Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00035 include_once "class.ilObjectListGUI.php";
00036
00037 class ilObjForumListGUI extends ilObjectListGUI
00038 {
00043 function ilObjForumListGUI()
00044 {
00045 $this->ilObjectListGUI();
00046 }
00047
00048 function setChildId($a_child_id)
00049 {
00050 $this->child_id = $a_child_id;
00051 }
00052 function getChildId()
00053 {
00054 return $this->child_id;
00055 }
00056
00057
00061 function init()
00062 {
00063 $this->delete_enabled = true;
00064 $this->cut_enabled = true;
00065 $this->subscribe_enabled = true;
00066 $this->link_enabled = true;
00067 $this->payment_enabled = false;
00068 $this->type = "frm";
00069 $this->gui_class_name = "ilobjforumgui";
00070
00071
00072 include_once('class.ilObjForumAccess.php');
00073 $this->commands = ilObjForumAccess::_getCommands();
00074 }
00075
00084 function initItem($a_ref_id, $a_obj_id, $a_title = "", $a_description = "")
00085 {
00086 parent::initItem($a_ref_id, $a_obj_id, $a_title, $a_description);
00087 $this->frm_obj =& ilObjectFactory::getInstanceByRefId($this->ref_id);
00088 $this->frm =& new ilForum();
00089 $this->frm->setForumRefId($a_ref_id);
00090 $this->frm->setWhereCondition("top_frm_fk = ".$a_obj_id);
00091 }
00092
00093
00105 function getProperties()
00106 {
00107 global $lng, $ilUser,$ilAccess;
00108
00109 $props = array();
00110
00111
00112 if(!$ilAccess->checkAccess('read','',$this->ref_id))
00113 {
00114 return array();
00115 }
00116
00117 include_once("classes/class.ilForum.php");
00118 include_once("classes/class.ilObjForum.php");
00119 $frm_data = ilForum::_lookupForumData($this->obj_id);
00120
00121 include_once("classes/class.ilObjUser.php");
00122 $MODS = ilForum::_getModerators($this->ref_id);
00123
00124 $moderators = "";
00125 for ($i = 0; $i < count($MODS); $i++)
00126 {
00127 if ($moderators != "")
00128 {
00129 $moderators .= ", ";
00130 }
00131 $moderators .= "<a class=\"il_ItemProperty\" target=\"".
00132 ilFrameTargetInfo::_getFrame("MainContent").
00133 "\" href=\"forums_user_view.php?ref_id=".$this->ref_id."&user=".
00134 $MODS[$i]."&offset=".$Start."\">".ilObjUser::_lookupLogin($MODS[$i])."</a>";
00135 }
00136
00137
00138 $props[] = array("alert" => false, "property" => $lng->txt("forums_moderators"),
00139 "value" => $moderators);
00140
00141
00142 $props[] = array("alert" => false, "property" => $lng->txt("forums_threads"),
00143 "value" => $frm_data["top_num_threads"]);
00144
00145
00146 $unread = ilObjForum::_getCountUnread($this->obj_id,$ilUser->getId());
00147 $alert = ($unread > 0)
00148 ? true
00149 : false;
00150 $props[] = array("alert" => $alert, "property" => $lng->txt("forums_articles")." (".$lng->txt("unread").")",
00151 "value" => $frm_data['top_num_posts']." (".$unread.")");
00152
00153
00154 $new = $this->frm_obj->getCountNew($ilUser->getId());
00155 $alert = ($new > 0)
00156 ? true
00157 : false;
00158 $props[] = array("alert" => $alert, "property" => $lng->txt("forums_new_articles"),
00159 "value" => $new);
00160
00161
00162 $props[] = array("alert" => false, "property" => $lng->txt("visits"),
00163 "value" => $frm_data["visits"]);
00164
00165
00166 if ($frm_data["top_last_post"] != "")
00167 {
00168 $lastPost = $this->frm->getLastPost($frm_data["top_last_post"]);
00169 $lastPost["pos_message"] = $this->frm->prepareText($lastPost["pos_message"]);
00170 }
00171 if (is_array($lastPost))
00172 {
00173 $last_user = $this->frm->getUserData($lastPost["pos_usr_id"],$lastPost["import_name"]);
00174
00175 $lpCont = "<a class=\"il_ItemProperty\" target=\"".
00176 ilFrameTargetInfo::_getFrame("MainContent").
00177 "\" href=\"forums_frameset.php?target=true&pos_pk=".
00178 $lastPost["pos_pk"]."&thr_pk=".$lastPost["pos_thr_fk"]."&ref_id=".
00179 $this->ref_id."#".$lastPost["pos_pk"]."\">".$lastPost["pos_message"]."</a> ".
00180 strtolower($lng->txt("from"))." ";
00181
00182 if($lastPost["pos_usr_id"] && ilObject::_exists($lastPost["pos_usr_id"]))
00183 {
00184 $lpCont .= "<a class=\"il_ItemProperty\" target=\"".
00185 ilFrameTargetInfo::_getFrame("MainContent").
00186 "\" href=\"forums_user_view.php?ref_id=".$this->ref_id."&user=".
00187 $last_user["usr_id"]."&offset=".$Start."\">".$last_user["login"]."</a>, ";
00188 $lpCont .= $lastPost["pos_date"];
00189 }
00190 else
00191 {
00192 $lpCont .= $last_user["login"];
00193 }
00194 }
00195
00196 $props[] = array("alert" => false, "newline" => true, "property" => $lng->txt("forums_last_post"),
00197 "value" => $lpCont);
00198
00199 return $props;
00200
00201 }
00202
00210 function getCommandFrame($a_cmd)
00211 {
00212
00213 $target = ilFrameTargetInfo::_getFrame("MainContent");
00214
00215 return $target;
00216 }
00217
00218 function getCommandLink($a_cmd)
00219 {
00220 switch($a_cmd)
00221 {
00222 case 'thread':
00223 return "forums_frameset.php?ref_id=".$this->ref_id.
00224 "&thr_pk=".$this->getChildId();
00225
00226 case 'posting':
00227 $thread_post = $this->getChildId();
00228 return "forums_frameset.php?target=1&ref_id=".$this->ref_id.
00229 "&thr_pk=".$thread_post[0].
00230 "&pos_pk=".$thread_post[1]."#".$thread_post[1];
00231
00232 default:
00233 return parent::getCommandLink($a_cmd);
00234 }
00235 }
00236
00237
00238 }
00239 ?>