Beispiel #1
0
 function onContentPrepareData($context, $data)
 {
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->djcatalog2profile) and $userId > 0) {
             // Load the profile data from the database.
             $db = JFactory::getDbo();
             $db->setQuery('SELECT u.*, c.country_name FROM #__djc2_users as u INNER JOIN #__djc2_countries as c on c.id = u.country_id ' . ' WHERE user_id = ' . (int) $userId);
             $results = $db->loadAssoc();
             // Check for a database error.
             if ($db->getErrorNum()) {
                 $this->_subject->setError($db->getErrorMsg());
                 return false;
             }
             if (count($results)) {
                 // Merge the profile data.
                 $data->djcatalog2profile = array();
                 foreach ($results as $k => $v) {
                     $data->djcatalog2profile[$k] = $v;
                 }
             }
         }
     }
     if (!JHtml::isRegistered('users.country_id')) {
         JHtml::register('users.country_id', array(__CLASS__, 'country'));
     }
     if (!JHtml::isRegistered('users.www')) {
         JHtml::register('users.www', array(__CLASS__, 'www'));
     }
     return true;
 }
Beispiel #2
0
 /**
  * @param	string	$context	The context for the data
  * @param	int		$data		The user id
  * @param	object
  *
  * @return	boolean
  * @since	1.6
  */
 function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         // Load the profile data from the database.
         $db = JFactory::getDbo();
         $db->setQuery('SELECT profile_key, profile_value FROM #__user_profiles' . ' WHERE user_id = ' . (int) $userId . " AND profile_key LIKE 'profile.%'" . ' ORDER BY ordering');
         $results = $db->loadRowList();
         // Check for a database error.
         if ($db->getErrorNum()) {
             $this->_subject->setError($db->getErrorMsg());
             return false;
         }
         // Merge the profile data.
         $data->profile = array();
         foreach ($results as $v) {
             $k = str_replace('profile.', '', $v[0]);
             $data->profile[$k] = $v[1];
         }
         if (!JHtml::isRegistered('users.url')) {
             JHtml::register('users.url', array(__CLASS__, 'url'));
         }
         if (!JHtml::isRegistered('users.calendar')) {
             JHtml::register('users.calendar', array(__CLASS__, 'calendar'));
         }
         if (!JHtml::isRegistered('users.tos')) {
             JHtml::register('users.tos', array(__CLASS__, 'tos'));
         }
     }
     return true;
 }
Beispiel #3
0
 /**
  * Listener for onAfterInitialise event
  *
  * @return  void
  */
 public function onAfterInitialise()
 {
     // Only for site
     if (!$this->app->isSite()) {
         return;
     }
     // Register listeners for JHtml helpers
     if (!JHtml::isRegistered('bootstrap.loadCss')) {
         JHtml::register('bootstrap.loadCss', 'PlgSystemBootstrap3::loadCss');
     }
     if (!JHtml::isRegistered('bootstrap.carousel')) {
         JHtml::register('bootstrap.carousel', 'PlgSystemBootstrap3::carousel');
     }
 }
	/**
	 * @param	string	$context	The context for the data
	 * @param	int		$data		The user id
	 * @param	object
	 *
	 * @return	boolean
	 * @since	1.6
	 */
	function onContentPrepareData($context, $data)
	{
		// Check we are manipulating a valid form.
		if (!in_array($context, self::$forms)) {
			return true;
		}

		if (is_object($data)) {
			$userId = isset($data->id) ? $data->id : 0;

			if (!isset($data->gravatar) and $userId > 0) {	
				// Add the gravatar data.
				$data->gravatar = array();
				$data->gravatar['avatar'] = md5(strtolower(trim($data->email)));
			}

			if (!JHtml::isRegistered('users.gravatar')) {
				JHtml::register('users.gravatar', array(__CLASS__, 'gravatar'));
			}
		}

		return true;
	}
