protected function Form_Create() { $this->objPrayerRequest = PrayerRequest::Load(QApplication::PathInfo(0)); $this->txtSubject = new QTextBox($this); $this->txtSubject->Name = 'Prayer Subject:'; $this->txtSubject->Visible = true; $this->txtSubject->Width = 400; $this->txtSubject->Enabled = false; if ($this->objPrayerRequest != null) { $this->txtSubject->Text = 'RE: ' . $this->objPrayerRequest->Subject; } $this->txtNote = new QTextBox($this); $this->txtNote->Name = 'Note:'; $this->txtNote->Rows = 20; $this->txtNote->Columns = 20; $this->txtNote->TextMode = QTextMode::MultiLine; $this->txtNote->Visible = true; $this->btnSubmitNote = new QButton($this); $this->btnSubmitNote->Text = 'Submit Note'; $this->btnSubmitNote->CausesValidation = true; $this->btnSubmitNote->AddAction(new QClickEvent(), new QAjaxAction('btnSubmitNote_Click')); }
protected function lnkSelected_Click($strFormId, $strControlId, $strParameter) { $intPrayerRequestId = $strParameter; $objPrayerRequest = PrayerRequest::Load($intPrayerRequestId); if ($objPrayerRequest) { $this->btnInappropriate->Visible = true; if ($objPrayerRequest->IsAllowNotes) { $this->btnEncouragement->Visible = true; } else { $this->btnEncouragement->Visible = false; } if ($objPrayerRequest->IsPrayerIndicator) { $this->lblPrayerCount->Visible = true; $this->btnIPrayed->Visible = true; } else { $this->lblPrayerCount->Visible = false; $this->btnIPrayed->Visible = false; } $this->objPrayerRequest = $objPrayerRequest; $this->lblSubject->Text = $objPrayerRequest->Subject; $this->lblDate->Text = $objPrayerRequest->Date ? $objPrayerRequest->Date->ToString() : ''; $this->lblContent->Text = $objPrayerRequest->Content; $imgPrayerCount = '<img src="/assets/images/spacer.png" class="prayerStar" />' . ' ' . $this->objPrayerRequest->PrayerCount . ' People prayed for you'; $this->lblPrayerCount->Text = $imgPrayerCount; } }
/** * Reload this PrayerRequest from the database. * @return void */ public function Reload() { // Make sure we are actually Restored from the database if (!$this->__blnRestored) { throw new QCallerException('Cannot call Reload() on a new, unsaved PrayerRequest object.'); } // Reload the Object $objReloaded = PrayerRequest::Load($this->intId); // Update $this's local variables to match $this->strName = $objReloaded->strName; $this->strEmail = $objReloaded->strEmail; $this->strSubject = $objReloaded->strSubject; $this->strContent = $objReloaded->strContent; $this->blnIsConfidential = $objReloaded->blnIsConfidential; $this->blnIsInappropriate = $objReloaded->blnIsInappropriate; $this->blnIsAllowNotes = $objReloaded->blnIsAllowNotes; $this->blnIsPrayerIndicator = $objReloaded->blnIsPrayerIndicator; $this->intPrayerCount = $objReloaded->intPrayerCount; $this->dttDate = $objReloaded->dttDate; }
/** * 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 PrayerRequestMetaControl * @param integer $intId primary key value * @param QMetaControlCreateType $intCreateType rules governing PrayerRequest object creation - defaults to CreateOrEdit * @return PrayerRequestMetaControl */ public static function Create($objParentObject, $intId = null, $intCreateType = QMetaControlCreateType::CreateOrEdit) { // Attempt to Load from PK Arguments if (strlen($intId)) { $objPrayerRequest = PrayerRequest::Load($intId); // PrayerRequest was found -- return it! if ($objPrayerRequest) { return new PrayerRequestMetaControl($objParentObject, $objPrayerRequest); } else { if ($intCreateType != QMetaControlCreateType::CreateOnRecordNotFound) { throw new QCallerException('Could not find a PrayerRequest object with PK arguments: ' . $intId); } } // 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 PrayerRequestMetaControl($objParentObject, new PrayerRequest()); }