Example #1
0
 /**
  * Gets the value of a user state variable.
  *
  * @param   string  $key      The key of the user state variable.
  * @param   string  $request  The name of the variable passed in a request.
  * @param   string  $default  The default value for the variable if not found. Optional.
  * @param   string  $type     Filter for the variable. Optional.
  * @return  The request user state.
  */
 public static function getState($key, $request, $default = null, $type = 'none')
 {
     $cur_state = \User::getState($key, $default);
     $new_state = self::getVar($request, null, 'default', $type);
     // Save the new value only if it was set in this request.
     if ($new_state !== null) {
         switch ($type) {
             case 'int':
                 $new_state = intval($new_state);
                 break;
             case 'word':
                 $new_state = preg_replace('/[^A-Z_]/i', '', $new_state);
                 break;
             case 'cmd':
                 $new_state = preg_replace('/[^A-Z0-9_\\.-]/i', '', $new_state);
                 break;
             case 'bool':
                 $new_state = (bool) $new_state;
                 break;
             case 'float':
                 $new_state = preg_replace('/-?[0-9]+(\\.[0-9]+)?/', '', $new_state);
                 break;
             case 'string':
                 $new_state = (string) $new_state;
                 break;
             case 'array':
                 $new_state = (array) $new_state;
                 break;
         }
         \User::setState($key, $new_state);
     } else {
         $new_state = $cur_state;
     }
     return $new_state;
 }
Example #2
0
 /**
  * Displays the view
  *
  * @param   string  $tpl  The name of the template file to parse
  * @return  void
  */
 public function display($tpl = null)
 {
     Html::behavior('framework');
     \Hubzero\Document\Assets::addComponentStylesheet('com_languages', 'overrider.css');
     \Hubzero\Document\Assets::addComponentScript('com_languages', 'overrider.js');
     //Document::addStyleSheet(Request::root().'media/overrider/css/overrider.css');
     //Document::addScript(Request::root().'media/overrider/js/overrider.js');
     $this->form = $this->get('Form');
     $this->item = $this->get('Item');
     $this->state = $this->get('State');
     // Check for errors
     if (count($errors = $this->get('Errors'))) {
         throw new Exception(implode("\n", $errors));
         return;
     }
     // Check whether the cache has to be refreshed
     $cached_time = User::getState('com_languages.overrides.cachedtime.' . $this->state->get('filter.client') . '.' . $this->state->get('filter.language'), 0);
     if (time() - $cached_time > 60 * 5) {
         $this->state->set('cache_expired', true);
     }
     // Add strings for translations in Javascript
     JText::script('COM_LANGUAGES_VIEW_OVERRIDE_NO_RESULTS');
     JText::script('COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR');
     $this->addToolbar();
     parent::display($tpl);
 }
Example #3
0
 /**
  * Gets the request filters and returns them
  *
  * @param  string $namespace the application state variable namespace
  * @return array
  **/
 public static function getFilters($namespace)
 {
     // Process query filters
     $q = User::getState("{$namespace}.query");
     if ($incoming = Request::getVar('q', false)) {
         $q[] = $incoming;
     }
     // Set some defaults for the filters, if not set otherwise
     if (!is_array($q)) {
         $q[0]['column'] = $namespace == 'com_time.tasks' ? 'assignee_id' : 'user_id';
         $q[0]['operator'] = 'e';
         $q[0]['value'] = User::get('id');
     }
     // Translate operators and augment query filters with human-friendly text
     $query = self::filtersMap($q);
     // Turn search into array of results, if not already
     $search = Request::getVar('search', User::getState("{$namespace}.search", ''));
     // If we have a search and it's not an array (i.e. it's coming in fresh with this request)
     if ($search && !is_array($search)) {
         // Explode multiple words into array
         $search = explode(" ", $search);
         // Only allow alphabetical characters for search
         $search = preg_replace("/[^a-zA-Z]/", "", $search);
     }
     // Set some values in the session
     User::setState("{$namespace}.search", $search);
     User::setState("{$namespace}.query", $query);
     return array('search' => $search, 'q' => $query);
 }
Example #4
0
 /**
  * Method to get the data that should be injected in the form.
  *
  * @return	mixed	The data for the form.
  * @since	1.6
  */
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = User::getState('com_templates.edit.source.data', array());
     if (empty($data)) {
         $data = $this->getSource();
     }
     return $data;
 }
Example #5
0
 /**
  * Method to get the data that should be injected in the form.
  *
  * @return  array    The default data is an empty array.
  * @since   11.1
  */
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = \User::getState('com_groups.edit.group.data', array());
     if (empty($data)) {
         $data = $this->getItem();
     }
     return $data;
 }
Example #6
0
 /**
  * Method to auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @since	1.6
  */
 protected function populateState($ordering = null, $direction = null)
 {
     // Load the filter state.
     $clientId = User::getState('com_modules.modules.filter.client_id', 0);
     $this->setState('filter.client_id', (int) $clientId);
     // Load the parameters.
     $params = Component::params('com_modules');
     $this->setState('params', $params);
     // Manually set limits to get all modules.
     $this->setState('list.limit', 0);
     $this->setState('list.start', 0);
     $this->setState('list.ordering', 'a.name');
     $this->setState('list.direction', 'ASC');
 }
