function execute() { $model = new connectionUserModel(); $user = ConnectionHelper::userLogin(); $model->addFavorite((int) $user['id'], (int) Request::post('user')); return true; }
function execute() { $model = new connectionUserModel(); $model->logout(); Request::redirect('/'); exit; }
function getMessage($id) { $result = $this->where(array('id' => (int) $id))->fetchAll(); if (sizeof($result) == 0) { return false; } $value = $result[0]; $userModel = new connectionUserModel(); $messageModel = new connectionMessageModel(); $source = $messageModel->getFromId($value['message_id']); if (!$source) { return false; } $message = array(); $message['id'] = (int) $value['id']; $message['type'] = $value['type']; $message['from'] = $userModel->getFromId($source['from']); $message['to'] = $userModel->getFromId($source['to']); $message['date'] = $value['date']; $message['state'] = $source['state']; $message['text'] = $source['text']; $message['attachment'] = isset($source['attachment']) ? $source['attachment'] : array(); $message['str_date'] = date("d.m.Y h:i:s", $value['date']); return $message; }
function execute() { $user = ConnectionHelper::userLogin(); $model = new connectionUserModel(); $model->updateInfo($_POST, (int) $user['id'], $_FILES); Request::redirect('/profile/'); return 'success'; }
function execute() { $model = new connectionUserModel(); $login = ConnectionHelper::userLogin(); $user = array_map(function ($a) use($model) { $data = $model->getInfo($a['id']); return array('id' => $data['id'], 'key' => $data['id'], 'name' => $data['first_name'], 'status' => $data['online'] ? 'online' : 'offline', 'avatar' => '/photo/thumb/' . $data['avatar']['id'], 'nickname' => $data['first_name'], 'camera' => isset($data['camera']) && $data['camera'] == 1 ? $data['stream'] : false); }, $model->getContact($login['id'])); echo json_encode(array('contact' => $user)); exit; }
function execute() { $user_id = Request::get('user_id'); $model = new connectionUserModel(); $user = $model->getFromId((int) $user_id); if (!$user || $user['status'] != connectionUserModel::STATUS_PUBLISHED) { $this->showNotFound(); return; } $userInfo = $model->getInfo((int) $user['id']); $fieldsModel = new connectionFieldsModel(); $this->setSeoPage('profile'); return array('user_profile' => $userInfo, 'video' => connectionUserVideoModel::create()->where(array('user' => (int) $user_id, 'status' => 'published'))->sort('date', -1)->fetchAll(), 'fields' => array('info' => $fieldsModel->getGroupLocale('info', Language::getActiveLanguageISO(), true), 'interest' => $fieldsModel->getGroupLocale('interest', Language::getActiveLanguageISO(), true))); }
public function execute() { $user = connectionUserModel::create()->getInfo((int) Request::get('id')); $dialog = connectionMessageModel::create()->getDisctinctDialog((int) Request::get('id')); $this->smarty->assign('user', $user); $this->smarty->assign('dialogs', $dialog); }
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); } }
function execute() { $from = Request::post('from'); $to = Request::post('to'); $messages = connectionMessageModel::create()->getDialogMessages((int) $from, (int) $to); $this->smarty->assign('user', connectionUserModel::create()->getInfo((int) $from)); $this->smarty->assign('messages', $messages); }
function execute() { $user = ConnectionHelper::userLogin(); $response = array('result' => '[`Title profile change password success`]'); if (!$user || !Request::post('old_password') || !Request::post('new_password') || !Request::post('repeat_password')) { return array('result' => '[`Title profile change password error`]'); } if (md5(Request::post('old_password')) != $user['password'] || Request::post('new_password') != Request::post('repeat_password')) { return array('result' => '[`Title profile change password error`]'); } $model = new connectionUserModel(); $password = Request::post('new_password'); if (!Validator::Field($password, $model->regFields['password'])) { return array('result' => '[`Title profile change password error`]'); } $model->changePassword($user['id'], $password); return $response; }
function execute() { $user = connectionUserModel::create()->getInfo((int) Request::params('user_id')); if (!$user || !isset($user['avatar'])) { $this->notFound(); } $file = connectionUserPhotoModel::create()->getImageSize((int) $user['avatar']['id'], (int) Request::params('user_id'), (int) Request::params('photo_size')); $this->showFile($file); }
function execute() { $user = (int) Request::post('user'); $status = Request::post('status'); $model = new connectionUserModel(); $userInfo = $model->getInfo($user); $statusList = $model->getStatuses(); if (!$userInfo) { return array('status' => 'error', 'message' => '[`Title error invalid user`]'); } if (!isset($statusList[$status])) { return array('status' => 'error', 'message' => '[`Title error invalid status`]'); } if ($status != $userInfo['status']) { $model->changeStatus($user, $status); } return array('status' => 'success', 'title' => $statusList[$status]['title'], 'color' => $statusList[$status]['color']); }
function execute() { $user = ConnectionHelper::userLogin(); $model = connectionUserModel::create(); $favorite = array(); foreach ($user['favorite'] as $userID) { $favorite[] = $model->getInfo($userID); } return array('favorite' => $favorite); }
function execute() { $video = new ConnectionVideo(); if (!Request::files('Filedata')) { return array('status' => 'error'); } $result = $video->download('Filedata'); if (!$result) { return array('status' => 'error'); } $file = Request::files('Filedata'); $model = new connectionUserVideoModel(); $user = ConnectionHelper::userLogin(); $userModel = new connectionUserModel(); $videoID = $model->insert(array('file' => $result, 'status' => 'upload', 'user' => (int) $user['id'], 'date' => strtotime('now'), 'title' => htmlspecialchars($file[0]['name']))); $userModel->addHistory($user['id'], connectionUserModel::HISTORY_ADD_VIDEO, '', array('video' => (int) $videoID)); Route::exec('php ' . MAIN_DIR . DS . 'cli.php connection ConvertVideo cli ' . $videoID); return array('status' => 'success'); }
public function getDialogMessages($from, $to) { $message = $this->where(array('$or' => array(array('from' => (int) $from, 'to' => (int) $to), array('from' => (int) $to, 'to' => (int) $from))))->sort('date', -1)->fetchAll(); $userModel = connectionUserModel::create(); return array_map(function ($a) use($userModel) { $a['from'] = $userModel->getInfo((int) $a['from']); $a['to'] = $userModel->getInfo((int) $a['to']); return $a; }, $message); }
public function execute() { $where = array(); if (Request::get('status')) { $where['status'] = Request::get('status'); } $user = array_map(function ($a) { return connectionUserModel::create()->getInfo($a['id']); }, connectionUserModel::create()->where($where)->sort('id', -1)->fetchAll()); $this->smarty->assign('user', $user); }
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(); }
function execute() { $user = connectionUserModel::create()->getFromId(Request::post('user')); $key = 'field_' . (int) Request::post('field'); if (isset($user[$key])) { foreach ($user[$key] as $index => $value) { if ($value['file'] == Request::post('file')) { unset($user[$key][$index]); } } connectionUserModel::create()->where(array('id' => (int) $user['id']))->update(array($key => array_values($user[$key]))); } }
public function execute() { $model = connectionUserModel::create(); $user = $model->getInfo((int) Request::get('id')); $favorite = array(); if (isset($user['favorite'])) { foreach ($user['favorite'] as $userID) { $favorite[] = $model->getInfo((int) $userID); } } $this->smarty->assign('user', $user); $this->smarty->assign('favorite', $favorite); }
function execute() { $data = $_POST; $userID = (int) $data['id']; $update = array(); $user = connectionUserModel::create()->getInfo($userID); $fields = array('first_name', 'last_name', 'sex', 'country', 'email', 'birth_date'); $data['birth_date'] = (int) strtotime($data['birth_date']['year'] . '-' . $data['birth_date']['month'] . '-' . $data['birth_date']['day']); foreach ($fields as $field) { if (isset($data[$field]) && $user[$field] != $data[$field]) { $update[$field] = $data[$field]; } } connectionUserModel::create()->where(array('id' => (int) $userID))->update($update); }
function execute() { $userID = (int) Request::post('user'); $model = connectionUserModel::create(); $user = $model->where(array('id' => (int) $userID))->fetchOne(); if (isset($user['token'])) { Request::cookie('connection_user', $userID); Request::cookie('connection_token', $user['token']); } else { $now = (int) strtotime('now'); $token = md5($user['email'] . $user['date'] . $now); Request::cookie('connection_user', $userID); Request::cookie('connection_token', $token); $model->where(array('id' => $userID))->update(array('token' => $token)); } }
function execute() { if (Request::get('delete_attach') && Request::get('file')) { $user = ConnectionHelper::userLogin(); $key = 'field_' . (int) Request::get('delete_attach'); if (isset($user[$key])) { foreach ($user[$key] as $index => $value) { if ($value['file'] == Request::get('file')) { unset($user[$key][$index]); } } connectionUserModel::create()->where(array('id' => (int) $user['id']))->update(array($key => array_values($user[$key]))); } } $model = new connectionFieldsModel(); return array('fields' => $model->getGroupLocale('info', Language::getActiveLanguageISO())); }
public function execute() { $user = connectionUserModel::create()->getInfo((int) Request::post('id')); $activeLang = $user['lang']; $lang = array(); array_map(function ($a) use(&$lang, $activeLang) { if ($a['iso'] == $activeLang) { $lang = $a; } }, Language::getList()); $fieldModel = new connectionFieldsModel(); $fields = array(); $fields = array_merge($fieldModel->getGroupLocale('info', 'ru'), $fields); $fields = array_merge($fieldModel->getGroupLocale('interest', 'ru'), $fields); $this->smarty->assign('lang', $lang); $this->smarty->assign('user', $user); $this->smarty->assign('fields', $fields); }
public function onTick(&$timer) { $connected = $this->getConnectionList(); foreach ($connected as $connection) { if (!isset($connection->user_id)) { continue; } if (!isset($connection->date) || (int) strtotime('now') - $connection->date < 1) { continue; } $message = connectionUserEventModel::create()->getUnread($connection->user_id, (int) $connection->last_message, 1); if (!$message) { continue; } if ($message['type'] == connectionUserEventModel::TYPE_INVITE_CHAT) { $user = connectionUserModel::create()->getInfo($message['from']); $this->sendMessage($connection, json_encode(array('action' => 'event', 'data' => array('id' => $message['id'], 'type' => 'bublle', 'title' => 'Приглашение в чат', 'text' => '<a href="/user/' . $user['id'] . '/">' . $user['first_name'] . '</a> приглашает вас в чат для общения.', 'user' => $message['from'])))); } $connection->last_message = $message['id']; } }
function execute() { connectionUserModel::create()->updateActive((int) Request::post('user')); }
private function __construct() { $this->model = connectionUserModel::create(); $this->addFields(); }
function execute() { connectionUserModel::create()->confirmationEmail((int) Request::post('id')); }
function addPhoto($user_id, $file_name) { $temp_dir = ConnectionHelper::getPhotoDir($user_id); $resize = new Resize($temp_dir . $file_name); if (!$resize) { return; } foreach (array_keys($this->dir) as $value) { File::mkdir($temp_dir . $this->dir[$value] . DS); } if (!file_exists($temp_dir . $this->dir['orig'] . DS . $this->blockedImage)) { foreach (array_keys($this->dir) as $value) { copy(ConnectionHelper::getPhotoDir() . $this->blockedImage, $temp_dir . $this->dir[$value] . DS . $this->blockedImage); } } // Save original copy($temp_dir . $file_name, $temp_dir . $this->dir['orig'] . DS . $file_name); // Generate thumbnail $resize->resizeImage(150, 200, 'portrait'); $resize->saveImage($temp_dir . $this->dir['thumb'] . DS . $file_name, 100); // Generate photo $resize->resizeImage(320, 430, 'portrait'); $resize->saveImage($temp_dir . $this->dir['photo'] . DS . $file_name, 100); // Generate big $resize->resizeImage(800, 800); $resize->saveImage($temp_dir . $this->dir['big'] . DS . $file_name, 100); // Delete original file from root dir unlink($temp_dir . $file_name); $userInfo = connectionUserModel::create()->getInfo($user_id); $data = array('user_id' => (int) $user_id, 'file' => $file_name, 'date' => strtotime('now'), 'published' => $userInfo['status'] == connectionUserModel::STATUS_PUBLISHED ? false : true); if ($this->countPhoto($user_id) == 0) { $data['avatar'] = true; } $photo = $this->insert($data); connectionUserModel::create()->addHistory($user_id, connectionUserModel::HISTORY_ADD_PHOTO, '', array('photo' => (int) $photo)); if (isset($data['avatar']) && $data['avatar']) { connectionUserModel::create()->addHistory($user_id, connectionUserModel::HISTORY_SET_AVATAR, '', array('photo' => (int) $photo)); } }
function execute() { $id = (int) Request::post('id'); connectionUserModel::create()->remove($id); }