XOOPS  2.6.0
category.php
Go to the documentation of this file.
1 <?php
2 /*
3  You may not change or alter any portion of this comment or credits
4  of supporting developers from this source code or any supporting source code
5  which is considered copyrighted (c) material of the original comment or credit authors.
6 
7  This program is distributed in the hope that it will be useful,
8  but WITHOUT ANY WARRANTY; without even the implied warranty of
9  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 */
11 
18 
28 {
32  public function __construct()
33  {
34  $this->initVar('imgcat_id', XOBJ_DTYPE_INT, 0, false, 5);
35  $this->initVar('imgcat_name', XOBJ_DTYPE_TXTBOX, '', true, 100);
36  $this->initVar('imgcat_maxsize', XOBJ_DTYPE_INT, 100000, false, 8);
37  $this->initVar('imgcat_maxwidth', XOBJ_DTYPE_INT, 128, false, 3);
38  $this->initVar('imgcat_maxheight', XOBJ_DTYPE_INT, 128, false, 3);
39  $this->initVar('imgcat_display', XOBJ_DTYPE_INT, 1, false, 1);
40  $this->initVar('imgcat_weight', XOBJ_DTYPE_INT, 0, false, 3);
41  $this->initVar('imgcat_type', XOBJ_DTYPE_TXTBOX, '', true, 1);
42  $this->initVar('imgcat_storetype', XOBJ_DTYPE_TXTBOX, 'file', true, 5);
43  }
44 }
45 
47 {
53  public function __construct(Connection $db = null)
54  {
55  parent::__construct($db, 'imagecategory', 'ImagesCategory', 'imgcat_id', 'imgcat_name');
56  }
57 
64  public function getPermittedObjects($criteria = null, $start = 0, $limit = 0, $id_as_key = false, $asobject = true)
65  {
66  $this->table_link = $this->db2->prefix('group_permission');
67 
68  if (isset($criteria)) {
70  } else {
71  $criteria = new CriteriaCompo();
72  }
73  $criteria->setSort('o.imgcat_weight, o.imgcat_id');
74  $criteria->setOrder('ASC');
75  $criteria->setStart($start);
76  $criteria->setLimit($limit);
77 
78  return parent::getByLink($criteria, null, $asobject, 'gperm_itemid', 'imgcat_id');
79  }
80 
91  public function getListByPermission($groups = array(), $perm = 'imgcat_read', $display = null, $storetype = null)
92  {
94  $criteria = new CriteriaCompo();
95  if (is_array($groups) && !empty($groups)) {
96  $criteriaTray = new CriteriaCompo();
97  foreach ($groups as $gid) {
98  $criteriaTray->add(new Criteria('gperm_groupid', $gid), 'OR');
99  }
100  $criteria->add($criteriaTray);
101  if ($perm == 'imgcat_read' || $perm == 'imgcat_write') {
102  $criteria->add(new Criteria('gperm_name', $perm));
103  $mid = $xoops->getModuleByDirName('images')->getVar('mid');
104  $criteria->add(new Criteria('gperm_modid', $mid));
105  }
106  }
107  if (isset($display)) {
108  $criteria->add(new Criteria('imgcat_display', intval($display)));
109  }
110  if (isset($storetype)) {
111  $criteria->add(new Criteria('imgcat_storetype', $storetype));
112  }
113  $categories = $this->getPermittedObjects($criteria, 0, 0, true);
114  $ret = array();
115  foreach (array_keys($categories) as $i) {
116  $ret[$i] = $categories[$i]->getVar('imgcat_name');
117  }
118  return $ret;
119  }
120 }
$mid
Definition: index.php:39
$i
Definition: dialog.php:68
static getInstance()
Definition: Xoops.php:160
getListByPermission($groups=array(), $perm= 'imgcat_read', $display=null, $storetype=null)
Definition: category.php:91
$xoops
Definition: admin.php:25
__construct(Connection $db=null)
Definition: category.php:53
$groups
$limit
Definition: findusers.php:202
$criteria
$start
initVar($key, $data_type, $value=null, $required=false, $maxlength=null, $options= '')
getPermittedObjects($criteria=null, $start=0, $limit=0, $id_as_key=false, $asobject=true)
Definition: category.php:64