Exemple #1
0
 public function index()
 {
     $this->load->library(['pagination', 'table']);
     $page = !empty($this->uri->segment(4)) ? $this->_perpage * ($this->uri->segment(4) - 1) : 0;
     $config['base_url'] = base_url($this->base . '/index/');
     $config['total_rows'] = $this->{$this->router->fetch_class()}->count_all();
     $this->_set_datagrid_header(isset($this->data['recursive']) ? $this->data['recursive'][1] : NULL);
     $unshift = [$this->primary_key => 'Primary Key'] + $this->data['datagrid_header'] + ['role' => 'Role'];
     $items = $this->_get_items();
     $this->user->order_by($this->primary_key, 'ASC');
     $this->user->limit($this->_perpage, $page);
     foreach ($this->user->with('user_role')->get_all() as $index => $row) {
         $row = object_to_array($row);
         foreach ($row as $k => $v) {
             if (!empty($items) && array_key_exists($k, $items)) {
                 $row[$k] = empty($v) ? $v : $items[$k][$v];
             }
         }
         $row['role'] = '';
         foreach ($row['user_role'] as $key => $value) {
             $role = $this->role->get($value['role_id']);
             $row['role'] .= '<span class="label label-info">' . $role->role_name . '</span> ';
         }
         $row = array_intersect_key($row, $unshift);
         $this->data['datagrid'][$index] = array_to_object($row);
     }
     $this->pagination->initialize($config);
     $this->data['links'] = $this->pagination->create_links();
 }
Exemple #2
0
 public static function getAwards()
 {
     $awards = Config::get('awards.types');
     foreach ($awards as &$award) {
         $award = array_to_object($award);
     }
     return $awards;
 }
/**
 * Converting an array into object
 *
 * @param   array   $array  Source
 * @return  object
 */
function array_to_object(array $array)
{
    $obj = new stdClass();
    foreach ($array as $key => $val) {
        $obj->{$key} = is_array($val) ? array_to_object($val) : $val;
    }
    return $obj;
}
Exemple #4
0
 public function test_array_to_object()
 {
     $a = ['key1' => 'val1', 'key2' => 'val2'];
     $o = $this->_get_test_obj();
     $this->assertEquals($o, array_to_object($a));
     $this->assertNotEquals($a, $o);
     $o->key3 = 'val3';
     $this->assertNotEquals($a + ['key3' => 'val3'], array_to_object($o));
 }
 protected function loadPluginConfi($object = true)
 {
     $plugin_configuration = array('roles' => get_option('cdm_roles'), 'batch_access' => get_option('cdm_batch_access'), 'client_comment' => get_option('cdm_client_comment'), 'client_upload' => get_option('cdm_client_upload'), 'display_month' => get_option('cdm_display_month'), 'display_year' => get_option('cdm_display_year'), 'display_date' => get_option('cdm_display_date'), 'display_all' => get_option('cdm_display_all'), 'external_css' => get_option('cdm_external_css'), 'secure_files' => get_option('cdm_secure_files'), 'allowed_extension' => get_option('cdm_allowed_extension'), 'update_options' => get_option('cdm_update_options'), 'filesize' => get_option('cdm_allowed_filesize'), 'userrole' => get_option('cdm_userroles'));
     if ($object) {
         return array_to_object($plugin_configuration);
     } else {
         return $plugin_configuration;
     }
 }
 public static function getByID($fsfID)
 {
     $db = Loader::db();
     $r = $db->GetRow('SELECT * FROM FileSetFiles WHERE fsfID = ?', array($fsfID));
     if (is_array($r) && $r['fsfID']) {
         $fsf = new static();
         $fsf = array_to_object($fsf, $r);
         return $fsf;
     }
 }
 public function testArrayToObject()
 {
     $obj1 = new stdClass();
     $obj1->foo = 'bar';
     $obj2 = new stdClass();
     $obj2->foo = $obj1;
     $this->assertEquals(new stdClass(), array_to_object([]));
     $this->assertEquals($obj1, array_to_object(['foo' => 'bar']));
     $this->assertEquals($obj2, array_to_object(['foo' => ['foo' => 'bar']]));
 }
