• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilRoleDesktopItem.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00037 class ilRoleDesktopItem
00038 {
00039         var $db;
00040         var $role_id;
00041  
00046         function ilRoleDesktopItem($a_role_id)
00047         {
00048                 global $ilDB;
00049 
00050                 $this->db =& $ilDB;
00051                 $this->role_id = $a_role_id;
00052         }
00053 
00054         function getRoleId()
00055         {
00056                 return $this->role_id;
00057         }
00058         function setRoleId($a_role_id)
00059         {
00060                 $this->role_id = $a_role_id;
00061         }
00062 
00063         function add($a_item_id,$a_item_type)
00064         {
00065                 global $ilDB;
00066                 
00067                 if($a_item_type and $a_item_id)
00068                 {
00069                         $query = "INSERT INTO role_desktop_items ".
00070                                 "SET role_id = ".$ilDB->quote($this->getRoleId()).", ".
00071                                 "item_id = ".$ilDB->quote($a_item_id).", ".
00072                                 "item_type = ".$ilDB->quote($a_item_type);
00073 
00074                         $this->db->query($query);
00075 
00076                         $this->__assign($a_item_id,$a_item_type);
00077                         
00078                         return true;
00079                 }
00080                 return false;
00081         }
00082         function delete($a_role_item_id)
00083         {
00084                 global $ilDB;
00085                 
00086                 $query = "DELETE FROM role_desktop_items ".
00087                         "WHERE role_item_id = ".$ilDB->quote($a_role_item_id);
00088 
00089                 $this->db->query($query);
00090 
00091                 return true;
00092         }
00093 
00094         function deleteAll()
00095         {
00096                 global $ilDB;
00097                 
00098                 $query = "DELETE FROM role_desktop_items ".
00099                         "WHERE role_id = ".$ilDB->quote($this->getRoleId());
00100 
00101                 $this->db->query($query);
00102 
00103                 return true;
00104         }
00105 
00106         function isAssigned($a_item_ref_id)
00107         {
00108                 global $ilDB;
00109                 
00110                 $query = "SELECT * FROM role_desktop_items ".
00111                         "WHERE role_id = ".$ilDB->quote($this->getRoleId())." ".
00112                         "AND item_id = ".$ilDB->quote($a_item_ref_id)." ";
00113 
00114                 $res = $this->db->query($query);
00115 
00116                 return $res->numRows() ? true : false;
00117         }
00118 
00119         function getItem($a_role_item_id)
00120         {
00121                 global $ilDB;
00122                 
00123                 $query = "SELECT * FROM role_desktop_items ".
00124                         "WHERE role_id = ".$ilDB->quote($this->getRoleId())." ".
00125                         "AND role_item_id = ".$ilDB->quote($a_role_item_id)." ";
00126 
00127                 $res = $this->db->query($query);
00128                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00129                 {
00130                         $item['item_id'] = $row->item_id;
00131                         $item['item_type'] = $row->item_type;
00132                 }
00133 
00134                 return $item ? $item : array();
00135         }
00136 
00137 
00138 
00139         function getAll()
00140         {
00141                 global $tree;
00142 
00143                 $query = "SELECT * FROM role_desktop_items ".
00144                         "WHERE role_id = ".$this->db->quote($this->getRoleId())." ";
00145 
00146                 $res = $this->db->query($query);
00147                 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00148                 {
00149                         // TODO this check must be modified for non tree objects
00150                         if(!$tree->isInTree($row->item_id))
00151                         {
00152                                 $this->delete($row->role_item_id);
00153                                 continue;
00154                         }
00155                         $items[$row->role_item_id]['item_id'] = $row->item_id;
00156                         $items[$row->role_item_id]['item_type'] = $row->item_type;
00157                 }
00158 
00159                 return $items ? $items : array();
00160         }
00161 
00162         // PRIVATE
00163         function __assign($a_item_id,$a_item_type)
00164         {
00165                 global $rbacreview;
00166 
00167                 foreach($rbacreview->assignedUsers($this->getRoleId()) as $user_id)
00168                 {
00169                         if(is_object($tmp_user = ilObjectFactory::getInstanceByObjId($user_id,false)))
00170                         {
00171                                 if(!$tmp_user->isDesktopItem($a_item_id,$a_item_type))
00172                                 {
00173                                         $tmp_user->addDesktopItem($a_item_id,$a_item_type);
00174                                 }
00175                         }
00176                 }
00177                 return true;
00178         }
00179 }
00180 ?>

Generated on Fri Dec 13 2013 17:56:48 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1