function getPhotoByID($photo_id)
 {
     $result = $this->where(array('id' => (int) $photo_id))->fetchAll();
     if (sizeof($result) == 0) {
         return false;
     }
     $photo = $result[0];
     $photo['blocked'] = false;
     if ($photo['avatar']) {
         return $photo;
     }
     if (ConnectionHelper::isLogin()) {
         $user = ConnectionHelper::userLogin();
         if ($user['id'] == $photo['user_id']) {
             return $photo;
         }
     }
     if (Request::get('backend')) {
         return $photo;
     }
     $index = sizeof($this->where(array('id' => array('$gt' => $photo['id']), 'user_id' => $photo['user_id'], 'published' => true))->sort('id', -1)->fetchAll()) + 1;
     if ($index > $this->showIndex) {
         $photo['file'] = $this->blockedImage;
         $photo['blocked'] = true;
     }
     return $photo;
 }
Exemplo n.º 2
0
 public static function before()
 {
     if (Request::get('lang')) {
         $langList = array_map(function ($a) {
             return $a['iso'];
         }, Language::getList());
         $lang = strtolower(Request::get('lang'));
         if (in_array($lang, $langList)) {
             Request::cookie(self::$langKeyCookie, $lang);
         }
         Request::redirect(Request::url(array('lang' => '')));
     }
     if (Request::get('confirm_email')) {
         connectionUserModel::create()->confirmationEmailLink(Request::get('confirm_email'));
         Request::get('email_confirm', true);
     }
     if (ConnectionHelper::isLogin() && Request::get('status') && Request::get('status') == connectionUserModel::STATUS_MODERATE) {
         $userLogin = ConnectionHelper::userLogin();
         connectionUserModel::create()->changeStatus($userLogin['id'], connectionUserModel::STATUS_MODERATE, 'Пользователь отправил профиль на проверку.');
         Request::redirect('/profile/');
     }
     if (Request::get('auth') && !ConnectionHelper::isLogin()) {
         Request::redirect('/login/');
     }
     if (ConnectionHelper::isLogin()) {
         ConnectionHelper::updateUserActive();
     }
 }
 function execute()
 {
     if (ConnectionHelper::isLogin()) {
         Request::redirect('/profile/');
     }
     $this->setSeoPage('login');
     if (!Request::post('login')) {
         return;
     }
     $model = new connectionUserModel();
     $result = $model->login(array('login' => Request::post('login'), 'password' => Request::post('password')));
     if ($result) {
         Request::redirect('/profile/');
     } else {
         Request::get('error_login', true);
     }
 }
 public function add($feedback)
 {
     $from = null;
     $data = array();
     if (ConnectionHelper::isLogin()) {
         $user = ConnectionHelper::userLogin();
         $from = (int) $user['id'];
     } else {
         $ticket = array('subject' => htmlspecialchars($feedback['subject']), 'message' => nl2br(htmlspecialchars($feedback['message'])));
         connectionNotificationModel::run(connectionNotificationModel::EVENT_NEW_FEEDBACK_ANONIMUS, array('user' => array('name' => htmlspecialchars($feedback['name']), 'email' => htmlspecialchars($feedback['email'])), 'ticket' => $ticket), Language::getActiveLanguageISO());
         return $ticket;
     }
     foreach ($this->field as $field) {
         if (!isset($feedback) || empty($feedback)) {
             return false;
         } else {
             $data[$field] = htmlspecialchars($feedback[$field]);
         }
     }
     $data['message'] = nl2br($data['message']);
     if (is_null($from)) {
         if (!isset($feedback['email']) || empty($feedback['email']) || !filter_var($feedback['email'], FILTER_VALIDATE_EMAIL)) {
             return false;
         }
         if (!isset($feedback['name']) || empty($feedback['name'])) {
             return false;
         }
         $data['contact'] = array('email' => htmlspecialchars($feedback['email']), 'name' => htmlspecialchars($feedback['name']));
     } else {
         $data['contact'] = $from;
     }
     $data['status'] = self::FEEDBACK_STATUS_NEW;
     $data['date'] = strtotime('now');
     $data['url'] = md5($data['date'] . $data['subject'] . uniqid());
     $data['last_action'] = 'user';
     if (isset($feedback['attachment']) && is_array($feedback['attachment'])) {
         $data['attachment'] = $feedback['attachment'];
     }
     $id = $this->insert($data);
     $data['id'] = $id;
     connectionNotificationModel::run(connectionNotificationModel::EVENT_NEW_FEEDBACK, array('user' => ConnectionHelper::userLogin(), 'ticket' => $data), Language::getActiveLanguageISO());
     return $id;
 }
 function execute()
 {
     $search = Request::post('search');
     $searchUser = ConnectionSearchUser::create();
     $saveTemp = false;
     $user = ConnectionHelper::userLogin();
     if (ConnectionHelper::isLogin() && !$search) {
         $saveTemp = Temp::get('user_' . $user['id'] . '_advanced_filter');
         $saveTemp = $saveTemp ? unserialize($saveTemp) : false;
     }
     if (!$saveTemp) {
         $saveTemp = array('query' => $search, 'filter' => $searchUser->filterSearchField($search));
         if (ConnectionHelper::isLogin()) {
             Temp::set('user_' . $user['id'] . '_advanced_filter', serialize($saveTemp));
         }
     }
     $this->setSeoPage('advanced_search');
     if ($search || true) {
         print_r($saveTemp);
     }
 }
 function execute()
 {
     if (ConnectionHelper::isLogin()) {
         Request::redirect('/profile/');
     }
     $this->setSeoPage('registration');
     if (!Request::post('registration')) {
         return;
     }
     $model = new connectionUserModel();
     $registration = $model->registration(array('first_name' => Request::post('first_name'), 'last_name' => Request::post('last_name'), 'email' => Request::post('email'), 'password' => Request::post('password'), 'sex' => Request::post('sex'), 'birth_day' => (int) Request::post('birth_day'), 'birth_month' => (int) Request::post('birth_month'), 'birth_year' => (int) Request::post('birth_year'), 'country' => (int) Request::post('country')));
     $status = 'error';
     $message = '[`Title success registration`]';
     if ($registration) {
         $status = 'success';
     } else {
         $message = '[`Title error in registration`]';
     }
     echo json_encode(array('status' => $status, 'message' => $message));
     $this->endAction();
 }
Exemplo n.º 7
0
 public function getOppositeSex()
 {
     if (!ConnectionHelper::isLogin()) {
         $sex = 'female';
     } else {
         $user = ConnectionHelper::userLogin();
         if ($user['sex'] == 'female') {
             $sex = 'male';
         } else {
             $sex = 'female';
         }
     }
     return $sex;
 }