public static function from_object($obj)
 {
     $ret = copy_new($obj, "DataTableColumn");
     if (isset($ret->data) && $ret->data !== null) {
         if (strpos($ret->data, '.') !== false) {
             // Replace the . to _ to avoid the bug
             $ret->dataCol = $ret->data;
             $ret->data = str_replace('.', '_', $ret->data);
         }
     }
     if (isset($ret->refer) && $ret->refer !== null) {
         if (strpos($ret->refer, '.') !== false) {
             // Replace the . to _ to avoid the bug
             $ret->referCol = $ret->refer;
             $ret->refer = str_replace('.', '_', $ret->refer);
         }
     }
     if (isset($ret->action)) {
         $ret->action = site_url($ret->action);
         if (isset($ret->toggle)) {
             $ret->render = 'datatable_toggle_column';
         } else {
             $ret->render = 'datatable_action_column';
         }
     } else {
         if (isset($ret->refer)) {
             $ret->render = 'datatable_action_column';
         }
     }
     return $ret;
 }
 public function testCopyObject()
 {
     $obj = array('name' => 'Jack', 'age' => 30, 'just.test' => 1);
     $dummy = copy_object($obj, new DummyExample());
     $this->assertEquals($obj['name'], $dummy->name);
     $dummy = copy_new($obj, 'DummyExample');
     $this->assertEquals($obj['name'], $dummy->name);
     $this->assertEquals($obj['just.test'], $dummy->just_test);
 }
示例#3
0
 public function addAlert($alert)
 {
     if (!isset($alert)) {
         return;
     }
     $alerts = $this->getAlerts();
     $alerts[] = copy_new($alert);
     $CI =& get_instance();
     $CI->session->set_userdata('alerts', $alerts);
 }
 public function getTransport($data)
 {
     ci_log('tttt', $data);
     $this->transport = copy_new($data, 'DataTableTransport');
     if (isset($this->model->joins)) {
         $this->transport->joins = $this->model->joins;
     }
     return $this->transport;
 }
示例#5
0
 private function _build_menu($user_id)
 {
     return array('account_summary' => copy_new(array('controller' => 'Account', 'method' => 'summary_details', 'args' => $user_id, 'label' => lang('Account Summary')), 'Action'), 'change_password' => copy_new(array('controller' => 'Account', 'method' => 'change_password', 'args' => $user_id, 'label' => lang('Change Password')), 'Action'), 'reset_password' => copy_new(array('controller' => 'Account', 'method' => 'reset_password', 'args' => $user_id, 'label' => lang('Reset Password')), 'Action'));
 }
示例#6
0
 public function show($name, $begin = null, $end = null, $args = array(), $mode = 'day')
 {
     $this->name = $name;
     $path = FCPATH . APPPATH . 'config/report/' . $name . '.json';
     $config = null;
     if (file_exists($path)) {
         $config = json_decode(file_get_contents($path));
         if (!isset($config->chart) || !isset($config->chart->renderTo)) {
             $config->chart->renderTo = $name;
         }
     }
     if ($config == null) {
         show_error("Report {$name}'s configuration is not found!");
         return;
     }
     $config->begin = $begin;
     $config->end = $end;
     $config->mode = $mode;
     $config->name = $name;
     $config->args = $args;
     $this->model = copy_new($config, 'Report_Model');
     return $this->model->show();
 }
 public function buildInterceptorConfig($class)
 {
     $parent_class = get_parent_class($class);
     if ($parent_class) {
         $config = $this->buildInterceptorConfig($parent_class);
         // Get parent's config first
     }
     // Getting the config for current
     $to_merge = $this->getConfigJson($class);
     if ($to_merge == null) {
         $to_merge = new InterceptorConfig();
     } else {
         if (!isset($to_merge->define)) {
             // If the config is just for arrays
             $to_merge = array('define' => new stdclass(), 'interceptors' => $to_merge);
         }
         $to_merge = copy_new($to_merge, "InterceptorConfig");
     }
     if (!isset($config)) {
         // If we don't have any parent
         return $to_merge;
     }
     $config->merge($to_merge);
     return $config;
 }
