Пример #1
0
 /**
  * Setup
  */
 protected function setUp()
 {
     // get service manager
     $this->serviceLocator = PageBootstrap::getServiceLocator();
     // get base model instance
     $this->model = $this->serviceLocator->get('Page\\Model\\PageNestedSet');
     $this->language = current(LocalizationService::getLocalizations())['language'];
 }
Пример #2
0
 /**
  * Get list of localizations
  *
  * @throws XmlRpc\Exception\XmlRpcActionDenied
  * @return array
  */
 public function getLocalizations()
 {
     // check user permission
     if (!AclService::checkPermission('xmlrpc_get_localizations')) {
         throw new XmlRpcActionDenied(self::REQUEST_DENIED);
     }
     // fire the get localizations via XmlRpc event
     LocalizationEvent::fireGetLocalizationsViaXmlRpcEvent();
     return LocalizationService::getLocalizations();
 }
 /**
  * Process action
  */
 public function processAction()
 {
     // get the payment's  type info
     if (null == ($payment = $this->getModel()->getPaymentTypeInfo($this->getSlug()))) {
         return $this->createHttpNotFoundModel($this->getResponse());
     }
     // get the payment type instance
     $paymentInstance = $this->getServiceLocator()->get('Payment\\Type\\PaymentTypeManager')->getInstance($payment['handler']);
     // validate the payment
     if (false !== ($transactionInfo = $paymentInstance->validatePayment())) {
         if (true === ($result = $this->getModel()->activateTransaction($transactionInfo, $payment['id'], true, true))) {
             // send an email notification about the paid transaction
             if ((int) $this->applicationSetting('payment_transaction_paid_users')) {
                 // get the user's info
                 $userInfo = !empty($transactionInfo['user_id']) ? UserIdentityService::getUserInfo($transactionInfo['user_id']) : [];
                 $notificationLanguage = !empty($userInfo['language']) ? $userInfo['language'] : LocalizationService::getDefaultLocalization()['language'];
                 EmailNotificationUtility::sendNotification($transactionInfo['email'], $this->applicationSetting('payment_transaction_paid_users_title', $notificationLanguage), $this->applicationSetting('payment_transaction_paid_users_message', $notificationLanguage), ['find' => ['Id', 'PaymentType'], 'replace' => [$transactionInfo['slug'], $this->getTranslator()->translate($payment['description'], 'default', LocalizationService::getLocalizations()[$notificationLanguage]['locale'])]]);
             }
         }
     } else {
         return $this->createHttpNotFoundModel($this->getResponse());
     }
     return $this->getResponse();
 }
Пример #4
0
 /**
  * Init view helpers
  *
  * @return array
  */
 public function getViewHelperConfig()
 {
     return ['factories' => ['localization' => function () {
         return new \Localization\View\Helper\Localization(LocalizationService::getCurrentLocalization(), LocalizationService::getLocalizations());
     }]];
 }
Пример #5
0
 /**
  * Clear widgets settings cache
  *
  * @param integer $pageId
  * @param string $language
  * @return boolean
  */
 public function clearWidgetsSettingsCache($pageId, $language = null)
 {
     // clear all caches
     if (!$language) {
         // get all localizations
         $localizations = LocalizationService::getLocalizations();
         foreach ($localizations as $localization) {
             $cacheName = CacheUtility::getCacheName(self::CACHE_WIDGETS_SETTINGS_BY_PAGE . $pageId . '_' . $localization['language']);
             // clear a page's widgets settings cache
             if ($this->staticCacheInstance->hasItem($cacheName)) {
                 if (false === ($result = $this->staticCacheInstance->removeItem($cacheName))) {
                     return $result;
                 }
             }
         }
     } else {
         $cacheName = CacheUtility::getCacheName(self::CACHE_WIDGETS_SETTINGS_BY_PAGE . $pageId . '_' . $language);
         if ($this->staticCacheInstance->hasItem($cacheName)) {
             if (false === ($result = $this->staticCacheInstance->removeItem($cacheName))) {
                 return $result;
             }
         }
     }
     return true;
 }
