From acc86b9221bf48ed364c976db53bfe7e009ba68b Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Tue, 1 Mar 2011 23:56:27 +0100 Subject: [PATCH] ability to override notification email for group --- src/messenger/webim/leavemessage.php | 7 ++++++- src/messenger/webim/locales/en/properties | 1 + src/messenger/webim/locales/ru/properties | 1 + src/messenger/webim/operator/group.php | 22 +++++++++++++++------- src/messenger/webim/view/group.php | 11 ++++++++++- 5 files changed, 33 insertions(+), 9 deletions(-) diff --git a/src/messenger/webim/leavemessage.php b/src/messenger/webim/leavemessage.php index 0ee3f036..15ee680f 100644 --- a/src/messenger/webim/leavemessage.php +++ b/src/messenger/webim/leavemessage.php @@ -51,6 +51,7 @@ function store_message($name, $email, $info, $message,$groupid,$referrer) { $groupid = ""; $groupname = ""; +$group = NULL; loadsettings(); if($settings['enablegroups'] == '1') { $groupid = verifyparam( "group", "/^\d{1,8}$/", ""); @@ -108,7 +109,11 @@ store_message($visitor_name, $email, $info, $message, $groupid, $referrer); $subject = getstring2_("leavemail.subject", array($visitor_name), $message_locale); $body = getstring2_("leavemail.body", array($visitor_name,$email,$message,$info ? "$info\n" : ""), $message_locale); -$inbox_mail = $settings['email']; +if (isset($group) && !empty($group['vcemail'])) { + $inbox_mail = $group['vcemail']; +} else { + $inbox_mail = $settings['email']; +} if($inbox_mail) { $link = connect(); diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index ceae655d..7f598731 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -144,6 +144,7 @@ form.field.groupcommonname.description=Name in English. form.field.groupcommonname=International name form.field.groupdesc.description=Description of the group. form.field.groupdesc=Description +form.field.groupemail.description=Group email for notifications. Leave empty to use the default address. form.field.groupname.description=Name to identify the group. form.field.groupname=Name form.field.jabber.description=For instant notifications diff --git a/src/messenger/webim/locales/ru/properties b/src/messenger/webim/locales/ru/properties index e2bf9d9e..c9404bfc 100644 --- a/src/messenger/webim/locales/ru/properties +++ b/src/messenger/webim/locales/ru/properties @@ -144,6 +144,7 @@ form.field.groupcommonname.description= form.field.groupcommonname=Интернациональное название form.field.groupdesc.description=Будет доступно посетителям при выборе группы. form.field.groupdesc=Описание +form.field.groupemail.description=Адрес для извещений. Оставьте пустым, чтобы использовать глобальный адрес. form.field.groupname.description=Может быть названием отдела в вашей компании. form.field.groupname=Название группы form.field.jabber.description=Для быстрого получения уведомлений diff --git a/src/messenger/webim/operator/group.php b/src/messenger/webim/operator/group.php index a7b58e27..745c46b8 100644 --- a/src/messenger/webim/operator/group.php +++ b/src/messenger/webim/operator/group.php @@ -39,16 +39,17 @@ function group_by_name($name) return $group; } -function create_group($name, $descr, $commonname, $commondescr) +function create_group($name, $descr, $commonname, $commondescr, $email) { global $mysqlprefix; $link = connect(); $query = sprintf( - "insert into ${mysqlprefix}chatgroup (vclocalname,vclocaldescription,vccommonname,vccommondescription) values ('%s','%s','%s','%s')", + "insert into ${mysqlprefix}chatgroup (vclocalname,vclocaldescription,vccommonname,vccommondescription,vcemail) values ('%s','%s','%s','%s','%s')", mysql_real_escape_string($name), mysql_real_escape_string($descr), mysql_real_escape_string($commonname), - mysql_real_escape_string($commondescr)); + mysql_real_escape_string($commondescr), + mysql_real_escape_string($email)); perform_query($query, $link); $id = mysql_insert_id($link); @@ -58,16 +59,17 @@ function create_group($name, $descr, $commonname, $commondescr) return $newdep; } -function update_group($groupid, $name, $descr, $commonname, $commondescr) +function update_group($groupid, $name, $descr, $commonname, $commondescr, $email) { global $mysqlprefix; $link = connect(); $query = sprintf( - "update ${mysqlprefix}chatgroup set vclocalname = '%s', vclocaldescription = '%s', vccommonname = '%s', vccommondescription = '%s' where groupid = %s", + "update ${mysqlprefix}chatgroup set vclocalname = '%s', vclocaldescription = '%s', vccommonname = '%s', vccommondescription = '%s', vcemail = '%s' where groupid = %s", mysql_real_escape_string($name), mysql_real_escape_string($descr), mysql_real_escape_string($commonname), mysql_real_escape_string($commondescr), + mysql_real_escape_string($email), $groupid); perform_query($query, $link); @@ -81,10 +83,14 @@ if (isset($_POST['name'])) { $description = getparam('description'); $commonname = getparam('commonname'); $commondescription = getparam('commondescription'); + $email = getparam('email'); if (!$name) $errors[] = no_field("form.field.groupname"); + if ($email != '' && !is_valid_email($email)) + $errors[] = wrong_field("form.field.mail"); + $existing_group = group_by_name($name); if ((!$groupid && $existing_group) || ($groupid && $existing_group && $groupid != $existing_group['groupid'])) @@ -92,11 +98,11 @@ if (isset($_POST['name'])) { if (count($errors) == 0) { if (!$groupid) { - $newdep = create_group($name, $description, $commonname, $commondescription); + $newdep = create_group($name, $description, $commonname, $commondescription, $email); header("Location: $webimroot/operator/groupmembers.php?gid=" . $newdep['groupid']); exit; } else { - update_group($groupid, $name, $description, $commonname, $commondescription); + update_group($groupid, $name, $description, $commonname, $commondescription, $email); header("Location: $webimroot/operator/group.php?gid=$groupid&stored"); exit; } @@ -105,6 +111,7 @@ if (isset($_POST['name'])) { $page['formdescription'] = topage($description); $page['formcommonname'] = topage($commonname); $page['formcommondescription'] = topage($commondescription); + $page['formemail'] = topage($email); $page['grid'] = topage($groupid); } @@ -120,6 +127,7 @@ if (isset($_POST['name'])) { $page['formdescription'] = topage($group['vclocaldescription']); $page['formcommonname'] = topage($group['vccommonname']); $page['formcommondescription'] = topage($group['vccommondescription']); + $page['formemail'] = topage($group['vcemail']); $page['grid'] = topage($group['groupid']); } } diff --git a/src/messenger/webim/view/group.php b/src/messenger/webim/view/group.php index b8f05d99..a4a5f871 100644 --- a/src/messenger/webim/view/group.php +++ b/src/messenger/webim/view/group.php @@ -91,7 +91,16 @@ require_once('inc_errors.php');

- + +
+
+
+ +
+
+
+
+