| 9760 | 
           nelberth | 
           1 | 
           <?php
  | 
        
        
            | 
            | 
           2 | 
           declare(strict_types=1);
  | 
        
        
            | 
            | 
           3 | 
              | 
        
        
            | 
            | 
           4 | 
           namespace LeadersLinked\Controller;
  | 
        
        
            | 
            | 
           5 | 
              | 
        
        
            | 
            | 
           6 | 
           use Laminas\Authentication\AuthenticationService;
  | 
        
        
            | 
            | 
           7 | 
           use Laminas\Authentication\Result as AuthResult;
  | 
        
        
            | 
            | 
           8 | 
           use Laminas\Db\Adapter\AdapterInterface;
  | 
        
        
            | 
            | 
           9 | 
           use Laminas\Cache\Storage\Adapter\AbstractAdapter;
  | 
        
        
            | 
            | 
           10 | 
           use Laminas\Mvc\Controller\AbstractActionController;
  | 
        
        
            | 
            | 
           11 | 
           use Laminas\Mvc\I18n\Translator;
  | 
        
        
            | 
            | 
           12 | 
           use Laminas\Log\LoggerInterface;
  | 
        
        
            | 
            | 
           13 | 
           use Laminas\View\Model\ViewModel;
  | 
        
        
            | 
            | 
           14 | 
           use Laminas\View\Model\JsonModel;
  | 
        
        
            | 
            | 
           15 | 
           use LeadersLinked\Model\HighPerformanceTeamsGroups;
  | 
        
        
            | 
            | 
           16 | 
           use LeadersLinked\Hydrator\ObjectPropertyHydrator;
  | 
        
        
           | 9841 | 
           nelberth | 
           17 | 
           use LeadersLinked\Form\CreateFeedForm;
  | 
        
        
           | 9760 | 
           nelberth | 
           18 | 
           use LeadersLinked\Library\Functions;
  | 
        
        
            | 
            | 
           19 | 
           use LeadersLinked\Mapper\UserMapper;
  | 
        
        
            | 
            | 
           20 | 
           use LeadersLinked\Mapper\HighPerformanceTeamsGroupsMapper;
  | 
        
        
            | 
            | 
           21 | 
           use LeadersLinked\Mapper\CompanyMapper;
  | 
        
        
           | 9776 | 
           nelberth | 
           22 | 
           use LeadersLinked\Mapper\TopicMapper;
  | 
        
        
           | 9861 | 
           nelberth | 
           23 | 
           use LeadersLinked\Model\Feed;
  | 
        
        
           | 9778 | 
           nelberth | 
           24 | 
           use LeadersLinked\Mapper\FeedMapper;
  | 
        
        
           | 9760 | 
           nelberth | 
           25 | 
              | 
        
        
            | 
            | 
           26 | 
           use LeadersLinked\Model\HighPerformanceTeamsGroupsMembers;
  | 
        
        
            | 
            | 
           27 | 
           use LeadersLinked\Form\HighPerformanceTeamsGroupsMembersForm;
  | 
        
        
            | 
            | 
           28 | 
           use LeadersLinked\Mapper\HighPerformanceTeamsGroupsMembersMapper;
  | 
        
        
           | 9766 | 
           nelberth | 
           29 | 
           class HighPerformanceTeamsGroupsViewForoArticlesController extends AbstractActionController
  | 
        
        
           | 9760 | 
           nelberth | 
           30 | 
           {
  | 
        
        
            | 
            | 
           31 | 
               /**
  | 
        
        
            | 
            | 
           32 | 
                *
  | 
        
        
            | 
            | 
           33 | 
                * @var AdapterInterface
  | 
        
        
            | 
            | 
           34 | 
                */
  | 
        
        
            | 
            | 
           35 | 
               private $adapter;
  | 
        
        
            | 
            | 
           36 | 
              | 
        
        
            | 
            | 
           37 | 
              | 
        
        
            | 
            | 
           38 | 
               /**
  | 
        
        
            | 
            | 
           39 | 
                *
  | 
        
        
            | 
            | 
           40 | 
                * @var AbstractAdapter
  | 
        
        
            | 
            | 
           41 | 
                */
  | 
        
        
            | 
            | 
           42 | 
               private $cache;
  | 
        
        
            | 
            | 
           43 | 
              | 
        
        
            | 
            | 
           44 | 
               /**
  | 
        
        
            | 
            | 
           45 | 
                *
  | 
        
        
            | 
            | 
           46 | 
                * @var  LoggerInterface
  | 
        
        
            | 
            | 
           47 | 
                */
  | 
        
        
            | 
            | 
           48 | 
               private $logger;
  | 
        
        
            | 
            | 
           49 | 
              | 
        
        
            | 
            | 
           50 | 
               /**
  | 
        
        
            | 
            | 
           51 | 
                *
  | 
        
        
            | 
            | 
           52 | 
                * @var array
  | 
        
        
            | 
            | 
           53 | 
                */
  | 
        
        
            | 
            | 
           54 | 
               private $config;
  | 
        
        
            | 
            | 
           55 | 
              | 
        
        
            | 
            | 
           56 | 
              | 
        
        
            | 
            | 
           57 | 
              | 
        
        
            | 
            | 
           58 | 
               /**
  | 
        
        
            | 
            | 
           59 | 
                *
  | 
        
        
            | 
            | 
           60 | 
                * @param AdapterInterface $adapter
  | 
        
        
            | 
            | 
           61 | 
                * @param AbstractAdapter $cache
  | 
        
        
            | 
            | 
           62 | 
                * @param LoggerInterface $logger
  | 
        
        
            | 
            | 
           63 | 
                * @param array $config
  | 
        
        
            | 
            | 
           64 | 
                */
  | 
        
        
            | 
            | 
           65 | 
               public function __construct($adapter, $cache , $logger, $config)
  | 
        
        
            | 
            | 
           66 | 
               {
  | 
        
        
            | 
            | 
           67 | 
                   $this->adapter      = $adapter;
  | 
        
        
            | 
            | 
           68 | 
                   $this->cache        = $cache;
  | 
        
        
            | 
            | 
           69 | 
                   $this->logger       = $logger;
  | 
        
        
            | 
            | 
           70 | 
                   $this->config       = $config;
  | 
        
        
            | 
            | 
           71 | 
              | 
        
        
            | 
            | 
           72 | 
              | 
        
        
            | 
            | 
           73 | 
               }
  | 
        
        
            | 
            | 
           74 | 
              | 
        
        
            | 
            | 
           75 | 
              | 
        
        
            | 
            | 
           76 | 
              | 
        
        
            | 
            | 
           77 | 
              | 
        
        
            | 
            | 
           78 | 
               public function indexAction()
  | 
        
        
            | 
            | 
           79 | 
               {
  | 
        
        
            | 
            | 
           80 | 
              | 
        
        
            | 
            | 
           81 | 
              | 
        
        
            | 
            | 
           82 | 
                   $currentUserPlugin = $this->plugin('currentUserPlugin');
  | 
        
        
            | 
            | 
           83 | 
                   $currentUser = $currentUserPlugin->getUser();
  | 
        
        
            | 
            | 
           84 | 
                   $currentCompany = $currentUserPlugin->getCompany();
  | 
        
        
           | 9772 | 
           nelberth | 
           85 | 
                   $group_uuid =  $this->params()->fromRoute('group_uuid');
  | 
        
        
           | 9776 | 
           nelberth | 
           86 | 
                   $category_uuid =  $this->params()->fromRoute('category_uuid');
  | 
        
        
           | 9760 | 
           nelberth | 
           87 | 
              | 
        
        
            | 
            | 
           88 | 
              | 
        
        
            | 
            | 
           89 | 
                   $request = $this->getRequest();
  | 
        
        
            | 
            | 
           90 | 
                   if($request->isGet()) {
  | 
        
        
            | 
            | 
           91 | 
              | 
        
        
            | 
            | 
           92 | 
              | 
        
        
            | 
            | 
           93 | 
                       $headers  = $request->getHeaders();
  | 
        
        
            | 
            | 
           94 | 
              | 
        
        
            | 
            | 
           95 | 
                       $isJson = false;
  | 
        
        
            | 
            | 
           96 | 
                       if($headers->has('Accept')) {
  | 
        
        
            | 
            | 
           97 | 
                           $accept = $headers->get('Accept');
  | 
        
        
            | 
            | 
           98 | 
              | 
        
        
            | 
            | 
           99 | 
                           $prioritized = $accept->getPrioritized();
  | 
        
        
            | 
            | 
           100 | 
              | 
        
        
            | 
            | 
           101 | 
                           foreach($prioritized as $key => $value) {
  | 
        
        
            | 
            | 
           102 | 
                               $raw = trim($value->getRaw());
  | 
        
        
            | 
            | 
           103 | 
              | 
        
        
            | 
            | 
           104 | 
                               if(!$isJson) {
  | 
        
        
            | 
            | 
           105 | 
                                   $isJson = strpos($raw, 'json');
  | 
        
        
            | 
            | 
           106 | 
                               }
  | 
        
        
            | 
            | 
           107 | 
              | 
        
        
            | 
            | 
           108 | 
                           }
  | 
        
        
            | 
            | 
           109 | 
                       }
  | 
        
        
           | 9775 | 
           nelberth | 
           110 | 
              | 
        
        
           | 9776 | 
           nelberth | 
           111 | 
                       if(!$group_uuid) {
  | 
        
        
            | 
            | 
           112 | 
                           $data = [
  | 
        
        
            | 
            | 
           113 | 
                               'success'   => false,
  | 
        
        
            | 
            | 
           114 | 
                               'data'   => 'ERROR_INVALID_PARAMETER'
  | 
        
        
            | 
            | 
           115 | 
                           ];
  | 
        
        
            | 
            | 
           116 | 
              | 
        
        
            | 
            | 
           117 | 
                           return new JsonModel($data);
  | 
        
        
            | 
            | 
           118 | 
                       }
  | 
        
        
            | 
            | 
           119 | 
              | 
        
        
            | 
            | 
           120 | 
                       if(!$category_uuid) {
  | 
        
        
            | 
            | 
           121 | 
                           $data = [
  | 
        
        
            | 
            | 
           122 | 
                               'success'   => false,
  | 
        
        
            | 
            | 
           123 | 
                               'data'   => 'ERROR_INVALID_PARAMETER'
  | 
        
        
            | 
            | 
           124 | 
                           ];
  | 
        
        
            | 
            | 
           125 | 
              | 
        
        
            | 
            | 
           126 | 
                           return new JsonModel($data);
  | 
        
        
            | 
            | 
           127 | 
                       }
  | 
        
        
            | 
            | 
           128 | 
              | 
        
        
           | 9775 | 
           nelberth | 
           129 | 
                       $highPerformanceTeamsGroupsMapper = HighPerformanceTeamsGroupsMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           130 | 
                       $highPerformanceTeamsGroups = $highPerformanceTeamsGroupsMapper->fetchOneByUuid($group_uuid);
  | 
        
        
           | 9776 | 
           nelberth | 
           131 | 
              | 
        
        
           | 9775 | 
           nelberth | 
           132 | 
                       if (!$highPerformanceTeamsGroups) {
  | 
        
        
            | 
            | 
           133 | 
                           $data = [
  | 
        
        
            | 
            | 
           134 | 
                               'success' => false,
  | 
        
        
            | 
            | 
           135 | 
                               'data' => 'ERROR_RECORD_NOT_FOUND'
  | 
        
        
            | 
            | 
           136 | 
                           ];
  | 
        
        
           | 9776 | 
           nelberth | 
           137 | 
              | 
        
        
           | 9775 | 
           nelberth | 
           138 | 
                           return new JsonModel($data);
  | 
        
        
            | 
            | 
           139 | 
                       }
  | 
        
        
           | 9776 | 
           nelberth | 
           140 | 
              | 
        
        
            | 
            | 
           141 | 
                       $highPerformanceTeamsGroupsMemberMapper = HighPerformanceTeamsGroupsMembersMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           142 | 
                       $highPerformanceTeamsGroupsMember = $highPerformanceTeamsGroupsMemberMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id, $currentUser->id);
  | 
        
        
            | 
            | 
           143 | 
                       if(!$highPerformanceTeamsGroupsMember) {
  | 
        
        
           | 9775 | 
           nelberth | 
           144 | 
                           return new JsonModel([
  | 
        
        
            | 
            | 
           145 | 
                               'success' => false,
  | 
        
        
           | 9776 | 
           nelberth | 
           146 | 
                               'data' => 'ERROR_RECORD_NOT_FOUND'
  | 
        
        
           | 9775 | 
           nelberth | 
           147 | 
                           ]);
  | 
        
        
           | 9776 | 
           nelberth | 
           148 | 
                       }
  | 
        
        
            | 
            | 
           149 | 
                       if(!($highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ACCEPTED || $highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ADDED_BY_ADMIN) ){
  | 
        
        
            | 
            | 
           150 | 
                           return new JsonModel([
  | 
        
        
            | 
            | 
           151 | 
                               'success' => false,
  | 
        
        
            | 
            | 
           152 | 
                               'data' => 'ERROR_YOU_DO_NOT_HAVE_ACCESS'
  | 
        
        
            | 
            | 
           153 | 
                           ]);
  | 
        
        
            | 
            | 
           154 | 
                       }
  | 
        
        
           | 9775 | 
           nelberth | 
           155 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           156 | 
                       if($isJson) {
  | 
        
        
            | 
            | 
           157 | 
              | 
        
        
           | 9784 | 
           nelberth | 
           158 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           159 | 
                           $acl = $this->getEvent()->getViewModel()->getVariable('acl');
  | 
        
        
           | 9905 | 
           nelberth | 
           160 | 
                           $allowEdit = $acl->isAllowed($currentUser->usertype_id, 'high-performance-teams/groups/view/foro/categories/articles/edit');
  | 
        
        
            | 
            | 
           161 | 
                           $allowDelete = $acl->isAllowed($currentUser->usertype_id,'high-performance-teams/groups/view/foro/categories/articles/delete');
  | 
        
        
            | 
            | 
           162 | 
                           $allowView = $acl->isAllowed($currentUser->usertype_id,'high-performance-teams/groups/view/foro/categories/articles/view');
  | 
        
        
           | 9760 | 
           nelberth | 
           163 | 
              | 
        
        
           | 9776 | 
           nelberth | 
           164 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           165 | 
              | 
        
        
            | 
            | 
           166 | 
                           $search = $this->params()->fromQuery('search', []);
  | 
        
        
            | 
            | 
           167 | 
                           $search = empty($search['value']) ? '' : filter_var($search['value'], FILTER_SANITIZE_STRING);
  | 
        
        
            | 
            | 
           168 | 
              | 
        
        
            | 
            | 
           169 | 
              | 
        
        
            | 
            | 
           170 | 
                           $records_x_page     = intval($this->params()->fromQuery('length', 10), 10);
  | 
        
        
            | 
            | 
           171 | 
                           $page               = (intval($this->params()->fromQuery('start', 1), 10)/$records_x_page)+1;
  | 
        
        
            | 
            | 
           172 | 
                           $order =  $this->params()->fromQuery('order', []);
  | 
        
        
            | 
            | 
           173 | 
                           $order_field        = empty($order[0]['column']) ? 99 :  intval($order[0]['column'], 10);
  | 
        
        
            | 
            | 
           174 | 
                           $order_direction    = empty($order[0]['dir']) ? 'ASC' : strtoupper(filter_var( $order[0]['dir'], FILTER_SANITIZE_STRING));
  | 
        
        
            | 
            | 
           175 | 
              | 
        
        
           | 9886 | 
           nelberth | 
           176 | 
                           $fields =  ['title', 'added_on'];
  | 
        
        
            | 
            | 
           177 | 
                           $order_field = isset($fields[$order_field]) ? $fields[$order_field] : 'added_on';
  | 
        
        
           | 9760 | 
           nelberth | 
           178 | 
              | 
        
        
            | 
            | 
           179 | 
                           if(!in_array($order_direction, ['ASC', 'DESC'])) {
  | 
        
        
           | 9888 | 
           nelberth | 
           180 | 
                               $order_direction = 'DESC';
  | 
        
        
           | 9760 | 
           nelberth | 
           181 | 
                           }
  | 
        
        
           | 9785 | 
           nelberth | 
           182 | 
              | 
        
        
            | 
            | 
           183 | 
                           $topicMapper = TopicMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           184 | 
                           $topic = $topicMapper->fetchOneByUuid($category_uuid);
  | 
        
        
            | 
            | 
           185 | 
              | 
        
        
           | 9787 | 
           nelberth | 
           186 | 
              | 
        
        
            | 
            | 
           187 | 
              | 
        
        
            | 
            | 
           188 | 
                           $feedMapper = FeedMapper::getInstance($this->adapter);
  | 
        
        
           | 9792 | 
           nelberth | 
           189 | 
              | 
        
        
           | 9789 | 
           nelberth | 
           190 | 
                           $paginator = $feedMapper->fetchAllDataTableForo($search, $page, $records_x_page, $order_field, $order_direction, $topic->id);
  | 
        
        
           | 9794 | 
           nelberth | 
           191 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           192 | 
                           $items = [];
  | 
        
        
            | 
            | 
           193 | 
              | 
        
        
            | 
            | 
           194 | 
                           $records = $paginator->getCurrentItems();
  | 
        
        
            | 
            | 
           195 | 
              | 
        
        
           | 9877 | 
           nelberth | 
           196 | 
              | 
        
        
            | 
            | 
           197 | 
                           $sandbox = $this->config['leaderslinked.runmode.sandbox'];
  | 
        
        
            | 
            | 
           198 | 
                           if($sandbox) {
  | 
        
        
            | 
            | 
           199 | 
                               $company_profile_url = $this->config['leaderslinked.frontend.sandbox_company_profile'];
  | 
        
        
            | 
            | 
           200 | 
                               $user_profile_url = $this->config['leaderslinked.frontend.sandbox_user_profile'];
  | 
        
        
            | 
            | 
           201 | 
              | 
        
        
            | 
            | 
           202 | 
                           } else {
  | 
        
        
            | 
            | 
           203 | 
                               $company_profile_url = $this->config['leaderslinked.frontend.production_company_profile'];
  | 
        
        
            | 
            | 
           204 | 
                               $user_profile_url = $this->config['leaderslinked.frontend.production_user_profile'];
  | 
        
        
            | 
            | 
           205 | 
                           }
  | 
        
        
           | 9760 | 
           nelberth | 
           206 | 
              | 
        
        
            | 
            | 
           207 | 
                           foreach($records as $record)
  | 
        
        
            | 
            | 
           208 | 
                           {
  | 
        
        
            | 
            | 
           209 | 
              | 
        
        
            | 
            | 
           210 | 
              | 
        
        
           | 9877 | 
           nelberth | 
           211 | 
                               $userMapper = UserMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           212 | 
                               $user = $userMapper->fetchOne($record->user_id);
  | 
        
        
           | 9919 | 
           nelberth | 
           213 | 
                               if($record->user_id!=$currentUser->id){
  | 
        
        
            | 
            | 
           214 | 
                                   $allowDelete=false;
  | 
        
        
            | 
            | 
           215 | 
                                   $allowEdit=false;
  | 
        
        
            | 
            | 
           216 | 
                               }
  | 
        
        
           | 9883 | 
           nelberth | 
           217 | 
                               $dt = \DateTime::createFromFormat('Y-m-d H:i:s', $record->added_on);
  | 
        
        
           | 9760 | 
           nelberth | 
           218 | 
                               $item = [
  | 
        
        
            | 
            | 
           219 | 
                                   'title' => $record->title,
  | 
        
        
           | 9877 | 
           nelberth | 
           220 | 
                                   'author' => [
  | 
        
        
            | 
            | 
           221 | 
                                       'user_name' => $user->first_name . ' ' . $user->last_name,
  | 
        
        
            | 
            | 
           222 | 
                                       'user_url' =>  str_replace('[uuid]', $user->uuid, $user_profile_url),
  | 
        
        
            | 
            | 
           223 | 
                                       'user_image' => $this->url()->fromRoute('storage', ['code' => $user->uuid, 'type' => 'user', 'filename' => $user->image]),
  | 
        
        
            | 
            | 
           224 | 
                                   ],
  | 
        
        
           | 9903 | 
           nelberth | 
           225 | 
                                   'added_on'=> $dt->format('d/m/Y'),
  | 
        
        
           | 9760 | 
           nelberth | 
           226 | 
                                   'actions' => [
  | 
        
        
           | 9911 | 
           nelberth | 
           227 | 
                                       'link_edit' => $allowEdit ? $this->url()->fromRoute('high-performance-teams/groups/view/foro/categories/articles/edit', ['group_uuid' => $group_uuid,'category_uuid' => $category_uuid, 'article_uuid' => $record->uuid]) : '',
  | 
        
        
           | 9906 | 
           nelberth | 
           228 | 
                                       'link_delete' => $allowDelete ? $this->url()->fromRoute('high-performance-teams/groups/view/foro/categories/articles/delete', ['group_uuid' => $group_uuid,'category_uuid' => $category_uuid, 'article_uuid' => $record->uuid]) : '',
  | 
        
        
           | 9911 | 
           nelberth | 
           229 | 
                                       'link_view' => $allowView ? $this->url()->fromRoute('high-performance-teams/groups/view/foro/categories/articles/view', ['group_uuid' => $group_uuid,'category_uuid' => $category_uuid, 'article_uuid' => $record->uuid]) : '',
  | 
        
        
           | 9760 | 
           nelberth | 
           230 | 
                                   ]
  | 
        
        
            | 
            | 
           231 | 
              | 
        
        
            | 
            | 
           232 | 
                               ];
  | 
        
        
            | 
            | 
           233 | 
              | 
        
        
            | 
            | 
           234 | 
                               array_push($items, $item);
  | 
        
        
            | 
            | 
           235 | 
              | 
        
        
            | 
            | 
           236 | 
                           }
  | 
        
        
            | 
            | 
           237 | 
              | 
        
        
            | 
            | 
           238 | 
                           return new JsonModel([
  | 
        
        
            | 
            | 
           239 | 
                               'success' => true,
  | 
        
        
            | 
            | 
           240 | 
                               'data' => [
  | 
        
        
            | 
            | 
           241 | 
                                   'items' => $items,
  | 
        
        
            | 
            | 
           242 | 
                                   'total' => $paginator->getTotalItemCount(),
  | 
        
        
            | 
            | 
           243 | 
                               ]
  | 
        
        
            | 
            | 
           244 | 
                           ]);
  | 
        
        
            | 
            | 
           245 | 
              | 
        
        
            | 
            | 
           246 | 
                       } else  {
  | 
        
        
           | 9841 | 
           nelberth | 
           247 | 
                           $formAdd = new CreateFeedForm($this->adapter);
  | 
        
        
           | 9760 | 
           nelberth | 
           248 | 
                           $this->layout()->setTemplate('layout/layout-backend');
  | 
        
        
            | 
            | 
           249 | 
                           $viewModel = new ViewModel();
  | 
        
        
           | 9768 | 
           nelberth | 
           250 | 
                           $viewModel->setTemplate('leaders-linked/high-performance-teams-groups-view-foro-articles/index.phtml');
  | 
        
        
           | 9760 | 
           nelberth | 
           251 | 
                           $viewModel->setVariables([
  | 
        
        
           | 9770 | 
           nelberth | 
           252 | 
                               'formAdd' => $formAdd,
  | 
        
        
           | 9772 | 
           nelberth | 
           253 | 
                               'group_uuid'=>$group_uuid,
  | 
        
        
           | 9775 | 
           nelberth | 
           254 | 
                               'group_title'=>$highPerformanceTeamsGroups->title,
  | 
        
        
           | 9777 | 
           nelberth | 
           255 | 
                               'group_description'=>$highPerformanceTeamsGroups->description,
  | 
        
        
            | 
            | 
           256 | 
                               'category_uuid'=>$category_uuid
  | 
        
        
           | 9760 | 
           nelberth | 
           257 | 
                           ]);
  | 
        
        
            | 
            | 
           258 | 
                           return $viewModel ;
  | 
        
        
            | 
            | 
           259 | 
                       }
  | 
        
        
            | 
            | 
           260 | 
                   } else {
  | 
        
        
            | 
            | 
           261 | 
                       return new JsonModel([
  | 
        
        
            | 
            | 
           262 | 
                           'success' => false,
  | 
        
        
            | 
            | 
           263 | 
                           'data' => 'ERROR_METHOD_NOT_ALLOWED'
  | 
        
        
            | 
            | 
           264 | 
                       ]);
  | 
        
        
            | 
            | 
           265 | 
                   }
  | 
        
        
            | 
            | 
           266 | 
               }
  | 
        
        
            | 
            | 
           267 | 
              | 
        
        
            | 
            | 
           268 | 
               public function addAction()
  | 
        
        
            | 
            | 
           269 | 
               {
  | 
        
        
           | 9850 | 
           nelberth | 
           270 | 
              | 
        
        
           | 9852 | 
           nelberth | 
           271 | 
              | 
        
        
           | 9847 | 
           nelberth | 
           272 | 
                   $currentUserPlugin = $this->plugin('currentUserPlugin');
  | 
        
        
           | 9760 | 
           nelberth | 
           273 | 
                   $currentUser = $currentUserPlugin->getUser();
  | 
        
        
            | 
            | 
           274 | 
                   $currentCompany = $currentUserPlugin->getCompany();
  | 
        
        
           | 9847 | 
           nelberth | 
           275 | 
                   $group_uuid =  $this->params()->fromRoute('group_uuid');
  | 
        
        
            | 
            | 
           276 | 
                   $category_uuid =  $this->params()->fromRoute('category_uuid');
  | 
        
        
           | 9760 | 
           nelberth | 
           277 | 
              | 
        
        
            | 
            | 
           278 | 
                   $request = $this->getRequest();
  | 
        
        
            | 
            | 
           279 | 
                   if($request->isPost()) {
  | 
        
        
            | 
            | 
           280 | 
              | 
        
        
           | 9847 | 
           nelberth | 
           281 | 
              | 
        
        
            | 
            | 
           282 | 
                       $dataPost = array_merge($request->getPost()->toArray(), $request->getFiles()->toArray());
  | 
        
        
            | 
            | 
           283 | 
              | 
        
        
            | 
            | 
           284 | 
                       $form = new CreateFeedForm($this->adapter);
  | 
        
        
            | 
            | 
           285 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           286 | 
                       $form->setData($dataPost);
  | 
        
        
           | 9859 | 
           nelberth | 
           287 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           288 | 
                       if($form->isValid()) {
  | 
        
        
           | 9860 | 
           nelberth | 
           289 | 
              | 
        
        
           | 9847 | 
           nelberth | 
           290 | 
              | 
        
        
            | 
            | 
           291 | 
                           $hydrator = new ObjectPropertyHydrator();
  | 
        
        
            | 
            | 
           292 | 
                           $feed = new Feed();
  | 
        
        
            | 
            | 
           293 | 
                           $hydrator->hydrate($dataPost, $feed);
  | 
        
        
            | 
            | 
           294 | 
              | 
        
        
           | 9862 | 
           nelberth | 
           295 | 
              | 
        
        
           | 9847 | 
           nelberth | 
           296 | 
              | 
        
        
           | 9855 | 
           nelberth | 
           297 | 
              | 
        
        
           | 9847 | 
           nelberth | 
           298 | 
                               $highPerformanceTeamsGroupsMapper = HighPerformanceTeamsGroupsMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           299 | 
                               $highPerformanceTeamsGroups = $highPerformanceTeamsGroupsMapper->fetchOneByUuid($group_uuid);
  | 
        
        
            | 
            | 
           300 | 
              | 
        
        
            | 
            | 
           301 | 
                               if (!$highPerformanceTeamsGroups) {
  | 
        
        
            | 
            | 
           302 | 
                                   $data = [
  | 
        
        
            | 
            | 
           303 | 
                                       'success' => false,
  | 
        
        
            | 
            | 
           304 | 
                                       'data' => 'ERROR_RECORD_NOT_FOUND'
  | 
        
        
            | 
            | 
           305 | 
                                   ];
  | 
        
        
            | 
            | 
           306 | 
              | 
        
        
            | 
            | 
           307 | 
                                   return new JsonModel($data);
  | 
        
        
            | 
            | 
           308 | 
                               }
  | 
        
        
            | 
            | 
           309 | 
              | 
        
        
            | 
            | 
           310 | 
                               if($highPerformanceTeamsGroups->status != HighPerformanceTeamsGroups::STATUS_ACTIVE) {
  | 
        
        
            | 
            | 
           311 | 
              | 
        
        
            | 
            | 
           312 | 
                                   return new JsonModel([
  | 
        
        
            | 
            | 
           313 | 
                                       'success' => false,
  | 
        
        
            | 
            | 
           314 | 
                                       'data' => 'ERROR_UNAUTHORIZED'
  | 
        
        
            | 
            | 
           315 | 
                                   ]);
  | 
        
        
            | 
            | 
           316 | 
              | 
        
        
            | 
            | 
           317 | 
                               }
  | 
        
        
            | 
            | 
           318 | 
              | 
        
        
            | 
            | 
           319 | 
                               $highPerformanceTeamsGroupsMemberMapper = HighPerformanceTeamsGroupsMembersMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           320 | 
                               $highPerformanceTeamsGroupsMember = $highPerformanceTeamsGroupsMemberMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id, $currentUser->id);
  | 
        
        
            | 
            | 
           321 | 
                               if($highPerformanceTeamsGroupsMember) {
  | 
        
        
            | 
            | 
           322 | 
                                   if($highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ACCEPTED || $highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ADDED_BY_ADMIN ){
  | 
        
        
            | 
            | 
           323 | 
                                       $id =  $highPerformanceTeamsGroups->id;
  | 
        
        
            | 
            | 
           324 | 
                                   }else{
  | 
        
        
            | 
            | 
           325 | 
              | 
        
        
            | 
            | 
           326 | 
                                       return new JsonModel([
  | 
        
        
            | 
            | 
           327 | 
                                           'success' => false,
  | 
        
        
            | 
            | 
           328 | 
                                           'data' => 'ERROR_UNAUTHORIZED'
  | 
        
        
            | 
            | 
           329 | 
                                       ]);
  | 
        
        
            | 
            | 
           330 | 
                                   }
  | 
        
        
            | 
            | 
           331 | 
              | 
        
        
            | 
            | 
           332 | 
                               } else {
  | 
        
        
            | 
            | 
           333 | 
              | 
        
        
            | 
            | 
           334 | 
                                   return new JsonModel([
  | 
        
        
            | 
            | 
           335 | 
                                       'success' => false,
  | 
        
        
            | 
            | 
           336 | 
                                       'data' => 'ERROR_RECORD_NOT_FOUND'
  | 
        
        
            | 
            | 
           337 | 
                                   ]);
  | 
        
        
            | 
            | 
           338 | 
                               }
  | 
        
        
            | 
            | 
           339 | 
              | 
        
        
           | 9864 | 
           nelberth | 
           340 | 
              | 
        
        
           | 9847 | 
           nelberth | 
           341 | 
              | 
        
        
            | 
            | 
           342 | 
                                   $topicMapper = TopicMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           343 | 
                                   $topic = $topicMapper->fetchOneByUuid($category_uuid);
  | 
        
        
            | 
            | 
           344 | 
                                   if($topic){
  | 
        
        
            | 
            | 
           345 | 
                                       $feed->topic_id = $topic->id;
  | 
        
        
            | 
            | 
           346 | 
                                   }else{
  | 
        
        
            | 
            | 
           347 | 
                                       return new JsonModel([
  | 
        
        
            | 
            | 
           348 | 
                                           'success' => false,
  | 
        
        
            | 
            | 
           349 | 
                                           'data' => 'ERROR_RECORD_NOT_FOUND'
  | 
        
        
            | 
            | 
           350 | 
                                       ]);
  | 
        
        
            | 
            | 
           351 | 
                                   }
  | 
        
        
           | 9760 | 
           nelberth | 
           352 | 
              | 
        
        
            | 
            | 
           353 | 
              | 
        
        
           | 9865 | 
           nelberth | 
           354 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           355 | 
              | 
        
        
           | 9847 | 
           nelberth | 
           356 | 
                           $feed->company_id       = $currentCompany->id;
  | 
        
        
            | 
            | 
           357 | 
                           $feed->group_id         = null;
  | 
        
        
            | 
            | 
           358 | 
                           $feed->high_performance_group_id = $id;
  | 
        
        
            | 
            | 
           359 | 
                           $feed->user_id          = $currentUser->id;
  | 
        
        
            | 
            | 
           360 | 
                           $feed->type             = Feed::TYPE_HPTG;
  | 
        
        
            | 
            | 
           361 | 
                           $feed->posted_or_shared = Feed::POSTED;
  | 
        
        
            | 
            | 
           362 | 
                           $feed->shared_with      = Feed::SHARE_WITH_CONNECTIONS;
  | 
        
        
            | 
            | 
           363 | 
                           $feed->total_comments   = 0;
  | 
        
        
            | 
            | 
           364 | 
                           $feed->total_shared     = 0;
  | 
        
        
            | 
            | 
           365 | 
              | 
        
        
            | 
            | 
           366 | 
              | 
        
        
           | 9866 | 
           nelberth | 
           367 | 
              | 
        
        
            | 
            | 
           368 | 
                           $feedMapper = FeedMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           369 | 
                           $result = $feedMapper->insert($feed);
  | 
        
        
            | 
            | 
           370 | 
              | 
        
        
           | 9867 | 
           nelberth | 
           371 | 
              | 
        
        
           | 9847 | 
           nelberth | 
           372 | 
                           if($result) {
  | 
        
        
           | 9868 | 
           nelberth | 
           373 | 
              | 
        
        
            | 
            | 
           374 | 
                               $this->logger->info('Se agrego el articulo del foro con el titulo ' . $feed->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
  | 
        
        
           | 9870 | 
           nelberth | 
           375 | 
              | 
        
        
            | 
            | 
           376 | 
                               $response = [
  | 
        
        
           | 9760 | 
           nelberth | 
           377 | 
                                   'success'   => true,
  | 
        
        
            | 
            | 
           378 | 
                                   'data'   => 'LABEL_RECORD_ADDED'
  | 
        
        
            | 
            | 
           379 | 
                               ];
  | 
        
        
           | 9847 | 
           nelberth | 
           380 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           381 | 
                           } else {
  | 
        
        
           | 9847 | 
           nelberth | 
           382 | 
                               $response = [
  | 
        
        
           | 9760 | 
           nelberth | 
           383 | 
                                   'success'   => false,
  | 
        
        
           | 9847 | 
           nelberth | 
           384 | 
                                   'data'   => $feedMapper->getError()
  | 
        
        
           | 9760 | 
           nelberth | 
           385 | 
                               ];
  | 
        
        
            | 
            | 
           386 | 
                           }
  | 
        
        
            | 
            | 
           387 | 
                       } else {
  | 
        
        
            | 
            | 
           388 | 
                           $messages = [];
  | 
        
        
            | 
            | 
           389 | 
                           $form_messages = (array) $form->getMessages();
  | 
        
        
            | 
            | 
           390 | 
                           foreach($form_messages  as $fieldname => $field_messages)
  | 
        
        
            | 
            | 
           391 | 
                           {
  | 
        
        
            | 
            | 
           392 | 
                               $messages[$fieldname] = array_values($field_messages);
  | 
        
        
            | 
            | 
           393 | 
                           }
  | 
        
        
            | 
            | 
           394 | 
              | 
        
        
           | 9847 | 
           nelberth | 
           395 | 
                           $response = [
  | 
        
        
           | 9760 | 
           nelberth | 
           396 | 
                               'success'   => false,
  | 
        
        
            | 
            | 
           397 | 
                               'data'   => $messages
  | 
        
        
           | 9847 | 
           nelberth | 
           398 | 
                           ];
  | 
        
        
           | 9760 | 
           nelberth | 
           399 | 
                       }
  | 
        
        
            | 
            | 
           400 | 
              | 
        
        
            | 
            | 
           401 | 
                   } else {
  | 
        
        
           | 9847 | 
           nelberth | 
           402 | 
                       $response = [
  | 
        
        
           | 9760 | 
           nelberth | 
           403 | 
                           'success' => false,
  | 
        
        
           | 9850 | 
           nelberth | 
           404 | 
                           'data' => 'ERROR_METHOD_NOT_ALLOWED'
  | 
        
        
           | 9760 | 
           nelberth | 
           405 | 
                       ];
  | 
        
        
            | 
            | 
           406 | 
                   }
  | 
        
        
            | 
            | 
           407 | 
              | 
        
        
           | 9847 | 
           nelberth | 
           408 | 
                   return new JsonModel($response);
  | 
        
        
           | 9760 | 
           nelberth | 
           409 | 
               }
  | 
        
        
            | 
            | 
           410 | 
              | 
        
        
            | 
            | 
           411 | 
              | 
        
        
            | 
            | 
           412 | 
                public function editAction(){
  | 
        
        
            | 
            | 
           413 | 
              | 
        
        
            | 
            | 
           414 | 
                   $currentUserPlugin = $this->plugin('currentUserPlugin');
  | 
        
        
            | 
            | 
           415 | 
                   $currentUser = $currentUserPlugin->getUser();
  | 
        
        
            | 
            | 
           416 | 
                   $currentCompany = $currentUserPlugin->getCompany();
  | 
        
        
            | 
            | 
           417 | 
                   $request = $this->getRequest();
  | 
        
        
           | 9915 | 
           nelberth | 
           418 | 
              | 
        
        
            | 
            | 
           419 | 
                   $group_uuid =  $this->params()->fromRoute('group_uuid');
  | 
        
        
            | 
            | 
           420 | 
                   $category_uuid =  $this->params()->fromRoute('category_uuid');
  | 
        
        
           | 9760 | 
           nelberth | 
           421 | 
              | 
        
        
           | 9915 | 
           nelberth | 
           422 | 
                   $article_uuid =  $this->params()->fromRoute('article_uuid');
  | 
        
        
           | 9760 | 
           nelberth | 
           423 | 
              | 
        
        
           | 9915 | 
           nelberth | 
           424 | 
                   if(!$group_uuid) {
  | 
        
        
           | 9760 | 
           nelberth | 
           425 | 
                       $data = [
  | 
        
        
            | 
            | 
           426 | 
                           'success'   => false,
  | 
        
        
            | 
            | 
           427 | 
                           'data'   => 'ERROR_INVALID_PARAMETER'
  | 
        
        
            | 
            | 
           428 | 
                       ];
  | 
        
        
            | 
            | 
           429 | 
              | 
        
        
            | 
            | 
           430 | 
                       return new JsonModel($data);
  | 
        
        
            | 
            | 
           431 | 
                   }
  | 
        
        
            | 
            | 
           432 | 
              | 
        
        
           | 9915 | 
           nelberth | 
           433 | 
                   if(!$category_uuid) {
  | 
        
        
            | 
            | 
           434 | 
                       $data = [
  | 
        
        
            | 
            | 
           435 | 
                           'success'   => false,
  | 
        
        
            | 
            | 
           436 | 
                           'data'   => 'ERROR_INVALID_PARAMETER'
  | 
        
        
            | 
            | 
           437 | 
                       ];
  | 
        
        
            | 
            | 
           438 | 
              | 
        
        
            | 
            | 
           439 | 
                       return new JsonModel($data);
  | 
        
        
            | 
            | 
           440 | 
                   }
  | 
        
        
            | 
            | 
           441 | 
              | 
        
        
            | 
            | 
           442 | 
                   if(!$article_uuid) {
  | 
        
        
            | 
            | 
           443 | 
                       $data = [
  | 
        
        
            | 
            | 
           444 | 
                           'success'   => false,
  | 
        
        
            | 
            | 
           445 | 
                           'data'   => 'ERROR_INVALID_PARAMETER'
  | 
        
        
            | 
            | 
           446 | 
                       ];
  | 
        
        
            | 
            | 
           447 | 
              | 
        
        
            | 
            | 
           448 | 
                       return new JsonModel($data);
  | 
        
        
            | 
            | 
           449 | 
                   }
  | 
        
        
            | 
            | 
           450 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           451 | 
                   $highPerformanceTeamsGroupsMapper = HighPerformanceTeamsGroupsMapper::getInstance($this->adapter);
  | 
        
        
           | 9915 | 
           nelberth | 
           452 | 
                   $highPerformanceTeamsGroups = $highPerformanceTeamsGroupsMapper->fetchOneByUuid($group_uuid);
  | 
        
        
           | 9760 | 
           nelberth | 
           453 | 
              | 
        
        
           | 9915 | 
           nelberth | 
           454 | 
                   if (!$highPerformanceTeamsGroups) {
  | 
        
        
           | 9760 | 
           nelberth | 
           455 | 
                       $data = [
  | 
        
        
            | 
            | 
           456 | 
                           'success' => false,
  | 
        
        
            | 
            | 
           457 | 
                           'data' => 'ERROR_RECORD_NOT_FOUND'
  | 
        
        
            | 
            | 
           458 | 
                       ];
  | 
        
        
            | 
            | 
           459 | 
              | 
        
        
            | 
            | 
           460 | 
                       return new JsonModel($data);
  | 
        
        
            | 
            | 
           461 | 
                   }
  | 
        
        
           | 9915 | 
           nelberth | 
           462 | 
              | 
        
        
            | 
            | 
           463 | 
                   $highPerformanceTeamsGroupsMemberMapper = HighPerformanceTeamsGroupsMembersMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           464 | 
                   $highPerformanceTeamsGroupsMember = $highPerformanceTeamsGroupsMemberMapper->fetchOneByGroupIdAndUserId($highPerformanceTeamsGroups->id, $currentUser->id);
  | 
        
        
            | 
            | 
           465 | 
                   if(!$highPerformanceTeamsGroupsMember) {
  | 
        
        
           | 9760 | 
           nelberth | 
           466 | 
                       return new JsonModel([
  | 
        
        
            | 
            | 
           467 | 
                           'success' => false,
  | 
        
        
           | 9915 | 
           nelberth | 
           468 | 
                           'data' => 'ERROR_RECORD_NOT_FOUND'
  | 
        
        
           | 9760 | 
           nelberth | 
           469 | 
                       ]);
  | 
        
        
           | 9915 | 
           nelberth | 
           470 | 
                   }
  | 
        
        
            | 
            | 
           471 | 
                   if(!($highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ACCEPTED || $highPerformanceTeamsGroupsMember->status == HighPerformanceTeamsGroupsMembers::STATUS_ADDED_BY_ADMIN) ){
  | 
        
        
            | 
            | 
           472 | 
                       return new JsonModel([
  | 
        
        
            | 
            | 
           473 | 
                           'success' => false,
  | 
        
        
            | 
            | 
           474 | 
                           'data' => 'ERROR_YOU_DO_NOT_HAVE_ACCESS'
  | 
        
        
            | 
            | 
           475 | 
                       ]);
  | 
        
        
            | 
            | 
           476 | 
                   }
  | 
        
        
           | 9760 | 
           nelberth | 
           477 | 
              | 
        
        
           | 9915 | 
           nelberth | 
           478 | 
                   $feedMapper = FeedMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           479 | 
                   $feed = $feedMapper->fetchOneByUuid($article_uuid);
  | 
        
        
            | 
            | 
           480 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           481 | 
                   if($request->isPost()) {
  | 
        
        
           | 9918 | 
           nelberth | 
           482 | 
              | 
        
        
            | 
            | 
           483 | 
                       $form = new  CreateFeedForm($this->adapter);
  | 
        
        
           | 9760 | 
           nelberth | 
           484 | 
                       $dataPost = $request->getPost()->toArray();
  | 
        
        
            | 
            | 
           485 | 
                       $form->setData($dataPost);
  | 
        
        
            | 
            | 
           486 | 
              | 
        
        
            | 
            | 
           487 | 
                       if($form->isValid()) {
  | 
        
        
            | 
            | 
           488 | 
                           $dataPost = (array) $form->getData();
  | 
        
        
            | 
            | 
           489 | 
              | 
        
        
            | 
            | 
           490 | 
                           $hydrator = new ObjectPropertyHydrator();
  | 
        
        
           | 9918 | 
           nelberth | 
           491 | 
                           $hydrator->hydrate($dataPost, $feed);
  | 
        
        
            | 
            | 
           492 | 
                           $result = $feedMapper->update($feed);
  | 
        
        
           | 9760 | 
           nelberth | 
           493 | 
              | 
        
        
            | 
            | 
           494 | 
                           if($result) {
  | 
        
        
           | 9918 | 
           nelberth | 
           495 | 
                               $this->logger->info('Se actualizo el articulo del foro con el titulo ' . $feed->title, ['user_id' => $currentUser->id, 'ip' => Functions::getUserIP()]);
  | 
        
        
           | 9760 | 
           nelberth | 
           496 | 
              | 
        
        
            | 
            | 
           497 | 
                               $data = [
  | 
        
        
            | 
            | 
           498 | 
                                   'success' => true,
  | 
        
        
            | 
            | 
           499 | 
                                   'data' => 'LABEL_RECORD_UPDATED'
  | 
        
        
            | 
            | 
           500 | 
                               ];
  | 
        
        
            | 
            | 
           501 | 
                           } else {
  | 
        
        
            | 
            | 
           502 | 
                               $data = [
  | 
        
        
            | 
            | 
           503 | 
                                   'success'   => false,
  | 
        
        
           | 9918 | 
           nelberth | 
           504 | 
                                   'data'      => $feedMapper->getError()
  | 
        
        
           | 9760 | 
           nelberth | 
           505 | 
                               ];
  | 
        
        
            | 
            | 
           506 | 
                           }
  | 
        
        
            | 
            | 
           507 | 
              | 
        
        
            | 
            | 
           508 | 
                           return new JsonModel($data);
  | 
        
        
            | 
            | 
           509 | 
              | 
        
        
            | 
            | 
           510 | 
                       } else {
  | 
        
        
            | 
            | 
           511 | 
                           $messages = [];
  | 
        
        
            | 
            | 
           512 | 
                           $form_messages = (array) $form->getMessages();
  | 
        
        
            | 
            | 
           513 | 
                           foreach($form_messages  as $fieldname => $field_messages)
  | 
        
        
            | 
            | 
           514 | 
                           {
  | 
        
        
            | 
            | 
           515 | 
                               $messages[$fieldname] = array_values($field_messages);
  | 
        
        
            | 
            | 
           516 | 
                           }
  | 
        
        
            | 
            | 
           517 | 
              | 
        
        
            | 
            | 
           518 | 
                           return new JsonModel([
  | 
        
        
            | 
            | 
           519 | 
                               'success'   => false,
  | 
        
        
            | 
            | 
           520 | 
                               'data'   => $messages
  | 
        
        
            | 
            | 
           521 | 
                           ]);
  | 
        
        
            | 
            | 
           522 | 
                       }
  | 
        
        
            | 
            | 
           523 | 
                   }else if ($request->isGet()) {
  | 
        
        
           | 9915 | 
           nelberth | 
           524 | 
              | 
        
        
            | 
            | 
           525 | 
              | 
        
        
            | 
            | 
           526 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           527 | 
                       $hydrator = new ObjectPropertyHydrator();
  | 
        
        
            | 
            | 
           528 | 
              | 
        
        
            | 
            | 
           529 | 
                       $data = [
  | 
        
        
            | 
            | 
           530 | 
                           'success' => true,
  | 
        
        
           | 9915 | 
           nelberth | 
           531 | 
                           'data' => $hydrator->extract($feed)
  | 
        
        
           | 9760 | 
           nelberth | 
           532 | 
                       ];
  | 
        
        
            | 
            | 
           533 | 
              | 
        
        
            | 
            | 
           534 | 
                       return new JsonModel($data);
  | 
        
        
            | 
            | 
           535 | 
                   } else {
  | 
        
        
            | 
            | 
           536 | 
                       $data = [
  | 
        
        
            | 
            | 
           537 | 
                           'success' => false,
  | 
        
        
            | 
            | 
           538 | 
                           'data' => 'ERROR_METHOD_NOT_ALLOWED'
  | 
        
        
            | 
            | 
           539 | 
                       ];
  | 
        
        
            | 
            | 
           540 | 
              | 
        
        
            | 
            | 
           541 | 
                       return new JsonModel($data);
  | 
        
        
            | 
            | 
           542 | 
                   }
  | 
        
        
            | 
            | 
           543 | 
              | 
        
        
            | 
            | 
           544 | 
                   return new JsonModel($data);
  | 
        
        
            | 
            | 
           545 | 
              | 
        
        
            | 
            | 
           546 | 
               }
  | 
        
        
            | 
            | 
           547 | 
              | 
        
        
            | 
            | 
           548 | 
              | 
        
        
            | 
            | 
           549 | 
              | 
        
        
            | 
            | 
           550 | 
              | 
        
        
           | 9904 | 
           nelberth | 
           551 | 
               public function deleteAction()
  | 
        
        
            | 
            | 
           552 | 
               {
  | 
        
        
           | 9760 | 
           nelberth | 
           553 | 
                   $currentUserPlugin = $this->plugin('currentUserPlugin');
  | 
        
        
           | 9904 | 
           nelberth | 
           554 | 
                   $currentUser = $currentUserPlugin->getUser();
  | 
        
        
           | 9760 | 
           nelberth | 
           555 | 
                   $currentCompany = $currentUserPlugin->getCompany();
  | 
        
        
           | 9904 | 
           nelberth | 
           556 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           557 | 
                   $request = $this->getRequest();
  | 
        
        
           | 9904 | 
           nelberth | 
           558 | 
                   if($request->isPost()) {
  | 
        
        
           | 9760 | 
           nelberth | 
           559 | 
              | 
        
        
           | 9904 | 
           nelberth | 
           560 | 
              | 
        
        
            | 
            | 
           561 | 
                       $article_uuid =  $this->params()->fromRoute('article_uuid');
  | 
        
        
            | 
            | 
           562 | 
              | 
        
        
            | 
            | 
           563 | 
                       $feedMapper = FeedMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           564 | 
                       $feed = $feedMapper->fetchOneByUuid($article_uuid);
  | 
        
        
            | 
            | 
           565 | 
                       if(!$feed) {
  | 
        
        
            | 
            | 
           566 | 
                           $response = [
  | 
        
        
            | 
            | 
           567 | 
                               'success' => false,
  | 
        
        
            | 
            | 
           568 | 
                               'data' => 'ERROR_POST_NOT_FOUND'
  | 
        
        
            | 
            | 
           569 | 
                           ];
  | 
        
        
            | 
            | 
           570 | 
                           return new JsonModel($response);
  | 
        
        
            | 
            | 
           571 | 
                       }
  | 
        
        
            | 
            | 
           572 | 
              | 
        
        
            | 
            | 
           573 | 
                       if($feed->company_id != $currentCompany->id) {
  | 
        
        
            | 
            | 
           574 | 
                           $response = [
  | 
        
        
            | 
            | 
           575 | 
                               'success' => false,
  | 
        
        
            | 
            | 
           576 | 
                               'data' => 'ERROR_UNAUTHORIZED'
  | 
        
        
            | 
            | 
           577 | 
                           ];
  | 
        
        
            | 
            | 
           578 | 
                           return new JsonModel($response);
  | 
        
        
            | 
            | 
           579 | 
                       }
  | 
        
        
            | 
            | 
           580 | 
              | 
        
        
            | 
            | 
           581 | 
                       $feedMapper = FeedMapper::getInstance($this->adapter);
  | 
        
        
            | 
            | 
           582 | 
                       $feed->status = Feed::STATUS_DELETED;
  | 
        
        
            | 
            | 
           583 | 
                       if($feedMapper->update($feed)) {
  | 
        
        
            | 
            | 
           584 | 
                           $response = [
  | 
        
        
           | 9760 | 
           nelberth | 
           585 | 
                               'success' => true,
  | 
        
        
           | 9904 | 
           nelberth | 
           586 | 
                               'data' => 'LABEL_FEED_WAS_DELETED'
  | 
        
        
           | 9760 | 
           nelberth | 
           587 | 
                           ];
  | 
        
        
           | 9904 | 
           nelberth | 
           588 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           589 | 
                       } else {
  | 
        
        
           | 9904 | 
           nelberth | 
           590 | 
                           $response = [
  | 
        
        
           | 9760 | 
           nelberth | 
           591 | 
                               'success' => false,
  | 
        
        
           | 9904 | 
           nelberth | 
           592 | 
                               'data' => $feedMapper->getError()
  | 
        
        
           | 9760 | 
           nelberth | 
           593 | 
                           ];
  | 
        
        
           | 9904 | 
           nelberth | 
           594 | 
                       }
  | 
        
        
           | 9760 | 
           nelberth | 
           595 | 
              | 
        
        
           | 9904 | 
           nelberth | 
           596 | 
              | 
        
        
            | 
            | 
           597 | 
                       return new JsonModel($response);
  | 
        
        
            | 
            | 
           598 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           599 | 
                   } else {
  | 
        
        
           | 9904 | 
           nelberth | 
           600 | 
                       $response = [
  | 
        
        
           | 9760 | 
           nelberth | 
           601 | 
                           'success' => false,
  | 
        
        
            | 
            | 
           602 | 
                           'data' => 'ERROR_METHOD_NOT_ALLOWED'
  | 
        
        
            | 
            | 
           603 | 
                       ];
  | 
        
        
            | 
            | 
           604 | 
                   }
  | 
        
        
           | 9904 | 
           nelberth | 
           605 | 
              | 
        
        
            | 
            | 
           606 | 
                   return new JsonModel($response);
  | 
        
        
           | 9760 | 
           nelberth | 
           607 | 
               }
  | 
        
        
            | 
            | 
           608 | 
              | 
        
        
            | 
            | 
           609 | 
              | 
        
        
           | 9904 | 
           nelberth | 
           610 | 
              | 
        
        
           | 9760 | 
           nelberth | 
           611 | 
              | 
        
        
            | 
            | 
           612 | 
              | 
        
        
            | 
            | 
           613 | 
           }
  |