• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

Modules/RemoteCourse/classes/class.ilObjRemoteCourseGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 include_once('classes/class.ilObjectGUI.php');
00025 
00036 class ilObjRemoteCourseGUI extends ilObjectGUI
00037 {
00043         public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00044         {
00045                 $this->type = 'rcrs';
00046                 parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
00047 
00048                 $this->lng->loadLanguageModule('rcrs');
00049                 $this->lng->loadLanguageModule('crs');
00050         }
00051 
00058         public function executeCommand()
00059         {
00060                 global $rbacsystem,$ilErr,$ilAccess;
00061 
00062                 $next_class = $this->ctrl->getNextClass($this);
00063                 $cmd = $this->ctrl->getCmd();
00064 
00065                 $this->prepareOutput();
00066 
00067                 switch($next_class)
00068                 {
00069                         case 'ilinfoscreengui':
00070                                 $this->infoScreen();    // forwards command
00071                                 break;
00072                 
00073                         case 'ilpermissiongui':
00074                                 $this->tabs_gui->setTabActive('perm_settings');
00075                                 include_once("./classes/class.ilPermissionGUI.php");
00076                                 $this->ctrl->forwardCommand(new ilPermissionGUI($this));
00077                                 break;
00078 
00079                         default:
00080                                 if(!$cmd || $cmd == 'view')
00081                                 {
00082                                         $cmd = "editSettings";
00083                                 }
00084                                 $cmd .= "Object";
00085                                 $this->$cmd();
00086                                 break;
00087                 }
00088                 return true;
00089         }
00090         
00097         public function getTabs($tabs_gui)
00098         {
00099                 global $ilAccess;
00100 
00101                 if($ilAccess->checkAccess('visible','',$this->object->getRefId()))
00102                 {
00103                         $tabs_gui->addTarget("info_short",
00104                                 $this->ctrl->getLinkTarget($this, "infoScreen"));
00105                 }
00106 
00107                 if($ilAccess->checkAccess('write','',$this->object->getRefId()))
00108                 {
00109                         $tabs_gui->addTarget("edit",
00110                                 $this->ctrl->getLinkTarget($this, "edit"),
00111                                 array(),
00112                                 "");
00113                 }
00114                 if ($ilAccess->checkAccess('edit_permission','',$this->object->getRefId()))
00115                 {
00116                         $tabs_gui->addTarget("perm_settings",
00117                                 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), 
00118                                 array("perm","info","owner"), 'ilpermissiongui');
00119                 }
00120         }
00121         
00127         function infoScreenObject()
00128         {
00129                 $this->ctrl->setCmd("showSummary");
00130                 $this->ctrl->setCmdClass("ilinfoscreengui");
00131                 $this->infoScreen();
00132         }
00133         
00134         
00142         public function infoScreen()
00143         {
00144                 global $ilErr,$ilAccess;
00145 
00146                 if(!$ilAccess->checkAccess('visible','',$this->object->getRefId()))
00147                 {
00148                         $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
00149                 }
00150 
00151                 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
00152                 $info = new ilInfoScreenGUI($this);
00153                 
00154                 $info->addSection($this->lng->txt('crs_general_info'));
00155                 $info->addProperty($this->lng->txt('title'),$this->object->getTitle());
00156                 if(strlen($this->object->getDescription()))
00157                 {
00158                         $info->addProperty($this->lng->txt('description'),$this->object->getDescription());
00159                 }
00160                 if(strlen($loc = $this->object->getLocalInformation()))
00161                 {
00162                         $info->addProperty($this->lng->txt('local_information'),$this->object->getLocalInformation());
00163                 }
00164                 
00165                 // Access
00166                 $info->addProperty($this->lng->txt('crs_visibility'),$this->availabilityToString());
00167                 
00168                 
00169                 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
00170                 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_INFO,
00171                         'rcrs',$this->object->getId());
00172                 $record_gui->setInfoObject($info);
00173                 $record_gui->parse();
00174                 
00175                 $this->ctrl->forwardCommand($info);
00176         }
00177         
00183         public function editObject()
00184         {
00185                 global $ilErr,$ilAccess;
00186 
00187                 if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
00188                 {
00189                         $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
00190                 }
00191                 $this->tabs_gui->setTabActive('edit');
00192                 
00193                 $this->initEditTable();
00194                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.edit.html','Modules/RemoteCourse');
00195                 $this->tpl->setVariable('EDIT_TABLE',$this->form->getHTML());
00196         }
00197         
00205         public function updateObject()
00206         {
00207                 global $ilErr,$ilAccess;
00208 
00209                 if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
00210                 {
00211                         $ilErr->raiseError($this->lng->txt('msg_no_perm_read'),$ilErr->MESSAGE);
00212                 }
00213                 
00214                 $this->object->setLocalInformation(ilUtil::stripSlashes($_POST['local_info']));
00215                 #$this->object->setAvailabilityType($_POST['activation_type']);
00216                 #$this->object->setStartingTime($_POST['start']);
00217                 #$this->object->setEndingTime($_POST['end']);
00218                 $this->object->update();
00219                 
00220                 // Save advanced meta data
00221                 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
00222                 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR,
00223                         'rcrs',$this->object->getId());
00224                 $record_gui->loadFromPost();
00225                 $record_gui->saveValues();
00226 
00227                 ilUtil::sendInfo($this->lng->txt("settings_saved"));
00228                 $this->editObject();
00229                 return true;
00230         }
00231 
00237         protected function initEditTable()
00238         {
00239                 if(is_object($this->form))
00240                 {
00241                         return true;
00242                 }
00243                 
00244                 $this->lng->loadLanguageModule('crs');
00245         
00246                 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
00247                 $this->form = new ilPropertyFormGUI();
00248                 $this->form->setTableWidth('75%');
00249                 $this->form->setFormAction($this->ctrl->getFormAction($this));
00250                 $this->form->setTitle($this->lng->txt('rcrs_general_info'));
00251                 $this->form->addCommandButton('update',$this->lng->txt('save'));
00252                 $this->form->addCommandButton('edit',$this->lng->txt('cancel'));
00253                 
00254                 $text = new ilTextInputGUI($this->lng->txt('title'),'title');
00255                 $text->setValue($this->object->getTitle());
00256                 $text->setSize(40);
00257                 $text->setMaxLength(128);
00258                 $text->setDisabled(true);
00259                 $this->form->addItem($text);
00260                 
00261                 
00262                 $area = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
00263                 $area->setValue($this->object->getDescription());
00264                 $area->setRows(3);
00265                 $area->setCols(80);
00266                 $area->setDisabled(true);
00267                 $this->form->addItem($area);
00268 
00269                 $area = new ilTextAreaInputGUI($this->lng->txt('local_info'),'local_info');
00270                 $area->setValue($this->object->getLocalInformation());
00271                 $area->setRows(3);
00272                 $area->setCols(80);
00273                 $this->form->addItem($area);
00274                 
00275                 $radio_grp = new ilRadioGroupInputGUI($this->lng->txt('crs_visibility'),'activation_type');
00276                 $radio_grp->setValue($this->object->getAvailabilityType());
00277                 $radio_grp->setDisabled(true);
00278 
00279                 $radio_opt = new ilRadioOption($this->lng->txt('crs_visibility_unvisible'),ilObjRemoteCourse::ACTIVATION_OFFLINE);
00280                 $radio_grp->addOption($radio_opt);
00281 
00282                 $radio_opt = new ilRadioOption($this->lng->txt('crs_visibility_limitless'),ilObjRemoteCourse::ACTIVATION_UNLIMITED);
00283                 $radio_grp->addOption($radio_opt);      
00284 
00285                 $radio_opt = new ilRadioOption($this->lng->txt('crs_visibility_until'),ilObjRemoteCourse::ACTIVATION_LIMITED);
00286                 
00287                 $start = new ilDateTimeInputGUI($this->lng->txt('crs_start'),'start');
00288                 $start->setUnixTime(time());
00289                 $start->setDisabled(true);
00290                 $start->setShowTime(true);
00291                 $radio_opt->addSubItem($start);
00292                 $end = new ilDateTimeInputGUI($this->lng->txt('crs_end'),'end');
00293                 $end->setUnixTime(time());
00294                 $end->setDisabled(true);
00295                 $end->setShowTime(true);
00296                 $radio_opt->addSubItem($end);
00297                 
00298                 $radio_grp->addOption($radio_opt);
00299                 $this->form->addItem($radio_grp);       
00300 
00301                 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDRecordGUI.php');
00302                 $record_gui = new ilAdvancedMDRecordGUI(ilAdvancedMDRecordGUI::MODE_EDITOR,'rcrs',$this->object->getId());
00303                 $record_gui->setPropertyForm($this->form);
00304                 $record_gui->parse();
00305         }
00306         
00314         public function availabilityToString()
00315         {
00316                 switch($this->object->getAvailabilityType())
00317                 {
00318                         case ilObjRemoteCourse::ACTIVATION_OFFLINE:
00319                                 return $this->lng->txt('offline');
00320                         
00321                         case ilObjRemoteCourse::ACTIVATION_UNLIMITED:
00322                                 return $this->lng->txt('crs_unlimited');
00323                         
00324                         case ilObjRemoteCourse::ACTIVATION_LIMITED:
00325                                 return $this->lng->txt('crs_from').' '.ilFormat::formatUnixTime($this->object->getStartingTime(),true).
00326                                         '<br /> '.$this->lng->txt('crs_to').' '.ilFormat::formatUnixTime($this->object->getEndingTime(),true);
00327                 }
00328                 return '';
00329         }
00330 }
00331 ?>

Generated on Fri Dec 13 2013 17:56:52 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1