public function getAttachments(ConversationAttachmentFilter $filter, MysqlPager $pager = null)
 {
     $attachments = array();
     $sqlQuery = $filter->getSQL();
     if ($pager !== null) {
         $this->query = $pager->executePagedSQL($sqlQuery);
     } else {
         $this->query->exec($sqlQuery);
     }
     $attachmentRows = $this->query->fetchRecords();
     foreach ($attachmentRows as $attachmentRow) {
         array_push($attachments, $this->getAttachmentObject($attachmentRow));
     }
     return $attachments;
 }
예제 #2
0
 public static function getAllLanguages(MysqlPager $pager = null, $cacheMinutes = null)
 {
     $languages = array();
     $sql = MySqlDbManager::getQueryObject();
     $qb = new QueryBuilder();
     $qb->select(new Field('*'))->from(Tbl::get('TBL_LANGUAGES'));
     if ($pager !== null) {
         $sql = $pager->executePagedSQL($qb->getSQL(), $cacheMinutes);
     } else {
         $sql->exec($qb->getSQL(), $cacheMinutes);
     }
     while (($lang_data = $sql->fetchRecord()) != false) {
         $l = new Language();
         static::setData($lang_data, $l);
         $languages[] = $l;
     }
     return $languages;
 }
예제 #3
0
 public function getGroups(UserGroupsFilter $filter = null, MysqlPager $pager = null, $cacheMinutes = 0)
 {
     if ($filter === null) {
         $filter = new UserGroupsFilter();
     }
     if ($pager !== null) {
         $this->query = $pager->executePagedSQL($filter->getSQL(), $cacheMinutes);
     } else {
         $this->query->exec($filter->getSQL(), $cacheMinutes);
     }
     $groups = array();
     if ($this->query->countRecords()) {
         foreach ($this->query->fetchRecords() as $row) {
             array_push($groups, $this->getGroupObjectFromData($row));
         }
     }
     return $groups;
 }
예제 #4
0
 public function getTexts(TextsValuesFilter $filter = null, MysqlPager $pager = null, $cacheMinutes = null)
 {
     $texts = array();
     if ($filter == null) {
         $filter = new TextsValuesFilter();
     }
     $sqlQuery = $filter->getSQL();
     if ($pager !== null) {
         $this->query = $pager->executePagedSQL($sqlQuery, $cacheMinutes);
     } else {
         $this->query->exec($sqlQuery, $cacheMinutes);
     }
     if ($this->query->countRecords()) {
         foreach ($this->query->fetchRecords() as $data) {
             array_push($texts, $this->getTextValueObjectFromData($data, $cacheMinutes));
         }
     }
     return $texts;
 }
 public function getChatMessages(ChatMessageFilter $filter = null, MysqlPager $pager = null, $cacheMinutes = 0)
 {
     $chatMessages = array();
     if ($filter == null) {
         $filter = new ChatMessageFilter();
     }
     $sqlQuery = $filter->getSQL();
     if ($pager !== null) {
         $this->query = $pager->executePagedSQL($sqlQuery, $cacheMinutes);
     } else {
         $this->query->exec($sqlQuery, $cacheMinutes);
     }
     if ($this->query->countRecords()) {
         while (($messageRow = $this->query->fetchRecord()) != null) {
             array_push($chatMessages, $this->getChatMessage($messageRow));
         }
     }
     return $chatMessages;
 }
예제 #6
0
 /**
  * Get Users list according to filter and pager
  * 
  * @param UsersFilter $filter
  * @param MysqlPager $pager
  * @param integer $initObjects For ex. INIT_PROPERTIES | INIT_PERMISSIONS
  * @param integer $cacheMinutes
  */
 public function getUsersList(UsersFilter $filter = null, MysqlPager $pager = null, $initObjects = self::INIT_ALL, $cacheMinutes = 0, $cacheTag = null)
 {
     if ($filter == null) {
         $filter = new UsersFilter();
     }
     $sqlQuery = $filter->getSQL();
     $sql = MySqlDbManager::getQueryObject();
     if ($pager !== null) {
         $sql = $pager->executePagedSQL($sqlQuery, $cacheMinutes, null, $cacheTag);
     } else {
         $sql->exec($sqlQuery, $cacheMinutes, $cacheTag);
     }
     $users = array();
     if ($sql->countRecords()) {
         while (($userId = $sql->fetchField('id')) != false) {
             array_push($users, $this->getUserById($userId, $initObjects, $cacheMinutes, $cacheTag));
         }
     }
     return $users;
 }
