示例#1
0
 /**
  * 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));
 }
 /**
  * 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;
     }
 }
示例#3
0
 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');
     }
 }
示例#4
0
 /**
  * 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('/');
     }
 }
示例#5
0
 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);
 }
 /**
  * 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;
 }
 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();
 }
示例#8
0
 /**
  * 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);
 }
示例#9
0
 /**
  * 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;
     }
 }
示例#10
0
                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) {
示例#11
0
 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('/');
     }
 }
示例#12
0
		</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++;
    // --------------------------------------------------------------------------
示例#13
0
 /**
  * Create a new user
  *
  * @access	public
  * @param	string	$data			An array of data to use for creating the user
  * @param	boolean	$send_welcome	Whether or not to send the welcome email or not
  * @return	boolean
  **/
 public function create($data = FALSE, $send_welcome = TRUE)
 {
     //	Has an email or a suername been submitted?
     if (APP_NATIVE_LOGIN_USING == 'EMAIL') {
         //	Email defined?
         if (empty($data['email'])) {
             $this->_set_error('An email address must be supplied.');
             return FALSE;
         }
         //	Check email against DB
         $this->db->where('email', $data['email']);
         if ($this->db->count_all_results(NAILS_DB_PREFIX . 'user_email')) {
             $this->_set_error('This email is already in use.');
             return FALSE;
         }
     } elseif (APP_NATIVE_LOGIN_USING == 'USERNAME') {
         //	Username defined?
         if (empty($data['username'])) {
             $this->_set_error('A username must be supplied.');
             return FALSE;
         }
         //	Check username against DB
         $this->db->where('username', $data['username']);
         if ($this->db->count_all_results(NAILS_DB_PREFIX . 'user')) {
             $this->_set_error('This username is already in use.');
             return FALSE;
         }
     } else {
         //	Either a username or an email must be supplied
         if (empty($data['email']) && empty($data['username'])) {
             $this->_set_error('An email address or a username must be supplied.');
             return FALSE;
         }
         if (!empty($data['email'])) {
             //	Check email against DB
             $this->db->where('email', $data['email']);
             if ($this->db->count_all_results(NAILS_DB_PREFIX . 'user_email')) {
                 $this->_set_error('This email is already in use.');
                 return FALSE;
             }
         }
         if (!empty($data['username'])) {
             //	Check username against DB
             $this->db->where('username', $data['username']);
             if ($this->db->count_all_results(NAILS_DB_PREFIX . 'user')) {
                 $this->_set_error('This username is already in use.');
                 return FALSE;
             }
         }
     }
     // --------------------------------------------------------------------------
     //	All should be ok, go ahead and create the account
     $_user_data = array();
     // --------------------------------------------------------------------------
     //	If a password has been passed then generate the encrypted strings, otherwise
     //	just generate a salt.
     if (empty($data['password'])) {
         $_password[] = NULL;
         $_password[] = $this->user_password_model->salt();
     } else {
         $_password = $this->user_password_model->generate_hash($data['password']);
         if (!$_password) {
             $this->_set_error($this->user_password_model->last_error());
             return FALSE;
         }
     }
     //	Do we need to inform the user of their password? This might be set
     //	if an admin created the account, or if the system generated a new password
     $_inform_user_pw = !empty($data['inform_user_pw']) ? TRUE : FALSE;
     // --------------------------------------------------------------------------
     //	Check that we're dealing with a valid group
     if (empty($data['group_id'])) {
         $_user_data['group_id'] = $this->user_group_model->get_default_group_id();
     } else {
         $_user_data['group_id'] = $data['group_id'];
     }
     $_group = $this->user_group_model->get_by_id($_user_data['group_id']);
     if (!$_group) {
         $this->_set_error('Invalid Group ID specified.');
         return FALSE;
     } else {
         $_user_data['group_id'] = $_group->id;
     }
     // --------------------------------------------------------------------------
     //	Check we're dealing with a valid auth_method
     if (!empty($data['auth_method_id'])) {
         if (is_numeric($data['auth_method_id'])) {
             $this->db->where('id', (int) $data['auth_method_id']);
         } else {
             //	TODO: Change this column to be called `slug`
             $this->db->where('type', $data['auth_method_id']);
         }
         $_auth_method = $this->db->get(NAILS_DB_PREFIX . 'user_auth_method')->row();
         if (!$_auth_method) {
             //	Define a use friendly error (this may be shown to them)
             $this->_set_error('There was an error creating the user account - Error #001');
             //	This is a problem, email devs
             send_developer_mail('No auth method available for the supplied auth_method_id', 'The user_model->create() method was called with an invalid auth_method_id ("' . $data['auth_method_id'] . '"). This needs investigated and corrected.');
             return FALSE;
         }
     } else {
         //	TODO: this column should be `slug`
         $this->db->where('type', 'native');
         $_auth_method = $this->db->get(NAILS_DB_PREFIX . 'user_auth_method')->row();
         if (!$_auth_method) {
             //	Define a use friendly error (this may be shown to them)
             $this->_set_error('There was an error creating the user account - Error #002');
             //	This is a problem, email devs
             send_developer_mail('No Native Authentication Method', 'There is no authentication method defined in the database for native registrations.');
             return FALSE;
         }
     }
     $_user_data['auth_method_id'] = $_auth_method->id;
     // --------------------------------------------------------------------------
     if (!empty($data['username'])) {
         $_user_data['username'] = $data['username'];
     }
     if (!empty($data['email'])) {
         $_email = $data['email'];
         $_email_is_verified = !empty($data['email_is_verified']);
     }
     $_user_data['password'] = $_password->password;
     $_user_data['password_md5'] = $_password->password_md5;
     $_user_data['password_engine'] = $_password->engine;
     $_user_data['salt'] = $_password->salt;
     $_user_data['ip_address'] = $this->input->ip_address();
     $_user_data['last_ip'] = $_user_data['ip_address'];
     $_user_data['created'] = date('Y-m-d H:i:s');
     $_user_data['last_update'] = date('Y-m-d H:i:s');
     $_user_data['is_suspended'] = !empty($data['is_suspended']);
     $_user_data['temp_pw'] = !empty($data['temp_pw']);
     $_user_data['auth_method_id'] = $_auth_method->id;
     //	Facebook oauth details
     $_user_data['fb_token'] = !empty($data['fb_token']) ? $data['fb_token'] : NULL;
     $_user_data['fb_id'] = !empty($data['fb_id']) ? $data['fb_id'] : NULL;
     //	Twitter oauth details
     $_user_data['tw_id'] = !empty($data['tw_id']) ? $data['tw_id'] : NULL;
     $_user_data['tw_token'] = !empty($data['tw_token']) ? $data['tw_token'] : NULL;
     $_user_data['tw_secret'] = !empty($data['tw_secret']) ? $data['tw_secret'] : NULL;
     //	Linkedin oauth details
     $_user_data['li_id'] = !empty($data['li_id']) ? $data['li_id'] : NULL;
     $_user_data['li_token'] = !empty($data['li_token']) ? $data['li_token'] : NULL;
     //	Referral code
     $_user_data['referral'] = $this->_generate_referral();
     //	Other data
     $_user_data['salutation'] = !empty($data['salutation']) ? $data['salutation'] : NULL;
     $_user_data['first_name'] = !empty($data['first_name']) ? $data['first_name'] : NULL;
     $_user_data['last_name'] = !empty($data['last_name']) ? $data['last_name'] : NULL;
     if (isset($data['gender'])) {
         $_user_data['gender'] = $data['gender'];
     }
     if (isset($data['timezone'])) {
         $_user_data['timezone'] = $data['timezone'];
     }
     if (isset($data['datetime_format_date'])) {
         $_user_data['datetime_format_date'] = $data['datetime_format_date'];
     }
     if (isset($data['datetime_format_time'])) {
         $_user_data['datetime_format_time'] = $data['datetime_format_time'];
     }
     if (isset($data['language'])) {
         $_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;
     }
 }
