Public Member Functions | Data Fields

ilObjForum Class Reference

Inheritance diagram for ilObjForum:
Collaboration diagram for ilObjForum:

Public Member Functions

 ilObjForum ($a_id=0, $a_call_by_reference=true)
 Constructor public.
 read ($a_force_db=false)
 read object data from db into object
 getDefaultView ()
 setDefaultView ($a_default_view)
 isAnonymized ()
 setAnonymized ($a_status)
 _lookupThreadSubject ($a_thread_id)
 getCountUnread ($a_usr_id, $a_thread_id=0)
 _getCountUnread ($a_frm_id, $a_usr_id, $a_thread_id=0)
 markThreadRead ($a_usr_id, $a_thread_id)
 markAllThreadsRead ($a_usr_id)
 markPostRead ($a_usr_id, $a_thread_id, $a_post_id)
 isRead ($a_usr_id, $a_post_id)
 getCountNew ($a_usr_id, $a_thread_id=0)
 __getCountNew ($a_usr_id, $a_thread_id=0)
 isNew ($a_usr_id, $a_thread_id, $a_post_id)
 updateLastAccess ($a_usr_id, $a_thread_id)
 _updateOldAccess ($a_usr_id)
 _deleteUser ($a_usr_id)
 _deleteReadEntries ($a_post_id)
 _deleteAccessEntries ($a_thread_id)
 update ()
 update forum data
 ilClone ($a_parent_ref, $a_with_content=true)
 copy all entries of a forum object.
 delete ()
 delete forum and all related data
 initDefaultRoles ()
 init default roles settings public
 notify ($a_event, $a_ref_id, $a_parent_non_rbac_id, $a_node_id, $a_params=0)
 notifys an object about an event occured Based on the event happend, each object may decide how it reacts.
 createSettings ()
 __read ()
 __getLastThreadAccess ($a_usr_id, $a_thread_id)
 isNotificationEnabled ($user_id, $thread_id)
 Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (result == 0).
 isStatisticsEnabled ()
 return if statistics are enabled
 setStatisticsEnabled ($enabled)

Data Fields

 $default_view = 1
 $anonymized = false
 Defines if a forum is anonymized or not private.
 $Forum
 $statisticsEnabled
 defines if a forum can show ranking statistics private

Detailed Description

Definition at line 39 of file class.ilObjForum.php.


Member Function Documentation

ilObjForum::__getCountNew ( a_usr_id,
a_thread_id = 0 
)

Definition at line 324 of file class.ilObjForum.php.

References $counter, $query, $res, $row, __getLastThreadAccess(), and isRead().

Referenced by getCountNew().

        {
                $counter = 0;
                
                $timest = $this->__getLastThreadAccess($a_usr_id,$a_thread_id);

                // CHECK FOR NEW
                $query = "SELECT pos_pk FROM frm_posts ".
                        "WHERE pos_thr_fk = '".$a_thread_id."' ".
                        "AND ( pos_date > '".date('Y-m-d H:i:s',$timest)."' ".
                        "OR pos_update > '".date('Y-m-d H:i:s',$timest)."') ".
                        "AND pos_usr_id != '".$a_usr_id."'";
                
                $res  =  $this->ilias->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        if(!$this->isRead($a_usr_id,$row->pos_pk))
                        {
                                ++$counter;
                        }
                }
                return $counter;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjForum::__getLastThreadAccess ( a_usr_id,
a_thread_id 
)

Definition at line 808 of file class.ilObjForum.php.

References $query, $res, and $row.

Referenced by __getCountNew(), and isNew().

        {
                $query = "SELECT * FROM frm_thread_access ".
                        "WHERE thread_id = '".$a_thread_id."' ".
                        "AND usr_id = '".$a_usr_id."'";

                $res = $this->ilias->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $last_access = $row->access_old;
                }
                if(!$last_access)
                {
                        // Set last access according to administration setting
                        $last_access = NEW_DEADLINE;
                }
                return $last_access;
        }

Here is the caller graph for this function:

ilObjForum::__read (  ) 

