ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilUserResult.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
34 {
35  // OBJECT VARIABLES
36  var $ilias;
37 
38  var $title;
39  var $obj_id;
40  var $user_id;
41  var $target;
42 
47  function ilUserResult($a_user_id,$a_obj_id = 0)
48  {
49  global $ilias;
50 
51  define("TABLE_SEARCH_DATA","search_data");
52 
53  $this->ilias =& $ilias;
54 
55  $this->obj_id = $a_obj_id;
56  $this->user_id = $a_user_id;
57 
58  $this->__init();
59  }
60 
61  // SET/GET
62  function getUserId()
63  {
64  return $this->user_id;
65  }
66 
67  function getType()
68  {
69  return "sea";
70  }
71  function setObjId($a_obj_id)
72  {
73  $this->obj_id = $a_obj_id;
74  }
75  function getObjId()
76  {
77  return $this->obj_id;
78  }
79  function setTitle($a_title)
80  {
81  $this->title = $a_title;
82  }
83  function getTitle()
84  {
85  return $this->title;
86  }
87  function setTarget($a_target)
88  {
89  $this->target = $a_target;
90  }
91  function getTarget()
92  {
93  return $this->target;
94  }
95 
96  function createLink()
97  {
98  $target = $this->getTarget();
99 
100  include_once 'Services/Search/classes/class.ilSearchObjectListFactory.php';
101 
102  $item_list_gui =& ilSearchObjectListFactory::_getInstance($target['type']);
103  $item_list_gui->initItem($target['id'],ilObject::_lookupObjId($target['id']));
104 
105  return array($item_list_gui->getCommandLink('view'),
106  $item_list_gui->getCommandFrame('view'));
107  }
108 
109  function updateTitle($a_title)
110  {
111  $query = "UPDATE ".TABLE_SEARCH_DATA." ".
112  "SET title = '".addslashes($a_title)."' ".
113  "WHERE obj_id = '".$this->getObjId()."' ".
114  "AND user_id = '".$this->getUserId()."'";
115 
116  $res = $this->ilias->db->query($query);
117 
118  return true;
119  }
120 
121 
122  // PRIVATE METHODS
123  function __init()
124  {
125  if($this->getObjId())
126  {
127  $query = "SELECT * FROM ".TABLE_SEARCH_DATA." ".
128  "WHERE obj_id = '".$this->getObjId()."' ".
129  "AND user_id = '".$this->getUserId()."'";
130 
131  $res = $this->ilias->db->query($query);
132  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
133  {
134  $this->setTitle($row->title);
135  $this->setTarget(unserialize(stripslashes($row->target)));
136  }
137  return true;
138  }
139  }
140 } // END class.Search
141 ?>