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


PHP active_user函数代码示例

本文整理汇总了PHP中active_user函数的典型用法代码示例。如果您正苦于以下问题:PHP active_user函数的具体用法?PHP active_user怎么用?PHP active_user使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: index

 /**
  * Log user out and forward to homepage (or via helper method if needed).
  *
  * @access	public
  * @param	none
  * @return	void
  **/
 public function index()
 {
     //	If already logged out just send them silently on their way
     if (!$this->user_model->is_logged_in()) {
         redirect('/');
     }
     // --------------------------------------------------------------------------
     //	Handle flashdata, if there's anything there pass it along as GET variables.
     //	We're about to destroy the session so they'll go bye-bye unless we do
     //	something with 'em.
     $_flash = array();
     $_flash['name'] = active_user('first_name');
     $_flash['success'] = $this->session->flashdata('success');
     $_flash['error'] = $this->session->flashdata('error');
     $_flash['notice'] = $this->session->flashdata('notice');
     $_flash['message'] = $this->session->flashdata('message');
     // --------------------------------------------------------------------------
     //	Generate an event for this log in
     create_event('did_log_out', active_user('id'));
     // --------------------------------------------------------------------------
     //	Log user out
     $this->auth_model->logout();
     // --------------------------------------------------------------------------
     //	Redirect via helper method
     redirect('auth/logout/bye?' . http_build_query($_flash));
 }
开发者ID:nailsapp,项目名称:module-auth,代码行数:33,代码来源:logout.php

示例2: set_as_default

 /**
  * Set's a group as the default group
  * @param mixed $group_id_slug The group's ID or slug
  */
 public function set_as_default($group_id_slug)
 {
     $_group = $this->get_by_id_or_slug($group_id_slug);
     if (!$_group) {
         $this->_set_error('Invalid Group');
     }
     // --------------------------------------------------------------------------
     $this->db->trans_begin();
     //	Unset old default
     $this->db->set('is_default', FALSE);
     $this->db->set('modified', 'NOW()', FALSE);
     if ($this->user_model->is_logged_in()) {
         $this->db->set('modified_by', active_user('id'));
     }
     $this->db->where('is_default', TRUE);
     $this->db->update($this->_table);
     //	Set new default
     $this->db->set('is_default', TRUE);
     $this->db->set('modified', 'NOW()', FALSE);
     if ($this->user_model->is_logged_in()) {
         $this->db->set('modified_by', active_user('id'));
     }
     $this->db->where('id', $_group->id);
     $this->db->update($this->_table);
     if ($this->db->trans_status() === FALSE) {
         $this->db->trans_rollback();
         return FALSE;
     } else {
         $this->db->trans_commit();
         //	Refresh the default group variable
         $this->get_default_group();
         return TRUE;
     }
 }
开发者ID:nailsapp,项目名称:module-system,代码行数:38,代码来源:user_group_model.php

示例3: invoice

 public function invoice()
 {
     $this->data['order'] = $this->shop_order_model->get_by_ref($this->uri->segment(4));
     //	Order exist?
     if (!$this->data['order']) {
         return $this->_bad_invoice('Invoice does not exist.');
     }
     // --------------------------------------------------------------------------
     //	User have permission?
     $_id_match = $this->data['order']->user->id && $this->data['order']->user->id != active_user('id');
     $_email_match = $this->data['order']->user->email && $this->data['order']->user->email != active_user('email');
     if (!$this->user_model->is_admin() && !$_id_match && !$_email_match) {
         return $this->_bad_invoice('Permission Denied.');
     }
     // --------------------------------------------------------------------------
     //	Render PDF
     if (isset($_GET['dl']) && !$_GET['dl']) {
         $this->load->view('shop/' . $this->_skin->dir . '/orders/invoice', $this->data);
     } else {
         $this->load->library('pdf');
         $this->pdf->load_view('shop/' . $this->_skin->dir . '/orders/invoice', $this->data);
         $this->pdf->render();
         $this->pdf->stream('INVOICE-' . $this->data['order']->ref . '.pdf');
     }
 }
