[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/admin/xmldb/actions/edit_statement_save/ -> edit_statement_save.class.php (source)

   1  <?php // $Id: edit_statement_save.class.php,v 1.4 2007/10/10 05:25:20 nicolasconnault Exp $
   2  
   3  ///////////////////////////////////////////////////////////////////////////
   4  //                                                                       //
   5  // NOTICE OF COPYRIGHT                                                   //
   6  //                                                                       //
   7  // Moodle - Modular Object-Oriented Dynamic Learning Environment         //
   8  //          http://moodle.com                                            //
   9  //                                                                       //
  10  // Copyright (C) 1999 onwards Martin Dougiamas        http://dougiamas.com  //
  11  //           (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com  //
  12  //                                                                       //
  13  // This program is free software; you can redistribute it and/or modify  //
  14  // it under the terms of the GNU General Public License as published by  //
  15  // the Free Software Foundation; either version 2 of the License, or     //
  16  // (at your option) any later version.                                   //
  17  //                                                                       //
  18  // This program is distributed in the hope that it will be useful,       //
  19  // but WITHOUT ANY WARRANTY; without even the implied warranty of        //
  20  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         //
  21  // GNU General Public License for more details:                          //
  22  //                                                                       //
  23  //          http://www.gnu.org/copyleft/gpl.html                         //
  24  //                                                                       //
  25  ///////////////////////////////////////////////////////////////////////////
  26  
  27  /// This class will save the changes performed to the name and comment of
  28  /// one statement
  29  
  30  class edit_statement_save extends XMLDBAction {
  31  
  32      /**
  33       * Init method, every subclass will have its own
  34       */
  35      function init() {
  36          parent::init();
  37  
  38      /// Set own custom attributes
  39  
  40      /// Get needed strings
  41          $this->loadStrings(array(
  42              'administration' => ''
  43          ));
  44      }
  45  
  46      /**
  47       * Invoke method, every class will have its own
  48       * returns true/false on completion, setting both
  49       * errormsg and output as necessary
  50       */
  51      function invoke() {
  52          parent::invoke();
  53  
  54          $result = true;
  55  
  56      /// Set own core attributes
  57          $this->does_generate = ACTION_NONE;
  58          //$this->does_generate = ACTION_GENERATE_HTML;
  59  
  60      /// These are always here
  61          global $CFG, $XMLDB;
  62  
  63      /// Do the job, setting result as needed
  64  
  65      /// Get parameters
  66          $dirpath = required_param('dir', PARAM_PATH);
  67          $dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
  68  
  69          $statementparam = strtolower(required_param('statement', PARAM_CLEAN));
  70          $name = trim(strtolower(required_param('name', PARAM_CLEAN)));
  71          $comment = required_param('comment', PARAM_CLEAN);
  72          $comment = stripslashes_safe($comment);
  73  
  74          $editeddir =& $XMLDB->editeddirs[$dirpath];
  75          $structure =& $editeddir->xml_file->getStructure();
  76          $statement =& $structure->getStatement($statementparam);
  77  
  78          $errors = array();    /// To store all the errors found
  79  
  80      /// If there is one name change, do it, changing the prev and next
  81      /// atributes of the adjacent tables
  82          if ($statementparam != $name) {
  83              $statement->setName($name);
  84              if ($statement->getPrevious()) {
  85                  $prev =& $structure->getStatement($statement->getPrevious());
  86                  $prev->setNext($name);
  87                  $prev->setChanged(true);
  88              }
  89              if ($statement->getNext()) {
  90                  $next =& $structure->getStatement($statement->getNext());
  91                  $next->setPrevious($name);
  92                  $next->setChanged(true);
  93              }
  94          }
  95  
  96      /// Set comment
  97          $statement->setComment($comment);
  98  
  99      /// Launch postaction if exists (leave this here!)
 100          if ($this->getPostAction() && $result) {
 101              return $this->launch($this->getPostAction());
 102          }
 103  
 104      /// Return ok if arrived here
 105          return $result;
 106      }
 107  }
 108  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7