Public Member Functions

ilObjForumListGUI Class Reference
[Modules/Forum]

Class ilObjForumListGUI. More...

Inheritance diagram for ilObjForumListGUI:
Collaboration diagram for ilObjForumListGUI:

Public Member Functions

 ilObjForumListGUI ()
 constructor
 setChildId ($a_child_id)
 getChildId ()
 init ()
 initialisation
 initItem ($a_ref_id, $a_obj_id, $a_title="", $a_description="")
 inititialize new item
 getProperties ()
 Get item properties.
 getCommandFrame ($a_cmd)
 Get command target.
 getCommandLink ($a_cmd)
 Get command link url.

Detailed Description

Class ilObjForumListGUI.

Author:
Alex Killing <alex.killing@gmx.de>
Id:
class.ilObjForumListGUI.php 16248 2008-03-13 16:09:09Z mjansen

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


Member Function Documentation

ilObjForumListGUI::getChildId (  ) 

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

Referenced by getCommandLink().

        {
                return $this->child_id;
        }

Here is the caller graph for this function:

ilObjForumListGUI::getCommandFrame ( a_cmd  ) 

Get command target.

Parameters:
int $a_ref_id reference id
string $a_cmd command

Reimplemented from ilObjectListGUI.

Definition at line 294 of file class.ilObjForumListGUI.php.

References ilFrameTargetInfo::_getFrame().

        {
                // separate method for this line
                $target = ilFrameTargetInfo::_getFrame("MainContent");

                return $target;
        }

Here is the call graph for this function:

ilObjForumListGUI::getCommandLink ( a_cmd  ) 

Get command link url.

Overwrite this method, if link target is not build by ctrl class (e.g. "forum.php"). This is the case for all links now, but bringing everything to ilCtrl should be realised in the future.

Parameters:
string $a_cmd command
Returns:
string command link url

Reimplemented from ilObjectListGUI.

Definition at line 302 of file class.ilObjForumListGUI.php.

References getChildId().

        {
                switch($a_cmd)
                {
                        case 'thread':
                                return "repository.php?cmd=showThreadFrameset&cmdClass=ilobjforumgui&ref_id=".$this->ref_id.
                                        "&thr_pk=".$this->getChildId();

                        case 'posting':
                                $thread_post = $this->getChildId();
                                return "repository.php?cmd=showThreadFrameset&cmdClass=ilobjforumgui&target=1&ref_id=".$this->ref_id.
                                        "&thr_pk=".$thread_post[0].
                                        "&pos_pk=".$thread_post[1]."#".$thread_post[1];

                        default:
                                return parent::getCommandLink($a_cmd);
                }
        }

Here is the call graph for this function:

ilObjForumListGUI::getProperties (  ) 

Get item properties.

Overwrite this method to add properties at the bottom of the item html

Returns:
array array of property arrays: "alert" (boolean) => display as an alert property (usually in red) "property" (string) => property name "value" (string) => property value

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

