ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilLinkResourceItems Class Reference

Class ilObjLinkResourceGUI. More...

+ Collaboration diagram for ilLinkResourceItems:

Public Member Functions

 __construct ($webr_id)
 Constructor 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 public.

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

References $ilDB.

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

Member Function Documentation

◆ __setCreateDate()

ilLinkResourceItems::__setCreateDate (   $a_date)

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

Referenced by add(), and readItem().

145  {
146  $this->c_date = $a_date;
147  }
+ Here is the caller graph for this function:

◆ __setLastUpdateDate()

ilLinkResourceItems::__setLastUpdateDate (   $a_date)

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

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

154  {
155  $this->m_date = $a_date;
156  }
+ Here is the caller graph for this function:

◆ _deleteAll()

static ilLinkResourceItems::_deleteAll (   $webr_id)
static

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

References $ilDB.

Referenced by ilObjLinkResource\delete().

583  {
584  global $ilDB;
585 
586  $ilDB->manipulate("DELETE FROM webr_items WHERE webr_id = ".$ilDB->quote($webr_id ,'integer'));
587 
588  return true;
589  }
global $ilDB
+ 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 634 of file class.ilLinkResourceItems.php.

References $ilDB, and ilObjLinkResourceAccess\_getFirstLink().

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

635  {
636  global $ilDB;
637 
638  include_once("./Modules/WebResource/classes/class.ilObjLinkResourceAccess.php");
639  return ilObjLinkResourceAccess::_getFirstLink($a_webr_id);
640  }
static _getFirstLink($a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one...
global $ilDB
+ 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 599 of file class.ilLinkResourceItems.php.

References $ilDB, $query, and $res.

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

600  {
601  global $ilDB;
602 
603  $query = "SELECT * FROM webr_items ".
604  "WHERE webr_id = ".$ilDB->quote($a_webr_id ,'integer').' '.
605  "AND active = ".$ilDB->quote(1,'integer').' ';
606  $res = $ilDB->query($query);
607  return $res->numRows() == 1 ? true : false;
608  }
global $ilDB
+ Here is the caller graph for this function:

◆ add()

ilLinkResourceItems::add (   $a_update_history = true)

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

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

373  {
374  global $ilDB;
375 
376  $this->__setLastUpdateDate(time());
377  $this->__setCreateDate(time());
378 
379  $next_id = $ilDB->nextId('webr_items');
380  $query = "INSERT INTO webr_items (link_id,title,description,target,active,disable_check,".
381  "last_update,create_date,webr_id,valid,internal) ".
382  "VALUES( ".
383  $ilDB->quote($next_id ,'integer').", ".
384  $ilDB->quote($this->getTitle() ,'text').", ".
385  $ilDB->quote($this->getDescription() ,'text').", ".
386  $ilDB->quote($this->getTarget() ,'text').", ".
387  $ilDB->quote($this->getActiveStatus() ,'integer').", ".
388  $ilDB->quote($this->getDisableCheckStatus() ,'integer').", ".
389  $ilDB->quote($this->getLastUpdateDate() ,'integer').", ".
390  $ilDB->quote($this->getCreateDate() ,'integer').", ".
391  $ilDB->quote($this->getLinkResourceId() ,'integer').", ".
392  $ilDB->quote($this->getValidStatus(),'integer'). ', '.
393  $ilDB->quote($this->getInternal(),'integer'). ' '.
394  ")";
395  $res = $ilDB->manipulate($query);
396 
397  $link_id = $next_id;
398  $this->setLinkId($link_id);
399 
400  if($a_update_history)
401  {
402  include_once("./Services/History/classes/class.ilHistory.php");
404  $this->getTitle());
405  }
406 
407  return $link_id;
408  }
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.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ cloneItems()

ilLinkResourceItems::cloneItems (   $a_new_id)

Copy web resource items.

public

Parameters
intobj_id of new object

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

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

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

◆ delete()

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

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

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

Referenced by ilObjLinkResourceGUI\deleteLinks().