Example #7
0
 /**
  * Method to get the data that should be injected in the form.
  *
  * @return	mixed	The data for the form.
  * @since	1.6
  */
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = User::getState('com_users.edit.user.data', array());
     if (empty($data)) {
         $data = $this->getItem();
     }
     // TODO: Maybe this can go into the parent model somehow?
     // Trigger the data preparation event.
     $results = Event::trigger('user.onContentPrepareData', array('com_admin.profile', $data));
     // Check for errors encountered while preparing the data.
     if (count($results) && in_array(false, $results, true)) {
         $this->setError($dispatcher->getError());
     }
     return $data;
 }
    /**
     * @param	JForm	$form	The form to be altered.
     * @param	array	$data	The associated data for the form.
     *
     * @return	boolean
     * @since	2.5
     */
    public function onContentPrepareForm($form, $data)
    {
        // Check we have a form
        if (!$form instanceof JForm) {
            $this->_subject->setError('JERROR_NOT_A_FORM');
            return false;
        }
        // Check we are manipulating a valid form.
        if ($form->getName() != 'com_plugins.plugin' || isset($data->name) && $data->name != 'plg_system_languagecode' || empty($data) && !User::getState('plg_system_language_code.edit')) {
            return true;
        }
        // Mark the plugin as being edited
        User::setState('plg_system_language_code.edit', $data->name == 'plg_system_languagecode');
        // Get site languages
        $languages = Lang::getKnownLanguages(JPATH_SITE);
        // Inject fields into the form
        foreach ($languages as $tag => $language) {
            $form->load('
<form>
	<fields name="params">
		<fieldset
			name="languagecode"
			label="PLG_SYSTEM_LANGUAGECODE_FIELDSET_LABEL"
			description="PLG_SYSTEM_LANGUAGECODE_FIELDSET_DESC"
		>
			<field
				name="' . strtolower($tag) . '"
				type="text"
				description="' . htmlspecialchars(Lang::txt('PLG_SYSTEM_LANGUAGECODE_FIELD_DESC', $language['name']), ENT_COMPAT, 'UTF-8') . '"
				translate_description="false"
				label="' . $tag . '"
				translate_label="false"
				size="7"
				filter="cmd"
			/>
		</fieldset>
	</fields>
</form>
			');
        }
        return true;
    }
Example #9
0
 /**
  * Update a set of extensions.
  *
  * @since	1.6
  */
 public function update()
 {
     // Check for request forgeries
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     $model = new Models\Update();
     $uid = Request::getVar('cid', array(), '', 'array');
     \Hubzero\Utility\Arr::toInteger($uid, array());
     if ($model->update($uid)) {
         App::get('cache')->clean('mod_menu');
     }
     $redirect_url = User::getState('com_installer.redirect_url');
     if (empty($redirect_url)) {
         $redirect_url = Route::url('index.php?option=com_installer&view=update', false);
     } else {
         // wipe out the user state when we're going to redirect
         User::setState('com_installer.redirect_url', '');
         User::setState('com_installer.message', '');
         User::setState('com_installer.extension_message', '');
     }
     App::redirect($redirect_url);
 }
Example #10
0
 /**
  * Method to get the configuration data.
  *
  * This method will load the global configuration data straight from
  * JConfig. If configuration data has been saved in the session, that
  * data will be merged into the original data, overwriting it.
  *
  * @return  array  An array containg all global config data.
  * @since   1.6
  */
 public function getData()
 {
     // Get the config data.
     //$config = new JConfig();
     $data = Config::getRoot()->toArray();
     //\Hubzero\Utility\Arr::fromObject($config);
     // Prime the asset_id for the rules.
     $data['asset_id'] = 1;
     // Get the text filter data
     $params = \Component::params('com_config');
     $data['filters'] = \Hubzero\Utility\Arr::fromObject($params->get('filters'));
     // If no filter data found, get from com_content (update of 1.6/1.7 site)
     if (empty($data['filters'])) {
         $contentParams = \Component::params('com_content');
         $data['filters'] = \Hubzero\Utility\Arr::fromObject($contentParams->get('filters'));
     }
     // Check for data in the session.
     $temp = User::getState('com_config.config.global.data');
     // Merge in the session data.
     if (!empty($temp)) {
         $data = array_merge($data, $temp);
     }
     return $data;
 }
Example #11
0
 /**
  * Method to get the data that should be injected in the form.
  *
  * @return	mixed	The data for the form.
  * @since	1.6
  */
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = User::getState('com_newsfeeds.edit.newsfeed.data', array());
     if (empty($data)) {
         $data = $this->getItem();
         // Prime some default values.
         if ($this->getState('newsfeed.id') == 0) {
             $data->set('catid', Request::getInt('catid', User::getState('com_newsfeeds.newsfeeds.filter.category_id')));
         }
     }
     return $data;
 }