示例#14
0
 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;
 }
示例#15
0
 /**
  * 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));
             //	Some data types require different handling
             switch ($_datatype) {
                 case 'date':
                     //	Dates must validate
                     if (isset($value['validation'])) {
                         $this->form_validation->set_rules($col, $_label, 'xss_clean|' . $value['validation'] . '|valid_date[' . $col . ']');
                     } else {
                         $this->form_validation->set_rules($col, $_label, 'xss_clean|valid_date[' . $col . ']');
                     }
                     break;
                     // --------------------------------------------------------------------------
                 // --------------------------------------------------------------------------
                 case 'file':
                 case 'upload':
                 case 'string':
                 default:
                     if (isset($value['validation'])) {
                         $this->form_validation->set_rules($col, $_label, 'xss_clean|' . $value['validation']);
                     } else {
                         $this->form_validation->set_rules($col, $_label, 'xss_clean');
                     }
                     break;
             }
         }
         // --------------------------------------------------------------------------
         //	Set messages
         $this->form_validation->set_message('required', lang('fv_required'));
         $this->form_validation->set_message('is_natural_no_zero', lang('fv_required'));
         $this->form_validation->set_message('valid_date', lang('fv_valid_date'));
         $this->form_validation->set_message('valid_datetime', lang('fv_valid_datetime'));
         // --------------------------------------------------------------------------
         //	Data is valid; ALL GOOD :]
         if ($this->form_validation->run($this)) {
             //	Define the data var
             $_data = array();
             // --------------------------------------------------------------------------
             //	If we have a profile image, attempt to upload it
             if (isset($_FILES['profile_img']) && $_FILES['profile_img']['error'] != 4) {
                 $_object = $this->cdn->object_replace($_user->profile_img, 'profile-images', 'profile_img');
                 if ($_object) {
                     $_data['profile_img'] = $_object->id;
                 } else {
                     $this->data['upload_error'] = $this->cdn->get_errors();
                     $this->data['error'] = lang('accounts_edit_error_profile_img');
                 }
             }
             // --------------------------------------------------------------------------
             if (!isset($this->data['upload_error'])) {
                 //	Set basic data
                 $_data['temp_pw'] = string_to_boolean($this->input->post('temp_pw'));
                 $_data['reset_security_questions'] = string_to_boolean($this->input->post('reset_security_questions'));
                 $_data['first_name'] = $this->input->post('first_name');
                 $_data['last_name'] = $this->input->post('last_name');
                 $_data['username'] = $this->input->post('username');
                 $_data['gender'] = $this->input->post('gender');
                 $_data['timezone'] = $this->input->post('timezone');
                 $_data['datetime_format_date'] = $this->input->post('datetime_format_date');
                 $_data['datetime_format_time'] = $this->input->post('datetime_format_time');
                 $_data['language'] = $this->input->post('language');
                 if ($this->input->post('password')) {
                     $_data['password'] = $this->input->post('password');
                 }
                 //	Set meta data
                 foreach ($this->data['user_meta_cols'] as $col => $value) {
                     switch ($value['datatype']) {
                         case 'bool':
                         case 'boolean':
                             //	Convert all to boolean from string
                             $_data[$col] = string_to_boolean($this->input->post($col));
                             break;
                             // --------------------------------------------------------------------------
                         // --------------------------------------------------------------------------
                         default:
                             $_data[$col] = $this->input->post($col);
                             break;
                     }
                 }
                 // --------------------------------------------------------------------------
                 //	Update account
                 if ($this->user_model->update($this->input->post('id'), $_data)) {
                     $_name = $this->input->post('first_name') . ' ' . $this->input->post('last_name');
                     $this->data['success'] = lang('accounts_edit_ok', array(title_case($_name)));
                     // --------------------------------------------------------------------------
                     //	Set Admin changelogs
                     $_name = '#' . number_format($this->input->post('id'));
                     if ($_data['first_name']) {
                         $_name .= ' ' . $_data['first_name'];
                     }
                     if ($_data['last_name']) {
                         $_name .= ' ' . $_data['last_name'];
                     }
                     foreach ($_data as $field => $value) {
                         if (isset($_user->{$field})) {
                             _ADMIN_CHANGE_ADD('updated', 'a', 'user', $this->input->post('id'), $_name, 'admin/accounts/edit/' . $this->input->post('id'), $field, $_user->{$field}, $value, FALSE);
                         }
                     }
                     // --------------------------------------------------------------------------
                     //	refresh the user object
                     $_user = $this->user_model->get_by_id($this->input->post('id'));
                     //	The account failed to update, feedback to user
                 } else {
                     $this->data['error'] = lang('accounts_edit_fail', implode(', ', $this->user_model->get_errors()));
                 }
             }
             //	Update failed for another reason
         } else {
             $this->data['error'] = lang('fv_there_were_errors');
         }
     }
     //	End POST() check
     // --------------------------------------------------------------------------
     //	Get the user's meta data
     if ($this->data['user_meta_cols']) {
         $this->db->select(implode(',', array_keys($this->data['user_meta_cols'])));
         $this->db->where('user_id', $_user->id);
         $_user_meta = $this->db->get(NAILS_DB_PREFIX . 'user_meta')->row();
     } else {
         $_user_meta = array();
     }
     // --------------------------------------------------------------------------
     //	Get the user's email addresses
     $this->data['user_emails'] = $this->user_model->get_emails_for_user($_user->id);
     // --------------------------------------------------------------------------
     $this->data['user_edit'] = $_user;
     $this->data['user_meta'] = $_user_meta;
     //	Page Title
     $this->data['page']->title = lang('accounts_edit_title', title_case($_user->first_name . ' ' . $_user->last_name));
     //	Get the groups, timezones and languages
     $this->data['groups'] = $this->user_group_model->get_all();
     $this->data['timezones'] = $this->datetime_model->get_all_timezone_flat();
     $this->data['date_formats'] = $this->datetime_model->get_all_date_format();
     $this->data['time_formats'] = $this->datetime_model->get_all_time_format();
     $this->data['languages'] = $this->language_model->get_all_enabled_flat();
     //	Fetch any user uploads
     if (module_is_enabled('cdn')) {
         $this->data['user_uploads'] = $this->cdn->get_objects_for_user($_user->id);
     }
     // --------------------------------------------------------------------------
     if (active_user('id') == $_user->id) {
         switch (active_user('gender')) {
             case 'male':
                 $this->data['notice'] = lang('accounts_edit_editing_self_m');
                 break;
             case 'female':
                 $this->data['notice'] = lang('accounts_edit_editing_self_f');
                 break;
             default:
                 $this->data['notice'] = lang('accounts_edit_editing_self_u');
                 break;
         }
     }
     // --------------------------------------------------------------------------
     //	Load views
     if ($this->input->get('inline') || $this->input->get('is_fancybox')) {
         $this->data['header_override'] = 'structure/header/blank';
         $this->data['footer_override'] = 'structure/footer/blank';
     }
     $this->load->view('structure/header', $this->data);
     $this->load->view('admin/accounts/edit/index', $this->data);
     $this->load->view('structure/footer', $this->data);
 }
示例#16
0
 /**
  * Set the user's preferred currency
  *
  * @access	public
  * @return	void
  *
  **/
 public function set_currency()
 {
     $_currency = $this->shop_currency_model->get_by_code($this->input->post('currency'));
     if ($_currency && $_currency->is_active) {
         //	Valid currency
         $this->session->set_userdata('shop_currency', $_currency->id);
         if ($this->user_model->is_logged_in()) {
             //	Save to the user object
             $this->user_model->update(active_user('id'), array('shop_currency' => $_currency->id));
         }
         $this->session->set_flashdata('success', '<strong>Success!</strong> Your currency has been updated.');
     } else {
         //	Failed to validate, feedback
         $this->session->set_flashdata('error', '<strong>Sorry,</strong> that currency is not valid.');
     }
     // --------------------------------------------------------------------------
     redirect($this->data['return']);
 }
 public function save()
 {
     //	Process all the items and save to the DB, then clean up
     if ($this->_changes) {
         $this->_changes = array_values($this->_changes);
         for ($i = 0; $i < count($this->_changes); $i++) {
             $this->_changes[$i]['changes'] = array_values($this->_changes[$i]['changes']);
             $this->_changes[$i]['changes'] = serialize($this->_changes[$i]['changes']);
             $this->_changes[$i]['created'] = date('Y-m-d H:i:s');
             $this->_changes[$i]['created_by'] = active_user('id');
             $this->_changes[$i]['modified'] = date('Y-m-d H:i:s');
             $this->_changes[$i]['modified_by'] = active_user('id');
         }
         $this->db->insert_batch($this->_table, $this->_changes);
     }
     // --------------------------------------------------------------------------
     $this->clear();
 }