225  {
226  global $ilDB;
227 
228  $item = $this->getItem($a_item_id);
229 
230  $query = "DELETE FROM webr_items ".
231  "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer')." ".
232  "AND link_id = ".$ilDB->quote($a_item_id ,'integer');
233  $res = $ilDB->manipulate($query);
234 
235  if($a_update_history)
236  {
237  include_once("./Services/History/classes/class.ilHistory.php");
238  ilHistory::_createEntry($this->getLinkResourceId(), "delete",
239  $item['title']);
240  }
241 
242  return true;
243  }
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.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActivatedItems()

ilLinkResourceItems::getActivatedItems ( )

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

References array, and getAllItems().

550  {
551  foreach($this->getAllItems() as $id => $item_data)
552  {
553  if($item_data['active'])
554  {
555  $active_items[$id] = $item_data;
556  }
557  }
558  return $active_items ? $active_items : array();
559  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ getActiveStatus()

ilLinkResourceItems::getActiveStatus ( )

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

Referenced by add(), and update().

132  {
133  return (bool) $this->status;
134  }
+ 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 466 of file class.ilLinkResourceItems.php.

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

467  {
468  global $ilDB;
469 
470  $query = "SELECT link_id FROM webr_items ".
471  "WHERE webr_id = ".$ilDB->quote($a_webr_id ,'integer');
472  $res = $ilDB->query($query);
473  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_ASSOC))
474  {
475  $link_ids[] = $row['link_id'];
476  }
477  return (array) $link_ids;
478  }
Create styles array
The data for the language used.
global $ilDB

◆ getAllItems()

ilLinkResourceItems::getAllItems ( )

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

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

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

481  {
482  global $ilDB;
483 
484  $query = "SELECT * FROM webr_items ".
485  "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer');
486 
487  $res = $this->db->query($query);
488  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
489  {
490  $items[$row->link_id]['title'] = $row->title;
491  $items[$row->link_id]['description'] = $row->description;
492  $items[$row->link_id]['target'] = $row->target;
493  $items[$row->link_id]['active'] = (bool) $row->active;
494  $items[$row->link_id]['disable_check'] = $row->disable_check;
495  $items[$row->link_id]['create_date'] = $row->create_date;
496  $items[$row->link_id]['last_update'] = $row->last_update;
497  $items[$row->link_id]['last_check'] = $row->last_check;
498  $items[$row->link_id]['valid'] = $row->valid;
499  $items[$row->link_id]['link_id'] = $row->link_id;
500  $items[$row->link_id]['internal'] = $row->internal;
501  }
502  return $items ? $items : array();
503  }
Create styles array
The data for the language used.
global $ilDB
+ 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 561 of file class.ilLinkResourceItems.php.

References array, getAllItems(), and time.

562  {
563  $period = $a_offset ? $a_offset : 0;
564  $time = time() - $period;
565 
566  foreach($this->getAllItems() as $id => $item_data)
567  {
568  if(!$item_data['disable_check'])
569  {
570  if(!$item_data['last_check'] or $item_data['last_check'] < $time)
571  {
572  $check_items[$id] = $item_data;
573  }
574  }
575  }
576  return $check_items ? $check_items : array();
577  }
Create styles array
The data for the language used.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ getCreateDate()

ilLinkResourceItems::getCreateDate ( )

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

Referenced by add().

149  {
150  return $this->c_date;
151  }
+ Here is the caller graph for this function:

◆ getDescription()

ilLinkResourceItems::getDescription ( )

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

Referenced by add(), and update().

116  {
117  return $this->description;
118  }
+ Here is the caller graph for this function:

◆ getDisableCheckStatus()

ilLinkResourceItems::getDisableCheckStatus ( )

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

Referenced by add(), and update().

140  {
141  return (bool) $this->check;
142  }
+ Here is the caller graph for this function:

◆ getInternal()

ilLinkResourceItems::getInternal ( )

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

Referenced by add(), and update().

182  {
183  return (bool) $this->internal;
184  }
+ Here is the caller graph for this function:

