/**
  * Fire deactivate action event
  *
  * @param $actionId
  * @return void
  */
 public static function fireDeactivateActionEvent($actionId)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - Action deactivated by guest' : 'Event - Action deactivated by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$actionId] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $actionId];
     self::fireEvent(self::DEACTIVATE_ACTION, $actionId, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
Exemplo n.º 2
0
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (!UserIdentityService::isGuest()) {
         return $this->getView()->partial('user/widget/dashboard', ['user' => UserIdentityService::getCurrentUserIdentity()]);
     }
     return false;
 }
Exemplo n.º 3
0
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (UserIdentityService::isGuest()) {
         // get a login form
         $loginForm = $this->getServiceLocator()->get('Application\\Form\\FormManager')->getInstance('User\\Form\\UserLogin');
         if ($this->getRequest()->isPost() && $this->getRequest()->getPost('form_name') == $loginForm->getFormName()) {
             // fill form with received values
             $loginForm->getForm()->setData($this->getRequest()->getPost());
             if ($loginForm->getForm()->isValid()) {
                 $userName = $this->getRequest()->getPost('nickname');
                 $password = $this->getRequest()->getPost('password');
                 // check an authentication
                 $authErrors = [];
                 $result = UserAuthenticateUtility::isAuthenticateDataValid($userName, $password, $authErrors);
                 if (false === $result) {
                     $this->getFlashMessenger()->setNamespace('error');
                     // add auth error messages
                     foreach ($authErrors as $message) {
                         $this->getFlashMessenger()->addMessage($this->translate($message));
                     }
                     return $this->reloadPage();
                 }
                 $rememberMe = null != ($remember = $this->getRequest()->getPost('remember')) ? true : false;
                 return $this->loginUser($result['user_id'], $result['nick_name'], $rememberMe);
             }
         }
         return $this->getView()->partial('user/widget/login', ['login_form' => $loginForm->getForm()]);
     }
     return false;
 }
Exemplo n.º 4
0
 /**
  * Fire uninstall localization event
  *
  * @param string $language
  * @return void
  */
 public static function fireUninstallLocalizationEvent($language)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - Localization uninstalled by guest' : 'Event - Localization uninstalled by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$language] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $language];
     self::fireEvent(self::UNINSTALL, $language, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (!UserIdentityService::isGuest() && ($adminMenu = $this->getView()->applicationAdminMenu())) {
         return $this->getView()->partial('user/widget/administration', ['menu' => $adminMenu]);
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (!UserIdentityService::isGuest()) {
         // get the user delete form
         $deleteForm = $this->getServiceLocator()->get('Application\\Form\\FormManager')->getInstance('User\\Form\\UserDelete');
         $request = $this->getRequest();
         // validate the form
         if ($request->isPost() && $this->getRequest()->getPost('form_name') == $deleteForm->getFormName()) {
             // fill the form with received values
             $deleteForm->getForm()->setData($request->getPost(), false);
             // delete the user's account
             if ($deleteForm->getForm()->isValid()) {
                 if (true !== ($deleteResult = $this->getModel()->deleteUser(UserIdentityService::getCurrentUserIdentity(), false))) {
                     $this->getFlashMessenger()->setNamespace('error')->addMessage($this->translate('Error occurred'));
                     return $this->reloadPage();
                 }
                 // clear user's identity
                 $this->logoutUser(UserIdentityService::getCurrentUserIdentity());
                 return $this->redirectTo();
             }
         }
         return $this->getView()->partial('user/widget/delete', ['delete_form' => $deleteForm->getForm()]);
     }
     return false;
 }
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (UserIdentityService::isGuest()) {
         return false;
     }
     $userId = UserIdentityService::getCurrentUserIdentity()['user_id'];
     // process post actions
     if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf'))) {
         $action = $this->getRequest()->getPost('action');
         if ($action) {
             switch ($action) {
                 case 'delete_membership':
                     $this->deleteMembership($this->getRequest()->getPost('id', -1));
                     break;
                 default:
             }
         }
     }
     // get a pagination page number
     $pageParamName = 'page_' . $this->widgetConnectionId;
     $page = $this->getView()->applicationRoute()->getQueryParam($pageParamName, 1);
     $wrapperId = 'purchased-memberships-wrapper';
     $count = (int) $this->getWidgetSetting('membership_user_list_items_count');
     // get data list
     $dataList = $this->getView()->partial('partial/data-list', ['filter_form' => false, 'ajax' => ['wrapper_id' => $wrapperId, 'widget_connection' => $this->widgetConnectionId, 'widget_position' => $this->widgetPosition], 'paginator' => $this->getModel()->getUserMembershipConnections($userId, $page, $count), 'paginator_order_list_show' => false, 'paginator_order_list' => [], 'paginator_per_page_show' => false, 'paginator_page_query' => $pageParamName, 'unit' => 'membership/partial/_membership-user-unit', 'unit_params' => ['items_width_medium' => $this->getWidgetSetting('membership_user_list_item_width_medium'), 'items_width_small' => $this->getWidgetSetting('membership_user_list_item_width_small'), 'items_width_extra_small' => $this->getWidgetSetting('membership_user_list_item_width_extra_small')], 'uniform_height' => '#' . $wrapperId . ' .membership-info', 'per_page' => $count]);
     if ($this->getRequest()->isXmlHttpRequest()) {
         return $dataList;
     }
     return $this->getView()->partial('membership/widget/membership-user', ['csrf_token' => ApplicationCsrfUtility::getToken(), 'widget_url' => $this->getWidgetConnectionUrl(), 'membership_wrapper' => $wrapperId, 'data' => $dataList]);
 }
