* @copyright 2001-2007 VIKO team and contributors * @license http://www.gnu.org/licenses/gpl.html GPL 2.0 */ require_once 'Module.php'; require_once 'School.php'; require_once 'SchoolNameForm.php'; require_once 'HTML/QuickForm/Renderer/VIKO.php'; /** * Adding new schools * * */ class Module_SchoolAdd extends Module { /** * Returns the module identifier string * * @access public * @static * @return string Identificator of module */ function getID() { return "school-add"; } /** * Returns page in HTML * * @return string HTML fragment */ function toHTML() { // only admins are allowed to add new schools if ( !$_SESSION['user']->hasAccessToGroup("ADMIN") ) { return $this->accessDeniedPage( _("You are not authorized to add, edit or delete schools.") ); } return $this->_addSchool(); } /** * Page for adding new school * * @access private * @return string HTML fragment */ function _addSchool() { $html_form = SchoolNameForm::createForm(); $school =& new School(); // translate the title $html = $this->title( _("Add school") ); if ( $html_form->validate() ) { $school->setName( $html_form->exportValue('school-name') ); $school->save(); $html.= HTML::p( HTML::notice( _("School successfully added.") ) ); } else { // convert form to HTML $html .= HTML_QuickForm_Renderer_VIKO::render( $html_form ); } // backlink $html .= HTML::backLink( $this->URI("statistics"), _("Return to the list of all schools"), STANDALONE ); return $html; } } ?>