ILIAS  release_4-4 Revision
ilLinkResourceItems Class Reference

Class ilObjLinkResourceGUI. More...

+ Collaboration diagram for ilLinkResourceItems:

Public Member Functions

 ilLinkResourceItems ($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 ()
 
 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)
 
 _deleteAll ($webr_id)
 
 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 _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.

Member Function Documentation

◆ __setCreateDate()

ilLinkResourceItems::__setCreateDate (   $a_date)

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

Referenced by add(), and readItem().

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

◆ __setLastUpdateDate()

ilLinkResourceItems::__setLastUpdateDate (   $a_date)

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

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

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

◆ _deleteAll()

ilLinkResourceItems::_deleteAll (   $webr_id)

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

Referenced by ilObjLinkResource\delete().

568  {
569  global $ilDB;
570 
571  $ilDB->manipulate("DELETE FROM webr_items WHERE webr_id = ".$ilDB->quote($webr_id ,'integer'));
572 
573  return true;
574  }
+ 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 619 of file class.ilLinkResourceItems.php.

References ilObjLinkResourceAccess\_getFirstLink().

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

620  {
621  global $ilDB;
622 
623  include_once("./Modules/WebResource/classes/class.ilObjLinkResourceAccess.php");
624  return ilObjLinkResourceAccess::_getFirstLink($a_webr_id);
625  }
static _getFirstLink($a_webr_id)
Get first link item Check before with _isSingular() if there is more or less than one...
+ 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 584 of file class.ilLinkResourceItems.php.

References $query, and $res.

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

585  {
586  global $ilDB;
587 
588  $query = "SELECT * FROM webr_items ".
589  "WHERE webr_id = ".$ilDB->quote($a_webr_id ,'integer').' '.
590  "AND active = ".$ilDB->quote(1,'integer').' ';
591  $res = $ilDB->query($query);
592  return $res->numRows() == 1 ? true : false;
593  }
+ Here is the caller graph for this function:

◆ add()

ilLinkResourceItems::add (   $a_update_history = true)

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

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

362  {
363  global $ilDB;
364 
365  $this->__setLastUpdateDate(time());
366  $this->__setCreateDate(time());
367 
368  $next_id = $ilDB->nextId('webr_items');
369  $query = "INSERT INTO webr_items (link_id,title,description,target,active,disable_check,".
370  "last_update,create_date,webr_id,valid) ".
371  "VALUES( ".
372  $ilDB->quote($next_id ,'integer').", ".
373  $ilDB->quote($this->getTitle() ,'text').", ".
374  $ilDB->quote($this->getDescription() ,'text').", ".
375  $ilDB->quote($this->getTarget() ,'text').", ".
376  $ilDB->quote($this->getActiveStatus() ,'integer').", ".
377  $ilDB->quote($this->getDisableCheckStatus() ,'integer').", ".
378  $ilDB->quote($this->getLastUpdateDate() ,'integer').", ".
379  $ilDB->quote($this->getCreateDate() ,'integer').", ".
380  $ilDB->quote($this->getLinkResourceId() ,'integer').", ".
381  $ilDB->quote($this->getValidStatus(),'integer'). ' '.
382  ")";
383  $res = $ilDB->manipulate($query);
384 
385  $link_id = $next_id;
386  $this->setLinkId($link_id);
387 
388  if($a_update_history)
389  {
390  include_once("./Services/History/classes/class.ilHistory.php");
392  $this->getTitle());
393  }
394 
395  return $link_id;
396  }
_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.
+ 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 184 of file class.ilLinkResourceItems.php.

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