Definition at line 793 of file class.ilObjForum.php.

References $query, $res, and $row.

Referenced by ilObjForum(), and read().

        {
                $query = "SELECT * FROM frm_settings WHERE ".
                        "obj_id = '".$this->getId()."'";

                $res = $this->ilias->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $this->default_view = $row->default_view;
                        $this->anonymized = $row->anonymized ? true : false;
                        $this->statisticsEnabled = $row->statistics_enabled ? true : false;
                }
                return true;
        }

Here is the caller graph for this function:

ilObjForum::_deleteAccessEntries ( a_thread_id  ) 

Definition at line 455 of file class.ilObjForum.php.

References $query.

Referenced by ilForum::deletePost().

        {
                global $ilDB;

                $query = "DELETE FROM frm_thread_access ".
                        "WHERE thread_id = '".$a_thread_id."'";

                $ilDB->query($query);

                return true;
        }

Here is the caller graph for this function:

ilObjForum::_deleteReadEntries ( a_post_id  ) 

Definition at line 443 of file class.ilObjForum.php.

References $query.

Referenced by ilForum::deletePost().

        {
                global $ilDB;

                $query = "DELETE FROM frm_user_read ".
                        "WHERE post_id = '".$a_post_id."'";

                $ilDB->query($query);

                return true;
        }

Here is the caller graph for this function:

ilObjForum::_deleteUser ( a_usr_id  ) 

Definition at line 425 of file class.ilObjForum.php.

References $query.

Referenced by ilObjUser::delete().

        {
                global $ilDB;

                $query = "DELETE FROM frm_user_read ".
                        "WHERE usr_id = '".$a_usr_id."'";

                $ilDB->query($query);

                $query = "DELETE FROM frm_thread_access ".
                        "WHERE usr_id = '".$a_usr_id."'";

                $ilDB->query($query);

                return true;
        }

Here is the caller graph for this function:

ilObjForum::_getCountUnread ( a_frm_id,
a_usr_id,
a_thread_id = 0 
)

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

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

Referenced by getCountUnread(), and ilObjForumListGUI::getProperties().

        {
                global $ilBench, $ilDB;

                $ilBench->start("Forum",'getCountRead');
                if(!$a_thread_id)
                {
                        // Get topic_id
                        $query = "SELECT top_pk FROM frm_data ".
                                "WHERE top_frm_fk = '".$a_frm_id."'";

                        $res = $ilDB->query($query);
                        while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                        {
                                $topic_id = $row->top_pk;
                        }

                        // Get number of posts
                        $query = "SELECT COUNT(pos_pk) as num_posts FROM frm_posts ".
                                "WHERE pos_top_fk = '".$topic_id."'";

                        $res = $ilDB->query($query);
                        while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                        {
                                $num_posts = $row->num_posts;
                        }

                        $query = "SELECT COUNT(post_id) count_read FROM frm_user_read ".
                                "WHERE obj_id = '".$a_frm_id."' ".
                                "AND usr_id = '".$a_usr_id."'";

                        $res = $ilDB->query($query);
                        while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                        {
                                $count_read = $row->count_read;
                        }
                        $unread = $num_posts - $count_read;

                        $ilBench->stop("Forum",'getCountRead');
                        return $unread > 0 ? $unread : 0;
                }
                else
                {
                        $query = "SELECT COUNT(pos_pk) as num_posts FROM frm_posts ".
                                "WHERE pos_thr_fk = '".$a_thread_id."'";

                        $res = $ilDB->query($query);
                        while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                        {
                                $num_posts = $row->num_posts;
                        }


                        $query = "SELECT COUNT(post_id) as count_read FROM frm_user_read ".
                                "WHERE obj_id = '".$a_frm_id."' ".
                                "AND usr_id = '".$a_usr_id."' ".
                                "AND thread_id = '".$a_thread_id."'";

                        $res = $ilDB->query($query);
                        while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                        {
                                $count_read = $row->count_read;
                        }
                        $unread = $num_posts - $count_read;

                        $ilBench->stop("Forum",'getCountRead');
                        return $unread > 0 ? $unread : 0;
                }
                $ilBench->stop("Forum",'getCountRead');
                return false;
        }