Exemple #8
0
 public static function getByID($logID)
 {
     $db = Database::get();
     $r = $db->Execute("select * from Logs where logID = ?", array($logID));
     if ($r) {
         $row = $r->FetchRow();
         $obj = new static();
         $obj = array_to_object($obj, $row);
         return $obj;
     }
 }
Exemple #9
0
 private function get_templates()
 {
     $this->load->model('template_model');
     $ids = $this->config->item('index_template_ids');
     $params = buildQueryOperation(array(), $this->common->get_start_row(), $this->common->get_page_size());
     foreach ((array) $ids as $id) {
         $params->QueryOperator->Filter[] = array_to_object(array('Name' => 'ID', 'Value' => $id));
     }
     $result = wrapWcfResult($this->template_model->get_templates_list($params, 'object'), 'Template');
     return empty($result->Data['rows']) ? [] : object_to_array($result->Data['rows']);
 }
Exemple #10
0
 function array_to_object($array)
 {
     $object = new stdClass();
     foreach ($array as $key => $value) {
         if (is_array($value)) {
             $object->{$key} = array_to_object($value);
         } else {
             $object->{$key} = $value;
         }
     }
     return $object;
 }
function array_to_object($array)
{
    $obj = new stdClass();
    foreach ($array as $k => $v) {
        if (is_array($v)) {
            $obj->{$k} = array_to_object($v);
        } else {
            $obj->{$k} = $v;
        }
    }
    return $obj;
}
 public function Find($where, $args = array())
 {
     $db = Loader::db();
     $return = array();
     $r = $db->GetAll('select * from ' . $this->_table . ' where ' . $where, $args);
     foreach ($r as $row) {
         $o = new $this();
         $o = array_to_object($o, $row);
         $return[] = $o;
     }
     return $return;
 }
 public function Find($where)
 {
     $db = Loader::db();
     $r = $db->Execute('select * from UserBannedIPs where ' . $where);
     $ips = array();
     while ($row = $r->FetchRow()) {
         $ip = new self();
         $ip = array_to_object(new self(), $row);
         $ips[] = $ip;
     }
     return $ips;
 }
Exemple #14
0
 /**
  * 根据激活码和应用获取记录
  *
  * @param string $code 激活码
  * @param string $application 应用
  * @return array 返回数组
  */
 public function get_verify_code_by_code($code, $application)
 {
     try {
         $this->load->helper('query_builder');
         $params = buildQueryOperation(array(), 1, 1);
         $params->QueryOperator->Filter = array(array_to_object(array('Name' => 'Code', 'Value' => $code)), array_to_object(array('Name' => 'Application', 'Value' => $application)));
         $result = wrapWcfResult($this->get_verify_codes($params), 'VerifyCode');
         return empty($result->Data['rows'][0]) ? [] : $result->Data['rows'][0];
     } catch (Exception $ex) {
         return [];
     }
 }
 private function get($where, $var)
 {
     $q = "select * from Users {$where}";
     $r = $this->connection->query($q, array($var));
     if ($r && $r->numRows() > 0) {
         $row = $r->fetchRow();
         $r->free();
         $ui = $this->application->make('Concrete\\Core\\User\\UserInfo');
         $ui = array_to_object($ui, $row);
         return $ui;
     }
 }