Example #12
0
echo CHtml::encode($data->email);
?>
	<br />

	<b><?php 
echo CHtml::encode($data->getAttributeLabel('activation_key'));
?>
:</b>
	<?php 
echo CHtml::encode($data->activation_key);
?>
	<br />

	<b><?php 
echo CHtml::encode($data->getAttributeLabel('status'));
?>
:</b>
	<?php 
echo CHtml::encode(User::getState($data->status));
?>
	<br />

	<?php 
/*
	<b><?php echo CHtml::encode($data->getAttributeLabel('created_at')); ?>:</b>
	<?php echo CHtml::encode($data->created_at); ?>
	<br />
*/
?>

</div>
Example #13
0
 /**
  * Method to get the data that should be injected in the form.
  *
  * @return  mixed  The data for the form.
  *
  * @since   1.6
  */
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = User::getState('com_modules.edit.module.data', array());
     if (empty($data)) {
         $data = $this->getItem();
         // This allows us to inject parameter settings into a new module.
         $params = User::getState('com_modules.add.module.params');
         if (is_array($params)) {
             $data->set('params', $params);
         }
     }
     return $data;
 }
Example #14
0
 /**
  * Method to get the data that should be injected in the form.
  *
  * @return	mixed	The data for the form.
  * @since	1.6
  */
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = User::getState($this->context . '.data', array());
     return $data;
 }
Example #15
0
//$newPoint = new Point(0, 'Foyer');
//echo $newPoint->getName();
echo '<h2>Ok id etu</h2>';
$User = new User('6362', 2, '', 1);
echo $User->getState();
echo '<h2>Ok id buckutt</h2>';
$User = new User('1', 3, '', 1);
echo $User->getState();
echo '<h2>Ok login</h2>';
$User = new User('bernardx', 1, '', 1);
echo $User->getState();
echo '<h2>usr inconnu</h2>';
$User = new User('636462', 2, '', 1);
echo $User->getState();
echo $User->getFirstname();
echo '<h2>Avec mot de passe</h2>';
$User = new User('bernardx', 1, 'toto');
echo $User->getState() . '<br />';
echo $User->getId() . '<br />';
echo $User->getFirstname() . '<br />';
echo $User->getLastname() . '<br />';
echo $User->getNickname() . '<br />';
echo $User->getMail() . '<br />';
echo $User->getCredit() . '<br />';
echo $User->getIp();
/*
echo '<h2>Avec mot de passe faux</h2>';
$User = new User('6362', 2, 'pezfzev');
echo $User->getState();
echo $User->getLastname();
*/
Example #16
0
 /**
  * Set local password
  *
  * @return void - redirect to members account page
  */
 private function setlocalpass()
 {
     // Logged in?
     if ($this->user->get('guest')) {
         App::redirect(Route::url('index.php?option=com_users&view=login&return=' . base64_encode(Route::url('index.php?option=' . $this->option . '&task=myaccount&active=account&action=setlocalpass'))), Lang::txt('You must be a logged in to access this area.'), 'warning');
         return;
     }
     // Get the token from the user state variable
     $token = User::getState($this->option . 'token');
     // First check to make sure they're not trying to jump to this page without first verifying their token
     if (is_null($token)) {
         // Tsk tsk, no sneaky business
         App::redirect(Route::url('index.php?option=' . $this->option . '&id=' . $this->user->get('id') . '&active=account&task=sendtoken'), Lang::txt('You must first verify your email address by inputting the token.'), 'error');
         return;
     }
     // Get the password input
     $password1 = Request::getVar('password1', null, 'post', 'string', JREQUEST_ALLOWRAW);
     $password2 = Request::getVar('password2', null, 'post', 'string', JREQUEST_ALLOWRAW);
     $change = Request::getVar('change', '', 'post');
     // Create the view
     $view = new \Hubzero\Plugin\View(array('folder' => 'members', 'element' => 'account', 'name' => 'setlocalpassword', 'layout' => 'setlocalpass'));
     // Add a few more variables to the view
     $view->option = $this->option;
     $view->id = $this->user->get('id');
     // Get the password rules
     $password_rules = \Hubzero\Password\Rule::getRules();
     // Get the password rule descriptions
     $view->password_rules = array();
     foreach ($password_rules as $rule) {
         if (!empty($rule['description'])) {
             $view->password_rules[] = $rule['description'];
         }
     }
     // Blank form request (no data submitted)
     if (empty($change)) {
         $view->notifications = $this->getPluginMessage() ? $this->getPluginMessage() : array();
         return $view->loadTemplate();
     }
     // Check for request forgeries
     Request::checkToken();
     // Load some needed libraries
     jimport('joomla.user.helper');
     // Initiate profile classs
     $profile = new \Hubzero\User\Profile();
     $profile->load($this->user->get('id'));
     // Fire the onBeforeStoreUser trigger
     Event::trigger('user.onBeforeStoreUser', array($this->user->getProperties(), false));
     // Validate the password against password rules
     if (!empty($password1)) {
         $msg = \Hubzero\Password\Rule::validate($password1, $password_rules, $profile->get('username'));
     } else {
         $msg = array();
     }
     // Verify password
     $passrules = false;
     if (!$password1 || !$password2) {
         $this->setError(Lang::txt('MEMBERS_PASS_MUST_BE_ENTERED_TWICE'));
     } elseif ($password1 != $password2) {
         $this->setError(Lang::txt('MEMBERS_PASS_NEW_CONFIRMATION_MISMATCH'));
     } elseif (!empty($msg)) {
         $this->setError(Lang::txt('Password does not meet site password requirements. Please choose a password meeting all the requirements listed.'));
         $passrules = true;
     }
     // Were there any errors?
     if ($this->getError()) {
         $change = array();
         $change['_missing']['password'] = $this->getError();
         if (!empty($msg) && $passrules) {
             //$change = $msg;
         }
         if (Request::getInt('no_html', 0)) {
             echo json_encode($change);
             exit;
         } else {
             $view->setError($this->getError());
             return $view->loadTemplate();
         }
     }
     // No errors, so let's move on - encrypt the password and update the profile
     $result = \Hubzero\User\Password::changePassword($profile->get('uidNumber'), $password1);
     // Save the changes
     if (!$result) {
         $view->setError(Lang::txt('MEMBERS_PASS_CHANGE_FAILED'));
         return $view->loadTemplate();
     }
     // Fire the onAfterStoreUser trigger
     Event::trigger('user.onAfterStoreUser', array($this->user->getProperties(), false, null, $this->getError()));
     // Flush the variables from the session
     User::setState($this->option . 'token', null);
     // Redirect
     if (Request::getInt('no_html', 0)) {
         echo json_encode(array("success" => true, "redirect" => Route::url($this->member->getLink() . '&active=account')));
         exit;
     } else {
         // Redirect user to confirm view page
         App::redirect(Route::url($this->member->getLink() . '&active=account'), Lang::txt('Password reset successful'), 'passed');
     }
     return;
 }
