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

Services/MetaData/classes/class.ilObjMDSettingsGUI.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 include_once("./classes/class.ilObjectGUI.php");
00024 
00025 
00036 class ilObjMDSettingsGUI extends ilObjectGUI
00037 {
00038 
00044         public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
00045         {
00046                 global $lng;
00047                 
00048                 $this->type = 'mds';
00049                 parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
00050 
00051                 $this->lng = $lng;
00052                 $this->lng->loadLanguageModule("meta");
00053         }
00054 
00061         public function executeCommand()
00062         {
00063                 global $rbacsystem,$ilErr,$ilAccess;
00064 
00065                 $next_class = $this->ctrl->getNextClass($this);
00066                 $cmd = $this->ctrl->getCmd();
00067 
00068                 $this->prepareOutput();
00069 
00070                 if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
00071                 {
00072                         $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
00073                 }
00074 
00075                 switch($next_class)
00076                 {
00077                         case 'iladvancedmdsettingsgui':
00078                                 $this->tabs_gui->setTabActive('md_advanced');
00079                                 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDSettingsGUI.php');
00080                                 $adv_md = new ilAdvancedMDSettingsGUI();
00081                                 $ret = $this->ctrl->forwardCommand($adv_md);
00082                                 break;
00083                         
00084                         case 'ilpermissiongui':
00085                                 $this->tabs_gui->setTabActive('perm_settings');
00086                                 include_once("./classes/class.ilPermissionGUI.php");
00087                                 $perm_gui =& new ilPermissionGUI($this);
00088                                 $ret =& $this->ctrl->forwardCommand($perm_gui);
00089                                 break;
00090 
00091                         default:
00092                                 $this->tabs_gui->setTabActive('md_copyright');
00093                                 $this->initMDSettings();
00094                                 if(!$cmd || $cmd == 'view')
00095                                 {
00096                                         $cmd = "settings";
00097                                 }
00098 
00099                                 $this->$cmd();
00100                                 break;
00101                 }
00102                 return true;
00103         }
00104 
00111         public function getAdminTabs()
00112         {
00113                 global $rbacsystem, $ilAccess;
00114 
00115                 if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
00116                 {
00117                         $this->tabs_gui->addTarget("md_copyright",
00118                                 $this->ctrl->getLinkTarget($this, "settings"),
00119                                 array("settings", "view"));
00120 
00121                         $this->tabs_gui->addTarget("md_advanced",
00122                                 $this->ctrl->getLinkTargetByClass('iladvancedmdsettingsgui', ""),
00123                                 '',
00124                                 'iladvancedmdsettingsgui');
00125                                 
00126                 }
00127 
00128                 if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
00129                 {
00130                         $this->tabs_gui->addTarget("perm_settings",
00131                                 $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
00132                                 array(),'ilpermissiongui');
00133                 }
00134         }
00135 
00139         public function settings()
00140         {
00141                 $this->tpl->addBlockFile('ADM_CONTENT','adm_content','tpl.settings.html','Services/MetaData');
00142                 
00143                 $this->initSettingsForm();
00144                 $this->tpl->setVariable('SETTINGS_TABLE',$this->form->getHTML());
00145                 
00146                 include_once("./Services/MetaData/classes/class.ilMDCopyrightTableGUI.php");
00147                 $table_gui = new ilMDCopyrightTableGUI($this,'settings');
00148                 $table_gui->setTitle($this->lng->txt("md_copyright_selection"));
00149                 $table_gui->parseSelections();
00150 //              $table_gui->addCommandButton("updateCopyrightSelection", $this->lng->txt("save"));
00151                 $table_gui->addCommandButton('addEntry',$this->lng->txt('add'));
00152                 $table_gui->addMultiCommand("confirmDeleteEntries", $this->lng->txt("delete"));
00153                 $table_gui->setSelectAllCheckbox("entry_id");
00154                 $this->tpl->setVariable('COPYRIGHT_TABLE',$table_gui->getHTML());
00155                 
00156                 
00157         }
00158 
00162         public function saveSettings()
00163         {
00164                 $this->md_settings->activateCopyrightSelection((int) $_POST['active']);
00165                 $this->md_settings->save();
00166                 ilUtil::sendInfo($this->lng->txt('settings_saved'));
00167                 $this->settings();
00168         }
00169         
00170         
00177         public function editEntry()
00178         {
00179                 $this->ctrl->saveParameter($this,'entry_id');
00180                 $this->initCopyrightEditForm();
00181                 $this->tpl->setContent($this->form->getHTML());
00182         }
00183         
00191         public function addEntry()
00192         {
00193                 $this->initCopyrightEditForm('add');
00194                 $this->tpl->setContent($this->form->getHTML());
00195         }
00196         
00197         
00204         public function saveEntry()
00205         {
00206                 global $ilErr;
00207 
00208                 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
00209                 $this->entry = new ilMDCopyrightSelectionEntry(0);
00210         
00211                 $this->entry->setTitle(ilUtil::stripSlashes($_POST['title']));
00212                 $this->entry->setDescription(ilUtil::stripSlashes($_POST['description']));
00213                 $this->entry->setCopyright($this->stripSlashes($_POST['copyright']));
00214                 $this->entry->setLanguage('en');
00215                 $this->entry->setCopyrightAndOtherRestrictions(true);
00216                 $this->entry->setCosts(false);
00217                 
00218                 if(!$this->entry->validate())
00219                 {
00220                         ilUtil::sendInfo($this->lng->txt('fill_out_all_required_fields'));
00221                         $this->addEntry();
00222                         return false;
00223                 }
00224                 $this->entry->add();
00225                 ilUtil::sendInfo($this->lng->txt('settings_saved'));
00226                 $this->settings();
00227                 return true;
00228         }
00229         
00236         public function confirmDeleteEntries()
00237         {
00238                 if(!is_array($_POST['entry_id']) or !count($_POST['entry_id']))
00239                 {
00240                         ilUtil::sendInfo($this->lng->txt('select_one'));
00241                         $this->settings();
00242                         return true;
00243                 }
00244                 
00245                 include_once('Services/Utilities/classes/class.ilConfirmationGUI.php');
00246                 $c_gui = new ilConfirmationGUI();
00247                 
00248                 // set confirm/cancel commands
00249                 $c_gui->setFormAction($this->ctrl->getFormAction($this, "deleteEntries"));
00250                 $c_gui->setHeaderText($this->lng->txt("md_delete_cp_sure"));
00251                 $c_gui->setCancel($this->lng->txt("cancel"), "settings");
00252                 $c_gui->setConfirm($this->lng->txt("confirm"), "deleteEntries");
00253 
00254                 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
00255 
00256                 // add items to delete
00257                 foreach($_POST["entry_id"] as $entry_id)
00258                 {
00259                         $entry = new ilMDCopyrightSelectionEntry($entry_id);
00260                         $c_gui->addItem('entry_id[]',$entry_id,$entry->getTitle());
00261                 }
00262                 $this->tpl->setContent($c_gui->getHTML());
00263         }
00264         
00271         public function deleteEntries()
00272         {
00273                 if(!is_array($_POST['entry_id']) or !count($_POST['entry_id']))
00274                 {
00275                         ilUtil::sendInfo($this->lng->txt('select_one'));
00276                         $this->settings();
00277                         return true;
00278                 }
00279 
00280                 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
00281                 foreach($_POST["entry_id"] as $entry_id)
00282                 {
00283                         $entry = new ilMDCopyrightSelectionEntry($entry_id);
00284                         $entry->delete();
00285                 }
00286                 ilUtil::sendInfo($this->lng->txt('md_copyrights_deleted'));
00287                 $this->settings();
00288                 return true;
00289         }
00290 
00297         public function updateEntry()
00298         {
00299                 global $ilErr;
00300 
00301                 include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
00302                 $this->entry = new ilMDCopyrightSelectionEntry((int) $_REQUEST['entry_id']);
00303         
00304                 $this->entry->setTitle(ilUtil::stripSlashes($_POST['title']));
00305                 $this->entry->setDescription(ilUtil::stripSlashes($_POST['description']));
00306                 $this->entry->setCopyright($this->stripSlashes($_POST['copyright']));
00307                 
00308                 if(!$this->entry->validate())
00309                 {
00310                         ilUtil::sendInfo($this->lng->txt('fill_out_all_required_fields'));
00311                         $this->editEntry();
00312                         return false;
00313                 }
00314                 $this->entry->update();
00315                 ilUtil::sendInfo($this->lng->txt('settings_saved'));
00316                 $this->settings();
00317                 return true;
00318         }
00319         
00320         
00326         protected function initSettingsForm()
00327         {
00328                 if(is_object($this->form))
00329                 {
00330                         return true;
00331                 }
00332                 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
00333                 $this->form = new ilPropertyFormGUI();
00334                 $this->form->setFormAction($this->ctrl->getFormAction($this));
00335                 $this->form->setTitle($this->lng->txt('md_copyright_settings'));
00336                 $this->form->addCommandButton('saveSettings',$this->lng->txt('save'));
00337                 $this->form->addCommandButton('settings',$this->lng->txt('cancel'));
00338                 
00339                 $check = new ilCheckboxInputGUI($this->lng->txt('md_copyright_enabled'),'active');
00340                 $check->setChecked($this->md_settings->isCopyrightSelectionActive());
00341                 $check->setValue(1);
00342                 $check->setInfo($this->lng->txt('md_copyright_enable_info'));
00343                 $this->form->addItem($check);
00344         }
00345         
00353         public function initCopyrightEditForm($a_mode = 'edit')
00354         {
00355                 if(is_object($this->form))
00356                 {
00357                         return true;
00358                 }
00359                 if(!is_object($this->entry))
00360                 {
00361                         include_once('Services/MetaData/classes/class.ilMDCopyrightSelectionEntry.php');
00362                         $this->entry = new ilMDCopyrightSelectionEntry((int) $_REQUEST['entry_id']);
00363                 }
00364                 
00365                 include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
00366                 $this->form = new ilPropertyFormGUI();
00367                 $this->form->setFormAction($this->ctrl->getFormAction($this));
00368                 
00369                 $tit = new ilTextInputGUI($this->lng->txt('title'),'title');
00370                 $tit->setValue($this->entry->getTitle());
00371                 $tit->setRequired(true);
00372                 $tit->setSize(40);
00373                 $tit->setMaxLength(255);
00374                 $this->form->addItem($tit);
00375                 
00376                 $des = new ilTextAreaInputGUI($this->lng->txt('description'),'description');
00377                 $des->setValue($this->entry->getDescription());
00378                 $des->setRows(3);
00379                 $this->form->addItem($des);
00380                 
00381                 $cop = new ilTextAreaInputGUI($this->lng->txt('md_copyright_value'),'copyright');
00382                 $cop->setValue($this->entry->getCopyright());
00383                 $cop->setRows(5);
00384                 $this->form->addItem($cop);
00385                 
00386                 switch($a_mode)
00387                 {
00388                         case 'edit':
00389                                 $this->form->setTitle($this->lng->txt('md_copyright_edit'));
00390                                 $this->form->addCommandButton('updateEntry',$this->lng->txt('save'));
00391                                 $this->form->addCommandButton('settings',$this->lng->txt('cancel'));
00392                                 break;
00393                         
00394                         case 'add':
00395                                 $this->form->setTitle($this->lng->txt('md_copyright_add'));
00396                                 $this->form->addCommandButton('saveEntry',$this->lng->txt('save'));
00397                                 $this->form->addCommandButton('settings',$this->lng->txt('cancel'));
00398                                 break;                  
00399                 }
00400                 
00401         }
00402         
00408         protected function initMDSettings()
00409         {
00410                 include_once('Services/MetaData/classes/class.ilMDSettings.php');
00411                 $this->md_settings = ilMDSettings::_getInstance();
00412         }
00413         
00419         protected function stripSlashes($a_str)
00420         {
00421                 if (ini_get("magic_quotes_gpc"))
00422                 {
00423                         $a_str = stripslashes($a_str);
00424                 }
00425                 return $a_str;          
00426         }
00427 }
00428 ?>

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