summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1c78453)
raw | patch | inline | side by side (parent: 1c78453)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 15 Jan 2008 16:28:27 +0000 (16:28 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 15 Jan 2008 16:28:27 +0000 (16:28 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/branches/2.5@8370 594d385d-05f5-0310-b6e9-bd551577e9d8
23 files changed:
index e84ddec657b4b875b855927b819211f7f6177b14..d6678993073e7b0def6c7f63f478a5669ae80b68 100644 (file)
--- a/include/class_plugin.inc
+++ b/include/class_plugin.inc
}
}
+ /* Handle tagging */
+ $this->tag_attrs(&$this->attrs);
}
}
+ function tag_attrs($at, $dn= "", $tag= "", $show= false)
+ {
+ /* No dn? Self-operation... */
+ if ($dn == ""){
+ $dn= $this->dn;
+
+ /* No tag? Find it yourself... */
+ if ($tag == ""){
+ $len= strlen($dn);
+
+ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "No tag for $dn - looking for one...", "Tagging");
+ $relevant= array();
+ foreach ($this->config->adepartments as $key => $ntag){
+
+ /* This one is bigger than our dn, its not relevant... */
+ if ($len <= strlen($key)){
+ continue;
+ }
+
+ /* This one matches with the latter part. Break and don't fix this entry */
+ if (preg_match('/(^|,)'.normalizePreg($key).'$/', $dn)){
+ @DEBUG (DEBUG_TRACE, __LINE__, __FUNCTION__, __FILE__, "DEBUG: Possibly relevant: $key", "Tagging");
+ $relevant[strlen($key)]= $ntag;
+ continue;
+ }
+
+ }
+
+ /* If we've some relevant tags to set, just get the longest one */
+ if (count($relevant)){
+ ksort($relevant);
+ $tmp= array_keys($relevant);
+ $idx= end($tmp);
+ $tag= $relevant[$idx];
+ $this->gosaUnitTag= $tag;
+ }
+ }
+ }
+
+ /* Remove tags that may already be here... */
+ remove_objectClass("gosaAdministrativeUnitTag", &$at);
+ if (isset($at['gosaUnitTag'])){
+ unset($at['gosaUnitTag']);
+ }
+
+ /* Set tag? */
+ if ($tag != ""){
+ add_objectClass("gosaAdministrativeUnitTag", &$at);
+ $at['gosaUnitTag']= $tag;
+ }
+
+ return ($at);
+ }
+
+
function handle_object_tagging($dn= "", $tag= "", $show= false)
{
//FIXME: How to optimize this? We have at least two
diff --git a/include/functions.inc b/include/functions.inc
index e83805413ea93da35bb4f1171bef0653a685d113..70ab363acedfc872f34830b1a1dd11b2ae7d51fc 100644 (file)
--- a/include/functions.inc
+++ b/include/functions.inc
}
+/* Add a given objectClass to an attrs entry */
+function add_objectClass($classes, &$attrs)
+{
+ if (is_array($classes)){
+ $list= $classes;
+ } else {
+ $list= array($classes);
+ }
+
+ foreach ($list as $class){
+ $attrs['objectClass'][]= $class;
+ }
+}
+
+
+/* Removes a given objectClass from the attrs entry */
+function remove_objectClass($classes, &$attrs)
+{
+ if (isset($attrs['objectClass'])){
+ /* Array? */
+ if (is_array($classes)){
+ $list= $classes;
+ } else {
+ $list= array($classes);
+ }
+
+ $tmp= array();
+ foreach ($attrs['objectClass'] as $oc) {
+ foreach ($list as $class){
+ if ($oc != $class){
+ $tmp[]= $oc;
+ }
+ }
+ }
+ $attrs['objectClass']= $tmp;
+ }
+}
+
+
/* Returns contents of the given POST variable and check magic quotes settings */
function get_post($name)
{
diff --git a/plugins/admin/applications/tabs_application.inc b/plugins/admin/applications/tabs_application.inc
index 859218e040e4fae135af767942d4b9b5312597da..b8863a7a4670de33bb84fc084bb1bcec79b11506 100644 (file)
}
tabs::save();
-
- /* Fix tagging if needed */
- $baseobject->dn= $this->dn;
- $baseobject->handle_object_tagging();
}
}
diff --git a/plugins/admin/departments/class_departmentGeneric.inc b/plugins/admin/departments/class_departmentGeneric.inc
index 9aecbccdff2cb3d39578dc59596a449b74e37625..18f8db4abe4574ff700d5cf047b0269e92f22e02 100644 (file)
$tmp= array();
/* Remove gosaAdministrativeUnit from this plugin */
- $has_unit_tag= false;
+ $has_unit_tag= false;
foreach($this->attrs['objectClass'] as $oc){
if (!preg_match("/^gosaAdministrativeUnit$/i", $oc)){
$tmp[]= $oc;
This will be done later */
$this->tag_objects(true);
- /* Fix tagging if needed */
- if (!$this->is_administrational_unit){
- $this->handle_object_tagging();
- }
-
/* Optionally execute a command after we're done */
$this->postcreate();
return(true);
$this->must_be_tagged =true;
return;
}
- $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
+ $this->handle_object_tagging($attrs['dn'], $this->gosaUnitTag, TRUE );
echo "<script language=\"javascript\" type=\"text/javascript\">scrollDown2();</script>" ;
}
}
index 0ad7dba9e40936965dea554b0fca6810835db848..c00c14dc3f78321aeffe666442f9c8c58dcac89c 100644 (file)
}
show_ldap_error($ldap->get_error(), _("Saving FAI hook base failed"));
- /* Do object tagging */
- $this->handle_object_tagging();
-
$ldap->cd($this->dn);
/* Prepare FAIscriptEntry to write it to ldap
}
}
+ /* Tag object */
+ $this->tag_attrs(&$tmp, $sub_dn, $this->gosaUnitTag);
+
if($obj['status'] == "delete"){
$ldap->cd($sub_dn);
$ldap->rmdir_recursive($sub_dn);
$this->handle_post_events("add");
show_ldap_error($ldap->get_error(), _("Saving FAI hook failed"));
}
- $this->handle_object_tagging($sub_dn, $this->gosaUnitTag);
}
}
index 32a26f91bb1bca327d91c72be94b119ca651a50d..18a7aeae70c5a2a9b719dc7fa4dd1ef7fe46f9f0 100644 (file)
}
show_ldap_error($ldap->get_error(), _("Saving FAI package base failed"));
- /* Do object tagging */
- $this->handle_object_tagging();
$ldap->cd($this->dn);
/* Save Package configurations */
/* cehck if object already exists */
$ldap->cat($pkgdn,array("objectClass"));
- /* Workaround for missing "gosaAdministrativeUnitTag" */
- $attrs = $ldap->fetch();
- if((isset($attrs['objectClass'])) && (in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass']))){
- $pkgattrs['objectClass'][] = "gosaAdministrativeUnitTag";
- }
+ /* Tag object */
+ $this->tag_attrs(&$pkgattrs, $sub_dn, $this->gosaUnitTag);
if(in_array($pkgattrs['FAIvariableType'],array("boolean","multiselect","password","select","string","text"))){
if($ldap->count()!=0){
show_ldap_error($ldap->get_error(), _("Saving FAI package entry failed"));
}
- /* Handle tagging */
- $this->handle_object_tagging($pkgdn, $this->gosaUnitTag);
}
}
}
diff --git a/plugins/admin/fai/class_faiPartitionTable.inc b/plugins/admin/fai/class_faiPartitionTable.inc
index c85cf9ab33e11f49997054cfe9e286efffb82a78..a627dfd6f7801211b641731d3ac97bcfcac3645e 100644 (file)
}
show_ldap_error($ldap->get_error(), _("Saving FAI partition table base failed"));
- /* Do object tagging */
- $this->handle_object_tagging();
-
/* Sort entries, because we must delete entries with status="delete" first */
$order = array();
foreach($this->disks as $key => $disk){
}
}
- /* Fix problem with missing objectClass "gosaAdministrativeUnitTag" for disks */
- $ldap->cat($disk_dn,array("objectClass"));
- $attrs = $ldap->fetch();
- if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
- $disk_attrs['objectClass'][] = "gosaAdministrativeUnitTag";
- }
-
+ /* Do object tagging */
+ $this->tag_attrs(&$disk_attrs, $disk_dn, $this->gosaUnitTag);
+
if($disk['status'] == "delete"){
$ldap->cd($disk_dn);
$ldap->rmdir_recursive($disk_dn);
print_red("unknown status while saving disks");
}
- $this->handle_object_tagging($disk_dn, $this->gosaUnitTag);
-
/* Collect all opperations. Delete first than add new entries .*/
$Todo['delete'] = array();
$Todo['rest'] = array();
$ldap->cat($partition_dn);
if($ldap->count()){
- /* Fix problem with missing objectClass "gosaAdministrativeUnitTag" for partitions */
- $attrs = $ldap->fetch();
- if(isset($attrs['objectClass']) && in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
- $partition_attrs['objectClass'][] = "gosaAdministrativeUnitTag";
- }
+ /* Tag object */
+ $this->tag_attrs(&$partition_attrs, $partition_dn, $this->gosaUnitTag);
+
if(empty($partition_attrs['description'])){
$partition_attrs['description']=array();
}
$ldap->add($partition_attrs);
show_ldap_error($ldap->get_error(), _("Saving FAI partition table entry failed"));
}
- $this->handle_object_tagging($partition_dn, $this->gosaUnitTag);
}
}
$this->handle_post_events("add");
index 84e5b40b1174dc503303d66235f18985c104ea0c..8f70c88a32bdb122f74ae59bcf1ce219cc59c64a 100644 (file)
$ldap->add($this->attrs);
}
show_ldap_error($ldap->get_error(), _("Saving FAI profile failed"));
-
- /* Do object tagging */
- $this->handle_object_tagging();
- show_ldap_error($ldap->get_error());
}
index ac945d890fedffa402ae1542b5017aa9546b303a..c4a84f3814ca6dbf3a7252a076fd443db17c0ebc 100644 (file)
}
show_ldap_error($ldap->get_error(), _("Creating FAI script base failed"));
- /* Do object tagging */
- $this->handle_object_tagging();
-
/* Prepare FAIscriptEntry to write it to ldap
* First sort array.
* Because we must delete old entries first.
$tmp['FAIpriority'] ="0";
}
- /* Check if gosaAdministrativeUnitTag is required as object class */
- if($obj['status'] == "edited"){
- $ldap->cat($sub_dn,array("objectClass"));
- $attrs = $ldap->fetch();
- if(isset($attrs['objectClass'])){
- if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
- $tmp['objectClass'][] = "gosaAdministrativeUnitTag";
- }
- }
- }
+ /* Tag object */
+ $this->tag_attrs(&$tmp, $sub_dn, $this->gosaUnitTag);
if($obj['status'] == "delete"){
$ldap->cd($sub_dn);
$this->handle_post_events("add");
show_ldap_error($ldap->get_error(), _("Saving FAI script failed"));
}
-
- $this->handle_object_tagging($sub_dn, $this->gosaUnitTag);
}
}
index bb552443cfa8a9690ec4711ccc25f151abc6d5e8..6a27eeca4cad45a8d2c07b504bbb006a39a86319 100644 (file)
}
show_ldap_error($ldap->get_error(), _("Saving FAI template base failed"));
- /* Do object tagging */
- $this->handle_object_tagging();
-
/* Prepare FAIscriptEntry to write it to ldap
* First sort array.
* Because we must delete old entries first.
}
}
- /* Check if gosaAdministrativeUnitTag is required as object class */
- if($obj['status'] == "edited"){
- $ldap->cat($sub_dn,array("objectClass"));
- $attrs = $ldap->fetch();
- if(isset($attrs['objectClass'])){
- if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
- $tmp['objectClass'][] = "gosaAdministrativeUnitTag";
- }
- }
- }
+ /* Tag object */
+ $this->tag_attrs(&$tmp, $sub_dn, $this->gosaUnitTag);
if($obj['status'] == "delete"){
$ldap->cd($sub_dn);
$this->handle_post_events("add");
show_ldap_error($ldap->get_error(), _("Creating FAI template entry failed"));
}
-
- $this->handle_object_tagging($sub_dn, $this->gosaUnitTag);
}
}
index 171ad312d99130b3a8d5beb0ca07efbd7d3adb0f..a2f36897f70a8c86d8294dde28eaff48e181720f 100644 (file)
}
show_ldap_error($ldap->get_error(), _("Saving FAI variable base failed"));
- /* Do object tagging */
- $this->handle_object_tagging();
-
/* Prepare FAIscriptEntry to write it to ldap
* First sort array.
* Because we must delete old entries first.
}
}
- /* Check if gosaAdministrativeUnitTag is required as object class */
- if($obj['status'] == "edited"){
- $ldap->cat($sub_dn,array("objectClass"));
- $attrs = $ldap->fetch();
- if(isset($attrs['objectClass'])){
- if(in_array_ics("gosaAdministrativeUnitTag",$attrs['objectClass'])){
- $tmp['objectClass'][] = "gosaAdministrativeUnitTag";
- }
- }
- }
+ /* Tag object */
+ $this->tag_attrs(&$tmp, $sub_dn, $this->gosaUnitTag);
if($obj['status'] == "delete"){
$ldap->cd($sub_dn);
$this->handle_post_events("add");
show_ldap_error($ldap->get_error(), _("Saving FAI variable failed"));
}
-
- $this->handle_object_tagging($sub_dn, $this->gosaUnitTag);
}
}
index 7adb0c3054f4f53d346c036916692f15285147aa..c83e876289655469a863c0f274ef3761ab6c4f5e 100644 (file)
$ret= tabs::save();
- /* Fix tagging if needed */
- $baseobject->dn= $new_dn;
- $baseobject->handle_object_tagging();
-
return $ret;
}
diff --git a/plugins/admin/mimetypes/tabs_mimetypes.inc b/plugins/admin/mimetypes/tabs_mimetypes.inc
index eb4368ce91e363c3a33d5a727bce145b1b4f04f3..cab01e1471a723335e24086a6866e6afe9863b62 100644 (file)
}
tabs::save();
-
- /* Fix tagging if needed */
- $baseobject->dn= $this->dn;
- $baseobject->handle_object_tagging();
- $this->by_object['mimetype'] = $baseobject;
}
}
index 33c6ae98c84134d771e0268d5a0f01541cf74388..496e84c44dd295756ea23b6d59d77fa0823f0500 100644 (file)
}
if ($this->dn == "new"){
- $this->dn= 'cn='.$baseobject->cn.','.get_groups_ou().$baseobject->base;
+ $this->dn= $new_dn;
}
tabs::save();
-
- /* Fix tagging if needed */
- $baseobject->dn= $new_dn;
- $baseobject->handle_object_tagging();
}
function saveCopyDialog()
diff --git a/plugins/admin/systems/class_printGeneric.inc b/plugins/admin/systems/class_printGeneric.inc
index d2f3b6beaf826d3b6f86b6043a7c1542441894fe..9fd41e31bb712854e879d0a4b897ffbea55a2d55 100644 (file)
$this->netConfigDNS->dn = $this->dn;
$this->netConfigDNS->save($this->dn);
}
-
- /* This is a multi object. Handle tagging here... */
- $this->handle_object_tagging();
}
function generateList(){
index 60facee5a7c6ea884f29804a158571db2f7f4958..55cb008cff3983a71eea11e953179ae1d3a78ce5 100644 (file)
}
tabs::save(TRUE);
-
- /* Fix tagging if needed */
- $baseobject->handle_object_tagging();
}
}
index cae0a24934acfdad42b01080229207c6c1b2c2cf..7328c86d10f52e4ab28f5962307fd3555cc77de5 100644 (file)
}
tabs::save(TRUE);
-
- /* Fix tagging if needed */
- $baseobject->handle_object_tagging();
}
}
index 0fbbccc222005f837dc571db50c45f4bc3d6652d..fd255199ce48fb07e1e4c9ad4359f03f38d4fc50 100644 (file)
}
tabs::save(FALSE);
-
- /* Fix tagging if needed */
- $baseobject->handle_object_tagging();
}
}
index 037aa850199ef91f1d45d9ecfe5ce965bc37968a..68a0f7b217132d1ec1558b1faf040f5adc408026 100644 (file)
$config= $_SESSION['config'];
$config->load_servers();
$_SESSION['config']= $config;
-
- /* Fix tagging if needed */
- $baseobject->handle_object_tagging();
}
}
index cac248e2ec5f80e7b5a332908440beddba8d9573..0395906ad791a3d7232f43170fd673e03a9ee2e8 100644 (file)
}
}
- /* Fix tagging if needed */
- $baseobject->handle_object_tagging();
}
}
index 3f03437fa837401b896944d1e758ae91e0e2d0fb..b04f89f98cb1b1c018f18729cfc2a15eb9927ee9 100644 (file)
}
tabs::save(TRUE);
-
- /* Fix tagging if needed */
- $baseobject->handle_object_tagging();
}
}
diff --git a/plugins/admin/systems/tabs_workstation.inc b/plugins/admin/systems/tabs_workstation.inc
index 8716247cde1e19950bd508f84a8c1801a5e176de..80c789ee8a48abcb43ff5fa10dad3603fcd3240c 100644 (file)
$this->by_object['printgeneric']->remove_from_parent();
}
}
-
- /* Fix tagging if needed */
- $baseobject->handle_object_tagging();
}
}
index 41093363189083a9f33aed3143af20413af5aceb..79cda297bab86e1adf83cd5811d8e529da3435e7 100644 (file)
$this->handle_post_events("modify",array("uid" => $this->uid));
}
- /* Fix tagging if needed */
- $this->handle_object_tagging();
-
return (0);
}