Exemplo n.º 8
0
 /**
  * Is allowed to view page
  *
  * @param array $privacyOptions
  * @param boolean $trustedData
  * @return boolean
  */
 public function isAllowedViewPage(array $privacyOptions = [], $trustedData = false)
 {
     $userId = !empty($privacyOptions['user_id']) || $this->objectId ? !empty($privacyOptions['user_id']) ? $privacyOptions['user_id'] : $this->objectId : RouteParamUtility::getParam('slug', -1);
     $userField = !empty($privacyOptions['user_id']) ? UserWidgetModel::USER_INFO_BY_ID : UserWidgetModel::USER_INFO_BY_SLUG;
     if (!UserIdentityService::isGuest() || null == ($userInfo = $this->getModel()->getUserInfo($userId, $userField))) {
         return false;
     }
     // check the user's status
     if ($userInfo['status'] != UserWidgetModel::STATUS_DISAPPROVED) {
         return false;
     }
     return true;
 }
Exemplo n.º 9
0
 /**
  * Get user info
  *
  * @param integer $userId
  * @return array
  */
 public function getUserInfo($userId)
 {
     // check user permissions
     if (!AclService::checkPermission('xmlrpc_view_user_info')) {
         throw new XmlRpcActionDenied(self::REQUEST_DENIED);
     }
     $viewerNickName = !UserIdentityService::isGuest() ? $this->userIdentity['nick_name'] : null;
     // get user info
     if (false !== ($userInfo = $this->getModel()->getXmlRpcUserInfo($userId, $this->userIdentity['user_id'], $viewerNickName))) {
         return $userInfo;
     }
     return [];
 }
