/**
 * check the data validity
 *
 * @param int    $userID    the user id
 * @param string $title     the title of the group we are interested in
 * @param  boolean $register is this the registrtion form
 * @param int    $action  the action of the form
 *
 * @return error   if data not valid
 *
 * @access public
 */
function civicrm_profile_html_validate($userID, $title, $action = NULL, $register = FALSE)
{
    return CRM_Core_BAO_UFGroup::isValid($userID, $title, $register, $action);
}
示例#2
0
/**
 * check the data validity
 *
 * @param int    $userID    the user id 
 * @param string $title     the title of the group we are interested in
 * @pram  boolean $register is this the registrtion form
 * @param int    $action  the action of the form
 *
 * @return error   if data not valid
 * 
 * @access public
 */
function crm_validate_profile_html($userID, $title, $action = null, $register = false)
{
    return CRM_Core_BAO_UFGroup::isValid($userID, $title, $register, $action);
}
示例#3
0
 /**
  * Save user registration and notify users and admins if required
  * @return void
  */
 function register_save()
 {
     global $mainframe;
     // Check for request forgeries
     JRequest::checkToken() or jexit('Invalid Token');
     // Get required system objects
     $user = clone JFactory::getUser();
     $pathway =& $mainframe->getPathway();
     $config =& JFactory::getConfig();
     $authorize =& JFactory::getACL();
     $document =& JFactory::getDocument();
     // If user registration is not allowed, show 403 not authorized.
     $usersConfig =& JComponentHelper::getParams('com_users');
     if ($usersConfig->get('allowUserRegistration') == '0') {
         JError::raiseError(403, JText::_('Access Forbidden'));
         return;
     }
     // do civicrm validation here
     require_once 'administrator/components/com_civicrm/civicrm.settings.php';
     require_once 'CRM/Core/Config.php';
     $civiConfig =& CRM_Core_Config::singleton();
     $civiConfig->formKeyDisable = true;
     require_once 'CRM/Core/BAO/UFGroup.php';
     $errors = CRM_Core_BAO_UFGroup::isValid(null, null, true);
     if (is_array($errors)) {
         $msg = null;
         foreach ($errors as $name => $error) {
             $msg .= "{$name}: {$error}<br/>";
         }
         JError::raiseWarning('', JText::_($msg));
         $this->register();
         return false;
     }
     // Initialize new usertype setting
     $newUsertype = $usersConfig->get('new_usertype');
     if (!$newUsertype) {
         $newUsertype = 'Registered';
     }
     // Bind the post array to the user object
     if (!$user->bind(JRequest::get('post'), 'usertype')) {
         JError::raiseError(500, $user->getError());
     }
     // Set some initial user values
     $user->set('id', 0);
     $user->set('usertype', '');
     $user->set('gid', $authorize->get_group_id('', $newUsertype, 'ARO'));
     $date =& JFactory::getDate();
     $user->set('registerDate', $date->toMySQL());
     // If user activation is turned on, we need to set the activation information
     $useractivation = $usersConfig->get('useractivation');
     if ($useractivation == '1') {
         jimport('joomla.user.helper');
         $user->set('activation', md5(JUserHelper::genRandomPassword()));
         $user->set('block', '1');
     }
     // If there was an error with registration, set the message and display form
     if (!$user->save()) {
         JError::raiseWarning('', JText::_($user->getError()));
         $this->register();
         return false;
     }
     // Send registration confirmation mail
     $password = JRequest::getString('password', '', 'post', JREQUEST_ALLOWRAW);
     $password = preg_replace('/[\\x00-\\x1F\\x7F]/', '', $password);
     //Disallow control chars in the email
     UserController::_sendMail($user, $password);
     // if this was a successful save, call civicrm code to save the contact
     if ($user->id) {
         require_once 'CRM/Core/BAO/UFMatch.php';
         CRM_Core_BAO_UFMatch::synchronize($user, true, 'Joomla', 'Individual');
         $userID = CRM_Core_BAO_UFMatch::getContactId($user->id);
         if ($userID) {
             require_once 'CRM/Core/BAO/UFGroup.php';
             CRM_Core_BAO_UFGroup::getEditHTML($userID, null, 2, true, false, null, false, 'Individual');
             $session =& CRM_Core_Session::singleton();
             $session->reset();
         }
     }
     // Everything went fine, set relevant message depending upon user activation state and display message
     if ($useractivation == 1) {
         $message = JText::_('REG_COMPLETE_ACTIVATE');
     } else {
         $message = JText::_('REG_COMPLETE');
     }
     //TODO :: this needs to be replace by raiseMessage
     JError::raiseNotice('', $message);
     $this->register();
 }