ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilLinkResourceItems Class Reference

Class ilObjLinkResourceGUI. More...

+ Collaboration diagram for ilLinkResourceItems:

Public Member Functions

 __construct ($webr_id)
 Constructor @access public. More...
 
 setLinkResourceRefId ($a_ref_id)
 
 getLinkResourceRefId ()
 
 setLinkResourceId ($a_id)
 
 getLinkResourceId ()
 
 setLinkId ($a_id)
 
 getLinkId ()
 
 setTitle ($a_title)
 
 getTitle ()
 
 setDescription ($a_description)
 
 getDescription ()
 
 setTarget ($a_target)
 
 getTarget ()
 
 setActiveStatus ($a_status)
 
 getActiveStatus ()
 
 setDisableCheckStatus ($a_status)
 
 getDisableCheckStatus ()
 
 __setCreateDate ($a_date)
 
 getCreateDate ()
 
 __setLastUpdateDate ($a_date)
 
 getLastUpdateDate ()
 
 setLastCheckDate ($a_date)
 
 getLastCheckDate ()
 
 setValidStatus ($a_status)
 
 getValidStatus ()
 
 setInternal ($a_status)
 
 getInternal ()
 
 cloneItems ($a_new_id)
 Copy web resource items. More...
 
 delete ($a_item_id, $a_update_history=true)
 
 update ($a_update_history=true)
 
 updateValid ($a_status)
 
 updateActive ($a_status)
 
 updateDisableCheck ($a_status)
 
 updateLastCheck ($a_offset=0)
 
 updateValidByCheck ($a_offset=0)
 
 add ($a_update_history=true)
 
 readItem ($a_link_id)
 
 getItem ($a_link_id)
 
 getAllItems ()
 
 sortItems ($a_items)
 Sort items (sorting mode depends on sorting setting) More...
 
 getActivatedItems ()
 
 getCheckItems ($a_offset=0)
 
 validate ()
 Validate required settings. More...
 
 toXML (ilXmlWriter $writer)
 Write link XML. More...
 

Static Public Member Functions

static lookupItem ($a_webr_id, $a_link_id)
 
static updateTitle ($a_link_id, $a_title)
 Update title. More...
 
static getAllItemIds ($a_webr_id)
 Get all link ids. More...
 
static _deleteAll ($webr_id)
 
static _isSingular ($a_webr_id)
 Check whether there is only one active link in the web resource. More...
 
static lookupNumberOfLinks ($a_webr_id)
 Get number of assigned links. More...
 
static _getFirstLink ($a_webr_id)
 Get first link item Check before with _isSingular() if there is more or less than one. More...
 

Detailed Description

Class ilObjLinkResourceGUI.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 15 of file class.ilLinkResourceItems.php.

Constructor & Destructor Documentation

◆ __construct()

ilLinkResourceItems::__construct (   $webr_id)

Constructor @access public.

Definition at line 21 of file class.ilLinkResourceItems.php.

22 {
23 global $ilDB;
24
25 $this->webr_ref_id = 0;
26 $this->webr_id = $webr_id;
27
28 $this->db = $ilDB;
29 }
global $ilDB

References $ilDB.

Member Function Documentation

◆ __setCreateDate()

ilLinkResourceItems::__setCreateDate (   $a_date)

Definition at line 142 of file class.ilLinkResourceItems.php.

143 {
144 $this->c_date = $a_date;
145 }

Referenced by add(), and readItem().

+ Here is the caller graph for this function:

◆ __setLastUpdateDate()

ilLinkResourceItems::__setLastUpdateDate (   $a_date)

Definition at line 151 of file class.ilLinkResourceItems.php.

152 {
153 $this->m_date = $a_date;
154 }

Referenced by add(), readItem(), and update().

+ Here is the caller graph for this function:

◆ _deleteAll()

static ilLinkResourceItems::_deleteAll (   $webr_id)
static

Definition at line 562 of file class.ilLinkResourceItems.php.

563 {
564 global $ilDB;
565
566 $ilDB->manipulate("DELETE FROM webr_items WHERE webr_id = " . $ilDB->quote($webr_id, 'integer'));
567
568 return true;
569 }

References $ilDB.

Referenced by ilObjLinkResource\delete().

+ Here is the caller graph for this function:

◆ _getFirstLink()

static ilLinkResourceItems::_getFirstLink (   $a_webr_id)
static

Get first link item Check before with _isSingular() if there is more or less than one.

Parameters
int$a_webr_idobject id of web resource
Returns
array link item data

