Exemplo n.º 1
0
 /**
  * Init layout
  */
 protected function initlayout()
 {
     try {
         // get a custom template path resolver
         $templatePathResolver = $this->serviceLocator->get('Layout\\View\\Resolver\\TemplatePathStack');
         // replace the default template path stack resolver with one
         $aggregateResolver = $this->serviceLocator->get('Zend\\View\\Resolver\\AggregateResolver');
         $aggregateResolver->attach($templatePathResolver)->getIterator()->remove($this->serviceLocator->get('Zend\\View\\Resolver\\TemplatePathStack'));
         $layout = $this->serviceLocator->get('Application\\Model\\ModelManager')->getInstance('Layout\\Model\\LayoutBase');
         $request = $this->serviceLocator->get('Request');
         // get a layout from cookies
         $allowSelectLayouts = (int) SettingService::getSetting('layout_select');
         $cookieLayout = isset($request->getCookie()->{self::LAYOUT_COOKIE}) && $allowSelectLayouts ? (int) $request->getCookie()->{self::LAYOUT_COOKIE} : null;
         // init a user selected layout
         if ($cookieLayout) {
             $activeLayouts = $layout->getLayoutsById($cookieLayout);
         } else {
             $activeLayouts = !empty(UserIdentityService::getCurrentUserIdentity()['layout']) && $allowSelectLayouts ? $layout->getLayoutsById(UserIdentityService::getCurrentUserIdentity()['layout']) : $layout->getDefaultActiveLayouts();
         }
         // add layouts paths for each module
         foreach ($this->moduleManager->getModules() as $module) {
             foreach ($activeLayouts as $layoutInfo) {
                 $templatePathResolver->addPath('module/' . $module . '/view/' . $layoutInfo['name']);
             }
         }
         LayoutService::setCurrentLayouts($activeLayouts);
     } catch (Exception $e) {
         ApplicationErrorLogger::log($e);
     }
 }
Exemplo n.º 2
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.º 3
0
 /**
  * Index page
  */
 public function indexAction()
 {
     // get user info by api key
     if (null != ($apiKey = $this->getRequest()->getQuery()->api_key)) {
         if (null != ($userInfo = UserIdentityService::getUserInfo($apiKey, UserModelBase::USER_INFO_BY_API_KEY))) {
             // fill the user's info
             if ($userInfo['status'] == UserModelBase::STATUS_APPROVED) {
                 $userIdentity = [];
                 foreach ($userInfo as $fieldName => $value) {
                     $userIdentity[$fieldName] = $value;
                 }
                 // init user identity
                 UserIdentityService::setCurrentUserIdentity($userIdentity);
             }
         }
     }
     XmlRpcServerFault::attachFaultException('XmlRpc\\Exception\\XmlRpcActionDenied');
     $server = new XmlRpcServer();
     // get xmlrpc classes
     if (null != ($classes = $this->getModel()->getClasses())) {
         $server->sendArgumentsToAllMethods(false);
         foreach ($classes as $class) {
             $server->setClass($class['path'], $class['namespace'], $this->getServiceLocator());
         }
     }
     $server->handle();
     // disable layout and view script
     return $this->response;
 }
 /**
  * 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.º 5
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);
 }
 /**
  * Is allowed to view the site
  *
  * @return boolean
  */
 public static function isAllowedViewSite()
 {
     if ((int) SettingService::getSetting('application_disable_site')) {
         $user = UserIdentityService::getCurrentUserIdentity();
         if ($user['role'] != AclBaseModel::DEFAULT_ROLE_ADMIN) {
             // get a visitor IP
             $remote = new RemoteAddress();
             $remote->setUseProxy(true);
             $userIp = $remote->getIpAddress();
             // get list of allowed ACL roles
             if (null != ($allowedAclRoles = SettingService::getSetting('application_disable_site_acl'))) {
                 if (!is_array($allowedAclRoles)) {
                     $allowedAclRoles = [$allowedAclRoles];
                 }
             }
             // get list of allowed IPs
             if (null != ($allowedIps = SettingService::getSetting('application_disable_site_ip'))) {
                 $allowedIps = explode(',', $allowedIps);
             }
             if ($allowedAclRoles || $allowedIps) {
                 if ($allowedAclRoles && in_array($user['role'], $allowedAclRoles) || $allowedIps && in_array($userIp, $allowedIps)) {
                     return true;
                 }
             }
             return false;
         }
     }
     return true;
 }
