Beispiel #1
0
 function retrieve_keys($phone_type, $variables = array())
 {
     if ($this->_user_id > 0) {
         $this->_keys = gs_keys_get_by_user($this->_user_name, $phone_type);
     } else {
         $this->_keys = gs_keys_get_by_profile($this->_profile_id, $phone_type);
     }
     if (isGsError($this->_keys) || !is_array($this->_keys)) {
         gs_log(GS_LOG_NOTICE, isGsError($this->_keys) ? $this->_keys->getMsg() : 'Failed to get softkeys');
         $this->_keys = null;
         return false;
     }
     if (is_array($variables) && count($variables) > 0) {
         $search = array_keys($variables);
         $replace = array_values($variables);
         unset($variables);
         foreach ($this->_keys as $key_name => $key_defs) {
             foreach ($key_defs as $inh_slf => $key_def) {
                 if ($this->_keys[$key_name][$inh_slf]['data'] != '') {
                     $this->_keys[$key_name][$inh_slf]['data'] = str_replace($search, $replace, $key_def['data']);
                 }
             }
         }
     }
     return true;
 }
Beispiel #2
0
 function retrieve_keys($phone_type, $variables = array())
 {
     if ($this->_user_id > 0) {
         $this->_keys = gs_keys_get_by_user($this->_user_name, $phone_type);
     } else {
         $this->_keys = gs_keys_get_by_profile($this->_profile_id, $phone_type);
     }
     if (isGsError($this->_keys) || !is_array($this->_keys)) {
         gs_log(GS_LOG_NOTICE, isGsError($this->_keys) ? $this->_keys->getMsg() : 'Failed to get softkeys');
         $this->_keys = null;
         return false;
     }
     if (is_array($variables) && count($variables) > 0) {
         $search = array_keys($variables);
         $replace = array_values($variables);
         unset($variables);
         foreach ($this->_keys as $key_name => $key_defs) {
             foreach ($key_defs as $inh_slf => $key_def) {
                 if ($this->_keys[$key_name][$inh_slf]['data'] != '') {
                     $this->_keys[$key_name][$inh_slf]['data'] = str_replace($search, $replace, $key_def['data']);
                 }
             }
         }
     }
     /*
     # get the pickup groups
     #
     $pgroups = array();
     $rs = $this->_db->execute(
     	'SELECT DISTINCT(`p`.`id`) `id`, `p`.`title` '.
     	'FROM '.
     		'`pickupgroups_users` `pu` JOIN '.
     		'`pickupgroups` `p` ON (`p`.`id`=`pu`.`group_id`) '.
     	'WHERE `pu`.`user_id`='. ((int)$this->_user_id) .' '.
     	'ORDER BY `p`.`id` '.
     	'LIMIT 10' );
     while ($r = $rs->fetchRow()) {
     	$pgroups[$r['id']] = $r['title'];
     }
     */
     # fix some key definitions
     #
     /*
     foreach ($this->_keys as $key_name => $key_defs) {
     foreach ($key_defs as $inh_slf => $key_def) {
     	
     	# make sure the user does not set keys for pickup groups
     	# which he/she does not belong to
     	#
     	if (in_array($key_def['function'], array('dest', 'blf'), true)     //FIXME for Siemens
     	&&  subStr($key_def['data'],0,2) === '*8') {
     		if (preg_match('/(?:^|[:])\*8\*([0-9]+)/S', $key_def['data'], $m)) {
     			$pgrpid = (int)lTrim($m[1],'0');
     		} else {
     			$pgrpid = 0;
     		}
     		if ($pgrpid > 0) {
     			if (! array_key_exists($pgrpid, $pgroups))
     				$pgrpid = 0;
     		}
     		if ($pgrpid < 1) {
     			unset($this->_keys[$key_name][$inh_slf]);
     		} else {
     			$this->_keys[$key_name][$inh_slf]['data' ] =
     				'*8*'. str_pad($pgrpid,5,'0',STR_PAD_LEFT);
     			$title = mb_subStr(trim($pgroups[$pgrpid]),0,20);
     			$this->_keys[$key_name][$inh_slf]['label'] =
     				'Grp. '. ($title != '' ? $title : $pgrpid);
     			unset($pgroups[$pgrpid]);
     		}
     	}
     }
     }
     */
     //FIXME
     # find free keys for the remaining pickup groups (if any)
     #
     //FIXME ?
     return true;
 }