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

Modules/ExternalFeed/classes/class.ilObjExternalFeed.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 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 require_once "./classes/class.ilObject.php";
00025 
00033 class ilObjExternalFeed extends ilObject
00034 {
00041         function ilObjExternalFeed($a_id = 0,$a_call_by_reference = true)
00042         {
00043                 $this->type = "feed";
00044                 $this->ilObject($a_id,$a_call_by_reference);
00045         }
00046 
00053         function update()
00054         {
00055                 if (!parent::update())
00056                 {                       
00057                         return false;
00058                 }
00059 
00060                 // put here object specific stuff
00061 
00062                 return true;
00063         }
00064 
00073         public function cloneObject($a_target_id,$a_copy_id = 0)
00074         {
00075                 global $ilDB, $ilLog;
00076                 
00077                 $new_obj = parent::cloneObject($a_target_id,$a_copy_id);
00078                 $fb = $this->getFeedBlock();
00079                 
00080                 include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
00081                 $new_feed_block = new ilExternalFeedBlock();
00082                 $new_feed_block->setContextObjId($new_obj->getId());
00083                 $new_feed_block->setContextObjType("feed");
00084 
00085                 if (is_object($fb))
00086                 {
00087                         $new_feed_block->setFeedUrl($fb->getFeedUrl());
00088                         $new_feed_block->setTitle($fb->getTitle());
00089                 }
00090                 $new_feed_block->create();
00091 
00092                 return $new_obj;
00093         }
00094 
00101         function delete()
00102         {               
00103                 // always call parent delete function first!!
00104                 if (!parent::delete())
00105                 {
00106                         return false;
00107                 }
00108                 
00109                 //put here your module specific stuff
00110                 
00111                 // delete feed block
00112                 include_once("./Services/Block/classes/class.ilCustomBlock.php");
00113                 $costum_block = new ilCustomBlock();
00114                 $costum_block->setContextObjId($this->getId());
00115                 $costum_block->setContextObjType($this->getType());
00116                 $c_blocks = $costum_block->queryBlocksForContext();
00117                 
00118                 include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
00119                 foreach($c_blocks as $c_block)          // should be usually only one
00120                 {
00121                         if ($c_block["type"] == "feed")
00122                         {
00123                                 $fb = new ilExternalFeedBlock($c_block["id"]);
00124                                 $fb->delete();
00125                                 include_once("./Services/Block/classes/class.ilBlockSetting.php");
00126                                 ilBlockSetting::_deleteSettingsOfBlock($c_block["id"], "feed");
00127                         }
00128                 }
00129 
00130                 //ilBlockSetting::_lookupSide($type, $user_id, $c_block["id"]);
00131                 
00132                 return true;
00133         }
00134 
00135         function getFeedBlock()
00136         {
00137                 global $ilLog;
00138                 
00139                 // delete feed block
00140                 include_once("./Services/Block/classes/class.ilCustomBlock.php");
00141                 $costum_block = new ilCustomBlock();
00142                 $costum_block->setContextObjId($this->getId());
00143                 $costum_block->setContextObjType($this->getType());
00144                 $c_blocks = $costum_block->queryBlocksForContext();
00145                 
00146                 include_once("./Services/Block/classes/class.ilExternalFeedBlock.php");
00147                 foreach($c_blocks as $c_block)          // should be usually only one
00148                 {
00149                         if ($c_block["type"] == "feed")
00150                         {
00151                                 $fb = new ilExternalFeedBlock($c_block["id"]);
00152                                 return $fb;
00153                         }
00154                 }
00155 
00156                 return false;
00157         }
00158         
00168         function initDefaultRoles()
00169         {
00170                 global $rbacadmin;
00171                 
00172                 // create a local role folder
00173                 //$rfoldObj = $this->createRoleFolder("Local roles","Role Folder of forum obj_no.".$this->getId());
00174 
00175                 // create moderator role and assign role to rolefolder...
00176                 //$roleObj = $rfoldObj->createRole("Moderator","Moderator of forum obj_no.".$this->getId());
00177                 //$roles[] = $roleObj->getId();
00178 
00179                 //unset($rfoldObj);
00180                 //unset($roleObj);
00181 
00182                 return $roles ? $roles : array();
00183         }
00184 
00198         function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00199         {
00200                 global $tree;
00201                 
00202                 switch ($a_event)
00203                 {
00204                         case "link":
00205                                 
00206                                 //var_dump("<pre>",$a_params,"</pre>");
00207                                 //echo "Module name ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
00208                                 //exit;
00209                                 break;
00210                         
00211                         case "cut":
00212                                 
00213                                 //echo "Module name ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
00214                                 //exit;
00215                                 break;
00216                                 
00217                         case "copy":
00218                         
00219                                 //var_dump("<pre>",$a_params,"</pre>");
00220                                 //echo "Module name ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
00221                                 //exit;
00222                                 break;
00223 
00224                         case "paste":
00225                                 
00226                                 //echo "Module name ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
00227                                 //exit;
00228                                 break;
00229                         
00230                         case "new":
00231                                 
00232                                 //echo "Module name ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
00233                                 //exit;
00234                                 break;
00235                 }
00236 
00237                 // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
00238                 if ($a_node_id==$_GET["ref_id"])
00239                 {
00240                         $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00241                         $parent_type = $parent_obj->getType();
00242                         if($parent_type == $this->getType())
00243                         {
00244                                 $a_node_id = (int) $tree->getParentId($a_node_id);
00245                         }
00246                 }
00247                 
00248                 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00249         }
00250 
00251 } // END class.ilObjExternalFeed
00252 ?>

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