From: hickert Date: Tue, 18 May 2010 10:03:33 +0000 (+0000) Subject: Updated class name X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=254a1981416d6ae00f8ff7ee708197276d718970;p=gosa.git Updated class name git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@18531 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-core/plugins/addons/propertyEditor/class_configViewer.inc b/gosa-core/plugins/addons/propertyEditor/class_configViewer.inc deleted file mode 100644 index 1af754774..000000000 --- a/gosa-core/plugins/addons/propertyEditor/class_configViewer.inc +++ /dev/null @@ -1,272 +0,0 @@ -config = $config; - $this->ui = $ui; - - // Build filter - if (session::global_is_set(get_class($this)."_filter")){ - $filter= session::global_get(get_class($this)."_filter"); - } else { - $filter = new filter(get_template_path("property-filter.xml", true)); - $filter->setObjectStorage($this->storagePoints); - } - $this->setFilter($filter); - - // Build headpage - $headpage = new listing(get_template_path("property-list.xml", true)); - $headpage->registerElementFilter("propertyName", "propertyEditor::propertyName"); - $headpage->registerElementFilter("propertyGroup", "propertyEditor::propertyGroup"); - $headpage->registerElementFilter("propertyClass", "propertyEditor::propertyClass"); - $headpage->registerElementFilter("propertyValue", "propertyEditor::propertyValue"); - $headpage->setFilter($filter); - parent::__construct($config, $ui, "property", $headpage); - - $this->registerAction("saveProperties","saveProperties"); - $this->registerAction("cancelProperties","cancelProperties"); - } - - - function execute() - { - // Walk trough all properties and check if there posts for us. - $all = $this->config->configRegistry->getAllProperties(); - foreach($all as $prop){ - $post = "{$prop->getClass()}:{$prop->getName()}"; - if(isset($_POST[$post]) && $prop->getStatus() != 'removed'){ - $prop->setValue(get_post($post)); - } - - // Open the command verify dialog - if(isset($_POST["testCommand_{$post}"])){ - $this->dialogObject = new commandVerifier($this->config,$prop); - } - } - if(isset($_POST['commandVerifier_save'])){ - $this->dialogObject->save(); - $this->closeDialogs(); - } - if(isset($_POST['commandVerifier_cancel'])){ - $this->closeDialogs(); - } - - - // Execute registered management event listeners. - $this->handleActions($this->detectPostActions()); - - // Handle properties that have to be migrated - if(isset($_POST['propertyMigrate_cancel']) && count($this->toBeMigrated)){ - unset($this->toBeMigrated[0]); - $this->toBeMigrated = array_values($this->toBeMigrated); - } - if(isset($_POST['propertyMigrate_save']) && count($this->toBeMigrated)){ - $first = $this->toBeMigrated[0]->getMigrationClass(); - $first->save_object(); - $msgs = $first->check(); - if(!count($msgs)){ - $this->toBeMigrated[0]->save(); - unset($this->toBeMigrated[0]); - $this->toBeMigrated = array_values($this->toBeMigrated); - - // Nothing to migrate and everything is fine, reload the list now. - if(!count($this->toBeMigrated)){ - $this->config->configRegistry->reload($force=TRUE); - } - } - } - if(count($this->toBeMigrated)){ - $first = $this->toBeMigrated[0]->getMigrationClass(); - $first->save_object(); - - // We've no problems with this property anymore. - while($first instanceOf propertyMigration && !$first->checkForIssues()){ - $this->toBeMigrated[0]->save(); - unset($this->toBeMigrated[0]); - $this->toBeMigrated = array_values($this->toBeMigrated); - if(count($this->toBeMigrated)){ - $first = $this->toBeMigrated[0]->getMigrationClass(); - }else{ - $first = NULL; - - // Nothing to migrate and everything is fine, reload the list now. - if(!count($this->toBeMigrated)){ - $this->config->configRegistry->reload($force=TRUE); - } - } - } - - if($first){ - $content = $first->execute(); - $smarty = get_smarty(); - $smarty->assign('content', $content); - $smarty->assign('leftSteps', count($this->toBeMigrated)); - return($smarty->fetch(get_template_path('migrate.tpl',TRUE))); - } - } - - return(management::execute()); - } - - function renderList() - { - // Walk trough all properties and check if we have modified something - $all = $this->config->configRegistry->getAllProperties(); - foreach($all as $prop){ - $modified = in_array($prop->getStatus(),array('modified','removed')); - if($modified) break; - } - - $smarty = get_smarty(); - $smarty->assign('is_modified', $modified); - return(management::renderList()); - } - - - function cancelProperties() - { - $this->config->configRegistry->reload($force=TRUE); - } - - function saveProperties() - { - // Check if we've misconfigured properties and skip saving in this case. - $all = $this->config->configRegistry->getAllProperties(); - $valid = TRUE; - foreach($all as $prop){ - $valid &= $prop->check(); - } - - // Now save the properties. - if($valid){ - $this->toBeMigrated = $this->config->configRegistry->saveChanges(); - - // Nothing to migrate and everything is fine, reload the list now. - if(!count($this->toBeMigrated)){ - $this->config->configRegistry->reload($force=TRUE); - } - } - } - - function detectPostActions() - { - $action = management::detectPostActions(); - if(isset($_POST['saveProperties'])) $action['action'] = 'saveProperties'; - if(isset($_POST['cancelProperties'])) $action['action'] = 'cancelProperties'; - return($action); - } - - protected function removeEntryRequested($action="",$target=array(),$all=array()) - { - foreach($target as $dn){ - list($class,$name) = preg_split("/:/", $dn); - if($this->config->configRegistry->propertyExists($class,$name)){ - $prop = $this->config->configRegistry->getProperty($class,$name); - $prop->restoreDefault(); - } - } - } - - static function propertyGroup($group, $description = array()) - { - return($group[0]); - } - static function propertyClass($class, $description = array()) - { - global $config; - if(isset($config->configRegistry->classToName[$class[0]])){ - $class = $config->configRegistry->classToName[$class[0]]; - }else{ - $class = $class[0]; - } - return($class); - } - static function propertyName($class,$cn, $description,$mandatory) - { - $id = "{$class[0]}_{$cn[0]}"; - - $title = _("No description"); - if(isset($description[0])) $title = htmlentities($description[0],ENT_COMPAT, 'UTF-8'); - $title = preg_replace("/\n/", "
", $title); - $tooltip = ""; - - $must = ($mandatory[0]) ? "*" : ""; - - return($tooltip."{$cn[0]}{$must}"); - } - static function propertyValue($class,$cn,$value,$type,$default,$defaults,$check,$mandatory) - { - $ssize = "208px"; - $isize = "200px"; - $name = "{$class[0]}:{$cn[0]}"; - $value = htmlentities($value[0],ENT_QUOTES ,'UTF-8'); - - // Add slashes to keep escaped values escaped after passing them to smarty. - $value = addslashes($value); - - switch($type[0]){ - case 'bool': - $res = ""; - case 'switch': - if(!empty($defaults[0])){ - $data = call_user_func(preg_split("/::/", $defaults[0]), $class[0],$cn[0],$value, $type[0]); - if(is_array($data)){ - $res = ""; - } - } - break; - case 'command': - $res = ""; - $res.= image('images/lists/edit.png', "testCommand_{$name}", _("Test the given command.")); - break; - case 'dn': - case 'rdn': - case 'uri': - case 'path': - case 'file': - case 'string': - case 'integer': - $res = ""; - break; - default: echo $type[0].$name." ";$res = ""; - } - - // Check if it is a required value. - if($mandatory[0] && empty($value)){ - $res.= ""; - } - - // Color row in red if the check methods returns false. - if(!empty($check[0]) && !empty($value)){ - $check = call_user_func(preg_split("/::/", $check[0]),$displayMessage=FALSE, $class[0], $cn[0], $value, $type[0]); - if(!$check){ - $res.= ""; - } - } - - return($res); - } -} -?> diff --git a/gosa-core/plugins/addons/propertyEditor/class_propertyEditor.inc b/gosa-core/plugins/addons/propertyEditor/class_propertyEditor.inc new file mode 100644 index 000000000..1af754774 --- /dev/null +++ b/gosa-core/plugins/addons/propertyEditor/class_propertyEditor.inc @@ -0,0 +1,272 @@ +config = $config; + $this->ui = $ui; + + // Build filter + if (session::global_is_set(get_class($this)."_filter")){ + $filter= session::global_get(get_class($this)."_filter"); + } else { + $filter = new filter(get_template_path("property-filter.xml", true)); + $filter->setObjectStorage($this->storagePoints); + } + $this->setFilter($filter); + + // Build headpage + $headpage = new listing(get_template_path("property-list.xml", true)); + $headpage->registerElementFilter("propertyName", "propertyEditor::propertyName"); + $headpage->registerElementFilter("propertyGroup", "propertyEditor::propertyGroup"); + $headpage->registerElementFilter("propertyClass", "propertyEditor::propertyClass"); + $headpage->registerElementFilter("propertyValue", "propertyEditor::propertyValue"); + $headpage->setFilter($filter); + parent::__construct($config, $ui, "property", $headpage); + + $this->registerAction("saveProperties","saveProperties"); + $this->registerAction("cancelProperties","cancelProperties"); + } + + + function execute() + { + // Walk trough all properties and check if there posts for us. + $all = $this->config->configRegistry->getAllProperties(); + foreach($all as $prop){ + $post = "{$prop->getClass()}:{$prop->getName()}"; + if(isset($_POST[$post]) && $prop->getStatus() != 'removed'){ + $prop->setValue(get_post($post)); + } + + // Open the command verify dialog + if(isset($_POST["testCommand_{$post}"])){ + $this->dialogObject = new commandVerifier($this->config,$prop); + } + } + if(isset($_POST['commandVerifier_save'])){ + $this->dialogObject->save(); + $this->closeDialogs(); + } + if(isset($_POST['commandVerifier_cancel'])){ + $this->closeDialogs(); + } + + + // Execute registered management event listeners. + $this->handleActions($this->detectPostActions()); + + // Handle properties that have to be migrated + if(isset($_POST['propertyMigrate_cancel']) && count($this->toBeMigrated)){ + unset($this->toBeMigrated[0]); + $this->toBeMigrated = array_values($this->toBeMigrated); + } + if(isset($_POST['propertyMigrate_save']) && count($this->toBeMigrated)){ + $first = $this->toBeMigrated[0]->getMigrationClass(); + $first->save_object(); + $msgs = $first->check(); + if(!count($msgs)){ + $this->toBeMigrated[0]->save(); + unset($this->toBeMigrated[0]); + $this->toBeMigrated = array_values($this->toBeMigrated); + + // Nothing to migrate and everything is fine, reload the list now. + if(!count($this->toBeMigrated)){ + $this->config->configRegistry->reload($force=TRUE); + } + } + } + if(count($this->toBeMigrated)){ + $first = $this->toBeMigrated[0]->getMigrationClass(); + $first->save_object(); + + // We've no problems with this property anymore. + while($first instanceOf propertyMigration && !$first->checkForIssues()){ + $this->toBeMigrated[0]->save(); + unset($this->toBeMigrated[0]); + $this->toBeMigrated = array_values($this->toBeMigrated); + if(count($this->toBeMigrated)){ + $first = $this->toBeMigrated[0]->getMigrationClass(); + }else{ + $first = NULL; + + // Nothing to migrate and everything is fine, reload the list now. + if(!count($this->toBeMigrated)){ + $this->config->configRegistry->reload($force=TRUE); + } + } + } + + if($first){ + $content = $first->execute(); + $smarty = get_smarty(); + $smarty->assign('content', $content); + $smarty->assign('leftSteps', count($this->toBeMigrated)); + return($smarty->fetch(get_template_path('migrate.tpl',TRUE))); + } + } + + return(management::execute()); + } + + function renderList() + { + // Walk trough all properties and check if we have modified something + $all = $this->config->configRegistry->getAllProperties(); + foreach($all as $prop){ + $modified = in_array($prop->getStatus(),array('modified','removed')); + if($modified) break; + } + + $smarty = get_smarty(); + $smarty->assign('is_modified', $modified); + return(management::renderList()); + } + + + function cancelProperties() + { + $this->config->configRegistry->reload($force=TRUE); + } + + function saveProperties() + { + // Check if we've misconfigured properties and skip saving in this case. + $all = $this->config->configRegistry->getAllProperties(); + $valid = TRUE; + foreach($all as $prop){ + $valid &= $prop->check(); + } + + // Now save the properties. + if($valid){ + $this->toBeMigrated = $this->config->configRegistry->saveChanges(); + + // Nothing to migrate and everything is fine, reload the list now. + if(!count($this->toBeMigrated)){ + $this->config->configRegistry->reload($force=TRUE); + } + } + } + + function detectPostActions() + { + $action = management::detectPostActions(); + if(isset($_POST['saveProperties'])) $action['action'] = 'saveProperties'; + if(isset($_POST['cancelProperties'])) $action['action'] = 'cancelProperties'; + return($action); + } + + protected function removeEntryRequested($action="",$target=array(),$all=array()) + { + foreach($target as $dn){ + list($class,$name) = preg_split("/:/", $dn); + if($this->config->configRegistry->propertyExists($class,$name)){ + $prop = $this->config->configRegistry->getProperty($class,$name); + $prop->restoreDefault(); + } + } + } + + static function propertyGroup($group, $description = array()) + { + return($group[0]); + } + static function propertyClass($class, $description = array()) + { + global $config; + if(isset($config->configRegistry->classToName[$class[0]])){ + $class = $config->configRegistry->classToName[$class[0]]; + }else{ + $class = $class[0]; + } + return($class); + } + static function propertyName($class,$cn, $description,$mandatory) + { + $id = "{$class[0]}_{$cn[0]}"; + + $title = _("No description"); + if(isset($description[0])) $title = htmlentities($description[0],ENT_COMPAT, 'UTF-8'); + $title = preg_replace("/\n/", "
", $title); + $tooltip = ""; + + $must = ($mandatory[0]) ? "*" : ""; + + return($tooltip."{$cn[0]}{$must}"); + } + static function propertyValue($class,$cn,$value,$type,$default,$defaults,$check,$mandatory) + { + $ssize = "208px"; + $isize = "200px"; + $name = "{$class[0]}:{$cn[0]}"; + $value = htmlentities($value[0],ENT_QUOTES ,'UTF-8'); + + // Add slashes to keep escaped values escaped after passing them to smarty. + $value = addslashes($value); + + switch($type[0]){ + case 'bool': + $res = ""; + case 'switch': + if(!empty($defaults[0])){ + $data = call_user_func(preg_split("/::/", $defaults[0]), $class[0],$cn[0],$value, $type[0]); + if(is_array($data)){ + $res = ""; + } + } + break; + case 'command': + $res = ""; + $res.= image('images/lists/edit.png', "testCommand_{$name}", _("Test the given command.")); + break; + case 'dn': + case 'rdn': + case 'uri': + case 'path': + case 'file': + case 'string': + case 'integer': + $res = ""; + break; + default: echo $type[0].$name." ";$res = ""; + } + + // Check if it is a required value. + if($mandatory[0] && empty($value)){ + $res.= ""; + } + + // Color row in red if the check methods returns false. + if(!empty($check[0]) && !empty($value)){ + $check = call_user_func(preg_split("/::/", $check[0]),$displayMessage=FALSE, $class[0], $cn[0], $value, $type[0]); + if(!$check){ + $res.= ""; + } + } + + return($res); + } +} +?>