Exemple #16
0
function array_to_object($array)
{
    if (!is_array($array)) {
        return $array;
    } else {
        if (count($array) > 0) {
            foreach ($array as &$item) {
                $item = array_to_object($item);
            }
            return (object) $array;
        } else {
            return false;
        }
    }
}
Exemple #17
0
 /**
  * 获取分页模板的数据
  *
  * @param array $data
  * @return array 返回数组
  */
 public function get_template_list_by_design($query)
 {
     $case_key = 'global_templates';
     $all_templates = $this->wycache->get($case_key);
     //$all_templates = [];
     if (empty($all_templates)) {
         //从WCF获取数据
         $params = buildQueryOperation([], 1, 9999);
         $params->QueryOperator->Filter[] = array_to_object(array('Name' => 'Published', 'Value' => '1'));
         $all_templates = wrapWcfResult($this->get_templates_list($params, 'object'), 'Template');
         $this->wycache->set($case_key, json_encode($all_templates, JSON_UNESCAPED_UNICODE), 18000);
         //保留5小时 60*60*5
     } else {
         $all_templates = json_decode($all_templates);
         //return $all_templates;
     }
     $templates = [];
     if (!empty($query->QueryOperator->Filter)) {
         $filter_query = $query->QueryOperator->Filter;
         $filter = [];
         foreach ($filter_query as $value) {
             if ($value->Name == 'TemplateCategory') {
                 $filter[] = $value->Value;
             }
         }
         $filter_count = count($filter);
         $all_templates_temp = $all_templates->Data->rows;
         foreach ($all_templates_temp as $template_value) {
             $cat_query_count = 0;
             $cat_query = $template_value->Categories->TemplateCategory;
             foreach ($cat_query as $value) {
                 if (in_array($value->ID, $filter) !== FALSE) {
                     $cat_query_count++;
                 }
                 if ($cat_query_count == $filter_count) {
                     $templates[] = $template_value;
                     break;
                 }
             }
         }
     } else {
         $templates = $all_templates->Data->rows;
     }
     $result['List'] = array_slice($templates, $query->QueryOperator->Pager->StartRow, $query->QueryOperator->Pager->RowCount);
     $result['TotalCount'] = $all_templates->Data->total;
     $result = object_to_array($result);
     return $result;
 }
Exemple #18
0
 /**
  * Converts an array to an object (stdClass), optionally recursively.
  * 
  * @param array $array Array to convert to object.
  * @param boolean $recursive [Optional] Whether to convert recursively. Default false.
  * @return object Object containing the array's keys/values as properties.
  */
 function array_to_object(array $array, $recusive = false)
 {
     $object = new \stdClass();
     foreach ($array as $key => $value) {
         if (is_array($value)) {
             $value = $recusive ? array_to_object($value, $recusive) : (object) $value;
         } else {
             if (is_object($value) && !$value instanceof \stdClass) {
                 $value = object_to_array($value);
                 $value = $recusive ? array_to_object($value, $recusive) : (object) $value;
             }
         }
         $object->{$key} = $value;
     }
     return $object;
 }
Exemple #19
0
 function login()
 {
     // Init
     $data = array();
     $this->load->model('users_model');
     // Prevent IE users from caching this page
     if (!isset($_SESSION)) {
         session_start();
     }
     // If redirect session var set redirect to home page
     if (!($redirect_to = $this->session->userdata('redirect_to'))) {
         $redirect_to = '/';
     }
     // If user is already logged in redirect to desired location
     if ($this->secure->is_auth()) {
         redirect($redirect_to);
     }
     // Check if user has a remember me cookie
     if ($this->users_model->check_remember_me()) {
         redirect($redirect_to);
     }
     // Form Validation
     $this->form_validation->set_rules('email', 'Username', 'trim|required');
     $this->form_validation->set_rules('password', 'Password', 'trim|required');
     // Process Form
     if ($this->form_validation->run() == TRUE) {
         $Data = array_to_object($this->input->post());
         // Database query to lookup email and password
         if ($this->users_model->login($this->input->post('email'), $this->input->post('password'))) {
             redirect($redirect_to);
         }
         redirect(current_url());
     }
     // If the user was attempting to log into the admin panel use the admin theme
     if ($this->uri->segment(1) == ADMIN_PATH) {
         $this->template->set_theme('admin', 'default', 'application/themes');
         $this->template->set_layout('default_wo_errors');
         $this->template->add_package('jquery');
         $this->template->add_script("\n                \$(document).ready(function() { \n                    \$('#email').focus();\n                });");
         $this->template->view("admin/login", $data);
     } else {
         $this->template->view("/users/login", $data);
     }
 }