开发者ID:nailsapp,项目名称:module-shop,代码行数:25,代码来源:orders.php

示例4: __construct

 /**
  * Constructor
  *
  * @access	public
  * @param	none
  * @return	void
  **/
 public function __construct()
 {
     parent::__construct();
     // --------------------------------------------------------------------------
     //	If user is logged in they shouldn't be accessing this method
     if ($this->user_model->is_logged_in()) {
         $this->session->set_flashdata('error', lang('auth_no_access_already_logged_in', active_user('email')));
         redirect('/');
     }
 }
开发者ID:nailsapp,项目名称:module-auth,代码行数:17,代码来源:reset_password.php

示例5: get_upload_token

 public function get_upload_token()
 {
     //	Define $_out array
     $_out = array();
     // --------------------------------------------------------------------------
     if ($this->user_model->is_logged_in()) {
         $_out['token'] = $this->cdn->generate_api_upload_token(active_user('id'));
     } else {
         $_out['status'] = 400;
         $_out['error'] = 'You must be logged in to generate an upload token.';
     }
     // --------------------------------------------------------------------------
     $this->_out($_out);
 }
开发者ID:nailsapp,项目名称:module-api,代码行数:14,代码来源:cdnapi.php

示例6: update

 /**
  * Updates an existing object
  *
  * @access public
  * @param int $id The ID of the object to update
  * @param array $data The data to update the object with
  * @return bool
  **/
 public function update($id, $data = array())
 {
     if (!$data) {
         return FALSE;
     }
     // --------------------------------------------------------------------------
     $this->db->set($data);
     $this->db->set('modified', 'NOW()', FALSE);
     if ($this->user_model->is_logged_in()) {
         $this->db->set('modified_by', active_user('id'));
     }
     $this->db->where('id', $id);
     $this->db->update(NAILS_DB_PREFIX . 'shop_voucher');
     return $this->db->affected_rows() ? TRUE : FALSE;
 }
开发者ID:nailsapp,项目名称:module-shop,代码行数:23,代码来源:shop_voucher_model.php

示例7: update

 public function update($id_slug, $label)
 {
     $_slug = $this->_generate_slug($label);
     $this->db->set('slug', $_slug);
     $this->db->set('label', $_slug);
     $this->db->set('modified', 'NOW()', FALSE);
     if ($this->user_model->is_logged_in()) {
         $this->db->set('modified_by', active_user('id'));
     }
     if (is_numeric($id_slug)) {
         $this->db->where('id', $id_slug);
     } else {
         $this->db->where('slug', $id_slug);
     }
     $this->db->update($this->_table);
     return (bool) $this->db->affected_rows();
 }
开发者ID:nailsapp,项目名称:module-blog,代码行数:17,代码来源:blog_category_model.php

示例8: index

 /**
  * Constructor
  *
  * @access	public
  * @param	none
  * @return	void
  **/
 public function index()
 {
     if (!$this->user_model->is_logged_in()) {
         unauthorised();
     }
     $_token = $this->input->get('token');
     $_token = $this->encrypt->decode($_token, APP_PRIVATE_KEY);
     if (!$_token) {
         show_404();
     }
     $_token = explode('|', $_token);
     if (count($_token) != 3) {
         show_404();
     }
     $_user = $this->user_model->get_by_email($_token[2]);
     if (!$_user || $_user->id != active_user('id ')) {
         show_404();
     }
     $this->load->library('emailer');
     $_email = $this->emailer->get_by_ref($_token[1]);
     if (!$_email) {
         show_404();
     }
     // --------------------------------------------------------------------------
     //	All seems above board, action the request
     if ($this->input->get('undo')) {
         if ($this->emailer->user_has_unsubscribed(active_user('id'), $_token[0])) {
             $this->emailer->subscribe_user(active_user('id'), $_token[0]);
         }
     } else {
         if (!$this->emailer->user_has_unsubscribed(active_user('id'), $_token[0])) {
             $this->emailer->unsubscribe_user(active_user('id'), $_token[0]);
         }
     }
     // --------------------------------------------------------------------------
     //	Load views
     $this->load->view('email/utilities/unsubscribe', $this->data);
 }
