+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
*/
/**
* Joomla specific stuff goes here.
*/
class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
+
/**
* Class constructor.
*/
}
// Prepare the values for a new Joomla user.
- $values = array();
+ $values = [];
$values['name'] = $fullname;
$values['username'] = trim($params['cms_name']);
$values['password1'] = $values['password2'] = $params['cms_pass'];
$ufID = CRM_Utils_Type::escape($ufID, 'Integer');
$ufName = CRM_Utils_Type::escape($ufName, 'String');
- $values = array();
+ $values = [];
$user = JUser::getInstance($ufID);
$values['email'] = $ufName;
$db->setQuery($query, 0, 10);
$users = $db->loadAssocList();
- $row = array();
+ $row = [];
if (count($users)) {
$row = $users[0];
}
$dbEmail = CRM_Utils_Array::value('email', $row);
if (strtolower($dbName) == strtolower($name)) {
$errors['cms_name'] = ts('The username %1 is already taken. Please select another username.',
- array(1 => $name)
+ [1 => $name]
);
}
if (strtolower($dbEmail) == strtolower($email)) {
$resetUrl = str_replace('administrator/', '', $config->userFrameworkBaseURL) . 'index.php?option=com_users&view=reset';
$errors[$emailName] = ts('The email address %1 already has an account associated with it. <a href="%2">Have you forgotten your password?</a>',
- array(1 => $email, 2 => $resetUrl)
+ [1 => $email, 2 => $resetUrl]
);
}
}
if (is_array($breadCrumbs)) {
foreach ($breadCrumbs as $crumbs) {
if (stripos($crumbs['url'], 'id%%')) {
- $args = array('cid', 'mid');
+ $args = ['cid', 'mid'];
foreach ($args as $a) {
$val = CRM_Utils_Request::retrieve($a, 'Positive', CRM_Core_DAO::$_nullObject,
FALSE, NULL, $_GET
global $database;
$query = $db->getQuery(TRUE);
$query->select($db->quoteName('email'))
- ->from($db->quoteName('#__users'))
- ->where($db->quoteName('id') . ' = ' . $user->id);
+ ->from($db->quoteName('#__users'))
+ ->where($db->quoteName('id') . ' = ' . $user->id);
$database->setQuery($query);
$user->email = $database->loadResult();
}
$user = NULL;
if ($loadCMSBootstrap) {
- $bootStrapParams = array();
+ $bootStrapParams = [];
if ($name && $password) {
- $bootStrapParams = array(
+ $bootStrapParams = [
'name' => $name,
'pass' => $password,
- );
+ ];
}
CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, FALSE);
}
$db->setQuery($query, 0, 0);
$users = $db->loadObjectList();
- $row = array();
+ $row = [];
if (count($users)) {
$row = $users[0];
}
if (!$contactID) {
return FALSE;
}
- return array($contactID, $dbId, mt_rand());
+ return [$contactID, $dbId, mt_rand()];
}
return FALSE;
$contactID = CRM_Core_BAO_UFMatch::getContactId($uid);
if (!empty($password)) {
$instance = JFactory::getApplication('site');
- $params = array(
+ $params = [
'username' => $username,
'password' => $password,
- );
+ ];
//perform the login action
$instance->login($params);
}
+ // Save details in Joomla session
+ $user = JFactory::getUser($uid);
+ $jsession = JFactory::getSession();
+ $jsession->set('user', $user);
+
+ // Save details in Civi session
$session = CRM_Core_Session::singleton();
$session->set('ufID', $uid);
$session->set('userID', $contactID);
*
* @return bool
*/
- public function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $realPath = NULL, $loadDefines = TRUE) {
+ public function loadBootStrap($params = [], $loadUser = TRUE, $throwError = TRUE, $realPath = NULL, $loadDefines = TRUE) {
$joomlaBase = self::getBasePath();
// load BootStrap here if needed
* CRM_Core_Module
*/
public function getModules() {
- $result = array();
+ $result = [];
$db = JFactory::getDbo();
$query = $db->getQuery(TRUE);
$plugins = $db->setQuery($query)->loadAssocList();
foreach ($plugins as $plugin) {
// question: is the folder really a critical part of the plugin's name?
- $name = implode('.', array('joomla', $plugin['type'], $plugin['folder'], $plugin['element']));
+ $name = implode('.', ['joomla', $plugin['type'], $plugin['folder'], $plugin['element']]);
$result[] = new CRM_Core_Module($name, $plugin['enabled'] ? TRUE : FALSE);
}
'',
$config->imageUploadDir
);
- return array($url, NULL, $siteRoot);
+ return [$url, NULL, $siteRoot];
}
/**
}
}
- /**
- * Append Joomla js to coreResourcesList.
- *
- * @param array $list
- */
- public function appendCoreResources(&$list) {
- $list[] = 'js/crm.joomla.js';
- }
-
/**
* @inheritDoc
*/
}
}
- return array(
+ return [
'contactCount' => $contactCount,
'contactMatching' => $contactMatching,
'contactCreated' => $contactCreated,
- );
+ ];
}
}