185  {
186  include_once 'Modules/WebResource/classes/class.ilParameterAppender.php';
187  $appender = new ilParameterAppender($this->getLinkResourceId());
188 
189  foreach($this->getAllItems() as $item)
190  {
191  $new_item = new ilLinkResourceItems($a_new_id);
192  $new_item->setTitle($item['title']);
193  $new_item->setDescription($item['description']);
194  $new_item->setTarget($item['target']);
195  $new_item->setActiveStatus($item['active']);
196  $new_item->setDisableCheckStatus($item['disable_check']);
197  $new_item->setLastCheckDate($item['last_check']);
198  $new_item->setValidStatus($item['valid']);
199  $new_item->add(true);
200 
201  // Add parameters
202  foreach(ilParameterAppender::_getParams($item['link_id']) as $param_id => $data)
203  {
204  $appender->setName($data['name']);
205  $appender->setValue($data['value']);
206  $appender->add($new_item->getLinkId());
207  }
208 
209  unset($new_item);
210  }
211  return true;
212  }
ilLinkResourceItems($webr_id)
Constructor public.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
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 214 of file class.ilLinkResourceItems.php.

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

Referenced by ilObjLinkResourceGUI\deleteLinks().

215  {
216  global $ilDB;
217 
218  $item = $this->getItem($a_item_id);
219 
220  $query = "DELETE FROM webr_items ".
221  "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer')." ".
222  "AND link_id = ".$ilDB->quote($a_item_id ,'integer');
223  $res = $ilDB->manipulate($query);
224 
225  if($a_update_history)
226  {
227  include_once("./Services/History/classes/class.ilHistory.php");
228  ilHistory::_createEntry($this->getLinkResourceId(), "delete",
229  $item['title']);
230  }
231 
232  return true;
233  }
_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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getActivatedItems()

ilLinkResourceItems::getActivatedItems ( )

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

References getAllItems().

535  {
536  foreach($this->getAllItems() as $id => $item_data)
537  {
538  if($item_data['active'])
539  {
540  $active_items[$id] = $item_data;
541  }
542  }
543  return $active_items ? $active_items : array();
544  }
+ Here is the call graph for this function:

◆ getActiveStatus()

ilLinkResourceItems::getActiveStatus ( )

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

Referenced by add(), and update().

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

References $query, $res, $row, and DB_FETCHMODE_ASSOC.

453  {
454  global $ilDB;
455 
456  $query = "SELECT link_id FROM webr_items ".
457  "WHERE webr_id = ".$ilDB->quote($a_webr_id ,'integer');
458  $res = $ilDB->query($query);
459  while($row = $res->fetchRow(DB_FETCHMODE_ASSOC))
460  {
461  $link_ids[] = $row['link_id'];
462  }
463  return (array) $link_ids;
464  }
const DB_FETCHMODE_ASSOC
Definition: class.ilDB.php:10

◆ getAllItems()

ilLinkResourceItems::getAllItems ( )

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

References $query, $res, $row, DB_FETCHMODE_OBJECT, and getLinkResourceId().

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