开发者ID:nailsapp,项目名称:module-email,代码行数:45,代码来源:unsubscribe.php

示例9: update_translation

 /**
  * Updates an existing translation object
  *
  * @access public
  * @param int $block_id The ID of the block this translation belongs to
  * @param int $language The ID of the language this block is written in
  * @param string $value The contents of this translation
  * @return bool
  **/
 public function update_translation($block_id, $language, $value)
 {
     //	Get existing translation
     $this->db->where('block_id', $block_id);
     $this->db->where('language', $language);
     $_old = $this->db->get(NAILS_DB_PREFIX . 'cms_block_translation')->row();
     if (!$_old) {
         return FALSE;
     }
     // --------------------------------------------------------------------------
     //	If the value hasn't changed then don't do anything
     if ($_old->value == trim($value)) {
         return FALSE;
     }
     // --------------------------------------------------------------------------
     $this->db->set('value', trim($value));
     $this->db->set('modified', 'NOW()', FALSE);
     if (active_user('id')) {
         $this->db->set('modified_by', active_user('id'));
     } else {
         $this->db->set('modified_by', NULL);
     }
     $this->db->where('block_id', $block_id);
     $this->db->where('language', $language);
     $this->db->update(NAILS_DB_PREFIX . 'cms_block_translation');
     if ($this->db->affected_rows()) {
         //	Create a new revision if value has changed
         $this->db->select('id');
         $this->db->where('block_id', $block_id);
         $this->db->where('language', $language);
         $_block_translation = $this->db->get(NAILS_DB_PREFIX . 'cms_block_translation')->row();
         if ($_block_translation) {
             $this->db->set('block_translation_id', $_block_translation->id);
             $this->db->set('value', $_old->value);
             $this->db->set('created', $_old->modified);
             $this->db->set('created_by', $_old->modified_by);
             $this->db->insert(NAILS_DB_PREFIX . 'cms_block_translation_revision');
             //	Upate the main block's modified date and user
             $this->update_block($_old->block_id);
         }
         return TRUE;
     } else {
         return FALSE;
     }
 }
开发者ID:nailsapp,项目名称:module-cms,代码行数:54,代码来源:cms_block_model.php

示例10: active_user

                break;
        }
        ?>
							</td>
							<td class="valid_from">
								<?php 
        $_format_d = active_user('date_setting')->format->date->format;
        $_format_t = active_user('date_setting')->format->time->format;
        echo date($_format_d . ' ' . $_format_t, strtotime($voucher->valid_from));
        ?>
							</td>
							<td class="expires">
								<?php 
        if ($voucher->valid_to) {
            $_format_d = active_user('date_setting')->format->date->format;
            $_format_t = active_user('date_setting')->format->time->format;
            echo date($_format_d . ' ' . $_format_t, strtotime($voucher->valid_from));
        } else {
            echo '<span class="blank">Does not expire</span>';
        }
        ?>
							</td>
							<td class="uses"><?php 
        echo number_format($voucher->use_count);
        ?>