References $lng, ilObject::_exists(), ilFrameTargetInfo::_getFrame(), ilForum::_getModerators(), ilObjUser::_lookupLogin(), ilObjUser::_lookupPref(), formatDate(), and ilForumProperties::getInstance().

        {
                global $lng, $ilUser, $ilAccess, $ilDB;

                $props = array();

                // Return no properties if read access isn't granted (e.g. course visibility)
                if (!$ilAccess->checkAccess('read', '', $this->ref_id))
                {
                        return array();
                }

                include_once('./Modules/Forum/classes/class.ilForum.php');
                include_once('./Modules/Forum/classes/class.ilObjForum.php');
                
                $forumObj = new ilObjForum($this->ref_id);
                $frm =& $forumObj->Forum;               
                $frm->setForumId($forumObj->getId());
                $frm->setForumRefId($forumObj->getRefId());
                
                $frm->setWhereCondition('top_frm_fk = '.$ilDB->quote($frm->getForumId()));
                // Forum Data
                $frmData = $frm->getOneTopic(); 
                
                // Moderators (Role: Moderator)
                include_once('./Services/User/classes/class.ilObjUser.php');
                $MODS = ilForum::_getModerators($this->ref_id);
                $moderators = "";
                for ($i = 0; $i < count($MODS); $i++)
                {
                        if ($moderators != "")
                        {
                                $moderators .= ", ";
                        }
                        
                        if (ilObjUser::_lookupPref($MODS[$i], 'public_profile') == 'y')
                        {
                                $moderators .= "<a class=\"il_ItemProperty\" target=\"".
                                ilFrameTargetInfo::_getFrame("MainContent").
                                "\" href=\"repository.php?cmd=showUser&cmdClass=ilobjforumgui&ref_id=".$this->ref_id."&user=".
                                $MODS[$i]."&offset=".$Start."\">".ilObjUser::_lookupLogin($MODS[$i])."</a>";
                        }
                        else
                        {
                                $moderators .= ilObjUser::_lookupLogin($MODS[$i]);
                        }                       
                }
                $props[] = array('alert' => false, 'property' => $lng->txt('forums_moderators'),
                        'value' => $moderators);
                
                // threads
                $threads = $frm->getAllThreads($frmData['top_pk']);
                $props[] = array('alert' => false, 'property' => $lng->txt('forums_threads'),
                        'value' => count($threads));    
                        
                // Posts
                $num_posts_total = 0;
                $num_unread_total = 0;
                $num_new_total = 0;
                $visits_total = 0;
                
                $objLastPost = null;
                foreach ($threads as $thread)
                {                       
                        $objTmpLastPost = null;
                        
                        if ($ilAccess->checkAccess('moderate_frm', '', $this->ref_id))
                        {                               
                                $num_posts = $thread->countPosts();     
                                $num_posts_total += $num_posts;                                 
                                $num_unread_total =      $num_posts - $thread->countReadPosts($ilUser->getId());
                                $num_new_total += $thread->countNewPosts($ilUser->getId());
                                
                                $objTmpLastPost = $thread->getLastPost();
                        }
                        else
                        {
                                $num_posts = $thread->countActivePosts();                               
                                $num_posts_total += $num_posts;
                                $num_unread_total += $num_posts - $thread->countReadActivePosts($ilUser->getId());
                                $num_new_total += $thread->countNewActivePosts($ilUser->getId());
                                
                                $objTmpLastPost = $thread->getLastActivePost(); 
                        }
                        
                        $visits_total += $thread->getVisits();
                        
                        // Last Post
                        if ((!is_object($objLastPost) && is_object($objTmpLastPost)) ||
                                (is_object($objLastPost) && is_object($objTmpLastPost) && $objLastPost->getCreateDate() < $objTmpLastPost->getCreateDate()))
                        {
                                $objLastPost = $objTmpLastPost;
                        }
                }

                // Posts (Unread)
                $alert = ($num_unread_total > 0) ? true : false;
                $props[] = array('alert' => $alert, 'property' => $lng->txt('forums_articles').' ('.$lng->txt('unread').')',
                        'value' => $num_posts_total.' ('.$num_unread_total.')');                        
                
                // New
                $alert = ($num_new_total > 0)   ? true : false;
                $props[] = array('alert' => $alert, 'property' => $lng->txt('forums_new_articles'),
                        'value' => $num_new_total);

                // Visits
                $props[] = array('alert' => false, 'property' => $lng->txt('visits'),
                        'value' => $visits_total);      
                        

                // Last Post
                if ($num_posts > 0)
                {                       
                        if (is_object($objLastPost))
                        {
                                $last_user = $this->frm->getUserData($objLastPost->getUserId(), $objLastPost->getImportName());
                                
                                $lpCont = "<a class=\"il_ItemProperty\" target=\"".
                                ilFrameTargetInfo::_getFrame('MainContent').
                                "\" href=\"repository.php?cmd=showThreadFrameset&cmdClass=ilobjforumgui&target=true&pos_pk=".
                                $objLastPost->getId()."&thr_pk=".$objLastPost->getThreadId()."&ref_id=".
                                $this->ref_id."#".$objLastPost->getId()."\">".$frm->limitMsgString($objLastPost->getMessage())."</a> ".
                                strtolower($lng->txt('from'))."&nbsp;";
                                
                                if (ilForumProperties::getInstance($this->obj_id)->isAnonymized())
                                {
                                        if ($objLastPost->getUserAlias() != '')
                                        {
                                                $lpCont .= $objLastPost->getUserAlias();
                                                
                                        }
                                        else
                                        {
                                                $lpCont .= $lng->txt('forums_anonymous');                                       
                                        }
                                        
                                        $lpCont .= ', '.ilFormat::formatDate($objLastPost->getCreateDate());
                                }
                                else
                                {
                                        if ($objLastPost->getUserId() && ilObject::_exists($objLastPost->getUserId()) && $last_user['public_profile'] == 'y')
                                        {
                                                $lpCont .= "<a class=\"il_ItemProperty\" target=\"".
                                                ilFrameTargetInfo::_getFrame('MainContent').
                                                "\" href=\"repository.php?cmd=showUser&cmdClass=ilobjforumgui&ref_id=".$this->ref_id."&user=".
                                                        $last_user['usr_id']."&offset=".$Start."\">".$last_user['login']."</a>, ";
                                                $lpCont .= ilFormat::formatDate($objLastPost->getCreateDate());
                                        }
                                        else
                                        {
                                                $lpCont .= $last_user['login'].', '.ilFormat::formatDate($objLastPost->getCreateDate());
                                        }
                                }
                                                        
                                /* At least one (last) posting? */
                                if ($lpCont != '')
                                {
                                        $props[] = array(
                                                                'alert' => false,
                                                                'newline' => true,
                                                                'property' => $lng->txt('forums_last_post'),
                                                                'value' => $lpCont
                                        );
                                }
                        }
                }

                /* Forum anonymized? */
                if (ilForumProperties::getInstance($this->obj_id)->isAnonymized())
                {
                        $props[] = array(
                                                'alert' => false,
                                                'newline' => true,
                                                'property' => $lng->txt('forums_anonymized'),
                                                'value' => $lng->txt('yes')
                        );
                }

                return $props;
        }

