'administration', 'name' => 'Administration'), ); function do_main() { $this->aBreadcrumbs[] = array('action' => 'unitManagement', 'name' => 'Unit Management'); $this->oPage->setBreadcrumbDetails('select a unit'); $this->oPage->setTitle("Unit Management"); $unit_id= KTUtil::arrayGet($_REQUEST, 'unit_id', null); if ($unit_id === null) { $for_edit = false; } else { $for_edit = true; } $add_fields = array(); $add_fields[] = new KTStringWidget('Unit Name','The unit\'s visible name. e.g. Tech Support', 'name', null, $this->oPage, true); $unit_list =& Unit::getList(); $edit_fields = array(); $edit_unit = null; if ($for_edit === true) { $oUnit = Unit::get($unit_id); $edit_fields[] = new KTStringWidget('Unit Name','The unit\'s visible name. e.g. Tech Support', 'name', $oUnit->getName(), $this->oPage, true); } $oTemplating = new KTTemplating; $oTemplate = $oTemplating->loadTemplate("ktcore/principals/unitadmin"); $aTemplateData = array( "context" => $this, "add_fields" => $add_fields, "for_edit" => $for_edit, "edit_fields" => $edit_fields, "edit_unit" => $oUnit, "unit_list" => $unit_list, ); return $oTemplate->render($aTemplateData); } function do_updateUnit() { $unit_id = KTUtil::arrayGet($_REQUEST, 'unit_id'); $oUnit = Unit::get($unit_id); if (PEAR::isError($oUnit) || ($oUnit == false)) { $this->errorRedirectToMain('Please specify a unit.'); exit(0); } $unit_name = KTUtil::arrayGet($_REQUEST, 'name', null); if (empty($unit_name)) { $this->errorRedirectToMain('Please specify a unit name.'); exit(0); } $this->startTransaction(); $oUnit->setName($unit_name); $res = $oUnit->update(); if (PEAR::isError($res)) { $this->errorRedirectToMain('Failed to update unit name.'); exit(0); } $this->commitTransaction(); $this->successRedirectToMain('Unit name changed to "' . $unit_name . '"'); } } ?>