</td>
							<td class="actions">
								<?php 
        $_buttons = array();
        // --------------------------------------------------------------------------
        if ($voucher->is_active) {
开发者ID:nailsapp,项目名称:module-admin,代码行数:31,代码来源:index.php

示例11: _is_user_suspended

 protected function _is_user_suspended()
 {
     //	Check if this user is suspended
     if ($this->user_model->is_logged_in() && active_user('is_suspended')) {
         //	Load models and langs
         $this->load->model('auth/auth_model');
         $this->lang->load('auth/auth');
         //	Log the user out
         $this->auth_model->logout();
         //	Create a new session
         $this->session->sess_create();
         //	Give them feedback
         $this->session->set_flashdata('error', lang('auth_login_fail_suspended'));
         redirect('/');
     }
 }
开发者ID:nailsapp,项目名称:common,代码行数:16,代码来源:CORE_NAILS_Controller.php

示例12: active_user

		</ul>

		<!--	CLEARFIX	-->
		<div class="clear"></div>

	</div>

	<div class="sidebar">
		<div class="padder">

		<div class="nav-search">
		<input type="search" placeholder="Type to search menu" />
		</div>

		<?php 
$_acl = active_user('acl');
$_mobile_menu = array();
$_counter = 0;
$loaded_modules = !empty($loaded_modules) ? $loaded_modules : array();
foreach ($loaded_modules as $module => $config) {
    //	Get any notifications for this module if applicable
    $_notifications = $module::notifications();
    $_class = '';
    if ($_counter == 0) {
        $_class = 'first';
    }
    if ($_counter == count($loaded_modules) - 1) {
        $_class = 'last';
    }
    $_counter++;
    // --------------------------------------------------------------------------
开发者ID:nailsapp,项目名称:common,代码行数:31,代码来源:nails-admin.php

示例13: create


//.........这里部分代码省略.........
         $_user_data['language'] = $data['language'];
     }
     // --------------------------------------------------------------------------
     //	Set Meta data
     $_meta_cols = $this->_get_meta_columns();
     $_meta_data = array();
     foreach ($data as $key => $val) {
         if (array_search($key, $_meta_cols) !== FALSE) {
             $_meta_data[$key] = $val;
         }
     }
     // --------------------------------------------------------------------------
     $this->db->trans_begin();
     $this->db->set($_user_data);
     if (!$this->db->insert(NAILS_DB_PREFIX . 'user')) {
         $this->_set_error('Failed to create base user object.');
         $this->db->trans_rollback();
         return FALSE;
     }
     $_id = $this->db->insert_id();
     // --------------------------------------------------------------------------
     //	Update the user table with an MD5 hash of the user ID; a number of functions
     //	make use of looking up this hashed information; this should be quicker.
     $this->db->set('id_md5', md5($_id));
     $this->db->where('id', $_id);
     if (!$this->db->update(NAILS_DB_PREFIX . 'user')) {
         $this->_set_error('Failed to update base user object.');
         $this->db->trans_rollback();
         return FALSE;
     }
     // --------------------------------------------------------------------------
     //	Create the user_meta record, add any extra data if needed
     $this->db->set('user_id', $_id);
     if ($_meta_data) {
         $this->db->set($_meta_data);
     }
     if (!$this->db->insert(NAILS_DB_PREFIX . 'user_meta')) {
         $this->_set_error('Failed to create user meta data object.');
         $this->db->trans_rollback();
         return FALSE;
     }
     // --------------------------------------------------------------------------
     //	Finally add the email address to the user_email table
     if (!empty($_email)) {
         $_code = $this->email_add($_email, $_id, TRUE, $_email_is_verified, FALSE);
         if (!$_code) {
             //	Error will be set by email_add();
             $this->db->trans_rollback();
             return FALSE;
         }
         //	Send the user the welcome email
         if ($send_welcome) {
             $this->load->library('emailer');
             $_email = new stdClass();
             $_email->type = 'new_user_' . $_group->id;
             $_email->to_id = $_id;
             $_email->data = array();
             $_email->data['method'] = $_auth_method;
             //	If this user is created by an admin then take note of that.
             if ($this->is_admin()) {
                 $_email->data['admin'] = new stdClass();
                 $_email->data['admin']->id = active_user('id');
                 $_email->data['admin']->first_name = active_user('first_name');
                 $_email->data['admin']->last_name = active_user('last_name');
                 $_email->data['admin']->group = new stdClass();
                 $_email->data['admin']->group->id = $_group->id;
                 $_email->data['admin']->group->name = $_group->label;
             }
             if (!empty($data['password']) && !empty($_inform_user_pw)) {
                 $_email->data['password'] = $data['password'];
                 //	Is this a temp password? We should let them know that too
                 if ($_user_data['temp_pw']) {
                     $_email->data['temp_pw'] = !empty($_user_data['temp_pw']);
                 }
             }
             //	If the email isn't verified we'll want to include a note asking them to do so
             if (!$_email_is_verified) {
                 $_email->data['verification_code'] = $_code;
             }
             if (!$this->emailer->send($_email, TRUE)) {
                 //	Failed to send using the group email, try using the generic email template
                 $_email->type = 'new_user';
                 if (!$this->emailer->send($_email, TRUE)) {
                     //	Email failed to send, musn't exist, oh well.
                     $_error = 'Failed to send welcome email.';
                     $_error .= !empty($_inform_user_pw) ? ' Inform the user their password is <strong>' . $data['password'] . '</strong>' : '';
                     $this->_set_error($_error);
                 }
             }
         }
     }
     // --------------------------------------------------------------------------
     //	commit the transaction and return new user object
     if ($this->db->trans_status() !== FALSE) {
         $this->db->trans_commit();
         return $this->get_by_id($_id);
     } else {
         return FALSE;
     }
 }