◆ getItem()

ilLinkResourceItems::getItem (   $a_link_id)

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

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

Referenced by delete(), and ilObjLinkResourceGUI\setValuesFromLink().

436  {
437  global $ilDB;
438 
439  $query = "SELECT * FROM webr_items ".
440  "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer')." ".
441  "AND link_id = ".$ilDB->quote($a_link_id ,'integer');
442 
443  $res = $this->db->query($query);
444  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
445  {
446  $item['title'] = $row->title;
447  $item['description'] = $row->description;
448  $item['target'] = $row->target;
449  $item['active'] = (bool) $row->active;
450  $item['disable_check'] = $row->disable_check;
451  $item['create_date'] = $row->create_date;
452  $item['last_update'] = $row->last_update;
453  $item['last_check'] = $row->last_check;
454  $item['valid'] = $row->valid;
455  $item['link_id'] = $row->link_id;
456  $item['internal'] = $row->internal;
457  }
458  return $item ? $item : array();
459  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastCheckDate()

ilLinkResourceItems::getLastCheckDate ( )

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

Referenced by update().

166  {
167  return $this->last_check;
168  }
+ Here is the caller graph for this function:

◆ getLastUpdateDate()

ilLinkResourceItems::getLastUpdateDate ( )

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

Referenced by add(), and update().

158  {
159  return $this->m_date;
160  }
+ Here is the caller graph for this function:

◆ getLinkId()

ilLinkResourceItems::getLinkId ( )

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

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

100  {
101  return $this->id;
102  }
+ Here is the caller graph for this function:

◆ getLinkResourceId()

ilLinkResourceItems::getLinkResourceId ( )

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

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

92  {
93  return $this->webr_id;
94  }
+ Here is the caller graph for this function:

◆ getLinkResourceRefId()

ilLinkResourceItems::getLinkResourceRefId ( )

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

84  {
85  return $this->webr_ref_id;
86  }

◆ getTarget()

ilLinkResourceItems::getTarget ( )

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

References $target.

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

124  {
125  return $this->target;
126  }
+ Here is the caller graph for this function:

◆ getTitle()

ilLinkResourceItems::getTitle ( )

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

References $title.

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

108  {
109  return $this->title;
110  }
+ Here is the caller graph for this function:

◆ getValidStatus()

ilLinkResourceItems::getValidStatus ( )

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

References $valid.

Referenced by add(), and update().

174  {
175  return (bool) $this->valid;
176  }
$valid
+ 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.

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

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

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  {
43  $item['title'] = $row->title;
44  $item['description'] = $row->description;
45  $item['target'] = $row->target;
46  $item['active'] = (bool) $row->active;
47  $item['disable_check'] = $row->disable_check;
48  $item['create_date'] = $row->create_date;
49  $item['last_update'] = $row->last_update;
50  $item['last_check'] = $row->last_check;
51  $item['valid'] = $row->valid;
52  $item['link_id'] = $row->link_id;
53  $item['internal'] = $row->internal;
54  }
55  return $item ? $item : array();
56 
57  }
Create styles array
The data for the language used.
global $ilDB
+ 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 615 of file class.ilLinkResourceItems.php.

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

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

616  {
617  global $ilDB;
618 
619  $query = "SELECT COUNT(*) num FROM webr_items ".
620  "WHERE webr_id = ".$ilDB->quote($a_webr_id,'integer');
621  $res = $ilDB->query($query);
623  return $row->num;
624  }
global $ilDB
+ Here is the caller graph for this function:

◆ readItem()

ilLinkResourceItems::readItem (   $a_link_id)

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

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

