ILIAS  release_4-4 Revision
ilShopNewsGUI Class Reference

Class ilShopNewsGUI. More...

+ Inheritance diagram for ilShopNewsGUI:
+ Collaboration diagram for ilShopNewsGUI:

Public Member Functions

 __construct ()
 
 executeCommand ()
 
 saveSettings ()
 
 initSettingsForm ($a_mode='edit')
 
 showSettings ()
 
 saveNews ()
 
 updateArchiveNews ()
 
 updateNews ()
 
 update ($view)
 
 performDeleteNews ()
 
 performDeleteArchiveNews ()
 
 performDelete ($view)
 
 confirmDeleteNews ()
 
 confirmDeleteArchiveNews ()
 
 confirmDelete ($view)
 
 initNewsForm ($a_mode='create', $view='news')
 
 addNewsForm ()
 
 editNews ()
 
 editArchiveNews ()
 
 editNewsForm ($view)
 
 getPropertiesValues ()
 
 getSettingsValues ()
 
 showNews ($confirmation_gui='')
 
 showArchive ($confirmation_gui='')
 
- Public Member Functions inherited from ilShopBaseGUI
 __construct ()
 

Data Fields

 $ilErr = null
 

Protected Member Functions

 buildSubTabs ()
 
 prepareOutput ()
 
- Protected Member Functions inherited from ilShopBaseGUI
 prepareOutput ()
 
 addPager ($result, $a_session_key)
 
 buildSubTabs ()
 
 setSection ($a_section)
 
 getSection ()
 
 setSubSection ($a_sub_section)
 
 getSubSection ()
 
 showButton ($a_cmd, $a_text, $a_target='')
 
 initTableGUI ()
 
 setTableGUIBasicData ($tbl, $result_set, $a_default_order_column='')
 

Private Attributes

 $form_gui = null
 
 $settings_form = null
 
 $oCurrentNewsItem = null
 

Additional Inherited Members

- Protected Attributes inherited from ilShopBaseGUI
 $ctrl = null
 
 $lng = null
 
 $tpl = null
 
 $oGeneralSettings = null
 
 $section = 0
 
 $sub_section = 0
 

Detailed Description

Class ilShopNewsGUI.

Author
Nadia Ahmad nahma.nosp@m.d@da.nosp@m.tabay.nosp@m..de

Definition at line 17 of file class.ilShopNewsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilShopNewsGUI::__construct ( )

Definition at line 25 of file class.ilShopNewsGUI.php.

References $_GET, and $ilErr.

26  {
27  global $ilErr;
28  parent::__construct();
29 
30  $this->oCurrentNewsItem = new ilShopNewsItem((int)$_GET['news_id']);
31 
32  $this->lng->loadLanguageModule('news');
33  $this->ilErr = $ilErr;
34  }
$_GET["client_id"]

Member Function Documentation

◆ addNewsForm()

ilShopNewsGUI::addNewsForm ( )

Definition at line 412 of file class.ilShopNewsGUI.php.

References initNewsForm().

413  {
414  $this->initNewsForm('create');
415  $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
416  }
initNewsForm($a_mode='create', $view='news')
+ Here is the call graph for this function:

◆ buildSubTabs()

ilShopNewsGUI::buildSubTabs ( )
protected

Definition at line 56 of file class.ilShopNewsGUI.php.

References $ilUser.

57  {
58  global $ilTabs, $ilUser, $rbacreview;
59 
60  $ilTabs->addSubTabTarget('news', $this->ctrl->getLinkTarget($this, 'showNews'), '', '', '','showNews');
61  $ilTabs->addSubTabTarget('archive', $this->ctrl->getLinkTarget($this, 'showArchive'), '', '', '','archive');
62 
63  if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
64  {
65  $ilTabs->addSubTabTarget('settings', $this->ctrl->getLinkTarget($this, 'showSettings'), '', '', '','settings');
66  }
67  }
global $ilUser
Definition: imgupload.php:15