开发者ID:nailsapp,项目名称:module-system,代码行数:101,代码来源:user_model.php

示例14: _export_source_shop_vouchers

 protected function _export_source_shop_vouchers()
 {
     $_acl = active_user('acl');
     if (!$this->user_model->is_superuser() && !isset($_acl['admin']['shop']['vouchers'])) {
         $this->session->set_flashdata('error', '<strong>Sorry,</strong> you do not have permission to export that data.');
         redirect('admin/utilities/export');
         return;
     }
     // --------------------------------------------------------------------------
     $_out = new stdClass();
     $_out->filename = NAILS_DB_PREFIX . 'shop_vouchers';
     $_out->fields = array();
     $_out->data = array();
     // --------------------------------------------------------------------------
     //	Fetch all vouchers
     $this->db->select('v.id,v.code,v.type,v.discount_type,v.discount_value,v.discount_application,v.label,v.valid_from');
     $this->db->select('v.valid_to,v.use_count,v.limited_use_limit,v.gift_card_balance,v.product_type_id,v.created');
     $this->db->select('v.modified,v.is_active,v.is_deleted');
     $_out->data = $this->db->get(NAILS_DB_PREFIX . 'shop_voucher v')->result_array();
     if ($_out->data) {
         $_out->fields = array_keys($_out->data[0]);
     }
     // --------------------------------------------------------------------------
     return $_out;
 }
开发者ID:nailsapp,项目名称:module-admin,代码行数:25,代码来源:utilities.php