410  {
411  global $ilDB;
412 
413  $query = "SELECT * FROM webr_items ".
414  "WHERE link_id = ".$ilDB->quote($a_link_id ,'integer');
415 
416  $res = $this->db->query($query);
417  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
418  {
419  $this->setTitle($row->title);
420  $this->setDescription($row->description);
421  $this->setTarget($row->target);
422  $this->setActiveStatus($row->active);
423  $this->setDisableCheckStatus($row->disable_check);
424  $this->__setCreateDate($row->create_date);
425  $this->__setLastUpdateDate($row->last_update);
426  $this->setLastCheckDate($row->last_check);
427  $this->setValidStatus($row->valid);
428  $this->setLinkId($row->link_id);
429  $this->setInternal($row->internal);
430  }
431  return true;
432  }
global $ilDB
+ Here is the call graph for this function:

◆ setActiveStatus()

ilLinkResourceItems::setActiveStatus (   $a_status)

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

Referenced by readItem().

128  {
129  $this->status = (int) $a_status;
130  }
+ Here is the caller graph for this function:

◆ setDescription()

ilLinkResourceItems::setDescription (   $a_description)

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

Referenced by readItem().

112  {
113  $this->description = $a_description;
114  }
+ Here is the caller graph for this function:

◆ setDisableCheckStatus()

ilLinkResourceItems::setDisableCheckStatus (   $a_status)

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

Referenced by readItem().

136  {
137  $this->check = (int) $a_status;
138  }
+ Here is the caller graph for this function:

◆ setInternal()

ilLinkResourceItems::setInternal (   $a_status)

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

Referenced by readItem().

178  {
179  $this->internal = (bool) $a_status;
180  }
+ Here is the caller graph for this function:

◆ setLastCheckDate()

ilLinkResourceItems::setLastCheckDate (   $a_date)

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

Referenced by readItem().

162  {
163  $this->last_check = $a_date;
164  }
+ Here is the caller graph for this function:

◆ setLinkId()

ilLinkResourceItems::setLinkId (   $a_id)

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

Referenced by add(), and readItem().

96  {
97  $this->id = $a_id;
98  }
+ Here is the caller graph for this function:

◆ setLinkResourceId()

ilLinkResourceItems::setLinkResourceId (   $a_id)

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

88  {
89  $this->webr_id = $a_id;
90  }

◆ setLinkResourceRefId()

ilLinkResourceItems::setLinkResourceRefId (   $a_ref_id)

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

80  {
81  $this->webr_ref_id = $a_ref_id;
82  }

◆ setTarget()

ilLinkResourceItems::setTarget (   $a_target)

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

Referenced by readItem().

120  {
121  $this->target = $a_target;
122  }
+ Here is the caller graph for this function:

◆ setTitle()

ilLinkResourceItems::setTitle (   $a_title)

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

Referenced by readItem().

104  {
105  $this->title = $a_title;
106  }
+ Here is the caller graph for this function:

◆ setValidStatus()

ilLinkResourceItems::setValidStatus (   $a_status)

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

Referenced by readItem().

170  {
171  $this->valid = (int) $a_status;
172  }
+ 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 510 of file class.ilLinkResourceItems.php.

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

Referenced by toXML().

511  {
512  include_once './Services/Container/classes/class.ilContainer.php';
513  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
515 
516  if($mode == ilContainer::SORT_TITLE)
517  {
518  $a_items = ilUtil::sortArray($a_items, 'title','asc',false,true);
519  return $a_items;
520  }
521 
522 
523  if($mode == ilContainer::SORT_MANUAL)
524  {
525  include_once './Services/Container/classes/class.ilContainerSorting.php';
527  foreach($a_items as $link_id => $item)
528  {
529  if(isset($pos[$link_id]))
530  {
531  $sorted[$link_id] = $item;
532  $sorted[$link_id]['position'] = $pos[$link_id];
533  }
534  else
535  {
536  $unsorted[$link_id] = $item;
537  }
538  }
539  $sorted = ilUtil::sortArray((array) $sorted, 'position','asc',true,true);
540  $unsorted = ilUtil::sortArray((array) $unsorted, 'title','asc',false,true);
541  $a_items = (array) $sorted + (array) $unsorted;
542  return $a_items;
543  }
544  return $a_items;
545  }
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
Create styles array
The data for the language used.
static _lookupSortMode($a_obj_id)
lookup sort mode
static lookupPositions($a_obj_id)
Get positions of subitems.
+ 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 657 of file class.ilLinkResourceItems.php.

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

