/**
  * Save changes to the registration
  *
  * @return  void
  */
 public function saveTask()
 {
     // Check for request forgeries
     Request::checkToken();
     $settings = Request::getVar('settings', array(), 'post');
     if (!is_array($settings) || empty($settings)) {
         App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_REGISTRATION_ERROR_MISSING_DATA'), 'error');
         return;
     }
     $arr = array();
     $component = new \JTableExtension($this->database);
     $component->load($component->find(array('element' => $this->_option, 'type' => 'component')));
     $params = new \Hubzero\Config\Registry($component->params);
     foreach ($settings as $name => $value) {
         $r = $value['create'] . $value['proxy'] . $value['update'] . $value['edit'];
         $params->set('registration' . trim($name), trim($r));
     }
     $component->params = $params->toString();
     $component->store();
     if (App::get('config')->get('caching')) {
         $handler = App::get('config')->get('cache_handler');
         App::get('config')->set($handler, array('cachebase' => PATH_APP . '/cache/site'));
         $cache = new \Hubzero\Cache\Manager(\App::getRoot());
         $cache->storage($handler);
         $cache->clean('_system');
     }
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_MEMBERS_REGISTRATION_SAVED'));
 }
 /**
  * Up
  **/
 public function up()
 {
     $params = $this->getParams('plg_system_hubzero');
     $search = $params->get('search');
     if ($search && $search == 'ysearch') {
         $params->set('search', 'search');
         $component = new \JTableExtension($this->db);
         $component->load(array('folder' => 'system', 'element' => 'hubzero'));
         $component->set('params', (string) $params);
         $component->store();
     }
 }
Example #3
0
 /**
  * Refreshes the manifest cache stored in #__extensions
  *
  * @param   integer  $eid  Extension ID
  *
  * @return  boolean
  *
  * @since   3.1
  */
 public function refreshManifestCache($eid)
 {
     if ($eid) {
         if (!$this->extension->load($eid)) {
             $this->abort(JText::_('JLIB_INSTALLER_ABORT_LOAD_DETAILS'));
             return false;
         }
         if ($this->extension->state == -1) {
             $this->abort(JText::_('JLIB_INSTALLER_ABORT_REFRESH_MANIFEST_CACHE'));
             return false;
         }
         // Fetch the adapter
         $adapter = $this->getAdapter($this->extension->type);
         if (!is_object($adapter)) {
             return false;
         }
         if (!method_exists($adapter, 'refreshManifestCache')) {
             $this->abort(JText::sprintf('JLIB_INSTALLER_ABORT_METHODNOTSUPPORTED_TYPE', $this->extension->type));
             return false;
         }
         $result = $adapter->refreshManifestCache();
         if ($result !== false) {
             return true;
         } else {
             return false;
         }
     }
     $this->abort(JText::_('JLIB_INSTALLER_ABORT_REFRESH_MANIFEST_CACHE_VALID'));
     return false;
 }
