Exemplo n.º 1
0
 public function cronUnpublishPage($oEvent)
 {
     $object_type = umiObjectTypesCollection::getInstance()->getTypeByGUID('root-pages-type');
     $field_id = $object_type->getFieldId("expiration_date");
     $sel = new umiSelection();
     $sel->addPropertyFilterLess($field_id, time());
     $sel->addPropertyFilterNotEqual($field_id, 0);
     $sel->addActiveFilter(true);
     $sel->forceHierarchyTable(true);
     $result = umiSelectionsParser::runSelection($sel);
     $res = array();
     foreach ($result as $key => $page_id) {
         $ePage = umiHierarchy::getInstance()->getElement($page_id, true);
         $ePage->setIsActive(false);
         $pageObject = $ePage->getObject();
         $pageObject->setValue("publish_status", $this->getPageStatusIdByStatusSid("page_status_unpublish"));
         $pageObject->commit();
         $ePage->commit();
         if (!($publishComments = $ePage->getValue("publish_comments"))) {
             $publishComments = "Отсутствуют.";
         }
         $user_id = $ePage->getObject()->getOwnerId();
         $oUser = umiObjectsCollection::getInstance()->getObject($user_id);
         if ($oUser instanceof umiObject && ($user_email = $oUser->getValue("e-mail"))) {
             //Составляем и посылаем сообщение пользователю
             $mail_message = new umiMail();
             $from = regedit::getInstance()->getVal("//settings/email_from");
             $mail_message->setFrom($from);
             $mail_message->setPriorityLevel("high");
             $mail_message->setSubject(getLabel('label-notification-expired-mail-header'));
             list($body) = def_module::loadTemplatesForMail("mail/expired", "body");
             $block['notify_header'] = getLabel('label-notification-expired-mail-header');
             $block['page_header'] = $ePage->getName();
             $block['publish_comments'] = $publishComments;
             $domain = domainsCollection::getInstance()->getDomain($ePage->getDomainId());
             $page_host = "http://" . $domain->getHost() . umiHierarchy::getInstance()->getPathById($page_id);
             $block['page_link'] = $page_host;
             $mail_html = def_module::parseTemplateForMail($body, $block, $page_id);
             $mail_message->addRecipient($user_email);
             $mail_message->setContent($mail_html);
             $mail_message->commit();
             $mail_message->send();
         }
     }
 }
Exemplo n.º 2
0
 public function getMessageLink($element_id = false)
 {
     $element_id = $this->analyzeRequiredPath($element_id);
     $per_page = $this->per_page;
     $curr_page = (int) getRequest('p');
     $element = umiHierarchy::getInstance()->getElement($element_id, true);
     if (!$element) {
         throw new publicException(getLabel('error-page-does-not-exist', null, ''));
     }
     $parent_id = $element->getParentId();
     $parent_element = umiHierarchy::getInstance()->getElement($parent_id);
     if (!$parent_element) {
         throw new publicException(getLabel('error-parent-does-not-exist', null, ''));
     }
     if ($element->getValue("publish_time")) {
         $publish_time = $element->getValue("publish_time")->getFormattedDate("U");
     }
     $sel = new umiSelection();
     $sel->setLimitFilter();
     $sel->addLimit($per_page, $curr_page);
     $sel->setElementTypeFilter();
     $topic_hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("forum", "message")->getId();
     $sel->addElementType($topic_hierarchy_type_id);
     $sel->setHierarchyFilter();
     $sel->addHierarchyFilter($parent_id);
     $object_type_id = umiObjectTypesCollection::getInstance()->getBaseType("forum", "message");
     $object_type = umiObjectTypesCollection::getInstance()->getType($object_type_id);
     $publish_time_field_id = $object_type->getFieldId('publish_time');
     $sel->setOrderFilter();
     $sel->setOrderByProperty($publish_time_field_id, true);
     $sel->setPropertyFilter();
     $sel->addPropertyFilterLess($publish_time_field_id, $publish_time);
     $sel->setPermissionsFilter();
     $sel->addPermissions();
     $total = umiSelectionsParser::runSelectionCounts($sel);
     $p = floor(($total - 1) / $this->per_page);
     if ($p < 0) {
         $p = 0;
     }
     return umiHierarchy::getInstance()->getPathById($parent_id) . "?p={$p}#" . $element_id;
 }
Exemplo n.º 3
0
 /**
  * Применение кастомной логики к объекту umiSelection
  *
  * @param umiSelection $selection Объект umiSelection
  */
 public function applyCustomCountFilters(&$selection)
 {
     $arCustomFilters = $this->customLogic->filters();
     $oType = umiObjectTypesCollection::getInstance()->getType($this->objectsTypeId);
     if (!$oType) {
         return;
     }
     foreach ($arCustomFilters as $arCustomFilter) {
         $iFieldId = $oType->getFieldId($arCustomFilter[0]);
         $sOperator = $arCustomFilter[1];
         $value = $arCustomFilter[2];
         switch ($sOperator) {
             case "eq":
                 $selection->addPropertyFilterEqual($iFieldId, $value);
                 break;
             case "noteq":
                 $selection->addPropertyFilterNotEqual($iFieldId, $value);
                 break;
             case "null":
                 $selection->addPropertyFilterIsNull($iFieldId);
                 break;
             case "notnull":
                 $selection->addPropertyFilterIsNotNull($iFieldId);
                 break;
             case "gt":
                 $selection->addPropertyFilterMore($iFieldId, $value);
                 break;
             case "lt":
                 $selection->addPropertyFilterLess($iFieldId, $value);
                 break;
             case "like":
                 $selection->addPropertyFilterLike($iFieldId, $value);
                 break;
         }
     }
 }