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';
32 $this->lng->loadLanguageModule(
'news');
39 $cmd = $this->ctrl->getCmd();
58 global $ilTabs,
$ilUser, $rbacreview;
60 $ilTabs->addSubTabTarget(
'news', $this->ctrl->getLinkTarget($this,
'showNews'),
'',
'',
'',
'showNews');
61 $ilTabs->addSubTabTarget(
'archive', $this->ctrl->getLinkTarget($this,
'showArchive'),
'',
'',
'',
'archive');
63 if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
65 $ilTabs->addSubTabTarget(
'settings', $this->ctrl->getLinkTarget($this,
'showSettings'),
'',
'',
'',
'settings');
73 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
75 $this->ilErr->raiseError($this->lng->txt(
'permission_denied'), $this->ilErr->MESSAGE);
78 $ilTabs->setSubTabActive(
'settings');
81 if($this->settings_form->checkInput())
83 $ilSetting->set(
'payment_news_archive_period', $this->settings_form->getInput(
'archive_period'));
87 return $this->tpl->setVariable(
'ADM_CONTENT', $this->settings_form->getHtml());
91 $this->form_gui->setValuesByPost();
92 return $this->tpl->setVariable(
'ADM_CONTENT', $this->settings_form->getHtml());
100 $this->settings_form->setTitle($this->lng->txt(
'payment_news_settings'));
103 $oSelectBox =
new ilSelectInputGUI($this->lng->txt(
'payment_news_archive_period'),
'archive_period');
104 $oSelectBox->
setInfo($this->lng->txt(
'payment_news_archive_period_info'));
106 for($i = 5; $i <= 100; $i += 5)
110 $oSelectBox->setOptions($options);
111 $this->settings_form->addItem($oSelectBox);
113 $this->settings_form->addCommandButton(
'saveSettings', $this->lng->txt(
'save'));
114 $this->settings_form->addCommandButton(
'showNews', $this->lng->txt(
'cancel'));
115 $this->settings_form->setFormAction($this->ctrl->getFormaction($this,
'saveSettings'));
120 global $ilTabs,
$ilUser, $rbacreview;
122 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
124 $this->ilErr->raiseError($this->lng->txt(
'permission_denied'),$this->ilErr->MESSAGE);
127 $ilTabs->setSubTabActive(
'settings');
132 return $this->tpl->setVariable(
'ADM_CONTENT', $this->settings_form->getHtml());
139 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
141 $this->ilErr->raiseError($this->lng->txt(
'permission_denied'),$this->ilErr->MESSAGE);
145 if ($this->form_gui->checkInput())
147 $this->oCurrentNewsItem->setTitle($this->form_gui->getInput(
'news_title'));
148 $this->oCurrentNewsItem->setContent($this->form_gui->getInput(
'news_content'));
149 $this->oCurrentNewsItem->setVisibility($this->form_gui->getInput(
'news_visibility'));
150 $this->oCurrentNewsItem->setUserId($ilUser->getId());
151 $this->oCurrentNewsItem->create();
158 $this->form_gui->setValuesByPost();
159 return $this->tpl->setVariable(
'ADM_CONTENT', $this->form_gui->getHtml());
165 return $this->
update(
'archive');
170 return $this->
update(
'news');
177 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
179 $this->ilErr->raiseError($this->lng->txt(
'permission_denied'),$this->ilErr->MESSAGE);
184 if ($this->form_gui->checkInput())
186 $this->oCurrentNewsItem->setTitle($this->form_gui->getInput(
'news_title'));
187 $this->oCurrentNewsItem->setContent($this->form_gui->getInput(
'news_content'));
188 $this->oCurrentNewsItem->setVisibility($this->form_gui->getInput(
'news_visibility'));
189 $this->oCurrentNewsItem->setUserId($ilUser->getId());
191 $this->oCurrentNewsItem->update();
195 if($view ==
'archive')
207 $this->form_gui->setValuesByPost();
208 return $this->tpl->setVariable(
'ADM_CONTENT', $this->form_gui->getHtml());
226 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
228 $this->ilErr->raiseError($this->lng->txt(
'permission_denied'),$this->ilErr->MESSAGE);
231 if(!(
int)
$_POST[
'news_id'])
248 $this->oCurrentNewsItem->setId(
$_POST[
'news_id']);
249 $this->oCurrentNewsItem->delete();
280 if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
282 $this->ilErr->raiseError($this->lng->txt(
'permission_denied'),$this->ilErr->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->ilErr->raiseError($this->lng->txt(
'permission_denied'),$this->ilErr->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.png', $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'));
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.png',$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'));
622 $news_tpl->setVariable(
'TABLE', $tbl->getHTML());
623 $tpl->setContent($news_tpl->get());
632 $ilTabs->setTabActive(
'payment_news');