Exemple #1
0
 /**
  * Returns class instance
  *
  * @return MODERATION_BOL_Service
  */
 public static function getInstance()
 {
     if (null === self::$classInstance) {
         self::$classInstance = new self();
     }
     return self::$classInstance;
 }
Exemple #2
0
 public function index()
 {
     $groups = MODERATION_BOL_Service::getInstance()->getContentGroups();
     if (OW::getRequest()->isPost()) {
         $selectedGroups = empty($_POST["groups"]) ? array() : $_POST["groups"];
         $types = array();
         foreach ($groups as $group) {
             $selected = in_array($group["name"], $selectedGroups);
             foreach ($group["entityTypes"] as $type) {
                 $types[$type] = $selected;
             }
         }
         OW::getConfig()->saveConfig("moderation", "content_types", json_encode($types));
         OW::getFeedback()->info(OW::getLanguage()->text("moderation", "content_types_saved_message"));
         $this->redirect(OW::getRouter()->urlForRoute("moderation.admin"));
     }
     $this->setPageHeading(OW::getLanguage()->text("moderation", "admin_heading"));
     $this->setPageTitle(OW::getLanguage()->text("moderation", "admin_title"));
     $form = new Form("contentTypes");
     $submit = new Submit("save");
     $submit->setLabel(OW::getLanguage()->text("admin", "save_btn_label"));
     $form->addElement($submit);
     $this->addForm($form);
     $this->assign("groups", $groups);
 }
Exemple #3
0
 public function responder($params)
 {
     if (!OW::getRequest()->isPost() || !OW::getUser()->isAuthenticated()) {
         throw new Redirect403Exception();
     }
     $data = $_POST;
     $data["items"] = empty($data["items"]) ? array() : $data["items"];
     list($command, $type) = explode(".", $data["command"]);
     $backUrl = empty($params["userId"]) ? OW::getRouter()->urlForRoute("moderation.approve", array("group" => $params["group"])) : OW::getRouter()->urlForRoute("moderation.user.approve", array("group" => $params["group"], "userId" => $params["userId"]));
     $itemKeys = $type == "single" ? array($data["item"]) : $data["items"];
     if (empty($itemKeys)) {
         OW::getFeedback()->warning(OW::getLanguage()->text("base", "moderation_no_items_warning"));
         $this->redirect($backUrl);
     }
     $itemIds = array();
     foreach ($itemKeys as $itemKey) {
         list($entityType, $entityId) = explode(":", $itemKey);
         $itemIds[$entityType] = empty($itemIds[$entityType]) ? array() : $itemIds[$entityType];
         $itemIds[$entityType][] = $entityId;
     }
     $affected = 0;
     $lastEntityType = null;
     foreach ($itemIds as $entityType => $entityIds) {
         if ($command == "delete") {
             $entityListToDelete = array();
             if (empty($params["userId"])) {
                 $entityListToDelete = $entityIds;
             } else {
                 $contentList = BOL_ContentService::getInstance()->getContentList($entityType, $entityIds);
                 foreach ($contentList as $entityId => $content) {
                     if ($content["userId"] == $params["userId"]) {
                         $entityListToDelete[] = $entityId;
                     }
                 }
             }
             BOL_ContentService::getInstance()->deleteContentList($entityType, $entityListToDelete);
         }
         if ($command == "approve") {
             BOL_ContentService::getInstance()->updateContentList($entityType, $entityIds, array("status" => BOL_ContentService::STATUS_ACTIVE));
         }
         MODERATION_BOL_Service::getInstance()->deleteEntityList($entityType, $entityIds);
         $lastEntityType = $entityType;
         $affected += count($entityIds);
     }
     // Feedback
     $assigns = array();
     $multiple = $affected > 1;
     if ($multiple) {
         $tmp = BOL_ContentService::getInstance()->getContentGroups();
         $groupInfo = $tmp[$params["group"]];
         $assigns["content"] = strtolower($groupInfo["label"]);
         $assigns["count"] = $affected;
     } else {
         $typeInfo = BOL_ContentService::getInstance()->getContentTypeByEntityType($lastEntityType);
         $assigns["content"] = $typeInfo["entityLabel"];
     }
     $feedbackKey = $command == "delete" ? "base+moderation_feedback_delete" : "moderation+feedback_approve";
     list($langPrefix, $langKey) = explode("+", $feedbackKey);
     OW::getFeedback()->info(OW::getLanguage()->text($langPrefix, $langKey . ($multiple ? "_multiple" : ""), $assigns));
     // Redirection
     $this->redirect($backUrl);
 }
Exemple #4
0
 public function approveEntity(OW_Event $event)
 {
     $params = $event->getParams();
     $data = $event->getData();
     $content = BOL_ContentService::getInstance()->getContent($params["entityType"], $params['entityId']);
     if (empty($content)) {
         $data["error"] = "Content not found";
         return;
     }
     $type = $content["typeInfo"];
     $authorized = OW::getUser()->isAdmin() || OW::getUser()->isAuthorized($type["authorizationGroup"]);
     if (!$authorized) {
         $data["error"] = "Not authorized";
         return;
     }
     BOL_ContentService::getInstance()->updateContentList($params["entityType"], array($params['entityId']), array("status" => BOL_ContentService::STATUS_ACTIVE));
     MODERATION_BOL_Service::getInstance()->deleteEntityList($params["entityType"], array($params['entityId']));
     $data["message"] = OW::getLanguage()->text("moderation", "feedback_approve", array("content" => $type["entityLabel"]));
     $event->setData($data);
     return $data;
 }
Exemple #5
0
<?php

$_entityList = MODERATION_BOL_Service::getInstance()->findAllEntityList();
$entityList = array();
foreach ($_entityList as $entity) {
    /* @var $entity MODERATION_BOL_Entity */
    $entityList[$entity->entityType] = empty($entityList[$entity->entityType]) ? array() : $entityList[$entity->entityType];
    $entityList[$entity->entityType][] = $entity->entityId;
}
foreach ($entityList as $entityType => $entityIds) {
    try {
        BOL_ContentService::getInstance()->updateContentList($entityType, $entityIds, array("status" => BOL_ContentService::STATUS_ACTIVE));
    } catch (Exception $ex) {
        // Pass
    }
}