Exemple #1
0
 public function getLatestSuccessUser($offset, $limit)
 {
     $dbManager = Db::getInstance();
     $statement = $dbManager->prepare(self::GET_LATEST_USER);
     $statement->bindValue(':offset', $offset, PDO::PARAM_INT);
     $statement->bindValue(':limit', $limit, PDO::PARAM_INT);
     if (!$statement->execute()) {
         return null;
     }
     $result = $statement->fetchAll(PDO::FETCH_ASSOC);
     if (!$result) {
         return null;
     }
     $uidList = [];
     foreach ($result as $row) {
         $uidList[] = $row['uid'];
     }
     return $uidList;
 }
 public function getUserRosterGroup($uid)
 {
     if (!$uid) {
         $this->setLastError(Code::FAIL_GROUP_ROSTER_NOT_EXISTS, 'uid is empty');
         return null;
     }
     $dbManager = Db::getInstance();
     $statement = $dbManager->prepare(self::GET_USER_ROSTER_GROUP);
     if (!$statement->execute([$uid])) {
         $this->setLastError(Code::FAIL_DATABASE_ERROR, 'get roster groups failed');
         return null;
     }
     $list = $statement->fetchAll(PDO::FETCH_CLASS, 'minions\\model\\RosterGroup');
     return $this->addDefaultGroupToList($list, $this->getUserDefaultGroup($uid));
 }
Exemple #3
0
 public function _initDb()
 {
     Db::getInstance()->initConfig(\Yaf\Application::app()->getConfig()->get('application')->get('database'));
 }
Exemple #4
0
 public function getGroupUserArray(GroupUser $model)
 {
     $dbManager = Db::getInstance();
     $statement = $dbManager->prepare(self::GET_GROUP_USER);
     if (!$statement->execute([$model->gid, $model->uid])) {
         return new ApiResponse(Code::FAIL_DATABASE_ERROR, 'execute to get group user failed');
     }
     return $statement->fetch(PDO::FETCH_ASSOC);
 }
Exemple #5
0
 public function moveGroup(Roster $model, RosterGroup $from, RosterGroup $to)
 {
     if (!$model->uid) {
         return new ApiResponse(Code::FAIL_USER_NOT_EXISTS, 'uid is empty');
     }
     if ($from->id == $to->id) {
         return new ApiResponse(Code::FAIL_MOVE_GROUP, 'from is same as to');
     }
     $dbManager = Db::getInstance();
     $statement = $dbManager->prepare(self::MOVE_GROUP);
     if (!$statement->execute([$to->id, $model->uid, $from->id])) {
         return new ApiResponse(Code::FAIL_DATABASE_ERROR, 'move group failed');
     }
     return null;
 }
Exemple #6
0
 public function getHotGroups(Group $model)
 {
     if (!$model->checkType()) {
         $this->setLastError(Code::FAIL_GROUP_TYPE, 'type is error');
         return null;
     }
     $dbManager = Db::getInstance();
     $statement = $dbManager->prepare(self::GET_HOT_GROUPS);
     if (!$statement->execute([$model->type])) {
         $this->setLastError(Code::FAIL_DATABASE_ERROR, 'get hot groups failed');
         return null;
     }
     return $statement->fetchAll(PDO::FETCH_CLASS, 'minions\\model\\Group');
 }
Exemple #7
0
<?php

use jegarn\cache\Cache;
use minions\db\Db;
define('PIC_HOST', '/upload/');
define('TEST_HOST', 'http://192.168.199.243');
require __DIR__ . '/../../examples/web-chat-system/src/bootstrap.php';
require __DIR__ . '/../../sdk/php/src/jegarn.php';
require __DIR__ . '/AppTestBase.php';
$config = new \Yaf\Config\Ini(__DIR__ . '/../../examples/web-chat-system/config/application.ini', 'develop');
Db::getInstance()->initConfig($config->get('application')->get('database'));
Cache::getInstance()->initConfig($config->get('application')->get('cache'));
Exemple #8
0
 public function removeUser(User $model)
 {
     $dbManager = Db::getInstance();
     if ($model->id) {
         $statement = $dbManager->prepare(self::REMOVE_USER_BY_UID);
         $statement->bindValue(1, $model->id, PDO::PARAM_INT);
         // this add to get user's user name
         if (!$model->username) {
             if ($resp = $this->getUser($model)) {
                 return $resp;
             }
         }
     } else {
         if ($model->username) {
             $statement = $dbManager->prepare(self::REMOVE_USER_BY_USERNAME);
             $statement->bindValue(1, $model->username, PDO::PARAM_STR);
         } else {
             return new ApiResponse(Code::FAIL_USER_UID_OR_NAME_NOT_EXISTS, null);
         }
     }
     if (!$statement->execute()) {
         return new ApiResponse(Code::FAIL_DATABASE_ERROR, null);
     }
     JegarnUtil::removeUser($model->username);
     return null;
 }