Ejemplo n.º 1
0
 /**
  *
  */
 private function load()
 {
     $table = new Db\Table\Conversations();
     $userTable = new Users();
     $view = new \Cunity\Messages\View\Conversation();
     $conversation = $table->loadConversationDetails($_GET['action']);
     $users = explode(",", $conversation['users']);
     if (!in_array($_SESSION['user']->userid, $users)) {
         $view = new PageNotFound();
     } else {
         unset($users[array_search($_SESSION['user']->userid, $users)]);
     }
     $table->markAsRead($_GET['action']);
     if (!empty($users)) {
         $conversation['users'] = $userTable->getSet($users, "u.userid", ["u.userid", "u.username", "u.name"])->toArray();
         $usernames = "";
         foreach ($conversation['users'] as $user) {
             $usernames .= $user['name'] . ',';
         }
         $view->setMetaData(["title" => substr($usernames, 0, -1)]);
     } else {
         $view->setMetaData(["title" => "Conversation"]);
     }
     $view->assign("conversation", $conversation);
     $view->show();
 }
Ejemplo n.º 2
0
 /**
  *
  */
 public function getAll()
 {
     $table = new Users();
     $result = $table->getSet([], "userid", ["username", "name", "userid"]);
     $view = new View($result !== null);
     $view->addData(["result" => $result->toArray()]);
     $view->sendResponse();
 }
Ejemplo n.º 3
0
 /**
  * @param int $userid
  * @return array|null
  */
 public function getFullFriendRequests($userid = 0)
 {
     $friends = $this->getFriendRequests($userid);
     if (!empty($friends)) {
         $users = new Users();
         return $users->getSet($friends, "u.userid", ["u.userid", "u.username", "u.name"])->toArray();
     }
     return null;
 }
Ejemplo n.º 4
0
 /**
  * @return bool
  */
 public function recreateSearchIndex()
 {
     $users = new Users();
     try {
         $index = \Zend_Search_Lucene::open($this->indexfile);
     } catch (\Zend_Search_Lucene_Exception $e) {
         $index = \Zend_Search_Lucene::create($this->indexfile);
     }
     $all = $users->getSet([]);
     foreach ($all as $user) {
         $doc = new \Zend_Search_Lucene_Document();
         $doc->addField(\Zend_Search_Lucene_Field::Text('username', $user->username));
         $doc->addField(\Zend_Search_Lucene_Field::unStored('name', $user->name));
         $index->addDocument($doc);
     }
     $index->optimize();
     return true;
 }