Example #4
0
	/**
	 * Refreshes the manifest cache stored in #__extensions
	 *
	 * @param   integer  $eid  Extension ID
	 *
	 * @return  mixed  void on success, false on error @todo missing return value ?
	 *
	 * @since   11.1
	 */
	function refreshManifestCache($eid)
	{
		if ($eid)
		{
			$this->extension = JTable::getInstance('extension');

			if (!$this->extension->load($eid))
			{
				$this->abort(JText::_('JLIB_INSTALLER_ABORT_LOAD_DETAILS'));
				return false;
			}

			if ($this->extension->state == -1)
			{
				$this->abort(JText::_('JLIB_INSTALLER_ABORT_REFRESH_MANIFEST_CACHE'));
				return false;
			}

			// Lazy load the adapter
			if (!isset($this->_adapters[$this->extension->type]) || !is_object($this->_adapters[$this->extension->type]))
			{
				if (!$this->setAdapter($this->extension->type))
				{
					return false;
				}
			}

			if (is_object($this->_adapters[$this->extension->type]))
			{
				if (method_exists($this->_adapters[$this->extension->type], 'refreshManifestCache'))
				{
					$result = $this->_adapters[$this->extension->type]->refreshManifestCache();

					if ($result !== false)
					{
						return true;
					}
					else
					{
						return false;
					}
				}
				else
				{
					$this->abort(JText::sprintf('JLIB_INSTALLER_ABORT_METHODNOTSUPPORTED_TYPE', $this->extension->type));

					return false;
				}
			}

			return false;
		}
		else
		{
			$this->abort(JText::_('JLIB_INSTALLER_ABORT_REFRESH_MANIFEST_CACHE_VALID'));

			return false;
		}
	}
 /**
  * Down
  **/
 public function down()
 {
     $this->addComponentEntry('register');
     $rparams = $this->getParams('com_members');
     $values = $rparams->toArray();
     $this->db->setQuery("SELECT * FROM `#__extensions` WHERE `type`='component' AND `element`='com_register' LIMIT 1");
     if ($data = $this->db->loadAssoc()) {
         $component = new \JTableExtension($this->db);
         $component->bind($data);
         $mparams = new \Hubzero\Config\Registry($component->params);
         foreach ($values as $key => $value) {
             $mparams->set($key, $value);
         }
         $component->params = $mparams->toString();
         $component->store();
     }
 }
 /**
  * Up
  **/
 public function up()
 {
     $params = $this->getParams('com_users');
     $user_type = $params->get('new_usertype');
     if (is_string($user_type) && strlen($user_type) > 2) {
         $query = "SELECT `id` FROM `#__usergroups` WHERE `title` = " . $this->db->quote($user_type);
         $this->db->setQuery($query);
         if ($id = $this->db->loadResult()) {
             $params->set('new_usertype', $id);
             $component = new \JTableExtension($this->db);
             $component->load(array('element' => 'com_users'));
             $component->set('params', (string) $params);
             $component->store();
         } else {
             $this->setError('Failed to convert new user type paramter of "' . $user_type . '" to an ID.', 'warning');
             return false;
         }
     }
 }
Example #7
0
 /**
  * Import the hub configuration
  *
  * @return  void
  */
 public function importHubconfigTask()
 {
     if (file_exists(PATH_APP . DS . 'hubconfiguration.php')) {
         include_once PATH_APP . DS . 'hubconfiguration.php';
     }
     $table = new \JTableExtension($this->database);
     $table->load($table->find(array('element' => $this->_option, 'type' => 'component')));
     if (class_exists('HubConfig')) {
         $hub_config = new \HubConfig();
         $this->config->set('geodb_driver', $hub_config->ipDBDriver);
         $this->config->set('geodb_host', $hub_config->ipDBHost);
         $this->config->set('geodb_port', $hub_config->ipDBPort);
         $this->config->set('geodb_user', $hub_config->ipDBUsername);
         $this->config->set('geodb_password', $hub_config->ipDBPassword);
         $this->config->set('geodb_database', $hub_config->ipDBDatabase);
         $this->config->set('geodb_prefix', $hub_config->ipDBPrefix);
     }
     $table->params = $this->config->toString();
     $table->store();
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_SYSTEM_GEO_IMPORT_COMPLETE'));
 }
Example #8
0
 /**
  * Import the hub configuration
  *
  * @return  void
  */
 public function importHubconfigTask()
 {
     if (file_exists(PATH_APP . DS . 'hubconfiguration.php')) {
         include_once PATH_APP . DS . 'hubconfiguration.php';
     }
     $table = new \JTableExtension($this->database);
     $table->load($table->find(array('element' => $this->_option, 'type' => 'component')));
     if (class_exists('HubConfig')) {
         $hub_config = new \HubConfig();
         $this->config->set('ldap_basedn', $hub_config->hubLDAPBaseDN);
         $this->config->set('ldap_primary', $hub_config->hubLDAPMasterHost);
         $this->config->set('ldap_secondary', $hub_config->hubLDAPSlaveHosts);
         $this->config->set('ldap_tls', $hub_config->hubLDAPNegotiateTLS);
         $this->config->set('ldap_searchdn', $hub_config->hubLDAPSearchUserDN);
         $this->config->set('ldap_searchpw', $hub_config->hubLDAPSearchUserPW);
         $this->config->set('ldap_managerdn', $hub_config->hubLDAPAcctMgrDN);
         $this->config->set('ldap_managerpw', $hub_config->hubLDAPAcctMgrPW);
     }
     $table->params = $this->config->toString();
     $table->store();
     App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller, false), Lang::txt('COM_SYSTEM_LDAP_IMPORT_COMPLETE'));
 }