示例#18
0
		<aside id = 'left_side'> 
		<?php 
IndexCategoryList();
?>
		</aside>
		
		<div id = 'right_side'>
		   
		   <div id ='hello'>
			<section id = 'right_side1'>
	         <img src ="images/main1.jpg" >
			</section>

			<section id = 'right_side2'>
			<?php 
active_user();
?>
		    </section>
		    </div>

		    <section id = 'right_side3'>
			<?php 
active_item();
?>
		    </section>

	   </div>


		<?php 
footerCode();
示例#19
0
 /**
  * Link a user's accounts together
  *
  * @access	public
  * @param	object $access_token The user's access token
  * @return	void
  **/
 protected function _link_user($access_token)
 {
     //	Set LinkeDInm details
     $_data = array();
     $_data['li_id'] = $access_token->user_id;
     $_data['li_token'] = $access_token->access_token;
     // --------------------------------------------------------------------------
     //	Update the user
     $this->user_model->update(active_user('id'), $_data);
     // --------------------------------------------------------------------------
     create_event('did_link_li', active_user('id'));
     // --------------------------------------------------------------------------
     //	Delete register token
     delete_cookie('liRegisterToken');
     // --------------------------------------------------------------------------
     //	Redirect
     $this->session->set_flashdata('success', lang('auth_social_linked_ok', 'LinkedIn'));
     $this->_redirect($this->_return_to);
     return;
 }