Here is the caller graph for this function:

ilObjForum::_lookupThreadSubject ( a_thread_id  ) 

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

References $query, $res, and $row.

Referenced by ilSearchResultPresentationGUI::__appendChildLinks().

        {
                global $ilDB;

                $query = "SELECT thr_subject FROM frm_threads ".
                        "WHERE thr_pk = '".$a_thread_id."'";
                $res = $ilDB->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        return $row->thr_subject;
                }
                return '';
        }

Here is the caller graph for this function:

ilObjForum::_updateOldAccess ( a_usr_id  ) 

Definition at line 401 of file class.ilObjForum.php.

References ilObject::$ilias, and $query.

Referenced by ilStartUpGUI::showLogin().

        {
                global $ilDB,$ilias;

                $query = "UPDATE frm_thread_access ".
                        "SET access_old = access_last ".
                        "WHERE usr_id = '".$a_usr_id."'";

                $ilDB->query($query);
                
                // Delete old entries

                $new_deadline = time() - 60 * 60 * 24 * 7 * ($ilias->getSetting('frm_store_new') ?
                                                                                                         $ilias->getSetting('frm_store_new') : 
                                                                                                         8);
                
                $query = "DELETE FROM frm_thread_access ".
                        "WHERE access_last < '".$new_deadline."'";

                $ilDB->query($query);
                
                return true;
        }

Here is the caller graph for this function:

ilObjForum::createSettings (  ) 

Definition at line 779 of file class.ilObjForum.php.

References $query, and isStatisticsEnabled().

        {               
                $query = "INSERT INTO frm_settings ".
                        "SET obj_id = '".$this->getId()."', ".
                        "default_view = '".$this->getDefaultView()."', ".
                        "anonymized = '".($this->isAnonymized() ? 1 : 0) ."', ".
                        "statistics_enabled= '".($this->isStatisticsEnabled() ? 1 : 0)."'";     
                $this->ilias->db->query($query);

                return true;
        }

Here is the call graph for this function:

ilObjForum::delete (  ) 

delete forum and all related data

public

Returns:
boolean true if all object data were removed; false if only a references were removed

Reimplemented from ilObject.

Definition at line 633 of file class.ilObjForum.php.

References $query, and ilObject::getId().

        {               
                // always call parent delete function first!!
                if (!parent::delete())
                {
                        return false;
                }
                // DELETE ATTACHMENTS
                $tmp_file_obj =& new ilFileDataForum($this->getId());
                $tmp_file_obj->delete();
                unset($tmp_file_obj);
                
                $this->Forum->setWhereCondition("top_frm_fk = ".$this->getId());
                $topData = $this->Forum->getOneTopic(); 
                
                $resThreads = $this->Forum->getThreadList($topData["top_pk"]);  
                
                while ($thrData = $resThreads->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        // delete tree
                        $query = "DELETE FROM frm_posts_tree WHERE thr_fk = '".$thrData["thr_pk"]."'";
                        $this->ilias->db->query($query);
                        
                        // delete posts
                        $query = "DELETE FROM frm_posts WHERE pos_thr_fk = '".$thrData["thr_pk"]."'";
                        $this->ilias->db->query($query);
                        
                        // delete threads
                        $query = "DELETE FROM frm_threads WHERE thr_pk = '".$thrData["thr_pk"]."'";
                        $this->ilias->db->query($query);
                }
                // delete topic
                $query = "DELETE FROM frm_data WHERE top_frm_fk = '".$this->getId()."'";
                $this->ilias->db->query($query);

                // delete settings
                $query = "DELETE FROM frm_settings WHERE obj_id = '".$this->getId()."'";
                $this->ilias->db->query($query);

                // delete read infos
                $query = "DELETE FROM frm_user_read WHERE obj_id = '".$this->getId()."'";
                $this->ilias->db->query($query);

                // delete thread access entries
                $query = "DELETE FROM frm_thread_access WHERE obj_id = '".$this->getId()."'";
                $this->ilias->db->query($query);

                return true;
        }

