/** * Sends a theme notification to the Factory. * * This is going to contact the Factory, so it qualifies as a third-party * call, therefore calling it during a normal page load is not advisable. A * possibly safer solution could be executing this via a menu callback called * through an asynchronous JavaScript call. * * If the request does not succeed (and $store_failed_notification is truthy), * the notification will be stored so that we may try again later when cron * runs. * * @param string $scope * The scope. Either "theme", "site", "group", or "global". * @param string $event * The type of theme event that occurred. Either "create", "modify", or * "delete". * @param int $nid * The node ID associated with the scope. Only required for "group" scope * notifications. If empty, it will be filled in automatically for "theme" * and "site" scope notifications. * @param string $theme * The system name of the theme the event relates to. Only relevant for * "theme" scope notifications. * @param int $timestamp * The timestamp when the notification was created. * @param bool $store_failed_notification * Optional variable to disable storing a notification when the sending * fails. Should be only used in case of notifications which have been * already added to the pending notification table. * * @return array * The message response body and code. */ public function sendNotification($scope, $event, $nid = NULL, $theme = NULL, $timestamp = NULL, $store_failed_notification = TRUE) { if (!$this->isEnabled()) { return array('code' => 500, 'data' => array('message' => t('The theme change notification feature is not enabled.'))); } try { if (empty($nid) && in_array($scope, array('theme', 'site'))) { $site = acsf_get_acsf_site(); $nid = $site->site_id; } $parameters = array('scope' => $scope, 'event' => $event, 'nid' => $nid); if ($theme) { $parameters['theme'] = $theme; } if ($timestamp) { $parameters['timestamp'] = $timestamp; } $message = new AcsfMessageRest('POST', 'site-api/v1/theme/notification', $parameters); $message->send(); $response = array('code' => $message->getResponseCode(), 'data' => $message->getResponseBody()); } catch (\Exception $e) { $error_message = t('AcsfThemeNotify failed with error: @message.', array('@message' => $e->getMessage())); syslog(LOG_ERR, $error_message); // Send a log message to the Factory. $acsf_log = new AcsfLog(); $acsf_log->log('theme_notify', $error_message, LOG_ERR); $response = array('code' => 500, 'data' => array('message' => $error_message)); } if ($store_failed_notification && $response['code'] !== 200) { $this->addNotification($event, $theme); } return $response; }
/** * Implements AcsfEventHandler::handle(). */ public function handle() { $site = acsf_get_acsf_site(); $site->refresh(); // Notify the user to verify their email address. $site->verification_status['last_updated'] = time(); $site->save(); }
/** * Implements AcsfEventHandler::handle(). */ public function handle() { drush_print(dt('Entered @class', array('@class' => get_class($this)))); if (!$this->isComplete()) { $site = acsf_get_acsf_site(); $site->clean(); variable_del('acsf_duplication_scrub_status'); variable_set('site_name', $this->event->context['site_name']); variable_set('install_time', time()); // As a preparatory step, remove any corrupt file entries that may prevent // duplication from succeeding. Specifically, remove any file with an // empty URI string. db_delete('file_managed')->condition('uri', '')->execute(); $this->setComplete(); } }