Beispiel #5
0
</dt>
		<dd>
			<?php 
            if (JHtml::isRegistered('users.' . $field->id)) {
                ?>
				<?php 
                echo JHtml::_('users.' . $field->id, $field->value);
                ?>
			<?php 
            } elseif (JHtml::isRegistered('users.' . $field->fieldname)) {
                ?>
				<?php 
                echo JHtml::_('users.' . $field->fieldname, $field->value);
                ?>
			<?php 
            } elseif (JHtml::isRegistered('users.' . $field->type)) {
                ?>
				<?php 
                echo JHtml::_('users.' . $field->type, $field->value);
                ?>
			<?php 
            } else {
                ?>
				<?php 
                echo JHtml::_('users.value', $field->value);
                ?>
			<?php 
            }
            ?>
		</dd>
		<?php 
Beispiel #6
0
 /**
  * Tests the isRegistered method.
  *
  * @return  void
  *
  * @since   11.1
  */
 public function testIsRegistered()
 {
     $registered = $this->getMock('MyHtmlClass', array('mockFunction'));
     // test that we can register the method
     JHtml::register('prefix.isregistered.method', array($registered, 'mockFunction'));
     $this->assertThat(JHtml::isRegistered('prefix.isregistered.method'), $this->isTrue(), 'Calling isRegistered on a valid method should pass.');
     $this->assertThat(JHtml::isRegistered('prefix.isregistered.nomethod'), $this->isFalse(), 'Calling isRegistered on a missing method should fail.');
 }
 /**
  * @param	JForm	$form	The form to be altered.
  * @param	array	$data	The associated data for the form.
  *
  * @return	boolean
  * @since	1.6
  */
 function onContentPrepareForm($form, $data)
 {
     if (!$form instanceof JForm) {
         $this->_subject->setError('JERROR_NOT_A_FORM');
         return false;
     }
     if (!JHtml::isRegistered('users.url')) {
         JHtml::register('users.url', array(__CLASS__, 'url'));
     }
     if (!JHtml::isRegistered('users.calendar')) {
         JHtml::register('users.calendar', array(__CLASS__, 'calendar'));
     }
     if (!JHtml::isRegistered('users.tos')) {
         JHtml::register('users.tos', array(__CLASS__, 'tos'));
     }
     // Check we are manipulating a valid form.
     $context = $form->getName();
     // The frontend and backend editor use the same form...
     if (!in_array($context, array('com_content.article'))) {
         return true;
     }
     // Note: The frontend form is generated by a custom view, we
     // have to alter it using template override to use our new fields
     // Load all needed field types (these are provided by the component)
     JForm::addFieldPath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplegeotag' . DS . 'models' . DS . 'fields');
     // Add the geotag fields to the form.
     JForm::addFormPath(dirname(__FILE__) . '/geotag');
     $form->loadFile('geotag', false);
     //throw new Exception(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_simplegeotag' . DS . 'models' . DS . 'fields');
     // Set whether location is requried
     $form->setFieldAttribute('latitude', 'required', $this->params->get('require_location') == 2, 'metadata');
     $form->setFieldAttribute('longitude', 'required', $this->params->get('require_location') == 2, 'metadata');
     return true;
 }
