Beispiel #1
0
 public static function getListByTemplateDependency($templateId, $parameters)
 {
     $templateId = intval($templateId);
     if (!$templateId) {
         // getter should not throw any exception on bad parameters
         return new \Bitrix\Main\DB\ArrayResult(array());
     }
     if (!is_array($parameters)) {
         $parameters = array();
     }
     if (!is_array($parameters['filter'])) {
         $parameters['filter'] = array();
     }
     $parameters['filter']['@TEMPLATE_ID'] = new \Bitrix\Main\DB\SqlExpression(\Bitrix\Tasks\Template\DependencyTable::getSubTreeSql($templateId));
     return static::getList($parameters);
 }
Beispiel #2
0
 function GetFilter($arFilter, $arParams)
 {
     if (!is_array($arFilter)) {
         $arFilter = array();
     }
     $arSqlSearch = array();
     foreach ($arFilter as $key => $val) {
         $res = CTasks::MkOperationFilter($key);
         $key = $res["FIELD"];
         $cOperationType = $res["OPERATION"];
         $key = strtoupper($key);
         switch ($key) {
             case "CREATED_BY":
             case "TASK_ID":
             case "TPARAM_TYPE":
             case "ID":
                 $arSqlSearch[] = CTasks::FilterCreate("TT." . $key, $val, "number", $bFullJoin, $cOperationType);
                 break;
             case "RESPONSIBLE":
                 $arSqlSearch[] = CTasks::FilterCreate("TT.RESPONSIBLE_ID", $val, "number", $bFullJoin, $cOperationType);
                 break;
             case "TITLE":
                 $arSqlSearch[] = CTasks::FilterCreate("TT." . $key, $val, "string", $bFullJoin, $cOperationType);
                 break;
             case "PRIORITY":
                 $arSqlSearch[] = CTasks::FilterCreate("TT." . $key, $val, "string_equal", $bFullJoin, $cOperationType);
                 break;
                 /*
                 case "TEMPLATE_CHILDREN_COUNT":
                 	$arSqlSearch[] = CTasks::FilterCreate($key, $val, "number", $bFullJoin, $cOperationType);
                 	break;
                 */
             /*
             case "TEMPLATE_CHILDREN_COUNT":
             	$arSqlSearch[] = CTasks::FilterCreate($key, $val, "number", $bFullJoin, $cOperationType);
             	break;
             */
             case "BASE_TEMPLATE_ID":
                 $parentColumnName = Template\DependencyTable::getPARENTIDColumnName();
                 $columnName = Template\DependencyTable::getIDColumnName();
                 $cOperationType = 'I';
                 // force to "identical" for this field, in any case
                 $val = (string) $val;
                 if ($val === '' || $val === '0') {
                     $val = false;
                 }
                 //$includeSubtree = 		$arParams['INCLUDE_TEMPLATE_SUBTREE'] === true || $arParams['INCLUDE_TEMPLATE_SUBTREE'] === 'Y';
                 $excludeSubtree = $arParams['EXCLUDE_TEMPLATE_SUBTREE'] === true || $arParams['EXCLUDE_TEMPLATE_SUBTREE'] === 'Y';
                 if ($excludeSubtree) {
                     $arSqlSearch[] = "TT.ID NOT IN (SELECT " . $columnName . " FROM " . Template\DependencyTable::getTableName() . " WHERE " . $parentColumnName . " = '" . intval($val) . "')";
                 } else {
                     $arSqlSearch[] = '(' . ($val ? "TD." . $parentColumnName . " = '" . intval($val) . "'" : "TD." . $parentColumnName . " = '0' OR TD." . $parentColumnName . " IS NULL") . ')';
                     //$arSqlSearch[] = CTasks::FilterCreate("TD.".Template\DependencyTable::getPARENTIDColumnName(), $val, "number", $bFullJoin, $cOperationType);
                 }
                 break;
         }
     }
     return $arSqlSearch;
 }