예제 #7
0
 public function getChatSessionsLog(MysqlPager $pager = null, $myUserId = null, $cacheMinutes = 0)
 {
     $sessions = array();
     $qb = new QueryBuilder();
     $qb->select(new Field("*", "chat_sess_log"))->from(Tbl::get('TBL_CHAT_SESSIONS_LOG'), "chat_sess_log");
     if ($myUserId !== null) {
         $orClause = new Orx();
         $orClause->add($qb->expr()->equal(new Field("user1_id", "chat_sess_log"), $myUserId));
         $orClause->add($qb->expr()->equal(new Field("user2_id", "chat_sess_log"), $myUserId));
         $qb->andWhere($orClause);
     }
     $qb->orderBy(new Field("datetime", "chat_sess_log"), MySqlDatabase::ORDER_DESC);
     $sqlQuery = $qb->getSQL();
     if ($pager !== null) {
         $this->query = $pager->executePagedSQL($sqlQuery, $cacheMinutes);
     } else {
         $this->query->exec($sqlQuery, $cacheMinutes);
     }
     if ($this->query->countRecords()) {
         while (($sesLogRow = $this->query->fetchRecord()) != null) {
             $chatSession = new ChatSessionLog();
             $chatSession->user1 = ChatUser::getObject($sesLogRow['user1_id']);
             $chatSession->user2 = ChatUser::getObject($sesLogRow['user2_id']);
             $chatSession->id = $sesLogRow['id'];
             $chatSession->closedDate = $sesLogRow['datetime'];
             array_push($sessions, $chatSession);
         }
     }
     return $sessions;
 }
예제 #8
0
 /**
  * Get DB configs list
  * @param ConfigDBFilter $filter
  * @param MysqlPager $pager
  * @param Integer $cacheMinutes
  */
 public static function getDBConfigsList(ConfigDBFilter $filter = null, MysqlPager $pager = null, $cacheMinutes = 0)
 {
     if ($filter == null) {
         $filter = new ConfigDBFilter();
     }
     $sql = MySqlDbManager::getQueryObject();
     $sqlQuery = $filter->getSQL();
     if ($pager !== null) {
         $sql = $pager->executePagedSQL($sqlQuery, $cacheMinutes);
     } else {
         $sql->exec($sqlQuery, $cacheMinutes);
     }
     $configsDBArray = array();
     if ($sql->countRecords() > 0) {
         foreach ($sql->fetchRecords() as $row) {
             array_push($configsDBArray, static::getConfigDBFromData($row));
         }
     }
     return $configsDBArray;
 }
예제 #9
0
 public function getPhotos(UserPhotosFilter $filter, MysqlPager $pager = null, $cacheMinutes = null, $reduced = true)
 {
     if ($filter == null) {
         $filter = new UserPhotosFilter();
     }
     $sqlQuery = $filter->getSQL();
     if ($pager !== null) {
         $this->query = $pager->executePagedSQL($sqlQuery, $cacheMinutes);
     } else {
         $this->query->exec($sqlQuery, $cacheMinutes);
     }
     $userPhotos = array();
     if ($this->query->countRecords()) {
         while (($row = $this->query->fetchRecord()) != false) {
             array_push($userPhotos, static::getFilledUserPhoto($row, $reduced));
         }
     }
     return $userPhotos;
 }
 /**
  * Get array of Message objects
  *
  * @param MessageFilter $filter
  * @param MysqlPager $pager
  * @param bool $headersOnly
  * @return array
  */
 public function getMessages(MessageFilter $filter = null, MysqlPager $pager = null, $headersOnly = true, $cacheMinutes = 0)
 {
     if ($filter === null) {
         $filter = new MessageFilter($headersOnly);
     }
     $sqlQuery = $filter->getSQL();
     if ($pager !== null) {
         $this->query = $pager->executePagedSQL($sqlQuery, $cacheMinutes);
     } else {
         $this->query->exec($sqlQuery, $cacheMinutes);
     }
     $messages = array();
     if ($this->query->countRecords()) {
         foreach ($this->query->fetchRecords() as $message) {
             $messages[] = new Message();
             $i = count($messages) - 1;
             $messages[$i]->setId($message["id"]);
             $messages[$i]->read = $message["read"];
             $messages[$i]->sender = $message["sender"];
             $messages[$i]->subject = $message["subject"];
             $messages[$i]->date = date(DEFAULT_DATETIME_FORMAT, $message["date"]);
             $messages[$i]->deleted = $message["deleted"];
             $messages[$i]->trashed = $message["trashed"];
             $messages[$i]->receivers = $this->getReceivers($messages[$i], $cacheMinutes);
             if (!$headersOnly) {
                 $messages[$i]->message = $message["message"];
             }
         }
     }
     return $messages;
 }