Example #17
0
 /**
  * Method to get the data that should be injected in the form.
  *
  * @return  mixed  The data for the form.
  *
  * @since   1.6
  */
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = User::getState('com_categories.edit.' . $this->getName() . '.data', array());
     if (empty($data)) {
         $data = $this->getItem();
     }
     return $data;
 }
Example #18
0
 /**
  * Method to save a user's profile data.
  *
  * @return	void
  * @since	1.6
  */
 public function save()
 {
     // Check for request forgeries.
     Session::checkToken() or exit(Lang::txt('JINVALID_TOKEN'));
     // Initialise variables.
     $app = JFactory::getApplication();
     $model = $this->getModel('Profile', 'UsersModel');
     $user = User::getRoot();
     $userId = (int) $user->get('id');
     // Get the user data.
     $data = Request::getVar('jform', array(), 'post', 'array');
     // Force the ID to this user.
     $data['id'] = $userId;
     // Validate the posted data.
     $form = $model->getForm();
     if (!$form) {
         App::abort(500, $model->getError());
         return false;
     }
     // Validate the posted data.
     $data = $model->validate($form, $data);
     // Check for errors.
     if ($data === false) {
         // Get the validation messages.
         $errors = $model->getErrors();
         // Push up to three validation messages out to the user.
         for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) {
             if ($errors[$i] instanceof Exception) {
                 Notify::warning($errors[$i]->getMessage());
             } else {
                 Notify::warning($errors[$i]);
             }
         }
         // Save the data in the session.
         $app->setUserState('com_users.edit.profile.data', $data);
         // Redirect back to the edit screen.
         $userId = (int) User::setState('com_users.edit.profile.id');
         $this->setRedirect(Route::url('index.php?option=com_users&view=profile&layout=edit&user_id=' . $userId, false));
         return false;
     }
     // Attempt to save the data.
     $return = $model->save($data);
     // Check for errors.
     if ($return === false) {
         // Save the data in the session.
         User::setState('com_users.edit.profile.data', $data);
         // Redirect back to the edit screen.
         $userId = (int) User::getState('com_users.edit.profile.id');
         $this->setMessage(Lang::txt('COM_USERS_PROFILE_SAVE_FAILED', $model->getError()), 'warning');
         $this->setRedirect(Route::url('index.php?option=com_users&view=profile&layout=edit&user_id=' . $userId, false));
         return false;
     }
     // Redirect the user and adjust session state based on the chosen task.
     switch ($this->getTask()) {
         case 'apply':
             // Check out the profile.
             User::setState('com_users.edit.profile.id', $return);
             $model->checkout($return);
             // Redirect back to the edit screen.
             $this->setMessage(Lang::txt('COM_USERS_PROFILE_SAVE_SUCCESS'));
             $this->setRedirect(Route::url(($redirect = User::getState('com_users.edit.profile.redirect')) ? $redirect : 'index.php?option=com_users&view=profile&layout=edit&hidemainmenu=1', false));
             break;
         default:
             // Check in the profile.
             $userId = (int) User::getState('com_users.edit.profile.id');
             if ($userId) {
                 $model->checkin($userId);
             }
             // Clear the profile id from the session.
             User::setState('com_users.edit.profile.id', null);
             // Redirect to the list screen.
             $this->setMessage(Lang::txt('COM_USERS_PROFILE_SAVE_SUCCESS'));
             $this->setRedirect(Route::url(($redirect = User::getState('com_users.edit.profile.redirect')) ? $redirect : 'index.php?option=com_users&view=profile&user_id=' . $return, false));
             break;
     }
     // Flush the data from the session.
     User::setState('com_users.edit.profile.data', null);
 }
