ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilNewsItemGen.php
Go to the documentation of this file.
1<?php
2/*
3 +-----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +-----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2006 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
24define("NEWS_TEXT", "text");
25define("NEWS_HTML", "html");
26define("NEWS_AUDIO", "audio");
27define("NEWS_USERS", "users");
28define("NEWS_PUBLIC", "public");
29
39{
40
41 protected $id;
42 protected $title;
43 protected $content;
44 protected $context_obj_id;
48 protected $content_type = "text";
49 protected $creation_date;
50 protected $update_date;
51 protected $user_id;
52 protected $visibility = "users";
53 protected $content_long;
54 protected $priority = 1;
55 protected $content_is_lang_var = 0;
56 protected $mob_id;
57 protected $playtime;
58
64 public function __construct($a_id = 0)
65 {
66 if ($a_id > 0)
67 {
68 $this->setId($a_id);
69 $this->read();
70 }
71
72 }
73
79 public function setId($a_id)
80 {
81 $this->id = $a_id;
82 }
83
89 public function getId()
90 {
91 return $this->id;
92 }
93
99 public function setTitle($a_title)
100 {
101 $this->title = $a_title;
102 }
103
109 public function getTitle()
110 {
111 return $this->title;
112 }
113
119 public function setContent($a_content)
120 {
121 $this->content = $a_content;
122 }
123
129 public function getContent()
130 {
131 return $this->content;
132 }
133
139 public function setContextObjId($a_context_obj_id)
140 {
141 $this->context_obj_id = $a_context_obj_id;
142 }
143
149 public function getContextObjId()
150 {
152 }
153
159 public function setContextObjType($a_context_obj_type)
160 {
161 $this->context_obj_type = $a_context_obj_type;
162 }
163
169 public function getContextObjType()
170 {
172 }
173
179 public function setContextSubObjId($a_context_sub_obj_id)
180 {
181 $this->context_sub_obj_id = $a_context_sub_obj_id;
182 }
183
189 public function getContextSubObjId()
190 {
192 }
193
199 public function setContextSubObjType($a_context_sub_obj_type)
200 {
201 $this->context_sub_obj_type = $a_context_sub_obj_type;
202 }
203
209 public function getContextSubObjType()
210 {
212 }
213
219 public function setContentType($a_content_type = "text")
220 {
221 $this->content_type = $a_content_type;
222 }
223
229 public function getContentType()
230 {
231 return $this->content_type;
232 }
233
239 public function setCreationDate($a_creation_date)
240 {
241 $this->creation_date = $a_creation_date;
242 }
243
249 public function getCreationDate()
250 {
252 }
253
259 public function setUpdateDate($a_update_date)
260 {
261 $this->update_date = $a_update_date;
262 }
263
269 public function getUpdateDate()
270 {
271 return $this->update_date;
272 }
273
279 public function setUserId($a_user_id)
280 {
281 $this->user_id = $a_user_id;
282 }
283
289 public function getUserId()
290 {
291 return $this->user_id;
292 }
293
299 public function setVisibility($a_visibility = "users")
300 {
301 $this->visibility = $a_visibility;
302 }
303
309 public function getVisibility()
310 {
311 return $this->visibility;
312 }
313
319 public function setContentLong($a_content_long)
320 {
321 $this->content_long = $a_content_long;
322 }
323
329 public function getContentLong()
330 {
331 return $this->content_long;
332 }
333
339 public function setPriority($a_priority = 1)
340 {
341 $this->priority = $a_priority;
342 }
343
349 public function getPriority()
350 {
351 return $this->priority;
352 }
353
359 public function setContentIsLangVar($a_content_is_lang_var = 0)
360 {
361 $this->content_is_lang_var = $a_content_is_lang_var;
362 }
363
369 public function getContentIsLangVar()
370 {
372 }
373
379 public function setMobId($a_mob_id)
380 {
381 $this->mob_id = $a_mob_id;
382 }
383
389 public function getMobId()
390 {
391 return $this->mob_id;
392 }
393
399 public function setPlaytime($a_playtime)
400 {
401 $this->playtime = $a_playtime;
402 }
403
409 public function getPlaytime()
410 {
411 return $this->playtime;
412 }
413
418 public function create()
419 {
420 global $ilDB;
421
422 }
423
424
425
430 public function delete()
431 {
432 global $ilDB;
433
434 $query = "DELETE FROM il_news_item".
435 " WHERE id = ".$ilDB->quote($this->getId(), "integer");
436
437 $ilDB->manipulate($query);
438
439 }
440
445 public function queryNewsForContext()
446 {
447 global $ilDB;
448
449 $query = "SELECT id, title, content, context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, content_type, creation_date, update_date, user_id, visibility, content_long, priority, content_is_lang_var, mob_id, playtime ".
450 "FROM il_news_item ".
451 "WHERE ".
452 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
453 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
454 " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
455 " AND ".$ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true).
456 " ORDER BY creation_date DESC ".
457 "";
458 $set = $ilDB->query($query);
459 $result = array();
460 while($rec = $ilDB->fetchAssoc($set))
461 {
462 $result[] = $rec;
463 }
464
465 return $result;
466
467 }
468
473 public function queryNewsForVisibility()
474 {
475 global $ilDB;
476
477 $query = "SELECT id, title, content, context_obj_id, context_obj_type, context_sub_obj_id, context_sub_obj_type, content_type, creation_date, update_date, user_id, visibility, content_long, priority, content_is_lang_var, mob_id, playtime ".
478 "FROM il_news_item ".
479 "WHERE ".
480 "context_obj_id = ".$ilDB->quote($this->getContextObjId(), "integer").
481 " AND context_obj_type = ".$ilDB->quote($this->getContextObjType(), "text").
482 " AND context_sub_obj_id = ".$ilDB->quote($this->getContextSubObjId(), "integer").
483 " AND ".$ilDB->equals("context_sub_obj_type", $this->getContextSubObjType(), "text", true).
484 " AND visibility = ".$ilDB->quote($this->getVisibility(), "text").
485 " ORDER BY creation_date DESC ".
486 "";
487
488 $set = $ilDB->query($query);
489 $result = array();
490 while($rec = $ilDB->fetchAssoc($set))
491 {
492 $result[] = $rec;
493 }
494
495 return $result;
496
497 }
498
499
500}
501?>
$result
A news item can be created by different sources.
getContextObjId()
Get ContextObjId.
setTitle($a_title)
Set Title.
setContentType($a_content_type="text")
Set ContentType.
getContent()
Get Content.
__construct($a_id=0)
Constructor.
setCreationDate($a_creation_date)
Set CreationDate.
setVisibility($a_visibility="users")
Set Visibility.
setContextSubObjType($a_context_sub_obj_type)
Set ContextSubObjType.
setPlaytime($a_playtime)
Set Playtime.
setContentIsLangVar($a_content_is_lang_var=0)
Set ContentIsLangVar.
getCreationDate()
Get CreationDate.
setUserId($a_user_id)
Set UserId.
setContextObjType($a_context_obj_type)
Set ContextObjType.
getPriority()
Get Priority.
setContextObjId($a_context_obj_id)
Set ContextObjId.
create()
Create new item.
getContentType()
Get ContentType.
setContextSubObjId($a_context_sub_obj_id)
Set ContextSubObjId.
getUpdateDate()
Get UpdateDate.
setContent($a_content)
Set Content.
queryNewsForVisibility()
Query NewsForVisibility.
setPriority($a_priority=1)
Set Priority.
setUpdateDate($a_update_date)
Set UpdateDate.
getUserId()
Get UserId.
getContextObjType()
Get ContextObjType.
setMobId($a_mob_id)
Set MobId.
getContextSubObjId()
Get ContextSubObjId.
setId($a_id)
Set Id.
getContentIsLangVar()
Get ContentIsLangVar.
getPlaytime()
Get Playtime.
getContextSubObjType()
Get ContextSubObjType.
queryNewsForContext()
Query NewsForContext.
getContentLong()
Get ContentLong.
setContentLong($a_content_long)
Set ContentLong.
getVisibility()
Get Visibility.
global $ilDB