Code

Added remove multiple to conferences
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 19 Apr 2007 07:55:28 +0000 (07:55 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Thu, 19 Apr 2007 07:55:28 +0000 (07:55 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@6112 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/gofon/conference/class_divListConferences.inc
plugins/gofon/conference/class_phoneConferenceManagment.inc
plugins/gofon/conference/remove.tpl
plugins/gofon/macro/class_gofonMacroManagement.inc

index 15f66f1db5e1818f69e9e8661b35d14f94c7454e..180cf03fd1403362768b0cb789a640260b746542 100755 (executable)
@@ -42,12 +42,17 @@ class divListConference extends MultiSelectWindow
     $this->EnableSaveButton (false);
 
     /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 50;
+    $action_col_size = 60;
     if($this->parent->snapshotEnabled()){
       $action_col_size += 20;
     }
 
+    /* Toggle all selected / deselected */
+    $chk = "<input type='checkbox' id='select_all' name='select_all'
+      onClick='toggle_all_(\"^item_selected_[0-9]*$\",\"select_all\");' >";
+
     /* set Page header */
+    $this->AddHeader(array("string"=> $chk,          "attach"=>"style='width:20px;'"));
     $this->AddHeader(array("string" => "&nbsp;", "attach" => "style='text-align:center;width:20px;'"));
     $this->AddHeader(array("string" =>_("Name - Number"), "attach" => "style=''"));
     $this->AddHeader(array("string" => _("Owner"), "attach" => "style='width:200px;'"));
@@ -113,8 +118,13 @@ class divListConference extends MultiSelectWindow
     /* Add the rest (base select ....)*/
     $listhead .= _("Base")."&nbsp;<select name='CurrentMainBase' onChange='mainform.submit()' class='center'>$options</select>".
       " <input class='center' type='image' src='images/list_submit.png' align='middle' 
-      title='"._("Submit department")."' name='submit_department' alt='".  _("Submit").     "'>&nbsp;".
-      "</div>";
+      title='"._("Submit department")."' name='submit_department' alt='".  _("Submit").     "'>&nbsp;";
+
+    /* Multiple options */
+    $listhead .= "&nbsp;<input class='center' type='image' align='middle' src='images/edittrash.png'
+      title='"._("Remove selected conferences")."' alt='"._("Remove conferences")."' name='remove_multiple_conferences'>&nbsp;";
+
+    $listhead .="</div>";
 
     $this->SetListHeader($listhead);
   }
@@ -133,7 +143,7 @@ class divListConference extends MultiSelectWindow
     $editlink = "<a href='?plug=".$_GET['plug']."&amp;id=%s&amp;act=edit_entry'>%s</a>";
 
     /* Dynamic action col, depending on snapshot icons */
-    $action_col_size = 50;
+    $action_col_size = 60;
     if($this->parent->snapshotEnabled()){
       $action_col_size += 20;
     }
@@ -195,6 +205,9 @@ class divListConference extends MultiSelectWindow
       /* Create title */
       $title = " title='".preg_replace("/ /","&nbsp;",@LDAP::fix($data['dn']))."' ";
 
+      /* Create each field */
+      $field0 = array("string" => "<input type='checkbox' id='item_selected_".$conferencekey."' name='item_selected_".$conferencekey."'>" ,
+          "attach" => "style='width:20px;'");
       $a_field1 = array("string"=>sprintf($userimg,_("Conference")), "attach" => $title." style='text-align:center;width:20px;'");
       $a_field2 = array("string"=>sprintf($editlink,$conferencekey,$conference['cn'][0].$number), "attach" => $title." style=''");
       $a_field3 = array("string"=> $cn , "attach" =>  $title." style='width:200px;'");
@@ -202,7 +215,7 @@ class divListConference extends MultiSelectWindow
       $a_field5 = array("string"=> preg_replace("/%KEY%/",$conferencekey,$actions), 
                         "attach"=> $title."style='width:".$action_col_size."px;border-right:0px;text-align:right;'");
 
-      $this->AddElement(array($a_field1,$a_field2,$a_field3,$a_field4,$a_field5));
+      $this->AddElement(array($field0,$a_field1,$a_field2,$a_field3,$a_field4,$a_field5));
     }
   }
 
index 463c449d353bab87f3c45daeeac486ef2389dd69..039399748ee5260a8387d703d7f814e3883c6875 100644 (file)
@@ -55,7 +55,7 @@ class phoneConferenceManagment extends plugin
     /* Call parent execute */
     plugin::execute();
 