◆ confirmDelete()

ilShopNewsGUI::confirmDelete (   $view)

Definition at line 276 of file class.ilShopNewsGUI.php.

References $_GET, $ilUser, ilUtil\sendInfo(), showArchive(), and showNews().

Referenced by confirmDeleteArchiveNews(), and confirmDeleteNews().

277  {
278  global $ilUser, $rbacreview;
279 
280  if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
281  {
282  $this->ilErr->raiseError($this->lng->txt('permission_denied'),$this->ilErr->MESSAGE);
283  }
284 
285  if(!isset($_GET['news_id']))
286  {
287  ilUtil::sendInfo($this->lng->txt('payment_news_missing_id'));
288  switch($view)
289  {
290  case 'archive':
291  return $this->showArchive();
292  break;
293 
294  case 'news':
295  default:
296  return $this->showNews();
297  break;
298  }
299  }
300 
301  include_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
302  $c_gui = new ilConfirmationGUI();
303  $c_gui->setHeaderText($this->lng->txt('payment_news_delete_sure'));
304  $c_gui->addHiddenItem('news_id', (int)$_GET['news_id']);
305 
306  $oNewsItem = new ilShopNewsItem($_GET['news_id']);
307  $title=$oNewsItem->getTitle();
308  $c_gui->addItem($news_title,$_GET['news_id'],$title);
309 
310 
311  switch($view)
312  {
313  case 'archive':
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');
317  $this->showArchive($c_gui->getHTML());
318  break;
319 
320  case 'news':
321  default:
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');
325  $this->showNews($c_gui->getHTML());
326  break;
327  }
328 
329  return true;
330  }
$_GET["client_id"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
showNews($confirmation_gui='')
global $ilUser
Definition: imgupload.php:15
showArchive($confirmation_gui='')
Confirmation screen class.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteArchiveNews()

ilShopNewsGUI::confirmDeleteArchiveNews ( )

Definition at line 271 of file class.ilShopNewsGUI.php.

References confirmDelete().

272  {
273  $this->confirmDelete('archive');
274  }
+ Here is the call graph for this function:

◆ confirmDeleteNews()

ilShopNewsGUI::confirmDeleteNews ( )

Definition at line 266 of file class.ilShopNewsGUI.php.

References confirmDelete().

267  {
268  $this->confirmDelete('news');
269  }
+ Here is the call graph for this function:

◆ editArchiveNews()

ilShopNewsGUI::editArchiveNews ( )

Definition at line 423 of file class.ilShopNewsGUI.php.

References editNewsForm().

424  {
425  return $this->editNewsForm('archive');
426  }
+ Here is the call graph for this function:

◆ editNews()

ilShopNewsGUI::editNews ( )

Definition at line 418 of file class.ilShopNewsGUI.php.

References editNewsForm().

419  {
420  return $this->editNewsForm('news');
421  }
+ Here is the call graph for this function:

◆ editNewsForm()

ilShopNewsGUI::editNewsForm (   $view)

Definition at line 428 of file class.ilShopNewsGUI.php.

References getPropertiesValues(), and initNewsForm().

Referenced by editArchiveNews(), and editNews().

429  {
430  $this->initNewsForm('edit', $view);
431  $this->getPropertiesValues();
432  $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
433  }
initNewsForm($a_mode='create', $view='news')
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilShopNewsGUI::executeCommand ( )

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

References $cmd, and prepareOutput().

37  {
38 // $next_class = $this->ctrl->getNextClass($this);
39  $cmd = $this->ctrl->getCmd();
40 
41  switch($cmd)
42  {
43  default:
44  if(!$cmd)
45  {
46  $cmd = 'showNews';
47  }
48  $this->prepareOutput();
49  $this->$cmd();
50  break;
51  }
52 
53  return true;
54  }
$cmd
Definition: sahs_server.php:35
+ Here is the call graph for this function:

◆ getPropertiesValues()

ilShopNewsGUI::getPropertiesValues ( )

Definition at line 435 of file class.ilShopNewsGUI.php.

Referenced by editNewsForm().

436  {
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()
442  ));
443  }
+ Here is the caller graph for this function:

◆ getSettingsValues()

ilShopNewsGUI::getSettingsValues ( )

Definition at line 445 of file class.ilShopNewsGUI.php.

References $ilSetting.

Referenced by saveSettings(), and showSettings().

446  {
447  global $ilSetting;
448 
449  $this->settings_form->setValuesByArray(array(
450  'archive_period' => $ilSetting->get('payment_news_archive_period')
451  ));
452  }
global $ilSetting
Definition: privfeed.php:40
+ Here is the caller graph for this function:

◆ initNewsForm()

ilShopNewsGUI::initNewsForm (   $a_mode = 'create',
  $view = 'news' 
)

Definition at line 332 of file class.ilShopNewsGUI.php.

References $ilUser, ilUtil\getImagePath(), ilRadioOption\setInfo(), and ilFormPropertyGUI\setInfo().

Referenced by addNewsForm(), editNewsForm(), saveNews(), and update().

333  {
334  global $ilTabs, $rbacreview, $ilUser;
335 
336  if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
337  {
338  $this->ilErr->raiseError($this->lng->txt('permission_denied'),$this->ilErr->MESSAGE);
339  }
340 
341  if($view == 'archive')
342  {
343  $ilTabs->setSubTabActive('archive');
344  }
345  else
346  {
347  $ilTabs->setSubTabActive('news');
348  }
349 
350 // include_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
351  $this->form_gui = new ilPropertyFormGUI();
352  $this->form_gui->setTitle($this->lng->txt('shopnews_settings'));
353  $this->form_gui->setTitleIcon(ilUtil::getImagePath('icon_news.png'));
354 
355  // Property Title
356  $text_input = new ilTextInputGUI($this->lng->txt('news_news_item_title'), 'news_title');
357  $text_input->setInfo('');
358  $text_input->setRequired(true);
359  $text_input->setMaxLength(200);
360  $text_input->setSize(93);
361 
362  $this->form_gui->addItem($text_input);
363 
364  // Property Content
365  $text_area = new ilTextAreaInputGUI($this->lng->txt('news_news_item_content'), 'news_content');
366  $text_area->setInfo('');
367  $text_area->setRequired(false);
368  $text_area->setCols(90);
369  $text_area->setRows(10);
370  $this->form_gui->addItem($text_area);
371 
372  // Property Visibility
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);
382 
383  // save and cancel commands
384  if($a_mode == 'create')
385  {
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'));
389  }
390  else
391  {
392  $this->ctrl->setParameter($this, 'news_id', $this->oCurrentNewsItem->getId());
393 
394  if($view == 'archive')
395  {
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'));
399  }
400  else
401  {
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'));
405  }
406  }
407 
408  $this->form_gui->setTitle($this->lng->txt('news_news_item_head'));
409  $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
410  }
This class represents an option in a radio group.
This class represents a property form user interface.
setInfo($a_info)
Set Info.
setInfo($a_info)
Set Information Text.
This class represents a property in a property form.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a text property in a property form.
global $ilUser
Definition: imgupload.php:15
This class represents a text area property in a property form.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ initSettingsForm()

ilShopNewsGUI::initSettingsForm (   $a_mode = 'edit')

Definition at line 96 of file class.ilShopNewsGUI.php.

References $options, ilUtil\getImagePath(), and ilFormPropertyGUI\setInfo().

Referenced by saveSettings(), and showSettings().