Exemple #20
0
function array_to_object($array)
{
    $obj = new \stdClass();
    foreach ($array as $k => $v) {
        if (strlen($k)) {
            if (is_array($v)) {
                if (count($v) !== 0) {
                    $obj->{$k} = array_to_object($v);
                    //RECURSION
                } else {
                    $obj->{$k} = null;
                }
            } else {
                $obj->{$k} = $v;
            }
        }
    }
    return $obj;
}
Exemple #21
0
 /** 
  *  根据传入的参数调用wcf接口,并返回数据
  * 
  *  @access public 
  *  @param operate_link_name 传入链接的名称(config->wcf->wcf_operate_url里面的键值)
  *  @param operate_func_name 执行的函数名
  *  @param param_data 要传给wcf的参数,格式为array
  *  @param result_type 返回值的格式,格式有 array、object两种,默认是array格式
  *  @return array/object 
  */
 function get_result_by_wcf($operate_link_name, $operate_func_name, $param_data = null, $result_type = 'array')
 {
     $func_result = "{$operate_func_name}Result";
     $p = new stdClass();
     //将传入参数数组转为对象
     if (!empty($param_data) && is_array($param_data)) {
         $p = array_to_object($param_data);
     } else {
         $p = $param_data;
     }
     $result = $this->wcf->{$operate_link_name}($operate_func_name, $p)->{$func_result};
     $log_params['link_name'] = $operate_link_name;
     $log_params['func_name'] = $operate_func_name;
     write_wcf_logs($log_params, $result);
     //将返回对象转为数组
     if ($result_type == 'array') {
         $result = object_to_array($result);
     }
     return $result;
 }
/**
 * Retrieves course section data given a course section ID or course section array.
 *
 * @since 6.2.0
 * @param int|etsis_Course_Sec|null $section
 *            Course section ID or course section array.
 * @param bool $object
 *            If set to true, data will return as an object, else as an array.
 */
function get_course_sec($section, $object = true)
{
    if ($section instanceof \app\src\Core\etsis_Course_Sec) {
        $_section = $section;
    } elseif (is_array($section)) {
        if (empty($section['courseSecID'])) {
            $_section = new \app\src\Core\etsis_Course_Sec($section);
        } else {
            $_section = \app\src\Core\etsis_Course_Sec::get_instance($section['courseSecID']);
        }
    } else {
        $_section = \app\src\Core\etsis_Course_Sec::get_instance($section);
    }
    if (!$_section) {
        return null;
    }
    if ($object == true) {
        $_section = array_to_object($_section);
    }
    return $_section;
}
/**
 * Retrieves course data given a course ID or course array.
 *
 * @since 6.2.0
 * @param int|etsis_Course|null $course
 *            Course ID or course array.
 * @param bool $object
 *            If set to true, data will return as an object, else as an array.
 */
function get_course($course, $object = true)
{
    if ($course instanceof \app\src\Core\etsis_Course) {
        $_course = $course;
    } elseif (is_array($course)) {
        if (empty($course['courseID'])) {
            $_course = new \app\src\Core\etsis_Course($course);
        } else {
            $_course = \app\src\Core\etsis_Course::get_instance($course['courseID']);
        }
    } else {
        $_course = \app\src\Core\etsis_Course::get_instance($course);
    }
    if (!$_course) {
        return null;
    }
    if ($object == true) {
        $_course = array_to_object($_course);
    }
    return $_course;
}
Exemple #24
0
 /**
  * Setter for available locales.
  *
  * @param array $locales Locales to set
  *
  * @author Benjamin Carl <*****@*****.**>
  */
 public function setAvailableLocales(array $locales)
 {
     self::$config->i18n->default->available = array_to_object($locales);
 }
Exemple #25
0
 /**
  * 将属性数组转换为类格式
  *
  * @param  string $html 转换好的控件html
  * @return class 返回control
  */
 private function change_properties($properties, $pid, $type = 'POST')
 {
     $pro = array();
     $state_code = '';
     foreach ($properties as $key => $value) {
         if ($key == 'state_code') {
             $state_code = $value;
             continue;
         }
         $pro[] = array_to_object(array('Name' => $key, 'Type' => $type, 'Value' => $value));
     }
     $control = new stdClass();
     $control->id = 0;
     $control->Properties = $pro;
     $control->pid = $pid;
     $control->stateCode = $state_code;
     return $control;
 }
