5 include_once
'Services/Payment/classes/class.ilShopBaseGUI.php';
6 include_once
'Services/Payment/classes/class.ilShopNewsItem.php';
7 include_once
'Services/Form/classes/class.ilPropertyFormGUI.php';
29 $this->lng->loadLanguageModule(
'news');
36 $next_class = $this->ctrl->getNextClass($this);
37 $cmd = $this->ctrl->getCmd();
56 global $ilTabs, $ilUser, $rbacreview;
58 $ilTabs->addSubTabTarget(
'news', $this->ctrl->getLinkTarget($this,
'showNews'),
'',
'',
'',
'showNews');
59 $ilTabs->addSubTabTarget(
'archive', $this->ctrl->getLinkTarget($this,
'showArchive'),
'',
'',
'',
'archive');
61 if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
63 $ilTabs->addSubTabTarget(
'settings', $this->ctrl->getLinkTarget($this,
'showSettings'),
'',
'',
'',
'settings');
69 global $ilTabs,
$ilSetting, $rbacreview, $ilUser;
71 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
73 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
76 $ilTabs->setSubTabActive(
'settings');
79 if($this->settings_form->checkInput())
81 $ilSetting->set(
'payment_news_archive_period', $this->settings_form->getInput(
'archive_period'));
85 return $this->tpl->setVariable(
'ADM_CONTENT', $this->settings_form->getHtml());
89 $this->form_gui->setValuesByPost();
90 return $this->tpl->setVariable(
'ADM_CONTENT', $this->settings_form->getHtml());
98 $this->settings_form->setTitle($this->lng->txt(
'payment_news_settings'));
101 $oSelectBox =
new ilSelectInputGUI($this->lng->txt(
'payment_news_archive_period'),
'archive_period');
102 $oSelectBox->
setInfo($this->lng->txt(
'payment_news_archive_period_info'));
104 for($i = 5; $i <= 100; $i += 5)
108 $oSelectBox->setOptions($options);
109 $this->settings_form->addItem($oSelectBox);
111 $this->settings_form->addCommandButton(
'saveSettings', $this->lng->txt(
'save'));
112 $this->settings_form->addCommandButton(
'showNews', $this->lng->txt(
'cancel'));
113 $this->settings_form->setFormAction($this->ctrl->getFormaction($this,
'saveSettings'));
118 global $ilTabs, $ilUser, $rbacreview;
120 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
122 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
125 $ilTabs->setSubTabActive(
'settings');
130 return $this->tpl->setVariable(
'ADM_CONTENT', $this->settings_form->getHtml());
135 global $ilUser, $rbacreview;
137 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
139 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
143 if ($this->form_gui->checkInput())
145 $this->oCurrentNewsItem->setTitle($this->form_gui->getInput(
'news_title'));
146 $this->oCurrentNewsItem->setContent($this->form_gui->getInput(
'news_content'));
147 $this->oCurrentNewsItem->setVisibility($this->form_gui->getInput(
'news_visibility'));
148 $this->oCurrentNewsItem->setUserId($ilUser->getId());
149 $this->oCurrentNewsItem->create();
156 $this->form_gui->setValuesByPost();
157 return $this->tpl->setVariable(
'ADM_CONTENT', $this->form_gui->getHtml());
163 return $this->
update(
'archive');
168 return $this->
update(
'news');
175 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
177 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
182 if ($this->form_gui->checkInput())
184 $this->oCurrentNewsItem->setTitle($this->form_gui->getInput(
'news_title'));
185 $this->oCurrentNewsItem->setContent($this->form_gui->getInput(
'news_content'));
186 $this->oCurrentNewsItem->setVisibility($this->form_gui->getInput(
'news_visibility'));
187 $this->oCurrentNewsItem->setUserId($ilUser->getId());
189 $this->oCurrentNewsItem->update();
193 if($view ==
'archive')
205 $this->form_gui->setValuesByPost();
206 return $this->tpl->setVariable(
'ADM_CONTENT', $this->form_gui->getHtml());
222 global $ilUser, $rbacreview;
224 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
226 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
229 if(!(
int)
$_POST[
'news_id'])
246 $this->oCurrentNewsItem->setId(
$_POST[
'news_id']);
247 $this->oCurrentNewsItem->delete();
278 global $ilUser, $rbacreview;
280 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
282 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
285 if(!isset(
$_GET[
'news_id']))
301 include_once
'Services/Utilities/classes/class.ilConfirmationGUI.php';
303 $c_gui->setHeaderText($this->lng->txt(
'payment_news_delete_sure'));
304 $c_gui->addHiddenItem(
'news_id', (
int)
$_GET[
'news_id']);
307 $title=$oNewsItem->getTitle();
308 $c_gui->addItem($news_title,$_GET[
'news_id'],
$title);
314 $c_gui->setFormAction($this->ctrl->getFormAction($this,
'performDeleteArchiveNews'));
315 $c_gui->setConfirm($this->lng->txt(
'confirm'),
'performDeleteArchiveNews');
316 $c_gui->setCancel($this->lng->txt(
'cancel'),
'showArchive');
322 $c_gui->setFormAction($this->ctrl->getFormAction($this,
'performDeleteNews'));
323 $c_gui->setConfirm($this->lng->txt(
'confirm'),
'performDeleteNews');
324 $c_gui->setCancel($this->lng->txt(
'cancel'),
'showNews');
334 global $ilTabs, $rbacreview, $ilUser;
336 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
338 $this->ilias->raiseError($this->lng->txt(
'permission_denied'), $this->ilias->error_obj->MESSAGE);
341 if($view ==
'archive')
343 $ilTabs->setSubTabActive(
'archive');
347 $ilTabs->setSubTabActive(
'news');
352 $this->form_gui->setTitle($this->lng->txt(
'shopnews_settings'));
356 $text_input =
new ilTextInputGUI($this->lng->txt(
'news_news_item_title'),
'news_title');
358 $text_input->setRequired(
true);
359 $text_input->setMaxLength(200);
360 $text_input->setSize(93);
362 $this->form_gui->addItem($text_input);
365 $text_area =
new ilTextAreaInputGUI($this->lng->txt(
'news_news_item_content'),
'news_content');
367 $text_area->setRequired(
false);
368 $text_area->setCols(90);
369 $text_area->setRows(10);
370 $this->form_gui->addItem($text_area);
373 $radio_group =
new ilRadioGroupInputGUI($this->lng->txt(
'news_news_item_visibility'),
'news_visibility');
374 $radio_option =
new ilRadioOption($this->lng->txt(
'news_visibility_users'),
'users');
375 $radio_group->addOption($radio_option);
376 $radio_option =
new ilRadioOption($this->lng->txt(
'news_visibility_public'),
'public');
377 $radio_group->addOption($radio_option);
378 $radio_group->
setInfo($this->lng->txt(
'news_news_item_visibility_info'));
379 $radio_group->setRequired(
false);
380 $radio_group->setValue(
'users');
381 $this->form_gui->addItem($radio_group);
384 if($a_mode ==
'create')
386 $this->form_gui->addCommandButton(
'saveNews', $this->lng->txt(
'save'));
387 $this->form_gui->addCommandButton(
'showNews', $this->lng->txt(
'cancel'));
388 $this->form_gui->setFormAction($this->ctrl->getFormAction($this,
'saveNews'));
392 $this->ctrl->setParameter($this,
'news_id', $this->oCurrentNewsItem->getId());
394 if($view ==
'archive')
396 $this->form_gui->addCommandButton(
'updateArchiveNews', $this->lng->txt(
'save'));
397 $this->form_gui->addCommandButton(
'showArchive', $this->lng->txt(
'cancel'));
398 $this->form_gui->setFormAction($this->ctrl->getFormAction($this,
'updateArchiveNews'));
402 $this->form_gui->addCommandButton(
'updateNews', $this->lng->txt(
'save'));
403 $this->form_gui->addCommandButton(
'showNews', $this->lng->txt(
'cancel'));
404 $this->form_gui->setFormAction($this->ctrl->getFormAction($this,
'updateNews'));
408 $this->form_gui->setTitle($this->lng->txt(
'news_news_item_head'));
409 $this->tpl->setVariable(
'ADM_CONTENT', $this->form_gui->getHtml());
415 $this->tpl->setVariable(
'ADM_CONTENT', $this->form_gui->getHtml());
432 $this->tpl->setVariable(
'ADM_CONTENT', $this->form_gui->getHtml());
437 $this->form_gui->setValuesByArray(array(
438 'news_creation_date' => $this->oCurrentNewsItem->getCreationDate(),
439 'news_title' => $this->oCurrentNewsItem->getTitle(),
440 'news_content' => $this->oCurrentNewsItem->getContent(),
441 'news_visibility' =>$this->oCurrentNewsItem->getVisibility()
449 $this->settings_form->setValuesByArray(array(
450 'archive_period' => $ilSetting->get(
'payment_news_archive_period')
458 $ilTabs->setSubTabActive(
'news');
460 include_once
'Services/Payment/classes/class.ilShopNewsItemList.php';
461 include_once
'Services/Table/classes/class.ilTable2GUI.php';
463 if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID) ==
true)
465 $ilToolbar->addButton($this->lng->txt(
'payment_news_add_news'), $this->ctrl->getLinkTarget($this,
'addNewsForm'));
468 $news_tpl =
new ilTemplate(
'tpl.main_view.html',
true,
true,
'Services/Payment');
470 if((
int)strlen($confirmation_gui))
472 $news_tpl->setVariable(
'CONFIRMATION', $confirmation_gui);
476 $tbl->setId(
'shop_news_tbl');
477 $tbl->setTitle($this->lng->txt(
'news'),
'icon_news.gif', $this->lng->txt(
'news'));
478 $tbl->setRowTemplate(
'tpl.shop_news_row.html',
'Services/Payment');
479 $tbl->setFormAction($this->ctrl->getFormAction($this),
'showNews');
480 $tbl->addColumn($this->lng->txt(
'news'),
'title',
'100%');
484 ->setPublicSection($ilUser->getId() == ANONYMOUS_USER_ID)
485 ->setArchiveDate(time() - ($ilSetting->get(
'payment_news_archive_period') * 24 * 60 * 60))
489 if($oNewsList->hasItems())
491 $tbl->setEnableHeader(
true);
492 $tbl->setEnableTitle(
true);
495 foreach($oNewsList as $entry)
497 if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID) ==
true)
499 $this->ctrl->setParameter($this,
'news_id', $entry->getId());
501 $result[$counter][
'news_id'] = $entry->getId();
502 $result[$counter][
'edit_src'] = $this->ctrl->getLinkTarget($this,
'editNews');
503 $result[$counter][
'edit_txt'] = $this->lng->txt(
'edit');
504 $result[$counter][
'delete_src'] = $this->ctrl->getLinkTarget($this,
'confirmDeleteNews');
505 $result[$counter][
'delete_txt'] = $this->lng->txt(
'delete');
507 $this->ctrl->clearParameters($this);
510 $result[$counter][
'title'] = $entry->getTitle();
511 $result[$counter][
'content'] = $entry->getContent();
512 $result[$counter][
'user_id'] = $entry->getUserId();
514 $result[$counter][
'txt_author'] = $this->lng->txt(
'author');
515 $result[$counter][
'author'] = $ilUser->getLogin();
517 $result[$counter][
'txt_creation_date'] = $this->lng->txt(
'create_date');
521 $result[$counter][
'txt_update_date'] = $this->lng->txt(
'last_update');
525 $result[$counter][
'txt_access'] = $this->lng->txt(
'access');
526 $result[$counter][
'access'] = $entry->getVisibility();
534 $tbl->setNoEntriesText($this->lng->txt(
'payment_news_no_news_items'));
537 $tbl->setData($result);
538 $news_tpl->setVariable(
'TABLE', $tbl->getHTML());
539 $tpl->setContent($news_tpl->get());
546 $ilTabs->setSubTabActive(
'archive');
548 include_once
'Services/Payment/classes/class.ilShopNewsItemList.php';
549 include_once
'Services/Table/classes/class.ilTable2GUI.php';
551 $news_tpl =
new ilTemplate(
'tpl.main_view.html',
true,
true,
'Services/Payment');
553 if((
int)strlen($confirmation_gui))
555 $news_tpl->setVariable(
'CONFIRMATION', $confirmation_gui);
559 $tbl->setId(
'shop_news_archive_tbl');
560 $tbl->setTitle($this->lng->txt(
'archive'),
'icon_news.gif',$this->lng->txt(
'news'));
561 $tbl->setRowTemplate(
'tpl.shop_news_row.html',
'Services/Payment');
562 $tbl->setFormAction($this->ctrl->getFormAction($this),
'showArchive');
563 $tbl->addColumn($this->lng->txt(
'archive'),
'title',
'100%');
567 ->setPublicSection($ilUser->getId() == ANONYMOUS_USER_ID)
568 ->setArchiveDate(time() - ($ilSetting->get(
'payment_news_archive_period') * 24 * 60 * 60))
571 if($oNewsList->hasItems())
573 $tbl->setEnableTitle(
true);
574 $tbl->setEnableHeader(
true);
577 foreach($oNewsList as $entry)
579 if($entry->getVisibility() !=
'public' && $ilUser->getId() == ANONYMOUS_USER_ID)
continue;
580 if(strtotime($entry->getCreationDate()) > time() - ($ilSetting->get(
'payment_news_archive_period') * 24 * 60 * 60))
continue;
582 if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID) ==
true)
584 $this->ctrl->setParameter($this,
'news_id', $entry->getId());
586 $result[$counter][
'news_id']= $entry->getId();
587 $result[$counter][
'edit_src'] = $this->ctrl->getLinkTarget($this,
'editArchiveNews');
588 $result[$counter][
'edit_txt'] = $this->lng->txt(
'edit');
589 $result[$counter][
'delete_src'] = $this->ctrl->getLinkTarget($this,
'confirmDeleteArchiveNews');
590 $result[$counter][
'delete_txt'] = $this->lng->txt(
'delete');
592 $this->ctrl->clearParameters($this);
597 $result[$counter][
'title'] = $entry->getTitle();
598 $result[$counter][
'content'] = $entry->getContent();
599 $result[$counter][
'user_id'] = $entry->getUserId();
601 $result[$counter][
'author'] = $ilUser->getLogin();
608 $result[$counter][
'txt_author'] = $this->lng->txt(
'author');
609 $result[$counter][
'txt_creation_date'] = $this->lng->txt(
'create_date');
610 $result[$counter][
'txt_update_date'] = $this->lng->txt(
'last_update');
612 $this->ctrl->clearParameters($this);
619 $tbl->setNoEntriesText($this->lng->txt(
'payment_news_no_news_items'));
621 $tbl->setData($result);
622 $news_tpl->setVariable(
'TABLE', $tbl->getHTML());
623 $tpl->setContent($news_tpl->get());
632 $ilTabs->setTabActive(
'payment_news');