Beispiel #8
0
 /**
  * Runs on content preparation
  *
  * @param   string  $context  The context for the data
  * @param   object  $data     An object containing the data for the form.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->sibdiet) and $userId > 0) {
             // Load the profile data from the database.
             $db = JFactory::getDbo();
             $db->setQuery('SELECT * FROM #__sibdiet_profiles' . ' WHERE users_id = ' . (int) $userId);
             try {
                 $data->sibdiet = $db->loadAssoc();
                 $data->sibdiet['image'] = $data->sibdiet['id'] . '.jpg';
             } catch (RuntimeException $e) {
                 $this->_subject->setError($e->getMessage());
                 return false;
             }
         }
         if (!JHtml::isRegistered('users.Genders')) {
             JHtml::register('users.Genders', array(__CLASS__, 'Genders'));
         }
         if (!JHtml::isRegistered('users.Birthday')) {
             JHtml::register('users.Birthday', array(__CLASS__, 'Birthday'));
         }
         if (!JHtml::isRegistered('users.Maritals')) {
             JHtml::register('users.Maritals', array(__CLASS__, 'Maritals'));
         }
         if (!JHtml::isRegistered('users.Educations')) {
             JHtml::register('users.Educations', array(__CLASS__, 'Educations'));
         }
         if (!JHtml::isRegistered('users.Bloods')) {
             JHtml::register('users.Bloods', array(__CLASS__, 'Bloods'));
         }
         if (!JHtml::isRegistered('users.Countries')) {
             JHtml::register('users.Countries', array(__CLASS__, 'Countries'));
         }
         if (!JHtml::isRegistered('users.ProfilePic')) {
             JHtml::register('users.ProfilePic', array(__CLASS__, 'ProfilePic'));
         }
     }
     return true;
 }
Beispiel #9
0
	/**
	 * testIsRegistered().
	 */
	public function testIsRegistered()
	{
		$registered = $this->getMock('MyHtmlClass', array('mockFunction'));

		// test that we can register the method
		JHtml::register('prefix.file.testfunction', array($registered, 'mockFunction'));

		$this->assertThat(
			JHtml::isRegistered('prefix.file.testfunction'),
			$this->isTrue(),
			'Function is not registered'
		);

		JHtml::unregister('prefix.file.testfunction');

		$this->assertThat(
			JHtml::isRegistered('prefix.file.testfunction'),
			$this->isFalse(),
			'Function is registered'
		);
	}
 /**
  * Runs on content preparation
  *
  * @param   string  $context  The context for the data
  * @param   object  $data     An object containing the data for the form.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->profile) and $userId > 0) {
             // Load the profile data from the database.
             $db = JFactory::getDbo();
             $db->setQuery('SELECT profile_key, profile_value FROM #__users_profiles' . ' WHERE user_id = ' . (int) $userId . " AND profile_key LIKE 'profile.%'" . ' ORDER BY ordering');
             try {
                 $results = $db->loadRowList();
             } catch (RuntimeException $e) {
                 $this->_subject->setError($e->getMessage());
                 return false;
             }
             // Merge the profile data.
             $data->profile = array();
             foreach ($results as $v) {
                 $k = str_replace('profile.', '', $v[0]);
                 $data->profile[$k] = json_decode($v[1], true);
                 if ($data->profile[$k] === null) {
                     $data->profile[$k] = $v[1];
                 }
             }
         }
         if (!JHtml::isRegistered('users.url')) {
             JHtml::register('users.url', array(__CLASS__, 'url'));
         }
         if (!JHtml::isRegistered('users.calendar')) {
             JHtml::register('users.calendar', array(__CLASS__, 'calendar'));
         }
     }
     return true;
 }
Beispiel #11
0
 /**
  * @param	string	The context for the data
  * @param	int		The user id
  * @param	object
  * @return	boolean
  * @since	1.6
  */
 function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.registration', 'com_users.user', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if ($userId) {
             $juser = JFactory::getUser($userId);
             if ($this->params->get('raidplanner-profile-group', 1) == 0) {
                 $data_key = 'params';
             } else {
                 $data_key = 'raidplanner';
             }
             $data->{$data_key} = array('characters' => $juser->getParam('characters', ''), 'calendar_secret' => $juser->getParam('calendar_secret', ''), 'vacation' => $juser->getParam('vacation', ''));
         }
         if (!JHtml::isRegistered('users.characters')) {
             JHtml::register('users.characters', array(__CLASS__, 'characters'));
         }
     }
     return true;
 }
