Public Member Functions

ilLinkResourceItems Class Reference
[Modules/WebResource]

Class ilObjLinkResourceGUI. More...

Public Member Functions

 ilLinkResourceItems ($webr_id)
 Constructor public.
 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.
 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 ()
 getActivatedItems ()
 getCheckItems ($a_offset=0)
 _deleteAll ($webr_id)
 _isSingular ($a_webr_id)
 Check whether there is only one active link in the web resource.
 _getFirstLink ($a_webr_id)
 Get first link item Check before with _isSingular() if there is more or less than one.

Detailed Description

Class ilObjLinkResourceGUI.

Author:
Stefan Meyer <smeyer@databay.de>
Version:
Id:
class.ilLinkResourceItems.php 13221 2007-02-07 15:40:02Z smeyer

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


Member Function Documentation

ilLinkResourceItems::__setCreateDate ( a_date  ) 

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

Referenced by add(), and readItem().

        {
                $this->c_date = $a_date;
        }

Here is the caller graph for this function:

ilLinkResourceItems::__setLastUpdateDate ( a_date  ) 

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

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

        {
                $this->m_date = $a_date;
        }

Here is the caller graph for this function:

ilLinkResourceItems::_deleteAll ( webr_id  ) 

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

Referenced by ilObjLinkResource::delete().

        {
                global $ilDB;
                
                $ilDB->query("DELETE FROM webr_items WHERE webr_id = ".$ilDB->quote($webr_id));

                return true;
        }

Here is the caller graph for this function:

ilLinkResourceItems::_getFirstLink ( a_webr_id  ) 

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

Parameters:
int $a_webr_id object id of web resource
Returns:
array link item data

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

References $res.

Referenced by ilObjLinkResourceListGUI::__readLink().

        {
                global $ilDB;

                $res = $ilDB->query("SELECT * FROM webr_items WHERE webr_id = ".
                        $ilDB->quote($a_webr_id)." AND active = '1'");
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $item['title']                          = $row->title;
                        $item['description']            = $row->description;
                        $item['target']                         = $row->target;
                        $item['active']                         = (bool) $row->active;
                        $item['disable_check']          = $row->disable_check;
                        $item['create_date']            = $row->create_date;
                        $item['last_update']            = $row->last_update;
                        $item['last_check']                     = $row->last_check;
                        $item['valid']                          = $row->valid;
                        $item['link_id']                        = $row->link_id;
                }
                return $item ? $item : array();
        }

Here is the caller graph for this function:

ilLinkResourceItems::_isSingular ( a_webr_id  ) 

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_id object id of web resource
Returns:
boolean success status

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

References $res.

Referenced by ilObjLinkResourceListGUI::__checkDirectLink().

        {
                global $ilDB;

                $res = $ilDB->query("SELECT * FROM webr_items WHERE webr_id = ".$ilDB->quote($a_webr_id)." AND active = '1'");

                return $res->numRows() == 1 ? true : false;
        }

Here is the caller graph for this function:

ilLinkResourceItems::add ( a_update_history = true  ) 

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

References __setCreateDate(), __setLastUpdateDate(), ilHistory::_createEntry(), getActiveStatus(), getCreateDate(), getDescription(), getDisableCheckStatus(), getLastUpdateDate(), getLinkResourceId(), getTarget(), getTitle(), and setLinkId().

        {
                global $ilDB;
                
                $this->__setLastUpdateDate(time());
                $this->__setCreateDate(time());

                $query = "INSERT INTO webr_items ".
                        "SET title = ".$ilDB->quote($this->getTitle()).", ".
                        "description = ".$ilDB->quote($this->getDescription()).", ".
                        "target = ".$ilDB->quote($this->getTarget()).", ".
                        "active = ".$ilDB->quote($this->getActiveStatus()).", ".
                        "disable_check = ".$ilDB->quote($this->getDisableCheckStatus()).", ".
                        "last_update = ".$ilDB->quote($this->getLastUpdateDate()).", ".
                        "create_date = ".$ilDB->quote($this->getCreateDate()).", ".
                        "webr_id = ".$ilDB->quote($this->getLinkResourceId());

                $this->db->query($query);

                $link_id = $this->db->getLastInsertId();
                $this->setLinkId($link_id);
                
                if($a_update_history)
                {
                        include_once("classes/class.ilHistory.php");
                        ilHistory::_createEntry($this->getLinkResourceId(), "add",
                                                                        $this->getTitle());
                }

                return $link_id;
        }

Here is the call graph for this function:

ilLinkResourceItems::cloneItems ( a_new_id  ) 

Copy web resource items.

public

Parameters:
int obj_id of new object

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

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

        {
                include_once 'Modules/WebResource/classes/class.ilParameterAppender.php';
                $appender = new ilParameterAppender($this->getLinkResourceId());
                
                foreach($this->getAllItems() as $item)
                {
                        $new_item = new ilLinkResourceItems($a_new_id);
                        $new_item->setTitle($item['title']);
                        $new_item->setDescription($item['description']);
                        $new_item->setTarget($item['target']);
                        $new_item->setActiveStatus($item['active']);
                        $new_item->setDisableCheckStatus($item['disable_check']);
                        $new_item->setLastCheckDate($item['last_check']);
                        $new_item->setValidStatus($item['valid']);
                        $new_item->add(true);

                        // Add parameters
                        foreach(ilParameterAppender::_getParams($item['link_id']) as $param_id => $data)
                        {
                                $appender->setName($data['name']);
                                $appender->setValue($data['value']);
                                $appender->add($new_item->getLinkId());
                        }

                        unset($new_item);
                }
                return true;
        }

Here is the call graph for this function:

ilLinkResourceItems::delete ( a_item_id,
a_update_history = true 
)

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

References ilHistory::_createEntry(), getLinkResourceId(), and getTitle().

        {
                global $ilDB;
                
                $query = "DELETE FROM webr_items ".
                        "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId())." ".
                        "AND link_id = ".$ilDB->quote($a_item_id);

                $this->db->query($query);

                if($a_update_history)
                {
                        include_once("classes/class.ilHistory.php");
                        ilHistory::_createEntry($this->getLinkResourceId(), "delete",
                                                                        $this->getTitle());
                }

                return true;
        }

Here is the call graph for this function:

ilLinkResourceItems::getActivatedItems (  ) 

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

References getAllItems().

        {
                foreach($this->getAllItems() as $id => $item_data)
                {
                        if($item_data['active'])
                        {
                                $active_items[$id] = $item_data;
                        }
                }
                return $active_items ? $active_items : array();
        }

Here is the call graph for this function:

ilLinkResourceItems::getActiveStatus (  ) 

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

Referenced by add(), and update().

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

Here is the caller graph for this function:

ilLinkResourceItems::getAllItems (  ) 

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

References $res, and getLinkResourceId().

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

        {
                global $ilDB;
                
                $query = "SELECT * FROM webr_items ".
                        "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId());

                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $items[$row->link_id]['title']                          = $row->title;
                        $items[$row->link_id]['description']            = $row->description;
                        $items[$row->link_id]['target']                         = $row->target;
                        $items[$row->link_id]['active']                         = (bool) $row->active;
                        $items[$row->link_id]['disable_check']          = $row->disable_check;
                        $items[$row->link_id]['create_date']            = $row->create_date;
                        $items[$row->link_id]['last_update']            = $row->last_update;
                        $items[$row->link_id]['last_check']                     = $row->last_check;
                        $items[$row->link_id]['valid']                          = $row->valid;
                        $items[$row->link_id]['link_id']                        = $row->link_id;
                }
                return $items ? $items : array();
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilLinkResourceItems::getCheckItems ( a_offset = 0  ) 

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

References getAllItems().

        {
                $period = $a_offset ? $a_offset : 0;
                $time = time() - $period;

                foreach($this->getAllItems() as $id => $item_data)
                {
                        if(!$item_data['disable_check'])
                        {
                                if(!$item_data['last_check'] or $item_data['last_check'] < $time)
                                {
                                        $check_items[$id] = $item_data;
                                }
                        }
                }
                return $check_items ? $check_items : array();
        }

Here is the call graph for this function:

ilLinkResourceItems::getCreateDate (  ) 

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

Referenced by add().

        {
                return $this->c_date;
        }

Here is the caller graph for this function:

ilLinkResourceItems::getDescription (  ) 

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

Referenced by add(), and update().

        {
                return $this->description;
        }

Here is the caller graph for this function:

ilLinkResourceItems::getDisableCheckStatus (  ) 

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

Referenced by add(), and update().

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

Here is the caller graph for this function:

ilLinkResourceItems::getItem ( a_link_id  ) 

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

