Пример #1
0
 /**
  * Method to return a list of users matching the filter criteria
  *
  * @author KnowledgeTree Team
  * @access public
  * @param string $filter
  * @param string $options
  * @return array $response The formatted response array
  */
 public function get_user_list($filter = NULL, $options = NULL)
 {
     $users = KTAPI_User::getList($filter, $options);
     if (PEAR::isError($users)) {
         $response['status_code'] = 1;
         $response['message'] = $users->getMessage();
         return $response;
     }
     foreach ($users as $user) {
         $results[] = $this->_get_user_details($user);
     }
     $response['message'] = '';
     $response['status_code'] = 0;
     $response['results'] = $results;
     return $response;
 }
Пример #2
0
 /**
  *
  * Test KTAPI_User getList(), getById(), getByName, getByUsername()
  *
  * @TODO KTAPI_User::getByEmail()
  */
 function testUsers()
 {
     // getList()
     $list = KTAPI_User::getList();
     $this->assertTrue(count($list) > 0);
     // getById()
     $user = KTAPI_User::getById(1);
     $this->assertTrue($user->Username == 'admin');
     $this->assertTrue($user->Name == 'Administrator');
     // getByName()
     $user = KTAPI_User::getByName('Anonymous');
     $this->assertTrue($user->Id == -2);
     // getByUsername()
     $user = KTAPI_User::getByUsername('admin');
     $this->assertTrue($user->Id == 1);
 }
Пример #3
0
 public function get_users_groups($params)
 {
     $kt =& $this->KT;
     $query = $params['query'];
     //$start=$params['start'];
     //$page=$params['page'];
     $results = KTAPI_User::getList('name LIKE "%' . $query . '%" AND id>0');
     $returnArray = array();
     if (count($results) > 0) {
         foreach ($results as $user) {
             $returnArray[] = array('emailid' => 'u_' . $user->getId(), 'name' => $user->getName(), 'to' => preg_replace('/(' . $query . ')/i', '<b>${0}</b>', $user->getName()));
         }
     }
     $groups = KTAPI_Group::getList('name LIKE "%' . $query . '%"');
     if (count($groups) > 0) {
         foreach ($groups as $group) {
             $returnArray[] = array('emailid' => 'g_' . $group->getId(), 'name' => $group->getName(), 'to' => preg_replace('/(' . $query . ')/i', '<b>${0}</b>', $group->getName()));
         }
     }
     $sendArray = array('emails' => $returnArray, 'metaData' => array('count' => count($finalArray), 'root' => 'emails', fields => array('name', 'to', 'emailid')));
     $this->setResponse($sendArray);
     return true;
 }