XOOPS RMCommon Utilities  2.1.8.91RC
 All Classes Namespaces Files Functions Variables
imagecategory.php
Go to the documentation of this file.
1 <?php
2 // $Id: imagecategory.php 902 2012-01-03 07:09:16Z i.bitcero $
3 // --------------------------------------------------------------
4 // Red México Common Utilities
5 // A framework for Red México Modules
6 // Author: Eduardo Cortés <i.bitcero@gmail.com>
7 // Email: i.bitcero@gmail.com
8 // License: GPL 2.0
9 // --------------------------------------------------------------
10 
15 {
16  public function __construct($id=null){
17  $this->db = XoopsDatabaseFactory::getDatabaseConnection();
18  $this->_dbtable = $this->db->prefix("rmc_img_cats");
19  $this->setNew();
20  $this->initVarsFromTable();
21  $this->setVarType('groups', XOBJ_DTYPE_ARRAY);
22  $this->setVarType('sizes', XOBJ_DTYPE_ARRAY);
23  if ($id==null){
24  return;
25  }
26 
27  if ($this->loadValues($id)){
28  $this->unsetNew();
29  }
30 
31  }
32 
33  public function id(){
34  return $this->getVar('id_cat');
35  }
36 
37  public function save(){
38  if ($this->isNew()){
39  return $this->saveToTable();
40  } else {
41  return $this->updateTable();
42  }
43  }
44 
45  public function max_file_size(){
46  $size = $this->getVar('filesize') * $this->getVar('sizeunit');
47  return $size;
48  }
49 
55  public function user_allowed_toupload(XoopsUser $user){
56 
57  $groups = $user->getGroups();
58  $allowed = $this->getVar('groups');
59 
60  foreach ($groups as $id){
61  if (in_array($id, $allowed['write'])) return true;
62  }
63 
64  return false;
65  }
66 
67  public function delete(){
68  return $this->deleteFromTable();
69  }
70 
71 }