Definition at line 614 of file class.ilLinkResourceItems.php.

615 {
616 global $ilDB;
617
618 include_once("./Modules/WebResource/classes/class.ilObjLinkResourceAccess.php");
620 }
static _getFirstLink($a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one.

References $ilDB, and ilObjLinkResourceAccess\_getFirstLink().

Referenced by ilObjLinkResourceListGUI\__readLink(), ilObjLinkResourceGUI\callDirectLink(), ilObjLinkResource\cloneObject(), and ilObjLinkResource\MDUpdateListener().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _isSingular()

static ilLinkResourceItems::_isSingular (   $a_webr_id)
static

Check whether there is only one active link in the web resource.

In this case this link is shown in a new browser window

Parameters
int$a_webr_idobject id of web resource
Returns
boolean success status

Definition at line 579 of file class.ilLinkResourceItems.php.

580 {
581 global $ilDB;
582
583 $query = "SELECT * FROM webr_items " .
584 "WHERE webr_id = " . $ilDB->quote($a_webr_id, 'integer') . ' ' .
585 "AND active = " . $ilDB->quote(1, 'integer') . ' ';
586 $res = $ilDB->query($query);
587 return $res->numRows() == 1 ? true : false;
588 }
$query
foreach($_POST as $key=> $value) $res

References $ilDB, $query, and $res.

Referenced by ilObjLinkResourceAccess\_checkDirectLink(), ilObjLinkResourceGUI\callDirectLink(), and ilObjLinkResource\cloneObject().

+ Here is the caller graph for this function:

◆ add()

ilLinkResourceItems::add (   $a_update_history = true)

Definition at line 365 of file class.ilLinkResourceItems.php.

366 {
367 global $ilDB;
368
369 $this->__setLastUpdateDate(time());
370 $this->__setCreateDate(time());
371
372 $next_id = $ilDB->nextId('webr_items');
373 $query = "INSERT INTO webr_items (link_id,title,description,target,active,disable_check," .
374 "last_update,create_date,webr_id,valid,internal) " .
375 "VALUES( " .
376 $ilDB->quote($next_id, 'integer') . ", " .
377 $ilDB->quote($this->getTitle(), 'text') . ", " .
378 $ilDB->quote($this->getDescription(), 'text') . ", " .
379 $ilDB->quote($this->getTarget(), 'text') . ", " .
380 $ilDB->quote($this->getActiveStatus(), 'integer') . ", " .
381 $ilDB->quote($this->getDisableCheckStatus(), 'integer') . ", " .
382 $ilDB->quote($this->getLastUpdateDate(), 'integer') . ", " .
383 $ilDB->quote($this->getCreateDate(), 'integer') . ", " .
384 $ilDB->quote($this->getLinkResourceId(), 'integer') . ", " .
385 $ilDB->quote($this->getValidStatus(), 'integer') . ', ' .
386 $ilDB->quote($this->getInternal(), 'integer') . ' ' .
387 ")";
388 $res = $ilDB->manipulate($query);
389
390 $link_id = $next_id;
391 $this->setLinkId($link_id);
392
393 if ($a_update_history) {
394 include_once("./Services/History/classes/class.ilHistory.php");
396 $this->getLinkResourceId(),
397 "add",
398 $this->getTitle()
399 );
400 }
401
402 return $link_id;
403 }
static _createEntry( $a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.

References $ilDB, $query, $res, __setCreateDate(), __setLastUpdateDate(), ilHistory\_createEntry(), getActiveStatus(), getCreateDate(), getDescription(), getDisableCheckStatus(), getInternal(), getLastUpdateDate(), getLinkResourceId(), getTarget(), getTitle(), getValidStatus(), and setLinkId().

+ Here is the call graph for this function:

◆ cloneItems()

ilLinkResourceItems::cloneItems (   $a_new_id)

Copy web resource items.

@access public

Parameters
intobj_id of new object

Definition at line 191 of file class.ilLinkResourceItems.php.

192 {
193 include_once 'Modules/WebResource/classes/class.ilParameterAppender.php';
194 $appender = new ilParameterAppender($this->getLinkResourceId());
195
196 foreach ($this->getAllItems() as $item) {
197 $new_item = new ilLinkResourceItems($a_new_id);
198 $new_item->setTitle($item['title']);
199 $new_item->setDescription($item['description']);
200 $new_item->setTarget($item['target']);
201 $new_item->setActiveStatus($item['active']);
202 $new_item->setDisableCheckStatus($item['disable_check']);
203 $new_item->setLastCheckDate($item['last_check']);
204 $new_item->setValidStatus($item['valid']);
205 $new_item->setInternal($item['internal']);
206 $new_item->add(true);
207
208 // Add parameters
209 foreach (ilParameterAppender::_getParams($item['link_id']) as $param_id => $data) {
210 $appender->setName($data['name']);
211 $appender->setValue($data['value']);
212 $appender->add($new_item->getLinkId());
213 }
214
215 unset($new_item);
216 }
217 return true;
218 }
Class ilObjLinkResourceGUI.
Class ilParameterAppender.
static _getParams($a_link_id)
Get dynamic parameter definitions.

References $data, ilParameterAppender\_getParams(), getAllItems(), and getLinkResourceId().

+ Here is the call graph for this function:

◆ delete()

ilLinkResourceItems::delete (   $a_item_id,
  $a_update_history = true 
)

Definition at line 220 of file class.ilLinkResourceItems.php.

221 {
222 global $ilDB;
223
224 $item = $this->getItem($a_item_id);
225
226 $query = "DELETE FROM webr_items " .
227 "WHERE webr_id = " . $ilDB->quote($this->getLinkResourceId(), 'integer') . " " .
228 "AND link_id = " . $ilDB->quote($a_item_id, 'integer');
229 $res = $ilDB->manipulate($query);
230
231 if ($a_update_history) {
232 include_once("./Services/History/classes/class.ilHistory.php");
234 $this->getLinkResourceId(),
235 "delete",
236 $item['title']
237 );
238 }
239
240 return true;
241 }

