Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / admin / xmldb / actions / edit_statement_save / edit_statement_save.class.php
blobb8de4e01c563eaaf894445114ef6c42090e1d1fd
1 <?php // $Id$
3 ///////////////////////////////////////////////////////////////////////////
4 // //
5 // NOTICE OF COPYRIGHT //
6 // //
7 // Moodle - Modular Object-Oriented Dynamic Learning Environment //
8 // http://moodle.com //
9 // //
10 // Copyright (C) 2001-3001 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 ///////////////////////////////////////////////////////////////////////////
27 /// This class will save the changes performed to the name and comment of
28 /// one statement
30 class edit_statement_save extends XMLDBAction {
32 /**
33 * Init method, every subclass will have its own
35 function init() {
36 parent::init();
38 /// Set own custom attributes
40 /// Get needed strings
41 $this->loadStrings(array(
42 'administration' => ''
43 ));
46 /**
47 * Invoke method, every class will have its own
48 * returns true/false on completion, setting both
49 * errormsg and output as necessary
51 function invoke() {
52 parent::invoke();
54 $result = true;
56 /// Set own core attributes
57 $this->does_generate = ACTION_NONE;
58 //$this->does_generate = ACTION_GENERATE_HTML;
60 /// These are always here
61 global $CFG, $XMLDB;
63 /// Do the job, setting result as needed
65 /// Get parameters
66 $dirpath = required_param('dir', PARAM_PATH);
67 $dirpath = $CFG->dirroot . stripslashes_safe($dirpath);
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);
74 $editeddir =& $XMLDB->editeddirs[$dirpath];
75 $structure =& $editeddir->xml_file->getStructure();
76 $statement =& $structure->getStatement($statementparam);
78 $errors = array(); /// To store all the errors found
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);
89 if ($statement->getNext()) {
90 $next =& $structure->getStatement($statement->getNext());
91 $next->setPrevious($name);
92 $next->setChanged(true);
96 /// Set comment
97 $statement->setComment($comment);
99 /// Launch postaction if exists (leave this here!)
100 if ($this->getPostAction() && $result) {
101 return $this->launch($this->getPostAction());
104 /// Return ok if arrived here
105 return $result;