示例15: edit

 /**
  * Edit an existing user account
  *
  * @access	public
  * @param	none
  * @return	void
  **/
 public function edit()
 {
     //	Get the user's data; loaded early because it's required for the user_meta_cols
     //	(we need to know the group of the user so we can pull up the correct cols/rules)
     $_user = $this->user_model->get_by_id($this->uri->segment(4));
     if (!$_user) {
         $this->session->set_flashdata('error', lang('accounts_edit_error_unknown_id'));
         redirect($this->input->get('return_to'));
         return;
     }
     //	Non-superusers editing superusers is not cool
     if (!$this->user_model->is_superuser() && user_has_permission('superuser', $_user)) {
         $this->session->set_flashdata('error', lang('accounts_edit_error_noteditable'));
         $_return_to = $this->input->get('return_to') ? $this->input->get('return_to') : 'admin/dashboard';
         redirect($_return_to);
         return;
     }
     //	Is this user editing someone other than themselves? If so, do they have permission?
     if (active_user('id') != $_user->id && !user_has_permission('admin.accounts.can_edit_others')) {
         $this->session->set_flashdata('error', lang('accounts_edit_error_noteditable'));
         $_return_to = $this->input->get('return_to') ? $this->input->get('return_to') : 'admin/dashboard';
         redirect($_return_to);
         return;
     }
     // --------------------------------------------------------------------------
     //	Load helpers
     $this->load->helper('date');
     // --------------------------------------------------------------------------
     //	Load the user_meta_cols; loaded here because it's needed for both the view
     //	and the form validation
     $_user_meta_cols = $this->config->item('user_meta_cols');
     $_group_id = $this->input->post('group_id') ? $this->input->post('group_id') : $_user->group_id;
     if (isset($_user_meta_cols[$_group_id])) {
         $this->data['user_meta_cols'] = $_user_meta_cols[$_user->group_id];
     } else {
         $this->data['user_meta_cols'] = NULL;
     }
     //	Set fields to ignore by default
     $this->data['ignored_fields'] = array();
     $this->data['ignored_fields'][] = 'id';
     $this->data['ignored_fields'][] = 'user_id';
     //	If no cols were found, DESCRIBE the user_meta table - where possible
     //	you should manually set columns, including datatypes
     if (NULL === $this->data['user_meta_cols']) {
         $_describe = $this->db->query('DESCRIBE `' . NAILS_DB_PREFIX . 'user_meta`')->result();
         $this->data['user_meta_cols'] = array();
         foreach ($_describe as $col) {
             //	Always ignore some fields
             if (array_search($col->Field, $this->data['ignored_fields']) !== FALSE) {
                 continue;
             }
             // --------------------------------------------------------------------------
             //	Attempt to detect datatype
             $_datatype = 'string';
             $_type = 'text';
             switch (strtolower($col->Type)) {
                 case 'text':
                     $_type = 'textarea';
                     break;
                 case 'date':
                     $_datatype = 'date';
                     break;
                 case 'tinyint(1) unsigned':
                     $_datatype = 'bool';
                     break;
             }
             // --------------------------------------------------------------------------
             $this->data['user_meta_cols'][$col->Field] = array('datatype' => $_datatype, 'type' => $_type, 'label' => ucwords(str_replace('_', ' ', $col->Field)));
         }
     }
     // --------------------------------------------------------------------------
     //	Validate if we're saving, otherwise get the data and display the edit form
     if ($this->input->post()) {
         //	Load validation library
         $this->load->library('form_validation');
         // --------------------------------------------------------------------------
         //	Define user table rules
         $this->form_validation->set_rules('username', '', 'xss_clean|alpha_dash|min_length[2]|unique_if_diff[' . NAILS_DB_PREFIX . 'user.username.' . $this->input->post('username_orig') . ']');
         $this->form_validation->set_rules('first_name', '', 'xss_clean|required');
         $this->form_validation->set_rules('last_name', '', 'xss_clean|required');
         $this->form_validation->set_rules('gender', '', 'xss_clean|required');
         $this->form_validation->set_rules('timezone', '', 'xss_clean|required');
         $this->form_validation->set_rules('datetime_format_date', '', 'xss_clean|required');
         $this->form_validation->set_rules('datetime_format_time', '', 'xss_clean|required');
         $this->form_validation->set_rules('language', '', 'xss_clean|required');
         $this->form_validation->set_rules('password', '', 'xss_clean');
         $this->form_validation->set_rules('temp_pw', '', 'xss_clean');
         $this->form_validation->set_rules('reset_security_questions', '', 'xss_clean');
         // --------------------------------------------------------------------------
         //	Define user_meta table rules
         foreach ($this->data['user_meta_cols'] as $col => $value) {
             $_datatype = isset($value['datatype']) ? $value['datatype'] : 'string';
             $_label = isset($value['label']) ? $value['label'] : ucwords(str_replace('_', ' ', $col));
//.........这里部分代码省略.........
开发者ID:nailsapp,项目名称:module-admin,代码行数:101,代码来源:accounts.php


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