예제 #11
0
 /**
  * Get all hosts
  *@return array Set of Host objects
  */
 public static function getAllHosts(MysqlPager $pager = null, $cacheMinutes = null)
 {
     $hosts = array();
     $sql = MySqlDbManager::getQueryObject();
     $qb = new QueryBuilder();
     $qb->select(new Field('*'))->from(Tbl::get('TBL_HOSTS', 'Host'));
     if ($pager !== null) {
         $sql = $pager->executePagedSQL($qb->getSQL(), $cacheMinutes);
     } else {
         $sql->exec($qb->getSQL(), $cacheMinutes);
     }
     while (($host_data = $sql->fetchRecord()) != false) {
         $h = new Host();
         Host::setData($host_data, $h);
         $hosts[] = $h;
     }
     return $hosts;
 }
예제 #12
0
 public function getConversationMessages(ConversationMessagesFilter $filter, MysqlPager $pager = null, $reduced = false)
 {
     $messages = array();
     $sqlQuery = $filter->getSQL();
     if ($pager !== null) {
         $this->query = $pager->executePagedSQL($sqlQuery);
     } else {
         $this->query->exec($sqlQuery);
     }
     $messageRows = $this->query->fetchRecords();
     foreach ($messageRows as $messageRow) {
         array_push($messages, $this->getConversationMessageObject($messageRow, $reduced));
     }
     return $messages;
 }
예제 #13
0
 /**
  * Get possible languages of given host
  *
  * @param Host $host
  * @return array set of Language objects
  */
 public static function getHostLanguages(Host $host, MysqlPager $pager = null, $cacheMinutes = null)
 {
     $sql = MySqlDbManager::getQueryObject();
     $languages = array();
     $qb = new QueryBuilder();
     $qb->select(new Field('*', 'l'))->from(Tbl::get("TBL_HOST_LANGUAGE"), 'hl')->leftJoin(Tbl::get("TBL_LANGUAGES", "Language"), 'l', $qb->expr()->equal(new Field('lang_id', 'hl'), new Field('id', 'l')))->where($qb->expr()->equal(new Field('host_id', 'hl'), $host->id));
     if ($pager !== null) {
         $sql = $pager->executePagedSQL($qb->getSQL(), $cacheMinutes);
     } else {
         $sql->exec($qb->getSQL(), $cacheMinutes);
     }
     $langs_data = $sql->fetchRecords();
     foreach ($langs_data as $lang_data) {
         $lang = new Language();
         Language::setData($lang_data, $lang);
         $languages[] = $lang;
     }
     return $languages;
 }
예제 #14
0
 /**
  * Searches through constants and values tables.
  *
  * Difference beetween search function and get_constants_list is the language parameter
  * and additional where parameter which allows to write mysql where statement for searching.
  * In get_constants_list if language is not specified then default language taken.
  *
  * @param array $types
  * @param Language $language
  * @param MysqlPager $pager
  * @param string $additional_where Mysql where clause
  *
  * @access public
  * @return array
  *
  */
 public function search(array $types = null, Language $language = null, MysqlPager $pager = null, $additional_where = null, $cacheMinutes = null)
 {
     $query = "SELECT lc.`id`, lc.`key`, lc.`type`,\n\t\t\t\t\t \tcv.`value`, cv.`lang_id`\n\t\t\t\t\tFROM `" . Tbl::get("TBL_CONSTANTS", "Constant") . "` lc\n\t\t\t\t\tJOIN `" . Tbl::get("TBL_VALUES", "Constant") . "` cv\n\t\t\t\t\tUSING (`id`)";
     if ($language !== null) {
         $query .= " WHERE cv.`lang_id` = '{$language->id}'";
     }
     if ($types !== null) {
         if ($language !== null) {
             $query .= " AND lc.`type` IN (" . implode(",", $types) . ")";
         } else {
             $query .= " WHERE lc.`type` IN (" . implode(",", $types) . ")";
         }
     }
     if ($additional_where !== null) {
         if ($types !== null or $language !== null) {
             $query .= " AND ( {$additional_where} )";
         } else {
             $query .= " WHERE {$additional_where}";
         }
     }
     $query .= " ORDER BY `id` DESC";
     if ($pager !== null) {
         $this->query = $pager->executePagedSQL($query, $cacheMinutes);
     } else {
         $this->query->exec($query, $cacheMinutes);
     }
     return $this->query->fetchRecords();
 }
예제 #15
0
 /**
  * Get user list
  *
  * @param UsersFilter $filter
  * @param MysqlPager $pager
  * @return array[User]
  */
 public function getUsersList(UsersFilter $filter = null, MysqlPager $pager = null, $cacheMinutes = 0)
 {
     $users = array();
     if ($filter == null) {
         $filter = new UsersFilter();
     }
     $sqlQuery = $filter->getSQL();
     if ($pager !== null) {
         $this->query = $pager->executePagedSQL($sqlQuery, $cacheMinutes);
     } else {
         $this->query->exec($sqlQuery, $cacheMinutes);
     }
     if ($this->query->countRecords()) {
         foreach ($this->query->fetchFields('id') as $user_id) {
             array_push($users, $this->getObjectById($user_id, $cacheMinutes));
         }
     }
     return $users;
 }