*/
class CRM_Utils_System_Joomla extends CRM_Utils_System_Base {
/**
- *
*/
public function __construct() {
/**
* Create a user of Joomla.
*
* @param array $params
- * Associated array.
* @param string $mail
* Email id for cms user.
*
- * @return uid if user exists, false otherwise
- *
+ * @return int|bool
+ * uid if user exists, false otherwise
*/
public function createUser(&$params, $mail) {
$baseDir = JPATH_SITE;
require_once $baseDir . '/components/com_users/models/registration.php';
$userParams = JComponentHelper::getParams('com_users');
- $model = new UsersModelRegistration();
- $ufID = NULL;
+ $model = new UsersModelRegistration();
+ $ufID = NULL;
// get the default usertype
$userType = $userParams->get('new_usertype');
}
// Prepare the values for a new Joomla user.
- $values = array();
- $values['name'] = $fullname;
- $values['username'] = trim($params['cms_name']);
+ $values = array();
+ $values['name'] = $fullname;
+ $values['username'] = trim($params['cms_name']);
$values['password1'] = $values['password2'] = $params['cms_pass'];
- $values['email1'] = $values['email2'] = trim($params[$mail]);
+ $values['email1'] = $values['email2'] = trim($params[$mail]);
$lang = JFactory::getLanguage();
$lang->load('com_users', $baseDir);
public function checkUserNameEmailExists(&$params, &$errors, $emailName = 'email') {
$config = CRM_Core_Config::singleton();
- $dao = new CRM_Core_DAO();
- $name = $dao->escape(CRM_Utils_Array::value('name', $params));
+ $dao = new CRM_Core_DAO();
+ $name = $dao->escape(CRM_Utils_Array::value('name', $params));
$email = $dao->escape(CRM_Utils_Array::value('mail', $params));
//don't allow the special characters and min. username length is two
//regex \\ to match a single backslash would become '/\\\\/'
/**
* Add a script file
*
- * @param $url: string, absolute path to file
+ * @param $url : string, absolute path to file
* @param string $region
* location within the document: 'html-header', 'page-header', 'page-footer'.
*
* Note: This function is not to be called directly
* @see CRM_Core_Region::render()
*
- * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
+ * @return bool
+ * TRUE if we support this operation in this CMS, FALSE otherwise
*/
public function addScriptUrl($url, $region) {
return FALSE;
/**
* Add an inline script
*
- * @param $code: string, javascript code
+ * @param $code : string, javascript code
* @param string $region
* location within the document: 'html-header', 'page-header', 'page-footer'.
*
* Note: This function is not to be called directly
* @see CRM_Core_Region::render()
*
- * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
+ * @return bool
+ * TRUE if we support this operation in this CMS, FALSE otherwise
*/
public function addScript($code, $region) {
return FALSE;
/**
* Add a css file
*
- * @param $url: string, absolute path to file
+ * @param $url : string, absolute path to file
* @param string $region
* location within the document: 'html-header', 'page-header', 'page-footer'.
*
* Note: This function is not to be called directly
* @see CRM_Core_Region::render()
*
- * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
+ * @return bool
+ * TRUE if we support this operation in this CMS, FALSE otherwise
*/
public function addStyleUrl($url, $region) {
if ($region == 'html-header') {
/**
* Add an inline style
*
- * @param $code: string, css code
+ * @param $code : string, css code
* @param string $region
* location within the document: 'html-header', 'page-header', 'page-footer'.
*
* Note: This function is not to be called directly
* @see CRM_Core_Region::render()
*
- * @return bool TRUE if we support this operation in this CMS, FALSE otherwise
+ * @return bool
+ * TRUE if we support this operation in this CMS, FALSE otherwise
*/
public function addStyle($code, $region) {
if ($region == 'html-header') {
*
* @param bool $forceBackend
*
- * @return string an HTML string containing a link to the given path.
+ * @return string
+ * an HTML string containing a link to the given path.
*/
function url(
$path = NULL, $query = NULL, $absolute = TRUE,
$fragment = NULL, $htmlize = TRUE,
$frontend = FALSE, $forceBackend = FALSE
) {
- $config = CRM_Core_Config::singleton();
+ $config = CRM_Core_Config::singleton();
$separator = $htmlize ? '&' : '&';
- $Itemid = '';
- $script = '';
- $path = CRM_Utils_String::stripPathChars($path);
+ $Itemid = '';
+ $script = '';
+ $path = CRM_Utils_String::stripPathChars($path);
if ($config->userFrameworkFrontend) {
$script = 'index.php';
* @param $action
* The default action if one is pre-specified.
*
- * @return string the url to post the form
+ * @return string
+ * the url to post the form
*/
public function postURL($action) {
if (!empty($action)) {
* @param bool $loadCMSBootstrap
* load cms bootstrap?.
*
- * @return mixed false if no auth
- * array(
- contactID, ufID, unique string ) if success
+ * @return array|bool
+ * [contactID, ufID, uniqueString] if success else false if no auth
*/
public function authenticate($name, $password, $loadCMSBootstrap = FALSE) {
require_once 'DB.php';
*
* @param array $data
* Array with user specific data.
- *
*/
public function setUserSession($data) {
list($userID, $ufID) = $data;
*
* @param string $message
* The message to set.
- *
*/
public function setMessage($message) {
return;
/**
* Get the locale set in the hosting CMS
*
- * @return string the used locale or null for none
+ * @return string
+ * the used locale or null for none
*/
public function getUFLocale() {
if (defined('_JEXEC')) {
// load BootStrap here if needed
// We are a valid Joomla entry point.
- if (! defined('_JEXEC') && $loadDefines) {
+ if (!defined('_JEXEC') && $loadDefines) {
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
define('JPATH_BASE', $joomlaBase . '/administrator');
/**
* Check is user logged in.
*
- * @return boolean true/false.
+ * @return boolean
*/
public function isUserLoggedIn() {
$user = JFactory::getUser();
/**
* Get currently logged in user uf id.
*
- * @return int logged in user uf id.
+ * @return int
+ * logged in user uf id.
*/
public function getLoggedInUfID() {
$user = JFactory::getUser();
/**
* Get currently logged in user unique identifier - this tends to be the email address or user name.
*
- * @return string $userID logged in user unique identifier
+ * @return string
+ * logged in user unique identifier
*/
public function getLoggedInUniqueIdentifier() {
$user = JFactory::getUser();
return $this->getUniqueIdentifierFromUserObject($user);
}
+
/**
* Get User ID from UserFramework system (Joomla)
* @param object $user
* Object as described by the CMS.
- * @return mixed <NULL, number>
+ * @return mixed
+ * <NULL, number>
*/
public function getUserIDFromUserObject($user) {
return !empty($user->id) ? $user->id : NULL;
* Get Unique Identifier from UserFramework system (CMS)
* @param object $user
* Object as described by the User Framework.
- * @return mixed $uniqueIdentifer Unique identifier from the user Framework system
- *
+ * @return mixed
+ * $uniqueIdentifer Unique identifier from the user Framework system
*/
public function getUniqueIdentifierFromUserObject($user) {
return ($user->guest) ? NULL : $user->email;
/**
* Get a list of all installed modules, including enabled and disabled ones
*
- * @return array CRM_Core_Module
+ * @return array
+ * CRM_Core_Module
*/
public function getModules() {
$result = array();
* @param string $destination
* If present, add destination to querystring (works for Drupal only).
*
- * @return string - loginURL for the current CMS
+ * @return string
+ * loginURL for the current CMS
* @static
*/
public function getLoginURL($destination = '') {
*
* @param $dir
*
- * @return array array
+ * @return array
+ * array
* - $url, (Joomla - non admin url)
* - $siteName,
* - $siteRoot