summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e22b01f)
raw | patch | inline | side by side (parent: e22b01f)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 7 Dec 2005 13:03:20 +0000 (13:03 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 7 Dec 2005 13:03:20 +0000 (13:03 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2248 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/admin/groups/application.tpl | patch | blob | history | |
plugins/admin/groups/class_groupApplication.inc | patch | blob | history |
index 65abe270230553aa7375807dee6b017d3ee76373..e8703bf0441db5171f92d6b294327290a7252080 100644 (file)
<b><LABEL for="used_apps">{t}Used applications{/t}</LABEL></b>
{$UsedApps}
<input type="submit" value="{t}Seperator{/t}" name='AddSeperator'>
+ <input type="text" value="" name='CatName'>
+ <input type="submit" value="{t}Add categorie{/t}" name='AddCat'>
</td>
<td>
</td>
diff --git a/plugins/admin/groups/class_groupApplication.inc b/plugins/admin/groups/class_groupApplication.inc
index af56827a189ab05a8ab7c63f42605bd6963c71af..f6d17c4f9bbea34a64fc6918f306b9ae774c97b2 100644 (file)
var $gosaMemberApplication= array();
/* Helpers */
- var $department= "";
- var $apps= array();
- var $used_apps= array();
- var $opt_edit= FALSE;
- var $option_name= array();
- var $option_value= array();
- var $appoption= array();
- var $table= "";
- var $curbase = "";
- var $curCatDir;
- var $curCatDepth=0;
- var $Categories=array();
+ var $departments = ""; // All departments within $this->curbase;
+ var $apps = array(); // All available applications
+ var $used_apps = array(); // Specifies which applications are currently assigned
+ var $option_name = array();
+ var $option_value = array();
+ var $appoption = array();
+
+ var $table = "";
+ var $curbase = "";
+ var $curCatDir ;
+ var $curCatDepth =0; //
/* attribute list for save action */
var $attributes= array();
}
}
+ /* Parse MemberApplication*/
$tmp = array();
$tmp2 = array();
-
$prios = array();
-
$cats = array();
foreach($this->gosaMemberApplication as $memberApp){
if(preg_match("/\|/i",$memberApp)){
+
$tmp = split("\|",$memberApp);
- $tmp2[$tmp[1]][$tmp[2]] = array("App"=>$tmp[0],"Cat"=>$tmp[1]);
- $cats [$tmp[1]] = $tmp[1];
+
+ if(!empty($tmp[0])){
+ $tmp2[$tmp[1]][$tmp[2]] = array("App"=>$tmp[0]);
+ }
+ if(!empty($tmp[1])){
+ $cats [$tmp[1]] = $tmp[1];
+ }
$prios[$tmp[1]][$tmp[2]] = $tmp[2];
}else{
$tmp2[]['App'] = $memberApp;
- $tmp2[]['Cat'] = "";
}
}
+ $this->Categories = $cats;
+
$this->gosaMemberApplication = $tmp2;
+ $cats[""]="";
foreach($cats as $cat ){
$max = max($prios[$cat]);
$min = 1;//min($prios[$cat]);
for($i = $min ; $i < $max ; $i++){
if(!isset($prios[$cat][$i])){
if($last == false){
- $this->gosaMemberApplication[$cat][$i]['Cat'] = $cat;
$this->gosaMemberApplication[$cat][$i]['App'] = "__SEPARATOR__".$i;
$last = true;
}
}
$this->gosaMemberApplication = $tmp;
-
$this->curbase = $this->config->current['BASE'];
}
{
$cat = $this->curCatDir;
$cnt = count($this->gosaMemberApplication[$cat]);
- $tmp = array("Cat" => $cat , "App" => "__SEPARATOR__".($cnt+1));
+ $tmp = array("App" => "__SEPARATOR__".($cnt+1));
$this->gosaMemberApplication[$cat][] = $tmp;
}
if((isset($_GET['act']))&&($_GET['act']=="open")){
$this->curCatDir = $_GET['id'];
-
- $found = false;
- foreach($this->Categories as $key => $name ){
- if($this->curCatDir==$name){
- $tmp = array_flip(split("\/",$key));
-
- $this->curCatDepth = ($tmp[$this->curCatDir]);
- $found= true;
- }
- }
- if(!$found){
- $this->curCatDir = "";
- $this->curCatDepth = 0;
- }
}
/* Do we need to flip is_account state? */
}
}
+
+ /* Add Categorie */
+ if((isset($_POST['AddCat']))&&(isset($_POST['CatName']))&&(!empty($_POST['CatName']))){
+ if(empty($this->curCatDir)){
+ $this->Categories[$_POST['CatName']]=$_POST['CatName'];
+ }else{
+ $this->Categories[$this->curCatDir."/".$_POST['CatName']]=$_POST['CatName'];
+ }
+ }
+
+
$this->reload();
foreach($_POST as $name => $value){
if(preg_match("/DelApp_/",$name)){
$id = $_GET['id'];
$act = $_GET['act'];
$found = -1;
- foreach($this->gosaMemberApplication[$this->curCatDir] as $key => $member){
- if($id == $member['App']){
- $found = $key;
+ if(isset($this->gosaMemberApplication[$this->curCatDir])){
+ foreach($this->gosaMemberApplication[$this->curCatDir] as $key => $member){
+ if($id == $member['App']){
+ $found = $key;
+ }
}
}
$div2 = new DivSelectBox("appgroup");
$div2->SetHeight(300);
- $menu = $this->CreateCatMenu();
- $str_noprio = " %s ";
- $linkopen = "<img src='images/folder.png'> <a href='?plug=".$_GET['plug']."&act=open&id=%s'>%s</a>";
- $app = "<img src='images/select_application.png'> %s";
+ $linkopen = "<img src='images/folder.png'> <a href='?plug=".$_GET['plug']."&act=open&id=%s'>%s</a>";
+ $catremove = "<a href='?plug=".$_GET['plug']."&act=idelcat&id=%s'><input type='image' src='images/edittrash.png' ></a>";
+ $app = "<img src='images/select_application.png'> %s";
- /* append back entry */
- if($menu["__BACK__"] != false){
- $div2 ->AddEntry(array(
- array("string"=>sprintf($linkopen,$menu["__BACK__"],".. [ "._("back")." ]")),
- array("string"=>" ","attach"=>"style='border-right:0px;'")
- ));
+ if(empty($this->curCatDir)){
+ $cnt =0;
+ }else{
+ $cnt = count(split("/",$this->curCatDir));
+ $tmp = split("/",$this->curCatDir);
+ $bbk = "";
+ for($i = 0 ; $i < ($cnt -1 ) ; $i++){
+ $bbk .= $tmp[$i];
+ }
+ $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,$bbk,"..")),array("string"=>" ","attach"=>"style='border-right:0px;'")));
}
-
- foreach($menu['__CATEGORY__'] as $path => $name){
- $div2 ->AddEntry(array(array("string"=>sprintf($linkopen,$path,$name)),array("string"=>" ","attach"=>"style='border-right:0px;'")));
+
+ foreach($this->Categories as $path => $name){
+ $depth = count(split("/",$path));
+ if(($depth == ($cnt)+1)){
+
+ $div2 ->AddEntry(array(
+ array("string"=>sprintf($linkopen,$path,$name)),
+ array("string"=>sprintf($catremove,$path).
+ "<img src='images/empty.png' width='19px'>",
+ "attach"=>"align='right' style='width:80px;border-right:0px;'")));
+ }
}
/* Append entries */
" <a href='?plug=".$_GET['plug']."&act=one_down&id=%s'> <img src='images/sort_down.png' border=0></a>".
" <input type='image' src='images/edittrash.png' name='DelApp_%s' value='%s'>";
$edit= " <input type='image' src='images/edit.png' name='EdiApp_%s' value='%s'>";
-
- foreach($menu["__ENTRY__"] as $path => $entry){
- if(preg_match("/__SEPARATOR__/",$path)){
- $div2 ->AddEntry(array(array("string"=>$separator),
- array("string"=>preg_replace("/\%s/",$entry['name'],$upudown),"attach"=>"style='border-right:0px;'")));
-
- }else{
- $div2 ->AddEntry(array(array("string"=>sprintf($app,$entry['name'])),
- array("string"=>preg_replace("/\%s/",$entry['name'],$upudown.$edit),"attach"=>"style='border-right:0px;'")));
+ if(isset($this->gosaMemberApplication[$this->curCatDir])){
+ foreach($this->gosaMemberApplication[$this->curCatDir] as $cat => $entry){
+ if(preg_match("/__SEPARATOR__/",$entry['App'])){
+ $div2 ->AddEntry(array(array("string"=>$separator),
+ array("string"=>preg_replace("/\%s/",$entry['App'],$upudown."<img src='images/empty.png' width='19px'>"),"attach"=>"align='right' style='border-right:0px;'")));
+ }else{
+ $div2 ->AddEntry(array(array("string"=>sprintf($app,$entry['App'])),
+ array("string"=>preg_replace("/\%s/",$entry['App'],$upudown.$edit),"attach"=>"align='right' style='border-right:0px;'")));
+ }
}
}
-
+
$smarty->assign("UsedApps", $div2->DrawList());
$smarty->assign("List", $div->DrawList());
$smarty->assign("apps", $apps);
}
- /* Save data to object */
-# function save_object()
-# {
-# plugin::save_object();
-# }
-
-
/* Save to LDAP */
function save()
{
plugin::save();
/* Copy members */
-
- $cats = array(""=>0);
- foreach($this->gosaMemberApplication as $mem => $entries){
- $cats[$mem]= 0;
- }
-
+ $this->Categories[""]="";
$this->attrs["gosaMemberApplication"]= array();
- $lastSEP = false;
- foreach ($this->gosaMemberApplication as $cat){
- foreach($cat as $val){
- $cats[$val['Cat']] ++;
- if(!preg_match("/__SEPARATOR__/i",$val['App'])){
- $this->attrs["gosaMemberApplication"][]= $val['App']."|".$val['Cat']."|".$cats[$val['Cat']];
- $lastSEP = false;
- }else{
- if($lastSEP){
- $cats[$val['Cat']] --;
+ $cats = array();
+ foreach($this->Categories as $name => $cats){
+ $cats[$name] =0;
+ if(isset($this->gosaMemberApplication[$name])){
+ foreach($this->gosaMemberApplication[$name] as $entry){
+ if(!preg_match("/__SEPARATOR__/",$entry['App'])){
+ $this->attrs["gosaMemberApplication"][]= $entry['App']."|".$name."|".$cats[$name];
}
- $lastSEP = true;
+ $cats[$name] = $cats[$name] + 1;
}
}
+ if(($cats[$name]==0)&&(!empty($name))){
+ $this->attrs["gosaMemberApplication"][]= "|".$name."|".$cats[$name];
+ }
}
/* Are there application parameters to be saved */
}
- function CreateCatMenu()
- {
- /* The current category */
- $na = $this->curCatDir;
-
- /* the current folder depth */
- $nd = $this->curCatDepth;
-
- /* init array */
- $return = array();
-
- $return["__CATEGORY__"] = array(); // Categories
- $return["__ENTRY__"] = array(); // Entries in this category
- $return["__BACK__"] = false; // The back entry
-
- $tmp = new xmlParse();
-
- $this->Categories= array();
- if(!isset($this->config->data['MAIN']['KDE_APPLICATIONS_MENU'])) {
- print_red(_("There is no value for 'KDE_APPLICATIONS_MENU' specified in your gosa.conf."));
- }else{
- $path = $this->config->data['MAIN']['KDE_APPLICATIONS_MENU'];
- if(file_exists($path)){
- if(is_readable($path)){
- $tmp->parseMenu($path);
- $this->Categories = $tmp->GetData();
- }else{
- print_red(sprintf(_("The specified file '%s' for 'KDE_APPLICATIONS_MENU' in your gosa.conf is not accessable."),$path));
- }
- }else{
- print_red(sprintf(_("The specified file '%s' for 'KDE_APPLICATIONS_MENU' in your gosa.conf is not accessable."),$path));
- }
- }
-
-
- /* Create new categories to return */
- foreach($this->Categories as $key => $val){
-
- /* Split categories by | to get name and priority */
- $nk = split("\/",$key);
-
- /* Check if this category must be shown */
- if((isset($nk[$nd]))&&(is_array($nk))&&($nk[$nd] == $na)){
-
- /* Add this to the list, if theres is a sub category */
- if(isset($nk[($nd+1)])){
- $return["__CATEGORY__"][$nk[($nd+1)]] = $nk[($nd+1)];
- }
-
- /* Create back entry */
- if($nd !=0 ){
- $return['__BACK__'] = $nk[($nd-1)];
- }else{
- $return['__BACK__'] = "..";
- }
-
- }elseif($na==""){
- $return["__CATEGORY__"][$nk[0]] = $nk[0];
- }
-
-
-
- }
-
- /* If back entry isn't set, set it to false (none) or to ..(base)*/
- if($return["__BACK__"] == false){
- $return['__BACK__'] = "..";
- if($nd == 0 ){
- $return['__BACK__'] = false;
- }
- }
- if((isset($this->gosaMemberApplication[$this->curCatDir]))&&(is_array($this->gosaMemberApplication[$this->curCatDir]))){
- foreach($this->gosaMemberApplication[$this->curCatDir] as $app){
- if($app['Cat'] == $this->curCatDir){
- $return["__ENTRY__"][$app['App']] = array("name"=>$app['App']) ;
- }
- }
- }
- /* Return this all ..*/
- return($return);
- }
-
function addApp($cn)
{
-
if((isset($this->gosaMemberApplication[$this->curCatDir]))&&(is_array($this->gosaMemberApplication[$this->curCatDir]))){
foreach($this->gosaMemberApplication[$this->curCatDir] as $entry){
if($entry['App'] == $cn) return;
}
}
- $this->gosaMemberApplication[$this->curCatDir][]= array("App"=>$cn,"Cat"=>$this->curCatDir);
+ $this->gosaMemberApplication[$this->curCatDir][]= array("App"=>$cn);
$this->used_apps[$cn]=$cn;
$this->is_modified= TRUE;
}
+
function removeApp($cn)
{
$temp= array();