97  {
98 
99  $this->settings_form = new ilPropertyFormGUI();
100  $this->settings_form->setTitle($this->lng->txt('payment_news_settings'));
101  $this->settings_form->setTitleIcon(ilUtil::getImagePath('icon_news.png'));
102 
103  $oSelectBox = new ilSelectInputGUI($this->lng->txt('payment_news_archive_period'), 'archive_period');
104  $oSelectBox->setInfo($this->lng->txt('payment_news_archive_period_info'));
105  $options = array();
106  for($i = 5; $i <= 100; $i += 5)
107  {
108  $options[$i] = $i;
109  }
110  $oSelectBox->setOptions($options);
111  $this->settings_form->addItem($oSelectBox);
112 
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'));
116  }
This class represents a selection list property in a property form.
This class represents a property form user interface.
setInfo($a_info)
Set Information Text.
if(!is_array($argv)) $options
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performDelete()

ilShopNewsGUI::performDelete (   $view)

Definition at line 222 of file class.ilShopNewsGUI.php.

References $_POST, $ilUser, ilUtil\sendInfo(), showArchive(), and showNews().

Referenced by performDeleteArchiveNews(), and performDeleteNews().

223  {
224  global $ilUser, $rbacreview;
225 
226  if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
227  {
228  $this->ilErr->raiseError($this->lng->txt('permission_denied'),$this->ilErr->MESSAGE);
229  }
230 
231  if(!(int)$_POST['news_id'])
232  {
233  ilUtil::sendInfo($this->lng->txt('payment_news_missing_id'));
234  switch($view)
235  {
236  case 'archive':
237  return $this->showArchive();
238  break;
239 
240  case 'news':
241  default:
242  return $this->showNews();
243  break;
244  }
245  }
246  else
247  {
248  $this->oCurrentNewsItem->setId($_POST['news_id']);
249  $this->oCurrentNewsItem->delete();
250  ilUtil::sendInfo($this->lng->txt('payment_news_deleted'));
251  }
252 
253  switch($view)
254  {
255  case 'archive':
256  return $this->showArchive();
257  break;
258 
259  case 'news':
260  default:
261  return $this->showNews();
262  break;
263  }
264  }
$_POST['username']
Definition: cron.php:12
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
showNews($confirmation_gui='')
global $ilUser
Definition: imgupload.php:15
showArchive($confirmation_gui='')
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performDeleteArchiveNews()

ilShopNewsGUI::performDeleteArchiveNews ( )

Definition at line 217 of file class.ilShopNewsGUI.php.

References performDelete().

218  {
219  return $this->performDelete('archive');
220  }
+ Here is the call graph for this function:

◆ performDeleteNews()

ilShopNewsGUI::performDeleteNews ( )

Definition at line 212 of file class.ilShopNewsGUI.php.

References performDelete().

213  {
214  return $this->performDelete('news');
215  }
+ Here is the call graph for this function:

◆ prepareOutput()

ilShopNewsGUI::prepareOutput ( )
protected

Definition at line 626 of file class.ilShopNewsGUI.php.

Referenced by executeCommand().

627  {
628  global $ilTabs;
629 
630  parent::prepareOutput();
631 
632  $ilTabs->setTabActive('payment_news');
633 
634  }
+ Here is the caller graph for this function:

◆ saveNews()

ilShopNewsGUI::saveNews ( )

Definition at line 135 of file class.ilShopNewsGUI.php.

References $ilUser, initNewsForm(), ilUtil\sendInfo(), and showNews().

136  {
137  global $ilUser, $rbacreview;
138 
139  if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
140  {
141  $this->ilErr->raiseError($this->lng->txt('permission_denied'),$this->ilErr->MESSAGE);
142  }
143 
144  $this->initNewsForm('create');
145  if ($this->form_gui->checkInput())
146  {
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();
152 
153  ilUtil::sendInfo($this->lng->txt('payment_news_created'));
154  return $this->showNews();
155  }
156  else
157  {
158  $this->form_gui->setValuesByPost();
159  return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
160  }
161  }
initNewsForm($a_mode='create', $view='news')
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
showNews($confirmation_gui='')
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:

◆ saveSettings()

ilShopNewsGUI::saveSettings ( )

Definition at line 69 of file class.ilShopNewsGUI.php.