Here is the call graph for this function:

ilObjForum::getCountNew ( a_usr_id,
a_thread_id = 0 
)

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

References $counter, $ilBench, $query, $res, $row, and __getCountNew().

        {
                global $ilBench;

                $ilBench->start('Forum','getCountNew');
                if($a_thread_id)
                {
                        $num = $this->__getCountNew($a_usr_id,$a_thread_id);
                        $ilBench->stop('Forum','getCountNew');

                        return $num;
                }
                else
                {
                        $counter = 0;

                        // Get threads
                        $query = "SELECT DISTINCT(pos_thr_fk) FROM frm_posts,frm_data ".
                                "WHERE top_pk = pos_top_fk ".
                                "AND top_frm_fk = '".$this->getId()."' ";

                        $res = $this->ilias->db->query($query);
                        
                        while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                        {
                                $counter += $this->__getCountNew($a_usr_id,$row->pos_thr_fk);
                        }
                        $ilBench->stop('Forum','getCountNew');
                        return $counter;
                }
                return 0;
        }

Here is the call graph for this function:

ilObjForum::getCountUnread ( a_usr_id,
a_thread_id = 0 
)

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

References _getCountUnread(), and ilObject::getId().

        {
                return $this->_getCountUnread($this->getId(),$a_usr_id,$a_thread_id);
        }

Here is the call graph for this function:

ilObjForum::getDefaultView (  ) 

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

        {
                return $this->default_view;
        }

ilObjForum::ilClone ( a_parent_ref,
a_with_content = true 
)

copy all entries of a forum object.

attention: frm_data is linked with ILIAS system (object_data) with the obj_id and NOT ref_id!

public

Parameters:
integer ref_id of parent object
boolean copy with or without content (threads)
Returns:
integer new ref id

Definition at line 508 of file class.ilObjForum.php.