Example #19
0
 /**
  * Method to get the data that should be injected in the form.
  *
  * @return	mixed	The data for the form.
  * @since	1.6
  */
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = User::getState('com_installer.manage.data', array());
     return $data;
 }
Example #20
0
 /**
  * Method to check whether an ID is in the edit list.
  *
  * @param   string   $context  The context for the session storage.
  * @param   integer  $id       The ID of the record to add to the edit list.
  * @return  boolean  True if the ID is in the edit list.
  */
 protected function checkEditId($context, $id)
 {
     if ($id) {
         $values = (array) User::getState($context . '.id');
         return in_array((int) $id, $values);
     }
     return true;
 }
Example #21
0
 /**
  * Retrieves state vars set in the model namespace
  *
  * @param   string  $var      The var to attempt to retrieve
  * @param   mixed   $default  The default to return, should the var be unknown
  * @return  mixed
  * @since   2.0.0
  **/
 public function getState($var, $default = null)
 {
     return User::getState($this->getModelName() . ".{$var}", $default);
 }
Example #22
0
 /**
  * Method to save the form data.
  *
  * @param		array		$data							The form data.
  * @param		boolean	$opposite_client	Indicates whether the override should not be created for the current client
  *
  * @return	boolean	True on success, false otherwise.
  *
  * @since		2.5
  */
 public function save($data, $opposite_client = false)
 {
     require_once JPATH_COMPONENT . '/helpers/languages.php';
     $client = User::getState('com_languages.overrides.filter.client', 0);
     $language = User::getState('com_languages.overrides.filter.language', 'en-GB');
     // If the override should be created for both
     if ($opposite_client) {
         $client = 1 - $client;
     }
     $client = $client ? 'administrator' : 'site';
     // Parse the override.ini file in oder to get the keys and strings
     $filename = PATH_APP . '/bootstrap/' . $client . '/language/overrides/' . $language . '.override.ini';
     $strings = LanguagesHelper::parseFile($filename);
     if (isset($strings[$data['id']])) {
         // If an existent string was edited check whether
         // the name of the constant is still the same
         if ($data['key'] == $data['id']) {
             // If yes, simply override it
             $strings[$data['key']] = $data['override'];
         } else {
             // If no, delete the old string and prepend the new one
             unset($strings[$data['id']]);
             $strings = array($data['key'] => $data['override']) + $strings;
         }
     } else {
         // If it is a new override simply prepend it
         $strings = array($data['key'] => $data['override']) + $strings;
     }
     foreach ($strings as $key => $string) {
         $strings[$key] = str_replace('"', '"_QQ_"', $string);
     }
     // Write override.ini file with the strings
     $registry = new \Hubzero\Config\Registry($strings);
     if (!Filesystem::write($filename, $registry->toString('INI'))) {
         return false;
     }
     // If the override should be stored for both clients save
     // it also for the other one and prevent endless recursion
     if (isset($data['both']) && $data['both'] && !$opposite_client) {
         return $this->save($data, true);
     }
     return true;
 }