658  {
659  $items = $this->sortItems($this->getAllItems());
660 
661  $position = 0;
662  foreach((array) $items as $item_id => $item)
663  {
664  ++$position;
665  $link = self::lookupItem($this->getLinkResourceId(), $item_id);
666 
667  $writer->xmlStartTag(
668  'WebLink',
669  array(
670  'id' => $link['link_id'],
671  'active' => $link['active'] ? 1 : 0,
672  'valid' => $link['valid'] ? 1 : 0,
673  'disableValidation' => $link['disable_check'] ? 1 : 0,
674  'position' => $position,
675  'internal' => $link['internal']
676  )
677  );
678  $writer->xmlElement('Title',array(),$link['title']);
679  $writer->xmlElement('Description',array(),$link['description']);
680  $writer->xmlElement('Target',array(),$link['target']);
681 
682  // Dynamic parameters
683  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
684  foreach(ilParameterAppender::_getParams($link_id) as $param_id => $param)
685  {
686  $value = '';
687  switch($param['value'])
688  {
689  case LINKS_USER_ID:
690  $value = 'userId';
691  break;
692 
693  case LINKS_LOGIN:
694  $value = 'userName';
695  break;
696 
697  case LINKS_MATRICULATION:
698  $value = 'matriculation';
699  break;
700  }
701 
702  if(!$value)
703  {
704  // Fix for deprecated LINKS_SESSION
705  continue;
706  }
707 
708  $writer->xmlElement(
709  'DynamicParameter',
710  array(
711  'id' => $param_id,
712  'name' => $param['name'],
713  'type' => $value
714  )
715  );
716  }
717 
718  $writer->xmlEndTag('WebLink');
719  }
720  return true;
721  }
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.
const LINKS_MATRICULATION
xmlElement($tag, $attrs=NULL, $data=Null, $encode=TRUE, $escape=TRUE)
Writes a basic element (no children, just textual content)
const LINKS_LOGIN
xmlEndTag($tag)
Writes an endtag.
Create styles array
The data for the language used.
const LINKS_USER_ID
static _getParams($a_link_id)
Get dynamic parameter definitions.
sortItems($a_items)
Sort items (sorting mode depends on sorting setting)
+ Here is the call graph for this function:

◆ update()

ilLinkResourceItems::update (   $a_update_history = true)

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

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

246  {
247  global $ilDB;
248 
249  if(!$this->getLinkId())
250  {
251  return false;
252  }
253 
254  $this->__setLastUpdateDate(time());
255  $query = "UPDATE webr_items ".
256  "SET title = ".$ilDB->quote($this->getTitle() ,'text').", ".
257  "description = ".$ilDB->quote($this->getDescription() ,'text').", ".
258  "target = ".$ilDB->quote($this->getTarget() ,'text').", ".
259  "active = ".$ilDB->quote($this->getActiveStatus() ,'integer').", ".
260  "valid = ".$ilDB->quote($this->getValidStatus() ,'integer').", ".
261  "disable_check = ".$ilDB->quote($this->getDisableCheckStatus() ,'integer').", ".
262  "internal = ".$ilDB->quote($this->getInternal() ,'integer').", ".
263  "last_update = ".$ilDB->quote($this->getLastUpdateDate() ,'integer').", ".
264  "last_check = ".$ilDB->quote($this->getLastCheckDate() ,'integer')." ".
265  "WHERE link_id = ".$ilDB->quote($this->getLinkId() ,'integer')." ".
266  "AND webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer');
267  $res = $ilDB->manipulate($query);
268 
269  if($a_update_history)
270  {
271  include_once("./Services/History/classes/class.ilHistory.php");
272  ilHistory::_createEntry($this->getLinkResourceId(), "update",
273  $this->getTitle());
274  }
275 
276  return true;
277  }
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.
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ updateActive()