示例#8
0
 private function build_menu($gateway_id)
 {
     return array('network_lan' => copy_new(array('controller' => 'Network', 'method' => 'lan', 'args' => $gateway_id, 'label' => lang('LAN Settings')), 'Action'), 'network_wlan' => copy_new(array('controller' => 'Network', 'method' => 'wlan', 'args' => $gateway_id, 'label' => lang('WLAN Settings')), 'Action'), 'network_ibox_basic' => copy_new(array('controller' => 'Network', 'method' => 'ibox_basic', 'args' => $gateway_id, 'label' => lang('iBox Basic Settings')), 'Action'));
 }
 /**
  * While customer uses SNS Account to login with gateway at first time
  * @param $oResponse    Oauth response data
  * @param $serial       gateway's serial number
  * @param $sProvider    kind of Oauth
  * @return array
  * @author jake
  * @since 2014-07-31
  */
 public function addNewSnsAccount($oResponse, $serial, $mac, $sProvider, $master = FALSE, $user_id = '')
 {
     $CI =& get_instance();
     $info = array();
     $group = $this->group_model->getUserGroup();
     $group_id = $group->id;
     $oSnsAccount = copy_new($oResponse, $sProvider . '_Provider');
     $aResponse = get_object_vars($oResponse);
     $aSnsAccount = $oSnsAccount->convertToBasic($aResponse, $oResponse);
     $user_info = array('email_address' => $aSnsAccount['uid'] . '@pinet.co', 'password' => 'password', 'username' => substr($aSnsAccount['uid'], 0, 20), 'user_type' => -1, 'group_id' => $group_id, 'name' => $aSnsAccount['nickname'], 'mobile' => '', 'sex' => $aSnsAccount['gender'], 'contact_name' => $aSnsAccount['nickname'], 'contact_country' => '', 'contact_province' => isset($oResponse->province) ? $oResponse->province : '', 'contact_city' => isset($oResponse->city) ? $oResponse->city : '', 'contact_street' => '', 'contact_postalcode' => '', 'contact_profile' => '');
     if (!$master) {
         $user_id = $this->user_model->register($user_info);
     }
     if ($master && !$user_id) {
         $user_id = $this->user_model->getUserByName($this->session->userdata('email_address'));
     }
     $CI->log('Add new account from ' . $sProvider . ' for ' . $user_id);
     $aSnsAccount['user_id'] = $user_id;
     $info['sns_account_id'] = $this->insert($aSnsAccount);
     $device = $this->device_model->getByMac($mac);
     if ($device) {
         $device->owner_id = $user_id;
         $this->device_model->update($device->id, obj2array($device));
         $info['device_id'] = $device->id;
     } else {
         $device = $this->device_model->getOrCreate($serial, $user_id, $mac);
         $info['device_id'] = $device->id;
     }
     return $info;
 }
 function addField($field)
 {
     $formField = copy_new($field, 'FormField');
     ci_log("The form field is ", $formField);
     $formField->init();
     $this->formFields[] = $formField;
     $this->_param($formField->name, $formField->label, $formField->getFormValidationRules());
 }
示例#11
0
 public function getActionsByGroup($group)
 {
     $this->result_mode = 'object';
     $ret = array();
     foreach ($this->get_all('group', $group) as $a) {
         $action = copy_new($a, 'Action');
         if ($this->validAction($action)) {
             $ret[] = $action;
         }
     }
     return $ret;
 }
示例#12
0
 public static function fromJson($json)
 {
     $obj = parse_json($json);
     if (isset($obj->where)) {
         $obj->where = (array) $obj->where;
     }
     if ($obj) {
         return copy_new($obj, "Clips\\Pagination");
     }
     return null;
 }
 private function _build_menu($gateway_id)
 {
     return array('ibox_app' => copy_new(array('controller' => 'Maintenance', 'method' => 'ibox_app', 'args' => $gateway_id, 'label' => lang('iBox App Settings')), 'Action'), 'task_scheduler' => copy_new(array('controller' => 'Maintenance', 'method' => 'task_scheduler', 'args' => $gateway_id, 'label' => lang('Task Scheduler')), 'Action'));
 }