References $ilSetting, $ilUser, getSettingsValues(), initSettingsForm(), and ilUtil\sendInfo().

70  {
71  global $ilTabs, $ilSetting, $rbacreview, $ilUser;
72 
73  if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
74  {
75  $this->ilErr->raiseError($this->lng->txt('permission_denied'), $this->ilErr->MESSAGE);
76  }
77 
78  $ilTabs->setSubTabActive('settings');
79 
80  $this->initSettingsForm('edit');
81  if($this->settings_form->checkInput())
82  {
83  $ilSetting->set('payment_news_archive_period', $this->settings_form->getInput('archive_period'));
84  $this->getSettingsValues();
85  ilUtil::sendInfo($this->lng->txt('payment_news_settings_saved'));
86 
87  return $this->tpl->setVariable('ADM_CONTENT', $this->settings_form->getHtml());
88  }
89  else
90  {
91  $this->form_gui->setValuesByPost();
92  return $this->tpl->setVariable('ADM_CONTENT', $this->settings_form->getHtml());
93  }
94  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
initSettingsForm($a_mode='edit')
global $ilUser
Definition: imgupload.php:15
global $ilSetting
Definition: privfeed.php:40
+ Here is the call graph for this function:

◆ showArchive()

ilShopNewsGUI::showArchive (   $confirmation_gui = '')

Definition at line 542 of file class.ilShopNewsGUI.php.

References $ilSetting, $ilUser, $result, ilShopBaseGUI\$tpl, ilShopNewsItemList\_getInstance(), ilDatePresentation\formatDate(), IL_CAL_DATETIME, and ilShopNewsItemList\TYPE_ARCHIVE.

Referenced by confirmDelete(), performDelete(), and update().

543  {
544  global $ilUser, $tpl, $ilTabs, $ilSetting, $rbacreview;
545 
546  $ilTabs->setSubTabActive('archive');
547 
548  include_once 'Services/Payment/classes/class.ilShopNewsItemList.php';
549  include_once 'Services/Table/classes/class.ilTable2GUI.php';
550 
551  $news_tpl = new ilTemplate('tpl.main_view.html', true, true, 'Services/Payment');
552 
553  if((int)strlen($confirmation_gui))
554  {
555  $news_tpl->setVariable('CONFIRMATION', $confirmation_gui);
556  }
557 
558  $tbl = new ilTable2GUI($this);
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%');
564 
565  $oNewsList = ilShopNewsItemList::_getInstance();
566  $oNewsList->setMode(ilShopNewsItemList::TYPE_ARCHIVE)
567  ->setPublicSection($ilUser->getId() == ANONYMOUS_USER_ID)
568  ->setArchiveDate(time() - ($ilSetting->get('payment_news_archive_period') * 24 * 60 * 60))
569  ->read();
570  $result = array();
571  if($oNewsList->hasItems())
572  {
573  $tbl->setEnableTitle(true);
574  $tbl->setEnableHeader(true);
575 
576  $counter = 0;
577  foreach($oNewsList as $entry)
578  {
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;
581 
582  if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID) == true)
583  {
584  $this->ctrl->setParameter($this, 'news_id', $entry->getId());
585 
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');
591 
592  $this->ctrl->clearParameters($this);
593  }
594 
595  $result[$counter]['creation_date'] = ilDatePresentation::formatDate(
596  new ilDateTime($entry->getCreationDate(), IL_CAL_DATETIME));
597  $result[$counter]['title'] = $entry->getTitle();
598  $result[$counter]['content'] = $entry->getContent();
599  $result[$counter]['user_id'] = $entry->getUserId();
600 
601  $result[$counter]['author'] = $ilUser->getLogin();
602  $result[$counter]['creation_date'] = ilDatePresentation::formatDate(
603  new ilDateTime($entry->getCreationDate(), IL_CAL_DATETIME));
604 
605  $result[$counter]['update_date'] = ilDatePresentation::formatDate(
606  new ilDateTime($entry->getCreationDate(), IL_CAL_DATETIME));
607 
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');
611 
612  $this->ctrl->clearParameters($this);
613 
614  ++$counter;
615  }
616  }
617  else
618  {
619  $tbl->setNoEntriesText($this->lng->txt('payment_news_no_news_items'));
620  }
621  $tbl->setData($result);
622  $news_tpl->setVariable('TABLE', $tbl->getHTML());
623  $tpl->setContent($news_tpl->get());
624  }
const IL_CAL_DATETIME
$result
Class ilTable2GUI.
special template class to simplify handling of ITX/PEAR
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
global $ilUser
Definition: imgupload.php:15
global $ilSetting
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showNews()