Exemplo n.º 10
0
 /**
  * Is allowed to view page
  *
  * @param array $privacyOptions
  * @param boolean $trustedData
  * @return boolean
  */
 public function isAllowedViewPage(array $privacyOptions = [], $trustedData = false)
 {
     if (!UserIdentityService::isGuest()) {
         return false;
     }
     if (!$trustedData) {
         $userId = $this->objectId ? $this->objectId : RouteParamUtility::getParam('slug', -1);
         $userInfo = $this->getModel()->getUserInfo($userId, UserWidgetModel::USER_INFO_BY_SLUG);
         if (null == $userInfo) {
             return false;
         }
     }
     return true;
 }
 /**
  * Index page
  */
 public function indexAction()
 {
     if (!UserIdentityService::isGuest()) {
         return $this->createHttpNotFoundModel($this->getResponse());
     }
     $this->layout($this->layout);
     $loginForm = $this->getServiceLocator()->get('Application\\Form\\FormManager')->getInstance('User\\Form\\UserLogin');
     if ($this->getRequest()->isPost()) {
         // fill form with received values
         $loginForm->getForm()->setData($this->getRequest()->getPost());
         if ($loginForm->getForm()->isValid()) {
             $userName = $this->getRequest()->getPost('nickname');
             $password = $this->getRequest()->getPost('password');
             // check an authentication
             $authErrors = [];
             $result = UserAuthenticateUtility::isAuthenticateDataValid($userName, $password, $authErrors);
             if (false === $result) {
                 $this->flashMessenger()->setNamespace('error');
                 // add auth error messages
                 foreach ($authErrors as $message) {
                     $this->flashMessenger()->addMessage($this->getTranslator()->translate($message));
                 }
                 return $this->reloadPage();
             }
             $rememberMe = null != ($remember = $this->getRequest()->getPost('remember')) ? true : false;
             // login a user
             UserAuthenticateUtility::loginUser($result['user_id'], $result['nick_name'], $rememberMe);
             // make a redirect
             if (null !== ($backUrl = $this->getRequest()->getQuery('back_url', null))) {
                 return $this->redirect()->toUrl($backUrl);
             }
             // search a first allowed admin page
             $adminMenu = $this->getAdminMenuModel()->getMenu();
             foreach ($adminMenu as $menuItems) {
                 foreach ($menuItems['items'] as $item) {
                     if (AclService::checkPermission($item['controller'] . ' ' . $item['action'], false)) {
                         return $this->redirectTo($item['controller'], $item['action']);
                     }
                 }
             }
             // redirect to the public home page
             $this->flashMessenger()->setNamespace('error');
             $this->flashMessenger()->addMessage($this->getTranslator()->translate('There are no admin pages allowed for you!'));
             return $this->redirectTo('page', 'index', [], false, [], 'page');
         }
     }
     return new ViewModel(['login_form' => $loginForm->getForm()]);
 }
 /**
  * Set event manager
  *
  * @param \Zend\EventManager\EventManagerInterface $events
  * @return void
  */
 public function setEventManager(EventManagerInterface $events)
 {
     parent::setEventManager($events);
     $controller = $this;
     // execute before executing action logic
     $events->attach('dispatch', function ($e) use($controller) {
         // check permission
         if (!AclService::checkPermission($controller->params('controller') . ' ' . $controller->params('action'), false)) {
             return UserIdentityService::isGuest() ? $this->redirectTo('login-administration', 'index', [], false, ['back_url' => $this->getRequest()->getRequestUri()]) : $controller->showErrorPage();
         }
         // set an admin layout
         if (!$e->getRequest()->isXmlHttpRequest()) {
             $controller->layout($this->layout);
         }
     }, 100);
 }
Exemplo n.º 13
0
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     // check a permission
     if (AclService::checkPermission('users_view_profile')) {
         // get the current user's info
         if (null != ($userInfo = $this->getModel()->getUserInfo($this->getSlug(), UserWidgetModel::USER_INFO_BY_SLUG))) {
             $viewerNickName = !UserIdentityService::isGuest() ? UserIdentityService::getCurrentUserIdentity()['nick_name'] : null;
             // fire the get user's info event
             UserEvent::fireGetUserInfoEvent($userInfo['user_id'], $userInfo['nick_name'], UserIdentityService::getCurrentUserIdentity()['user_id'], $viewerNickName);
             // breadcrumb
             $this->getView()->pageBreadcrumb()->setCurrentPageTitle($userInfo['nick_name']);
             $this->getView()->headMeta()->setName('description', $userInfo['nick_name']);
             return $this->getView()->partial('user/widget/info', ['user' => $userInfo]);
         }
     }
     return false;
 }
