Пример #1
0
 function postProcess()
 {
     $formValues = $this->controller->exportValues($this->_name);
     require_once 'CRM/Standalone/User.php';
     require_once 'CRM/Utils/System/Standalone.php';
     require_once 'CRM/Core/BAO/OpenID.php';
     $user = new CRM_Standalone_User($formValues['user_unique_id'], $formValues['email'], $formValues['first_name'], $formValues['last_name']);
     CRM_Utils_System_Standalone::getUserID($user);
     require_once 'CRM/Core/Session.php';
     $session = CRM_Core_Session::singleton();
     $contactId = $session->get('userID');
     $query = "SELECT count(id) FROM civicrm_uf_match";
     $ufCount = CRM_Core_DAO::singleValueQuery($query);
     if ($ufCount == 1 || defined('ALLOWED_TO_LOGIN')) {
         $openId = new CRM_Core_DAO_OpenID();
         $openId->contact_id = $contactId;
         $openId->find(true);
         $openId->allowed_to_login = 1;
         $openId->update();
     }
     // add first user to admin group
     if ($ufCount == 1) {
         require_once 'CRM/Contact/BAO/GroupContact.php';
         require_once 'CRM/Contact/DAO/Group.php';
         $group = new CRM_Contact_DAO_Group();
         $group->name = 'Administrators';
         $group->is_active = 1;
         if ($group->find(true)) {
             $contactIds = array($contactId);
             CRM_Contact_BAO_GroupContact::addContactsToGroup($contactIds, $group->id, 'Web', 'Added');
         }
     } else {
         if ($ufCount > 1 && !defined('CIVICRM_ALLOW_ALL')) {
             $session->set('msg', 'You are not allowed to login. Login failed. Contact your Administrator.');
             $session->set('goahead', "no");
         }
     }
     // Set this to false if the registration is successful
     $session->set('new_install', false);
     header("Location: index.php");
     CRM_Utils_System::civiExit();
 }