Here is the call graph for this function:

ilObjForumListGUI::ilObjForumListGUI (  ) 

constructor

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

References ilObjectListGUI::ilObjectListGUI().

        {
                $this->ilObjectListGUI();
        }

Here is the call graph for this function:

ilObjForumListGUI::init (  ) 

initialisation

Reimplemented from ilObjectListGUI.

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

References ilObjForumAccess::_getCommands().

        {
                $this->static_link_enabled = true;
                $this->delete_enabled = true;
                $this->cut_enabled = true;
                $this->subscribe_enabled = true;
                $this->link_enabled = true;
                $this->payment_enabled = false;
                $this->type = "frm";
                $this->gui_class_name = "ilobjforumgui";
                
                // general commands array
                include_once('./Modules/Forum/classes/class.ilObjForumAccess.php');
                $this->commands = ilObjForumAccess::_getCommands();
        }

Here is the call graph for this function:

ilObjForumListGUI::initItem ( a_ref_id,
a_obj_id,
a_title = "",
a_description = "" 
)

inititialize new item

Parameters:
int $a_ref_id reference id
int $a_obj_id object id
string $a_title title
string $a_description description

Reimplemented from ilObjectListGUI.

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

References ilObjectFactory::getInstanceByRefId().

        {
                global $ilDB;
                
                parent::initItem($a_ref_id, $a_obj_id, $a_title, $a_description);
                $this->frm_obj =& ilObjectFactory::getInstanceByRefId($this->ref_id);
                $this->frm =& new ilForum();
                $this->frm->setForumRefId($a_ref_id);
                $this->frm->setWhereCondition("top_frm_fk = ".$ilDB->quote($a_obj_id));
        }

Here is the call graph for this function:

ilObjForumListGUI::setChildId ( a_child_id  ) 

Definition at line 47 of file class.ilObjForumListGUI.php.

        {
                $this->child_id = $a_child_id;
        }


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