Ejemplo n.º 1
0
 public function itemHandler(BASE_CLASS_EventProcessCommentItem $e)
 {
     $language = OW::getLanguage();
     $deleteButton = false;
     $cAction = null;
     $value = $e->getItem();
     if ($this->isOwnerAuthorized || $this->isModerator || (int) OW::getUser()->getId() === (int) $value->getUserId()) {
         $deleteButton = true;
     }
     $flagButton = $value->getUserId() != OW::getUser()->getId();
     if ($this->isBaseModerator || $deleteButton || $flagButton) {
         $cAction = new BASE_CMP_ContextAction();
         $parentAction = new BASE_ContextAction();
         $parentAction->setKey('parent');
         $parentAction->setClass('ow_comments_context');
         $cAction->addAction($parentAction);
         if ($deleteButton) {
             $flagAction = new BASE_ContextAction();
             $flagAction->setLabel($language->text('base', 'contex_action_comment_delete_label'));
             $flagAction->setKey('udel');
             $flagAction->setParentKey($parentAction->getKey());
             $delId = 'del-' . $value->getId();
             $flagAction->setId($delId);
             $this->actionArr['comments'][$delId] = $value->getId();
             $cAction->addAction($flagAction);
         }
         if ($this->isBaseModerator && $value->getUserId() != OW::getUser()->getId()) {
             $modAction = new BASE_ContextAction();
             $modAction->setLabel($language->text('base', 'contex_action_user_delete_label'));
             $modAction->setKey('cdel');
             $modAction->setParentKey($parentAction->getKey());
             $delId = 'udel-' . $value->getId();
             $modAction->setId($delId);
             $this->actionArr['users'][$delId] = $value->getUserId();
             $cAction->addAction($modAction);
         }
         if ($flagButton) {
             $flagAction = new BASE_ContextAction();
             $flagAction->setLabel($language->text('base', 'flag'));
             $flagAction->setKey('cflag');
             $flagAction->setParentKey($parentAction->getKey());
             $flagAction->addAttribute("onclick", "var d = \$(this).data(); OW.flagContent(d.etype, d.eid);");
             $flagAction->addAttribute("data-etype", "comment");
             $flagAction->addAttribute("data-eid", $value->id);
             $cAction->addAction($flagAction);
         }
     }
     if ($this->params->getCommentPreviewMaxCharCount() > 0 && mb_strlen($value->getMessage()) > $this->params->getCommentPreviewMaxCharCount()) {
         $e->setDataProp('previewMaxChar', $this->params->getCommentPreviewMaxCharCount());
     }
     $e->setDataProp('cnxAction', empty($cAction) ? '' : $cAction->render());
 }
Ejemplo n.º 2
0
 public function itemHandler(BASE_CLASS_EventProcessCommentItem $e)
 {
     $language = OW::getLanguage();
     $deleteButton = false;
     $cAction = null;
     $value = $e->getItem();
     if ($this->isOwnerAuthorized || $this->isModerator || (int) OW::getUser()->getId() === (int) $value->getUserId()) {
         $deleteButton = true;
     }
     if ($this->isBaseModerator || $deleteButton) {
         $cAction = new BASE_CMP_ContextAction();
         $parentAction = new BASE_ContextAction();
         $parentAction->setKey('parent');
         $parentAction->setClass('ow_comments_context');
         $cAction->addAction($parentAction);
         if ($deleteButton) {
             $delAction = new BASE_ContextAction();
             $delAction->setLabel($language->text('base', 'contex_action_comment_delete_label'));
             $delAction->setKey('udel');
             $delAction->setParentKey($parentAction->getKey());
             $delId = 'del-' . $value->getId();
             $delAction->setId($delId);
             $this->actionArr['comments'][$delId] = $value->getId();
             $cAction->addAction($delAction);
         }
         if ($this->isBaseModerator && $value->getUserId() != OW::getUser()->getId()) {
             $modAction = new BASE_ContextAction();
             $modAction->setLabel($language->text('base', 'contex_action_user_delete_label'));
             $modAction->setKey('cdel');
             $modAction->setParentKey($parentAction->getKey());
             $delId = 'udel-' . $value->getId();
             $modAction->setId($delId);
             $this->actionArr['users'][$delId] = $value->getUserId();
             $cAction->addAction($modAction);
         }
     }
     $e->setDataProp('cnxAction', empty($cAction) ? '' : $cAction->render());
 }