Public Member Functions

ilLinkResourceItems Class Reference

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 ()
 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

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


Member Function Documentation

ilLinkResourceItems::__setCreateDate ( a_date  ) 

Definition at line 118 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 127 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 421 of file class.ilLinkResourceItems.php.

Referenced by ilObjLinkResource::delete().

        {
                global $ilDB;
                
                $ilDB->query("DELETE FROM webr_items WHERE webr_id = '".$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 455 of file class.ilLinkResourceItems.php.

References $res, and $row.

Referenced by ilObjLinkResourceListGUI::__readLink().

        {
                global $ilDB;

                $res = $ilDB->query("SELECT * FROM webr_items WHERE webr_id = '".$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 438 of file class.ilLinkResourceItems.php.

References $res.

Referenced by ilObjLinkResourceListGUI::__checkDirectLink().

        {
                global $ilDB;

                $res = $ilDB->query("SELECT * FROM webr_items WHERE webr_id = '".$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 291 of file class.ilLinkResourceItems.php.

References $query, __setCreateDate(), __setLastUpdateDate(), ilHistory::_createEntry(), getDescription(), getLinkResourceId(), getTarget(), and getTitle().

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

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

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

                $link_id = $this->db->getLastInsertId();

                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::delete ( a_item_id,
a_update_history = true 
)

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

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

        {
                $query = "DELETE FROM webr_items ".
                        "WHERE webr_id = '".$this->getLinkResourceId()."' ".
                        "AND link_id = '".$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 388 of file class.ilLinkResourceItems.php.

References $id, and 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 105 of file class.ilLinkResourceItems.php.

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

ilLinkResourceItems::getAllItems (  ) 

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

References $query, $res, and $row.

Referenced by getActivatedItems(), and getCheckItems().

        {
                $query = "SELECT * FROM webr_items ".
                        "WHERE webr_id = '".$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 caller graph for this function:

ilLinkResourceItems::getCheckItems ( a_offset = 0  ) 

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

References $id, and 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 122 of file class.ilLinkResourceItems.php.

        {
                return $this->c_date;
        }

ilLinkResourceItems::getDescription (  ) 

Definition at line 89 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 113 of file class.ilLinkResourceItems.php.

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

ilLinkResourceItems::getItem ( a_link_id  ) 

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

References $query, $res, and $row.

        {

                $query = "SELECT * FROM webr_items ".
                        "WHERE webr_id = '".$this->getLinkResourceId()."' ".
                        "AND link_id = '".$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();
        }

ilLinkResourceItems::getLastCheckDate (  ) 

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

        {
                return $this->last_check;
        }

ilLinkResourceItems::getLastUpdateDate (  ) 

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

        {
                return $this->m_date;
        }

ilLinkResourceItems::getLinkId (  ) 

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

Referenced by update().

        {
                return $this->id;
        }

Here is the caller graph for this function:

ilLinkResourceItems::getLinkResourceId (  ) 

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

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

        {
                return $this->webr_id;
        }

Here is the caller graph for this function:

ilLinkResourceItems::getLinkResourceRefId (  ) 

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

        {
                return $this->webr_ref_id;
        }

ilLinkResourceItems::getTarget (  ) 

Definition at line 97 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 81 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 147 of file class.ilLinkResourceItems.php.

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

ilLinkResourceItems::ilLinkResourceItems ( webr_id  ) 

Constructor public.

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

        {
                global $ilDB;

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

                $this->db =& $ilDB;
        }

ilLinkResourceItems::readItem ( a_link_id  ) 

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

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

        {
                $query = "SELECT * FROM webr_items ".
                        "WHERE link_id = '".$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 101 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 85 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 109 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 135 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 69 of file class.ilLinkResourceItems.php.

Referenced by readItem().

        {
                $this->id = $a_id;
        }

Here is the caller graph for this function:

ilLinkResourceItems::setLinkResourceId ( a_id  ) 

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

        {
                $this->webr_id = $a_id;
        }

ilLinkResourceItems::setLinkResourceRefId ( a_ref_id  ) 

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

        {
                $this->webr_ref_id = $a_ref_id;
        }

ilLinkResourceItems::setTarget ( a_target  ) 

Definition at line 93 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 77 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 143 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 170 of file class.ilLinkResourceItems.php.

References $query, __setLastUpdateDate(), ilHistory::_createEntry(), getDescription(), getLinkId(), getLinkResourceId(), getTarget(), and getTitle().

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

                $this->__setLastUpdateDate(time());
                $query = "UPDATE webr_items ".
                        "SET title = '".ilUtil::prepareDBString($this->getTitle())."', ".
                        "description = '".ilUtil::prepareDBString($this->getDescription())."', ".
                        "target = '".ilUtil::prepareDBString($this->getTarget())."', ".
                        "active = '".$this->getActiveStatus()."', ".
                        "valid = '".$this->getValidStatus()."', ".
                        "disable_check = '".$this->getDisableCheckStatus()."', ".
                        "last_update = '".$this->getLastUpdateDate()."', ".
                        "last_check = '".$this->getLastCheckDate()."' ".
                        "WHERE link_id = '".$this->getLinkId()."' ".
                        "AND webr_id = '".$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 213 of file class.ilLinkResourceItems.php.

References $query.

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

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

                return true;
        }

ilLinkResourceItems::updateDisableCheck ( a_status  ) 

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

References $query.

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

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

                return true;
        }

ilLinkResourceItems::updateLastCheck ( a_offset = 0  ) 

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

References $query.

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

ilLinkResourceItems::updateValid ( a_status  ) 

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

References $query.

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

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

                return true;
        }

ilLinkResourceItems::updateValidByCheck ( a_offset = 0  ) 

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

References $query.

        {
                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 = '".$this->getLinkResourceId()."' ".
                                "AND last_check < '".$time."'";
                        
                        $this->db->query($query);
                }
                else
                {
                        $query = "UPDATE webr_items ".
                                "SET valid = '1' ".
                                "WHERE disable_check = '0' ".
                                "AND webr_id = '".$this->getLinkResourceId()."'";

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


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