References $forumObj, $q, $query, $rbacadmin, ilObject::getId(), ilUtil::prepareDBString(), and ilObjUser::updateActiveRoles().

        {               
                global $rbacadmin;

                // always call parent ilClone function first!!
                $new_ref_id = parent::ilClone($a_parent_ref);
                
                // get object instance of cloned forum
                $forumObj =& $this->ilias->obj_factory->getInstanceByRefId($new_ref_id);

                // COPY settings
                $query = "INSERT INTO frm_settings ".
                        "SET obj_id = '".$forumObj->getId()."', ".
                        "default_view = '".$this->getDefaultView()."', ".
                        "anonymized = '".($this->isAnonymized() ? 1 : 0)."'";
                $this->ilias->db->query($query);
                

                // COPY ATTACHMENTS
                $tmp_file_obj =& new ilFileDataForum($this->getId());

                // create a local role folder & default roles
                $roles = $forumObj->initDefaultRoles();

                // ...finally assign moderator role to creator of forum object
                $rbacadmin->assignUser($roles[0], $forumObj->getOwner(), "n");
                ilObjUser::updateActiveRoles($forumObj->getOwner());

                // STOP HERE if without_content is selected
                if(!$a_with_content)
                {
                        $this->Forum->setWhereCondition("top_frm_fk = ".$this->getId());
                        $topData = $this->Forum->getOneTopic();

                        $query = "INSERT INTO frm_data ".
                                "VALUES('0','".$forumObj->getId()."','".ilUtil::prepareDBString($topData['top_name'])."','".
                                ilUtil::prepareDBString($topData['top_description'])."','0','0','','".$roles[0]."',NOW(),'0',NOW(),'0','".
                                $this->ilias->account->getId()."')";

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

                        return $new_ref_id;
                }
                

                // get forum data
                $this->Forum->setWhereCondition("top_frm_fk = ".$this->getId());
                $topData = $this->Forum->getOneTopic();
                
                // insert new forum as a copy 
                $q = "INSERT INTO frm_data ";
                $q .= "(top_frm_fk,top_name,top_description,top_num_posts,top_num_threads,top_last_post,top_mods,top_date,".
                        "top_usr_id,visits,top_update,update_user) ";
                $q .= "VALUES ";
                $q .= "('".$forumObj->getId()."','".addslashes($topData["top_name"])."','".addslashes($topData["top_description"])."','".
                        $topData["top_num_posts"]."','".$topData["top_num_threads"]."','".$topData["top_last_post"]."','".$roles[0]."','".
                        $topData["top_date"]."','".$topData["top_usr_id"]."','".$topData["visits"]."','".$topData["top_update"]."','".
                        $topData["update_user"]."')";
                $this->ilias->db->query($q);

                // get last insert id and return it
                $new_top_pk = $this->ilias->db->getLastInsertId();

                // get threads from old forum and insert them as copys
                $resThreads = $this->Forum->getThreadList($topData["top_pk"]);  
                
                while ($thrData = $resThreads->fetchRow(DB_FETCHMODE_ASSOC))
                {
                        $q = "INSERT INTO frm_threads ";
                        $q .= "(thr_top_fk,thr_usr_id,thr_subject,thr_date,thr_update,thr_num_posts,thr_last_post,visits) ";
                        $q .= "VALUES ";
                        $q .= "('".$new_top_pk."','".$thrData["thr_usr_id"]."','".addslashes($thrData["thr_subject"])."','".
                                $thrData["thr_date"]."','".$thrData["thr_update"]."','".$thrData["thr_num_posts"]."','".
                                $thrData["thr_last_post"]."','".$thrData["visits"]."')";
                        $this->ilias->db->query($q);
                        
                        // get last insert id and return it
                        $new_thr_pk = $this->ilias->db->getLastInsertId();
                                                
                        // get posts from old thread and insert them as copys
                        $resPosts = $this->Forum->getPostList($topData["top_pk"], $thrData["thr_pk"]);
                        
                        while ($posData = $resPosts->fetchRow(DB_FETCHMODE_ASSOC))
                        {
                                $q2 = "INSERT INTO frm_posts ";
                                $q2 .= "(pos_top_fk,pos_thr_fk,pos_usr_id,pos_message,pos_date,pos_update) ";
                                $q2 .= "VALUES ";
                                $q2 .= "('".$new_top_pk."','".$new_thr_pk."','".$posData["pos_usr_id"]."','".
                                        addslashes($posData["pos_message"])."','".$posData["pos_date"]."','".$posData["pos_update"]."')";
                                $this->ilias->db->query($q2);

                                // get last insert id and return it
                                $new_pos_pk = $this->ilias->db->getLastInsertId();

                                // CLONE POST ATTACHMENTS
                                $tmp_file_obj->setPosId($posData["pos_pk"]);
                                $tmp_file_obj->ilClone($forumObj->getId(),$new_pos_pk);
                                
                                // get tree data from old post and insert copy
                            $q3 = "SELECT * FROM frm_posts_tree ";
                                $q3 .= "WHERE pos_fk = '".$posData["pos_pk"]."' ";         
                                $q3 .= "AND thr_fk = '".$thrData["thr_pk"]."'";
                                $treeData = $this->ilias->db->getRow($q3, DB_FETCHMODE_ASSOC);
                                                                
                                $q4 = "INSERT INTO frm_posts_tree (thr_fk,pos_fk,parent_pos,lft,rgt,depth,date) ";
                                $q4 .= "VALUES ";
                                $q4 .= "('".$new_thr_pk."','".$new_pos_pk."','".$treeData["parent_pos"]."','".
                                        $treeData["lft"]."','".$treeData["rgt"]."','".$treeData["depth"]."','".$treeData["date"]."')";
                                $this->ilias->db->query($q4);
                        }
                }

                // always destroy objects in clone method because clone() is recursive and creates instances for each object in subtree!
                unset($forumObj);

                // ... and finally always return new reference ID!!
                return $new_ref_id;
        }

Here is the call graph for this function:

ilObjForum::ilObjForum ( a_id = 0,
a_call_by_reference = true 
)

Constructor public.

Parameters:
integer reference_id or object_id
boolean treat the id as reference_id (true) or object_id (false)

Definition at line 74 of file class.ilObjForum.php.

References ilObject::$ilias, __read(), and ilObject::ilObject().

        {
                global $ilias;

                /*
                 * this constant is used for the information if a single post is marked as new
                 * All threads/posts created before this date are never marked as new
                 * Default is 8 weeks
                 *
                 */
                $new_deadline = time() - 60 * 60 * 24 * 7 * ($ilias->getSetting('frm_store_new') ? 
                                                                                                         $ilias->getSetting('frm_store_new') : 
                                                                                                         8);
                define('NEW_DEADLINE',$new_deadline);
        
                $this->type = "frm";
                $this->ilObject($a_id,$a_call_by_reference);
                
                // TODO: needs to rewrite scripts that are using Forum outside this class
                $this->Forum =& new ilForum();

                if($a_id)
                {
                        $this->__read();
                }
        }

Here is the call graph for this function:

ilObjForum::initDefaultRoles (  ) 

init default roles settings public

Returns:
array object IDs of created local roles.

Reimplemented from ilObject.

Definition at line 688 of file class.ilObjForum.php.

References $permissions, $rbacadmin, ilObject::createRoleFolder(), ilObject::getId(), and ilObject::getRefId().

        {
                global $rbacadmin;
                
                // create a local role folder
                $rfoldObj = $this->createRoleFolder();

                // create moderator role and assign role to rolefolder...
                $roleObj = $rfoldObj->createRole("il_frm_moderator_".$this->getRefId(),"Moderator of forum obj_no.".$this->getId());
                $roles[] = $roleObj->getId();

                // grant permissions: visible,read,write,edit_post,delete_post
                $permissions = array(1,2,3,4,6,9,10);
                $rbacadmin->grantPermission($roles[0],$permissions,$this->getRefId());

                unset($rfoldObj);
                unset($roleObj);

                return $roles ? $roles : array();
        }

Here is the call graph for this function:

ilObjForum::isAnonymized (  ) 

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

        {
                return $this->anonymized ? true : false;
        }

ilObjForum::isNew ( a_usr_id,
a_thread_id,
a_post_id 
)

Definition at line 348 of file class.ilObjForum.php.