ilLinkResourceItems::updateActive (   $a_status)

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

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

292  {
293  global $ilDB;
294 
295  $query = "UPDATE webr_items ".
296  "SET active = ".$ilDB->quote($a_status ,'integer')." ".
297  "WHERE link_id = ".$ilDB->quote($this->getLinkId() ,'integer');
298 
299  $this->db->query($query);
300 
301  return true;
302  }
global $ilDB
+ Here is the call graph for this function:

◆ updateDisableCheck()

ilLinkResourceItems::updateDisableCheck (   $a_status)

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

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

304  {
305  global $ilDB;
306 
307  $query = "UPDATE webr_items ".
308  "SET disable_check = ".$ilDB->quote($a_status ,'integer')." ".
309  "WHERE link_id = ".$ilDB->quote($this->getLinkId() ,'integer');
310  $res = $ilDB->manipulate($query);
311 
312  return true;
313  }
global $ilDB
+ Here is the call graph for this function:

◆ updateLastCheck()

ilLinkResourceItems::updateLastCheck (   $a_offset = 0)

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

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

316  {
317  global $ilDB;
318 
319  if($a_offset)
320  {
321  $period = $a_offset ? $a_offset : 0;
322  $time = time() - $period;
323 
324 
325  $query = "UPDATE webr_items ".
326  "SET last_check = ".$ilDB->quote(time() ,'integer')." ".
327  "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer')." ".
328  "AND disable_check = '0' ".
329  "AND last_check < ".$ilDB->quote($time ,'integer');
330  $res = $ilDB->manipulate($query);
331  }
332  else
333  {
334  $query = "UPDATE webr_items ".
335  "SET last_check = ".$ilDB->quote(time() ,'integer')." ".
336  "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer')." ".
337  "AND disable_check = '0' ";
338  $res = $ilDB->manipulate($query);
339  }
340  return true;
341  }
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ 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 65 of file class.ilLinkResourceItems.php.

References $ilDB, and $query.

Referenced by ilObjLinkResource\cloneObject().

66  {
67  global $ilDB;
68 
69  $query = 'UPDATE webr_items SET '.
70  'title = '.$ilDB->quote($a_title,'text').' '.
71  'WHERE link_id = '.$ilDB->quote($a_link_id,'integer');
72  $ilDB->manipulate($query);
73  return true;
74  }
global $ilDB
+ Here is the caller graph for this function:

◆ updateValid()

ilLinkResourceItems::updateValid (   $a_status)

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

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

280  {
281  global $ilDB;
282 
283  $query = "UPDATE webr_items ".
284  "SET valid = ".$ilDB->quote($a_status ,'integer')." ".
285  "WHERE link_id = ".$ilDB->quote($this->getLinkId() ,'integer');
286  $res = $ilDB->manipulate($query);
287 
288  return true;
289  }
global $ilDB
+ Here is the call graph for this function:

◆ updateValidByCheck()

ilLinkResourceItems::updateValidByCheck (   $a_offset = 0)

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

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

344  {
345  global $ilDB;
346 
347  if($a_offset)
348  {
349  $period = $a_offset ? $a_offset : 0;
350  $time = time() - $period;
351 
352 
353  $query = "UPDATE webr_items ".
354  "SET valid = '1' ".
355  "WHERE disable_check = '0' ".
356  "AND webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer')." ".
357  "AND last_check < ".$ilDB->quote($time ,'integer');
358  $res = $ilDB->manipulate($query);
359  }
360  else
361  {
362  $query = "UPDATE webr_items ".
363  "SET valid = '1' ".
364  "WHERE disable_check = '0' ".
365  "AND webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer');
366  $res = $ilDB->manipulate($query);
367  }
368  return true;
369  }
global $ilDB
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:

◆ validate()

ilLinkResourceItems::validate ( )

Validate required settings.

Returns

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

References getTarget(), and getTitle().

647  {
648  return $this->getTarget() and $this->getTitle();
649  }
+ Here is the call graph for this function:

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