Exemplo n.º 7
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.º 8
0
 /**
  * Page 404
  * 
  * @return string|boolean
  */
 public function __invoke()
 {
     $language = LocalizationService::getCurrentLocalization()['language'];
     $page404 = false;
     // get a custom 404 page's url
     if (true === DisableSiteUtility::isAllowedViewSite() && false !== ($page404 = $this->getView()->pageUrl(self::CUSTOM_404_PAGE, [], $language, true))) {
         $userRole = UserIdentityService::getCurrentUserIdentity()['role'];
         if (false == ($pageInfo = $this->getModel()->getActivePageInfo(self::CUSTOM_404_PAGE, $userRole, $language))) {
             return false;
         }
         // fire the page show event
         PageEvent::firePageShowEvent($pageInfo['slug'], $language);
         // check for redirect
         if ($pageInfo['redirect_url']) {
             $response = ServiceLocatorService::getServiceLocator()->get('Response');
             $response->getHeaders()->addHeaderLine('Location', $pageInfo['redirect_url']);
             $response->setStatusCode(Response::STATUS_CODE_301);
             $response->sendHeaders();
             return false;
         }
         // get the page's breadcrumb
         $breadcrumb = $this->getModel()->getActivePageParents($pageInfo['left_key'], $pageInfo['right_key'], $userRole, $language);
         return $this->getView()->partial($this->getModel()->getLayoutPath() . $pageInfo['layout'], ['page' => $pageInfo, 'breadcrumb' => $breadcrumb]);
     }
     return $page404;
 }
 /**
  * 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.º 10
0
 /**
  * Get page url
  *
  * @param string $slug
  * @param string $language
  * @param array $privacyOptions     
  * @param boolean $trustedPrivacyData
  * @param string $objectId
  * @return string|boolean
  */
 protected function getPageUrl($slug, $language, array $privacyOptions = [], $trustedPrivacyData = false, $objectId = null)
 {
     if (!isset($this->pagesMap[$language]) || !array_key_exists($slug, $this->pagesMap[$language])) {
         return false;
     }
     // get a page info
     $page = $this->pagesMap[$language][$slug];
     // check the page's status
     if ($page['active'] != PageNestedSet::PAGE_STATUS_ACTIVE || $page['module_status'] != ApplicationAbstractBaseModel::MODULE_STATUS_ACTIVE) {
         return false;
     }
     // check the page's privacy
     if (false == ($result = PagePrivacyUtility::checkPagePrivacy($page['privacy'], $privacyOptions, $trustedPrivacyData, $objectId))) {
         return false;
     }
     // check the page's visibility
     if (!empty($page['hidden']) && in_array(UserIdentityService::getCurrentUserIdentity()['role'], $page['hidden'])) {
         return false;
     }
     // check for a parent and
     if (!empty($page['parent'])) {
         if (false === ($parentUrl = $this->getPageUrl($page['parent'], $language, [], false))) {
             return false;
         }
         // build a link (skip the home page)
         if ($this->pagesMap[$language][$page['parent']]['level'] > 1) {
             $slug = $parentUrl . '/' . $slug;
         }
     }
     return $slug;
 }
 /**
  * Is allowed view page
  * 
  * @param array $privacyOptions
  * @param boolean $trustedData
  * @return boolean
  */
 public function isAllowedViewPage(array $privacyOptions = [], $trustedData = false)
 {
     // check a permission
     if (UserIdentityService::isDefaultUser() || !AclService::checkPermission('memberships_view_buy_page', false)) {
         return false;
     }
     return true;
 }
Exemplo n.º 12
0
 /**
  * Logout user
  *
  * @param array $userIdentity
  * @return void
  */
 protected function logoutUser(array $userIdentity)
 {
     // clear logged user's identity
     UserIdentityService::getAuthService()->clearIdentity();
     // skip a remember me time
     $this->getServiceLocator()->get('Zend\\Session\\SessionManager')->rememberMe(0);
     // fire the user logout event
     UserEvent::fireLogoutEvent($userIdentity['user_id'], $userIdentity['nick_name']);
 }
 /**
  * View transaction's items
  */
 public function ajaxViewTransactionItemsAction()
 {
     $transactionId = $this->params()->fromQuery('id', -1);
     $userId = UserIdentityService::getCurrentUserIdentity()['user_id'];
     // get transaction's items
     if (null == ($items = $this->getModel()->getAllTransactionItems($transactionId, $userId, true))) {
         return $this->createHttpNotFoundModel($this->getResponse());
     }
     return new ViewModel(['transaction' => $this->getModel()->getTransactionInfo($transactionId, false, 'id', false), 'items' => $items]);
 }
Exemplo n.º 14
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.º 15
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.º 16
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;
 }