References $query, $res, __getLastThreadAccess(), and isRead().

        {
                if($this->isRead($a_usr_id,$a_post_id))
                {
                        return false;
                }
                $timest = $this->__getLastThreadAccess($a_usr_id,$a_thread_id);
                
                $query = "SELECT * FROM frm_posts ".
                        "WHERE pos_pk = '".$a_post_id."' ".
                        "AND (pos_date > '".date('Y-m-d H:i:s',$timest)."' ".
                        "OR pos_update > '".date('Y-m-d H:i:s',$timest)."') ".
                        "AND pos_usr_id != '".$a_usr_id."'";

                $res = $this->ilias->db->query($query);

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

Here is the call graph for this function:

ilObjForum::isNotificationEnabled ( user_id,
thread_id 
)

Check whether a user's notification about new posts in a thread is enabled (result > 0) or not (result == 0).

Parameters:
integer user_id A user's ID
integer thread_id ID of the thread
Returns:
integer Result private

Definition at line 835 of file class.ilObjForum.php.

References $q, and $user_id.

        {
                $q = "SELECT COUNT(*) FROM frm_notification WHERE ";
                $q .= "user_id = '" . $user_id . "' AND ";
                $q .= "thread_id = '". $thread_id . "'";
                return $this->ilias->db->getOne($q);
        }

ilObjForum::isRead ( a_usr_id,
a_post_id 
)

Definition at line 277 of file class.ilObjForum.php.

References $query, and $res.

Referenced by __getCountNew(), and isNew().

        {
                $query = "SELECT * FROM frm_user_read ".
                        "WHERE usr_id = '".$a_usr_id."' ".
                        "AND post_id = '".$a_post_id."'";

                $res = $this->ilias->db->query($query);

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

Here is the caller graph for this function:

ilObjForum::isStatisticsEnabled (  ) 

return if statistics are enabled

Definition at line 846 of file class.ilObjForum.php.

Referenced by createSettings(), and update().

        {
                return $this->statisticsEnabled? true: false;
        }

Here is the caller graph for this function:

ilObjForum::markAllThreadsRead ( a_usr_id  ) 

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

References $query, $res, $row, and markThreadRead().

        {
                $query = "SELECT * FROM frm_data, frm_threads ".
                        "WHERE top_frm_fk = '".$this->getId()."' ".
                        "AND top_pk = thr_top_fk ";

                $res = $this->ilias->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $this->markThreadRead($a_usr_id,$row->thr_pk);
                }

                return true;
        }

Here is the call graph for this function:

ilObjForum::markPostRead ( a_usr_id,
a_thread_id,
a_post_id 
)

Definition at line 250 of file class.ilObjForum.php.

References $query, and $res.

Referenced by markThreadRead().

        {
                // CHECK IF ENTRY EXISTS
                $query = "SELECT * FROM frm_user_read ".
                        "WHERE usr_id = '".$a_usr_id."' ".
                        "AND obj_id = '".$this->getId()."' ".
                        "AND thread_id = '".$a_thread_id."' ".
                        "AND post_id = '".$a_post_id."'";

                $res = $this->ilias->db->query($query);
                if($res->numRows())
                {
                        return true;
                }
                

                $query = "INSERT INTO frm_user_read ".
                        "SET usr_id = '".$a_usr_id."', ".
                        "obj_id = '".$this->getId()."', ".
                        "thread_id = '".$a_thread_id."', ".
                        "post_id = '".$a_post_id."'";

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

                return true;
        }

Here is the caller graph for this function:

ilObjForum::markThreadRead ( a_usr_id,
a_thread_id 
)

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

References $query, $res, $row, and markPostRead().

Referenced by markAllThreadsRead().

        {
                // Get all post ids
                $query = "SELECT * FROM frm_posts ".
                        "WHERE pos_thr_fk = '".$a_thread_id."'";

                $res = $this->ilias->db->query($query);
                while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
                {
                        $this->markPostRead($a_usr_id,$a_thread_id,$row->pos_pk);
                }
                return true;
        }

Here is the call graph for this function:

Here is the caller graph for this function:

ilObjForum::notify ( a_event,
a_ref_id,
a_parent_non_rbac_id,
a_node_id,
a_params = 0 
)

notifys an object about an event occured Based on the event happend, each object may decide how it reacts.

public

Parameters:
string event
integer reference id of object where the event occured
array passes optional parameters if required
Returns:
boolean

Reimplemented from ilObject.

Definition at line 719 of file class.ilObjForum.php.

References $_GET, $tree, and ilObject::getType().

        {
                global $tree;
                
                switch ($a_event)
                {
                        case "link":
                                
                                //var_dump("<pre>",$a_params,"</pre>");
                                //echo "Forum ".$this->getRefId()." triggered by link event. Objects linked into target object ref_id: ".$a_ref_id;
                                //exit;
                                
                                break;
                        
                        case "cut":

                                //echo "Forum ".$this->getRefId()." triggered by cut event. Objects are removed from target object ref_id: ".$a_ref_id;
                                //exit;
                                
                                break;
                                
                        case "copy":
                        
                                //var_dump("<pre>",$a_params,"</pre>");
                                //echo "Forum ".$this->getRefId()." triggered by copy event. Objects are copied into target object ref_id: ".$a_ref_id;
                                //exit;
                                
                                break;

                        case "paste":
                                
                                //echo "Forum ".$this->getRefId()." triggered by paste (cut) event. Objects are pasted into target object ref_id: ".$a_ref_id;
                                //exit;
                                
                                break;
                        
                        case "new":
                                
                                //echo "Forum ".$this->getRefId()." triggered by paste (new) event. Objects are applied to target object ref_id: ".$a_ref_id;
                                //exit;
                                
                                break;
                }
                
                
                // At the beginning of the recursive process it avoids second call of the notify function with the same parameter
                if ($a_node_id==$_GET["ref_id"])
                {       
                        $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
                        $parent_type = $parent_obj->getType();
                        if($parent_type == $this->getType())
                        {
                                $a_node_id = (int) $tree->getParentId($a_node_id);
                        }
                }
                
                parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);

        }