Пример #6
0
 /**
  * Fire edit role event
  *
  * @param array $user
  *      string language
  *      string email
  *      string nick_name
  *      integer user_id
  * @param string $roleName
  * @param boolean $isSystemEvent
  * @retun void
  */
 public static function fireEditRoleEvent($user, $roleName, $isSystemEvent = false)
 {
     // event's description
     $eventDesc = $isSystemEvent ? 'Event - User\'s role edited by the system' : (UserIdentityService::isGuest() ? 'Event - User\'s role edited by guest' : 'Event - User\'s role edited by user');
     $eventDescParams = $isSystemEvent ? [$user['user_id']] : (UserIdentityService::isGuest() ? [$user['user_id']] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $user['user_id']]);
     self::fireEvent(self::EDIT_ROLE, $user['user_id'], self::getUserId($isSystemEvent), $eventDesc, $eventDescParams);
     // send a notification
     if ((int) SettingService::getSetting('user_role_edited_send')) {
         $notificationLanguage = $user['language'] ? $user['language'] : LocalizationService::getDefaultLocalization()['language'];
         EmailNotificationUtility::sendNotification($user['email'], SettingService::getSetting('user_role_edited_title', $notificationLanguage), SettingService::getSetting('user_role_edited_message', $notificationLanguage), ['find' => ['RealName', 'Role'], 'replace' => [$user['nick_name'], ServiceLocatorService::getServiceLocator()->get('Translator')->translate($roleName, 'default', LocalizationService::getLocalizations()[$notificationLanguage]['locale'])]]);
     }
 }
 /**
  * Clean expired memberships connections
  */
 public function cleanExpiredMembershipsConnectionsAction()
 {
     $request = $this->getRequest();
     $deletedConnections = 0;
     $notifiedConnections = 0;
     // get a list of expired memberships connections
     if (null != ($expiredConnections = $this->getModel()->getExpiredMembershipsConnections(self::ITEMS_LIMIT))) {
         // process expired memberships connections
         foreach ($expiredConnections as $connectionInfo) {
             // delete the connection
             if (false === ($deleteResult = $this->getModel()->deleteMembershipConnection($connectionInfo['id']))) {
                 break;
             }
             // get a next membership connection
             $nextConnection = $this->getModel()->getMembershipConnectionFromQueue($connectionInfo['user_id']);
             $nextRoleId = $nextConnection ? $nextConnection['role_id'] : AclBaseModel::DEFAULT_ROLE_MEMBER;
             $nextRoleName = $nextConnection ? $nextConnection['role_name'] : AclBaseModel::DEFAULT_ROLE_MEMBER_NAME;
             // change the user's role
             if (true === ($result = $this->getUserModel()->editUserRole($connectionInfo['user_id'], $nextRoleId, $nextRoleName, $connectionInfo, true))) {
                 // activate the next membership connection
                 if ($nextConnection) {
                     $this->getModel()->activateMembershipConnection($nextConnection['id']);
                 }
             }
             $deletedConnections++;
         }
     }
     // get list of not notified memberships connections
     if ((int) $this->applicationSetting('membership_expiring_send')) {
         if (null != ($notNotifiedConnections = $this->getModel()->getNotNotifiedMembershipsConnections(self::ITEMS_LIMIT))) {
             // process not notified memberships connections
             foreach ($notNotifiedConnections as $connectionInfo) {
                 if (false === ($markResult = $this->getModel()->markConnectionAsNotified($connectionInfo['id']))) {
                     break;
                 }
                 // send a notification about membership expiring
                 $notificationLanguage = $connectionInfo['language'] ? $connectionInfo['language'] : LocalizationService::getDefaultLocalization()['language'];
                 $locale = LocalizationService::getLocalizations()[$notificationLanguage]['locale'];
                 ApplicationEmailNotification::sendNotification($connectionInfo['email'], $this->applicationSetting('membership_expiring_send_title', $notificationLanguage), $this->applicationSetting('membership_expiring_send_message', $notificationLanguage), ['find' => ['RealName', 'Role', 'ExpireDate'], 'replace' => [$connectionInfo['nick_name'], ApplicationServiceLocatorService::getServiceLocator()->get('Translator')->translate($connectionInfo['role_name'], 'default', $locale), ApplicationServiceLocatorService::getServiceLocator()->get('viewhelpermanager')->get('applicationDate')->__invoke($connectionInfo['expire_date'], [], $locale)]]);
                 $notifiedConnections++;
             }
         }
     }
     // delete not active empty connections
     $this->getModel()->deleteNotActiveEmptyConnections();
     $verbose = $request->getParam('verbose');
     if (!$verbose) {
         return 'All expired  membership connections have been deleted.' . "\n";
     }
     $result = $deletedConnections . ' membership connections  have been deleted.' . "\n";
     $result .= $notifiedConnections . ' membership connections  have been notified.' . "\n";
     return $result;
 }