References $ilDB, $query, $res, ilHistory\_createEntry(), getItem(), and getLinkResourceId().

+ Here is the call graph for this function:

◆ getActivatedItems()

ilLinkResourceItems::getActivatedItems ( )

Definition at line 534 of file class.ilLinkResourceItems.php.

535 {
536 foreach ($this->getAllItems() as $id => $item_data) {
537 if ($item_data['active']) {
538 $active_items[$id] = $item_data;
539 }
540 }
541 return $active_items ? $active_items : array();
542 }
if(!array_key_exists('StateId', $_REQUEST)) $id

References $id, and getAllItems().

+ Here is the call graph for this function:

◆ getActiveStatus()

ilLinkResourceItems::getActiveStatus ( )

Definition at line 129 of file class.ilLinkResourceItems.php.

130 {
131 return (bool) $this->status;
132 }

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getAllItemIds()

static ilLinkResourceItems::getAllItemIds (   $a_webr_id)
static

Get all link ids.

Parameters
int$a_webr_id
Returns

Definition at line 459 of file class.ilLinkResourceItems.php.

460 {
461 global $ilDB;
462
463 $query = "SELECT link_id FROM webr_items " .
464 "WHERE webr_id = " . $ilDB->quote($a_webr_id, 'integer');
465 $res = $ilDB->query($query);
466 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
467 $link_ids[] = $row['link_id'];
468 }
469 return (array) $link_ids;
470 }

References $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_ASSOC.

◆ getAllItems()

ilLinkResourceItems::getAllItems ( )

Definition at line 472 of file class.ilLinkResourceItems.php.

473 {
474 global $ilDB;
475
476 $query = "SELECT * FROM webr_items " .
477 "WHERE webr_id = " . $ilDB->quote($this->getLinkResourceId(), 'integer');
478
479 $res = $this->db->query($query);
480 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
481 $items[$row->link_id]['title'] = $row->title;
482 $items[$row->link_id]['description'] = $row->description;
483 $items[$row->link_id]['target'] = $row->target;
484 $items[$row->link_id]['active'] = (bool) $row->active;
485 $items[$row->link_id]['disable_check'] = $row->disable_check;
486 $items[$row->link_id]['create_date'] = $row->create_date;
487 $items[$row->link_id]['last_update'] = $row->last_update;
488 $items[$row->link_id]['last_check'] = $row->last_check;
489 $items[$row->link_id]['valid'] = $row->valid;
490 $items[$row->link_id]['link_id'] = $row->link_id;
491 $items[$row->link_id]['internal'] = $row->internal;
492 }
493 return $items ? $items : array();
494 }

References $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and getLinkResourceId().

Referenced by cloneItems(), getActivatedItems(), getCheckItems(), and toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCheckItems()

ilLinkResourceItems::getCheckItems (   $a_offset = 0)

Definition at line 544 of file class.ilLinkResourceItems.php.