467  {
468  global $ilDB;
469 
470  $query = "SELECT * FROM webr_items ".
471  "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer');
472 
473  $res = $this->db->query($query);
474  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
475  {
476  $items[$row->link_id]['title'] = $row->title;
477  $items[$row->link_id]['description'] = $row->description;
478  $items[$row->link_id]['target'] = $row->target;
479  $items[$row->link_id]['active'] = (bool) $row->active;
480  $items[$row->link_id]['disable_check'] = $row->disable_check;
481  $items[$row->link_id]['create_date'] = $row->create_date;
482  $items[$row->link_id]['last_update'] = $row->last_update;
483  $items[$row->link_id]['last_check'] = $row->last_check;
484  $items[$row->link_id]['valid'] = $row->valid;
485  $items[$row->link_id]['link_id'] = $row->link_id;
486  }
487  return $items ? $items : array();
488  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ 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 546 of file class.ilLinkResourceItems.php.

References getAllItems().

547  {
548  $period = $a_offset ? $a_offset : 0;
549  $time = time() - $period;
550 
551  foreach($this->getAllItems() as $id => $item_data)
552  {
553  if(!$item_data['disable_check'])
554  {
555  if(!$item_data['last_check'] or $item_data['last_check'] < $time)
556  {
557  $check_items[$id] = $item_data;
558  }
559  }
560  }
561  return $check_items ? $check_items : array();
562  }
+ Here is the call graph for this function:

◆ getCreateDate()

ilLinkResourceItems::getCreateDate ( )

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

Referenced by add().

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

◆ getDescription()

ilLinkResourceItems::getDescription ( )

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

Referenced by add(), and update().

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

◆ getDisableCheckStatus()

ilLinkResourceItems::getDisableCheckStatus ( )

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

Referenced by add(), and update().

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

◆ getItem()

ilLinkResourceItems::getItem (   $a_link_id)

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

References $query, $res, $row, DB_FETCHMODE_OBJECT, and getLinkResourceId().

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

423  {
424  global $ilDB;
425 
426  $query = "SELECT * FROM webr_items ".
427  "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer')." ".
428  "AND link_id = ".$ilDB->quote($a_link_id ,'integer');
429 
430  $res = $this->db->query($query);
431  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
432  {
433  $item['title'] = $row->title;
434  $item['description'] = $row->description;
435  $item['target'] = $row->target;
436  $item['active'] = (bool) $row->active;
437  $item['disable_check'] = $row->disable_check;
438  $item['create_date'] = $row->create_date;
439  $item['last_update'] = $row->last_update;
440  $item['last_check'] = $row->last_check;
441  $item['valid'] = $row->valid;
442  $item['link_id'] = $row->link_id;
443  }
444  return $item ? $item : array();
445  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastCheckDate()

ilLinkResourceItems::getLastCheckDate ( )

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

Referenced by update().

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

◆ getLastUpdateDate()

ilLinkResourceItems::getLastUpdateDate ( )

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

Referenced by add(), and update().

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

◆ getLinkId()

ilLinkResourceItems::getLinkId ( )

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

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

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

◆ getLinkResourceId()

ilLinkResourceItems::getLinkResourceId ( )

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

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

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

◆ getLinkResourceRefId()

ilLinkResourceItems::getLinkResourceRefId ( )

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

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

◆ getTarget()

ilLinkResourceItems::getTarget ( )

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

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

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

◆ getTitle()

ilLinkResourceItems::getTitle ( )

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

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

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

◆ getValidStatus()

ilLinkResourceItems::getValidStatus ( )

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

References $valid.

Referenced by add(), and update().

173  {
174  return (bool) $this->valid;
175  }
$valid
+ Here is the caller graph for this function:

◆ ilLinkResourceItems()

ilLinkResourceItems::ilLinkResourceItems (   $webr_id)

Constructor public.

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

Referenced by cloneItems().

22  {
23  global $ilDB;
24 
25  $this->webr_ref_id = 0;
26  $this->webr_id = $webr_id;
27 
28  $this->db =& $ilDB;
29  }
+ 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 $query, $res, $row, and DB_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(DB_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  }
54  return $item ? $item : array();
55 
56  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ 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 600 of file class.ilLinkResourceItems.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

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

601  {
602  global $ilDB;
603 
604  $query = "SELECT COUNT(*) num FROM webr_items ".
605  "WHERE webr_id = ".$ilDB->quote($a_webr_id,'integer');
606  $res = $ilDB->query($query);
607  $row = $res->fetchRow(DB_FETCHMODE_OBJECT);
608  return $row->num;
609  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the caller graph for this function:

◆ readItem()

ilLinkResourceItems::readItem (   $a_link_id)

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

References $query, $res, $row, __setCreateDate(), __setLastUpdateDate(), DB_FETCHMODE_OBJECT, setActiveStatus(), setDescription(), setDisableCheckStatus(), setLastCheckDate(), setLinkId(), setTarget(), setTitle(), and setValidStatus().

398  {
399  global $ilDB;
400 
401  $query = "SELECT * FROM webr_items ".
402  "WHERE link_id = ".$ilDB->quote($a_link_id ,'integer');
403 
404  $res = $this->db->query($query);
405  while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
406  {
407  $this->setTitle($row->title);
408  $this->setDescription($row->description);
409  $this->setTarget($row->target);
410  $this->setActiveStatus($row->active);
411  $this->setDisableCheckStatus($row->disable_check);
412  $this->__setCreateDate($row->create_date);
413  $this->__setLastUpdateDate($row->last_update);
414  $this->setLastCheckDate($row->last_check);
415  $this->setValidStatus($row->valid);
416  $this->setLinkId($row->link_id);
417  }
418  return true;
419  }
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
+ Here is the call graph for this function:

◆ setActiveStatus()

ilLinkResourceItems::setActiveStatus (   $a_status)

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

Referenced by readItem().

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

◆ setDescription()

ilLinkResourceItems::setDescription (   $a_description)

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

Referenced by readItem().

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

◆ setDisableCheckStatus()

ilLinkResourceItems::setDisableCheckStatus (   $a_status)

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

Referenced by readItem().

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

◆ setLastCheckDate()

ilLinkResourceItems::setLastCheckDate (   $a_date)

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

Referenced by readItem().

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

◆ setLinkId()

ilLinkResourceItems::setLinkId (   $a_id)

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

Referenced by add(), and readItem().

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

◆ setLinkResourceId()

ilLinkResourceItems::setLinkResourceId (   $a_id)

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

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

◆ setLinkResourceRefId()

ilLinkResourceItems::setLinkResourceRefId (   $a_ref_id)

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

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

◆ setTarget()

ilLinkResourceItems::setTarget (   $a_target)

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

Referenced by readItem().

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

◆ setTitle()

ilLinkResourceItems::setTitle (   $a_title)

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

Referenced by readItem().

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

◆ setValidStatus()

ilLinkResourceItems::setValidStatus (   $a_status)

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

Referenced by readItem().

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

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

496  {
497  include_once './Services/Container/classes/class.ilContainer.php';
498  include_once './Services/Container/classes/class.ilContainerSortingSettings.php';
500 
501  if($mode == ilContainer::SORT_TITLE)
502  {
503  $a_items = ilUtil::sortArray($a_items, 'title','asc',false,true);
504  return $a_items;
505  }
506 
507 
508  if($mode == ilContainer::SORT_MANUAL)
509  {
510  include_once './Services/Container/classes/class.ilContainerSorting.php';
512  foreach($a_items as $link_id => $item)
513  {
514  if(isset($pos[$link_id]))
515  {
516  $sorted[$link_id] = $item;
517  $sorted[$link_id]['position'] = $pos[$link_id];
518  }
519  else
520  {
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 sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
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:

◆ toXML()

ilLinkResourceItems::toXML ( ilXmlWriter  $writer)

Write link XML.

Parameters
ilXmlWriter$writer
Returns

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

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

643  {
644  foreach(self::getAllItemIds($this->getLinkResourceId()) as $link_id)
645  {
646  $link = self::lookupItem($this->getLinkResourceId(), $link_id);
647 
648  $writer->xmlStartTag(
649  'WebLink',
650  array(
651  'id' => $link['link_id'],
652  'active' => $link['active'] ? 1 : 0,
653  'valid' => $link['valid'] ? 1 : 0,
654  'disableValidation' => $link['disable_check'] ? 1 : 0,
655 # 'action' => 'Delete'
656  )
657  );
658  $writer->xmlElement('Title',array(),$link['title']);
659  $writer->xmlElement('Description',array(),$link['description']);
660  $writer->xmlElement('Target',array(),$link['target']);
661 
662  // Dynamic parameters
663  include_once './Modules/WebResource/classes/class.ilParameterAppender.php';
664  foreach(ilParameterAppender::_getParams($link_id) as $param_id => $param)
665  {
666  $value = '';
667  switch($param['value'])
668  {
669  case LINKS_USER_ID:
670  $value = 'userId';
671  break;
672 
673  case LINKS_LOGIN:
674  $value = 'userName';
675  break;
676 
677  case LINKS_MATRICULATION:
678  $value = 'matriculation';
679  break;
680  }
681 
682  if(!$value)
683  {
684  // Fix for deprecated LINKS_SESSION
685  continue;
686  }
687 
688  $writer->xmlElement(
689  'DynamicParameter',
690  array(
691  'id' => $param_id,
692  'name' => $param['name'],
693  'type' => $value
694  )
695  );
696  }
697 
698  $writer->xmlEndTag('WebLink');
699  }
700  return true;
701  }
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.
const LINKS_USER_ID
static _getParams($a_link_id)
Get dynamic parameter definitions.
+ Here is the call graph for this function:

◆ update()

ilLinkResourceItems::update (   $a_update_history = true)

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

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

236  {
237  global $ilDB;
238 
239  if(!$this->getLinkId())
240  {
241  return false;
242  }
243 
244  $this->__setLastUpdateDate(time());
245  $query = "UPDATE webr_items ".
246  "SET title = ".$ilDB->quote($this->getTitle() ,'text').", ".
247  "description = ".$ilDB->quote($this->getDescription() ,'text').", ".
248  "target = ".$ilDB->quote($this->getTarget() ,'text').", ".
249  "active = ".$ilDB->quote($this->getActiveStatus() ,'integer').", ".
250  "valid = ".$ilDB->quote($this->getValidStatus() ,'integer').", ".
251  "disable_check = ".$ilDB->quote($this->getDisableCheckStatus() ,'integer').", ".
252  "last_update = ".$ilDB->quote($this->getLastUpdateDate() ,'integer').", ".
253  "last_check = ".$ilDB->quote($this->getLastCheckDate() ,'integer')." ".
254  "WHERE link_id = ".$ilDB->quote($this->getLinkId() ,'integer')." ".
255  "AND webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer');
256  $res = $ilDB->manipulate($query);
257 
258  if($a_update_history)
259  {
260  include_once("./Services/History/classes/class.ilHistory.php");
261  ilHistory::_createEntry($this->getLinkResourceId(), "update",
262  $this->getTitle());
263  }
264 
265  return true;
266  }
_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.
+ Here is the call graph for this function:

◆ updateActive()

ilLinkResourceItems::updateActive (   $a_status)

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

References $query, and getLinkId().

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

◆ updateDisableCheck()

ilLinkResourceItems::updateDisableCheck (   $a_status)

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

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

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

◆ updateLastCheck()

ilLinkResourceItems::updateLastCheck (   $a_offset = 0)

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

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

305  {
306  global $ilDB;
307 
308  if($a_offset)
309  {
310  $period = $a_offset ? $a_offset : 0;
311  $time = time() - $period;
312 
313 
314  $query = "UPDATE webr_items ".
315  "SET last_check = ".$ilDB->quote(time() ,'integer')." ".
316  "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer')." ".
317  "AND disable_check = '0' ".
318  "AND last_check < ".$ilDB->quote($time ,'integer');
319  $res = $ilDB->manipulate($query);
320  }
321  else
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  $res = $ilDB->manipulate($query);
328  }
329  return true;
330  }
+ 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 64 of file class.ilLinkResourceItems.php.

References $query.

Referenced by ilObjLinkResource\cloneObject().

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

◆ updateValid()

ilLinkResourceItems::updateValid (   $a_status)

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

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

269  {
270  global $ilDB;
271 
272  $query = "UPDATE webr_items ".
273  "SET valid = ".$ilDB->quote($a_status ,'integer')." ".
274  "WHERE link_id = ".$ilDB->quote($this->getLinkId() ,'integer');
275  $res = $ilDB->manipulate($query);
276 
277  return true;
278  }
+ Here is the call graph for this function:

◆ updateValidByCheck()

ilLinkResourceItems::updateValidByCheck (   $a_offset = 0)

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

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

333  {
334  global $ilDB;
335 
336  if($a_offset)
337  {
338  $period = $a_offset ? $a_offset : 0;
339  $time = time() - $period;
340 
341 
342  $query = "UPDATE webr_items ".
343  "SET valid = '1' ".
344  "WHERE disable_check = '0' ".
345  "AND webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer')." ".
346  "AND last_check < ".$ilDB->quote($time ,'integer');
347  $res = $ilDB->manipulate($query);
348  }
349  else
350  {
351  $query = "UPDATE webr_items ".
352  "SET valid = '1' ".
353  "WHERE disable_check = '0' ".
354  "AND webr_id = ".$ilDB->quote($this->getLinkResourceId() ,'integer');
355  $res = $ilDB->manipulate($query);
356  }
357  return true;
358  }
+ Here is the call graph for this function:

◆ validate()

ilLinkResourceItems::validate ( )

Validate required settings.

Returns

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

References getTarget(), and getTitle().

632  {
633  return $this->getTarget() and $this->getTitle();
634  }
+ Here is the call graph for this function:

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