Example #23
0
 /**
  * Display the editor area.
  *
  * @param   string   $name     The control name.
  * @param   string   $html     The contents of the text area.
  * @param   string   $width    The width of the text area (px or %).
  * @param   string   $height   The height of the text area (px or %).
  * @param   int      $col      The number of columns for the textarea.
  * @param   int      $row      The number of rows for the textarea.
  * @param   boolean  $buttons  True and the editor buttons will be displayed.
  * @param   string   $id       An optional ID for the textarea (note: since 1.6). If not supplied the name is used.
  * @param   string   $asset
  * @param   object   $author
  * @param   array    $params   Associative array of editor parameters.
  * @return  string HTML
  */
 public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array())
 {
     if (empty($id)) {
         $id = $name;
     }
     // Only add "px" to width and height if they are not given as a percentage
     if (is_numeric($width)) {
         $width .= 'px';
     }
     if (is_numeric($height)) {
         $height .= 'px';
     }
     // Must pass the field id to the buttons in this editor.
     $buttons = $this->_displayButtons($id, $buttons, $asset, $author);
     $compressed = Config::get('debug') ? '-uncompressed' : '';
     // Default syntax
     $parserFile = 'parsexml.js';
     $styleSheet = array('xmlcolors.css');
     // Look if we need special syntax coloring.
     $syntax = User::getState('editor.source.syntax');
     if ($syntax) {
         switch ($syntax) {
             case 'css':
                 $parserFile = 'parsecss.js';
                 $styleSheet = array('csscolors.css');
                 break;
             case 'js':
                 $parserFile = array('tokenizejavascript.js', 'parsejavascript.js');
                 $styleSheet = array('jscolors.css');
                 break;
             case 'html':
                 $parserFile = array('parsexml.js', 'parsecss.js', 'tokenizejavascript.js', 'parsejavascript.js', 'parsehtmlmixed.js');
                 $styleSheet = array('xmlcolors.css', 'jscolors.css', 'csscolors.css');
                 break;
             case 'php':
                 $parserFile = array('parsexml.js', 'parsecss.js', 'tokenizejavascript.js', 'parsejavascript.js', 'tokenizephp.js', 'parsephp.js', 'parsephphtmlmixed.js');
                 $styleSheet = array('xmlcolors.css', 'jscolors.css', 'csscolors.css', 'phpcolors.css');
                 break;
             default:
                 break;
         }
         //switch
     }
     foreach ($styleSheet as &$style) {
         $style = Request::root() . '/' . $this->_basePath . 'assets/css/' . $style;
     }
     $options = new stdClass();
     $options->basefiles = array('basefiles' . $compressed . '.js');
     $options->path = Request::root() . '/' . $this->_basePath . 'assets/js/';
     $options->parserfile = $parserFile;
     $options->stylesheet = $styleSheet;
     $options->height = $height;
     $options->width = $width;
     $options->continuousScanning = 500;
     if ($this->params->get('linenumbers', 0)) {
         $options->lineNumbers = true;
         $options->textWrapping = false;
     }
     if ($this->params->get('tabmode', '') == 'shift') {
         $options->tabMode = 'shift';
     }
     $html = array();
     $html[] = "<textarea name=\"{$name}\" id=\"{$id}\" cols=\"{$col}\" rows=\"{$row}\">{$content}</textarea>";
     $html[] = $buttons;
     $html[] = '<script type="text/javascript">';
     $html[] = '(function() {';
     $html[] = 'var editor = CodeMirror.fromTextArea("' . $id . '", ' . json_encode($options) . ');';
     $html[] = 'Joomla.editors.instances[\'' . $id . '\'] = editor;';
     $html[] = '})()';
     $html[] = '</script>';
     return implode("\n", $html);
 }
Example #24
0
<?php