545 {
546 $period = $a_offset ? $a_offset : 0;
547 $time = time() - $period;
548
549 foreach ($this->getAllItems() as $id => $item_data) {
550 if (!$item_data['disable_check']) {
551 if (!$item_data['last_check'] or $item_data['last_check'] < $time) {
552 $check_items[$id] = $item_data;
553 }
554 }
555 }
556 return $check_items ? $check_items : array();
557 }
$time
Definition: cron.php:21

References $id, $time, and getAllItems().

+ Here is the call graph for this function:

◆ getCreateDate()

ilLinkResourceItems::getCreateDate ( )

Definition at line 146 of file class.ilLinkResourceItems.php.

147 {
148 return $this->c_date;
149 }

Referenced by add().

+ Here is the caller graph for this function:

◆ getDescription()

ilLinkResourceItems::getDescription ( )

Definition at line 113 of file class.ilLinkResourceItems.php.

114 {
115 return $this->description;
116 }

References $description.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getDisableCheckStatus()

ilLinkResourceItems::getDisableCheckStatus ( )

Definition at line 137 of file class.ilLinkResourceItems.php.

138 {
139 return (bool) $this->check;
140 }

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getInternal()

ilLinkResourceItems::getInternal ( )

Definition at line 179 of file class.ilLinkResourceItems.php.

180 {
181 return (bool) $this->internal;
182 }

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getItem()

ilLinkResourceItems::getItem (   $a_link_id)

Definition at line 429 of file class.ilLinkResourceItems.php.

430 {
431 global $ilDB;
432
433 $query = "SELECT * FROM webr_items " .
434 "WHERE webr_id = " . $ilDB->quote($this->getLinkResourceId(), 'integer') . " " .
435 "AND link_id = " . $ilDB->quote($a_link_id, 'integer');
436
437 $res = $this->db->query($query);
438 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
439 $item['title'] = $row->title;
440 $item['description'] = $row->description;
441 $item['target'] = $row->target;
442 $item['active'] = (bool) $row->active;
443 $item['disable_check'] = $row->disable_check;
444 $item['create_date'] = $row->create_date;
445 $item['last_update'] = $row->last_update;
446 $item['last_check'] = $row->last_check;
447 $item['valid'] = $row->valid;
448 $item['link_id'] = $row->link_id;
449 $item['internal'] = $row->internal;
450 }
451 return $item ? $item : array();
452 }

References $ilDB, $query, $res, $row, ilDBConstants\FETCHMODE_OBJECT, and getLinkResourceId().

Referenced by delete().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastCheckDate()

ilLinkResourceItems::getLastCheckDate ( )

Definition at line 163 of file class.ilLinkResourceItems.php.

164 {
165 return $this->last_check;
166 }

Referenced by update().

+ Here is the caller graph for this function:

◆ getLastUpdateDate()

ilLinkResourceItems::getLastUpdateDate ( )

Definition at line 155 of file class.ilLinkResourceItems.php.

156 {
157 return $this->m_date;
158 }

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ getLinkId()

ilLinkResourceItems::getLinkId ( )

Definition at line 97 of file class.ilLinkResourceItems.php.

98 {
99 return $this->id;
100 }

References $id.

Referenced by update(), updateActive(), updateDisableCheck(), and updateValid().

+ Here is the caller graph for this function:

◆ getLinkResourceId()

ilLinkResourceItems::getLinkResourceId ( )

Definition at line 89 of file class.ilLinkResourceItems.php.

90 {
91 return $this->webr_id;
92 }

Referenced by add(), cloneItems(), delete(), getAllItems(), getItem(), sortItems(), toXML(), update(), updateLastCheck(), and updateValidByCheck().

+ Here is the caller graph for this function:

◆ getLinkResourceRefId()

ilLinkResourceItems::getLinkResourceRefId ( )

Definition at line 81 of file class.ilLinkResourceItems.php.

82 {
83 return $this->webr_ref_id;
84 }

◆ getTarget()

ilLinkResourceItems::getTarget ( )

Definition at line 121 of file class.ilLinkResourceItems.php.

122 {
123 return $this->target;
124 }

References $target.

Referenced by add(), update(), and validate().

+ Here is the caller graph for this function:

◆ getTitle()

ilLinkResourceItems::getTitle ( )

Definition at line 105 of file class.ilLinkResourceItems.php.

106 {
107 return $this->title;
108 }

References $title.

Referenced by add(), update(), and validate().

+ Here is the caller graph for this function:

◆ getValidStatus()