ilShopNewsGUI::showNews (   $confirmation_gui = '')

Definition at line 454 of file class.ilShopNewsGUI.php.

References $ilSetting, $ilUser, $result, ilShopBaseGUI\$tpl, ilShopNewsItemList\_getInstance(), ilDatePresentation\formatDate(), IL_CAL_DATETIME, and ilShopNewsItemList\TYPE_NEWS.

Referenced by confirmDelete(), performDelete(), saveNews(), and update().

455  {
456  global $ilUser, $tpl, $ilTabs, $ilSetting, $rbacreview, $ilToolbar;
457 
458  $ilTabs->setSubTabActive('news');
459 
460  include_once 'Services/Payment/classes/class.ilShopNewsItemList.php';
461  include_once 'Services/Table/classes/class.ilTable2GUI.php';
462 
463  if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID) == true)
464  {
465  $ilToolbar->addButton($this->lng->txt('payment_news_add_news'), $this->ctrl->getLinkTarget($this, 'addNewsForm'));
466  }
467 
468  $news_tpl = new ilTemplate('tpl.main_view.html', true, true, 'Services/Payment');
469 
470  if((int)strlen($confirmation_gui))
471  {
472  $news_tpl->setVariable('CONFIRMATION', $confirmation_gui);
473  }
474 
475  $tbl = new ilTable2GUI($this);
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%');
481 
482  $oNewsList = ilShopNewsItemList::_getInstance();
483  $oNewsList->setMode(ilShopNewsItemList::TYPE_NEWS)
484  ->setPublicSection($ilUser->getId() == ANONYMOUS_USER_ID)
485  ->setArchiveDate(time() - ($ilSetting->get('payment_news_archive_period') * 24 * 60 * 60))
486  ->read();
487 
488  $result = array();
489  if($oNewsList->hasItems())
490  {
491  $tbl->setEnableHeader(true);
492  $tbl->setEnableTitle(true);
493 
494  $counter = 0;
495  foreach($oNewsList as $entry)
496  {
497  if($rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID) == true)
498  {
499  $this->ctrl->setParameter($this, 'news_id', $entry->getId());
500 
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');
506 
507  $this->ctrl->clearParameters($this);
508  }
509 
510  $result[$counter]['title'] = $entry->getTitle();
511  $result[$counter]['content'] = $entry->getContent();
512  $result[$counter]['user_id'] = $entry->getUserId();
513 
514  $result[$counter]['txt_author'] = $this->lng->txt('author');
515  $result[$counter]['author'] = $ilUser->getLogin();
516 
517  $result[$counter]['txt_creation_date'] = $this->lng->txt('create_date');
518  $result[$counter]['creation_date'] = ilDatePresentation::formatDate(
519  new ilDateTime($entry->getCreationDate(), IL_CAL_DATETIME));
520 
521  $result[$counter]['txt_update_date'] = $this->lng->txt('last_update');
522  $result[$counter]['update_date'] = ilDatePresentation::formatDate(
523  new ilDateTime($entry->getUpdateDate(), IL_CAL_DATETIME));
524 
525  $result[$counter]['txt_access'] = $this->lng->txt('access');
526  $result[$counter]['access'] = $entry->getVisibility();
527 
528  ++$counter;
529  }
530  }
531  else
532  {
533 
534  $tbl->setNoEntriesText($this->lng->txt('payment_news_no_news_items'));
535  }
536 
537  $tbl->setData($result);
538  $news_tpl->setVariable('TABLE', $tbl->getHTML());
539  $tpl->setContent($news_tpl->get());
540  }
const IL_CAL_DATETIME
$result
Class ilTable2GUI.
special template class to simplify handling of ITX/PEAR
static formatDate(ilDateTime $date)
Format a date public.
Date and time handling
global $ilUser
Definition: imgupload.php:15
global $ilSetting
Definition: privfeed.php:40
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSettings()