Beispiel #12
0
 public function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->joomlamailer) && $userId > 0) {
             $user = JFactory::getUser($userId);
             // check if user is subscribed
             $db = JFactory::getDBO();
             $query = $db->getQuery(true)->select(1)->from($db->qn('#__joomailermailchimpintegration'))->where($db->qn('userid') . ' = ' . $db->q($userId))->where($db->qn('listid') . ' = ' . $db->q($this->listId));
             try {
                 $isSubscribed = $db->setQuery($query)->loadResult() ? 1 : 0;
             } catch (Exception $e) {
                 $isSubscribed = false;
             }
             $data->joomlamailer['subscribe'] = $isSubscribed;
             if (!JHtml::isRegistered('users.subscribe')) {
                 JHtml::register('users.subscribe', array(__CLASS__, 'subscribe'));
             }
             if (!$isSubscribed) {
                 return;
             }
             $userData = $this->api->listMemberInfo($this->listId, $user->email);
             if (isset($userData['merges']) && count($userData['merges'])) {
                 foreach ($userData['merges'] as $key => $value) {
                     $data->joomlamailer_merges[$key] = $value;
                 }
             }
             if (isset($userData['merges']['GROUPINGS']) && count($userData['merges']['GROUPINGS'])) {
                 foreach ($userData['merges']['GROUPINGS'] as $group) {
                     $data->joomlamailer_groupings[$group['id']] = $group['groups'];
                 }
             }
             if (!JHtml::isRegistered('users.birthday')) {
                 JHtml::register('users.birthday', array(__CLASS__, 'birthday'));
             }
             if (!JHtml::isRegistered('users.address')) {
                 JHtml::register('users.address', array(__CLASS__, 'address'));
             }
         }
     }
     return true;
 }
Beispiel #13
0
 /**
  * Runs on content preparation
  *
  * @param   string  $context  The context for the data
  * @param   object  $data     An object containing the data for the form.
  *
  * @return  boolean
  *
  * @since   1.6
  */
 public function onContentPrepareData($context, $data)
 {
     // Check we are manipulating a valid form.
     if (!in_array($context, array('com_users.profile', 'com_users.user', 'com_users.registration', 'com_admin.profile'))) {
         return true;
     }
     if (is_object($data)) {
         $userId = isset($data->id) ? $data->id : 0;
         if (!isset($data->profile) and $userId > 0) {
             // Load the profile data from the database.
             $db = JFactory::getDbo();
             $query = $db->getQuery(true)->select(array($db->qn('profile_key'), $db->qn('profile_value')))->from('#__user_profiles')->where($db->qn('user_id') . ' = ' . $db->q((int) $userId))->where($db->qn('profile_key') . ' LIKE ' . $db->qn('profile.%'))->order($db->qn('ordering'));
             $db->setQuery($query);
             $results = $db->loadRowList();
             // Merge the profile data.
             $data->profile = array();
             foreach ($results as $v) {
                 $k = str_replace('profile.', '', $v[0]);
                 $data->profile[$k] = json_decode($v[1], true);
                 if ($data->profile[$k] === null) {
                     $data->profile[$k] = $v[1];
                 }
             }
         }
         if (!JHtml::isRegistered('users.url')) {
             JHtml::register('users.url', array(__CLASS__, 'url'));
         }
         if (!JHtml::isRegistered('users.calendar')) {
             JHtml::register('users.calendar', array(__CLASS__, 'calendar'));
         }
         if (!JHtml::isRegistered('users.tos')) {
             JHtml::register('users.tos', array(__CLASS__, 'tos'));
         }
         if (!JHtml::isRegistered('users.dob')) {
             JHtml::register('users.dob', array(__CLASS__, 'dob'));
         }
     }
     return true;
 }
 public function onContentPrepareData($context, $data)
 {
     // only operate on known contexts
     if (!in_array($context, array('com_admin.profile', 'com_users.user', 'com_users.profile')) || !is_object($data)) {
         return true;
     }
     // register helpers to render tfa fields
     foreach (array('activate', 'authentication', 'backup') as $field) {
         if (!JHtml::isRegistered($key = 'users.' . $field)) {
             JHtml::register($key, array(__CLASS__, $field));
         }
     }
 }