date = $xml_data->getAttribute('date'); $this->by = $xml_data->getAttribute('by'); if ( $xml_data->hasAttribute('tostate') ) { $this->to_state = $xml_data->getAttribute('tostate'); } if ( $xml_data->hasAttribute('autotostate') ) { $this->auto_to_state = $xml_data->getAttribute('autotostate'); } } // ---------------------------------------- // Constructor // // Initiates the instance based on extracted data instead of an // xml object. // // Arguments: // $date is the date of the alteration // $by is the user making the alteration // $to_state is the new state for the result sub part // ---------------------------------------- public function __construct4($date, $by, $to_state, $auto_to_state) { $this->is_new = true; $this->date = $date; $this->by = $by; $this->to_state = $to_state; $this->auto_to_state = $auto_to_state; } // ---------------------------------------- // get_date // // Returns the date of the alteration. // ---------------------------------------- public function get_date() { return $this->date; } // ---------------------------------------- // get_altered_by // // Returns who altered the result. // ---------------------------------------- public function get_altered_by() { return $this->by; } // ---------------------------------------- // get_auto_to_state // // Returns the new auto state for this alteration. // ---------------------------------------- public function get_auto_to_state() { return $this->auto_to_state; } // ---------------------------------------- // get_to_state // // Returns the new state for this alteration. // ---------------------------------------- public function get_to_state() { return $this->to_state; } // ---------------------------------------- // is_new // // Returns a boolean indicating whether the sub part is new to // this student. // ---------------------------------------- public function is_new() { return $this->is_new; } // ---------------------------------------- // save_results_to_file // // Stores the results for this altered tag on the given // file. We know the student exists in active students for this // course. // // Arguments: // $xml_document is the DOMDocument in which to store the changes. // $sub_elem the sub part xml element to append results to. // // Returns true if successfully saved, false otherwise, to handle // errors outside. // ---------------------------------------- public function save_results_to_file($xml_document, $sub_elem) { // An altered tag that has been added is always new, we never // modify a tag, so we create a new one. $tag_elem = $xml_document->createElement('altered'); $tag_elem->setAttribute('date', $this->date); $tag_elem->setAttribute('by', $this->by); // ---------- // Check the optional attributes and store them if they // have a value. // ---------- if ( isset($this->to_state) and ! empty($this->to_state) ) { $tag_elem->setAttribute('tostate', $this->to_state); } if ( isset($this->auto_to_state) and ! empty($this->auto_to_state) ) { $tag_elem->setAttribute('autotostate', $this->auto_to_state); } $sub_elem->appendChild($tag_elem); } // ---------------------------------------- // print_dump // // Print function for debugging / testing. // ---------------------------------------- public function print_dump() { print "\t\t\t\tAltered tag date: " . $this->date . ", by: " . $this->by . ", tostate: " . $this->to_state . ", toautostate: " . $this->auto_to_state . "\n"; } // ---------------------------------------- // End of Altered_Tag class definition // ---------------------------------------- } // ---------------------------------------------------------------------------- ?>