/**
  * 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]);
 }
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (false === ($pageUrl = $this->getView()->pageUrl('shopping-cart'))) {
         return false;
     }
     return $this->getView()->partial('payment/widget/init-shopping-cart-info', ['csrf_token' => ApplicationCsrfUtility::getToken()]);
 }
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     // process post actions
     if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf')) && $this->getRequest()->getPost('form_name') == 'shopping-cart') {
         $items = $this->getRequest()->getPost('items');
         if ($items && is_array($items)) {
             switch ($this->getRequest()->getQuery('action')) {
                 // delete shopping cart items
                 case 'delete':
                     return $this->deleteItems($items);
                 default:
             }
         }
     }
     // get pagination params
     $page = $this->getRouteParam('page', 1);
     $perPage = $this->getRouteParam('per_page');
     $orderBy = $this->getRouteParam('order_by', 'id');
     $orderType = $this->getRouteParam('order_type', 'desc');
     // get data
     $paginator = $this->getModel()->getShoppingCartItems($page, $perPage, $orderBy, $orderType);
     $dataGridWrapper = 'shopping-cart-page-wrapper';
     // get data grid
     $dataGrid = $this->getView()->partial('payment/widget/shopping-cart', ['paginator' => $paginator, 'order_by' => $orderBy, 'order_type' => $orderType, 'per_page' => $perPage, 'widget_connection' => $this->widgetConnectionId, 'widget_position' => $this->widgetPosition, 'data_grid_wrapper' => $dataGridWrapper, 'paymentHandlerManager' => $this->getServiceLocator()->get('Payment\\Handler\\PaymentHandlerManager')]);
     if ($this->getRequest()->isXmlHttpRequest()) {
         return $dataGrid;
     }
     return $this->getView()->partial('payment/widget/shopping-cart-wrapper', ['data_grid_wrapper' => $dataGridWrapper, 'data_grid' => $dataGrid]);
 }
Exemple #4
0
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     $disableRating = !AclService::checkPermission('pages_use_rating') || $this->getModel()->isPageRated($this->pageId, $this->getPageSlug());
     // process actions
     if ($this->getRequest()->isPost() && ApplicationCsrf::isTokenValid($this->getRequest()->getPost('csrf'))) {
         if (false !== ($action = $this->getRequest()->getPost('widget_action', false)) && $this->getRequest()->isXmlHttpRequest()) {
             switch ($action) {
                 case 'add_rating':
                     return $this->getView()->json($this->addPageRating($disableRating));
                 default:
             }
         }
     }
     // get current page's rating info
     $pageRating = $this->getModel()->getPageRatingInfo($this->pageId, $this->getPageSlug());
     $currentRating = $pageRating ? $this->processRatingValue($pageRating['total_rating'] / $pageRating['total_count']) : 0;
     return $this->getView()->partial('page/widget/rating', ['csrf' => ApplicationCsrf::getToken(), 'rating' => $currentRating, 'widget_url' => $this->getWidgetConnectionUrl(), 'big_rating' => $this->getWidgetSetting('page_rating_size') == 'big_rating', 'step_rating' => (double) $this->getWidgetSetting('page_rating_min_step'), 'disable_rating' => $disableRating]);
 }
 /**
  * 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]);
 }
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (AclService::checkPermission('comment_view', false)) {
         // is approve allowing
         $allowApprove = AclService::checkPermission('comment_approve', false);
         // process actions
         if (false !== ($action = $this->getRequest()->getQuery('widget_action', false)) && $this->getRequest()->isXmlHttpRequest()) {
             switch ($action) {
                 case 'get_comments':
                     // get the comment info
                     $lastCommentId = $this->getRequest()->getQuery('widget_last_comment', -1);
                     $commentInfo = $this->getModel()->getCommentModel()->getCommentInfo($lastCommentId, $this->pageId, $this->getPageSlug());
                     if ($commentInfo) {
                         $leftComments = $this->getModel()->getCommentsCount($allowApprove, $this->pageId, $this->getPageSlug(), $commentInfo[$this->getModel()->getCommentModel()->getRightKey()]);
                         return $this->getView()->json(['show_paginator' => $leftComments - (int) $this->getWidgetSetting('comment_per_page') > 0, 'comments' => $this->getCommentsList($allowApprove, false, $commentInfo[$this->getModel()->getCommentModel()->getRightKey()], true)]);
                     }
                     break;
                 case 'add_comment':
                     // validate and add a new comment
                     if ($this->getRequest()->isPost()) {
                         return $this->getView()->json($this->getAddCommentForm($allowApprove));
                     }
                     break;
                 case 'get_form':
                     return $this->getView()->json($this->getCommentForm($allowApprove, $this->getRequest()->getQuery('widget_comment_id', null)));
                 case 'edit_comment':
                     // validate and edit the comment
                     if ($this->getRequest()->isPost()) {
                         return $this->getView()->json($this->getEditCommentForm($allowApprove, $this->getRequest()->getQuery('widget_comment_id', -1)));
                     }
                     break;
                 case 'approve_comment':
                     if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf'))) {
                         return $this->getView()->json($this->approveComment($this->getRequest()->getQuery('widget_comment_id', -1)));
                     }
                     break;
                 case 'disapprove_comment':
                     if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf'))) {
                         return $this->getView()->json($this->disapproveComment($this->getRequest()->getQuery('widget_comment_id', -1)));
                     }
                     break;
                 case 'delete_comment':
                     if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf'))) {
                         return $this->getView()->json($this->deleteComment($this->getRequest()->getQuery('widget_comment_id', -1)));
                     }
                     break;
                 case 'spam_comment':
                     if ($this->getRequest()->isPost() && ApplicationCsrfUtility::isTokenValid($this->getRequest()->getPost('csrf'))) {
                         return $this->getView()->json($this->spamComment($this->getRequest()->getQuery('widget_comment_id', -1)));
                     }
                     break;
             }
         }
         return $this->getView()->partial('comment/widget/comments-list', ['csrf_token' => ApplicationCsrfUtility::getToken(), 'base_url' => $this->getWidgetConnectionUrl(), 'comment_form' => AclService::checkPermission('comment_add', false) ? $this->getCommentForm()['form'] : null, 'comments' => $this->getCommentsList($allowApprove), 'show_paginator' => $this->getModel()->getCommentsCount($allowApprove, $this->pageId, $this->getPageSlug()) > (int) $this->getWidgetSetting('comment_per_page')]);
     }
     return false;
 }
Exemple #7
0
 /**
  * Is token valid
  *
  * @param string $token
  * @return boolean
  */
 public function isTokenValid($token)
 {
     return ApplicationCsrfUtility::isTokenValid($token);
 }
 /**
  * Get widget content
  *
  * @return string|boolean
  */
 public function getContent()
 {
     if (null != ($questionId = $this->getWidgetSetting('poll_question'))) {
         // get a question info
         if (null != ($questionInfo = $this->getModel()->getQuestionInfo($questionId))) {
             // get list of answers
             $answers = $this->getModel()->getAnswers($questionId);
             $isVotingDisabled = $this->getModel()->isAnswerVoteExist($questionId) || !AclService::checkPermission('polls_make_votes', false);
             if (count($answers) > 1) {
                 // process post actions
                 if ($this->getRequest()->isPost() && ApplicationCsrf::isTokenValid($this->getRequest()->getPost('csrf'))) {
                     if (false !== ($action = $this->getRequest()->getPost('widget_action', false)) && $this->getRequest()->isXmlHttpRequest()) {
                         switch ($action) {
                             case 'make_vote':
                                 if (false !== ($answerId = $this->getRequest()->getPost('answer_id', false)) && !$isVotingDisabled) {
                                     if (true === ($result = $this->getModel()->addAnswerVote($questionId, $answerId))) {
                                         // increase acl track
                                         AclService::checkPermission('polls_make_votes');
                                     }
                                 }
                                 return $this->getView()->json(['data' => $this->getPollResult($questionId, $answers)]);
                             default:
                         }
                     }
                 }
                 // process get actions
                 if (false !== ($action = $this->getRequest()->getQuery('widget_action', false)) && $this->getRequest()->isXmlHttpRequest()) {
                     switch ($action) {
                         case 'get_answers':
                             return $this->getView()->json(['data' => $this->getPollAnswers($answers, $isVotingDisabled)]);
                         case 'get_results':
                         default:
                             return $this->getView()->json(['data' => $this->getPollResult($questionId, $answers)]);
                     }
                 }
                 return $this->getView()->partial('poll/widget/poll-init', ['csrf' => ApplicationCsrf::getToken(), 'widget_url' => $this->getWidgetConnectionUrl(), 'connection_id' => $this->widgetConnectionId, 'question_info' => $questionInfo, 'answers' => $this->getPollAnswers($answers, $isVotingDisabled)]);
             }
         }
     }
     return false;
 }