ilLinkResourceItems::getValidStatus ( )

Definition at line 171 of file class.ilLinkResourceItems.php.

172 {
173 return (bool) $this->valid;
174 }
$valid

References $valid.

Referenced by add(), and update().

+ Here is the caller graph for this function:

◆ lookupItem()

static ilLinkResourceItems::lookupItem (   $a_webr_id,
  $a_link_id 
)
static

Definition at line 32 of file class.ilLinkResourceItems.php.

33 {
34 global $ilDB;
35
36 $query = "SELECT * FROM webr_items " .
37 "WHERE webr_id = " . $ilDB->quote($a_webr_id, 'integer') . " " .
38 "AND link_id = " . $ilDB->quote($a_link_id, 'integer');
39
40 $res = $ilDB->query($query);
41 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
42 $item['title'] = $row->title;
43 $item['description'] = $row->description;
44 $item['target'] = $row->target;
45 $item['active'] = (bool) $row->active;
46 $item['disable_check'] = $row->disable_check;
47 $item['create_date'] = $row->create_date;
48 $item['last_update'] = $row->last_update;
49 $item['last_check'] = $row->last_check;
50 $item['valid'] = $row->valid;
51 $item['link_id'] = $row->link_id;
52 $item['internal'] = $row->internal;
53 }
54 return $item ? $item : array();
55 }

References $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilObjLinkResourceSubItemListGUI\getHTML(), toXML(), and ilObjLinkResourceGUI\updateLinks().

+ Here is the caller graph for this function:

◆ lookupNumberOfLinks()

static ilLinkResourceItems::lookupNumberOfLinks (   $a_webr_id)
static

Get number of assigned links.

Parameters
int$a_webr_id
Returns

Definition at line 595 of file class.ilLinkResourceItems.php.

596 {
597 global $ilDB;
598
599 $query = "SELECT COUNT(*) num FROM webr_items " .
600 "WHERE webr_id = " . $ilDB->quote($a_webr_id, 'integer');
601 $res = $ilDB->query($query);
603 return $row->num;
604 }

References $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilObjLinkResourceGUI\activateTabs(), ilObjLinkResourceGUI\isContainerMetaDataRequired(), ilObjLinkResource\MDUpdateListener(), and ilObjLinkResourceGUI\setTabs().

+ Here is the caller graph for this function:

◆ readItem()

ilLinkResourceItems::readItem (   $a_link_id)

Definition at line 404 of file class.ilLinkResourceItems.php.

405 {
406 global $ilDB;
407
408 $query = "SELECT * FROM webr_items " .
409 "WHERE link_id = " . $ilDB->quote($a_link_id, 'integer');
410
411 $res = $this->db->query($query);
412 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
413 $this->setTitle($row->title);
414 $this->setDescription($row->description);
415 $this->setTarget($row->target);
416 $this->setActiveStatus($row->active);
417 $this->setDisableCheckStatus($row->disable_check);
418 $this->__setCreateDate($row->create_date);
419 $this->__setLastUpdateDate($row->last_update);
420 $this->setLastCheckDate($row->last_check);
421 $this->setValidStatus($row->valid);
422 $this->setLinkId($row->link_id);
423 $this->setInternal($row->internal);
424 }
425 return true;
426 }

References $ilDB, $query, $res, $row, __setCreateDate(), __setLastUpdateDate(), ilDBConstants\FETCHMODE_OBJECT, setActiveStatus(), setDescription(), setDisableCheckStatus(), setInternal(), setLastCheckDate(), setLinkId(), setTarget(), setTitle(), and setValidStatus().

+ Here is the call graph for this function:

◆ setActiveStatus()

ilLinkResourceItems::setActiveStatus (   $a_status)

Definition at line 125 of file class.ilLinkResourceItems.php.

126 {
127 $this->status = (int) $a_status;
128 }

Referenced by readItem().

+ Here is the caller graph for this function:

◆ setDescription()

ilLinkResourceItems::setDescription (   $a_description)

Definition at line 109 of file class.ilLinkResourceItems.php.

110 {
111 $this->description = $a_description;
112 }

Referenced by readItem().

+ Here is the caller graph for this function:

◆ setDisableCheckStatus()

ilLinkResourceItems::setDisableCheckStatus (   $a_status)

Definition at line 133 of file class.ilLinkResourceItems.php.

134 {
135 $this->check = (int) $a_status;
136 }

Referenced by readItem().

+ Here is the caller graph for this function:

◆ setInternal()

