return TRUE;
}
- static function authenticateScript($abort = TRUE, $name = NULL, $pass = NULL, $storeInSession = TRUE, $loadCMSBootstrap = TRUE) {
+ static function authenticateScript($abort = TRUE, $name = NULL, $pass = NULL, $storeInSession = TRUE, $loadCMSBootstrap = TRUE, $requireKey = TRUE) {
// auth to make sure the user has a login/password to do a shell
// operation
// later on we'll link this to acl's
);
}
- if (!self::authenticateKey($abort)) {
+ if ($requireKey && !self::authenticateKey($abort)) {
return FALSE;
}
// lets store contact id and user id in session
list($userID, $ufID, $randomNumber) = $result;
if ($userID && $ufID) {
- $session = CRM_Core_Session::singleton();
- $session->set('ufID', $ufID);
- $session->set('userID', $userID);
+
+ $config = CRM_Core_Config::singleton();
+ $config->userSystem->setUserSession( array($userID, $ufID) );
}
else {
return self::authenticateAbort("ERROR: Unexpected error, could not match userID and contactID",
og_ungroup($ogID, 'user', user_load($drupalID));
}
}
+
+ /**
+ * Set a init session with user object
+ *
+ * @param array $data array with user specific data
+ *
+ * @access public
+ */
+ function setUserSession($data) {
+ list($userID, $ufID) = $data;
+ $session = CRM_Core_Session::singleton();
+ $session->set('ufID', $ufID);
+ $session->set('userID', $userID);
+ }
}
'pass' => $password,
);
}
- CRM_Utils_System::loadBootStrap($bootStrapParams);
+ CRM_Utils_System::loadBootStrap($bootStrapParams, TRUE, TRUE, FALSE);
}
jimport('joomla.application.component.helper');
return FALSE;
}
+ /**
+ * Set a init session with user object
+ *
+ * @param array $data array with user specific data
+ *
+ * @access public
+ */
+ function setUserSession($data) {
+ list($userID, $ufID) = $data;
+ $user = new JUser( $ufID );
+ $session = &JFactory::getSession();
+ $session->set('user', $user);
+
+ $cSession = CRM_Core_Session::singleton();
+ $cSession->set('ufID', $ufID);
+ $cSession->set('userID', $userID);
+ }
+
/**
* Set a message in the UF to display to a user
*
* @param $loadUser boolean load cms user?
* @param $throwError throw error on failure?
*/
- function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE) {
+ function loadBootStrap($params = array(), $loadUser = TRUE, $throwError = TRUE, $loadDefines = TRUE) {
// Setup the base path related constant.
$joomlaBase = dirname(dirname(dirname(dirname(dirname(dirname(dirname(dirname(__FILE__))))))));
// load BootStrap here if needed
// We are a valid Joomla entry point.
- if ( ! defined( '_JEXEC' ) ) {
+ if ( ! defined( '_JEXEC' ) && $loadDefines ) {
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
define('JPATH_BASE', $joomlaBase . '/administrator');
}
if (!empty($this->_user)) {
+ if(!CRM_Utils_System::authenticateScript(TRUE, $this->_user, $this->_password, TRUE, FALSE, FALSE)) {
+ $this->_log(ts("Failed to login as %1. Wrong username or password.", array('1' => $this->_user)));
+ return FALSE;
+ }
if (!$cms->loadUser($this->_user)) {
$this->_log(ts("Failed to login as %1", array('1' => $this->_user)));
return FALSE;