示例#20
0
if ($user_edit->id != active_user('id') && user_has_permission('admin.accounts.can_login_as')) {
    $_buttons[] = login_as_button($user_edit->id, $user_edit->password, lang('admin_login_as') . ' ' . $user_edit->first_name, 'class="awesome" target="_parent"');
}
// --------------------------------------------------------------------------
//	Edit
if ($user_edit->id != active_user('id') && user_has_permission('admin.accounts.delete')) {
    $_buttons[] = anchor('admin/accounts/delete/' . $user_edit->id . '?return_to=' . urlencode('admin/accounts'), lang('action_delete'), 'class="awesome red confirm" data-title="' . lang('admin_confirm_delete_title') . '" data-body="' . lang('admin_confirm_delete_body') . '"');
}
// --------------------------------------------------------------------------
//	Suspend
if ($user_edit->is_suspended) {
    if (active_user('id') != $user_edit->id && user_has_permission('admin.accounts.unsuspend')) {
        $_buttons[] = anchor('admin/accounts/unsuspend/' . $user_edit->id . $return_string, lang('action_unsuspend'), 'class="awesome"');
    }
} else {
    if (active_user('id') != $user_edit->id && user_has_permission('admin.accounts.suspend')) {
        $_buttons[] = anchor('admin/accounts/suspend/' . $user_edit->id . $return_string, lang('action_suspend'), 'class="awesome red"');
    }
}
?>