Here is the call graph for this function:

ilObjForum::read ( a_force_db = false  ) 

read object data from db into object

Parameters:
boolean public

Reimplemented from ilObject.

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

References __read().

        {
                parent::read($a_force_db);

                $this->__read();
        }

Here is the call graph for this function:

ilObjForum::setAnonymized ( a_status  ) 

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

        {
                $this->anonymized = $a_status ? true : false;
        }

ilObjForum::setDefaultView ( a_default_view  ) 

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

        {
                return $this->default_view = (int) $a_default_view;
        }

ilObjForum::setStatisticsEnabled ( enabled  ) 
Parameters:
enabled true or false

Definition at line 854 of file class.ilObjForum.php.

        {
                $this->statisticsEnabled = $enabled?true: false;
        }

ilObjForum::update (  ) 

update forum data

public

Reimplemented from ilObject.

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

References $_SESSION, $query, $res, ilObject::getDescription(), ilObject::getId(), ilObject::getTitle(), and isStatisticsEnabled().

        {
                if (parent::update())
                {                       
                        $query = "UPDATE frm_data ".
                                         "SET ".
                                         "top_name = '".ilUtil::prepareDBString($this->getTitle())."',".
                                         "top_description = '".ilUtil::prepareDBString($this->getDescription())."',".
                                         "top_update = '".date("Y-m-d H:i:s")."',".
                                         "update_user = '".(int) $_SESSION["AccountId"]."' ".
                                         "WHERE top_frm_fk = '".(int) $this->getId()."'";
                        $res = $this->ilias->db->query($query);

                        $query = "REPLACE INTO frm_settings ".
                                "SET obj_id = '".$this->getId()."', ".
                                "default_view = '".$this->getDefaultView()."', ".
                                "anonymized = '".($this->isAnonymized() ? 1 : 0)."', ".
                                "statistics_enabled= '".($this->isStatisticsEnabled() ? 1 : 0)."'";
                        
                        $this->ilias->db->query($query);
                
                        return true;
                }

                return false;
        }

Here is the call graph for this function:

ilObjForum::updateLastAccess ( a_usr_id,
a_thread_id 
)

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

References $query, and $res.

        {
                $query = "SELECT * FROM frm_thread_access ".
                        "WHERE usr_id = '".$a_usr_id."' ".
                        "AND obj_id = '".$this->getId()."' ".
                        "AND thread_id = '".$a_thread_id."'";

                $res = $this->ilias->db->query($query);
                if($res->numRows())
                {
                        $query = "UPDATE frm_thread_access ".
                                "SET access_last = '".time()."' ".
                                "WHERE usr_id = '".$a_usr_id."' ".
                                "AND obj_id = '".$this->getId()."' ".
                                "AND thread_id = '".$a_thread_id."'";

                        $this->ilias->db->query($query);
                }
                else
                {
                        $query = "INSERT INTO frm_thread_access ".
                                "SET access_last = '".time()."', ".
                                "access_old = '0', ".
                                "usr_id = '".$a_usr_id."', ".
                                "obj_id = '".$this->getId()."', ".
                                "thread_id = '".$a_thread_id."'";

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

                return true;
        }


Field Documentation

ilObjForum::$anonymized = false

Defines if a forum is anonymized or not private.

Definition at line 52 of file class.ilObjForum.php.

ilObjForum::$default_view = 1

Definition at line 46 of file class.ilObjForum.php.

ilObjForum::$Forum

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

ilObjForum::$statisticsEnabled

defines if a forum can show ranking statistics private

Definition at line 66 of file class.ilObjForum.php.


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