Example #9
0
 /**
  * Method to check if the extension is already present in the database
  *
  * @return  void
  *
  * @since   3.4
  * @throws  RuntimeException
  */
 protected function checkExistingExtension()
 {
     try {
         $this->currentExtensionId = $this->extension->find(array('element' => $this->element, 'type' => $this->type));
         // If it does exist, load it
         if ($this->currentExtensionId) {
             $this->extension->load(array('element' => $this->element, 'type' => $this->type));
         }
     } catch (RuntimeException $e) {
         // Install failed, roll back changes
         throw new RuntimeException(JText::sprintf('JLIB_INSTALLER_ABORT_ROLLBACK', JText::_('JLIB_INSTALLER_' . $this->route), $e->getMessage()), $e->getCode(), $e);
     }
 }
Example #10
0
 function refreshManifestCache($eid)
 {
     if ($eid) {
         $this->extension =& JTable::getInstance('extension');
         if (!$this->extension->load($eid)) {
             $this->abort(JText::_('Failed to load extension details'));
             return false;
         }
         if ($this->extension->state == -1) {
             $this->abort(JText::_('Refresh Manifest Cache failed') . ': ' . JText::_('Extension is not currently installed'));
             return false;
         }
         // Lazy load the adapter
         if (!isset($this->_adapters[$this->extension->type]) || !is_object($this->_adapters[$this->extension->type])) {
             if (!$this->setAdapter($this->extension->type)) {
                 return false;
             }
         }
         if (is_object($this->_adapters[$this->extension->type])) {
             if (method_exists($this->_adapters[$this->extension->type], 'refreshManifestCache')) {
                 $result = $this->_adapters[$this->extension->type]->refreshManifestCache();
                 if ($result !== false) {
                     return true;
                 } else {
                     return false;
                 }
             } else {
                 $this->abort(JText::_('Method not supported for this extension type') . ': ' . $this->extension->type);
                 return false;
             }
         }
         return false;
     } else {
         $this->abort(JText::_('Refresh Manifest Cache failed') . ': ' . JText::_('Extension not valid'));
         return false;
     }
 }
