Ejemplo n.º 1
0
 public function Send()
 {
     if (!$this->IsAvailable()) {
         return false;
     }
     $arNotification = $this->Notify->getNotification();
     //No need to send about updates;
     if ($arNotification["ACTION"] == "UPDATE") {
         return 0;
     }
     $category = ToUpper($arNotification["CATEGORY"]);
     $arEmailSubscribe = array();
     if (!array_key_exists("CATEGORIES", $arNotification)) {
         $arNotification["CATEGORIES"] = \CIdeaManagment::getInstance()->Idea()->GetCategoryList();
     }
     if (array_key_exists($category, $arNotification["CATEGORIES"]) && \CIdeaManagment::getInstance()->Idea()->GetCategoryListID() > 0) {
         $category = $arNotification["CATEGORIES"][$category];
     } else {
         $category = null;
     }
     if ($arNotification["TYPE"] == "IDEA") {
         $filter = array("LOGIC" => "OR", array("=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY, "=ENTITY_CODE" => ''));
         if (!is_null($category)) {
             $filter[] = array("=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY, "=ASCENDED_CATEGORIES.IBLOCK_ID" => \CIdeaManagment::getInstance()->Idea()->GetCategoryListID(), "<=ASCENDED_CATEGORIES.DEPTH_LEVEL" => $category["DEPTH_LEVEL"], "<=ASCENDED_CATEGORIES.LEFT_MARGIN" => $category["LEFT_MARGIN"], ">=ASCENDED_CATEGORIES.RIGHT_MARGIN" => $category["RIGHT_MARGIN"]);
         }
     } else {
         $filter = array("LOGIC" => "OR", array("=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_IDEA, "=ENTITY_CODE" => $arNotification["POST_ID"]), array("=SUBSCRIBE_TYPE" => \Bitrix\Idea\NotifyEmailTable::SUBSCRIBE_TYPE_ALL, "=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY, "=ENTITY_CODE" => ''));
         if (!is_null($category)) {
             $filter[] = array("=SUBSCRIBE_TYPE" => \Bitrix\Idea\NotifyEmailTable::SUBSCRIBE_TYPE_ALL, "=ENTITY_TYPE" => \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY, "=ASCENDED_CATEGORIES.IBLOCK_ID" => \CIdeaManagment::getInstance()->Idea()->GetCategoryListID(), "<=ASCENDED_CATEGORIES.DEPTH_LEVEL" => $category["DEPTH_LEVEL"], "<=ASCENDED_CATEGORIES.LEFT_MARGIN" => $category["LEFT_MARGIN"], ">=ASCENDED_CATEGORIES.RIGHT_MARGIN" => $category["RIGHT_MARGIN"]);
         }
     }
     $db_res = \Bitrix\Idea\NotifyEmailTable::getList(array('filter' => $filter, 'select' => array("USER_ID", "USER_EMAIL" => "USER.EMAIL")));
     if (!is_null($category)) {
         $arNotification["CATEGORY"] = $category["NAME"];
     }
     unset($arNotification["CATEGORIES"]);
     if (!array_key_exists("IDEA_TITLE", $arNotification)) {
         $arNotification["IDEA_TITLE"] = $arNotification["TITLE"];
     }
     while ($r = $db_res->Fetch()) {
         if ($r["USER_ID"] != $arNotification["AUTHOR_ID"] && !array_key_exists($r["USER_ID"], $arEmailSubscribe) && check_email($r["USER_EMAIL"])) {
             $arEmailSubscribe[$r["USER_ID"]] = $r["USER_EMAIL"];
             $arNotification["EMIAL_TO"] = $r["USER_EMAIL"];
             //This is for backward compatibility
             $arNotification["EMAIL_TO"] = $r["USER_EMAIL"];
             //ADD_IDEA_COMMENT, ADD_IDEA
             CEvent::Send($arNotification["ACTION"] . '_' . $arNotification["TYPE"], SITE_ID, $arNotification);
         }
     }
     return count($arEmailSubscribe) > 0;
 }
Ejemplo n.º 2
0
 public function getAscendedCategories($category = null, $userId = null)
 {
     $return = false;
     $userId = $userId === null ? $this->userID : $userId;
     if ($this->IblockID > 0 && $userId > 0) {
         $cache = $this->checkCache($userId, array("CATEGORY" => $category));
         if (!!$cache) {
             $return = $cache;
         } else {
             if (empty($category)) {
                 $return = array();
                 $db_res = NotifyEmailTable::getList(array("filter" => array("USER_ID" => $userId, "=ENTITY_TYPE" => NotifyEmailTable::ENTITY_TYPE_CATEGORY, "=ENTITY_CODE" => NULL)));
                 while ($res = $db_res->fetch()) {
                     array_push($return, $res);
                 }
             } else {
                 if (is_string($category) && ($categories = \CIdeaManagment::getInstance()->idea()->getCategoryList()) && !empty($categories)) {
                     $category = ToUpper($category);
                     if (array_key_exists($category, $categories)) {
                         $return = array();
                         $category = $categories[$category];
                         $db_res = NotifyEmailTable::getList(array("filter" => array("=USER_ID" => $userId, "=ENTITY_TYPE" => NotifyEmailTable::ENTITY_TYPE_CATEGORY, "=ASCENDED_CATEGORIES.IBLOCK_ID" => \CIdeaManagment::getInstance()->idea()->getCategoryListID(), "<=ASCENDED_CATEGORIES.DEPTH_LEVEL" => $category["DEPTH_LEVEL"], "<=ASCENDED_CATEGORIES.LEFT_MARGIN" => $category["LEFT_MARGIN"], ">=ASCENDED_CATEGORIES.RIGHT_MARGIN" => $category["RIGHT_MARGIN"])));
                         while ($res = $db_res->fetch()) {
                             array_push($return, $res);
                         }
                     }
                 }
             }
         }
         $this->setCache($userId, array("CATEGORY" => $category), $return);
     }
     return $return;
 }
Ejemplo n.º 3
0
            }
            LocalRedirect($APPLICATION->GetCurPageParam("", array("ACTION", "ID", "ENTITY_TYPE", "ENTITY_CODE", "sessid")));
            break;
    }
}
$arResult = array("USER_ID" => $USER->GetID(), "IDEA" => array(), "SUBSCRIBE" => array(), "IDEA_STATUS" => array(), "GRID" => array());
//Get Idea subscribtion
if ($arResult["USER_ID"] > 0) {
    //InitGrid
    $GridOptions = new CGridOptions($arResult["GRID_ID"]);
    //Grid Sort
    $arSort = $GridOptions->GetSorting(array("sort" => array("DATE_PUBLISH" => "DESC"), "vars" => array("by" => "by", "order" => "order")));
    $arResult["GRID"]["SORT"] = $arSort["sort"];
    $arResult["GRID"]["SORT_VARS"] = $arSort["vars"];
    $arNav = $GridOptions->GetNavParams(array("nPageSize" => 25));
    $db_res = \Bitrix\Idea\NotifyEmailTable::getList(array('filter' => array("USER_ID" => $arResult["USER_ID"]), 'select' => array("ID" => "RUNTIME_ID", "SUBSCRIBE_TYPE", "ENTITY_TYPE", "ENTITY_CODE", "CATEGORY_NAME" => "ASCENDED_CATEGORIES.NAME"), 'order' => array("ENTITY_TYPE" => "ASC", "ENTITY_CODE" => "ASC"), 'runtime' => array(new \Bitrix\Main\Entity\ExpressionField('RUNTIME_ID', \Bitrix\Main\Application::getConnection()->getSqlHelper()->getConcatFunction("CASE " . "WHEN %s='" . \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_IDEA . "' AND %s='' THEN '" . CIdeaManagmentEmailNotify::SUBSCRIBE_ALL . "' " . "WHEN %s='" . \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_IDEA . "' THEN '" . CIdeaManagmentEmailNotify::SUBSCRIBE_IDEA_COMMENT . "' " . "WHEN %s='" . \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY . "' AND %s='' THEN '" . CIdeaManagmentEmailNotify::SUBSCRIBE_ALL_IDEA . "' " . "WHEN %s='" . \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY . "' THEN '" . \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY . "' " . "ELSE 'UNK' END", "%s"), array("ENTITY_TYPE", "ENTITY_CODE", "ENTITY_TYPE", "ENTITY_TYPE", "ENTITY_CODE", "ENTITY_TYPE", "ENTITY_CODE")))));
    $oIdeaSubscribe = new CDBResult($db_res);
    $oIdeaSubscribe->NavStart($arNav["nPageSize"], false);
    //Select Subscribe
    $arBlogPostId = array();
    while ($r = $oIdeaSubscribe->Fetch()) {
        $arResult["SUBSCRIBE"][] = $r["ID"];
        if ($r["ID"] == CIdeaManagmentEmailNotify::SUBSCRIBE_ALL) {
            $arResult["IDEA"] = array(CIdeaManagmentEmailNotify::SUBSCRIBE_ALL => $r + array("TITLE" => GetMessage("IDEA_SUBSCRIBE_ALL_SUBSCRIBED"), "ID" => CIdeaManagmentEmailNotify::SUBSCRIBE_ALL)) + $arResult["IDEA"];
        } else {
            if ($r["ID"] == CIdeaManagmentEmailNotify::SUBSCRIBE_ALL_IDEA) {
                $arResult["IDEA"] = array(CIdeaManagmentEmailNotify::SUBSCRIBE_ALL_IDEA => $r + array("TITLE" => GetMessage("IDEA_SUBSCRIBE_ALL_IDEA_SUBSCRIBED"), "ID" => CIdeaManagmentEmailNotify::SUBSCRIBE_ALL_IDEA)) + $arResult["IDEA"];
            } else {
                if ($r["ENTITY_TYPE"] == \Bitrix\Idea\NotifyEmailTable::ENTITY_TYPE_CATEGORY) {
                    $arResult["IDEA"][$r["ID"]] = $r + array("TITLE" => !!$r["CATEGORY_NAME"] ? $r["CATEGORY_NAME"] : GetMessage("IDEA_SUBSCRIBE_NOT_FOUND_2", array("#CODE#" => $r["ENTITY_CODE"])));
                } else {