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

content/classes/class.ilObjMediaPool.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 
00036 require_once "classes/class.ilObject.php";
00037 require_once "classes/class.ilMetaData.php";
00038 require_once("classes/class.ilObjFolder.php");
00039 
00040 class ilObjMediaPool extends ilObject
00041 {
00042         var $tree;
00043 
00050         function ilObjMediaPool($a_id = 0,$a_call_by_reference = true)
00051         {
00052                 // this also calls read() method! (if $a_id is set)
00053                 $this->type = "mep";
00054                 $this->ilObject($a_id,$a_call_by_reference);
00055         }
00056 
00057         function read()
00058         {
00059                 parent::read();
00060                 $this->tree =& new ilTree($this->getId());
00061                 $this->tree->setTreeTablePK("mep_id");
00062                 $this->tree->setTableNames('mep_tree','object_data');
00063         }
00064 
00065 
00069         function create()
00070         {
00071                 parent::create();
00072 
00073                 // create media pool tree
00074                 $this->tree =& new ilTree($this->getId());
00075                 $this->tree->setTreeTablePK("mep_id");
00076                 $this->tree->setTableNames('mep_tree','object_data');
00077                 $this->tree->addTree($this->getId(), 1);
00078 
00079         }
00080 
00084         function &getTree()
00085         {
00086                 return $this->tree;
00087         }
00088 
00095         function update()
00096         {
00097                 if (!parent::update())
00098                 {
00099                         return false;
00100                 }
00101 
00102                 // put here object specific stuff
00103 
00104                 return true;
00105         }
00106 
00114         function ilClone($a_parent_ref)
00115         {
00116                 global $rbacadmin;
00117 
00118                 // always call parent ilClone function first!!
00119                 $new_ref_id = parent::ilClone($a_parent_ref);
00120 
00121                 // get object instance of ilCloned object
00122                 //$newObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id);
00123 
00124                 // create a local role folder & default roles
00125                 //$roles = $newObj->initDefaultRoles();
00126 
00127                 // ...finally assign role to creator of object
00128                 //$rbacadmin->assignUser($roles[0], $newObj->getOwner(), "n");
00129 
00130                 // always destroy objects in ilClone method because ilClone() is recursive and creates instances for each object in subtree!
00131                 //unset($newObj);
00132 
00133                 // ... and finally always return new reference ID!!
00134                 return $new_ref_id;
00135         }
00136 
00147         function delete()
00148         {
00149                 // always call parent delete function first!!
00150                 if (!parent::delete())
00151                 {
00152                         return false;
00153                 }
00154 
00155                 // get childs
00156                 $childs = $this->tree->getSubTree($this->tree->getNodeData($this->tree->readRootId()));
00157 
00158                 // delete tree
00159                 $this->tree->removeTree($this->tree->getTreeId());
00160 
00161                 // delete childs
00162                 foreach ($childs as $child)
00163                 {
00164                         switch ($child["type"])
00165                         {
00166                                 case "mob":
00167                                         include_once("content/classes/Media/class.ilObjMediaObject.php");
00168                                         $mob = new ilObjMediaObject($child["obj_id"]);
00169                                         $mob->delete();
00170                                         break;
00171 
00172                                 case "fold":
00173                                         include_once("classes/class.ilObjFolder.php");
00174                                         $fold = new ilObjFolder($child["obj_id"], false);
00175                                         $fold->delete();
00176                                         break;
00177                         }
00178                 }
00179 
00180 
00181 
00182                 return true;
00183         }
00184 
00194         function initDefaultRoles()
00195         {
00196                 global $rbacadmin;
00197 
00198                 // create a local role folder
00199                 //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
00200 
00201                 // create moderator role and assign role to rolefolder...
00202                 //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
00203                 //$roles[] = $roleObj->getId();
00204 
00205                 //unset($rfoldObj);
00206                 //unset($roleObj);
00207 
00208                 return $roles ? $roles : array();
00209         }
00210 
00224         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00225         {
00226                 global $tree;
00227 
00228                 switch ($a_event)
00229                 {
00230                         case "link":
00231 
00232                                 //var_dump("<pre>",$a_params,"</pre>");
00233                                 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
00234                                 //exit;
00235                                 break;
00236 
00237                         case "cut":
00238 
00239                                 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
00240                                 //exit;
00241                                 break;
00242 
00243                         case "copy":
00244 
00245                                 //var_dump("<pre>",$a_params,"</pre>");
00246                                 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
00247                                 //exit;
00248                                 break;
00249 
00250                         case "paste":
00251 
00252                                 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
00253                                 //exit;
00254                                 break;
00255 
00256                         case "new":
00257 
00258                                 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
00259                                 //exit;
00260                                 break;
00261                 }
00262 
00263                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
00264                 if ($a_node_id==$_GET["ref_id"])
00265                 {
00266                         $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00267                         $parent_type = $parent_obj->getType();
00268                         if($parent_type == $this->getType())
00269                         {
00270                                 $a_node_id = (int) $tree->getParentId($a_node_id);
00271                         }
00272                 }
00273 
00274                 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00275         }
00276 
00277 
00281         function getChilds($obj_id = "")
00282         {
00283                 if ($obj_id == "")
00284                 {
00285                         $obj_id = $this->tree->getRootId();
00286                 }
00287 
00288                 $objs = $this->tree->getChildsByType($obj_id, "fold");
00289                 $mobs = $this->tree->getChildsByType($obj_id, "mob");
00290                 foreach($mobs as $key => $mob)
00291                 {
00292                         $objs[] = $mob;
00293                 }
00294 
00295                 return $objs;
00296         }
00297 
00298         function getParentId($obj_id = "")
00299         {
00300                 if ($obj_id == "")
00301                 {
00302                         return false;
00303                 }
00304                 if ($obj_id == $this->tree->getRootId())
00305                 {
00306                         return false;
00307                 }
00308 
00309                 return $this->tree->getParentId($obj_id);
00310         }
00311         
00312         function insertInTree($a_obj_id, $a_parent = "")
00313         {
00314                 if (!$this->tree->isInTree($a_obj_id))
00315                 {
00316                         $parent = ($a_parent == "")
00317                                 ? $this->tree->getRootId()
00318                                 : $a_parent;
00319                         $this->tree->insertNode($a_obj_id, $parent);
00320                         return true;
00321                 }
00322                 else
00323                 {
00324                         return false;
00325                 }
00326         }
00327 
00328 
00329         function deleteChild($obj_id)
00330         {
00331                 $type = ilObject::_lookupType($obj_id);
00332                 $title = ilObject::_lookupTitle($obj_id);
00333 
00334 
00335                 $node_data = $this->tree->getNodeData($obj_id);
00336                 $subtree = $this->tree->getSubtree($node_data);
00337 
00338                 // delete tree
00339                 if($this->tree->isInTree($obj_id))
00340                 {
00341                         $this->tree->deleteTree($node_data);
00342                 }
00343 
00344                 // delete objects
00345                 foreach ($subtree as $node)
00346                 {
00347                         if ($node["type"] == "mob")
00348                         {
00349                                 $obj =& new ilObjMediaObject($node["child"]);
00350                                 $obj->delete();
00351                         }
00352 
00353                         if ($node["type"] == "fold")
00354                         {
00355                                 $obj =& new ilObjFolder($node["child"], false);
00356                                 $obj->delete();
00357                         }
00358                 }
00359         }
00360 }
00361 ?>

Generated on Fri Dec 13 2013 09:06:36 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1