References $res, and getLinkResourceId().

        {
                global $ilDB;
                
                $query = "SELECT * FROM webr_items ".
                        "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId())." ".
                        "AND link_id = ".$ilDB->quote($a_link_id);

                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $item['title']                          = $row->title;
                        $item['description']            = $row->description;
                        $item['target']                         = $row->target;
                        $item['active']                         = (bool) $row->active;
                        $item['disable_check']          = $row->disable_check;
                        $item['create_date']            = $row->create_date;
                        $item['last_update']            = $row->last_update;
                        $item['last_check']                     = $row->last_check;
                        $item['valid']                          = $row->valid;
                        $item['link_id']                        = $row->link_id;
                }
                return $item ? $item : array();
        }

Here is the call graph for this function:

ilLinkResourceItems::getLastCheckDate (  ) 

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

Referenced by update().

        {
                return $this->last_check;
        }

Here is the caller graph for this function:

ilLinkResourceItems::getLastUpdateDate (  ) 

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

Referenced by add(), and update().

        {
                return $this->m_date;
        }

Here is the caller graph for this function:

ilLinkResourceItems::getLinkId (  ) 

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

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

        {
                return $this->id;
        }

Here is the caller graph for this function:

ilLinkResourceItems::getLinkResourceId (  ) 

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

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

        {
                return $this->webr_id;
        }

Here is the caller graph for this function:

ilLinkResourceItems::getLinkResourceRefId (  ) 

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

        {
                return $this->webr_ref_id;
        }

ilLinkResourceItems::getTarget (  ) 

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

Referenced by add(), and update().

        {
                return $this->target;
        }

Here is the caller graph for this function:

ilLinkResourceItems::getTitle (  ) 

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

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

        {
                return $this->title;
        }

Here is the caller graph for this function:

ilLinkResourceItems::getValidStatus (  ) 

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

Referenced by update().

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

Here is the caller graph for this function:

ilLinkResourceItems::ilLinkResourceItems ( webr_id  ) 

Constructor public.

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

Referenced by cloneItems().

        {
                global $ilDB;

                $this->webr_ref_id = 0;
                $this->webr_id = $webr_id;

                $this->db =& $ilDB;
        }

Here is the caller graph for this function:

ilLinkResourceItems::readItem ( a_link_id  ) 

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

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

        {
                global $ilDB;
                
                $query = "SELECT * FROM webr_items ".
                        "WHERE link_id = ".$ilDB->quote($a_link_id);

                $res = $this->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $this->setTitle($row->title);
                        $this->setDescription($row->description);
                        $this->setTarget($row->target);
                        $this->setActiveStatus($row->active);
                        $this->setDisableCheckStatus($row->disable_check);
                        $this->__setCreateDate($row->create_date);
                        $this->__setLastUpdateDate($row->last_update);
                        $this->setLastCheckDate($row->last_check);
                        $this->setValidStatus($row->valid);
                        $this->setLinkId($row->link_id);
                }
                return true;
        }

Here is the call graph for this function:

ilLinkResourceItems::setActiveStatus ( a_status  ) 

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

Referenced by readItem().

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

Here is the caller graph for this function:

ilLinkResourceItems::setDescription ( a_description  ) 

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

Referenced by readItem().

        {
                $this->description = $a_description;
        }

Here is the caller graph for this function:

ilLinkResourceItems::setDisableCheckStatus ( a_status  ) 

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

Referenced by readItem().

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

Here is the caller graph for this function:

ilLinkResourceItems::setLastCheckDate ( a_date  ) 

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

Referenced by readItem().

        {
                $this->last_check = $a_date;
        }

Here is the caller graph for this function:

ilLinkResourceItems::setLinkId ( a_id  ) 

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

Referenced by add(), and readItem().

        {
                $this->id = $a_id;
        }

Here is the caller graph for this function:

ilLinkResourceItems::setLinkResourceId ( a_id  ) 

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

        {
                $this->webr_id = $a_id;
        }

ilLinkResourceItems::setLinkResourceRefId ( a_ref_id  ) 

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

        {
                $this->webr_ref_id = $a_ref_id;
        }

ilLinkResourceItems::setTarget ( a_target  ) 

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

Referenced by readItem().

        {
                $this->target = $a_target;
        }

Here is the caller graph for this function:

ilLinkResourceItems::setTitle ( a_title  ) 

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

Referenced by readItem().

        {
                $this->title = $a_title;
        }

Here is the caller graph for this function:

ilLinkResourceItems::setValidStatus ( a_status  ) 

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

Referenced by readItem().

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

Here is the caller graph for this function:

ilLinkResourceItems::update ( a_update_history = true  ) 

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

