25 const CONDITION_UPLOAD = 1;
26 const CONDITION_RANGE = 2;
27 const CONDITION_PLAIN_FILES = 3;
36 $dbViewQuery = self::getUploadTreeView($itemTreeBounds, $constraints);
37 parent::__construct($dbViewQuery,
'UploadTreeView' . ($viewSuffix ?
'.' . $viewSuffix :
''));
48 $isDefaultTable = $uploadTreeTableName ==
'uploadtree_a' || $uploadTreeTableName ==
'uploadtree';
49 if ($isDefaultTable) {
50 $constraints[] = self::CONDITION_UPLOAD;
52 $baseQuery =
"SELECT * FROM $uploadTreeTableName";
53 $condition = self::getConstraintsCondition($itemTreeBounds, $constraints);
54 return $baseQuery . $condition;
57 private static function getConstraintsCondition(
ItemTreeBounds $itemTreeBounds, $constraints)
59 $conditions = array();
60 foreach (array_unique($constraints) as $constraint) {
61 $conditions[] = self::getConstraintCondition($itemTreeBounds, $constraint);
63 $condition = implode(
' AND ', $conditions);
64 return $condition ?
' WHERE ' . $condition :
'';
67 private static function getConstraintCondition(
ItemTreeBounds $itemTreeBounds, $constraint)
69 switch ($constraint) {
70 case self::CONDITION_UPLOAD:
72 return "upload_fk = $uploadId";
73 case self::CONDITION_RANGE:
74 $left = $itemTreeBounds->
getLeft();
75 $right = $itemTreeBounds->
getRight();
76 return "lft BETWEEN $left AND $right";
77 case self::CONDITION_PLAIN_FILES:
78 return '((ufile_mode & (3<<28))=0) AND pfile_fk != 0';
80 throw new \InvalidArgumentException(
"constraint $constraint is not defined");
static getUploadTreeView(ItemTreeBounds $itemTreeBounds, $constraints)
__construct(ItemTreeBounds $itemTreeBounds, $constraints=array(), $viewSuffix=null)