Beispiel #1
0
 public function testEmail()
 {
     $channels = array();
     $channels[] = \Native5\Services\Messaging\Notifier::TYPE_EMAIL;
     $email = new \Native5\Services\Messaging\MailMessage();
     $email->setSubject('Test E-mail : Subject 001');
     $email->setBody('Testing E-mail Sending works.');
     $email->setRecipients(array('*****@*****.**', '*****@*****.**'));
     //$email->addAttachment(__FILE__);
     //$email->addAttachment(__DIR__.'/../../Application.php');
     //$email->addAttachment('/home/shamik/Work/Native5_Packages/SDKs/native5-sdk-services-php/LICENSE');
     //$email->addAttachment('/home/shamik/Work/Native5_Packages/SDKs/native5-sdk-services-php/VERSION');
     $mailService = \Native5\Services\Messaging\NotificationService::instance();
     $mailStatus = $mailService->sendNotification($channels, $email);
     $GLOBALS['logger']->info("Got mailStatus: " . print_r($mailStatus, 1));
 }
Beispiel #2
0
 public static function sendNotification(\Akzo\Scheme $scheme, $transition)
 {
     $transitionName = $transition->getName();
     $templateData = array("scheme" => $scheme, "url" => self::_getSiteUrl(), "initiatorName" => $scheme->initiator->identity->name, "initiatorCode" => $scheme->initiator->identity->code, "reviewerName" => $scheme->reviewer->identity->name, "reviewerCode" => $scheme->reviewer->identity->code, "approverName" => $scheme->approver->identity->name, "approverCode" => $scheme->approver->identity->code);
     if (strcmp($transitionName, \Akzo\Scheme\StateTransition::INITIATE_CREATED_SCHEME) === 0 || strcmp($transitionName, \Akzo\Scheme\StateTransition::INITIATE_STAGED_SCHEME) === 0 || strcmp($transitionName, \Akzo\Scheme\StateTransition::INITIATE_UPDATED_SCHEME) === 0) {
         $notifications = self::_prepareNotifications($scheme, "initiated", "Scheme Review / Approval Initiated", "Initiated, To be Reviewed", $templateData, array(self::REVIEWER => true));
     } else {
         if (strcmp($transitionName, \Akzo\Scheme\StateTransition::REVIEW_SCHEME) === 0) {
             $notifications = self::_prepareNotifications($scheme, "reviewed", "Scheme Reviewed", "Reviewed, To be Approved", $templateData, array(self::REVIEWER => true, self::APPROVER => true));
         } else {
             if (strcmp($transitionName, \Akzo\Scheme\StateTransition::APPROVE_SCHEME) === 0) {
                 $notifications = self::_prepareNotifications($scheme, "approved", "Scheme Approved", "Approved", $templateData, array(self::APPROVER => true));
             } else {
                 if (strcmp($transitionName, \Akzo\Scheme\StateTransition::REQUEST_SCHEME_UPDATE) === 0 && in_array(\Akzo\Scheme\State::TO_BE_REVIEWED, $transition->getInitialStates())) {
                     $notifications = self::_prepareNotifications($scheme, "reviewerRequestedUpdate", "Scheme Update Requested by Reviewer", "To be Updated", $templateData, array(self::REVIEWER => true));
                 } else {
                     if (strcmp($transitionName, \Akzo\Scheme\StateTransition::REQUEST_SCHEME_UPDATE) === 0 && in_array(\Akzo\Scheme\State::TO_BE_APPROVED, $transition->getInitialStates())) {
                         $notifications = self::_prepareNotifications($scheme, "approverRequestedUpdate", "Scheme Update Requested by Approver", "To be Updated", $templateData, array(self::APPROVER => true));
                     } else {
                         if (strcmp($transitionName, \Akzo\Scheme\StateTransition::REQUEST_SCHEME_REVIEW) === 0) {
                             $notifications = self::_prepareNotifications($scheme, "requestedReview", "Scheme Review Requested by Approver", "To be Reviewed", $templateData, array(self::REVIEWER => true, self::APPROVER => true));
                         } else {
                             if (strcmp($transitionName, \Akzo\Scheme\StateTransition::EDIT_APPROVED_SCHEME) === 0) {
                                 $notifications = self::_prepareNotifications($scheme, "editApproved", "Edition of Approved Scheme by Initiator", "To be Updated", $templateData, array(self::REVIEWER => true, self::APPROVER => true));
                             }
                         }
                     }
                 }
             }
         }
     }
     // Send the notifications
     foreach ($notifications as $idx => $notification) {
         file_put_contents(getcwd() . '/logs/email.' . $idx . '.log', print_r($notification, 1));
         $mailService = \Native5\Services\Messaging\NotificationService::instance();
         $mailStatus = $mailService->sendNotification(array(\Native5\Services\Messaging\Notifier::TYPE_EMAIL), $notification);
     }
 }
Beispiel #3
0
 /**
  * init 
  * 
  * @param string $configFile Configuration with which to initialize an app with
  *
  * @static
  * @access public
  * @return void
  */
 public static function init($configFile = 'config/settings.yml', $localConfigFile = 'config/settings.local.yml')
 {
     // Check what php SAPI is being used
     self::$_cli = false;
     if (strcmp(php_sapi_name(), 'cli') === 0) {
         self::$_cli = true;
     }
     // Initialize application services, Store application Object as a global
     // Services are available from global app.
     $GLOBALS['app'] = $app = new self();
     $GLOBALS['logger'] = LoggerFactory::instance()->getLogger();
     $GLOBALS['routeLogger'] = LoggerFactory::instance()->getLogger();
     $configFactory = new ConfigurationFactory($configFile, $localConfigFile);
     $app->_config = $configFactory->getConfig();
     $logFolder = getcwd() . '/logs';
     if (!file_exists($logFolder)) {
         if (!mkdir($logFolder)) {
             $logFolder = sys_get_temp_dir() . '/logs';
             if (!file_exists($logFolder) && !mkdir($logFolder)) {
                 die('Insufficient privileges to create logs folder in application directory, or temp path, exiting');
             }
         }
     }
     $file = $logFolder . DIRECTORY_SEPARATOR . $app->_config->getApplicationContext() . '-debug.log';
     $GLOBALS['logger']->addHandler($file, Logger::ALL, self::$LOG_MAPPING[$app->_config->getLogLevel()]);
     $analyticsFile = $logFolder . DIRECTORY_SEPARATOR . $app->_config->getApplicationContext() . '-analytics.log';
     $GLOBALS['routeLogger']->addHandler($analyticsFile, Logger::ALL, self::$LOG_MAPPING[$app->_config->getLogLevel()], 'analytics');
     if (!self::$_cli) {
         $sessionManager = new WebSessionManager();
         $sessionManager->startSession(null, true);
         $app->_services['sessions'] = $sessionManager;
         SecurityUtils::setSecurityManager(new DefaultSecurityManager());
         $app->_subject = $app->_getSubjectFromSession($sessionManager->getActiveSession());
         $app->_services['routing'] = new RoutingEngine();
     }
     $app->_services['messaging'] = NotificationService::instance();
     return $app;
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     \Native5\Application::init(__DIR__ . '/../../../../config/settings.yml');
     $this->object = NotificationService::instance();
     $this->_logger = $GLOBALS['logger'];
 }