References __setLastUpdateDate(), ilHistory::_createEntry(), getActiveStatus(), getDescription(), getDisableCheckStatus(), getLastCheckDate(), getLastUpdateDate(), getLinkId(), getLinkResourceId(), getTarget(), getTitle(), and getValidStatus().

        {
                global $ilDB;
                
                if(!$this->getLinkId())
                {
                        return false;
                }

                $this->__setLastUpdateDate(time());
                $query = "UPDATE webr_items ".
                        "SET title = ".$ilDB->quote($this->getTitle()).", ".
                        "description = ".$ilDB->quote($this->getDescription()).", ".
                        "target = ".$ilDB->quote($this->getTarget()).", ".
                        "active = ".$ilDB->quote($this->getActiveStatus()).", ".
                        "valid = ".$ilDB->quote($this->getValidStatus()).", ".
                        "disable_check = ".$ilDB->quote($this->getDisableCheckStatus()).", ".
                        "last_update = ".$ilDB->quote($this->getLastUpdateDate()).", ".
                        "last_check = ".$ilDB->quote($this->getLastCheckDate())." ".
                        "WHERE link_id = ".$ilDB->quote($this->getLinkId())." ".
                        "AND webr_id = ".$ilDB->quote($this->getLinkResourceId());

                $this->db->query($query);

                if($a_update_history)
                {
                        include_once("classes/class.ilHistory.php");
                        ilHistory::_createEntry($this->getLinkResourceId(), "update",
                                                                        $this->getTitle());
                }

                return true;
        }

Here is the call graph for this function:

ilLinkResourceItems::updateActive ( a_status  ) 

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

References getLinkId().

        {
                global $ilDB;
                
                $query = "UPDATE webr_items ".
                        "SET active = ".$ilDB->quote($a_status)." ".
                        "WHERE link_id = ".$ilDB->quote($this->getLinkId());

                $this->db->query($query);

                return true;
        }

Here is the call graph for this function:

ilLinkResourceItems::updateDisableCheck ( a_status  ) 

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

References getLinkId().

        {
                global $ilDB;
                
                $query = "UPDATE webr_items ".
                        "SET disable_check = ".$ilDB->quote($a_status)." ".
                        "WHERE link_id = ".$ilDB->quote($this->getLinkId());

                $this->db->query($query);

                return true;
        }

Here is the call graph for this function:

ilLinkResourceItems::updateLastCheck ( a_offset = 0  ) 

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

References getLinkResourceId().

        {
                global $ilDB;
                
                if($a_offset)
                {
                        $period = $a_offset ? $a_offset : 0;
                        $time = time() - $period;
                        
                        
                        $query = "UPDATE webr_items ".
                                "SET last_check = ".$ilDB->quote(time())." ".
                                "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId())." ".
                                "AND disable_check = '0' ".
                                "AND last_check < ".$ilDB->quote($time);
                        
                        $this->db->query($query);
                }
                else
                {
                        $query = "UPDATE webr_items ".
                                "SET last_check = ".$ilDB->quote(time())." ".
                                "WHERE webr_id = ".$ilDB->quote($this->getLinkResourceId())." ".
                                "AND disable_check = '0' ";
                        
                        $this->db->query($query);
                }
                return true;
        }

Here is the call graph for this function:

ilLinkResourceItems::updateValid ( a_status  ) 

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

References getLinkId().

        {
                global $ilDB;
                
                $query = "UPDATE webr_items ".
                        "SET valid = ".$ilDB->quote($a_status)." ".
                        "WHERE link_id = ".$ilDB->quote($this->getLinkId());

                $this->db->query($query);

                return true;
        }

Here is the call graph for this function:

ilLinkResourceItems::updateValidByCheck ( a_offset = 0  ) 

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

References getLinkResourceId().

        {
                global $ilDB;
                
                if($a_offset)
                {
                        $period = $a_offset ? $a_offset : 0;
                        $time = time() - $period;
                        
                        
                        $query = "UPDATE webr_items ".
                                "SET valid = '1' ".
                                "WHERE disable_check = '0' ".
                                "AND webr_id = ".$ilDB->quote($this->getLinkResourceId())." ".
                                "AND last_check < ".$ilDB->quote($time);
                        
                        $this->db->query($query);
                }
                else
                {
                        $query = "UPDATE webr_items ".
                                "SET valid = '1' ".
                                "WHERE disable_check = '0' ".
                                "AND webr_id = ".$ilDB->quote($this->getLinkResourceId());

                        $this->db->query($query);
                }
                return true;
        }

Here is the call graph for this function:


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