Code

Updated user management.
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Oct 2009 09:13:47 +0000 (09:13 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Tue, 27 Oct 2009 09:13:47 +0000 (09:13 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@14644 594d385d-05f5-0310-b6e9-bd551577e9d8

gosa-core/include/class_management.inc
gosa-core/plugins/admin/users/class_userManagement.inc
gosa-core/plugins/admin/users/user-list.xml

index 617b0226051b9220f54b12280d706f6e1687108a..f4375e8b6712d6374e026d6be57a797b66d3c49c 100644 (file)
@@ -83,6 +83,16 @@ class management
     $str = $this->handleActions($this->detectPostActions());
     if($str) return($this->getHeader().$str);
 
+    // Open single dialog objects
+    if(is_object($this->dialogObject)){
+      if(method_exists($this->dialogObject,'save_object')) $this->dialogObject->save_object(); 
+      if(method_exists($this->dialogObject,'execute')){
+        $display = $this->dialogObject->execute(); 
+        $display.= $this->_getTabFooter();
+        return($this->getHeader().$display);
+      } 
+    }
+
     // Display tab object.
     if($this->tabObject instanceOf tabs || $this->tabObject instanceOf multi_plug){
       $this->tabObject->save_object();
@@ -341,6 +351,7 @@ class management
     $this->dn = "";
     $this->dns = array();
     $this->tabObject = null;
+    $this->dialogObject = null;
     set_object_info();
   }
 
index 8082f9f4fbc6463a16cc45a5c4f0026e4237a886..0fc4d93f01093cb787647e5869e86c028df066f6 100644 (file)
@@ -53,8 +53,14 @@ class userManagement extends management
     $headpage->registerElementFilter("lockLabel", "userManagement::filterLockLabel");
     $headpage->registerElementFilter("lockImage", "userManagement::filterLockImage");
     $headpage->setFilter($filter);
-    $this->cpHandler = new CopyPasteHandler($this->config);
-    $this->snapHandler = new SnapshotHandler($this->config);
+
+    // Add copy&paste and snapshot handler.
+    if ($this->config->boolValueIsTrue("main", "copyPaste")){
+      $this->cpHandler = new CopyPasteHandler($this->config);
+    }
+    if($this->config->get_cfg_value("enableSnapshots") == "true"){
+      $this->snapHandler = new SnapshotHandler($this->config);
+    }
 
     parent::__construct($config, $ui, "users", $headpage);
 
@@ -79,24 +85,73 @@ class userManagement extends management
     $this->registerAction("templateContinue", "templateContinue");
     $this->registerAction("templatize", "templatizeUsers");
     $this->registerAction("templatizeContinue", "templatizeContinue");
+
+    $this->registerAction("sendMessage", "sendMessage");
+    $this->registerAction("saveEventDialog", "saveEventDialog");
+    $this->registerAction("abortEventDialog", "closeDialogs");
   }
 
+
   // Inject user actions 
   function detectPostActions()
   {
     $action = management::detectPostActions();
     if(isset($_POST['template_continue'])) $action['action'] = "templateContinue";
     if(isset($_POST['templatize_continue'])) $action['action'] = "templatizeContinue";
+    if(isset($_POST['save_event_dialog'])) $action['action'] = "saveEventDialog";
+    if(isset($_POST['abort_event_dialog'])) $action['action'] = "abortEventDialog";
     return($action);
   }
 
 
+  /*! \brief  Sends a message to a set of users using gosa-si events.
+   */ 
+  function sendMessage($action="",$target=array(),$all=array())
+  {
+    if(class_available("DaemonEvent")){
+      $uids = array();
+      $ldap = $this->config->get_ldap_link();
+      $ldap->cd($this->config->current['BASE']);
+      foreach($target as $dn){
+        $ldap->cat($dn,array('uid'));
+        $attrs = $ldap->fetch();
+        if(isset($attrs['uid'][0])){
+          $uids[] = $attrs['uid'][0];
+        }
+      }
+      if(count($uids)){
+        $events = DaemonEvent::get_event_types(USER_EVENT);
+        $event = "DaemonEvent_notify";
+        if(isset($events['BY_CLASS'][$event])){
+          $type = $events['BY_CLASS'][$event];
+          $this->dialogObject = new $type['CLASS_NAME']($this->config);
+          $this->dialogObject->add_users($uids);
+          $this->dialogObject->set_type(SCHEDULED_EVENT);
+        }
+      }
+    }
+  }
+
 
-  function alert($action,$values)
+  /*! \brief  Sends a message to a set of users using gosa-si events.
+   */ 
+  function saveEventDialog()
   {
-    print_a(array($action,$values));
+    $this->dialogObject->save_object();
+    $msgs = $this->dialogObject->check();
+    if(count($msgs)){
+      msg_dialog::displayChecks($msgs);
+    }else{
+      $o_queue = new gosaSupportDaemon();
+      $o_queue->append($this->dialogObject);
+      if($o_queue->is_error()){
+        msg_dialog::display(_("Infrastructure error"), msgPool::siError($o_queue->get_error()),ERROR_DIALOG);
+      }
+      $this->closeDialogs();
+    }
   }
 
+
   /*! \brief  Intiates template creation. 
    */ 
   function newTemplate($action,$entry)
index 7ab138502011dbb2f3d9e30ca4ccff9886c66bc3..ed2f59cc0fc13ce8fb39b151dbdf5bf8177bd30b 100644 (file)
       <label>Unlock users</label>
     </action>
 
+    <action>
+      <name>sendMessage</name>
+      <type>entry</type>
+      <image>plugins/goto/images/notify.png</image>
+      <label>Send message</label>
+    </action>
+
     <action>
       <type>separator</type>
     </action>
     <action>
       <type>exporter</type>
     </action>
+
+    <action>
+      <type>separator</type>
+    </action>
+
+    <action>
+      <type>copypaste</type>
+    </action>
+
+    <action>
+      <type>snapshot</type>
+    </action>
   </actionmenu>
 
   <actiontriggers snapshot="true" copypaste="true">