/**
  * If the title is empty, set it to getLinkURL()
  *
  * @return string
  **/
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     if (!$this->Title) {
         switch ($this->Type) {
             case 'URL':
             case 'Email':
             case 'Phone':
                 $this->Title = $this->{$this->Type};
                 break;
             case 'SiteTree':
                 $this->Title = $this->SiteTree()->MenuTitle;
                 break;
             default:
                 if ($this->Type && ($component = $this->getComponent($this->Type))) {
                     $this->Title = $component->Title;
                 }
                 break;
         }
         if (!$this->Title) {
             $this->Title = 'Link-' . $this->ID;
         }
         $this->write();
     }
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     if ($this->isChanged("ID") && $this->getFirstWrite() && $this->getSyncMailChimp()) {
         $apikey = SiteConfig::current_site_config()->getMCAPIKey();
         $api = new MCAPI($apikey);
         $list = $this->getComponent("MCList");
         if (!empty($list)) {
             // Limitited to 50 Bytes (Hopefully 50 Chars)
             $SegmentTitle = substr($this->Title, 0, 45);
             $api->listStaticSegmentAdd($list->ListID, $SegmentTitle);
             if ($api->errorCode) {
                 SS_Log::log("API Call Failed: listStaticSegmentAdd(); | Error Code = " . $api->errorCode . " | Error Message = " . $api->errorMessage, SS_Log::ERR);
             } else {
                 SS_Log::log("API Call Success: listStaticSegmentAdd();", SS_Log::NOTICE);
                 // Make Second Call To Return MailChimp Segment ID
                 $segments = $api->listStaticSegments($list->ListID);
                 foreach ($segments as $segment) {
                     // Make Sure We Capture the WHOLE Event ID!
                     $id_chars = strlen((string) $this->EventID);
                     $id = substr($segment['name'], 6, $id_chars);
                     if ($id == $this->EventID) {
                         SS_Log::log("This Event ID = " . $this->EventID . ", Static Segment Named " . $segment['name'] . " Relates to Event ID " . $id, SS_Log::NOTICE);
                         SS_Log::log("We Have a Match", SS_Log::NOTICE);
                         $this->setField("MCListSegmentID", $segment['id']);
                         $this->write();
                         break;
                     }
                 }
             }
         }
     }
     // END: if($this->isChanged("ID")) {
     $this->setFirstWrite(false);
 }
 /**
  * After we've been written, check whether we've got a template and to then
  * create the relevant actions etc.  
  */
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     if ($this->numChildren() == 0 && $this->Template && !$this->TemplateVersion) {
         $this->workflowService->defineFromTemplate($this, $this->Template);
     }
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     $dashboards = $this->Dashboards();
     if (!$dashboards->Count()) {
         $this->createDefaultBoards();
     }
 }
Example #5
0
 /**
  * After saving this post, update the {@link ForumThread} with information
  * that this is now the most recent post
  */
 function onAfterWrite()
 {
     parent::onAfterWrite();
     // Tell the thread this is the most recently added or edited.
     if ($this->ThreadID) {
         $this->Thread()->updateLastPost($this);
     }
 }
 /**
  * Add an extension point for afterCreate
  */
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     if ($this->_isCreating === true) {
         $this->_isCreating = false;
         $this->extend('onAfterCreate');
     }
 }
Example #7
0
 protected function onAfterWrite()
 {
     parent::onAfterWrite();
     foreach ($this->EntitiesSurveys() as $sub_surveys) {
         $sub_surveys->IsTest = $this->IsTest;
         $sub_surveys->write();
     }
 }
Example #8
0
 protected function onAfterWrite()
 {
     parent::onAfterWrite();
     foreach ($this->EntitySurveys() as $entity) {
         $entity->Enabled = $this->Enabled;
         $entity->write();
     }
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     $pages = $this->Pages();
     foreach ($pages as $page) {
         $page->storeQuestionData();
     }
 }
 function onAfterWrite()
 {
     if (!$this->Hash) {
         $this->Hash = self::udihash($this->ID);
         $this->write();
     }
     parent::onAfterWrite();
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     /** @var SiteConfig $siteConfig Limit uploaded images to the setting in the siteconfig. */
     $siteConfig = SiteConfig::current_site_config();
     if ($siteConfig->SlideshowSize) {
         $this->resizeImages($siteConfig);
     }
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     $Image = $this->Image();
     if ($Image) {
         $Image->Title = $this->Title;
         $Image->write();
     }
 }
