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

classes/class.ilObjNoteFolder.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 
00035 require_once "class.ilObject.php";
00036 
00037 // TODO: note class need complete redesign since to user trees are saved to main tree table.
00038 // is a tree actually useful to administrate user settings?
00039 class ilObjNoteFolder extends ilObject
00040 {
00041         var $m_usr_id;
00042         
00043         var $m_tree;
00044 
00045         var $m_notefId ;
00046         
00053         function ilObjNoteFolder($user_id = 0,$a_call_by_reference = true)
00054         {
00055                 $this->type = "notf";
00056                 $this->ilObject($user_id,$a_call_by_reference);
00057                 
00058                 $this->m_usr_id = $user_id;
00059         }
00060 
00066         function create()
00067         {
00068                 parent::create();
00069 
00070                 //$this->m_tree = new ilTree(0,0,$this->m_usr_id);
00071                 
00072                 // TODO: method needs revision
00073                 //$this->m_notefId = $this->m_tree->getNodeDataByType("notf");
00074         }
00075 
00083         function addNote($note_id, $group="")
00084         {
00085 
00086                 global $rbacreview;
00087                 //getgroupmembers
00088                 $grp_members = $rbacreview->assignedUsers($group);
00089         
00090                 if(!empty($group))
00091                 {
00092                         foreach($grp_members as $member)
00093                         {       
00094                                 $myTree = new ilTree(0, 0, $member); 
00095 
00096                                 //get parent_id of usersettingfolder... 
00097                                 $rootid =  $myTree->getRootId();
00098         
00099                                 $node_data = $myTree->getNodeDataByType("notf");
00100 
00101                                 $myTree->insertNode($note_id, $node_data[0]["obj_id"], $rootid["child"]);
00102                         
00103                         }
00104                 }
00105                 //insert the note in ones own notefolder
00106                 $myTree = new ilTree(0, 0, $this->m_usr_id); 
00107         
00108                 //get parent_id of usersettingfolder... 
00109                 $rootid =  $myTree->getRootId();
00110         
00111                 $node_data = $myTree->getNodeDataByType("notf");
00112 
00113                 $myTree->insertNode($note_id, $node_data[0]["obj_id"], $rootid["child"]);
00114         } 
00115 
00122         function deleteNotes($notes)
00123         {
00124                 global $rbacsystem;
00125                 $myTree = new ilTree($this->m_notefId[0]["obj_id"], 0, 0, $this->m_usr_id);     
00126 
00127                 foreach ($notes as $note)
00128                 {
00129                         //delete note in note_data, only owner can delete notes 
00130                         //$note_obj = getObject($note);
00131                         $noteObj =& $this->ilias->obj_factory->getInstanceByObjId($note);
00132                         if ($noteObj->getOwner() == $this->m_usr_id)
00133                         {
00134                                 $query = "DELETE FROM note_data WHERE note_id ='".$note."'";
00135                                 $res = $this->ilias->db->query($query);
00136                                 //TODO: delete entry in object_data and all dependencies, references 
00137                                 //getgroupmembers and delete the note in members notefolder
00138                         }
00139 
00140                         //get note_data of note folder
00141                         $node_data1 = $myTree->getNodeDataByType("notf");               
00142                         $note_data2 = $myTree->getNodeData($note);      
00143                         $myTree->deleteTree($note_data2);                               
00144                 }
00145         }
00146 
00155         function getNotes($note_id = "")
00156         {
00157                 $notes = array();
00158                 $myTree = new ilTree($this->m_notefId[0]["obj_id"], 0, 0, $this->m_usr_id);
00159 
00160                 $nodes = $myTree->getNodeDataByType("note");
00161 
00162                 if($note_id == "")
00163                 {
00164                         foreach($nodes as $node_data)
00165                         {
00166                                 //$note_data = getObject($node_data["child"]);
00167                                 $noteObj =& $this->ilias->obj_factory->getInstanceByObjId($node_data["child"]);
00168                                 // todo: full object handling (getNodes should return real objects)
00169                                 $note_data = array(     "obj_id" => $noteObj->getId(),
00170                                                                         "type" => $noteObj->getType(),
00171                                                                         "description" => $noteObj->getDescription(),
00172                                                                         "owner" => $noteObj->getOwner(),
00173                                                                         "create_date" => $noteObj->getCreateDate(),
00174                                                                         "last_update" => $noteObj->getCreateDate());
00175                                 array_push($notes, $note_data);
00176                         }
00177 
00178                 }
00179                 else
00180                 {
00181                         //$node_data["child"] = $note_id;
00182                         //$notes = getObject($node_data["child"]);
00183                         $noteObj =& $this->ilias->obj_factory->getInstanceByObjId($note_id);
00184                         // todo: full object handling (getNodes should return real objects)
00185                         $notes = array( "obj_id" => $noteObj->getId(),
00186                                                         "type" => $noteObj->getType(),
00187                                                         "description" => $noteObj->getDescription(),
00188                                                         "owner" => $noteObj->getOwner(),
00189                                                         "create_date" => $noteObj->getCreateDate(),
00190                                                         "last_update" => $noteObj->getCreateDate());
00191 
00192                 }
00193                 return $notes;
00194         }
00195 
00196         function viewNote($note_id)
00197         {
00198                 $note = array();
00199                 $myTree = new ilTree($this->m_notefId[0]["obj_id"], 0, $this->m_usr_id);
00200 
00201                 $nodes = $myTree->getNodeDataByType("note");
00202                 $node_data["child"] = $note_id;
00203                 $note = NoteObject::viewObject($node_data["child"]);
00204                 return $note;   
00205         }
00206 
00207 }
00208 
00209 
00210 ?>

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