-    $_SESSION['LOCK_VARS_TO_USE'] = array("/^id$/","/^act$/","/^conference_/");
+    $_SESSION['LOCK_VARS_TO_USE'] = array("/^id$/","/^act$/","/^conference_/","/^item_selected/","/^remove_multiple_conferences/");
 
     /***************
       Variable initialisation
@@ -85,6 +85,8 @@ class phoneConferenceManagment extends plugin
         $s_action="edit";
         $s_entry  = preg_replace("/conference_edit_/i","",$key);
         $s_entry  = preg_replace("/_.*$/","",$s_entry);
+      }elseif(preg_match("/^remove_multiple_conferences/",$key)){
+        $s_action="del_multiple";
       } 
     }
 
@@ -112,6 +114,76 @@ class phoneConferenceManagment extends plugin
     }
 
 
+
+    /********************
+      Delete MULTIPLE entries requested, display confirm dialog
+     ********************/
+
+    if ($s_action=="del_multiple"){
+      $ids = $this->list_get_selected_items();
+
+      if(count($ids)){
+
+        foreach($ids as $id){
+          $dn = $this->conferences[$id]['dn'];
+          if (($user= get_lock($dn)) != ""){
+            return(gen_locked_message ($user, $dn));
+          }
+          $this->dns[$id] = $dn;
+        }
+
+        $dns_names = "<br><pre>";
+        foreach($this->dns as $dn){
+          add_lock ($dn, $this->ui->dn);
+          $dns_names .= $dn."\n";
+        }
+        $dns_names .="</pre>";
+
+        /* Lock the current entry, so nobody will edit it during deletion */
+        $smarty->assign("info",     sprintf(_("You're about to delete the following user(s) %s"), @LDAP::fix($dns_names)));
+        $smarty->assign("multiple", true);
+        return($smarty->fetch(get_template_path('remove.tpl', TRUE)));
+      }
+    }
+
+
+    /********************
+      Delete MULTIPLE entries confirmed
+     ********************/
+
+    /* Confirmation for deletion has been passed. Users should be deleted. */
+    if (isset($_POST['delete_multiple_conference_confirm'])){
+
+      /* Remove user by user and check acls before removeing them */
+      foreach($this->dns as $key => $dn){
+        $this->dn = $dn;
+        $acl = $this->ui->get_permissions($this->dn,"gofonconference/conference");
+        if(preg_match("/d/",$acl)){
+          $this->remove_from_parent();
+          gosa_log ("Department object'".$this->dn."' has been removed");
+        } else {
+          print_red (_("You have no permission to remove this department."));
+        }
+        /* Remove lock file after successfull deletion */
+        del_lock ($dn);
+        unset($this->dns[$key]);
+      }
+    }
+
+
+    /********************
+      Delete MULTIPLE entries Canceled
+     ********************/
+
+    /* Remove lock */
+    if(isset($_POST['delete_multiple_conference_cancel'])){
+      foreach($this->dns as $key => $dn){
+        del_lock ($dn);
+        unset($this->dns[$key]);
+      }
+    }
+
+
     /***************
       Delete 
      ***************/
@@ -132,6 +204,7 @@ class phoneConferenceManagment extends plugin
         } else {
           add_lock ($this->dn, $this->ui->dn);
           $smarty->assign("info", sprintf(_("You're about to delete the whole LDAP subtree placed under '%s'."), $this->dn));
+          $smarty->assign("multiple", false);
           $display.= $smarty->fetch (get_template_path('remove.tpl', TRUE));
           return ($display);
         }
@@ -277,7 +350,7 @@ class phoneConferenceManagment extends plugin
 
     /* Add departments if subsearch is disabled */
     if(!$this->DivListConference->SubSearch){
-      $this->DivListConference->AddDepartments($this->DivListConference->selectedBase,5);
+      $this->DivListConference->AddDepartments($this->DivListConference->selectedBase,5,1);
     }
     $this->reload();
     $this->DivListConference->setEntries($this->conferences);
@@ -350,6 +423,20 @@ class phoneConferenceManagment extends plugin
     }
   }
 
+
+  function list_get_selected_items()
+  {
+    $ids = array();
+    foreach($_POST as $name => $value){
+      if(preg_match("/^item_selected_[0-9]*$/",$name)){
+        $id   = preg_replace("/^item_selected_/","",$name);
+        $ids[$id] = $id;
+      }
+    }
+    return($ids);
+  }
+
+
 }
 // vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
 ?>
index 33fdbbc2f396354da358d3919b5c0f44e6fbb7e3..970abd4beac28e17b99cb4c1ee15d377d0d76e7b 100644 (file)
@@ -1,8 +1,8 @@
 <div style="font-size:18px;">
  <img alt="" src="images/button_cancel.png" align=top>&nbsp;{t}Warning{/t}
 </div>
-<p>
  {$info}
+<p>
  {t}This includes 'all' accounts, systems, etc. in this subtree. Please double check if your really want to do this since there is no way for GOsa to get your data back.{/t}
 </p>
 
 </p>
 
 <p class="plugbottom">
-  <input type=submit name="delete_department_confirm" value="{t}Delete{/t}">
-  &nbsp;
-  <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+{if $multiple}
+       <input type=submit name="delete_multiple_conference_confirm" value="{t}Delete{/t}">
+       &nbsp;
+       <input type=submit name="delete_multiple_conference_cancel" value="{t}Cancel{/t}">
+{else}
+       <input type=submit name="delete_department_confirm" value="{t}Delete{/t}">
+       &nbsp;
+       <input type=submit name="delete_cancel" value="{t}Cancel{/t}">
+{/if}
 </p>
 
index 8f670bb89564fc6b88100de70202b5b59987457d..8069d41cd57bba65ae97a8394bf765dab3e4e81c 100755 (executable)
@@ -285,6 +285,7 @@ class gofonMacro extends plugin
         add_lock ($this->dn, $this->ui->dn);
         $smarty= get_smarty();
         $smarty->assign("intro", sprintf(_("You're about to delete the macro '%s'."), $this->dn));
+        $smarty->assign("multiple", false);
         return($smarty->fetch (get_template_path('remove.tpl', TRUE)));
       } else {