Example #13
0
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     //register new request
     $new_request = new OrganizationRegistrationRequest();
     $new_request->MemberID = Member::currentUserID();
     $new_request->OrganizationID = $this->ID;
     $new_request->write();
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     self::updateProductCache();
     // Update the catalog cache
     if ($catalog = Catalog::get()->byID($this->CatalogID)) {
         $catalog->updateCatalogCache();
     }
 }
 function onAfterWrite()
 {
     parent::onAfterWrite();
     $location = $this->getLocation($this->Address);
     if ($location) {
         $this->MapLatitude = $location['lat'];
         $this->MapLongitude = $location['lng'];
         $this->write();
     }
 }
 public function onAfterWrite()
 {
     //Update stock levels if a variation is being saved here
     parent::onAfterWrite();
     $item = $this->Item();
     $variation = $this->Object();
     if ($variation && $variation->exists() && $variation instanceof Variation) {
         $item->updateStockLevels();
     }
 }
 function onAfterWrite()
 {
     parent::onAfterWrite();
     if (!$this->Sent) {
         $email = new Email($from = Email::getAdminEmail(), $to = $this->To, $subject = $this->Subject, $body = $this->Body, $bounceHandlerURL = null, $cc = null, $bcc = Email::getAdminEmail());
         $email->send();
         $this->Sent = 1;
         $this->write();
     }
 }
 /**
  * Cleans up logs older than X days after writing
  */
 protected function onAfterWrite()
 {
     parent::onAfterWrite();
     //Clean up old logs
     $oldLogs = KapostBridgeLog::get()->filter('Created:LessThan', date('Y-m-d H:i:s', strtotime('-' . self::config()->log_expire_days . ' days')));
     if ($oldLogs->count() > 0) {
         foreach ($oldLogs as $log) {
             $log->delete();
         }
     }
 }
 /**
  * Cleans up the expired tokens after writing
  */
 protected function onAfterWrite()
 {
     parent::onAfterWrite();
     //Clean up the expired tokens
     $expiredTokens = KapostPreviewToken::get()->filter('Created:LessThan', date('Y-m-d H:i:s', strtotime('-' . KapostService::config()->preview_token_expiry . ' minutes')));
     if ($expiredTokens->count() > 0) {
         foreach ($expiredTokens as $token) {
             $token->delete();
         }
     }
 }
 function onAfterWrite()
 {
     parent::onAfterWrite();
     if ($this->newWhatWeDid) {
         $this->newWhatWeDid->WebPortfolioItem()->add($this);
         $this->WhatWeDid()->add($this->newWhatWeDid);
     }
     if (isset($_REQUEST["AddWhatWeDid"])) {
         unset($_REQUEST["AddWhatWeDid"]);
     }
     $this->newWhatWeDid = null;
 }
 function onAfterWrite()
 {
     parent::onAfterWrite();
     if ($this->mergeInto) {
         DB::query("UPDATE \"WebPortfolioItem_WhatWeDid\" SET \"WebPortfolioWhatWeDidDescriptorID\" = " . $this->mergeInto->ID . " WHERE \"WebPortfolioWhatWeDidDescriptorID\"  = " . $this->ID);
         $this->delete();
     }
     if (isset($_REQUEST["MergeID"])) {
         unset($_REQUEST["MergeID"]);
     }
     $this->mergeInto = null;
 }
 /**
  * After we've been written, check whether we've got a template and to then
  * create the relevant actions etc.
  */
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     // Request via ImportForm where TemplateVersion is already set, so unset it
     $posted = Controller::curr()->getRequest()->postVars();
     if (isset($posted['_CsvFile']) && $this->TemplateVersion) {
         $this->TemplateVersion = null;
     }
     if ($this->numChildren() == 0 && $this->Template && !$this->TemplateVersion) {
         $this->workflowService->defineFromTemplate($this, $this->Template);
     }
 }
 public function onAfterWrite()
 {
     if (!$this->DetailPageLink) {
         $this->DetailPageLink = Director::absoluteBaseURL() . strtolower($this->Type) . '/show/' . $this->ID;
         $this->write();
     }
     if ($this->isChanged('Accepted') && $this->Accepted) {
         $mailData = array('Subject' => $this->Type . " '" . $this->Name . "' has been Approved", 'To' => ExtensionAuthorController::get_authors_email($this->ID), 'From' => Config::inst()->get($this->Type, 'ReviewerEmail'), 'ExtensionType' => $this->Type, 'ExtensionName' => $this->Name, 'ExtensionPageUrl' => $this->DetailPageLink, 'SubmittedBy' => $this->SubmittedBy()->Name);
         $this->sendMailtoAuthors($mailData);
     }
     parent::onAfterWrite();
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     //Make sure there is only one default address
     if ($this->Default == true) {
         $addrs = Address::get()->where("\"ClassName\" = '" . get_class($this) . "' AND \"MemberID\" = '{$this->MemberID}' AND \"Default\" = 1 AND \"ID\" != {$this->ID}");
         if ($addrs && $addrs->exists()) {
             foreach ($addrs as $addr) {
                 $addr->Default = 0;
                 $addr->write();
             }
         }
     }
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     $dashboards = $this->Dashboards();
     if (!$dashboards->Count()) {
         $i = 0;
         while ($i < self::$max_dashboards) {
             $area = new MemberDashboard();
             $area->DashboardID = $this->ID;
             $area->write();
             $i++;
         }
     }
 }