ilLinkResourceItems::setInternal (   $a_status)

Definition at line 175 of file class.ilLinkResourceItems.php.

176 {
177 $this->internal = (bool) $a_status;
178 }

Referenced by readItem().

+ Here is the caller graph for this function:

◆ setLastCheckDate()

ilLinkResourceItems::setLastCheckDate (   $a_date)

Definition at line 159 of file class.ilLinkResourceItems.php.

160 {
161 $this->last_check = $a_date;
162 }

Referenced by readItem().

+ Here is the caller graph for this function:

◆ setLinkId()

ilLinkResourceItems::setLinkId (   $a_id)

Definition at line 93 of file class.ilLinkResourceItems.php.

94 {
95 $this->id = $a_id;
96 }

Referenced by add(), and readItem().

+ Here is the caller graph for this function:

◆ setLinkResourceId()

ilLinkResourceItems::setLinkResourceId (   $a_id)

Definition at line 85 of file class.ilLinkResourceItems.php.

86 {
87 $this->webr_id = $a_id;
88 }

◆ setLinkResourceRefId()

ilLinkResourceItems::setLinkResourceRefId (   $a_ref_id)

Definition at line 77 of file class.ilLinkResourceItems.php.

78 {
79 $this->webr_ref_id = $a_ref_id;
80 }

◆ setTarget()

ilLinkResourceItems::setTarget (   $a_target)

Definition at line 117 of file class.ilLinkResourceItems.php.

118 {
119 $this->target = $a_target;
120 }

Referenced by readItem().

+ Here is the caller graph for this function:

◆ setTitle()

ilLinkResourceItems::setTitle (   $a_title)

Definition at line 101 of file class.ilLinkResourceItems.php.

102 {
103 $this->title = $a_title;
104 }

Referenced by readItem().

+ Here is the caller graph for this function:

◆ setValidStatus()

ilLinkResourceItems::setValidStatus (   $a_status)

Definition at line 167 of file class.ilLinkResourceItems.php.

168 {
169 $this->valid = (int) $a_status;
170 }

Referenced by readItem().

+ Here is the caller graph for this function:

◆ sortItems()

ilLinkResourceItems::sortItems (   $a_items)

Sort items (sorting mode depends on sorting setting)

Parameters
object$a_items
Returns

Definition at line 501 of file class.ilLinkResourceItems.php.

502 {
503 include_once './Services/Container/classes/class.ilContainer.php';
504 include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
506
507 if ($mode == ilContainer::SORT_TITLE) {
508 $a_items = ilUtil::sortArray($a_items, 'title', 'asc', false, true);
509 return $a_items;
510 }
511
512
513 if ($mode == ilContainer::SORT_MANUAL) {
514 include_once './Services/Container/classes/class.ilContainerSorting.php';
516 foreach ($a_items as $link_id => $item) {
517 if (isset($pos[$link_id])) {
518 $sorted[$link_id] = $item;
519 $sorted[$link_id]['position'] = $pos[$link_id];
520 } else {
521 $unsorted[$link_id] = $item;
522 }
523 }
524 $sorted = ilUtil::sortArray((array) $sorted, 'position', 'asc', true, true);
525 $unsorted = ilUtil::sortArray((array) $unsorted, 'title', 'asc', false, true);
526 $a_items = (array) $sorted + (array) $unsorted;
527 return $a_items;
528 }
529 return $a_items;
530 }
static _lookupSortMode($a_obj_id)
lookup sort mode
static lookupPositions($a_obj_id)
Get positions of subitems.
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray

References ilContainerSortingSettings\_lookupSortMode(), getLinkResourceId(), ilContainerSorting\lookupPositions(), ilContainer\SORT_MANUAL, ilContainer\SORT_TITLE, and ilUtil\sortArray().

Referenced by toXML().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toXML()

ilLinkResourceItems::toXML ( ilXmlWriter  $writer)

Write link XML.

Parameters
ilXmlWriter$writer
Returns

Definition at line 637 of file class.ilLinkResourceItems.php.

