| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- class admin_profiles_model extends Model {
-
-
- public function getProfiles() {
- $result = $this->query("SELECT * FROM azonics_profiles "
- . "INNER JOIN azonics_users ON profile_uid=user_id WHERE "
- . "profile_status<>'0' "
- . "ORDER BY profile_create_date DESC;");
- return $result;
- }
-
-
- public function searchProfiles($keyword='') {
- $keyword = $this->escapeString($keyword);
-
- $result = $this->query("SELECT * FROM azonics_profiles INNER JOIN azonics_users ON profile_uid=user_id WHERE "
- . "profile_status<>'0' AND "
- . "profile_name LIKE '%".$keyword."%' OR "
- . "profile_description LIKE '%".$keyword."%' OR "
- . "profile_tags LIKE '%".$keyword."%' "
- . "ORDER BY profile_create_date DESC;");
-
- return $result;
- }
-
-
- public function loadProfile() {
- $profile_id = $this->escapeString($_REQUEST['id']);
- $row = $this->query("select * from azonics_profiles where profile_id='".$profile_id."';");
- return $row[0];
- }
-
-
- public function loadUserProfile() {
- $profile_id = $this->escapeString($_REQUEST['id']);
- $row = $this->query("select * from azonics_profiles where profile_id='".$profile_id."';");
- $result = $this->query("select * from azonics_users where user_id='".$row[0]->profile_uid."';");
- return $result[0];
- }
-
-
- public function getUserDesigns() {
- $profile_id = $this->escapeString($_REQUEST['id']);
- $row = $this->query("select * from azonics_profiles where profile_id='".$profile_id."';");
- $result = $this->query("select * from azonics_profiles, azonics_users where profile_status<>'0' and profile_uid='".$row[0]->profile_uid."' and user_id=profile_uid order by profile_create_date desc;");
- return $result;
- }
-
-
- public function saveProfile() {
- $data = $this->escapeArray($_REQUEST);
-
- if ($data['profile_id']!='') {
- if ($data['tempContainer']!='') {
- $fname = Image_helper::saveImageToFile('designs',$data['tempContainer']);
- $this->execute("update azonics_profiles set profile_main_image='".$fname."' where profile_id='".$data['profile_id']."';");
- }
-
- $this->execute("update azonics_profiles set "
- . "profile_uid='".$data['profile_uid']."', "
- . "profile_name='".$data['profile_name']."', "
- . "profile_description='".$data['profile_description']."', "
- . "profile_category='".$data['profile_category']."', "
- . "profile_tags='".$data['profile_tags']."', "
- . "profile_price='".$data['profile_price']."', "
- . "profile_actual_price='".$data['profile_actual_price']."' where profile_id='".$data['profile_id']."';");
-
- return $data['profile_id'];
- }
- else {
- if ($data['tempContainer']!='') {
- $fname = Image_helper::saveImageToFile('designs',$data['tempContainer']);
- }
- $this->execute("insert into azonics_profiles set "
- . "profile_uid='".$data['profile_uid']."', "
- . "profile_status='1', "
- . "profile_name='".$data['profile_name']."', "
- . "profile_description='".$data['profile_description']."', "
- . "profile_main_image='".$fname."', "
- . "profile_category='".$data['profile_category']."', "
- . "profile_tags='".$data['profile_tags']."', "
- . "profile_price='".$data['profile_price']."', "
- . "profile_actual_price='".$data['profile_actual_price']."';");
-
- return $this->getLastInsertID();
- }
- }
-
-
- public function deleteProfile() {
- $profile_id = $this->escapeString($_REQUEST['id']);
- $this->execute("update azonics_profiles set profile_status='0' where profile_id='".$profile_id."';");
- return true;
- }
-
-
- public function setProfileStatus() {
- $profile_id = $this->escapeString($_REQUEST['id']);
- $profile_status = $this->escapeString($_REQUEST['status']);
- $this->execute("update azonics_profiles set profile_status='".$profile_status."' where profile_id='".$profile_id."';");
- return true;
- }
-
-
- }
|