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

Modules/Course/classes/class.ilCourseItemAdministrationGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 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 
00036 class ilCourseItemAdministrationGUI
00037 {
00038         var $container_obj;
00039         var $tpl;
00040         var $ctrl;
00041         var $lng;
00042 
00047         function ilCourseItemAdministrationGUI(&$container_obj,$a_item_id)
00048         {
00049                 global $tpl,$ilCtrl,$lng,$ilObjDataCache,$ilErr,$ilTabs;
00050 
00051                 $this->tpl =& $tpl;
00052                 $this->ctrl =& $ilCtrl;
00053                 $this->lng =& $lng;
00054                 $this->lng->loadLanguageModule('crs');
00055                 $this->err =& $ilErr;
00056                 $this->tabs_gui =& $ilTabs;
00057 
00058                 $this->container_obj =& $container_obj;
00059 
00060                 $this->item_id = $a_item_id;
00061                 $this->ctrl->saveParameter($this,'item_id');
00062 
00063                 $this->__initItem();
00064         }
00065 
00066         function &executeCommand()
00067         {
00068                 global $ilTabs;
00069 
00070                 $this->__setTabs();
00071 
00072                 $cmd = $this->ctrl->getCmd();
00073 
00074                 // Check if item id is given and valid
00075                 if(!$this->__checkItemId())
00076                 {
00077                         ilUtil::sendInfo($this->lng->txt("crs_no_item_id_given"),true);
00078                         $this->ctrl->returnToParent($this);
00079                 }
00080 
00081                 switch($this->ctrl->getNextClass($this))
00082                 {
00083 
00084                         case 'ilconditionhandlerinterface':
00085                                 
00086                                 // preconditions for single course items
00087                                 include_once './classes/class.ilConditionHandlerInterface.php';
00088                                 $this->ctrl->saveParameter($this,'item_id',$_GET['item_id']);
00089                                 $new_gui =& new ilConditionHandlerInterface($this,(int) $_GET['item_id']);
00090                                 $this->ctrl->forwardCommand($new_gui);
00091                                 $this->tabs_gui->setTabActive('preconditions');
00092                                 break;
00093 
00094                         default:
00095                                 $this->tabs_gui->setTabActive('timings');
00096                                 if(!$cmd)
00097                                 {
00098                                         $cmd = 'edit';
00099                                 }
00100                                 $this->$cmd();
00101                                 $this->tabs_gui->setTabActive('timings');
00102                                 break;
00103                 }
00104         }
00105 
00106         function getItemId()
00107         {
00108                 return $this->item_id;
00109         }
00110 
00111         function cancel()
00112         {
00113                 $this->ctrl->returnToParent($this);
00114         }
00115 
00116         function edit()
00117         {
00118                 global $ilErr,$ilAccess,$ilObjDataCache;
00119 
00120                 if(!$ilAccess->checkAccess('write','',$this->container_obj->getRefId()))
00121                 {
00122                         $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
00123                 }
00124 
00125                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.crs_edit_item.html",'Modules/Course');
00126                 $this->tpl->setVariable("FORMACTION",$this->ctrl->getFormAction($this));
00127                 $item_data = $this->items_obj->getItem($this->getItemId());
00128                 $title = $ilObjDataCache->lookupTitle($item_data['obj_id']);
00129 
00130                 if(isset($_POST['cmd']))
00131                 {
00132                         $timing_type = $_POST['timing_type'];
00133                         $visible = $_POST['visible'];
00134                         $changeable = $_POST['changeable'];
00135                         $timing_start = $this->__toUnix($_POST['timing_start'],$_POST['timing_start_time']);
00136                         $timing_end = $this->__toUnix($_POST['timing_end'],$_POST['timing_end_time']);
00137                         $suggestion_start = $this->__toUnix($_POST['sug_start']);
00138                         $suggestion_end = $this->__toUnix($_POST['sug_end']);
00139                         $earliest_start = $this->__toUnix($_POST['early_start']);
00140                         $latest_end = $this->__toUnix($_POST['late_end']);
00141                 }
00142                 else
00143                 {
00144                         $timing_type = $item_data['timing_type'];
00145                         $visible = $item_data['visible'];
00146                         $changeable = $item_data['changeable'];
00147                         $timing_start = $item_data['timing_start'];
00148                         $timing_end = $item_data['timing_end'];
00149                         $suggestion_start = $item_data['suggestion_start'];
00150                         $suggestion_end = $item_data['suggestion_end'];
00151                         $earliest_start = $item_data['earliest_start'];
00152                         $latest_end = $item_data['latest_end'];
00153                 }
00154 
00155                 // SET TEXT VARIABLES
00156                 $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_".$ilObjDataCache->lookupType($item_data['obj_id'])));
00157                 $this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath("icon_".$ilObjDataCache->lookupType($item_data['obj_id']).".gif"));
00158                 $this->tpl->setVariable("TITLE",$ilObjDataCache->lookupTitle($item_data['obj_id']));
00159                 $this->tpl->setVariable("EDIT_TIMINGS",$this->lng->txt('crs_edit_timings'));
00160                 $this->tpl->setVariable("TXT_TIMINGS",$this->lng->txt('crs_timings_disabled'));
00161                 $this->tpl->setVariable("INFO_DEACTIVATED",$this->lng->txt('crs_timings_disabled_info'));
00162                 $this->tpl->setVariable("TXT_BEGIN",$this->lng->txt('crs_timings_start'));
00163                 $this->tpl->setVariable("TXT_END",$this->lng->txt('crs_timings_END'));
00164                 $this->tpl->setVariable("TXT_ACTIVATION_ENABLED",$this->lng->txt('crs_timings_availability_enabled'));
00165                 $this->tpl->setVariable("TXT_PRESETTING",$this->lng->txt('crs_timings_presetting_tbl'));
00166                 $this->tpl->setVariable("TXT_SUG_BEGIN",$this->lng->txt('crs_timings_sug_begin'));
00167                 $this->tpl->setVariable("TXT_SUG_END",$this->lng->txt('crs_suggestion_end'));
00168                 $this->tpl->setVariable("TXT_EARLY_BEGIN",$this->lng->txt('crs_timings_early_begin'));
00169                 $this->tpl->setVariable("TXT_LATE_END",$this->lng->txt('crs_timings_late_end'));
00170                 $this->tpl->setVariable("TXT_TIME",$this->lng->txt('time'));
00171 
00172 
00173 
00174                 // Disabled
00175                 $this->tpl->setVariable("TXT_AVAILABILITY",$this->lng->txt('crs_timings_availability_tbl'));
00176                 $this->tpl->setVariable("TXT_TIMINGS_DEACTIVATED",$this->lng->txt('crs_timings_deactivated'));
00177                 $this->tpl->setVariable("RADIO_DEACTIVATE",ilUtil::formRadioButton($timing_type == IL_CRS_TIMINGS_DEACTIVATED,
00178                                                                                                                                                    'timing_type',IL_CRS_TIMINGS_DEACTIVATED));
00179 
00180                 // Activation
00181                 $this->tpl->setVariable("RADIO_ACTIVATION",ilUtil::formRadioButton($timing_type == IL_CRS_TIMINGS_ACTIVATION,
00182                                                                                                                                                    'timing_type',IL_CRS_TIMINGS_ACTIVATION));
00183                 $this->tpl->setVariable("TXT_TIMINGS_ACTIVATION",$this->lng->txt('crs_timings_availability'));
00184                 $this->tpl->setVariable("INFO_AVAILABILITY",$this->lng->txt('crs_item_availability_info'));
00185 
00186                 $this->tpl->setVariable("CHECK_VISIBILITY",ilUtil::formCheckbox($visible,
00187                                                                                                                                                 'visible',1));
00188                 $this->tpl->setVariable("TXT_VISIBILITY",$this->lng->txt('crs_timings_visibility'));
00189 
00190                 // Timings
00191                 $this->tpl->setVariable("RADIO_TIMINGS",ilUtil::formRadioButton($timing_type == IL_CRS_TIMINGS_PRESETTING,
00192                                                                                                                                                 'timing_type',IL_CRS_TIMINGS_PRESETTING));
00193                 $this->tpl->setVariable("TXT_TIMINGS_PRESETTING",$this->lng->txt('crs_timings_presetting'));
00194                 $this->tpl->setVariable("INFO_PRESETTING",$this->lng->txt('crs_item_presetting_info'));
00195 
00196                 $this->tpl->setVariable("CHECK_CHANGE",ilUtil::formCheckbox($changeable,'changeable',1));
00197                 $this->tpl->setVariable("TXT_CHANGE",$this->lng->txt('crs_timings_changeable'));
00198 
00199                 // Start
00200                 $this->tpl->setVariable("TXT_START",$this->lng->txt('crs_timings_start'));
00201 
00202                 $date = $this->__prepareDateSelect($timing_start);
00203                 $this->tpl->setVariable("START_DATE_SELECT",
00204                                                                 ilUtil::makeDateSelect('timing_start',$date['y'],$date['m'],$date['d'],date('Y',time())));
00205 
00206                 $date = $this->__prepareTimeSelect($timing_start);
00207                 $this->tpl->setVariable("START_TIME_SELECT",
00208                                                                 ilUtil::makeTimeSelect('timing_start_time',true,$date['h'],$date['m'],0,false));
00209 
00210                 // End
00211                 $date = $this->__prepareDateSelect($timing_end);
00212                 $this->tpl->setVariable("END_DATE_SELECT",
00213                                                                 ilUtil::makeDateSelect('timing_end',$date['y'],$date['m'],$date['d'],date('Y',time())));
00214 
00215                 $date = $this->__prepareTimeSelect($timing_end);
00216                 $this->tpl->setVariable("END_TIME_SELECT",
00217                                                                 ilUtil::makeTimeSelect('timing_end_time',true,$date['h'],$date['m'],0,false));
00218 
00219                 // End
00220                 $this->tpl->setVariable("TXT_END",$this->lng->txt('crs_timings_end'));
00221 
00222                 // Suggestion Start
00223                 $date = $this->__prepareDateSelect($suggestion_start);
00224                 $this->tpl->setVariable("SUG_START_SELECT",
00225                                                                 ilUtil::makeDateSelect('sug_start',$date['y'],$date['m'],$date['d'],date('Y',time())));
00226                 
00227                 $date = $this->__prepareDateSelect($suggestion_end);
00228                 $this->tpl->setVariable("SUG_END_SELECT",
00229                                                                 ilUtil::makeDateSelect('sug_end',$date['y'],$date['m'],$date['d'],date('Y',time())));
00230 
00231                 // Earliest Latest
00232                 $date = $this->__prepareDateSelect($earliest_start);
00233                 $this->tpl->setVariable("EARLY_SELECT",
00234                                                                 ilUtil::makeDateSelect('early_start',$date['y'],$date['m'],$date['d'],date('Y',time())));
00235 
00236                 $date = $this->__prepareDateSelect($latest_end);
00237                 $this->tpl->setVariable("LATE_SELECT",
00238                                                                 ilUtil::makeDateSelect('late_end',$date['y'],$date['m'],$date['d'],date('Y',time())));
00239 
00240                 $this->tpl->setVariable("TXT_CANCEL",$this->lng->txt("cancel"));
00241                 $this->tpl->setVariable("TXT_SAVE",$this->lng->txt("save"));
00242         }
00243 
00244         function update()
00245         {
00246                 global $ilErr,$ilAccess,$ilObjDataCache;
00247 
00248                 if(!$ilAccess->checkAccess('write','',$this->container_obj->getRefId()))
00249                 {
00250                         $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
00251                 }
00252 
00253                 $this->items_obj->setTimingType($_POST['timing_type']);
00254                 $this->items_obj->setTimingStart($this->__toUnix($_POST['timing_start'],$_POST['timing_start_time']));
00255                 $this->items_obj->setTimingEnd($this->__toUnix($_POST['timing_end'],$_POST['timing_end_time']));
00256                 $this->items_obj->setSuggestionStart($this->__toUnix($_POST["sug_start"]));
00257                 $this->items_obj->setSuggestionEnd($this->__toUnix($_POST["sug_end"],array('h' => 23,'m' => 55)));
00258                 $this->items_obj->setEarliestStart($this->__toUnix($_POST['early_start']));
00259                 $this->items_obj->setLatestEnd($this->__toUnix($_POST['late_end'],array('h' => 23,'m' => 55)));
00260                 $this->items_obj->toggleVisible($_POST['visible']);
00261                 $this->items_obj->toggleChangeable($_POST['changeable']);
00262 
00263                 if(!$this->items_obj->validateActivation())
00264                 {
00265                         ilUtil::sendInfo($ilErr->getMessage());
00266                         $this->edit();
00267 
00268                         return true;
00269                 }
00270                 $this->items_obj->update($this->getItemId());
00271                 ilUtil::sendInfo($this->lng->txt('settings_saved'));
00272                 $this->edit();
00273                 #$this->ctrl->returnToParent($this);
00274 
00275                 return true;
00276         }
00277 
00278         function moveUp()
00279         {
00280                 global $ilErr,$ilAccess,$ilObjDataCache;
00281 
00282                 if(!$ilAccess->checkAccess('write','',$this->container_obj->getRefId()))
00283                 {
00284                         $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
00285                 }
00286 
00287                 $this->items_obj->moveUp((int) $this->getItemId());
00288                 ilUtil::sendInfo($this->lng->txt("crs_moved_item"),true);
00289 
00290                 $this->ctrl->returnToParent($this);
00291                 return true;
00292         }
00293 
00294         function moveDown()
00295         {
00296                 global $ilErr,$ilAccess,$ilObjDataCache;
00297 
00298                 if(!$ilAccess->checkAccess('write','',$this->container_obj->getRefId()))
00299                 {
00300                         $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->MESSAGE);
00301                 }
00302 
00303                 $this->items_obj->moveDown((int) $this->getItemId());
00304                 ilUtil::sendInfo($this->lng->txt("crs_moved_item"),true);
00305 
00306                 $this->ctrl->returnToParent($this);
00307                 return true;
00308         }
00309 
00310 
00311         function __checkItemId()
00312         {
00313                 global $tree;
00314 
00315                 if(!$this->getItemId())
00316                 {
00317                         return false;
00318                 }
00319                 // Item has to be within course
00320                 if(!$tree->checkForParentType($this->getItemId(),'crs'))
00321                 {
00322                         return false;
00323                 }
00324                 return true;
00325         }
00326 
00327         function __initItem()
00328         {
00329                 global $ilObjDataCache,$tree;
00330 
00331                 include_once "./Modules/Course/classes/class.ilCourseItems.php";
00332                 
00333                 if(!is_object($this->items_obj))
00334                 {
00335                         $parent_ref = $tree->getParentId($this->item_id);
00336                         $cont_obj = ilObjectFactory::getInstanceByRefId($parent_ref,false);
00337                         
00338                         if($cont_obj->getType() == 'crs')
00339                         {
00340                                 $this->items_obj =& new ilCourseItems($cont_obj,$cont_obj->getRefId());
00341                         }
00342                         else
00343                         {
00344                                 // lookup crs_obj
00345                                 $crs_ref_id = $tree->checkForParentType($cont_obj->getRefId(),'crs');
00346                                 $crs_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id);
00347 
00348                                 $this->items_obj =& new ilCourseItems($crs_obj,$cont_obj->getRefId());
00349                         }
00350                         /*
00351                         if($ilObjDataCache->lookupType($this->container_obj->getId()) == 'crs')
00352                         {
00353                                 $this->items_obj =& new ilCourseItems($this->container_obj,$this->container_obj->getRefId());
00354                         }
00355                         else
00356                         {
00357                                 // lookup crs_obj
00358                                 $crs_ref_id = $tree->checkForParentType($this->container_obj->getRefId(),'crs');
00359                                 $crs_obj = ilObjectFactory::getInstanceByRefId($crs_ref_id);
00360 
00361                                 $this->items_obj =& new ilCourseItems($crs_obj,$this->container_obj->getRefId());
00362                         }
00363                         */
00364                 }
00365                 return true;
00366         }
00367 
00368         function __toUnix($date,$time = array())
00369         {
00370                 return mktime($time['h'],$time['m'],0,$date['m'],$date['d'],$date['y']);
00371         }
00372 
00373         function __prepareDateSelect($a_unix_time)
00374         {
00375                 return array('y' => date('Y',$a_unix_time),
00376                                          'm' => date('m',$a_unix_time),
00377                                          'd' => date('d',$a_unix_time));
00378         }
00379 
00380         function __prepareTimeSelect($a_unix_time)
00381         {
00382                 return array('h' => date('G',$a_unix_time),
00383                                          'm' => date('i',$a_unix_time),
00384                                          's' => date('s',$a_unix_time));
00385         }
00386 
00387         function __setTabs()
00388         {
00389                 global $rbacsystem,$ilUser;
00390                 
00391                 $this->tabs_gui->clearTargets();
00392 
00393                 $this->tabs_gui->setBackTarget($this->lng->txt('back_to_'.$this->container_obj->getType().'_content'),
00394                                                                            'repository.php?ref_id='.$this->container_obj->getRefId());
00395                 $this->tabs_gui->addTarget("timings",
00396                                                                    $this->ctrl->getLinkTarget($this,'edit'),
00397                                                                    "edit", get_class($this));
00398                 $this->ctrl->setParameterByClass('ilconditionhandlerinterface','item_id',(int) $_GET['item_id']);
00399                 $this->tabs_gui->addTarget("preconditions",
00400                                                                    $this->ctrl->getLinkTargetByClass('ilConditionHandlerInterface','listConditions'),
00401                                                                    "", "ilConditionHandlerInterface");
00402                 return true;
00403         }
00404 
00405 } // END class.ilCourseItemAdminsitration
00406 ?>

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