function set($user_id, $interest_id) { if ($user_id > 0 && $interest_id > 0) { $count = (int) Project::getDatabase()->selectCell("SELECT count(*) FROM " . $this->_table . " WHERE user_id=?d AND interest_id=?d", (int) $user_id, (int) $interest_id); if ($count <= 0) { $interest_model = new InterestsModel(); if ($interest_model->exists($interest_id)) { Project::getDatabase()->query("INSERT INTO " . $this->_table . " SET user_id = ?d, interest_id = ?d", $user_id, $interest_id); $interest_model->increaseCounter($interest_id); } } } }
/** * Action: Поиск по интересам */ public function SearchByInterestAction() { $v_request = Project::getRequest(); $v_session = Project::getSession(); $data = array(); $this->_BaseSiteData($data); $data['action'] = 'SearchByInterest'; $v_id_interest = (int) $v_request->getKeyByNumber(0); $v_n_page = (int) $v_request->getKeyByNumber(1); $v_model = new InterestsModel(); $data['interests_list'] = $v_model->loadAll(); if ($v_id_interest > 0) { $this->_getData($data, 'SearchByInterest', $v_n_page, $v_id_interest); } $this->_view->assign('tab_list', TabController::getSearchUserTabs(false, true)); // Show tabs $this->_view->assign('counter_users', $this->counter_users); $this->_view->Search_ByInterest($data); $this->_view->parse(); }
public function SaveprofileAction() { $this->checkOfficeAccess(); $request = Project::getRequest(); if ($request->flash) { $user_model = Project::getUser()->getShowedUser(); if ($request->mood) { $user_model->mood = $request->mood; } if ($request->status) { $user_model->status = $request->status; } if ($request->about) { $user_model->about = $request->about; } $user_model->save(); } else { if ($this->ValidateSaveAction() && $request->register) { $user_model = Project::getUser()->getShowedUser(); $old_rate_nm = $user_model->getUserRateNMByRegistrationData($user_model->id); if ($request->pwd) { $user_model->salt = AppCrypt::generateSalt(); $user_model->pass = AppCrypt::getHash($request->pwd, $user_model->salt); } $user_model->first_name = $request->name; $user_model->last_name = $request->surname; $user_model->middle_name = $request->father_name; $user_model->birth_date = $request->year . "-" . $request->month . "-" . $request->day; $user_model->gender = (int) $request->gender; $user_model->marital_status = $request->marital_status; $user_model->icq = $request->icq; $user_model->website = $request->website; $user_model->phone = $request->phone; $user_model->mobile_phone = $request->mobile_phone; $user_model->about = $request->about; $user_model->interest = $request->interest; $user_model->books = $request->books; $user_model->films = $request->films; $user_model->musicians = $request->musicians; $user_model->country_id = (int) $request->country; $user_model->state_id = (int) $request->state; $user_model->city_id = (int) $request->city; $user_model->skype = $request->skype; $user_model->im = $request->im; // Setting params $user_model->save(); //print_r($user); $separator = ","; if (strlen($request->interest)) { $interest_list = explode($separator, $request->interest); foreach ($interest_list as $interest) { $interest = trim($interest); if (strlen($interest)) { $interest_model = new InterestsModel(); $interest_id = $interest_model->set($interest); $user_interest_model = new UserInterestsModel(); $user_interest_model->set($user_id, $interest_id); } } } $new_rate_nm = $user_model->getUserRateNMByRegistrationData($user_model->id); if ($new_rate_nm['nm'] - $old_rate_nm['nm'] != 0) { $user_model->changeUserMoney($user_model->id, 0, $new_rate_nm['nm'] - $old_rate_nm['nm'], 'Изменение регистрационных данных'); } $user_model->changeUserRate($user_model->id, $new_rate_nm['rate'] - $old_rate_nm['rate']); } } $this->ProfileEditAction(); /* $this->model->load($this->view->userData['id']); $this->model->set("email", $this->params['email']); $this->model->set("last_name", $this->params['last_name']); $this->model->set("first_name", $this->params['first_name']); $this->model->set("middle_name", $this->params['middle_name']); $this->model->set("birth_date", $this->params['birth_year'].'-'.$this->params['birth_month'].'-'.$this->params['birth_day']); $this->model->set("country_id", $this->params['country_id']); $this->model->set("city", ucfirst($this->params['city'])); $this->model->set("gender", $this->params['gender']); $this->model->set("about", $this->params['about']); $this->model->set("interest", $this->params['interest']); $this->model->update(); $this->model->resetSql(); $this->model->where('users.id="'.$this->view->userData['id'].'"'); $this->model->join('user_types', "user_types.id=users.user_type_id"); $userData = $this->model->getOne(); $session = getManager('CSession'); $userData = $session->write('user', serialize($userData)); $router = getManager('CRouter'); $router->redirect($router->createUrl("User", "Viewprofile")); */ }