Example #11
0
 /**
  * Method is called after user data is stored in the database
  *
  * @param   array    $user     holds the new user data
  * @param   boolean  $isnew    true if a new user is stored
  * @param   boolean  $success  true if user was succesfully stored in the database
  * @param   string   $msg      message
  * @return  void
  */
 public function onAfterStoreUser($user, $isnew, $succes, $msg)
 {
     $xprofile = \Hubzero\User\Profile::getInstance($user['id']);
     if (!is_object($xprofile)) {
         $params = Component::params('com_members');
         $hubHomeDir = rtrim($params->get('homedir'), '/');
         if (empty($hubHomeDir)) {
             // try to deduce a viable home directory based on sitename or live_site
             $sitename = strtolower(Config::get('sitename'));
             $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1);
             $sitename = trim($sitename, '/ ');
             $sitename_e = explode('.', $sitename, 2);
             if (isset($sitename_e[1])) {
                 $sitename = $sitename_e[0];
             }
             if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) {
                 $sitename = '';
             }
             if (empty($sitename)) {
                 $sitename = strtolower(Request::base());
                 $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1);
                 $sitename = trim($sitename, '/ ');
                 $sitename_e = explode('.', $sitename, 2);
                 if (isset($sitename_e[1])) {
                     $sitename = $sitename_e[0];
                 }
                 if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) {
                     $sitename = '';
                 }
             }
             $hubHomeDir = DS . 'home';
             if (!empty($sitename)) {
                 $hubHomeDir .= DS . $sitename;
             }
             if (!empty($hubHomeDir)) {
                 $db = App::get('db');
                 $component = new JTableExtension($this->database);
                 $component->load($component->find(array('element' => 'com_members', 'type' => 'component')));
                 $params = new \Hubzero\Config\Registry($component->params);
                 $params->set('homedir', $hubHomeDir);
                 $component->params = $params->toString();
                 $component->store();
             }
         }
         $xprofile = new \Hubzero\User\Profile();
         $xprofile->set('gidNumber', $params->get('gidNumber', '100'));
         $xprofile->set('gid', $params->get('gid', 'users'));
         $xprofile->set('uidNumber', $user['id']);
         $xprofile->set('homeDirectory', $hubHomeDir . DS . $user['username']);
         $xprofile->set('loginShell', '/bin/bash');
         $xprofile->set('ftpShell', '/usr/lib/sftp-server');
         $xprofile->set('name', $user['name']);
         $xprofile->set('email', $user['email']);
         $xprofile->set('emailConfirmed', '3');
         $xprofile->set('username', $user['username']);
         $xprofile->set('regIP', $_SERVER['REMOTE_ADDR']);
         $xprofile->set('emailConfirmed', -rand(1, pow(2, 31) - 1));
         $xprofile->set('public', $params->get('privacy', 0));
         if (isset($_SERVER['REMOTE_HOST'])) {
             $xprofile->set('regHost', $_SERVER['REMOTE_HOST']);
         }
         $xprofile->set('registerDate', Date::toSql());
         $result = $xprofile->create();
         if (!$result) {
             return new Exception('Unable to create \\Hubzero\\User\\Profile record', 500);
         }
     } else {
         $update = false;
         $params = Component::params('com_members');
         if ($xprofile->get('username') != $user['username']) {
             $xprofile->set('username', $user['username']);
             $update = true;
         }
         if ($xprofile->get('name') != $user['name']) {
             $xprofile->set('name', $user['name']);
             $update = true;
         }
         if ($xprofile->get('email') != $user['email']) {
             $xprofile->set('email', $user['email']);
             $xprofile->set('emailConfirmed', 0);
             $update = true;
         }
         if ($xprofile->get('emailConfirmed') == '') {
             $xprofile->set('emailConfirmed', '3');
             $update = true;
         }
         if ($xprofile->get('gid') == '') {
             $xprofile->set('gid', $params->get('gid', 'users'));
             $update = true;
         }
         if ($xprofile->get('gidNumber') == '') {
             $xprofile->set('gidNumber', $params->get('gidNumber', '100'));
             $update = true;
         }
         if ($xprofile->get('loginShell') == '') {
             $xprofile->set('loginShell', '/bin/bash');
             $update = true;
         }
         if ($xprofile->get('ftpShell') == '') {
             $xprofile->set('ftpShell', '/usr/lib/sftp-server');
             // This isn't right, but we're using an empty shell as an indicator that we should also update default privacy
             $xprofile->set('public', $params->get('privacy', 0));
             $update = true;
         }
         if ($update) {
             $xprofile->update();
         }
     }
     // Check if quota exists for the user
     $params = Component::params('com_members');
     if ($params->get('manage_quotas', false)) {
         require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'users_quotas.php';
         require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'tables' . DS . 'quotas_classes.php';
         $quota = new \Components\Members\Tables\UsersQuotas($this->database);
         $quota->load(array('user_id' => $user['id']));
         if (!$quota->id) {
             $class = new \Components\Members\Tables\QuotasClasses($this->database);
             $class->load(array('alias' => 'default'));
             if ($class->id) {
                 $quota->set('user_id', $user['id']);
                 $quota->set('class_id', $class->id);
                 $quota->set('soft_blocks', $class->soft_blocks);
                 $quota->set('hard_blocks', $class->hard_blocks);
                 $quota->set('soft_files', $class->soft_files);
                 $quota->set('hard_files', $class->hard_files);
                 $quota->store();
             }
         }
     }
 }
