protected function Form_Create() { $this->txtDescription = new QTextBox($this); $this->txtDescription->Name = 'Description'; $this->lstStackCount = new QListBox($this); $this->lstStackCount->Name = 'Number of Stacks'; $this->calDateCredited = new QDateTimePicker($this); $this->calDateCredited->MaximumYear = date('Y') + 5; $this->calDateCredited->DateTime = QDateTime::Now(); $this->txtReportedTotals = array(); for ($i = 1; $i <= 20; $i++) { $this->lstStackCount->AddItem($i, $i, $i == 1); $txtReportedTotal = new QFloatTextBox($this, 'txtReportedTotal' . $i); $txtReportedTotal->Name = 'Reported Total for Stack #' . $i; $txtReportedTotal->Visible = false; $this->txtReportedTotals[$i] = $txtReportedTotal; } $this->lstStackCount->AddAction(new QChangeEvent(), new QAjaxAction('lstStackCount_Change')); $this->lstStackCount_Change(); $this->btnSave = new QButton($this); $this->btnSave->Text = 'Create Stack'; $this->btnSave->CssClass = 'primary'; $this->btnSave->CausesValidation = true; $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click')); $this->btnCancel = new QLinkButton($this); $this->btnCancel->CssClass = 'cancel'; $this->btnCancel->Text = 'Cancel'; $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click')); $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction()); }
/** * This will log a message to the Qcodo Log. Location of the log file is defined in __QCODO_LOG__ * * By default, this will log a "Normal" level log entry in the "default" Qcodo log file, which is * located at __QCODO_LOG__/default.log.txt * * Either parameter can be overridden. * * @param string $strMessage * @param integer $intLogLevel * @param string $strLogModule * @return void */ public static function Log($strMessage, $intLogLevel = QLogLevel::Normal, $strLogModule = 'default') { // Cancel out if log level is too low if ($intLogLevel > self::$MinimumLogLevel) { return; } // Setup Log Path if (!defined('__QCODO_LOG__')) { throw new QCallerException('__QCODO_LOG__ must be defined before running QLog::Log'); } // Cancel out if log path is null if (!__QCODO_LOG__) { return; } // Create the Log Directory if it does NOT yet exist if (!is_dir(__QCODO_LOG__)) { QApplication::MakeDirectory(__QCODO_LOG__, 0777); } // Setup the Line $strLine = sprintf("%5s | %s | %s | %s\r\n", getmypid(), QLogLevel::$NameArray[$intLogLevel], QDateTime::Now()->NowToString(QDateTime::FormatIso), self::FormatMessage($strMessage)); // Open the File for Writing $strLogFilePath = __QCODO_LOG__ . '/' . $strLogModule . self::$Extension; $objFile = fopen($strLogFilePath, 'a'); // Write the Line fwrite($objFile, $strLine); fclose($objFile); }
public function btnOkay_Click($strFormId, $strControlId, $strParameter) { $this->btnOkay->Enabled = true; $blnNewTopic = false; // Setup stuff if it's a NEW message being posted (either a NEW response or a NEW topic) if (!$this->blnEditMode) { // For NEW TOPIC in this Forum if (!$this->mctMessage->Message->Topic) { $objForum = Forum::Load($this->lstForum->SelectedValue); $objNewTopic = $objForum->PostTopic(trim($this->txtTopicName->Text), trim($this->txtMessage->Text), QApplication::$Person); QApplication::Redirect(sprintf('/forums/forum.php/%s/%s/', $objForum->Id, $objNewTopic->Id)); // Otherwise, it's a new POST in this TOPIC } else { $this->mctMessage->Message->PostDate = QDateTime::Now(); } // Set the Reply Number for this New Message $this->mctMessage->Message->ReplyNumber = $this->mctMessage->Message->Topic->GetNextReplyNumber(); } // Save Everything Else $this->mctMessage->SaveMessage(); $this->mctMessage->Message->RefreshCompiledHtml(); $this->mctMessage->SaveMessage(); // Refresh Stats and Stuff $this->mctMessage->Message->Topic->RefreshStats(); $this->mctMessage->Message->Topic->RefreshSearchIndex(); $this->mctMessage->Message->TopicLink->RefreshStats(); // Send Alerts and Reset Read Flag on any NEW post if (!$this->blnEditMode) { $this->mctMessage->Message->SendAlerts(); $this->mctMessage->Message->Topic->UnassociateAllPeopleAsRead(); //Mark as read for poster $this->mctMessage->Message->Topic->AssociatePersonAsRead(QApplication::$Person); } $this->ParentControl->CloseMessageDialog(true, !$this->blnEditMode); }
public function Save($blnForceInsert = false, $blnForceUpdate = false) { $this->intSuggestionWordCount = NarroString::WordCount($this->strSuggestionValue); $this->intSuggestionCharCount = mb_strlen($this->strSuggestionValue); $this->strSuggestionValueMd5 = md5($this->strSuggestionValue); if (!isset($this->blnIsImported)) { $this->blnIsImported = false; } if (!$this->__blnRestored || $blnForceInsert) { $this->dttCreated = QDateTime::Now(); } else { $this->dttModified = QDateTime::Now(); } parent::Save($blnForceInsert, $blnForceUpdate); /** * Update all context infos with the has suggestion property */ $arrContextInfo = NarroContextInfo::QueryArray(QQ::AndCondition(QQ::Equal(QQN::NarroContextInfo()->Context->TextId, $this->intTextId), QQ::Equal(QQN::NarroContextInfo()->LanguageId, $this->intLanguageId), QQ::Equal(QQN::NarroContextInfo()->HasSuggestions, 0))); foreach ($arrContextInfo as $objOneContextInfo) { $objOneContextInfo->HasSuggestions = 1; $objOneContextInfo->Modified = QDateTime::Now(); try { $objOneContextInfo->Save(); } catch (Exception $objEx) { NarroLogger::LogWarn($objEx->getMessage()); } } }
private static function Log($strMessage, $intPriority, $intProjectId = null, $intLanguageId = null, $intUserId = null) { if (SERVER_INSTANCE != 'dev' && $intPriority == NarroLog::PRIORITY_DEBUG) { return true; } $objLogEntry = new NarroLog(); $objLogEntry->Date = QDateTime::Now(); $objLogEntry->Priority = $intPriority; $objLogEntry->Message = $strMessage; $objLogEntry->ProjectId = is_null($intProjectId) ? is_null(self::$intProjectId) ? null : self::$intProjectId : $intProjectId; $objLogEntry->LanguageId = is_null($intLanguageId) ? is_null(self::$intLanguageId) ? null : self::$intLanguageId : $intLanguageId; $objLogEntry->UserId = is_null($intUserId) ? is_null(self::$intUserId) ? null : self::$intUserId : $intUserId; try { $objLogEntry->Save(); } catch (Exception $objEx) { error_log($objEx->getMessage() . $objEx->getTraceAsString()); } if (QFirebug::getEnabled()) { switch ($intPriority) { case NarroLog::PRIORITY_INFO: QFirebug::info($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId); break; case NarroLog::PRIORITY_WARN: QFirebug::warn($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId); break; case NarroLog::PRIORITY_ERROR: QFirebug::error($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId); break; default: QFirebug::log($objLogEntry->Message . ' / ' . $objLogEntry->UserId . ' / ' . $objLogEntry->ProjectId . ' / ' . $objLogEntry->LanguageId); } } }
protected function SetupPanel() { $this->mctPledge = StewardshipPledgeMetaControl::Create($this, $this->strUrlHashArgument, QMetaControlCreateType::CreateOnRecordNotFound); if (!$this->mctPledge->EditMode) { // Trying to create a NEW comment $this->mctPledge->StewardshipPledge->DateStarted = QDateTime::Now(); $this->mctPledge->StewardshipPledge->Person = $this->objPerson; $this->mctPledge->StewardshipPledge->FulfilledFlag = false; $this->mctPledge->StewardshipPledge->ActiveFlag = true; $this->btnSave->Text = 'Create'; } else { $this->btnSave->Text = 'Update'; $this->btnDelete = new QLinkButton($this); $this->btnDelete->Text = 'Delete'; $this->btnDelete->CssClass = 'delete'; $this->btnDelete->AddAction(new QClickEvent(), new QConfirmAction('Are you SURE you want to DELETE this pledge?')); $this->btnDelete->AddAction(new QClickEvent(), new QAjaxControlAction($this, 'btnDelete_Click')); $this->btnDelete->AddAction(new QClickEvent(), new QTerminateAction()); } // Create Controls $this->lstStewardshipFund = $this->mctPledge->lstStewardshipFund_Create(null, QQ::All(), array(QQ::OrderBy(QQN::StewardshipFund()->Name))); $this->calDateStarted = $this->mctPledge->calDateStarted_Create(); $this->calDateEnded = $this->mctPledge->calDateEnded_Create(); $this->txtPledgeAmount = $this->mctPledge->txtPledgeAmount_Create(); $this->chkActiveFlag = $this->mctPledge->chkActiveFlag_Create(); $this->chkActiveFlag->Text = 'Note: All fulfilled pledges automatically considred "inactive".'; $this->calDateStarted->MinimumYear = 2000; $this->calDateStarted->MaximumYear = date('Y') + 10; $this->calDateEnded->MinimumYear = 2000; $this->calDateEnded->MaximumYear = date('Y') + 10; }
public function btnSave_Click() { if (!$this->mctComments->EditMode) { $this->mctComments->Comment->DatePosted = QDateTime::Now(); } $this->mctComments->SaveComment(); QApplication::ExecuteJavaScript('document.location="#comments";'); }
/** * Creates a new EmailMessage object with the raw data from a POP3 Server. * @param string $strRawMessage * @return EmailMessage */ public static function CreateWithRawMessage($strRawMessage) { $objEmailMessage = new EmailMessage(); $objEmailMessage->RawMessage = $strRawMessage; $objEmailMessage->EmailMessageStatusTypeId = EmailMessageStatusType::NotYetAnalyzed; $objEmailMessage->DateReceived = QDateTime::Now(); $objEmailMessage->Save(); return $objEmailMessage; }
public function ParsePostData() { if (key_exists('form_location', $_POST)) { $arrParts = explode('/', $_POST['form_location']); $this->fltLat = $arrParts[0]; $this->fltLong = $arrParts[1]; $this->dttUpdated = QDateTime::Now(); } }
/** * This will specifiy viewability based on (a) approval and (b) ensuring it's not yet expired * @return boolean */ public function IsViewable() { if (!$this->blnApprovalFlag) { return false; } if ($this->dttDateExpired->IsEarlierThan(QDateTime::Now())) { return false; } return true; }
public function Save($blnForceInsert = false, $blnForceUpdate = false) { $this->intTextWordCount = NarroString::WordCount($this->strTextValue); $this->intTextCharCount = strlen($this->strTextValue); $this->strTextValueMd5 = md5($this->strTextValue); if (!$this->__blnRestored || $blnForceInsert) { $this->dttCreated = QDateTime::Now(); } else { $this->dttModified = QDateTime::Now(); } parent::Save($blnForceInsert, $blnForceUpdate); }
/** * This will QUEUE a message for delivery. * @param string $strToAddress * @param string $strFromAddress if null, it will look up from Registry * @param string $strSubject * @param string $strBody * @param string $strCc * @param string $strBcc */ public static function QueueMessage($strToAddress, $strFromAddress, $strSubject, $strBody, $strCc = null, $strBcc = null) { $objEmailMessage = new OutgoingEmailQueue(); $objEmailMessage->ToAddress = $strToAddress; $objEmailMessage->FromAddress = $strFromAddress ? $strFromAddress : Registry::GetValue('system_email_address'); $objEmailMessage->CcAddress = $strCc; $objEmailMessage->BccAddress = $strBcc; $objEmailMessage->Subject = $strSubject; $objEmailMessage->Body = $strBody; $objEmailMessage->DateQueued = QDateTime::Now(); $objEmailMessage->ErrorFlag = false; $objEmailMessage->Save(); }
public function btnSave_Click() { if (trim($this->txtComment->Text)) { $objComment = new NarroTextComment(); $objComment->UserId = QApplication::GetUserId(); $objComment->LanguageId = QApplication::GetLanguageId(); $objComment->TextId = $this->intTextId; $objComment->Created = QDateTime::Now(); $objComment->CommentText = $this->txtComment->Text; $objComment->CommentTextMd5 = md5($objComment->CommentText); $objComment->Save(); $this->dtgComments->Refresh(); } }
public function btnInactivate_Click() { $objConditions = QQ::AndCondition(QQ::Equal(QQN::Person()->GroupParticipation->GroupId, $this->objGroup->Id), QQ::IsNull(QQN::Person()->GroupParticipation->DateEnd)); $personArray = Person::QueryArray($objConditions, null); foreach ($personArray as $objPerson) { $groupParticipationArray = $objPerson->GetGroupParticipationArray(); foreach ($groupParticipationArray as $objGroupParticipation) { if ($objGroupParticipation->GroupId == $this->objGroup->Id) { $objGroupParticipation->DateEnd = QDateTime::Now(); $objGroupParticipation->Save(); } } } $this->dtgMembers->Refresh(); }
protected function btnSubmitPraise_Click($strFormId, $strControlId, $strParameter) { // Generate a praise object. $objPraise = new Praises(); $objPraise->Email = $this->txtEmail->Text; $objPraise->Name = $this->txtName->Text; $objPraise->Subject = $this->txtSubject->Text; $objPraise->Content = $this->txtContent->Text; $objNowTime = new DateTime(); $objPraise->Date = QDateTime::Now(); $objPraise->Save(); //email success $this->SendMessage(); // return to prayer page QApplication::Redirect('/prayer/complete_submit_praise.php'); }
public function RenderTitle(ClassifiedPost $objPost) { if ($objPost->DateExpired->IsEarlierThan(QDateTime::Now(false))) { $objStyle = new QDataGridRowStyle(); $objStyle->BackColor = '#eaa'; } else { if (!$objPost->ApprovalFlag) { $objStyle = new QDataGridRowStyle(); $objStyle->ForeColor = '#888'; } else { $objStyle = null; } } $this->dtgPosts->OverrideRowStyle($this->dtgPosts->CurrentRowIndex, $objStyle); return sprintf('<a href="/classifieds/post.php/%s">%s</a>', $objPost->Id, QApplication::HtmlEntities($objPost->Title)); }
public static function UpdateUserLocation($objLocationData) { if (is_null($objLocationData)) { return false; } $objUser = self::User(); if (!is_null($objUser)) { $objUser->LastLat = $objLocationData->Lat; $objUser->LastLong = $objLocationData->Long; $objUser->LastLocationUpdate = QDateTime::Now(); $objUser->Save(); return true; } else { return false; } }
protected function Form_Create() { $this->lstYear = new QListBox($this); for ($intYear = 2002; $intYear <= date('Y'); $intYear++) { $this->lstYear->AddItem($intYear, $intYear, QApplication::PathInfo(0) ? QApplication::PathInfo(0) == $intYear : $intYear == QDateTime::Now()->Year); } $this->lstMonth = new QListBox($this); for ($intMonth = 1; $intMonth <= 12; $intMonth++) { $dttDate = new QDateTime('2000-' . $intMonth . '-01'); $this->lstMonth->AddItem($dttDate->ToString('MMMM'), $intMonth, QApplication::PathInfo(1) ? QApplication::PathInfo(1) == $intMonth : $intMonth == QDateTime::Now()->Month); } $this->lstYear->AddAction(new QChangeEvent(), new QAjaxAction('lstDate_Change')); $this->lstMonth->AddAction(new QChangeEvent(), new QAjaxAction('lstDate_Change')); $this->dtgReport = new QDataGrid($this); $this->dtgReport->AddColumn(new QDataGridColumn('Fund', '<?= $_FORM->RenderRow($_ITEM); ?><?= StewardshipFund::Load($_ITEM[0])->Name; ?>', 'Width=400px')); $this->dtgReport->AddColumn(new QDataGridColumn('Monthly Total', '<?= QApplication::DisplayCurrency($_ITEM[1]); ?>', 'Width=400px')); $this->dtgReport->AddColumn(new QDataGridColumn('YTD', '<?= QApplication::DisplayCurrency($_ITEM[2]); ?>', 'Width=400px')); $this->dttDate = new QDateTime($this->lstYear->SelectedValue . '-' . $this->lstMonth->SelectedValue . '-01'); $this->dttDate->SetTime(null, null, null); // Get the Data $objReportArray = StewardshipPost::GetReportByFundAndMonth($this->dttDate); $objReportYtdArray = StewardshipPost::GetReportYtdByFundForMonth($this->dttDate); // Setup the data holders $this->fltTotal = 0; $this->fltTotalYtd = 0; $objArray = array(); foreach ($objReportArray as $objLineItem) { $objFund = StewardshipFund::Load($objLineItem[0]); if ($objFund->AccountNumber == '7011.010' || substr($objFund->AccountNumber, 0, 1) == '4') { $this->fltTotal += $objLineItem[1]; $objArray[$objLineItem[0]] = array($objLineItem[0], $objLineItem[1], null); } } foreach ($objReportYtdArray as $objLineItem) { $objFund = StewardshipFund::Load($objLineItem[0]); if ($objFund->AccountNumber == '7011.010' || substr($objFund->AccountNumber, 0, 1) == '4') { $this->fltTotalYtd += $objLineItem[1]; if (array_key_exists($objLineItem[0], $objArray)) { $objArray[$objLineItem[0]][2] = $objLineItem[1]; } else { $objArray[$objLineItem[0]] = array($objLineItem[0], null, $objLineItem[1]); } } } // Bind the data $this->dtgReport->DataSource = $objArray; }
protected function btnSubmitPrayer_Click($strFormId, $strControlId, $strParameter) { // Generate a prayer request object. $objPrayer = new PrayerRequest(); $objPrayer->Email = ''; $objPrayer->Name = $this->txtName->Text; $objPrayer->Subject = ''; $objPrayer->Content = $this->txtContent->Text; $objPrayer->IsAllowNotes = false; $objPrayer->IsConfidential = true; $objPrayer->IsInappropriate = false; $objPrayer->IsPrayerIndicator = false; $objNowTime = new DateTime(); $objPrayer->Date = QDateTime::Now(); $objPrayer->Save(); $this->SendMessage(); // return to prayer page QApplication::Redirect('/prayer/complete_confidential_prayer.php'); }
protected function Form_Create() { $this->objCategory = ClassifiedCategory::LoadByToken(QApplication::PathInfo(0)); if (!$this->objCategory) { QApplication::Redirect('/classifieds/'); } $objPost = new ClassifiedPost(); $objPost->ClassifiedCategory = $this->objCategory; $objPost->DatePosted = QDateTime::Now(); $objPost->DateExpired = QDateTime::Now(); $objPost->DateExpired->Day += 90; $objPost->ApprovalFlag = false; $this->mctPost = new ClassifiedPostMetaControl($this, $objPost); $this->txtTitle = $this->mctPost->txtTitle_Create(); $this->txtTitle->Required = true; $this->txtContent = $this->mctPost->txtContent_Create(); $this->txtContent->Required = true; $this->txtName = $this->mctPost->txtName_Create(); $this->txtName->Required = true; $this->txtPhone = $this->mctPost->txtPhone_Create(); $this->txtPhone->Required = true; $this->txtEmail = $this->mctPost->txtEmail_Create(); $this->txtEmail->Required = true; if (QApplication::$PublicLogin && ($objPerson = QApplication::$PublicLogin->Person)) { $this->txtName->Text = $objPerson->Name; if ($objPerson->PrimaryEmail) { $this->txtEmail->Text = $objPerson->PrimaryEmail->Address; } if ($objPerson->PrimaryPhone) { $this->txtPhone->Text = $objPerson->PrimaryPhone->Number; } } $this->btnSubmit = new QButton($this); $this->btnSubmit->AddAction(new QClickEvent(), new QAjaxAction('btnSubmit_Click')); $this->btnSubmit->CssClass = 'primary'; $this->btnSubmit->Text = 'Submit Request'; $this->btnSubmit->CausesValidation = true; $this->btnCancel = new QLinkButton($this); $this->btnCancel->CssClass = 'cancel'; $this->btnCancel->Text = 'Cancel'; $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click')); $this->btnCancel->AddAction(new QClickEvent(), new QTerminateAction()); }
/** * Called to refresh the list of participations for this GroupCategory */ public function RefreshParticipationList() { $fltTime = microtime(true); GroupParticipation::GetDatabase()->NonQuery('DELETE FROM group_participation WHERE group_id=' . $this->intGroupId); $objPersonArray = array(); foreach ($this->Group->GetThisAndChildren() as $objGroup) { if ($objGroup->GroupTypeId != GroupType::GroupCategory) { foreach ($objGroup->GetGroupParticipationArray() as $objParticipation) { $objPersonArray[$objParticipation->PersonId] = $objParticipation->Person; } } } foreach ($objPersonArray as $objPerson) { $this->Group->AddPerson($objPerson, null); } $intTime = round((microtime(true) - $fltTime) * 1000); $this->DateRefreshed = QDateTime::Now(); $this->ProcessTimeMs = $intTime; $this->Save(); }
public function RefreshParticipationList() { $fltStartTime = microtime(true); $objGroupRole = GroupRole::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::GroupRole()->MinistryId, $this->Group->MinistryId), QQ::Equal(QQN::GroupRole()->GroupRoleTypeId, GroupRoleType::Participant)), QQ::OrderBy(QQN::GroupRole()->Id)); if (!$objGroupRole) { $objGroupRole = new GroupRole(); $objGroupRole->MinistryId = $this->Group->MinistryId; $objGroupRole->Name = 'Participant'; $objGroupRole->GroupRoleTypeId = GroupRoleType::Participant; $objGroupRole->Save(); } $this->Group->DeleteAllGroupParticipations(); $objPersonCursor = $this->SearchQuery->Execute(); while ($objPerson = Person::InstantiateCursor($objPersonCursor)) { $this->Group->AddPerson($objPerson, $objGroupRole->Id); } $fltEndTime = microtime(true); $this->dttDateRefreshed = QDateTime::Now(); $this->ProcessTimeMs = round(($fltEndTime - $fltStartTime) * 1000); $this->Save(); }
public function Send() { // Do **NOT** send again if it has already been sent! if ($this->dttDateSent) { return; } // Store an array of email addresses (SMS-based) to send to $strBccArray = array(); // Get the Group, and get the array for CcArray $intPersonIdArray = array(); foreach ($this->Group->GetActiveGroupParticipationArray() as $objGroupParticipation) { // ONly at most one per person if (!array_key_exists($objGroupParticipation->PersonId, $intPersonIdArray)) { // Get the Person $objPerson = $objGroupParticipation->Person; // Do we have an SMS? if ($objPhone = $objPerson->GetSmsEnabledPhone()) { // Yep! Add it to the list $strBccArray[] = $objPhone->SmsEmailAddress; } // Finally, let's make sure it only gets sent (at most) once per person $intPersonIdArray[$objGroupParticipation->PersonId] = $objGroupParticipation->PersonId; } } // Do we have any to send to? if (count($strBccArray)) { // Yes -- let's send it $objEmailMessage = new QEmailMessage($this->Login->Email, $this->Login->Email, $this->strSubject, $this->strBody); $objEmailMessage->Bcc = implode(', ', $strBccArray); QEmailServer::Send($objEmailMessage); $this->DateSent = QDateTime::Now(); $this->Save(); } else { // No -- let's report it $objEmailMessage = new QEmailMessage($this->Login->Email, $this->Login->Email, '[Failed to Send] ' . $this->strSubject, 'The following SMS did NOT send because there were no SMS-enabled group participants: ' . $this->strBody); QEmailServer::Send($objEmailMessage); $this->Delete(); } }
protected function Form_Create() { $count = 10000; Project::ClearCache(); Person::ClearCache(); // Create test persons in database. // Tiny objects if (Person::CountAll() < $count) { for ($i = 0; $i < $count; $i++) { $objPerson = new Person(); $objPerson->FirstName = 'FirstName' . $i; $objPerson->LastName = 'LastName' . $i; $objPerson->Save(); } } // Bigger objects with expansion if (Project::CountAll() < $count) { for ($i = 0; $i < $count; $i++) { $objProject = new Project(); $objProject->Name = 'Project' . $i; $objProject->ProjectStatusTypeId = ProjectStatusType::Open; $objProject->ManagerPersonId = $i % 1000 + 1000; $objProject->Description = 'Description' . $i; $objProject->StartDate = QDateTime::Now(); $objProject->EndDate = QDateTime::Now(); $objProject->Budget = $i; $objProject->Spent = 1; $objProject->Save(); } } $this->pnlTiny = new QPanel($this); $this->pnlTiny->Name = '10,000 Person Objects'; $this->pnlBig = new QPanel($this); $this->pnlBig->Name = '10,000 Project Objects With Expansion'; $this->btnGo = new QButton($this); $this->btnGo->Text = 'Go'; $this->btnGo->AddAction(new QClickEvent(), new QAjaxAction('Go_Click')); }
public function btnVote_Click($strFormId, $strControlId, $strParameter) { if (!QApplication::HasPermissionForThisLang('Can vote', $this->objContextInfo->Context->ProjectId)) { return false; } $objNarroSuggestionVote = NarroSuggestionVote::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroSuggestionVote()->ContextId, $this->objContextInfo->ContextId), QQ::Equal(QQN::NarroSuggestionVote()->SuggestionId, $strParameter), QQ::Equal(QQN::NarroSuggestionVote()->UserId, QApplication::GetUserId()))); if (!$objNarroSuggestionVote) { $objNarroSuggestionVote = new NarroSuggestionVote(); $objNarroSuggestionVote->SuggestionId = $strParameter; $objNarroSuggestionVote->ContextId = $this->objContextInfo->ContextId; $objNarroSuggestionVote->UserId = QApplication::GetUserId(); $objNarroSuggestionVote->Created = QDateTime::Now(); } if (strpos($strControlId, 'votdn') === 0) { $objNarroSuggestionVote->VoteValue = -1; } else { $objNarroSuggestionVote->VoteValue = 1; } $objNarroSuggestionVote->Modified = QDateTime::Now(); $objNarroSuggestionVote->Save(); $this->objContextInfo->Modified = QDateTime::Now(); $this->objContextInfo->Save(); if ($this->ParentControl->ParentControl->chkRefresh->Checked && $strControlId != $this->btnKeepUntranslated->ControlId) { $this->ParentControl->ParentControl->btnSearch_Click(); } $this->lblText->Warning = t('Thank you for your vote. You can change it anytime by voting another suggestion.'); }
protected function LendBasket() { foreach ($this->objBasket->GetBasket() as $item) { $objItem = Myassets::QuerySingle(QQ::Equal(QQN::Myassets()->Id, $item->Id)); $objPerson = Peopledetails::QuerySingle(QQ::Equal(QQN::Peopledetails()->Id, $this->strBorrower)); $objShareDetails = new Sharedetails(); $objShareDetails->Asin = $objItem->Asin; $objShareDetails->Email = $objPerson->Email; /*Logic to get the return date*/ $today = new QDateTime(QDateTime::Now); $daySpan = new QDateTimeSpan(); $daySpan->AddDays(30); $returnDate = $today->Add($daySpan); $objShareDetails->TakenDate = QDateTime::Now(false); $objShareDetails->ReturnDate = $returnDate; $objShareDetails->Title = $objItem->Title; $objShareDetails->FullName = $objPerson->FullName; $objShareDetails->Save(); } }
<?php $strRelative = QDateTime::Now()->Difference($_FORM->objWikiVersion->PostDate)->SimpleDisplay(); if ($strRelative == 'a day') { $strRelative = 'yesterday'; } else { if (!$strRelative) { $strRelative = 'just now'; } else { $strRelative .= ' ago'; } } ?> <h3 style="margin-top: 12px;"> version: <strong>#<?php _p($_FORM->objWikiVersion->VersionNumber); ?> </strong> <?php if ($_FORM->objWikiVersion->IsCurrentVersion()) { ?> (current) <?php } ?> | last edited by: <strong><a href="<?php
public function __get($strName) { $this->ReinforceNullProperties(); switch ($strName) { case 'Month': if ($this->blnDateNull) { return null; } else { return (int) parent::format('m'); } case 'Day': if ($this->blnDateNull) { return null; } else { return (int) parent::format('d'); } case 'Year': if ($this->blnDateNull) { return null; } else { return (int) parent::format('Y'); } case 'Hour': if ($this->blnTimeNull) { return null; } else { return (int) parent::format('H'); } case 'Minute': if ($this->blnTimeNull) { return null; } else { return (int) parent::format('i'); } case 'Second': if ($this->blnTimeNull) { return null; } else { return (int) parent::format('s'); } case 'Timestamp': // Until PHP fixes a bug where lowest int is int(-2147483648) but lowest float/double is (-2147529600) // We return as a "double" return (double) parent::format('U'); case 'Age': // Figure out the Difference from "Now" $dtsFromCurrent = $this->Difference(QDateTime::Now()); // It's in the future ('about 2 hours from now') if ($dtsFromCurrent->IsPositive()) { return $dtsFromCurrent->SimpleDisplay() . ' from now'; } else { if ($dtsFromCurrent->IsNegative()) { $dtsFromCurrent->Seconds = abs($dtsFromCurrent->Seconds); return $dtsFromCurrent->SimpleDisplay() . ' ago'; // It's current } else { return 'right now'; } } default: throw new QUndefinedPropertyException('GET', 'QDateTime', $strName); } }
/** * 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; } }
public function btnSave_Click($strFormId, $strControlId, $strParameter) { $this->objPerson->Title = $this->lstTitle->SelectedValue; $this->objPerson->FirstName = trim($this->txtFirstName->Text); $this->objPerson->MiddleName = trim($this->txtMiddleName->Text); $this->objPerson->LastName = trim($this->txtLastName->Text); $this->objPerson->Suffix = $this->lstSuffix->SelectedValue; $this->objPerson->Nickname = trim($this->txtNickname->Text); $this->objPerson->PriorLastNames = trim($this->txtPriorLastNames->Text); $this->objPerson->MailingLabel = trim($this->txtMailingLabel->Text); $this->objPerson->Gender = trim($this->lstGender->SelectedValue); // Date of Birth Stuff switch ($this->lstDateOfBirth->SelectedValue) { case self::DobNone: $this->objPerson->DateOfBirth = null; $this->objPerson->DobGuessedFlag = null; $this->objPerson->DobYearApproximateFlag = null; break; case self::DobExact: $this->objPerson->DateOfBirth = $this->dtxDateOfBirth->DateTime; $this->objPerson->DobGuessedFlag = false; $this->objPerson->DobYearApproximateFlag = false; break; case self::DobApproximateDay: if ($this->objPerson->DateOfBirth) { $dttDate = new QDateTime($this->objPerson->DateOfBirth); $dttDate->Year = QDateTime::Now()->Year; if ($dttDate->IsLaterThan(QDateTime::Now())) { $dttDate->Year -= 1; } } else { $dttDate = QDateTime::Now(); $dttDate->Month -= 6; } $dttDate->Year -= $this->txtAge->Text; $this->objPerson->DateOfBirth = $dttDate; $this->objPerson->DobGuessedFlag = true; $this->objPerson->DobYearApproximateFlag = false; break; case self::DobApproximateYear: $dttDate = QDateTime::Now(); $dttDate->Month = $this->lstMonth->SelectedValue; $dttDate->Day = $this->lstDay->SelectedValue; if ($dttDate->IsLaterThan(QDateTime::Now())) { $dttDate->Year -= 1; } $dttDate->Year -= $this->txtAge->Text; $this->objPerson->DateOfBirth = $dttDate; $this->objPerson->DobGuessedFlag = false; $this->objPerson->DobYearApproximateFlag = true; break; case self::DobApproximateYearAndDay: if ($this->objPerson->DateOfBirth) { $dttDate = new QDateTime($this->objPerson->DateOfBirth); $dttDate->Year = QDateTime::Now()->Year; if ($dttDate->IsLaterThan(QDateTime::Now())) { $dttDate->Year -= 1; } } else { $dttDate = QDateTime::Now(); $dttDate->Month -= 6; } $dttDate->Year -= $this->txtAge->Text; $this->objPerson->DateOfBirth = $dttDate; $this->objPerson->DobGuessedFlag = true; $this->objPerson->DobYearApproximateFlag = true; break; default: throw new Exception('Invalid DOB Type'); } $this->objPerson->RefreshAge(false); // Deceased Flag and Date if ($this->objPerson->DeceasedFlag = $this->chkDeceased->Checked) { $this->objPerson->DateDeceased = $this->dtxDateDeceased->DateTime; // Also unsubscribe from church newsletter $objList = CommunicationList::LoadByToken('allchurch_nl'); if ($objList->IsPersonAssociated($this->objPerson)) { $objList->UnassociatePerson($this->objPerson); } } else { $this->objPerson->DateDeceased = null; } $this->objPerson->Save(); $this->objPerson->RefreshNameItemAssociations(); // Refresh Name of teh Household (if applicable) if ($this->objPerson->HouseholdAsHead) { $this->objPerson->HouseholdAsHead->RefreshName(); } foreach ($this->objPerson->GetHouseholdParticipationArray() as $objHouseholdParticipation) { $objHouseholdParticipation->Household->RefreshMembers(); } QApplication::ExecuteJavaScript('document.location = "#general";'); }