Exemplo n.º 17
0
 /**
  * Login user
  *
  * @param integer $userId
  * @param string $nickName
  * @param boolean $rememberMe
  * @return void
  */
 public static function loginUser($userId, $nickName, $rememberMe)
 {
     $user = [];
     $user['user_id'] = $userId;
     // save user id
     UserIdentityService::getAuthService()->getStorage()->write($user);
     UserIdentityService::setCurrentUserIdentity(UserIdentityService::getUserInfo($userId));
     AclService::clearCurrentAcl();
     // fire the user login event
     UserEvent::fireLoginEvent($userId, $nickName);
     if ($rememberMe) {
         ServiceLocatorService::getServiceLocator()->get('Zend\\Session\\SessionManager')->rememberMe((int) SettingService::getSetting('user_session_time'));
     }
 }
 /**
  * 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);
 }
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (AclService::checkPermission('comment_view', false)) {
         // get the current user's info
         if (null != ($userInfo = UserIdentityService::getUserInfo($this->getSlug(), BaseModel::USER_INFO_BY_SLUG))) {
             // get last comments
             $comments = $this->getModel()->getLastComments($this->getCurrentLanguage(), (int) $this->getWidgetSetting('comment_count'), $userInfo['user_id']);
             if (count($comments)) {
                 // increase ACL track
                 AclService::checkPermission('comment_view');
                 return $this->getView()->partial('comment/widget/user-last-comments-list', ['visible_chars' => $this->getWidgetSetting('comment_visible_chars'), 'comments' => $comments]);
             }
         }
     }
     return false;
 }
Exemplo n.º 21
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;
 }
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     $userId = UserIdentityService::getCurrentUserIdentity()['user_id'];
     // process post actions
     if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf')) && $this->getRequest()->getPost('form_name') == 'transactions') {
         $transactions = $this->getRequest()->getPost('transactions');
         if ($transactions && is_array($transactions)) {
             switch ($this->getRequest()->getQuery('action')) {
                 // delete selected transactions
                 case 'delete':
                     return $this->deleteTransactions($transactions, $userId);
                 default:
             }
         }
     }
     // get pagination options
     list($pageParamName, $perPageParamName, $orderByParamName, $orderTypeParamName) = $this->getPaginationParams();
     $page = $this->getView()->applicationRoute()->getQueryParam($pageParamName, 1);
     $perPage = $this->getView()->applicationRoute()->getQueryParam($perPageParamName);
     $orderBy = $this->getView()->applicationRoute()->getQueryParam($orderByParamName);
     $orderType = $this->getView()->applicationRoute()->getQueryParam($orderTypeParamName);
     $filters = [];
     $fieldsPostfix = '_' . $this->widgetConnectionId;
     // get a filter form
     $filterForm = $this->getServiceLocator()->get('Application\\Form\\FormManager')->getInstance('Payment\\Form\\PaymentUserTransactionFilter')->setFieldsPostfix($fieldsPostfix);
     $request = $this->getRequest();
     $filterForm->getForm()->setData($request->getQuery(), false);
     // validate the filter form
     if ($this->getRequest()->isXmlHttpRequest() || $this->getView()->applicationRoute()->getQueryParam('form_name') == $filterForm->getFormName()) {
         // check the filter form validation
         if ($filterForm->getForm()->isValid()) {
             $filters = $filterForm->getData();
         }
     }
     // get data
     $paginator = $this->getModel()->getUserTransactions($userId, $page, $perPage, $orderBy, $orderType, $filters, $fieldsPostfix);
     $dataGridWrapper = 'transactions-page-wrapper';
     // get data grid
     $dataGrid = $this->getView()->partial('payment/widget/transaction-history', ['current_currency' => PaymentService::getPrimaryCurrency(), 'payment_types' => $this->getModel()->getPaymentsTypes(false, true), 'filter_form' => $filterForm->getForm(), 'paginator' => $paginator, 'order_by' => $orderBy, 'order_type' => $orderType, 'per_page' => $perPage, 'page_param_name' => $pageParamName, 'per_page_param_name' => $perPageParamName, 'order_by_param_name' => $orderByParamName, 'order_type_param_name' => $orderTypeParamName, 'widget_connection' => $this->widgetConnectionId, 'widget_position' => $this->widgetPosition, 'data_grid_wrapper' => $dataGridWrapper]);
     if ($this->getRequest()->isXmlHttpRequest()) {
         return $dataGrid;
     }
     return $this->getView()->partial('payment/widget/transaction-history-wrapper', ['data_grid_wrapper' => $dataGridWrapper, 'data_grid' => $dataGrid]);
 }
Exemplo n.º 23
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.º 24
0
 /**
  * Select layout
  */
 public function ajaxSelectLayoutAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ((int) $this->applicationSetting('layout_select')) {
             $layoutId = $this->getSlug(-1);
             $layouts = LayoutService::getLayouts(false);
             // save selected layout
             if (array_key_exists($layoutId, $layouts)) {
                 if (!$this->isGuest()) {
                     $user = UserIdentityService::getCurrentUserIdentity();
                     $this->getModel()->selectLayout($layoutId, $user['user_id']);
                 }
                 LayoutCookieUtility::saveLayout($layoutId);
             }
         }
     }
     return $this->getResponse();
 }
Exemplo n.º 25
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.º 26
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;
 }
 /**
  * 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();
 }
 /**
  * Get a user id
  *
  * @param boolean $isSystemEvent
  * @return integer
  */
 protected static function getUserId($isSystemEvent = false)
 {
     return $isSystemEvent ? UserBaseModel::DEFAULT_SYSTEM_ID : UserIdentityService::getCurrentUserIdentity()['user_id'];
 }
 /**
  * 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.º 30
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);
 }