summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: c028d69)
raw | patch | inline | side by side (parent: c028d69)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 28 Jun 2006 11:48:48 +0000 (11:48 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Wed, 28 Jun 2006 11:48:48 +0000 (11:48 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@3961 594d385d-05f5-0310-b6e9-bd551577e9d8
contrib/gosa.conf | patch | blob | history | |
html/images/notifications.png | [new file with mode: 0755] | patch | blob |
plugins/addons/notifications/class_msgplug.inc | [new file with mode: 0644] | patch | blob |
plugins/addons/notifications/contents.tpl | [new file with mode: 0644] | patch | blob |
plugins/addons/notifications/main.inc | [new file with mode: 0644] | patch | blob |
plugins/personal/mail/class_mailAccount.inc | patch | blob | history |
diff --git a/contrib/gosa.conf b/contrib/gosa.conf
index 01a127cf1bb59de04577541dc240f9e09719a80a..cf56c5681a76f2218202a7056f97a4c53efd9801 100644 (file)
--- a/contrib/gosa.conf
+++ b/contrib/gosa.conf
icon="application.png" path="plugins/admin/applications" />
<plugin acl="systems" class="systems" icon="system.png"
path="plugins/admin/systems" />
- <plugin acl="mimetype" class="mimetypeManagement"
- icon="mimetypes.png" path="plugins/admin/mimetypes" />
+ <plugin acl="mimetype" class="mimetypeManagement"
+ icon="mimetypes.png" path="plugins/admin/mimetypes" />
<!-- Use 'lock_dn' for dn
'lock_name' for name
path="plugins/addons/mailqueue" />
<plugin acl="ldapmanager" class="ldif" icon="ldif.png"
path="plugins/addons/ldapmanager" />
+ <plugin acl="notifications" class="msgplug" icon="notifications.png"
+ path="plugins/addons/notifications" />
</section>
</menu>
diff --git a/html/images/notifications.png b/html/images/notifications.png
new file mode 100755 (executable)
index 0000000..e88e686
Binary files /dev/null and b/html/images/notifications.png differ
index 0000000..e88e686
Binary files /dev/null and b/html/images/notifications.png differ
diff --git a/plugins/addons/notifications/class_msgplug.inc b/plugins/addons/notifications/class_msgplug.inc
--- /dev/null
@@ -0,0 +1,229 @@
+<?php
+
+class msgplug extends plugin
+{
+ /* Definitions */
+ var $plHeadline= "Notifications";
+ var $plDescription= "This does something";
+
+ /* attribute list for save action */
+ var $attributes= array("target", "nmessage");
+ var $objectclasses= array();
+
+ /* Helpers */
+ var $target= "group";
+ var $nmessage= "";
+
+ var $targets= array();
+ var $users= array();
+ var $groups= array();
+ var $recipients= array();
+ var $show_templates= false;
+ var $templates= array();
+ var $template= "";
+ var $finalized= false;
+
+
+ function msgplug ($config, $dn= NULL)
+ {
+ /* Include config object */
+ $this->config= $config;
+ $ui= get_userinfo();
+ $tag= $ui->gosaUnitTag;
+
+ /* Preset values */
+ $this->targets= array("user" => _("Users"), "group" => _("Groups"));
+ ksort($this->targets);
+
+ /* Users */
+ $ldap= $config->get_ldap_link();
+ $ldap->cd($config->current['BASE']);
+ if ($tag == ""){
+ $ldap->search('(objectClass=gosaAccount)', array('uid', 'cn'));
+ } else {
+ $ldap->search('(&(objectClass=gosaAccount)(gosaUnitTag)'.$tag.'))', array('uid', 'cn'));
+ }
+ while ($attrs= $ldap->fetch()){
+ $this->users['U:'.$attrs['uid'][0]]= $attrs['cn'][0].' ['.$attrs['uid'][0].']';
+ }
+ ksort($this->users);
+
+ /* Groups */
+ $ldap->cd($config->current['BASE']);
+ if ($tag == ""){
+ $ldap->search('(objectClass=posixGroup)', array('cn', 'description'));
+ } else {
+ $ldap->search('(&(objectClass=posixGroup)(gosaUnitTag='.$tag.'))', array('cn', 'description'));
+ }
+ while ($attrs= $ldap->fetch()){
+ $dsc= "";
+ if (isset($attrs['description'][0])){
+ $dsc= $attrs['description'][0];
+ }
+ $this->groups['G:'.$attrs['cn'][0]]= $attrs['cn'][0].' ['.$dsc.']';
+ }
+ ksort($this->groups);
+
+ /* Load templates */
+ if (isset($this->config->current['NOTIFYDIR'])){
+ $dir= $this->config->current['NOTIFYDIR'];
+ if (is_dir($dir) && is_readable($dir)){
+
+ /* Look for files and build the vacation array */
+ $dh= opendir($dir);
+ while ($file = readdir($dh)){
+ $description= $this->parse_notification("$dir/$file");
+ if ($description != ""){
+ $this->templates["$dir/$file"]= $description;
+ }
+ }
+ closedir($dh);
+ }
+
+ /* Enable templates if there are some... */
+ if (count($this->templates)){
+ $this->show_templates= true;
+ }
+ }
+ }
+
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Send message? */
+ if (isset($_POST['send'])){
+
+ /* Do we have recipients? */
+ if (count($this->recipients)){
+
+ /*Permissions ok? */
+ if (chkacl($this->acl, 'notify') != ""){
+ print_red(_("You have no permissions to send a message!"));
+ } else {
+ $cmd= search_config($this->config->data['MENU'], "msgplug", "NOTIFY_COMMAND");
+ if ($cmd == ""){
+ print_red(_("No NOTIFY_COMMAND definition found in your gosa.conf"));
+ } else {
+ $parameters= "";
+ foreach ($this->recipients as $key => $value){
+ $parameters.= "$key ";
+ }
+ exec ("$cmd $parameters", $dummy, $retval);
+ if ($retval != 0){
+ print_red(sprintf(_("Execution of '%s' failed!"), $cmd));
+ }
+ $this->finalized= true;
+ }
+ }
+ } else {
+ print_red(_("Please specify at least one recipient to send a message!"));
+ }
+ }
+
+ /* Bounce back to the original dialog */
+ if (isset($_POST['continue'])){
+ $this->finalized= false;
+ }
+
+ /* Add to list? */
+ if (isset($_POST['add']) && isset($_POST['source'])){
+ foreach ($_POST['source'] as $key){
+ if ($this->target == 'user'){
+ $this->recipients[$key]= $this->users[$key];
+ }
+ if ($this->target == 'group'){
+ $this->recipients[$key]= $this->groups[$key];
+ }
+ }
+ ksort($this->recipients);
+ }
+
+ /* Remove from list? */
+ if (isset($_POST['del']) && isset($_POST['recipient'])){
+ foreach ($_POST['recipient'] as $key){
+ unset($this->recipients[$key]);
+ }
+ }
+
+ /* Import message? */
+ if (isset($_POST["import_template"]) && isset($this->templates[$_POST["nmessage_template"]])){
+ $contents= "";
+ $lines= file($_POST["nmessage_template"]);
+ foreach ($lines as $line){
+ if (!preg_match('/^DESC:/', $line)){
+ $contents.= $line;
+ }
+ }
+
+ /* Replace attributes */
+ $ui= get_userinfo();
+ $contents= preg_replace('/%self/', $ui->cn, $contents);
+
+ /* Save message */
+ $this->nmessage= htmlspecialchars($contents);
+ }
+
+ $smarty= get_smarty();
+
+ /* Assign possible target types */
+ $smarty->assign("targets", $this->targets);
+ foreach ($this->attributes as $attr){
+ $smarty->assign($attr, $this->$attr);
+ }
+
+ /* Generate list */
+ $tmp= array();
+ foreach (array("user" => "users", "group" => "groups") as $field => $arr){
+ if ($this->target == $field){
+ foreach ($this->$arr as $key => $value){
+ if (!isset($this->recipients[$key])){
+ $tmp[$key]= $value;
+ }
+ }
+ }
+ }
+ $smarty->assign('sources', $tmp);
+ $smarty->assign('recipients', $this->recipients);
+
+ /* Assign ACL */
+ $smarty->assign('nmessageACL', chkacl($this->acl, "notify"));
+
+ /* Handle templates */
+ $smarty->assign('show_templates', $this->show_templates?"true":"false");
+ $smarty->assign('message_templates', $this->templates);
+ $smarty->assign('template', $this->template);
+ $smarty->assign('finished', $this->finalized?"true":"false");
+
+ /* Show main page */
+ return ($smarty->fetch (get_template_path('contents.tpl', TRUE)));
+ }
+
+
+ function parse_notification($file)
+ {
+ $desc= "";
+
+ if (is_file($file)){
+ $fh = fopen($file, "r");
+ $line= fgets($fh, 256);
+
+ if (!preg_match('/^DESC:/', $line)){
+ print_red (_("No DESC tag in message file:")." $file");
+ return $desc;
+ }
+ fclose ($fh);
+
+ $desc= trim(preg_replace('/^DESC:\s*/', '', $line));
+ }
+
+ return $desc;
+ }
+
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/plugins/addons/notifications/contents.tpl b/plugins/addons/notifications/contents.tpl
--- /dev/null
@@ -0,0 +1,76 @@
+{if $finished eq "false"}
+<h2>{t}Notification target{/t}</h2>
+
+<table style="width:100%">
+ <tr>
+ <td style="width:48%; vertical-align:top;">
+ {t}Use target from{/t}
+ <select name="target" onChange="document.mainform.submit()">
+ {html_options options=$targets selected=$target}
+ <option disabled> </option>
+ </select>
+ <input type="submit" value="{t}Apply{/t}" name="refresh"><br><br>
+ </td>
+ <td>
+ </td>
+ <td>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ {t}Available recipients{/t}<br>
+ <select style="width:100%;height:180px;" name="source[]" size="20" multiple title="{t}List message possible targets{/t}">
+ {html_options options=$sources}
+ <option disabled> </option>
+ </select>
+ </td>
+ <td style="vertical-align:center; text-align:center">
+ <input type="submit" value=">" name="add">
+ <br><br>
+ <input type="submit" value="<" name="del">
+ </td>
+ <td style="width:48%; vertical-align:top;">
+ {t}Recipients{/t}<br>
+ <select style="width:100%;height:180px;" name="recipient[]" size="20" multiple title="{t}List message recipients{/t}">
+ {html_options options=$recipients}
+ <option disabled> </option>
+ </select>
+ </td>
+ </tr>
+</table>
+
+
+<p class="seperator"> </p>
+<h2>{t}Message{/t}</h2>
+
+<textarea id="nmessage" style="width:99%; height:180px;" name="nmessage" rows="4" cols="512" {$nmessageACL}>{$nmessage}</textarea>
+{if $show_templates eq "true"}
+<select name="nmessage_template">
+ {html_options options=$message_templates selected=$template}
+ <option disabled> </option>
+</select>
+<input type="submit" value="{t}Import{/t}" name="import_template">
+{/if}
+
+<p class="seperator"> </p>
+<div style='text-align:right;margin-top:5px'>
+ <input type="submit" name="send" value="{t}Send message{/t}">
+</div>
+
+
+<!-- Place cursor -->
+<script language="JavaScript" type="text/javascript">
+ <!-- // First input field on page
+ document.mainform.nmessage.focus();
+ -->
+</script>
+{else}
+<h2>{t}Notification send!{/t}</h2>
+<p class="seperator"> </p>
+<br>
+{t}Your message has been sent successfully. Press the continue button to get back to the notification plugin.{/t}
+<p class="seperator"> </p>
+<div style='text-align:right;margin-top:5px'>
+ <input type="submit" name="continue" value="{t}Continue{/t}">
+</div>
+{/if}
diff --git a/plugins/addons/notifications/main.inc b/plugins/addons/notifications/main.inc
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2005 Cajus Pollmeier
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+if (!$remove_lock){
+ /* Create message object on demand */
+ if (!isset($_SESSION['msgplug']) || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+ $_SESSION['msgplug']= new msgplug ($config);
+ }
+ $msgplug= $_SESSION['msgplug'];
+
+ /* Set permissions */
+ $acl= get_permissions ($ui->dn, $ui->subtreeACL);
+ $msgplug->acl= get_module_permission($acl, "msgplug", $ui->dn);
+
+ /* save changes back to object */
+ if (isset ($_POST['target'])){
+ $msgplug->save_object ();
+ }
+
+ /* Execute formular */
+ $display= $msgplug->execute ();
+ $display.= "<input type=\"hidden\" name=\"ignore\">\n";
+
+ /* Page header*/
+ $display= print_header(get_template_path('images/notifications.png'), _("Notifications")).$display;
+
+ /* Store changes in session */
+ $_SESSION['msgplug']= $msgplug;
+}
+?>
diff --git a/plugins/personal/mail/class_mailAccount.inc b/plugins/personal/mail/class_mailAccount.inc
index bff7beeb0397a48690f7a5d1a423d8b8a2cdf9d8..2ade42931fd6ba40db14abc15ff3f512564c0e5c 100644 (file)
}
}
-
- /* Get vacation message */
-
/* Fill vacation array */
$this->vacation= array();
if (isset($this->config->current['VACATIONDIR'])){
}
- /* Vocation message */
+ /* Vacation message */
/* Import vacation message? */
if (isset($_POST["import_vacation"]) && isset($this->vacation[$_POST["vacation_template"]])){