Inheritance: extends Model
 public function UnInvite($InvitationID = '', $PostBackKey = '')
 {
     $this->Permission('Garden.SignIn.Allow');
     $InvitationModel = new InvitationModel();
     $Session = Gdn::Session();
     if ($Session->ValidateTransientKey($PostBackKey)) {
         try {
             $InvitationModel->Delete($InvitationID, $this->UserModel);
         } catch (Exception $ex) {
             $this->Form->AddError(strip_tags($ex->getMessage()));
         }
         if ($this->Form->ErrorCount() == 0) {
             $this->StatusMessage = T('The invitation was removed successfully.');
         }
     }
     $this->View = 'Invitations';
     $this->Invitations();
 }
 private function setInvitationStatus($setStatus, $id_order)
 {
     $objInvitation = new InvitationModel();
     $arrInvitation = $objInvitation->getWhere("inv_id_order='{$id_order}' AND status != '1'");
     foreach ($arrInvitation as $invitation) {
         $invitation->status = "1";
         $invitation->load = "1";
         $invitation->save();
         $result = true;
     }
     return $result;
 }
Ejemplo n.º 3
0
 /**
  * Invitation-only registration. Requires code.
  *
  * @param int $InvitationCode
  * @since 2.0.0
  */
 public function registerInvitation($InvitationCode = 0)
 {
     $this->Form->setModel($this->UserModel);
     // Define gender dropdown options
     $this->GenderOptions = array('u' => t('Unspecified'), 'm' => t('Male'), 'f' => t('Female'));
     if (!$this->Form->isPostBack()) {
         $this->Form->setValue('InvitationCode', $InvitationCode);
     }
     $InvitationModel = new InvitationModel();
     // Look for the invitation.
     $Invitation = $InvitationModel->getWhere(array('Code' => $this->Form->getValue('InvitationCode')))->firstRow(DATASET_TYPE_ARRAY);
     if (!$Invitation) {
         $this->Form->addError('Invitation not found.', 'Code');
     } else {
         if ($Expires = val('DateExpires', $Invitation)) {
             $Expires = Gdn_Format::toTimestamp($Expires);
             if ($Expires <= time()) {
             }
         }
     }
     $this->Form->addHidden('ClientHour', date('Y-m-d H:00'));
     // Use the server's current hour as a default
     $this->Form->addHidden('Target', $this->target());
     Gdn::userModel()->addPasswordStrength($this);
     if ($this->Form->isPostBack() === true) {
         $this->InvitationCode = $this->Form->getValue('InvitationCode');
         // Add validation rules that are not enforced by the model
         $this->UserModel->defineSchema();
         $this->UserModel->Validation->applyRule('Name', 'Username', $this->UsernameError);
         $this->UserModel->Validation->applyRule('TermsOfService', 'Required', t('You must agree to the terms of service.'));
         $this->UserModel->Validation->applyRule('Password', 'Required');
         $this->UserModel->Validation->applyRule('Password', 'Strength');
         $this->UserModel->Validation->applyRule('Password', 'Match');
         // $this->UserModel->Validation->applyRule('DateOfBirth', 'MinimumAge');
         $this->fireEvent('RegisterValidation');
         try {
             $Values = $this->Form->formValues();
             $Values = $this->UserModel->filterForm($Values, true);
             unset($Values['Roles']);
             $AuthUserID = $this->UserModel->register($Values, array('Method' => 'Invitation'));
             $this->setData('UserID', $AuthUserID);
             if (!$AuthUserID) {
                 $this->Form->setValidationResults($this->UserModel->validationResults());
             } else {
                 // The user has been created successfully, so sign in now.
                 Gdn::session()->start($AuthUserID);
                 if ($this->Form->getFormValue('RememberMe')) {
                     Gdn::authenticator()->setIdentity($AuthUserID, true);
                 }
                 $this->fireEvent('RegistrationSuccessful');
                 // ... and redirect them appropriately
                 $Route = $this->redirectTo();
                 if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
                     $this->RedirectUrl = url($Route);
                 } else {
                     if ($Route !== false) {
                         redirect($Route);
                     }
                 }
             }
         } catch (Exception $Ex) {
             $this->Form->addError($Ex);
         }
     } else {
         // Set some form defaults.
         if ($Name = val('Name', $Invitation)) {
             $this->Form->setValue('Name', $Name);
         }
         $this->InvitationCode = $InvitationCode;
     }
     // Make sure that the hour offset for new users gets defined when their account is created
     $this->addJsFile('entry.js');
     $this->render();
 }
Ejemplo n.º 4
0
 /**
  * Revoke an invitation.
  *
  * @since 2.0.0
  * @param int $InvitationID Unique identifier.
  * @throws Exception Throws an exception when the invitation isn't found or the user doesn't have permission to delete it.
  */
 public function uninvite($InvitationID)
 {
     $this->permission('Garden.SignIn.Allow');
     if (!$this->Form->authenticatedPostBack()) {
         throw forbiddenException('GET');
     }
     $InvitationModel = new InvitationModel();
     $Session = Gdn::session();
     try {
         $Valid = $InvitationModel->delete($InvitationID, $this->UserModel);
         if ($Valid) {
             $this->informMessage(t('The invitation was removed successfully.'));
             $this->jsonTarget(".js-invitation[data-id=\"{$InvitationID}\"]", '', 'SlideUp');
         }
     } catch (Exception $ex) {
         $this->Form->addError(strip_tags($ex->getMessage()));
     }
     if ($this->Form->errorCount() == 0) {
         $this->render('Blank', 'Utility');
     }
 }