当前位置: 首页>>代码示例>>PHP>>正文


PHP HC_App::app_conf方法代码示例

本文整理汇总了PHP中HC_App::app_conf方法的典型用法代码示例。如果您正苦于以下问题:PHP HC_App::app_conf方法的具体用法?PHP HC_App::app_conf怎么用?PHP HC_App::app_conf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HC_App的用法示例。


在下文中一共展示了HC_App::app_conf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index()
 {
     $app = $this->config->item('nts_app');
     $app_conf = HC_App::app_conf();
     if (isset($GLOBALS['NTS_CONFIG'][$app]['FORCE_LOGIN_ID'])) {
         $id = $GLOBALS['NTS_CONFIG'][$app]['FORCE_LOGIN_ID'];
         $this->auth->login($id);
     }
     // sync user account
     $ri = $this->remote_integration();
     if ($ri) {
         $id = $this->auth->check();
         if ($id) {
             $model_name = $ri . '_User';
             $um = HC_App::model($model_name);
             $um->sync($id);
             $this->auth->reset_user();
         }
     }
     // check user level
     $user_level = 0;
     $user_id = 0;
     if ($this->auth->check()) {
         if ($test_user = $this->auth->user()) {
             $user_id = $test_user->id;
             $user_level = $test_user->level;
         }
     }
     if ($ri) {
         $wall_schedule_display = 0;
     } else {
         $wall_schedule_display = $app_conf->get('wall:schedule_display');
     }
     $default_params = $this->default_params;
     $allowed = FALSE;
     switch ($user_level) {
         case 0:
             if ($wall_schedule_display <= $user_level) {
                 $to = 'list';
             } else {
                 if ($user_id) {
                     $to = 'auth/notallowed';
                 } else {
                     $to = 'auth/login';
                 }
             }
             break;
         case USER_HC_MODEL::LEVEL_ADMIN:
         case USER_HC_MODEL::LEVEL_MANAGER:
             $to = isset($default_params['route']) ? $default_params['route'] : 'list';
             break;
         case USER_HC_MODEL::LEVEL_STAFF:
             $to = isset($default_params['route']) ? $default_params['route'] : 'listme';
             break;
     }
     $this->redirect($to);
     exit;
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:58,代码来源:dispatcher.php

示例2: get_staff

 public function get_staff()
 {
     $app_conf = HC_App::app_conf();
     $working_levels = $app_conf->get('working_levels');
     $this->clear();
     /* get those users who can be assigned to shifts */
     $this->where('active', self::STATUS_ACTIVE);
     if ($working_levels) {
         if (!is_array($working_levels)) {
             $working_levels = array($working_levels);
         }
         $this->where_in('level', $working_levels);
     }
     $this->get();
     return $this;
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:16,代码来源:user.php

示例3: attempt

 public function attempt($identity, $password, $remember = FALSE)
 {
     $app_conf = HC_App::app_conf();
     $login_with = $app_conf->get('login_with');
     if ($login_with != 'username') {
         $identity_name = 'email';
     } else {
         $identity_name = 'username';
     }
     $where = array($identity_name => $identity);
     $this->auth_model->from_array($where);
     if ($this->auth_model->check_password($password)) {
         $this->login($this->auth_model->id);
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:18,代码来源:hc_auth.php

示例4: insert

 function insert()
 {
     $args = func_get_args();
     $id = array_shift($args);
     $model = HC_App::model('shift');
     $model->where('id', $id)->get();
     $this->_check_model($model);
     $acl = HC_App::acl();
     if (!$acl->set_object($model)->can('release')) {
         return;
     }
     $current_user = $this->auth->user();
     $app_conf = HC_App::app_conf();
     $approval_required = $app_conf->get("release:approval_required");
     if ($approval_required) {
         $model->release_request = 1;
         $action_result = $model->save();
     } else {
         $action_result = $model->delete($current_user, 'user');
     }
     if ($action_result) {
         /* extensions */
         // $extensions->run('shifts/update', $post, $model);
         if ($approval_required) {
             $msg = HCM::__('Shift release request received');
         } else {
             $msg = HCM::__('Shift released');
         }
         /* save and redirect here */
         $this->session->set_flashdata('message', $msg);
     } else {
         /* save and redirect here */
         $this->session->set_flashdata('error', HCM::__('Error'));
     }
     $redirect_to = 'shifts/zoom/index/id/' . $id . '/tab/release';
     /* what to refresh on referring page */
     $parent_refresh = $model->present_calendar_refresh();
     $parent_refresh = array_keys($parent_refresh);
     $this->redirect($redirect_to, $parent_refresh);
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:40,代码来源:edit.php

示例5: insert

 function insert()
 {
     $args = func_get_args();
     $id = array_shift($args);
     $model = HC_App::model('shift');
     $model->where('id', $id)->get();
     $this->_check_model($model);
     $acl = HC_App::acl();
     if (!$acl->set_object($model)->can('pickup')) {
         return;
     }
     $current_user = $this->auth->user();
     $related = array('user' => $current_user);
     $model->user = $current_user;
     $app_conf = HC_App::app_conf();
     $approval_required = $app_conf->get('pickup:approval_required');
     if ($approval_required) {
         $model->status = $model->_const('STATUS_DRAFT');
     }
     $action_result = $model->save($related);
     if ($action_result) {
         if ($approval_required) {
             $msg = HCM::__('Shift pickup request received');
         } else {
             $msg = HCM::__('Shift picked up');
         }
         /* save and redirect here */
         $this->session->set_flashdata('message', $msg);
     } else {
         /* save and redirect here */
         $this->session->set_flashdata('error', HCM::__('Error'));
     }
     $redirect_to = 'shifts/zoom/index/' . $id;
     //			$redirect_to = '-referrer-';
     /* what to refresh on referring page */
     $parent_refresh = $model->present_calendar_refresh();
     $parent_refresh = array_keys($parent_refresh);
     $this->redirect($redirect_to, $parent_refresh);
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:39,代码来源:edit.php

示例6: __construct

 function __construct($time = 0, $tz = '')
 {
     //static $initCount;
     //$initCount++;
     //echo "<h2>init $initCount</h2>";
     if (strlen($time) == 0) {
         $ts = 0;
     }
     if (!$time) {
         $time = time();
     }
     if (is_array($time)) {
         $time = $time[0];
     }
     parent::__construct();
     if ($time > 0) {
         $this->setTimestamp($time);
     } else {
         $this->setNow();
     }
     $app_conf = HC_App::app_conf();
     if (!$tz) {
         $tz = $app_conf ? $app_conf->get('timezone') : '';
     }
     if ($tz) {
         $this->setTimezone($tz);
     }
     $this->weekStartsOn = $app_conf ? $app_conf->get('week_starts') : 0;
     $time_format = $app_conf ? $app_conf->get('time_format') : '';
     if ($time_format) {
         $this->timeFormat = $time_format;
     }
     $date_format = $app_conf ? $app_conf->get('date_format') : '';
     if ($date_format) {
         $this->dateFormat = $date_format;
     }
 }
开发者ID:kumarkvk,项目名称:vz_emp_shiftsSchedule,代码行数:37,代码来源:hc_time.php

示例7: update

 function update($tab = 'core')
 {
     $app_conf = HC_App::app_conf();
     $fields = $this->config->items('settings');
     $tabs = $this->_get_tabs($fields);
     $these_fields = $tabs[$tab];
     $validator = new HC_Validator();
     foreach ($these_fields as $fn) {
         $f = $fields[$fn];
         if (isset($f['rules'])) {
             $validator->set_rules($fn, $f['rules']);
         }
     }
     $post = $this->input->post();
     $this->form->grab($post);
     $values = $this->form->values();
     if ($values && $validator->run($values) == TRUE) {
         reset($these_fields);
         foreach ($these_fields as $fn) {
             $app_conf->set($fn, $values[$fn]);
         }
         // redirect back
         $msg = HCM::__('Settings updated');
         $this->session->set_flashdata('message', $msg);
         $to = 'conf/admin/index/' . $tab;
         $this->redirect($to);
     } else {
         $errors = $validator->error();
         $this->form->set_values($values);
         $this->form->set_errors($errors);
         $fields = $this->config->items('settings');
         /* render view */
         $this->layout->set_partial('content', $this->render('conf/admin/index', array('fields' => $fields, 'form' => $this->form, 'tab' => $tab, 'tabs' => $tabs)));
         $this->layout();
     }
 }
开发者ID:kumarkvk,项目名称:vz_emp_shiftsSchedule,代码行数:36,代码来源:admin.php

示例8: array

<?php

$this->layout->set_partial('header', HC_Html::page_header(HC_Html_Factory::element('h2')->add_child(HCM::__('Log In'))));
$app_conf = HC_App::app_conf();
if ($app_conf->get('login_with') == 'username') {
    $identity_label = HCM::__('Username');
} else {
    $identity_label = HCM::__('Email');
}
$display_form = HC_Html_Factory::widget('form')->add_attr('action', HC_Lib::link('auth/login')->url())->add_attr('class', 'form-horizontal')->add_attr('class', 'form-condensed');
$display_form->add_item(HC_Html_Factory::widget('label_row')->set_label($identity_label)->set_content($form->input('identity')->add_attr('placeholder', $identity_label))->set_error($form->input('identity')->error()));
$display_form->add_item(HC_Html_Factory::widget('label_row')->set_label(HCM::__('Password'))->set_content($form->input('password')->add_attr('placeholder', HCM::__('Password')))->set_error($form->input('password')->error()));
$display_form->add_item(HC_Html_Factory::widget('label_row')->set_content(HC_Html_Factory::element('input')->add_attr('type', 'submit')->add_attr('class', array('btn', 'btn-default'))->add_attr('title', HCM::__('Log In'))->add_attr('value', HCM::__('Log In'))));
$out = HC_Html_Factory::widget('list')->add_attr('class', 'list-unstyled')->add_attr('class', 'list-separated');
$out->add_item($display_form);
$out->add_item(HC_Html_Factory::widget('titled', 'a')->add_attr('href', HC_Lib::link('auth/forgot_password'))->add_child(HCM::__('Lost your password?')));
echo $out->render();
开发者ID:RCMmedia,项目名称:rubicon,代码行数:17,代码来源:login.php

示例9: run

 function run()
 {
     $validator = new HC_Validator();
     // $validator->set_rules('first_name',			'trim|required');
     $post = $this->input->post();
     $this->form->grab($post);
     $values = $this->form->values();
     $errors = array();
     if ($values && $validator->run($values)) {
         /* run setup */
         /* reset tables */
         $this->_drop_tables();
         /* setup tables */
         $this->load->library('migration');
         if (!$this->migration->current()) {
             show_error($this->migration->error_string());
             return false;
         }
         $setup_ok = TRUE;
         /* admin user */
         $um = HC_App::model('user');
         $um->from_array($values);
         $um->level = $um->_const('LEVEL_ADMIN');
         if ($um->save()) {
             $email_from = $values['email'];
             $email_from_name = $values['first_name'] . ' ' . $values['last_name'];
         } else {
             $errors = array_merge($errors, $um->errors());
             $this->_drop_tables();
             $setup_ok = FALSE;
         }
         if ($setup_ok) {
             /* default settings */
             $app_conf = HC_App::app_conf();
             $app_conf->init();
             // to reload database
             $app_conf->set('email_from', $email_from);
             $app_conf->set('email_from_name', $email_from_name);
             $this->session->set_flashdata('message', HCM::__('OK'));
             # message sent on succesful setup
             $this->redirect('setup/ok');
             return;
         }
     }
     $errors = array_merge($errors, $validator->errors());
     $this->form->set_errors($errors);
     return $this->index();
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:48,代码来源:setup.php

示例10: format_price

 static function format_price($amount, $calculated_price = '')
 {
     $app_conf = HC_App::app_conf();
     $before_sign = $app_conf->get('currency_sign_before');
     $currency_format = $app_conf->get('currency_format');
     list($dec_point, $thousand_sep) = explode('||', $currency_format);
     $after_sign = $app_conf->get('currency_sign_after');
     $amount = number_format($amount, 2, $dec_point, $thousand_sep);
     $return = $before_sign . $amount . $after_sign;
     if (strlen($calculated_price) && $amount != $calculated_price) {
         $calc_format = $before_sign . number_format($calculated_price, 2, $dec_point, $thousand_sep) . $after_sign;
         $return = $return . ' <span style="text-decoration: line-through;">' . $calc_format . '</span>';
     }
     return $return;
 }
开发者ID:kumarkvk,项目名称:vz_emp_shiftsSchedule,代码行数:15,代码来源:hc_lib.php

示例11: layout

 function layout($template_file = NULL)
 {
     $template_dir = '_layout_new';
     $ri = HC_Lib::ri();
     $is_module = $this->is_module();
     $is_ajax = $this->input->is_ajax_request();
     if ($is_module or $is_ajax) {
         $template_file = 'index_module';
     } else {
         if (!$template_file) {
             $template_file = 'index';
         }
         /* theme */
         $theme_dir = $GLOBALS['NTS_APPPATH'] . '/../theme';
         if (file_exists($theme_dir)) {
             $theme_head = $theme_dir . '/head.php';
             if (file_exists($theme_head)) {
                 $this->layout->set_partial('theme_head', $this->render('../../theme/head', array()));
             }
             $theme_header = $theme_dir . '/header.php';
             if (file_exists($theme_header)) {
                 $this->layout->set_partial('theme_header', $this->render('../../theme/header', array()));
             }
             $theme_footer = $theme_dir . '/footer.php';
             if (file_exists($theme_footer)) {
                 $this->layout->set_partial('theme_footer', $this->render('../../theme/footer', array()));
             }
         }
         $this->layout->set_param('ri', $ri);
         /* head */
         // if( ! $ri ){
         $page_title = $this->config->item('nts_app_title');
         $this->layout->set_partial('head', $this->render($template_dir . '/head', array('layout' => $this->layout, 'page_title' => $page_title)));
         // }
         /* menu & profile */
         $user = NULL;
         if ($this->auth && $this->auth->check() && $this->auth->user() && $this->auth->user()->active) {
             $user = $this->auth->user();
         }
         $user = $this->auth->user();
         /* menu */
         if ((1 or $user) && !$this->is_setup) {
             $menu_conf = $this->config->item('menu');
             $disabled_panels = $this->config->item('disabled_panels');
             $this_uri = $this->uri->uri_string();
             $user_level = $user ? $user->level : 0;
             $acl = HC_App::acl();
             $auth_user = $acl->user();
             $this->layout->set_partial('menu', $this->render($template_dir . '/menu', array('menu_conf' => $menu_conf, 'disabled_panels' => $disabled_panels, 'this_uri' => $this_uri, 'user' => $auth_user)));
         }
         /* profile */
         $app_conf = HC_App::app_conf();
         if ((1 or !$ri) && !$this->is_setup) {
             $this_method = $this->router->fetch_method();
             $login_with = $app_conf->get('login_with');
             $this->layout->set_partial('profile', $this->render($template_dir . '/profile', array('this_method' => $this_method, 'login_with' => $login_with, 'user' => $user)));
         }
         /* brand */
         $brand_title = $this->config->item('nts_app_title');
         $brand_url = $this->config->item('nts_app_url');
         $hc_app_version = $this->config->item('hc_app_version');
         if (!$ri && strlen($brand_title)) {
             $this->layout->set_partial('brand', $this->render($template_dir . '/brand', array('brand_title' => $brand_title, 'brand_url' => $brand_url, 'ri' => $ri, 'app_version' => $hc_app_version)));
         }
         /* js footer code */
         $this->layout->set_partial('js_footer', $this->render($template_dir . '/js_footer', array()));
     }
     /* flashdata */
     if (!$is_module) {
         $this->layout->set_partial('flashdata', $this->render($template_dir . '/flashdata', array('message' => $this->session->flashdata('message_ajax') ? $this->session->flashdata('message_ajax') : $this->session->flashdata('message'), 'debug_message' => $this->session->flashdata('debug_message'), 'error' => $this->session->flashdata('error_ajax') ? $this->session->flashdata('error_ajax') : $this->session->flashdata('error'))));
         $this->layout->set_partial('flashdata_ajax', $this->render($template_dir . '/flashdata', array('message' => $this->session->flashdata('message_ajax'), 'debug_message' => NULL, 'error' => $this->session->flashdata('error_ajax'))));
     }
     /* final output */
     $this->layout->set_template($template_dir . '/' . $template_file);
     /* return */
     $this->load->view($this->layout->template(), array('layout' => $this->layout));
     /*
     		return $this->render(
     			$this->layout->template(),
     			array(
     				'layout'	=> $this->layout
     				)
     			);
     */
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:85,代码来源:MY_BaseController.php

示例12: _download

 private function _download($shifts)
 {
     $app_conf = HC_App::app_conf();
     $separator = $app_conf->get('csv_separator');
     // header
     $headers = array(HCM::__('Type'), HCM::__('Date'), HCM::__('Time'), HCM::__('Duration'), HCM::__('Staff'), HCM::__('Location'), HCM::__('Status'));
     $data = array();
     $data[] = join($separator, $headers);
     $t = HC_Lib::time();
     // shifts
     foreach ($shifts as $sh) {
         $values = array();
         // type
         $values[] = $sh->present_type(HC_PRESENTER::VIEW_RAW);
         // date
         $values[] = $sh->present_date(HC_PRESENTER::VIEW_RAW);
         // time
         $values[] = $sh->present_time(HC_PRESENTER::VIEW_RAW);
         // duration
         $values[] = $t->formatPeriodExtraShort($sh->get_duration(), 'hour');
         // staff
         $values[] = $sh->present_user(HC_PRESENTER::VIEW_RAW);
         // location
         $values[] = $sh->present_location(HC_PRESENTER::VIEW_RAW);
         // status
         $values[] = $sh->present_status(HC_PRESENTER::VIEW_RAW);
         /* add csv line */
         $data[] = HC_Lib::build_csv(array_values($values), $separator);
     }
     // output
     $out = join("\n", $data);
     $file_name = isset($this->conf['export']) ? $this->conf['export'] : 'export';
     $file_name .= '-' . date('Y-m-d_H-i') . '.csv';
     $this->load->helper('download');
     force_download($file_name, $out);
     return;
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:37,代码来源:list.php

示例13: run

 function run()
 {
     $validator = new HC_Validator();
     $wum = HC_App::model('wordpress_user');
     $wordpress_roles = $wum->wp_roles();
     $wordpress_count_users = count_users();
     foreach ($wordpress_roles as $role_value => $role_name) {
         $field_name = 'role_' . $role_value;
         $validator->set_rules($field_name, 'trim|required');
     }
     $post = $this->input->post();
     $this->form->grab($post);
     $values = $this->form->values();
     if ($post) {
         if ($validator->run($values) == FALSE) {
             $errors = $validator->error();
             $this->form->set_values($values);
             $this->form->set_errors($errors);
             /* render view */
             return $this->index();
         } else {
             /* run setup */
             /* reset tables */
             $this->_drop_tables();
             /* setup tables */
             $this->load->library('migration');
             if (!$this->migration->current()) {
                 show_error($this->migration->error_string());
                 return false;
             }
             $app_conf = HC_App::app_conf();
             $app_conf->init();
             $setup_ok = TRUE;
             $append_role_name = $values['append_role_name'];
             /* save settings */
             reset($values);
             foreach ($values as $k => $v) {
                 $app_conf->set('wordpress_' . $k, $v);
             }
             $um = HC_App::model('user');
             /* all users */
             $result = $wum->sync_all($values);
             if ($result !== TRUE) {
                 $msg = array();
                 foreach ($result as $uid => $user_result) {
                     foreach ($user_result as $k => $v) {
                         $msg[] = 'User ID=' . $uid . ': ' . $k . ': ' . $v;
                     }
                 }
                 $msg = join('<br>', $msg);
                 $this->session->set_flashdata('error', $msg);
                 $setup_ok = FALSE;
             }
             $success_count = $wum->get_last_count('success');
             /* this user */
             $current_user = wp_get_current_user();
             $result = $wum->sync($current_user->ID, $um->_const('LEVEL_ADMIN'));
             if ($result !== TRUE) {
                 $msg = array();
                 foreach ($result as $k => $v) {
                     $msg[] = $k . ': ' . $v;
                 }
                 $msg = join('<br>', $msg);
                 $this->session->set_flashdata('error', $msg);
                 $setup_ok = FALSE;
             }
             // $success_count++;
             if ($setup_ok) {
                 /* default settings */
                 $email_from = get_bloginfo('admin_email');
                 $email_from_name = get_bloginfo('name');
                 $app_conf->set('email_from', $email_from);
                 $app_conf->set('email_from_name', $email_from_name);
                 $msg = 'Imported ' . $success_count . ' ';
                 $msg .= $count_users > 1 ? 'users' : 'user';
                 $this->session->set_flashdata('message', $msg);
                 $this->redirect('setup/ok');
                 return;
             } else {
                 $this->_drop_tables();
                 $this->redirect('wordpress/setup');
             }
         }
     }
     return $this->index();
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:86,代码来源:setup.php

示例14: syncrun

 function syncrun()
 {
     $validator = new HC_Validator();
     $wum = HC_App::model('wordpress_user');
     $wordpress_roles = $wum->wp_roles();
     $wordpress_count_users = count_users();
     foreach ($wordpress_roles as $role_value => $role_name) {
         $field_name = 'role_' . $role_value;
         $validator->set_rules($field_name, 'trim|required');
     }
     $post = $this->input->post();
     $this->form->grab($post);
     $values = $this->form->values();
     if ($post) {
         if ($validator->run($values) == FALSE) {
             $errors = $validator->error();
             $this->form->set_values($values);
             $this->form->set_errors($errors);
             /* render view */
             return $this->sync();
         } else {
             $app_conf = HC_App::app_conf();
             $setup_ok = TRUE;
             $append_role_name = $values['append_role_name'];
             /* save settings */
             reset($values);
             foreach ($values as $k => $v) {
                 $app_conf->set('wordpress_' . $k, $v);
             }
             $um = HC_App::model('user');
             /* all users */
             $result = $wum->sync_all($values);
             if ($result !== TRUE) {
                 $msg = array();
                 foreach ($result as $uid => $user_result) {
                     foreach ($user_result as $k => $v) {
                         $msg[] = 'User ID=' . $uid . ': ' . $k . ': ' . $v;
                     }
                 }
                 $msg = join('<br>', $msg);
                 $this->session->set_flashdata('error', $msg);
                 $setup_ok = FALSE;
             }
             $success_count = $wum->get_last_count('success');
             $archived_count = $wum->get_last_count('archived');
             /* this user */
             $current_user = wp_get_current_user();
             $result = $wum->sync($current_user->ID, $um->_const('LEVEL_ADMIN'));
             if ($result !== TRUE) {
                 $msg = array();
                 foreach ($result as $k => $v) {
                     $msg[] = $k . ': ' . $v;
                 }
                 $msg = join('<br>', $msg);
                 $this->session->set_flashdata('error', $msg);
                 $setup_ok = FALSE;
             }
             // $success_count++;
             if ($setup_ok) {
                 $msg = 'Synchronized ' . $success_count . ' ';
                 $msg .= $success_count_users > 1 ? 'users' : 'user';
                 if ($archived_count) {
                     $msg .= '<br>Archived ' . $archived_count . ' ';
                     $msg .= $archived_count > 1 ? 'users' : 'user';
                 }
                 $this->session->set_flashdata('message', $msg);
                 $this->redirect('admin/users');
                 return;
             } else {
                 $this->redirect('wordpress/admin/users');
             }
         }
     }
     return $this->sync();
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:75,代码来源:users.php

示例15: sync

 public function sync($id, $force_level = NULL)
 {
     $wuser = get_user_by('id', $id);
     $user = HC_App::model('user');
     $user->where('id', $id)->get();
     $is_new = $user->exists() ? FALSE : TRUE;
     if ($is_new) {
         $user->id = $id;
         if ($force_level) {
             $user_level = $force_level;
         } else {
             /* check new user level */
             $app_conf = HC_App::app_conf();
             $wp_role = $wuser->roles && is_array($wuser->roles) && isset($wuser->roles[0]) ? $wuser->roles[0] : '';
             $k = 'wordpress_' . 'role_' . $wp_role;
             $user_level = $app_conf->get($k);
             if ($wp_role == 'administrator') {
                 $user_level = $user->_const('LEVEL_ADMIN');
             }
         }
         if (!$user_level) {
             return;
         }
         $user->level = $user_level;
         $password = hc_random();
         $user->password = $password;
         $user->confirm_password = $password;
     } else {
         if ($force_level) {
             $user->level = $force_level;
         }
     }
     if ($wuser->user_firstname) {
         $user->first_name = $wuser->user_firstname;
         $user->last_name = $wuser->user_lastname;
     } else {
         $user->first_name = $wuser->display_name;
     }
     if ($wuser->user_email) {
         if ($is_new or $wuser->user_email != $user->email) {
             // check if this email already exists
             $um = HC_App::model('user');
             $um->where('email', $wuser->user_email)->get();
             if ($um->exists()) {
                 if ($is_new) {
                     // update id in our table
                     $um->where('id', $um->id)->update('id', $id);
                     $user->id = $id;
                 } else {
                     $user->id = $um->id;
                 }
                 $is_new = FALSE;
             }
             $user->email = $wuser->user_email;
         }
     }
     $user->active = $user->_const('STATUS_ACTIVE');
     $user->remove_validation('email');
     $user->remove_validation('username');
     $user->remove_validation('confirm_password');
     /*
     		if( $is_new ){
     			if( $user->save_as_new() ){
     				$return = TRUE;
     			}
     			else {
     				$return = $user->errors();
     			}
     		}
     		else {
     			if( $user->save() ){
     				$return = TRUE;
     			}
     			else {
     				$return = $user->errors();
     			}
     		}
     */
     if ($is_new && $user->save_as_new() or !$is_new && $user->save()) {
         $return = TRUE;
     } else {
         $return = $user->errors();
     }
     return $return;
 }
开发者ID:RCMmedia,项目名称:rubicon,代码行数:85,代码来源:wordpress_user.php


注:本文中的HC_App::app_conf方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。