示例#1
0
 static function search($search_options = array(), $limit = -1, $offset = 0)
 {
     $sql_options = array('joins' => self::$joins, 'select' => self::$select);
     $device = new self();
     $devices = parent::search(self::$__CLASS__, $device->table, $search_options, $sql_options, $limit, $offset);
     return $devices;
 }
示例#2
0
 static function search($search_options = array(), $limit = -1, $offset = 0)
 {
     $sql_options = array('joins' => array(), 'select' => self::$select);
     $obj = new self();
     $groups = parent::search(self::$__CLASS__, $obj->table, $search_options, $sql_options, $limit, $offset);
     if (is_object($groups)) {
         $groups = array($groups);
     }
     $sorted_groups = array();
     foreach ($groups as $group) {
         $sorted_groups[$group->id] = $group;
         $sorted_groups[$group->id]->users = array();
     }
     $groups = $sorted_groups;
     if (empty($sorted_groups)) {
         return $sorted_groups;
     }
     $ci =& get_instance();
     $ci->db->select('u.*, g.*, gu.*')->from('groups as g')->join('groups_users gu', 'gu.group_id = g.id')->join('users u', 'u.id = gu.user_id')->where('u.is_active', true)->where_in('g.id', array_keys($sorted_groups))->where('g.is_active', true)->order_by('gu.order', 'asc');
     $groups_users = $ci->db->get()->result();
     foreach ($groups_users as $gu) {
         $groups[$gu->group_id]->users[$gu->user_id] = $gu;
     }
     if ($limit == 1 && count($groups) > 0) {
         $groups = current($groups);
     }
     return $groups;
 }
示例#3
0
 static function search($search_options = array(), $limit = -1, $offset = 0)
 {
     $sql_options = array();
     $instance = new self();
     $values = parent::search(self::$__CLASS__, $instance->table, $search_options, $sql_options, $limit, $offset);
     return $values;
 }
示例#4
0
 static function search($search_options = array(), $limit = -1, $offset = 0)
 {
     $sql_options = array();
     $include_numbers = true;
     if (isset($search_options['numbers'])) {
         $include_numbers = $search_options['numbers'];
         unset($search_options['numbers']);
     }
     $obj = new self();
     $flows = parent::search(self::$__CLASS__, $obj->table, $search_options, $sql_options, $limit, $offset);
     if (is_object($flows)) {
         $flows = array($flows);
     }
     if ($include_numbers) {
         try {
             $ci =& get_instance();
             $ci->load->model('vbx_incoming_numbers');
             $numbers = $ci->vbx_incoming_numbers->get_numbers();
             $flow_ids_to_numbers = array();
             foreach ($numbers as $num) {
                 if ($num->installed) {
                     $flow_ids_to_numbers[$num->flow_id][] = $num;
                 }
             }
             foreach ($flows as $flow) {
                 $flow->numbers = array();
                 $numbers_for_flow = array();
                 if (array_key_exists(intval($flow->id), $flow_ids_to_numbers)) {
                     foreach ($flow_ids_to_numbers[$flow->id] as $num) {
                         $numbers_for_flow[] = $num->phone;
                     }
                 }
                 $flow->numbers = $numbers_for_flow;
             }
         } catch (VBX_IncomingNumberException $e) {
             error_log($e->getMessage());
             $ci =& get_instance();
             $ci->session->set_flashdata('error', 'Unable to fetch incoming numbers from Twilio');
         }
     }
     if ($limit == 1 && count($flows) == 1) {
         $flows = $flows[0];
     }
     return $flows;
 }
示例#5
0
 static function search($search_options = array(), $limit = -1, $offset = 0)
 {
     $sql_options = array('joins' => self::$joins, 'select' => self::$select);
     $user = new VBX_User();
     $users = parent::search(self::$__CLASS__, $user->table, $search_options, $sql_options, $limit, $offset);
     if (empty($users)) {
         return $users;
     }
     if ($limit == 1) {
         $users = array($users);
     }
     $ci =& get_instance();
     $ci->load->model('vbx_device');
     foreach ($users as $i => $user) {
         $users[$i]->devices = VBX_Device::search(array('user_id' => $user->id), 100);
     }
     if ($limit == 1 && count($users) == 1) {
         return $users[0];
     }
     return $users;
 }
示例#6
0
 public static function search($search_options = array(), $limit = -1, $offset = 0)
 {
     $ci =& get_instance();
     $sql_options = array('joins' => self::$joins, 'select' => self::$select);
     $user = new VBX_User();
     $users = parent::search(self::$__CLASS__, $user->table, $search_options, $sql_options, $limit, $offset);
     if (empty($users)) {
         return $users;
     }
     if ($limit == 1) {
         $users = array($users);
     }
     $ci->load->model('vbx_device');
     foreach ($users as $i => $user) {
         $users[$i]->devices = VBX_Device::search(array('user_id' => $user->id), 100);
         if ($users[$i]->setting('online') && $users[$i]->setting('online') != 9) {
             array_unshift($users[$i]->devices, new VBX_Device((object) array('id' => 0, 'name' => 'client', 'value' => 'client:' . $users[$i]->id, 'sms' => 0, 'sequence' => -99, 'is_active' => 1, 'user_id' => $users[$i]->id)));
         }
     }
     if ($limit == 1 && count($users) == 1) {
         return $users[0];
     }
     return $users;
 }
示例#7
0
 public function get_by_number($number, $user_id)
 {
     $number = normalize_phone_to_E164($number);
     $search_opts = array('user_id' => intval($user_id), 'value' => normalize_phone_to_E164($number));
     $device = parent::search(self::$__CLASS__, $this->table, $search_opts, array(), 1);
     return $device;
 }
示例#8
0
 public static function search($search_options, $limit = -1, $offset = 0)
 {
     $setting_object = new self::$__CLASS__();
     $settings = parent::search(self::$__CLASS__, $setting_object->table, $search_options, array(), $limit, $offset);
     return !empty($settings) ? $settings : false;
 }