638 {
639 $items = $this->sortItems($this->getAllItems());
640
641 $position = 0;
642 foreach ((array) $items as $item_id => $item) {
643 ++$position;
644 $link = self::lookupItem($this->getLinkResourceId(), $item_id);
645
646 $writer->xmlStartTag(
647 'WebLink',
648 array(
649 'id' => $link['link_id'],
650 'active' => $link['active'] ? 1 : 0,
651 'valid' => $link['valid'] ? 1 : 0,
652 'disableValidation' => $link['disable_check'] ? 1 : 0,
653 'position' => $position,
654 'internal' => $link['internal']
655 )
656 );
657 $writer->xmlElement('Title', array(), $link['title']);
658 $writer->xmlElement('Description', array(), $link['description']);
659 $writer->xmlElement('Target', array(), $link['target']);
660
661 // Dynamic parameters
662 include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
663 foreach (ilParameterAppender::_getParams($link_id) as $param_id => $param) {
664 $value = '';
665 switch ($param['value']) {
666 case LINKS_USER_ID:
667 $value = 'userId';
668 break;
669
670 case LINKS_LOGIN:
671 $value = 'userName';
672 break;
673
675 $value = 'matriculation';
676 break;
677 }
678
679 if (!$value) {
680 // Fix for deprecated LINKS_SESSION
681 continue;
682 }
683
684 $writer->xmlElement(
685 'DynamicParameter',
686 array(
687 'id' => $param_id,
688 'name' => $param['name'],
689 'type' => $value
690 )
691 );
692 }
693
694 $writer->xmlEndTag('WebLink');
695 }
696 return true;
697 }
const LINKS_USER_ID
const LINKS_LOGIN
const LINKS_MATRICULATION
static lookupItem($a_webr_id, $a_link_id)
sortItems($a_items)
Sort items (sorting mode depends on sorting setting)
xmlEndTag($tag)
Writes an endtag.
xmlElement($tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlStartTag($tag, $attrs=null, $empty=false, $encode=true, $escape=true)
Writes a starttag.

References ilParameterAppender\_getParams(), getAllItems(), getLinkResourceId(), LINKS_LOGIN, LINKS_MATRICULATION, LINKS_USER_ID, lookupItem(), sortItems(), ilXmlWriter\xmlElement(), ilXmlWriter\xmlEndTag(), and ilXmlWriter\xmlStartTag().

+ Here is the call graph for this function:

◆ update()

ilLinkResourceItems::update (   $a_update_history = true)

Definition at line 243 of file class.ilLinkResourceItems.php.

244 {
245 global $ilDB;
246
247 if (!$this->getLinkId()) {
248 return false;
249 }
250
251 $this->__setLastUpdateDate(time());
252 $query = "UPDATE webr_items " .
253 "SET title = " . $ilDB->quote($this->getTitle(), 'text') . ", " .
254 "description = " . $ilDB->quote($this->getDescription(), 'text') . ", " .
255 "target = " . $ilDB->quote($this->getTarget(), 'text') . ", " .
256 "active = " . $ilDB->quote($this->getActiveStatus(), 'integer') . ", " .
257 "valid = " . $ilDB->quote($this->getValidStatus(), 'integer') . ", " .
258 "disable_check = " . $ilDB->quote($this->getDisableCheckStatus(), 'integer') . ", " .
259 "internal = " . $ilDB->quote($this->getInternal(), 'integer') . ", " .
260 "last_update = " . $ilDB->quote($this->getLastUpdateDate(), 'integer') . ", " .
261 "last_check = " . $ilDB->quote($this->getLastCheckDate(), 'integer') . " " .
262 "WHERE link_id = " . $ilDB->quote($this->getLinkId(), 'integer') . " " .
263 "AND webr_id = " . $ilDB->quote($this->getLinkResourceId(), 'integer');
264 $res = $ilDB->manipulate($query);
265
266 if ($a_update_history) {
267 include_once("./Services/History/classes/class.ilHistory.php");
269 $this->getLinkResourceId(),
270 "update",
271 $this->getTitle()
272 );
273 }
274
275 return true;
276 }

References $ilDB, $query, $res, __setLastUpdateDate(), ilHistory\_createEntry(), getActiveStatus(), getDescription(), getDisableCheckStatus(), getInternal(), getLastCheckDate(), getLastUpdateDate(), getLinkId(), getLinkResourceId(), getTarget(), getTitle(), and getValidStatus().

+ Here is the call graph for this function:

◆ updateActive()

ilLinkResourceItems::updateActive (   $a_status)

Definition at line 290 of file class.ilLinkResourceItems.php.

291 {
292 global $ilDB;
293
294 $query = "UPDATE webr_items " .
295 "SET active = " . $ilDB->quote($a_status, 'integer') . " " .
296 "WHERE link_id = " . $ilDB->quote($this->getLinkId(), 'integer');
297
298 $this->db->query($query);
299
300 return true;
301 }

References $ilDB, $query, and getLinkId().

+ Here is the call graph for this function:

◆ updateDisableCheck()

ilLinkResourceItems::updateDisableCheck (   $a_status)

Definition at line 302 of file class.ilLinkResourceItems.php.

303 {
304 global $ilDB;
305
306 $query = "UPDATE webr_items " .
307 "SET disable_check = " . $ilDB->quote($a_status, 'integer') . " " .
308 "WHERE link_id = " . $ilDB->quote($this->getLinkId(), 'integer');
309 $res = $ilDB->manipulate($query);
310
311 return true;
312 }

References $ilDB, $query, $res, and getLinkId().

+ Here is the call graph for this function:

◆ updateLastCheck()

ilLinkResourceItems::updateLastCheck (   $a_offset = 0)

Definition at line 314 of file class.ilLinkResourceItems.php.

315 {
316 global $ilDB;
317
318 if ($a_offset) {
319 $period = $a_offset ? $a_offset : 0;
320 $time = time() - $period;
321
322
323 $query = "UPDATE webr_items " .
324 "SET last_check = " . $ilDB->quote(time(), 'integer') . " " .
325 "WHERE webr_id = " . $ilDB->quote($this->getLinkResourceId(), 'integer') . " " .
326 "AND disable_check = '0' " .
327 "AND last_check < " . $ilDB->quote($time, 'integer');
328 $res = $ilDB->manipulate($query);
329 } else {
330 $query = "UPDATE webr_items " .
331 "SET last_check = " . $ilDB->quote(time(), 'integer') . " " .
332 "WHERE webr_id = " . $ilDB->quote($this->getLinkResourceId(), 'integer') . " " .
333 "AND disable_check = '0' ";
334 $res = $ilDB->manipulate($query);
335 }
336 return true;
337 }

References $ilDB, $query, $res, $time, and getLinkResourceId().

+ Here is the call graph for this function:

◆ updateTitle()

static ilLinkResourceItems::updateTitle (   $a_link_id,
  $a_title 
)
static

Update title.

Parameters
type$a_link_id
type$a_title

Definition at line 63 of file class.ilLinkResourceItems.php.

64 {
65 global $ilDB;
66
67 $query = 'UPDATE webr_items SET ' .
68 'title = ' . $ilDB->quote($a_title, 'text') . ' ' .
69 'WHERE link_id = ' . $ilDB->quote($a_link_id, 'integer');
70 $ilDB->manipulate($query);
71 return true;
72 }

References $ilDB, and $query.

Referenced by ilObjLinkResource\cloneObject().

+ Here is the caller graph for this function:

◆ updateValid()

ilLinkResourceItems::updateValid (   $a_status)

Definition at line 278 of file class.ilLinkResourceItems.php.

279 {
280 global $ilDB;
281
282 $query = "UPDATE webr_items " .
283 "SET valid = " . $ilDB->quote($a_status, 'integer') . " " .
284 "WHERE link_id = " . $ilDB->quote($this->getLinkId(), 'integer');
285 $res = $ilDB->manipulate($query);
286
287 return true;
288 }

References $ilDB, $query, $res, and getLinkId().

+ Here is the call graph for this function:

◆ updateValidByCheck()

ilLinkResourceItems::updateValidByCheck (   $a_offset = 0)

Definition at line 339 of file class.ilLinkResourceItems.php.

340 {
341 global $ilDB;
342
343 if ($a_offset) {
344 $period = $a_offset ? $a_offset : 0;
345 $time = time() - $period;
346
347
348 $query = "UPDATE webr_items " .
349 "SET valid = '1' " .
350 "WHERE disable_check = '0' " .
351 "AND webr_id = " . $ilDB->quote($this->getLinkResourceId(), 'integer') . " " .
352 "AND last_check < " . $ilDB->quote($time, 'integer');
353 $res = $ilDB->manipulate($query);
354 } else {
355 $query = "UPDATE webr_items " .
356 "SET valid = '1' " .
357 "WHERE disable_check = '0' " .
358 "AND webr_id = " . $ilDB->quote($this->getLinkResourceId(), 'integer');
359 $res = $ilDB->manipulate($query);
360 }
361 return true;
362 }

References $ilDB, $query, $res, $time, and getLinkResourceId().

+ Here is the call graph for this function:

◆ validate()

ilLinkResourceItems::validate ( )

Validate required settings.

Returns

Definition at line 626 of file class.ilLinkResourceItems.php.

627 {
628 return $this->getTarget() and $this->getTitle();
629 }

References getTarget(), and getTitle().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: