protected function Form_Create() { $this->objProvisionalPublicLogin = ProvisionalPublicLogin::Load(QApplication::PathInfo(0)); if (!$this->objProvisionalPublicLogin || $this->objProvisionalPublicLogin->UrlHash != QApplication::PathInfo(1)) { QApplication::Redirect('/register/'); } }
/** * This will create a provisional PublicLogin record, including setting up the hash. * NOTE: If the PublicLogin record already exists AND it is a non-provisional one, then this will throw an error * Otherwise, if the PublicLogin exists as a provisional one, it will simply overwrite the provisioned info. * * @param string $strUsername * @param string $strEmailAddress * @param string $strFirstName * @param string $strLastName * @return ProvisionalPublicLogin */ public static function CreateProvisional($strUsername, $strEmailAddress, $strFirstName, $strLastName) { $strEmailAddress = trim(strtolower($strEmailAddress)); $strUsername = QApplication::Tokenize($strUsername, false); if (strlen($strUsername) < 4) { throw new QCallerException('Username is too short: ' . $strUsername); } if (!self::IsProvisionalCreatableForUsername($strUsername)) { throw new QCallerException('Username is already taken: ' . $strUsername); } // Perform the Creation Tasks within a Single Transaction try { PublicLogin::GetDatabase()->TransactionBegin(); // Delete any other provisional login using this email address with a different username foreach (ProvisionalPublicLogin::QueryArray(QQ::Equal(QQN::ProvisionalPublicLogin()->EmailAddress, $strEmailAddress)) as $objProvisionalPublicLogin) { if ($objProvisionalPublicLogin->PublicLogin->Username != $strUsername) { $objPublicLogin = $objProvisionalPublicLogin->PublicLogin; $objProvisionalPublicLogin->Delete(); $objPublicLogin->Delete(); } } // Be sure to reuse the username record if applicable $objPublicLogin = PublicLogin::LoadByUsername($strUsername); $blnChangeHash = true; if ($objPublicLogin) { if ($objPublicLogin->ProvisionalPublicLogin->EmailAddress == $strEmailAddress) { $blnChangeHash = false; } $objProvisionalPublicLogin = $objPublicLogin->ProvisionalPublicLogin; $objPublicLogin->DateRegistered = QDateTime::Now(); $objPublicLogin->Save(); } else { $objPublicLogin = new PublicLogin(); $objPublicLogin->ActiveFlag = true; $objPublicLogin->Username = $strUsername; $objPublicLogin->DateRegistered = QDateTime::Now(); $objPublicLogin->Save(); $objProvisionalPublicLogin = new ProvisionalPublicLogin(); $objProvisionalPublicLogin->PublicLogin = $objPublicLogin; } // Update Values $objProvisionalPublicLogin->FirstName = trim($strFirstName); $objProvisionalPublicLogin->LastName = trim($strLastName); $objProvisionalPublicLogin->EmailAddress = trim($strEmailAddress); if ($blnChangeHash) { $objProvisionalPublicLogin->UrlHash = md5(microtime()); $objProvisionalPublicLogin->ConfirmationCode = rand(1000, 9999); } $objProvisionalPublicLogin->Save(); PublicLogin::GetDatabase()->TransactionCommit(); $objProvisionalPublicLogin->SendConfirmationEmail(); return $objProvisionalPublicLogin; } catch (Exception $objExc) { PublicLogin::GetDatabase()->TransactionRollBack(); throw $objExc; } }
/** * This will save this object's PublicLogin instance, * updating only the fields which have had a control created for it. */ public function SavePublicLogin() { try { // Update any fields for controls that have been created if ($this->lstPerson) { $this->objPublicLogin->PersonId = $this->lstPerson->SelectedValue; } if ($this->chkActiveFlag) { $this->objPublicLogin->ActiveFlag = $this->chkActiveFlag->Checked; } if ($this->txtUsername) { $this->objPublicLogin->Username = $this->txtUsername->Text; } if ($this->txtPassword) { $this->objPublicLogin->Password = $this->txtPassword->Text; } if ($this->txtLostPasswordQuestion) { $this->objPublicLogin->LostPasswordQuestion = $this->txtLostPasswordQuestion->Text; } if ($this->txtLostPasswordAnswer) { $this->objPublicLogin->LostPasswordAnswer = $this->txtLostPasswordAnswer->Text; } if ($this->chkTemporaryPasswordFlag) { $this->objPublicLogin->TemporaryPasswordFlag = $this->chkTemporaryPasswordFlag->Checked; } if ($this->calDateRegistered) { $this->objPublicLogin->DateRegistered = $this->calDateRegistered->DateTime; } if ($this->calDateLastLogin) { $this->objPublicLogin->DateLastLogin = $this->calDateLastLogin->DateTime; } // Update any UniqueReverseReferences (if any) for controls that have been created for it if ($this->lstProvisionalPublicLogin) { $this->objPublicLogin->ProvisionalPublicLogin = ProvisionalPublicLogin::Load($this->lstProvisionalPublicLogin->SelectedValue); } // Save the PublicLogin object $this->objPublicLogin->Save(); // Finally, update any ManyToManyReferences (if any) } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } }
/** * Override method to perform a property "Get" * This will get the value of $strName * * @param string $strName Name of the property to get * @return mixed */ public function __get($strName) { switch ($strName) { /////////////////// // Member Variables /////////////////// case 'Id': // Gets the value for intId (Read-Only PK) // @return integer return $this->intId; case 'PersonId': // Gets the value for intPersonId (Unique) // @return integer return $this->intPersonId; case 'ActiveFlag': // Gets the value for blnActiveFlag // @return boolean return $this->blnActiveFlag; case 'Username': // Gets the value for strUsername (Unique) // @return string return $this->strUsername; case 'Password': // Gets the value for strPassword // @return string return $this->strPassword; case 'LostPasswordQuestion': // Gets the value for strLostPasswordQuestion // @return string return $this->strLostPasswordQuestion; case 'LostPasswordAnswer': // Gets the value for strLostPasswordAnswer // @return string return $this->strLostPasswordAnswer; case 'TemporaryPasswordFlag': // Gets the value for blnTemporaryPasswordFlag // @return boolean return $this->blnTemporaryPasswordFlag; case 'DateRegistered': // Gets the value for dttDateRegistered (Not Null) // @return QDateTime return $this->dttDateRegistered; case 'DateLastLogin': // Gets the value for dttDateLastLogin // @return QDateTime return $this->dttDateLastLogin; /////////////////// // Member Objects /////////////////// /////////////////// // Member Objects /////////////////// case 'Person': // Gets the value for the Person object referenced by intPersonId (Unique) // @return Person try { if (!$this->objPerson && !is_null($this->intPersonId)) { $this->objPerson = Person::Load($this->intPersonId); } return $this->objPerson; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'ProvisionalPublicLogin': // Gets the value for the ProvisionalPublicLogin object that uniquely references this PublicLogin // by objProvisionalPublicLogin (Unique) // @return ProvisionalPublicLogin try { if ($this->objProvisionalPublicLogin === false) { // We've attempted early binding -- and the reverse reference object does not exist return null; } if (!$this->objProvisionalPublicLogin) { $this->objProvisionalPublicLogin = ProvisionalPublicLogin::LoadByPublicLoginId($this->intId); } return $this->objProvisionalPublicLogin; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// //////////////////////////// // Virtual Object References (Many to Many and Reverse References) // (If restored via a "Many-to" expansion) //////////////////////////// case '__Restored': return $this->__blnRestored; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } }
public static function GetSoapArrayFromArray($objArray) { if (!$objArray) { return null; } $objArrayToReturn = array(); foreach ($objArray as $objObject) { array_push($objArrayToReturn, ProvisionalPublicLogin::GetSoapObjectFromObject($objObject, true)); } return unserialize(serialize($objArrayToReturn)); }
/** * Main utility method to aid with data binding. It is used by the default BindAllRows() databinder but * could and should be used by any custom databind methods that would be used for instances of this * MetaDataGrid, by simply passing in a custom QQCondition and/or QQClause. * * If a paginator is set on this DataBinder, it will use it. If not, then no pagination will be used. * It will also perform any sorting (if applicable). * * @param QQCondition $objConditions override the default condition of QQ::All() to the query, itself * @param QQClause[] $objOptionalClauses additional optional QQClause object or array of QQClause objects for the query * @return void */ public function MetaDataBinder(QQCondition $objCondition = null, $objOptionalClauses = null) { // Setup input parameters to default values if none passed in if (!$objCondition) { $objCondition = QQ::All(); } $objClauses = $objOptionalClauses ? $objOptionalClauses : array(); // We need to first set the TotalItemCount, which will affect the calcuation of LimitClause below if ($this->Paginator) { $this->TotalItemCount = ProvisionalPublicLogin::QueryCount($objCondition, $objClauses); } // If a column is selected to be sorted, and if that column has a OrderByClause set on it, then let's add // the OrderByClause to the $objClauses array if ($objClause = $this->OrderByClause) { array_push($objClauses, $objClause); } // Add the LimitClause information, as well if ($objClause = $this->LimitClause) { array_push($objClauses, $objClause); } // Set the DataSource to be a Query result from ProvisionalPublicLogin, given the clauses above $this->DataSource = ProvisionalPublicLogin::QueryArray($objCondition, $objClauses); }
/** * Static Helper Method to Create using PK arguments * You must pass in the PK arguments on an object to load, or leave it blank to create a new one. * If you want to load via QueryString or PathInfo, use the CreateFromQueryString or CreateFromPathInfo * static helper methods. Finally, specify a CreateType to define whether or not we are only allowed to * edit, or if we are also allowed to create a new one, etc. * * @param mixed $objParentObject QForm or QPanel which will be using this ProvisionalPublicLoginMetaControl * @param integer $intPublicLoginId primary key value * @param QMetaControlCreateType $intCreateType rules governing ProvisionalPublicLogin object creation - defaults to CreateOrEdit * @return ProvisionalPublicLoginMetaControl */ public static function Create($objParentObject, $intPublicLoginId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intPublicLoginId)) { $objProvisionalPublicLogin = ProvisionalPublicLogin::Load($intPublicLoginId); // ProvisionalPublicLogin was found -- return it! if ($objProvisionalPublicLogin) { return new ProvisionalPublicLoginMetaControl($objParentObject, $objProvisionalPublicLogin); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a ProvisionalPublicLogin object with PK arguments: ' . $intPublicLoginId); } } // If EditOnly is specified, throw an exception } else { if ($intCreateType == QMetaControlCreateType::EditOnly) { throw new QCallerException('No PK arguments specified'); } } // If we are here, then we need to create a new record return new ProvisionalPublicLoginMetaControl($objParentObject, new ProvisionalPublicLogin()); }