Exemplo n.º 14
0
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (UserIdentityService::isGuest() && (int) $this->getSetting('user_allow_register')) {
         // get an user form
         $userForm = $this->getServiceLocator()->get('Application\\Form\\FormManager')->getInstance('User\\Form\\User')->setModel($this->getModel())->setTimeZones(TimeZoneService::getTimeZones())->showCaptcha(true);
         // validate the form
         if ($this->getRequest()->isPost() && $this->getRequest()->getPost('form_name') == $userForm->getFormName()) {
             // make certain to merge the files info!
             $post = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray());
             // fill the form with received values
             $userForm->getForm()->setData($post, false);
             // save data
             if ($userForm->getForm()->isValid()) {
                 // add a new user with a particular status
                 $status = (int) $this->getSetting('user_auto_confirm') ? true : false;
                 $userInfo = $this->getModel()->addUser($userForm->getForm()->getData(), LocalizationService::getCurrentLocalization()['language'], $status, $this->getRequest()->getFiles()->avatar, true);
                 // the user has been added
                 if (is_array($userInfo)) {
                     // check the user status
                     if (!$status) {
                         // get user activate url
                         if (false !== ($activateUrl = $this->getView()->pageUrl('user-activate', ['user_id' => $userInfo['user_id']]))) {
                             // send an email activate notification
                             EmailNotificationUtility::sendNotification($userInfo['email'], $this->getSetting('user_email_confirmation_title'), $this->getSetting('user_email_confirmation_message'), ['find' => ['RealName', 'SiteName', 'ConfirmationLink', 'ConfCode'], 'replace' => [$userInfo['nick_name'], $this->getSetting('application_site_name'), $this->getView()->url('page', ['page_name' => $activateUrl, 'slug' => $userInfo['slug']], ['force_canonical' => true]), $userInfo['activation_code']]], true);
                             $this->getFlashMessenger()->setNamespace('success')->addMessage($this->translate('We sent a message with a confirmation code to your registration e-mail'));
                         } else {
                             $this->getFlashMessenger()->setNamespace('success')->addMessage($this->translate('Your profile will be activated after checking'));
                         }
                         $this->reloadPage();
                     } else {
                         // login and redirect the registered user
                         return $this->loginUser($userInfo['user_id'], $userInfo['nick_name'], false);
                     }
                 } else {
                     $this->getFlashMessenger()->setNamespace('error')->addMessage($this->translate('Error occurred'));
                 }
                 return $this->reloadPage();
             }
         }
         return $this->getView()->partial('user/widget/register', ['user_form' => $userForm->getForm()]);
     }
     return false;
 }
Exemplo n.º 15
0
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     // get a contact form
     $contactForm = $this->getServiceLocator()->get('Application\\Form\\FormManager')->getInstance('Page\\Form\\PageContact')->showCaptcha((int) $this->getWidgetSetting('page_contact_form_captcha') && UserIdentityService::isGuest());
     if ($this->getRequest()->isPost() && $this->getRequest()->getPost('form_name') == $contactForm->getFormName()) {
         // fill form with received values
         $contactForm->getForm()->setData($this->getRequest()->getPost());
         if ($contactForm->getForm()->isValid()) {
             $formData = $contactForm->getForm()->getData();
             $sendResult = EmailNotificationUtility::sendNotification($this->getWidgetSetting('page_contact_form_email'), $this->getWidgetSetting('page_contact_form_title'), $this->getWidgetSetting('page_contact_form_message'), ['find' => ['RealName', 'Email', 'Phone', 'Message'], 'replace' => [$formData['name'], $formData['email'], $formData['phone'], $formData['message']]], true);
             // send the message
             if (true === $sendResult) {
                 $this->getFlashMessenger()->setNamespace('success')->addMessage($this->translate('Your message has been sent'));
             } else {
                 $this->getFlashMessenger()->setNamespace('error')->addMessage($this->translate('Message cannot be sent. Please try again later'));
             }
             $this->reloadPage();
         }
     }
     return $this->getView()->partial('page/widget/contact', ['contact_form' => $contactForm->getForm()]);
 }
Exemplo n.º 16
0
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (!UserIdentityService::isGuest()) {
         // get an user form
         $userForm = $this->getServiceLocator()->get('Application\\Form\\FormManager')->getInstance('User\\Form\\User')->setModel($this->getModel())->setTimeZones(TimeZoneService::getTimeZones())->setUserId(UserIdentityService::getCurrentUserIdentity()['user_id'])->setUserAvatar(UserIdentityService::getCurrentUserIdentity()['avatar']);
         // fill the form with default values
         $userForm->getForm()->setData(UserIdentityService::getCurrentUserIdentity());
         // validate the form
         if ($this->getRequest()->isPost() && $this->getRequest()->getPost('form_name') == $userForm->getFormName()) {
             // make certain to merge the files info!
             $post = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray());
             // fill the form with received values
             $userForm->getForm()->setData($post, false);
             // save data
             if ($userForm->getForm()->isValid()) {
                 // set status
                 $status = (int) $this->getSetting('user_auto_confirm') || UserIdentityService::getCurrentUserIdentity()['role'] == AclBaseModel::DEFAULT_ROLE_ADMIN ? true : false;
                 $deleteAvatar = (int) $this->getRequest()->getPost('avatar_delete') ? true : false;
                 // edit current user's info
                 $result = $this->getModel()->editUser(UserIdentityService::getCurrentUserIdentity(), $userForm->getForm()->getData(), $status, $this->getRequest()->getFiles()->avatar, $deleteAvatar, true);
                 if (true === $result) {
                     if ($status) {
                         $this->getFlashMessenger()->setNamespace('success')->addMessage($this->translate('Your account has been edited'));
                     } else {
                         $this->getFlashMessenger()->setNamespace('success')->addMessage($this->translate('Your account will be active after checking'));
                         // redirect to login page
                         $loginUrl = $this->getView()->pageUrl('login');
                         return $this->redirectTo(['page_name' => false !== $loginUrl ? $loginUrl : '']);
                     }
                 } else {
                     $this->getFlashMessenger()->setNamespace('error')->addMessage($this->translate('Error occurred'));
                 }
                 return $this->reloadPage();
             }
         }
         return $this->getView()->partial('user/widget/edit', ['user_form' => $userForm->getForm()]);
     }
     return false;
 }