<?php 
if ($_buttons) {
    ?>
<fieldset id="edit-user-actions">
	<legend><?php 
    echo lang('accounts_edit_actions_legend');
    ?>
</legend>
	<p>
	<?php 
示例#21
0
 if ($member->id == active_user('id') || user_has_permission('admin.accounts.can_edit_others')) {
     $_buttons[] = anchor('admin/accounts/edit/' . $member->id . $_return, lang('action_edit'), 'data-fancybox-type="iframe" class="edit fancybox-max awesome small grey"');
 }
 // --------------------------------------------------------------------------
 //	Suspend user
 if ($member->is_suspended) {
     if (user_has_permission('admin.accounts.unsuspend')) {
         $_buttons[] = anchor('admin/accounts/unsuspend/' . $member->id . $_return, lang('action_unsuspend'), 'class="awesome small green"');
     }
 } else {
     if (user_has_permission('admin.accounts.suspend')) {
         $_buttons[] = anchor('admin/accounts/suspend/' . $member->id . $_return, lang('action_suspend'), 'class="awesome small red"');
     }
 }
 // --------------------------------------------------------------------------
 if (user_has_permission('admin.accounts.delete') && $member->id != active_user('id') && $member->group_id != 1) {
     $_buttons[] = anchor('admin/accounts/delete/' . $member->id . $_return, lang('action_delete'), 'class="confirm awesome small red" data-title="Delete user &quot;' . $member->first_name . ' ' . $member->last_name . '&quot?" data-body="' . lang('admin_confirm_delete') . '"');
 }
 // --------------------------------------------------------------------------
 //	These buttons are variable between views
 foreach ($actions as $button) {
     $_buttons[] = anchor($button['url'] . $_return, $button['label'], 'class="awesome small ' . $button['class'] . '"');
 }
 // --------------------------------------------------------------------------
 //	Render all the buttons, if any
 if ($_buttons) {
     foreach ($_buttons as $button) {
         echo $button;
     }
 } else {
     echo '<span class="not-editable">' . lang('accounts_index_noactions') . '</span>';
示例#22
0
 /**
  * Unlinks a local account from LinkedIn
  *
  * @access	public
  * @return	void
  **/
 public function unlink_user($user_id = NULL)
 {
     //	Grab reference to the userobject
     $_userobj =& get_userobject();
     // --------------------------------------------------------------------------
     if (NULL === $user_id) {
         $_uid = active_user('id');
     } else {
         if (is_callable(array($_userobj, 'get_by_id'))) {
             $_u = get_userobject()->get_by_id($user_id);
             if (!empty($_u->id)) {
                 $_uid = $_u->id;
             } else {
                 return FALSE;
             }
         } else {
             return FALSE;
         }
     }
     // --------------------------------------------------------------------------
     //	Update our user
     if (is_callable(array($_userobj, 'update'))) {
         $_data = array();
         $_data['li_id'] = NULL;
         $_data['li_token'] = NULl;
         return $_userobj->update($_uid, $_data);
     } else {
         return TRUE;
     }
 }
示例#23
0
 /**
  * Gets the URL where the user will be redirected to after connecting/logging in
  *
  * @access	public
  * @param	string $success Where to redirect the user to on successful login
  * @param	string $fail Where to redirect the user to on failed login
  * @return	void
  **/
 private function _get_redirect_url($success, $fail)
 {
     //	Set a little userdata for when we come back
     $_data = array();
     $_data['nailsTWConnectReturnTo'] = $success ? $success : active_user('group_homepage');
     $_data['nailsTWConnectReturnToFail'] = $fail ? $fail : $success;
     //	Filter out empty items
     $_data = array_filter($_data);
     $_query_string = $_data ? '?' . http_build_query($_data) : NULL;
     return site_url('auth/tw/connect/verify' . $_query_string);
 }
示例#24
0
 /**
  * Create an event object
  *
  * @access	public
  * @param	string		$type				The type of event to create
  * @param	int			$created_by			The event creator (NULL == system)
  * @param	int/array	$interested_party	The ID of an interested aprty (array for multiple interested parties)
  * @param	mixed		$data				Any data to store alongside the event object
  * @param	int			$ref				A numeric reference to store alongside the event (e.g the id of the object the event relates to)
  * @param	string		$recorded			A strtotime() friendly string of the date to use instead of NOW() for the created date
  * @return	int or boolean
  **/
 public function create($type, $created_by = NULL, $level = 0, $interested_parties = NULL, $data = NULL, $ref = NULL, $recorded = NULL)
 {
     //	Admins logged in as people shouldn't be creating events, GHOST MODE, woooooooo
     //	Ghost mode runs on production only, all other environments generate events (for testing)
     if (ENVIRONMENT == 'production' && get_userobject()->was_admin()) {
         return TRUE;
     }
     // --------------------------------------------------------------------------
     if (empty($type)) {
         $this->_add_error('Event type not defined.');
         return FALSE;
     }
     // --------------------------------------------------------------------------
     if (!is_string($type)) {
         $this->_add_error('Event type must be a string.');
         return FALSE;
     }
     // --------------------------------------------------------------------------
     //	Get the event type
     if (!isset($this->_event_type[$type])) {
         $this->db->select('id');
         $this->db->where('slug', $type);
         $this->_event_type[$type] = $this->db->get(NAILS_DB_PREFIX . 'event_type')->row();
         if (!$this->_event_type[$type]) {
             show_error('Unrecognised event type.');
         }
     }
     // --------------------------------------------------------------------------
     //	Prep created by
     $created_by = (int) $created_by;
     if (!$created_by) {
         $created_by = active_user('id') ? (int) active_user('id') : NULL;
     }
     // --------------------------------------------------------------------------
     //	Prep data
     $_data = array();
     $_data['type_id'] = (int) $this->_event_type[$type]->id;
     $_data['created_by'] = $created_by;
     $_data['url'] = uri_string();
     $_data['data'] = $data ? serialize($data) : NULL;
     $_data['ref'] = (int) $ref;
     $_data['ref'] = $_data['ref'] ? $_data['ref'] : NULL;
     $_data['level'] = $level;
     // --------------------------------------------------------------------------
     $this->db->set($_data);
     if ($recorded) {
         $_data['created'] = date('Y-m-d H:i:s', strtotime($recorded));
     } else {
         $this->db->set('created', 'NOW()', FALSE);
     }
     // --------------------------------------------------------------------------
     //	Create the event
     $this->db->insert(NAILS_DB_PREFIX . 'event');
     // --------------------------------------------------------------------------
     if (!$this->db->affected_rows()) {
         $this->_add_error('Event could not be created');
         return FALSE;
     } else {
         $_event_id = $this->db->insert_id();
     }
     // --------------------------------------------------------------------------
     /**
      *	Add the interested parties.
      *	The creator (if one is defined) will also be added as an interested party
      *	however it will be immediately marked as read (so as not to generate a
      *	notification badge for them.
      *
      **/
     //	Prep the $_data array
     $_data = array();
     if ($created_by) {
         $_data[] = array('event_id' => $_event_id, 'user_id' => $created_by, 'is_read' => TRUE);
     }
     // --------------------------------------------------------------------------
     //	Add the other interested parties (if any)
     if ($interested_parties !== NULL) {
         if (is_numeric($interested_parties)) {
             $interested_parties = array($interested_parties);
         }
         // --------------------------------------------------------------------------
         foreach ($interested_parties as $ip) {
             //	Don't add the creator as an interested party
             if ($ip == $created_by) {
                 continue;
             }
             // --------------------------------------------------------------------------
             $_data[] = array('event_id' => $_event_id, 'user_id' => $ip, 'is_read' => FALSE);
         }
     }
     // --------------------------------------------------------------------------
     if ($_data) {
         //	Attempt to add interested parties
         $this->db->insert_batch(NAILS_DB_PREFIX . 'event_interested_party', $_data);
         if ($this->db->affected_rows()) {
             //	All good! Return the new event ID
             return $_event_id;
         } else {
             $this->_add_error('Interested parties failed to add, event not created');
             //	Roll back the event
             $this->db->where('id', $_event_id);
             $this->db->delete(NAILS_DB_PREFIX . 'event');
             return FALSE;
         }
     } else {
         //	No interested parties, so simply return the event ID
         return $_event_id;
     }
     // --------------------------------------------------------------------------
     //	Return result
     return TRUE;
 }
示例#25
0
	<table>
		<thead>
			<tr>
				<th class="image">Image</th>
				<th class="title">Details</th>
				<th class="status">Published</th>
				<th class="user">Author</th>
				<th class="datetime">Modified</th>
				<th class="actions">Actions</th>
			</tr>
		</thead>
		<tbody>
		<?php 
if ($posts) {
    $_date_format = active_user('pref_date_format');
    $_time_format = active_user('pref_time_format');
    foreach ($posts as $post) {
        echo '<tr class="post" data-title="' . $post->title . '">';
        echo '<td class="image">';
        if ($post->image_id) {
            echo anchor(cdn_serve($post->image_id), img(cdn_scale($post->image_id, 75, 75)), 'class="fancybox"');
        } else {
            echo img(NAILS_ASSETS_URL . 'img/admin/modules/blog/image-icon.png');
        }
        echo '</td>';
        echo '<td class="title">';
        //	Title
        echo $post->title;
        //	URL
        echo '<small>' . anchor($post->url, $post->url, 'target="_blank"') . '</small>';
        //	Exceprt
示例#26
0
文件: blank.php 项目: nailsapp/common
			window.NAILS.LANG				= {};
			window.NAILS.USER				= {};
			window.NAILS.USER.ID			= <?php 
echo active_user('id') ? active_user('id') : 'null';
?>
;
			window.NAILS.USER.FNAME			= '<?php 
echo active_user('first_name');
?>
';
			window.NAILS.USER.LNAME			= '<?php 
echo active_user('last_name');
?>
';
			window.NAILS.USER.EMAIL			= '<?php 
echo active_user('email');
?>
';
		</script>

		<!-- JAVASCRIPT[S] -->
		<?php 
echo $this->asset->output('js');
?>

	</head>
	<body class="blank">

		<?php 
if (isset($error) && !empty($error)) {
    ?>
示例#27
0
 public function __construct($config = array())
 {
     parent::__construct();
     // --------------------------------------------------------------------------
     $_config_set_session = isset($config['set_session']) ? (bool) $config['set_session'] : TRUE;
     // --------------------------------------------------------------------------
     $_base = $this->get_base_currency();
     // --------------------------------------------------------------------------
     //	Shop's base currency (i.e what the products are listed in etc)
     if (!defined('SHOP_BASE_CURRENCY_SYMBOL')) {
         define('SHOP_BASE_CURRENCY_SYMBOL', $_base->symbol);
     }
     if (!defined('SHOP_BASE_CURRENCY_SYMBOL_POS')) {
         define('SHOP_BASE_CURRENCY_SYMBOL_POS', $_base->symbol_position);
     }
     if (!defined('SHOP_BASE_CURRENCY_PRECISION')) {
         define('SHOP_BASE_CURRENCY_PRECISION', $_base->decimal_precision);
     }
     if (!defined('SHOP_BASE_CURRENCY_CODE')) {
         define('SHOP_BASE_CURRENCY_CODE', $_base->code);
     }
     //	Formatting constants
     if (!defined('SHOP_BASE_CURRENCY_THOUSANDS')) {
         define('SHOP_BASE_CURRENCY_THOUSANDS', $_base->thousands_seperator);
     }
     if (!defined('SHOP_BASE_CURRENCY_DECIMALS')) {
         define('SHOP_BASE_CURRENCY_DECIMALS', $_base->decimal_symbol);
     }
     //	User's preferred currency
     if ($this->session->userdata('shop_currency')) {
         //	Use the currency defined in the session
         $_currency_code = $this->session->userdata('shop_currency');
     } elseif (active_user('shop_currency')) {
         //	Use the currency defined in the user object
         $_currency_code = active_user('shop_currency');
         if (!headers_sent()) {
             $this->session->set_userdata('shop_currency', $_currency_code);
         }
     } else {
         //	Can we determine the user's location and set a currency based on that?
         //	If not, fall back to base currency
         $this->load->library('geo_ip');
         $_lookup = $this->geo_ip->country();
         if (!empty($_lookup->status) && $_lookup->status == 200) {
             //	We know the code, does it have a known currency?
             $_country_currency = $this->shop_currency_model->get_by_country($_lookup->country->iso);
             if ($_country_currency) {
                 $_currency_code = $_country_currency->code;
             } else {
                 //	Fall back to default
                 $_currency_code = $_base->code;
             }
         } else {
             $_currency_code = $_base->code;
         }
         //	Save to session
         if (!headers_sent()) {
             $this->session->set_userdata('shop_currency', $_currency_code);
         }
     }
     //	Fetch the user's render currency
     $_user_currency = $this->shop_currency_model->get_by_code($_currency_code);
     if (!$_user_currency) {
         //	Bad currency code
         $_user_currency = $_base;
         if (!headers_sent()) {
             $this->session->unset_userdata('shop_currency', $_currency_code);
         }
         if ($this->user_model->is_logged_in()) {
             $this->user_model->update(active_user('id'), array('shop_currency' => NULL));
         }
     }
     //	Set the user constants
     if (!defined('SHOP_USER_CURRENCY_SYMBOL')) {
         define('SHOP_USER_CURRENCY_SYMBOL', $_user_currency->symbol);
     }
     if (!defined('SHOP_USER_CURRENCY_SYMBOL_POS')) {
         define('SHOP_USER_CURRENCY_SYMBOL_POS', $_user_currency->symbol_position);
     }
     if (!defined('SHOP_USER_CURRENCY_PRECISION')) {
         define('SHOP_USER_CURRENCY_PRECISION', $_user_currency->decimal_precision);
     }
     if (!defined('SHOP_USER_CURRENCY_CODE')) {
         define('SHOP_USER_CURRENCY_CODE', $_user_currency->code);
     }
     //	Formatting constants
     if (!defined('SHOP_USER_CURRENCY_THOUSANDS')) {
         define('SHOP_USER_CURRENCY_THOUSANDS', $_user_currency->thousands_seperator);
     }
     if (!defined('SHOP_USER_CURRENCY_DECIMALS')) {
         define('SHOP_USER_CURRENCY_DECIMALS', $_user_currency->decimal_symbol);
     }
 }
示例#28
0
	</p>
	<?php 
echo form_close();
?>
</div>

<script type="text/javascript">
	var _CREATE_EDIT;
	$(function(){

		_CREATE_EDIT	= new NAILS_Admin_Shop_Inventory_Create_Edit();
		_CREATE_EDIT.init(  <?php 
echo json_encode($product_types);
?>
, '<?php 
echo $this->cdn->generate_api_upload_token(active_user('id'));
?>
' );

	});
</script>

<script type="text/template" id="template-variation">
<?php 
$_data = array();
$_data['is_first'] = FALSE;
$_data['is_php'] = FALSE;
$_data['counter'] = FALSE;
$_data['variation'] = NULL;
$_data['num_variants'] = NULL;
$this->load->view('admin/shop/inventory/utilities/template-mustache-inventory-variant', $_data);
示例#29
0
 /**
  * View a single article
  *
  * @access public
  * @return void
  **/
 public function single($id = NULL)
 {
     //	Get the single post by its slug
     if ($id) {
         $this->data['post'] = $this->blog_post_model->get_by_id($id);
         if ($this->data['post']->url != $this->input->server('REQUEST_URI')) {
             redirect($this->data['post']->url, 'location', 301);
         }
     } else {
         $this->data['post'] = $this->blog_post_model->get_by_slug($this->uri->rsegment(2));
     }
     // --------------------------------------------------------------------------
     //	Check we have something to show, otherwise, bail out
     if (!$this->data['post']) {
         show_404();
     }
     // --------------------------------------------------------------------------
     //	If this post's status is not published then 404, unless logged in as an admin
     if (!$this->data['post']->is_published && !$this->user_model->is_admin()) {
         show_404();
     }
     // --------------------------------------------------------------------------
     //	Widgets
     $this->_fetch_sidebar_widgets();
     // --------------------------------------------------------------------------
     //	Meta
     $this->data['page']->title = $this->_blog_name . ': ';
     $this->data['page']->title .= $this->data['post']->seo_title ? $this->data['post']->seo_title : $this->data['post']->title;
     $this->data['page']->seo->description = $this->data['post']->seo_description;
     $this->data['page']->seo->keywords = $this->data['post']->seo_keywords;
     // --------------------------------------------------------------------------
     //	Assets
     if (app_setting('social_enabled', 'blog')) {
         $this->asset->load('social-likes/social-likes.min.js', 'BOWER');
         switch (app_setting('social_skin', 'blog')) {
             case 'FLAT':
                 $this->asset->load('social-likes/social-likes_flat.css', 'BOWER');
                 break;
             case 'BIRMAN':
                 $this->asset->load('social-likes/social-likes_birman.css', 'BOWER');
                 break;
             case 'CLASSIC':
             default:
                 $this->asset->load('social-likes/social-likes_classic.css', 'BOWER');
                 break;
         }
     }
     // --------------------------------------------------------------------------
     //	Load views
     $this->load->view('structure/header', $this->data);
     $this->load->view($this->_skin->path . 'views/single', $this->data);
     $this->load->view('structure/footer', $this->data);
     // --------------------------------------------------------------------------
     //	Register a hit
     $_data = array();
     $_data['user_id'] = active_user('id');
     $_data['referrer'] = $this->input->server('HTTP_REFERER');
     $this->blog_post_model->add_hit($this->data['post']->id, $_data);
 }
示例#30
0
echo NAILS_ASSETS_URL . 'bower_components/html5shiv/dist/html5shiv.js';
?>
"></script>
		  <script src="<?php 
echo NAILS_ASSETS_URL . 'bower_components/respond/dest/respond.min.js';
?>
"></script>
		<![endif]-->
	</head>
	<body>
		<div class="container">
			<div class="row text-center" style="margin-top:1em;">
				<?php 
if ($user->was_admin()) {
    echo '<div class="alert alert-info text-left">';
    echo 'Logged in as <strong>' . active_user('first_name,last_name') . ' (' . active_user('email') . ')</strong>.';
    echo anchor($this->session->userdata('admin_recovery')->back_to_admin_url, 'Back to Admin', 'class="pull-right btn btn-sm btn-default" style="margin-top:-0.5em;"');
    echo '</div>';
}
?>
				<h1>
					<?php 
echo anchor('', APP_NAME, 'style="text-decoration:none;color:inherit;"');
?>
				</h1>
				<p>
					<?php 
echo NAILS_APP_STRAPLINE;
?>
				</p>
			</div><!-- /.row -->