Exemple #26
0
    $data->slug = $args->slug;
    $data->version = $latest_package['version'];
    $data->last_updated = $latest_package['date'];
    $data->download_link = $latest_package['package'];
    $data->author = $latest_package['author'];
    $data->external = $latest_package['external'];
    $data->requires = $latest_package['requires'];
    $data->tested = $latest_package['tested'];
    $data->homepage = $latest_package['homepage'];
    $data->downloaded = $latest_package['downloaded'];
    $data->sections = $latest_package['sections'];
    print serialize($data);
}
// theme_update
if ($action == 'theme_update') {
    $update_info = array_to_object($latest_package);
    $update_data = array();
    $update_data['package'] = $update_info->package;
    $update_data['new_version'] = $update_info->version;
    $update_data['url'] = $packages[$args->slug]['info']['url'];
    if (version_compare($args->version, $latest_package['version'], '<')) {
        print serialize($update_data);
    }
}
if ($action == 'theme_information') {
    $data = new stdClass();
    $data->slug = $args->slug;
    $data->name = $latest_package['name'];
    $data->version = $latest_package['version'];
    $data->last_updated = $latest_package['date'];
    $data->download_link = $latest_package['package'];
Exemple #27
0
 /**
  * Validates that a passed string is valid ini.
  *
  * @param string $input           The input to validation
  * @param bool   $processSections TRUE to process sections, FALSE to do not
  *
  * @author Benjamin Carl <*****@*****.**>
  *
  * @return mixed|bool Input on success, otherwise FALSE
  */
 protected function validate($input, $processSections = self::PHP_INI_PARSER_PROCESS_SECTIONS)
 {
     if (true === is_string($input)) {
         $input = @parse_ini_string($input, $processSections);
         // Convert our associative array to an object
         $input = array_to_object(array_change_key_case_recursive($input));
     }
     return $input;
 }
Exemple #28
0
<?php

include '../inc/config.php';
$ecard = getTeamNomination($_GET['id']);
$ecardImage = str_replace(' ', '-', strtolower($ecard->BeliefID));
$searchList = array_to_object(getThisTeamMembers($ecard->ID));
foreach ($searchList as $list) {
    $teamEmailList .= getName($list->EmpNum) . ", ";
    if (!isset($firstPersonEmpNum)) {
        $firstPersonEmpNum = $list;
    }
}
$teamEmailList = chop($teamEmailList, ", ");
$teamEmailList = strrev(implode(strrev(' and'), explode(',', strrev($teamEmailList), 2)));
$ecard->teamEmailList = $teamEmailList;
?>

<div class="ecardPadding">
	<?php 
// get first team member
$ecard->full_name = $firstPersonEmpNum->Fname . ' ' . $firstPersonEmpNum->Sname;
$ecard->Fname = $ecard->Team;
if ($ecard->Volunteer != '') {
    $ecard->NomFull_name = $ecard->Volunteer;
} else {
    $ecard->NomFull_name = getName($ecard->NominatorEmpNum);
}
$ecard->NomFname = getFirstName($ecard->NominatorEmpNum);
if ($ecard->littleExtra == 'Yes') {
    echo indEcardTeamExtraText($ecard);
} else {
Exemple #29
0
function array_to_object($array = array()) {
    //http://www.lost-in-code.com/programming/php-code/php-array-to-object/
    if (!empty($array)) {
        $data = false;

        foreach ($array as $akey => $aval) {
			if( is_array($aval) ){
				$aval = array_to_object($aval);
			}
            $data -> {$akey} = $aval;
        }

        return $data;
    }

    return false;
}
Exemple #30
0
 public function getSavedSearches()
 {
     $db = Loader::db();
     $sets = array();
     $u = new User();
     $r = $db->Execute('SELECT * FROM FileSets WHERE fsType = ? AND uID = ? ORDER BY fsName ASC', array(self::TYPE_SAVED_SEARCH, $u->getUserID()));
     while ($row = $r->FetchRow()) {
         $fs = new static();
         $fs = array_to_object($fs, $row);
         $sets[] = $fs;
     }
     return $sets;
 }