ilShopNewsGUI::showSettings ( )

Definition at line 118 of file class.ilShopNewsGUI.php.

References $ilUser, getSettingsValues(), and initSettingsForm().

119  {
120  global $ilTabs, $ilUser, $rbacreview;
121 
122  if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
123  {
124  $this->ilErr->raiseError($this->lng->txt('permission_denied'),$this->ilErr->MESSAGE);
125  }
126 
127  $ilTabs->setSubTabActive('settings');
128 
129  $this->initSettingsForm('edit');
130  $this->getSettingsValues();
131 
132  return $this->tpl->setVariable('ADM_CONTENT', $this->settings_form->getHtml());
133  }
initSettingsForm($a_mode='edit')
global $ilUser
Definition: imgupload.php:15
+ Here is the call graph for this function:

◆ update()

ilShopNewsGUI::update (   $view)

Definition at line 173 of file class.ilShopNewsGUI.php.

References $ilUser, initNewsForm(), ilUtil\sendInfo(), showArchive(), and showNews().

Referenced by updateArchiveNews(), and updateNews().

174  {
175  global $ilUser, $rbacreview;
176 
177  if(!$rbacreview->isAssigned($ilUser->getId(), SYSTEM_ROLE_ID))
178  {
179  $this->ilErr->raiseError($this->lng->txt('permission_denied'),$this->ilErr->MESSAGE);
180  }
181 
182  $this->initNewsForm('edit', $view);
183 
184  if ($this->form_gui->checkInput())
185  {
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());
190 
191  $this->oCurrentNewsItem->update();
192 
193  ilUtil::sendInfo($this->lng->txt('payment_news_updated'));
194 
195  if($view == 'archive')
196  {
197  return $this->showArchive();
198  }
199  else
200  {
201  return $this->showNews();
202  }
203 
204  }
205  else
206  {
207  $this->form_gui->setValuesByPost();
208  return $this->tpl->setVariable('ADM_CONTENT', $this->form_gui->getHtml());
209  }
210  }
initNewsForm($a_mode='create', $view='news')
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
showNews($confirmation_gui='')
global $ilUser
Definition: imgupload.php:15
showArchive($confirmation_gui='')
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateArchiveNews()

ilShopNewsGUI::updateArchiveNews ( )

Definition at line 163 of file class.ilShopNewsGUI.php.

References update().

164  {
165  return $this->update('archive');
166  }
+ Here is the call graph for this function:

◆ updateNews()

ilShopNewsGUI::updateNews ( )

Definition at line 168 of file class.ilShopNewsGUI.php.

References update().

169  {
170  return $this->update('news');
171  }
+ Here is the call graph for this function:

Field Documentation

◆ $form_gui

ilShopNewsGUI::$form_gui = null
private

Definition at line 19 of file class.ilShopNewsGUI.php.

◆ $ilErr

ilShopNewsGUI::$ilErr = null

Definition at line 23 of file class.ilShopNewsGUI.php.

Referenced by __construct().

◆ $oCurrentNewsItem

ilShopNewsGUI::$oCurrentNewsItem = null
private

Definition at line 21 of file class.ilShopNewsGUI.php.

◆ $settings_form

ilShopNewsGUI::$settings_form = null
private

Definition at line 20 of file class.ilShopNewsGUI.php.


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