Example #12
0
		</thead>
		<tfoot>
			<tr>
				<td colspan="8">
					<?php 
// Initiate paging
$pagination = $this->pagination($this->total, $this->filters['start'], $this->filters['limit']);
echo $pagination->render();
?>
				</td>
			</tr>
		</tfoot>
		<tbody>
<?php 
$db = App::get('db');
$tbl = new JTableExtension($db);
$k = 0;
for ($i = 0, $n = count($this->rows); $i < $n; $i++) {
    $row =& $this->rows[$i];
    $link = 'index.php?option=com_plugins&task=edit&extension_id=' . $row->id . '&component=' . $row->folder;
    $access = $row->groupname;
    $published = $row->published;
    $ordering = $this->filters['sort'] == 'p.folder';
    switch ($row->published) {
        case '2':
            $task = 'publish';
            $img = 'disabled.png';
            $alt = Lang::txt('Trashed');
            $cls = 'trashed';
            break;
        case '1':
Example #13
0
 /**
  * Global config has been saved.
  * Check the product key and if it exists create an update site entry
  * Update server XML manifest generated from update/premium.php
  *
  * @param string          $option
  * @param JTableExtension $data
  */
 function onExtensionAfterSave($option, $data)
 {
     if ($option !== 'com_config.component') {
         return;
     }
     if ($data->get('name') !== 'com_fabrik') {
         return;
     }
     $props = $data->getProperties();
     $params = new JRegistry($props['params']);
     $productKey = $params->get('fabrik_product_key', '');
     if ($productKey === '') {
         return;
     }
     $table = JTable::getInstance('Updatesite');
     $table->load(array('name' => 'Fabrik - Premium'));
     $table->save(array('type' => 'collection', 'name' => 'Fabrik - Premium', 'enabled' => 1, 'location' => 'http://localhost:81/fabrik31x/public_html/update/premium.php?productKey=' . $productKey));
 }
Example #14
0
 /**
  * Set plugin parameter.
  * http://stackoverflow.com/questions/22236929/setting-persistent-plugin-parameters-in-joomla-3
  * http://stackoverflow.com/questions/22236929/setting-persistent-plugin-parameters-in-joomla-3
  */
 public static function setPluginParameter($name, $value)
 {
     if (class_exists('JTableExtension')) {
         $db = JFactory::getDBO();
         $extensionTable = new JTableExtension($db);
         //$pluginId = $extensionTable->find('element', self::PLG_NAME);
         $pluginId = self::getPluginId($db);
         if (empty($pluginId)) {
             return false;
         }
         $extensionTable->load($pluginId);
         $plugin =& JPluginHelper::getPlugin(self::PLG_TYPE, self::PLG_NAME);
         if (empty($plugin)) {
             return false;
         }
         $params = self::getPluginParams();
         $params->set($name, $value);
         $extensionTable->bind(array('params' => $params->toString()));
         // check and store
         if (!$extensionTable->check()) {
             return false;
         }
         if (!$extensionTable->store()) {
             return false;
         }
         return true;
     }
     return false;
 }
Example #15
0
				</th>
			</tr>
		</thead>
		<tfoot>
			<tr>
				<td colspan="8"><?php 
$pagination = $this->pagination($this->total, $this->filters['start'], $this->filters['limit']);
echo $pagination->render();
?>
</td>
			</tr>
		</tfoot>
		<tbody>
<?php 
$db = App::get('db');
$tbl = new JTableExtension($db);
$k = 0;
for ($i = 0, $n = count($this->rows); $i < $n; $i++) {
    $row =& $this->rows[$i];
    $link = Route::url('index.php?option=com_plugins&task=edit&extension_id=' . $row->id . '&component=resources');
    //$access    = $this->grid('access', $row, $i);
    //$checked = $this->grid('checkedout', $row, $i);
    $published = Html::grid('published', $row->enabled, $i, '', false);
    $ordering = $this->filters['sort'] == 'p.folder';
    switch ($row->published) {
        case '2':
            $task = 'publish';
            $img = 'disabled.png';
            $alt = Lang::txt('JTRASHED');
            $cls = 'trashed';
            break;
Example #16
0
 /**
  * Extra install operation.
  *
  * @param JTableExtension $extension
  * @return void
  */
 function extra(&$extension)
 {
     if (AINSTALLER_J16) {
         if (isset($extension->enabled)) {
             $db = JFactory::getDbo();
             /* @var $db JDatabaseMySQL */
             $db->setQuery('UPDATE `#__modules` SET `published` = ' . (int) $extension->enabled . ' WHERE `module` = ' . $db->Quote($extension->get('element')));
             $db->query();
         }
     }
 }
Example #17
0
 /**
  * Method is called after user data is stored in the database
  *
  * @param   array    $user     holds the new user data
  * @param   boolean  $isnew    true if a new user is stored
  * @param   boolean  $success  true if user was succesfully stored in the database
  * @param   string   $msg      message
  * @return  void
  */
 public function onAfterStoreUser($user, $isnew, $success, $msg)
 {
     $xprofile = \Hubzero\User\Profile::getInstance($user['id']);
     if (!is_object($xprofile)) {
         $params = Component::params('com_members');
         $hubHomeDir = rtrim($params->get('homedir'), '/');
         if (empty($hubHomeDir)) {
             // try to deduce a viable home directory based on sitename or live_site
             $sitename = strtolower(Config::get('sitename'));
             $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1);
             $sitename = trim($sitename, '/ ');
             $sitename_e = explode('.', $sitename, 2);
             if (isset($sitename_e[1])) {
                 $sitename = $sitename_e[0];
             }
             if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) {
                 $sitename = '';
             }
             if (empty($sitename)) {
                 $sitename = strtolower(Request::base());
                 $sitename = preg_replace('/^http[s]{0,1}:\\/\\//', '', $sitename, 1);
                 $sitename = trim($sitename, '/ ');
                 $sitename_e = explode('.', $sitename, 2);
                 if (isset($sitename_e[1])) {
                     $sitename = $sitename_e[0];
                 }
                 if (!preg_match("/^[a-zA-Z]+[\\-_0-9a-zA-Z\\.]+\$/i", $sitename)) {
                     $sitename = '';
                 }
             }
             $hubHomeDir = DS . 'home';
             if (!empty($sitename)) {
                 $hubHomeDir .= DS . $sitename;
             }
             if (!empty($hubHomeDir)) {
                 $db = App::get('db');
                 $component = new JTableExtension($this->database);
                 $component->load($component->find(array('element' => 'com_members', 'type' => 'component')));
                 $params = new \Hubzero\Config\Registry($component->params);
                 $params->set('homedir', $hubHomeDir);
                 $component->params = $params->toString();
                 $component->store();
             }
         }
         $xprofile = new \Hubzero\User\Profile();
         $xprofile->set('gidNumber', $params->get('gidNumber', '100'));
         $xprofile->set('gid', $params->get('gid', 'users'));
         $xprofile->set('uidNumber', $user['id']);
         $xprofile->set('homeDirectory', isset($user['homeDirectory']) ? $user['homeDirectory'] : $hubHomeDir . DS . $user['username']);
         $xprofile->set('loginShell', isset($user['loginShell']) ? $user['loginShell'] : '/bin/bash');
         $xprofile->set('ftpShell', isset($user['ftpShell']) ? $user['ftpShell'] : '/usr/lib/sftp-server');
         $xprofile->set('name', $user['name']);
         $xprofile->set('email', $user['email']);
         $xprofile->set('username', $user['username']);
         $xprofile->set('regIP', $_SERVER['REMOTE_ADDR']);
         //$xprofile->set('emailConfirmed', '3');
         $xprofile->set('emailConfirmed', isset($user['activation']) ? $user['activation'] : -rand(1, pow(2, 31) - 1));
         $xprofile->set('public', $params->get('privacy', 0));
         if (isset($_SERVER['REMOTE_HOST'])) {
             $xprofile->set('regHost', $_SERVER['REMOTE_HOST']);
         }
         $xprofile->set('registerDate', Date::toSql());
         $result = $xprofile->create();
         if (!$result) {
             return new Exception('Unable to create \\Hubzero\\User\\Profile record', 500);
         }
     } else {
         $update = false;
         $params = Component::params('com_members');
         if ($xprofile->get('username') != $user['username']) {
             $xprofile->set('username', $user['username']);
             $update = true;
         }
         if ($xprofile->get('name') != $user['name']) {
             $xprofile->set('name', $user['name']);
             $update = true;
         }
         // Fix missing surname/given name as well
         if ($xprofile->get('name') && (!$xprofile->get('surname') || !$xprofile->get('givenName'))) {
             $firstname = $xprofile->get('givenName');
             $middlename = $xprofile->get('middleName');
             $lastname = $xprofile->get('surname');
             $words = array_map('trim', explode(' ', $xprofile->get('name')));
             $count = count($words);
             if ($count == 1) {
                 $firstname = $words[0];
             } else {
                 if ($count == 2) {
                     $firstname = $words[0];
                     $lastname = $words[1];
                 } else {
                     if ($count == 3) {
                         $firstname = $words[0];
                         $middlename = $words[1];
                         $lastname = $words[2];
                     } else {
                         $firstname = $words[0];
                         $lastname = $words[$count - 1];
                         $middlename = $words[1];
                         for ($i = 2; $i < $count - 1; $i++) {
                             $middlename .= ' ' . $words[$i];
                         }
                     }
                 }
             }
             $firstname = trim($firstname);
             if ($firstname) {
                 $xprofile->set('givenName', $firstname);
             }
             $middlename = trim($middlename);
             if ($middlename) {
                 $xprofile->set('middleName', $middlename);
             }
             $lastname = trim($lastname);
             if ($lastname) {
                 $xprofile->set('surname', $lastname);
             }
             $update = true;
         }
         if ($xprofile->get('email') != $user['email']) {
             $xprofile->set('email', $user['email']);
             $xprofile->set('emailConfirmed', 0);
             $update = true;
         }
         if ($xprofile->get('emailConfirmed') == '') {
             $xprofile->set('emailConfirmed', '3');
             $update = true;
         }
         if ($xprofile->get('gid') == '') {
             $xprofile->set('gid', $params->get('gid', 'users'));
             $update = true;
         }
         if ($xprofile->get('gidNumber') == '') {
             $xprofile->set('gidNumber', $params->get('gidNumber', '100'));
             $update = true;
         }
         if ($xprofile->get('loginShell') == '') {
             $xprofile->set('loginShell', '/bin/bash');
             $update = true;
         }
         if ($xprofile->get('ftpShell') == '') {
             $xprofile->set('ftpShell', '/usr/lib/sftp-server');
             // This isn't right, but we're using an empty shell as an indicator that we should also update default privacy
             $xprofile->set('public', $params->get('privacy', 0));
             $update = true;
         }
         if ($update) {
             $xprofile->update();
         }
     }
     // Check if quota exists for the user
     $params = Component::params('com_members');
     if ($params->get('manage_quotas', false)) {
         require_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'quota.php';
         $quota = Components\Members\Models\Quota::all()->whereEquals('user_id', $user['id'])->row();
         if (!$quota->get('id')) {
             $class = Components\Members\Models\Quota\Category::defaultEntry();
             if ($class->get('id')) {
                 $quota->set('user_id', $user['id']);
                 $quota->set('class_id', $class->get('id'));
                 $quota->set('soft_blocks', $class->get('soft_blocks'));
                 $quota->set('hard_blocks', $class->get('hard_blocks'));
                 $quota->set('soft_files', $class->get('soft_files'));
                 $quota->set('hard_files', $class->get('hard_files'));
                 $quota->save();
             }
         }
     }
     if ($success) {
         Event::trigger('members.onMemberAfterSave', array($user, $isnew, $success, $msg));
     }
 }