Example #26
0
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     if (empty($this->UserHash) || empty($this->MessageHash)) {
         $this->UserHash = $this->makeUserHash();
         $this->MessageHash = $this->makeMessageHash();
         $rootMessage = $this->getRootMessage();
         if ($rootMessage->ID == $this->ID) {
             $this->LastEdited = SS_Datetime::now()->getValue();
         } else {
             $rootMessage->LastEdited = SS_Datetime::now()->getValue();
             $rootMessage->write();
         }
         $this->write();
     }
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     if ($this->FirstExecution && !$this->JustWritten) {
         if (!$this->ScheduledJobID) {
             $job = new ScheduledExecutionJob($this);
             $time = date('Y-m-d H:i:s');
             if ($this->FirstExecution) {
                 $time = date('Y-m-d H:i:s', strtotime($this->FirstExecution));
             }
             $srv = singleton('QueuedJobService');
             $this->ScheduledJobID = $srv->queueJob($job, $time, Member::currentUserID(), $this->JobType);
             $this->JustWritten = true;
             $this->write();
         }
     }
 }
Example #28
0
 /**
  * If the title is empty, set it to getLinkURL()
  * @return String
  **/
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     if (!$this->Title) {
         if ($this->Type == 'URL' || $this->Type == 'Email') {
             $this->Title = $this->{$this->Type};
         } elseif ($this->Type == 'SiteTree') {
             $this->Title = $this->SiteTree()->MenuTitle;
         } else {
             if ($this->Type && ($component = $this->getComponent($this->Type))) {
                 $this->Title = $component->Title;
             }
         }
         if (!$this->Title) {
             $this->Title = 'Link-' . $this->ID;
         }
         $this->write();
     }
 }
 public function onAfterWrite()
 {
     parent::onAfterWrite();
     // On Event Creation Instanciate New MCListSegment Object(s)
     if ($this->owner->isChanged("ID") && $this->getFirstWrite()) {
         if (!empty($this->_AffectedMCListIDs)) {
             $ListData = explode(',', $this->_AffectedMCListIDs);
             foreach ($ListData as $ListID) {
                 $seg = new MCListSegment();
                 $seg->setField("MCListID", $ListID);
                 $seg->setField("EventID", $this->owner->ID);
                 $seg->setField("Title", "Event " . $this->owner->ID . ": " . $this->owner->getTitle());
                 $seg->write();
             }
         }
     }
     // END: if($this->isChanged("ID")) {
     $this->setFirstWrite(false);
 }
 function onAfterWrite()
 {
     $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
     parent::onAfterWrite();
     //add recommendations that are not actually matching
     $combos = $this->Recommendations();
     if ($combos) {
         $idArray = array();
         foreach ($combos as $combo) {
             $idArray[$combo->SiteTreeID] = $combo->SiteTreeID;
         }
         if (count($idArray)) {
             $pages = SiteTree::get()->filter(array("ID" => $idArray));
             if ($pages->count()) {
                 foreach ($pages as $page) {
                     $changed = false;
                     $title = Config::inst()->get("SearchHistory", "seperator") . $this->getTitle();
                     $multipliedTitle = Config::inst()->get("SearchHistory", "seperator") . str_repeat($this->getTitle(), Config::inst()->get("SearchHistory", "number_of_keyword_repeats"));
                     if (stripos($page->MetaKeywords . " ", $multipliedTitle) === false) {
                         $page->MetaKeywords . $multipliedTitle;
                         $changed = true;
                     }
                     if (stripos($page->MetaKeywords . " ", $multipliedTitle) === false) {
                         $page->MetaKeywords = $page->MetaKeywords . $multipliedTitle;
                         $changed = true;
                     }
                     if ($changed) {
                         $page->writeToStage('Stage');
                         $page->Publish('Stage', 'Live');
                         $page->Status = "Published";
                     }
                 }
             }
         }
     }
     //delete useless ones
     if (strlen($this->Title) < Config::inst()->get("SearchHistory", "minimum_length")) {
         $this->delete();
     }
 }