Exemplo n.º 17
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'])]]);
     }
 }
Exemplo n.º 18
0
 /**
  * Fire delete file event
  *
  * @param string $path
  * @return void
  */
 public static function fireDeleteFileEvent($path)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - File deleted by guest' : 'Event - File deleted by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$path] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $path];
     self::fireEvent(self::DELETE_FILE, $path, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
 /**
  * Fire add membership role event
  *
  * @param integer $membershipRoleId
  * @return void
  */
 public static function fireAddMembershipRoleEvent($membershipRoleId)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - Membership role added by guest' : 'Event - Membership role added by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$membershipRoleId] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $membershipRoleId];
     self::fireEvent(self::ADD_MEMBERSHIP_ROLE, $membershipRoleId, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
Exemplo n.º 20
0
 /**
  * Fire delete question event
  *
  * @param integer $questionId
  * @return void
  */
 public static function fireDeleteQuestionEvent($questionId)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - Poll question deleted by guest' : 'Event - Poll question deleted by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$questionId] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $questionId];
     self::fireEvent(self::DELETE_QUESTION, $questionId, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
Exemplo n.º 21
0
 /**
  * Fire delete custom layout event
  *
  * @param string $layoutName
  * @return void
  */
 public static function fireDeleteCustomLayoutEvent($layoutName)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - Custom layout deleted by guest' : 'Event - Custom layout deleted by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$layoutName] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $layoutName];
     self::fireEvent(self::DELETE, $layoutName, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
Exemplo n.º 22
0
 /**
  * Fire delete page event
  *
  * @param integer $pageId
  * @return void
  */
 public static function fireDeletePageEvent($pageId)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - Page deleted by guest' : 'Event - Page deleteted by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$pageId] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $pageId];
     self::fireEvent(self::PAGE_DELETE, $pageId, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
Exemplo n.º 23
0
 /**
  * Is allowed to view page
  *
  * @param array $privacyOptions
  * @param boolean $trustedData
  * @return boolean
  */
 public function isAllowedViewPage(array $privacyOptions = [], $trustedData = false)
 {
     return UserIdentityService::isGuest();
 }
 /**
  * Fire delete category event
  *
  * @param integer $categoryId
  * @return void
  */
 public static function fireDeleteCategoryEvent($categoryId)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - Slideshow category deleted by guest' : 'Event - Slideshow category deleted by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$categoryId] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $categoryId];
     self::fireEvent(self::DELETE_CATEGORY, $categoryId, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
 /**
  * Is it a guest or not?.
  *
  * @return boolean
  */
 public function isGuest()
 {
     return UserIdentityService::isGuest();
 }
 /**
  * Process comments
  *
  * @param array $comments
  * @param boolean $asArray
  * @return string|array
  */
 protected function processComments(array $comments, $asArray = false)
 {
     $processedComments = null;
     if (count($comments)) {
         $userId = !UserIdentityService::isGuest() ? UserIdentityService::getCurrentUserIdentity()['user_id'] : $this->getModel()->getCommentModel()->getGuestId();
         $maxRepliesNestedLevel = (int) $this->getWidgetSetting('comment_max_nested_level');
         $showUsersThumbs = (int) $this->getWidgetSetting('comment_show_thumbs');
         // process comments
         foreach ($comments as $comment) {
             $content = $this->getView()->partial('comment/widget/_comment-item-start', ['id' => $comment['id'], 'parent_id' => $comment['parent_id'], 'comment' => $comment['comment'], 'approved' => $comment['active'] == CommentNestedSet::COMMENT_STATUS_ACTIVE, 'own_comment' => $userId == $comment['user_id'] || $userId == $comment['guest_id'], 'visible_chars' => (int) $this->getWidgetSetting('comment_visible_chars'), 'registered_nickname' => $comment['registered_nickname'], 'guest_id' => $comment['guest_id'], 'name' => $comment['name'], 'user_id' => $comment['user_id'], 'user_slug' => $comment['registered_slug'], 'user_avatar' => $comment['registered_avatar'], 'created' => $comment['created'], 'show_reply' => $comment['level'] <= $maxRepliesNestedLevel, 'show_thumbs' => $showUsersThumbs]);
             // check for children
             if (!$asArray && !empty($comment['children'])) {
                 $content .= $this->processComments($comment['children']);
             }
             $content .= $this->getView()->partial('comment/widget/_comment-item-end');
             // collect processed comments
             !$asArray ? $processedComments .= $content : ($processedComments[] = ['id' => $comment['id'], 'parent_id' => $comment['parent_id'], 'comment' => $content]);
         }
     }
     return $processedComments;
 }
Exemplo n.º 27
0
 /**
  * Fire delete custom module event
  *
  * @param string $module
  * @return void
  */
 public static function fireDeleteCustomModuleEvent($module)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - Custom module deleted by guest' : 'Event - Custom module deleted by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$module] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $module];
     self::fireEvent(self::DELETE_CUSTOM_MODULE, $module, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
Exemplo n.º 28
0
 /**
  * Fire delete acl role event
  *
  * @param integer $roleId
  * @return void
  */
 public static function fireDeleteAclRoleEvent($roleId)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - ACL role deleted by guest' : 'Event - ACL role deleteted by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$roleId] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $roleId];
     self::fireEvent(self::DELETE_ROLE, $roleId, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
Exemplo n.º 29
0
 /**
  * Fire edit payment currency event
  *
  * @param integer $currencyId
  * @return void
  */
 public static function fireEditPaymentCurrencyEvent($currencyId)
 {
     // event's description
     $eventDesc = UserIdentityService::isGuest() ? 'Event - Payment currency edited by guest' : 'Event - Payment currency edited by user';
     $eventDescParams = UserIdentityService::isGuest() ? [$currencyId] : [UserIdentityService::getCurrentUserIdentity()['nick_name'], $currencyId];
     self::fireEvent(self::EDIT_PAYMENT_CURRENCY, $currencyId, UserIdentityService::getCurrentUserIdentity()['user_id'], $eventDesc, $eventDescParams);
 }
Exemplo n.º 30
0
 /**
  * Init view helpers
  */
 public function getViewHelperConfig()
 {
     return ['invokables' => ['userLoginWidget' => 'User\\View\\Widget\\UserLoginWidget', 'userRegisterWidget' => 'User\\View\\Widget\\UserRegisterWidget', 'userActivateWidget' => 'User\\View\\Widget\\UserActivateWidget', 'userForgotWidget' => 'User\\View\\Widget\\UserForgotWidget', 'userPasswordResetWidget' => 'User\\View\\Widget\\UserPasswordResetWidget', 'userDeleteWidget' => 'User\\View\\Widget\\UserDeleteWidget', 'userInfoWidget' => 'User\\View\\Widget\\UserInfoWidget', 'userAvatarWidget' => 'User\\View\\Widget\\UserAvatarWidget', 'userDashboardWidget' => 'User\\View\\Widget\\UserDashboardWidget', 'userDashboardUserInfoWidget' => 'User\\View\\Widget\\UserDashboardUserInfoWidget', 'userEditWidget' => 'User\\View\\Widget\\UserEditWidget', 'userDashboardAdministrationWidget' => 'User\\View\\Widget\\UserDashboardAdministrationWidget'], 'factories' => ['userAvatarUrl' => function () {
         $thumbDir = ApplicationService::getResourcesUrl() . UserBaseModel::getThumbnailsDir();
         $avatarDir = ApplicationService::getResourcesUrl() . UserBaseModel::getAvatarsDir();
         return new \User\View\Helper\UserAvatarUrl($thumbDir, $avatarDir);
     }, 'userMenu' => function () {
         $userMenu = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('User\\Model\\UserMenu');
         return new \User\View\Helper\UserMenu($userMenu->getMenu());
     }, 'userIdentity' => function () {
         return new \User\View\Helper\UserIdentity(UserIdentityService::getCurrentUserIdentity());
     }, 'userIsGuest' => function () {
         return new \User\View\Helper\UserIsGuest(UserIdentityService::isGuest());
     }]];
 }