/* @var $this UserController */
/* @var $model User */
$this->breadcrumbs = array('Пользователи' => array('index'), $model->login);
$this->menu = array(array('label' => 'Список', 'url' => array('index')), array('label' => 'Создать', 'url' => array('create')), array('label' => 'Редактировать', 'url' => array('update', 'id' => $model->id)), array('label' => 'Удалить', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')), array('label' => 'Управление', 'url' => array('admin')));
$profile = $model->profile;
?>

<h1>Просмотр пользователя <?php 
echo $model->login;
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', 'login', 'password', 'salt', 'email', 'activation_key', array('label' => $model->getAttributeLabel('status'), 'value' => User::getState($model->status)), 'created_at')));
?>

<h1>Профиль пользователя <?php 
echo $model->login;
?>
</h1>

<?php 
$this->widget('zii.widgets.CDetailView', array('data' => $profile, 'attributes' => array('first_name', 'second_name', 'third_name', array('label' => 'Город', 'value' => $profile->getRegion()), 'address', 'email', 'phone', 'gender' => array('label' => 'Пол', 'value' => $profile->getGenderInfo()), 'family' => array('label' => 'Семейное положение', 'value' => $profile->getFamilyState()), 'activities', 'interests', 'music', 'quotes', 'about')));
Example #25
0
 /**
  * Retrieves state vars set in the model namespace
  *
  * @param   string  $var      The var to attempt to retrieve
  * @param   mixed   $default  The default to return, should the var be unknown
  * @return  mixed
  * @since   2.0.0
  **/
 public function getState($var, $default = null)
 {
     $key = str_replace('\\', '.', $this->getModelNamespace()) . '.' . $this->getModelName() . ".{$var}";
     return User::getState($key, $default);
 }
Example #26
0
 /**
  * Method to log in a user.
  *
  * @since	1.6
  */
 public function login()
 {
     // Populate the data array:
     $data = array();
     $options = array();
     $data['return'] = base64_decode(Request::getVar('return', '', 'POST', 'BASE64'));
     $data['username'] = Request::getVar('username', '', 'method', 'username');
     $data['password'] = Request::getString('passwd', '', 'post', JREQUEST_ALLOWRAW);
     $authenticator = Request::getVar('authenticator', '', 'method');
     // If a specific authenticator is specified try to call the login method for that plugin
     if (!empty($authenticator)) {
         Plugin::import('authentication');
         $plugins = Plugin::byType('authentication');
         foreach ($plugins as $plugin) {
             $className = 'plg' . $plugin->type . $plugin->name;
             if ($plugin->name != $authenticator) {
                 continue;
             }
             if (class_exists($className)) {
                 if (method_exists($className, 'login')) {
                     $myplugin = new $className($this, (array) $plugin);
                     $myplugin->login($credentials, $options);
                     if (isset($options['return'])) {
                         $data['return'] = $options['return'];
                     }
                 }
                 $options['authenticator'] = $authenticator;
                 $options['action'] = 'core.login.site';
                 break;
             }
         }
     }
     // If no authenticator is specified, or the login method for that plugin did not exist then use joomla default
     if (!isset($myplugin)) {
         // Check for request forgeries
         Session::checkToken('request');
         if ($return = Request::getVar('return', '', 'method', 'base64')) {
             $return = base64_decode($return);
             if (!JURI::isInternal($return)) {
                 $return = '';
             }
         }
         if ($freturn = Request::getVar('freturn', '', 'method', 'base64')) {
             $freturn = base64_decode($freturn);
             if (!JURI::isInternal($freturn)) {
                 $freturn = '';
             }
         }
         // Get the log in options.
         $options = array();
         $options['remember'] = Request::getBool('remember', false);
         $options['return'] = $data['return'];
         $options['action'] = 'core.login.site';
         if (!empty($authenticator)) {
             $options['authenticator'] = $authenticator;
         }
         // Get the log in credentials.
         $credentials = array();
         $credentials['username'] = $data['username'];
         $credentials['password'] = $data['password'];
     }
     // Set the return URL if empty.
     if (empty($data['return'])) {
         $data['return'] = 'index.php?option=com_members&task=myaccount';
     }
     // Set the return URL in the user state to allow modification by plugins
     User::setState('users.login.form.return', $data['return']);
     try {
         $result = App::get('auth')->login($credentials, $options);
     } catch (Exception $e) {
         $result = $e;
     }
     // Perform the log in.
     if (true === $result) {
         // Success
         User::setState('users.login.form.data', array());
         // If no_html is set, return json response
         if (Request::getInt('no_html', 0)) {
             echo json_encode(array("success" => true, "redirect" => Route::url(User::getState('users.login.form.return'), false)));
             exit;
         } else {
             App::redirect(Route::url(User::getState('users.login.form.return'), false));
         }
     } else {
         // Login failed !
         $data['remember'] = isset($options['remember']) ? (int) $options['remember'] : 0;
         User::setState('users.login.form.data', $data);
         // Facilitate third party login forms
         if (!isset($return) || !$return) {
             $return = Route::url('index.php?option=com_users&view=login');
         }
         if (isset($freturn)) {
             $return = $freturn;
         }
         $error = $result ? $result->getMessage() : 'An unknown error has occurred';
         // If no_html is set, return json response
         if (Request::getInt('no_html', 0)) {
             echo json_encode(array("error" => $error, "freturn" => Route::url($return, false)));
             exit;
         } else {
             // Redirect to a login form
             App::redirect(Route::url($return, false), $error, 'error');
         }
     }
 }
Example #27
0
 /**
  * Bloquer qqn
  * 
  * @return int $state
  * @param int $usr_id
  */
 public function blockUser($usr_id)
 {
     if ($this->User->isBloqueur() != 1) {
         return 400;
     }
     $User = new User($usr_id, 3, '', '', 1);
     $User->blockMe();
     return $User->getState();
 }
Example #28
0
 /**
  * Auto-populate the model state.
  *
  * Note. Calling getState in this method will result in recursion.
  *
  * @return	void
  * @since	1.6
  */
 protected function populateState()
 {
     $app = JFactory::getApplication('administrator');
     // Load the User state.
     $pk = (int) Request::getInt('id');
     $this->setState('item.id', $pk);
     if (!($parentId = User::getState('com_menus.edit.item.parent_id'))) {
         $parentId = Request::getInt('parent_id');
     }
     $this->setState('item.parent_id', $parentId);
     $menuType = User::getState('com_menus.edit.item.menutype');
     if (Request::getCmd('menutype', false)) {
         $menuType = Request::getCmd('menutype', 'mainmenu');
     }
     $this->setState('item.menutype', $menuType);
     if (!($type = User::getState('com_menus.edit.item.type'))) {
         $type = Request::getCmd('type');
         // Note a new menu item will have no field type.
         // The field is required so the user has to change it.
     }
     $this->setState('item.type', $type);
     if ($link = User::getState('com_menus.edit.item.link')) {
         $this->setState('item.link', $link);
     }
     // Load the parameters.
     $params = Component::params('com_menus');
     $this->setState('params', $params);
 }
Example #29
0
 /**
  * Initializes pagination object
  *
  * @param   string  $namespace  The session state variable namespace
  * @param   int     $total      Total number of records
  * @param   string  $start      The variable name representing the pagination start number
  * @param   string  $limit      The variable name representing the pagination limit number
  * @return  object
  * @since   2.0.0
  **/
 public static function init($namespace, $total, $start = 'start', $limit = 'limit')
 {
     $instance = new self();
     $instance->total = $total;
     $instance->start = \Request::getInt($start, 0);
     $instance->limit = \Request::getInt($limit, User::getState($namespace . '.limit', \Config::get('list_limit')));
     User::setState($namespace . '.start', $instance->start);
     User::setState($namespace . '.limit', $instance->limit);
     return $instance;
 }
 function ShowURL($params)
 {
     $tempUser = new User($params['CustomerID']);
     //Customer Information from CE
     $params['userID'] = "CE" . $tempUser->getId();
     $params['userEmail'] = $tempUser->getEmail();
     $params['userFirstName'] = $tempUser->getFirstName();
     $params['userLastName'] = $tempUser->getLastName();
     $params['userOrganization'] = $tempUser->getOrganization();
     $params['userAddress'] = $tempUser->getAddress();
     $params['userCity'] = $tempUser->getCity();
     $params['userState'] = $tempUser->getState();
     $params['userZipcode'] = $tempUser->getZipCode();
     $params['userCountry'] = $tempUser->getCountry();
     $params['userPhone'] = $tempUser->getPhone();
     // Get customer Authnet CIM profile
     $customerProfile = $this->getCustomerProfile($params);
     if ($customerProfile['error']) {
         return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
             <html xmlns="http://www.w3.org/1999/xhtml">
                 <head>
                     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                     <title>Untitled Document</title>
                 </head>
                 <body>' . $customerProfile['detail'] . '</body>
             </html>';
     }
     //Authorize.net CIM Credentials from CE plugin
     $myapilogin = $this->settings->get('plugin_authnetcim_Authorize.Net CIM API Login ID');
     $mYtRaNsaCTiOnKEy = $this->settings->get('plugin_authnetcim_Authorize.Net CIM Transaction Key');
     $sandbox = $this->settings->get('plugin_authnetcim_Authorize.Net CIM Test Mode');
     $USE_DEVELOPMENT_SERVER = $sandbox ? AuthnetCIM::USE_DEVELOPMENT_SERVER : AuthnetCIM::USE_PRODUCTION_SERVER;
     //Need to check to see if user is coming from signup
     if ($params['isSignup']) {
         // Actually handle the signup URL setting
         if ($this->settings->get('Signup Completion URL') != '') {
             $returnURL = $this->settings->get('Signup Completion URL') . '?success=1';
         } else {
             $returnURL = $params["clientExecURL"] . "/order.php?step=complete&pass=1";
         }
         $hosted_Profile_Page_Border_Visible = 'true';
     } else {
         $hosted_Profile_Page_Border_Visible = 'false';
         $returnURL = $params['returnURL'];
     }
     // Get the Hosted Profile Page
     $hosted_Profile_Return_Url_Text = 'Continue to confirmation page.';
     $hosted_Profile_Card_Code_Required = 'true';
     $hosted_Profile_Billing_Address_Required = 'true';
     try {
         $cim = new AuthnetCIM($myapilogin, $mYtRaNsaCTiOnKEy, $USE_DEVELOPMENT_SERVER);
         $cim->setParameter('customerProfileId', $customerProfile['profile_id']);
         if ($params['isSignup']) {
             $cim->setParameter('hostedProfileReturnUrl', $returnURL);
         } else {
             $cim->setParameter('hostedProfileIFrameCommunicatorUrl', $returnURL);
         }
         $cim->setParameter('hostedProfileReturnUrlText', $hosted_Profile_Return_Url_Text);
         $cim->setParameter('hostedProfilePageBorderVisible', $hosted_Profile_Page_Border_Visible);
         $cim->setParameter('hostedProfileCardCodeRequired', $hosted_Profile_Card_Code_Required);
         $cim->setParameter('hostedProfileBillingAddressRequired', $hosted_Profile_Billing_Address_Required);
         $cim->getHostedProfilePage();
         // Get the token for the profile
         if ($cim->isSuccessful()) {
             $profile_token = $cim->getProfileToken();
             return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                 <html xmlns="http://www.w3.org/1999/xhtml">
                     <body>
                         <form id="formAuthorizeNetPage" method="post" action="https://' . ($sandbox ? 'test' : 'secure') . '.authorize.net/profile/manage">
                             <input type="hidden" name="token" value="' . $profile_token . '"/>
                         </form>
                         <script type="text/javascript">
                             document.getElementById("formAuthorizeNetPage").submit();
                         </script>
                     </body>
                 </html>';
         } else {
             return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
                 <html xmlns="http://www.w3.org/1999/xhtml">
                     <head>
                         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                         <title>Untitled Document</title>
                     </head>
                     <body>' . $cim->getResponseSummary() . '</body>
                 </html>';
         }
     } catch (AuthnetCIMException $e) {
         return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
             <html xmlns="http://www.w3.org/1999/xhtml">
                 <head>
                     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                     <title>Untitled Document</title>
                 </head>
                 <body>' . $e . '</body>
             </html>';
     }
 }