예제 #1
0
 public function render($tpl_file = '')
 {
     if (sizeof($tpl_file) > 0) {
         $this->smarty_object = $tpl_file;
     }
     return $this->smarty_object->fetch();
 }
예제 #2
0
 public function action_message()
 {
     \Assets::js('page', base_UI . 'js/pages/chat.js');
     $user_id = \Registry::getCurrentUser()->id;
     $receiver_id = $this->request->param('id');
     $receiver = \Model\User::model()->findByPk($receiver_id);
     $criteria = new \DBCriteria();
     $criteria->condition = ' ( session = "' . $receiver_id . "#" . $user_id . '" ) OR
     ( session = "' . $user_id . "#" . $receiver_id . '" ) ';
     $session = \Model\Chat::model()->find($criteria);
     $short_history = $this->userCustomHistory($user_id, $receiver_id, $session->session, $this->user_messages);
     $this->template->assign(['short_history' => $short_history, 'session' => $session->session, 'receiver' => $receiver]);
     $this->response->body($this->template->fetch('chat/message.tpl'));
 }
예제 #3
0
 public function action_index()
 {
     $user_id = \Registry::getCurrentUser()->iduser;
     $category = $this->request->post('category');
     if (!($search = \Utils\Protect::Validate($this->request->post('search'), 'string'))) {
         $search = \Utils\Protect::Validate($this->request->query('search'), 'string');
     }
     if (!empty($search)) {
         switch ($category) {
             case '1':
                 $this->findAll($search);
                 break;
             default:
                 $this->findAll($search);
                 $category = 1;
         }
     }
     $this->template->assign(['category' => $category, 'search' => $search]);
     $this->response->body($this->template->fetch('search/results.tpl'));
 }
예제 #4
0
 /**
  * gets info from social network. If profile already linked to user authenticates, otherwise create new user instance
  * @throws \Kohana_Database_Exception
  */
 public function action_uloginAuth()
 {
     $s = file_get_contents('http://ulogin.ru/token.php?token=' . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']);
     $user = json_decode($s, true);
     if (strlen($user['error']) > 0) {
         $this->response->body($this->template->fetch('internal.tpl'));
         return;
     }
     $condition = (new \DBCriteria())->addColumnCondition(['uid' => $user['uid'], 'network' => $user['network']]);
     /** @var $ULogin \Model\ULogin */
     $ULogin = \Model\ULogin::model()->with('user')->find($condition);
     if (null === $ULogin) {
         \Session::instance()->set('UloginData', $user);
         $user['bdate'] = date('Y-m-d', strtotime($user['bdate']));
         $user_model = new User();
         $user_model->login = $user['login'];
         $user_model->first_name = $user['first_name'];
         $user_model->email = $user['email'];
         $access_level = new \Auth\Access();
         $access_level->set(\Auth\Access::User_Login);
         $user_model->access_level = $access_level->getValue();
         if (!$user_model->save()) {
             throw new \Kohana_Database_Exception('Unable to save user model');
         }
         $ULogin = new ULogin();
         $ULogin->network = $user['network'];
         $ULogin->uid = $user['uid'];
         $ULogin->profile = $user['identity'];
         $ULogin->user_id = $user_model->id;
         if (!$ULogin->save()) {
             $this->response->body('Unable to save social network data');
         }
         \Auth\Base::startSession($ULogin['user']);
         $this->redirect(\Route::get('pages')->uri(['controller' => 'Map', 'action' => 'Add']));
     } else {
         \Auth\Base::startSession($ULogin['user']);
         $this->redirect(\Route::get('pages')->uri(['controller' => 'Map', 'action' => 'Add']));
     }
 }