Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/backup/util/structure/backup_attribute.class.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
00017 
00030 class backup_attribute extends base_attribute implements processable, annotable {
00031 
00032     protected $annotationitem; // To store the item this element will be responsible to annotate
00033 
00034     public function process($processor) {
00035         if (!$processor instanceof base_processor) { // No correct processor, throw exception
00036             throw new base_element_struct_exception('incorrect_processor');
00037         }
00038         $processor->process_attribute($this);
00039     }
00040 
00041     public function set_annotation_item($itemname) {
00042         if (!empty($this->annotationitem)) {
00043             $a = new stdclass();
00044             $a->attribute = $this->get_name();
00045             $a->annotating= $this->annotationitem;
00046             throw new base_element_struct_exception('attribute_already_used_for_annotation', $a);
00047         }
00048         $this->annotationitem = $itemname;
00049     }
00050 
00051     public function annotate($backupid) {
00052         if (empty($this->annotationitem)) { // We aren't annotating this item
00053             return;
00054         }
00055         if (!$this->is_set()) {
00056             throw new base_element_struct_exception('attribute_has_not_value', $this->get_name());
00057         }
00058         backup_structure_dbops::insert_backup_ids_record($backupid, $this->annotationitem, $this->get_value());
00059     }
00060 
00061 }
 All Data Structures Namespaces Files Functions Variables Enumerations