Exemplo n.º 1
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.º 2
0
 public function autoDetectOrders(umiSelection $sel, $object_type_id)
 {
     if (array_key_exists("order_filter", $_REQUEST)) {
         $sel->setOrderFilter();
         $type = umiObjectTypesCollection::getInstance()->getType($object_type_id);
         $order_filter = getRequest('order_filter');
         foreach ($order_filter as $field_name => $direction) {
             if ($direction === "asc") {
                 $direction = true;
             }
             if ($direction === "desc") {
                 $direction = false;
             }
             if ($field_name == "name") {
                 $sel->setOrderByName((bool) $direction);
                 continue;
             }
             if ($field_name == "ord") {
                 $sel->setOrderByOrd((bool) $direction);
                 continue;
             }
             if ($type) {
                 if ($field_id = $type->getFieldId($field_name)) {
                     $sel->setOrderByProperty($field_id, (bool) $direction);
                 } else {
                     continue;
                 }
             }
         }
     } else {
         return false;
     }
 }
Exemplo n.º 3
0
 public function collectAllChanges($module, $method, $parentElementId = false)
 {
     $endTime = time();
     $beginTime = $endTime - 3600 * 24 * 30;
     $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName($module, $method)->getId();
     $object_type_id = umiObjectTypesCollection::getInstance()->getBaseType($module, $method);
     $object_type = umiObjectTypesCollection::getInstance()->getType($object_type_id);
     $publish_time_field_id = $object_type->getFieldId('publish_time');
     $sel = new umiSelection();
     $sel->setElementTypeFilter();
     $sel->addElementType($hierarchy_type_id);
     $sel->setPermissionsFilter();
     $sel->addPermissions();
     $sel->setOrderFilter();
     $sel->setOrderByProperty($publish_time_field_id, false);
     $sel->setPropertyFilter();
     $sel->addPropertyFilterBetween($publish_time_field_id, $beginTime, $endTime);
     if ($parentElementId !== false) {
         if (!is_numeric($parentElementId)) {
             $parentElementId = umiHierarchy::getInstance()->getIdByPath($parentElementId);
         }
         $sel->setHierarchyFilter();
         $sel->addHierarchyFilter($parentElementId);
     }
     $result = umiSelectionsParser::runSelection($sel);
     $total = umiSelectionsParser::runSelectionCounts($sel);
     $res = array();
     foreach ($result as $elementId) {
         $childs = sizeof(umiHierarchy::getInstance()->getChilds($elementId));
         $res[] = array("id" => $elementId, "childs" => $childs);
     }
     return array("result" => $res, "total" => $total);
 }
Exemplo n.º 4
0
 public function insertlast($template = "default")
 {
     if (!$template) {
         $template = "default";
     }
     $type_id = umiObjectTypesCollection::getInstance()->getBaseType("vote", "poll");
     $type = umiObjectTypesCollection::getInstance()->getType($type_id);
     $time_field_id = $type->getFieldId("publish_time");
     $hierarchy_type_id = umiHierarchyTypesCollection::getInstance()->getTypeByName("vote", "poll")->getId();
     $sel = new umiSelection();
     $sel->setHierarchyFilter();
     $sel->addElementType($hierarchy_type_id);
     $sel->setLimitFilter();
     $sel->addLimit(1);
     $sel->setOrderFilter();
     $sel->setOrderByProperty($time_field_id, false);
     $sel->addPermissions();
     $sel->forceHierarchyTable();
     $result = umiSelectionsParser::runSelection($sel);
     if (sizeof($result)) {
         list($element_id) = $result;
     } else {
         $element_id = false;
     }
     if ($element_id) {
         return $this->poll($element_id, $template);
     }
 }