52 $lng->loadLanguageModule(
"news");
54 $this->ctrl->saveParameter($this,
"news_ref_id");
62 $next_class = $this->ctrl->getNextClass();
68 $cmd = $this->ctrl->getCmd(
"view");
73 $this->tpl->show(
true);
83 $this->lng->txt(
"personal_desktop"));
84 $this->tpl->setTitle($this->lng->txt(
"personal_desktop"));
99 $news_tpl =
new ilTemplate(
"tpl.pd_news.html",
true,
true,
"Services/News");
101 include_once(
"Services/News/classes/class.ilNewsSubscription.php");
102 include_once(
"Services/News/classes/class.ilNewsItem.php");
105 $per = (
$_SESSION[
"news_pd_news_per"] !=
"")
109 $allow_shorter_periods = $news_set->get(
"allow_shorter_periods");
110 $allow_longer_periods = $news_set->get(
"allow_longer_periods");
114 2 => sprintf($lng->txt(
"news_period_x_days"), 2),
115 3 => sprintf($lng->txt(
"news_period_x_days"), 3),
116 5 => sprintf($lng->txt(
"news_period_x_days"), 5),
117 7 => $lng->txt(
"news_period_1_week"),
118 14 => sprintf($lng->txt(
"news_period_x_weeks"), 2),
119 30 => $lng->txt(
"news_period_1_month"),
120 60 => sprintf($lng->txt(
"news_period_x_months"), 2),
121 120 => sprintf($lng->txt(
"news_period_x_months"), 4),
122 180 => sprintf($lng->txt(
"news_period_x_months"), 6),
123 366 => $lng->txt(
"news_period_1_year"));
126 foreach($per_opts as $k => $opt)
128 if (!$allow_shorter_periods && ($k < $default_per)) $unset[$k] = $k;
129 if (!$allow_longer_periods && ($k > $default_per)) $unset[$k] = $k;
131 foreach($unset as $k)
133 unset($per_opts[$k]);
135 foreach($per_opts as $k => $v)
137 $news_tpl->setCurrentBlock(
"per_option");
138 $news_tpl->setVariable(
"VAL_PER", $k);
139 $news_tpl->setVariable(
"TXT_PER", $v);
142 $news_tpl->setVariable(
"SEL_PER",
' selected="selected" ');
144 $news_tpl->parseCurrentBlock();
151 $pd_items = $ilUser->getDesktopItems();
152 foreach($pd_items as $item)
154 $ref_ids[] = $item[
"ref_id"];
155 $obj_ids[] = $item[
"obj_id"];
159 $sel_ref_id = (
$_GET[
"news_ref_id"] > 0)
160 ?
$_GET[
"news_ref_id"]
161 : $ilUser->getPref(
"news_sel_ref_id");
166 $news_tpl->setCurrentBlock(
"related_option");
167 $news_tpl->setVariable(
"VAL_RELATED",
"0");
168 $news_tpl->setVariable(
"TXT_RELATED", $lng->txt(
"news_all_items"));
169 $news_tpl->parseCurrentBlock();
172 $sel_has_news =
false;
181 if ($sel_ref_id == $ref_id)
183 $sel_has_news =
true;
190 $news_items = $nitem->_getNewsItemsOfUser($ilUser->getId(),
false,
199 foreach($conts as $ref_id =>
$title)
201 $news_tpl->setCurrentBlock(
"related_option");
202 $news_tpl->setVariable(
"VAL_RELATED", $ref_id);
203 $news_tpl->setVariable(
"TXT_RELATED",
$title.
" (".(
int) $cnt[$ref_id].
")");
204 if ($sel_ref_id == $ref_id)
206 $news_tpl->setVariable(
"SEL",
' selected="selected" ');
208 $news_tpl->parseCurrentBlock();
211 $news_tpl->setCurrentBlock(
"related_selection");
212 $news_tpl->setVariable(
"FORMACTION", $ilCtrl->getFormAction($this));
213 $news_tpl->setVariable(
"TXT_RELATED_TO", $lng->txt(
"news_related_to"));
214 $news_tpl->setVariable(
"TXT_CHANGE", $lng->txt(
"change"));
215 $news_tpl->parseCurrentBlock();
221 $nitem->setContextObjId($obj_id);
222 $nitem->setContextObjType($obj_type);
223 $news_items = $nitem->getNewsForRefId($sel_ref_id,
false,
227 include_once(
"./Services/News/classes/class.ilPDNewsTableGUI.php");
229 $pd_news_table->setData($news_items);
231 if (count($news_items) > 0)
233 $news_tpl->setVariable(
"NEWS", $pd_news_table->getHTML());
237 $news_tpl->setCurrentBlock(
"no_news");
238 $news_tpl->setVariable(
"NO_NEWS", $lng->txt(
"news_no_news_items"));
239 $news_tpl->parseCurrentBlock();
242 $tpl->setContent($news_tpl->get());
252 $this->ctrl->setParameter($this,
"news_ref_id", $_POST[
"news_ref_id"]);
253 $ilUser->writePref(
"news_sel_ref_id", $_POST[
"news_ref_id"]);
254 if ($_POST[
"news_per"] > 0)
256 $_SESSION[
"news_pd_news_per"] = $_POST[
"news_per"];
258 $this->ctrl->redirect($this,
"view");