From e578a29058ea72855dc05b40cee563cb72f7e82e Mon Sep 17 00:00:00 2001 From: "Michael Kaufmann (d00p)" Date: Thu, 15 Jan 2015 22:10:37 +0100 Subject: [PATCH] add option to display the custom-notes to the user and actually save the custom-note Signed-off-by: Michael Kaufmann (d00p) --- admin_admins.php | 20 ++++++++++++++--- admin_customers.php | 22 +++++++++++++++---- install/froxlor.sql | 2 ++ .../admin/admin/formfield.admin_add.php | 8 +++++++ .../admin/admin/formfield.admin_edit.php | 8 +++++++ .../admin/customer/formfield.customer_add.php | 8 +++++++ .../customer/formfield.customer_edit.php | 8 +++++++ lng/english.lng.php | 1 + lng/german.lng.php | 1 + templates/Sparkle/admin/index/index.tpl | 8 +++++++ templates/Sparkle/customer/index/index.tpl | 5 +++++ 11 files changed, 84 insertions(+), 7 deletions(-) diff --git a/admin_admins.php b/admin_admins.php index c4f61d59..f483a33b 100644 --- a/admin_admins.php +++ b/admin_admins.php @@ -201,6 +201,9 @@ if ($page == 'admins' $name = validate($_POST['name'], 'name'); $email = $idna_convert->encode(validate($_POST['email'], 'email')); + $custom_notes = validate(str_replace("\r\n", "\n", $_POST['custom_notes']), 'custom_notes', '/^[^\0]*$/'); + $custom_notes_show = intval_ressource($_POST['custom_notes_show']); + $loginname = validate($_POST['loginname'], 'loginname'); $password = validate($_POST['admin_password'], 'password'); $password = validatePassword($password); @@ -391,7 +394,9 @@ if ($page == 'admins' 'tickets_see_all' => $tickets_see_all, 'mysqls' => $mysqls, 'ip' => $ipaddress, - 'theme' => $_theme + 'theme' => $_theme, + 'custom_notes' => $custom_notes, + 'custom_notes_show' => $custom_notes_show ); $ins_stmt = Database::prepare(" @@ -419,7 +424,9 @@ if ($page == 'admins' `tickets_see_all` = :tickets_see_all, `mysqls` = :mysqls, `ip` = :ip, - `theme` = :theme + `theme` = :theme, + `custom_notes` = :custom_notes, + `custom_notes_show` = :custom_notes_show "); Database::pexecute($ins_stmt, $ins_data); @@ -490,6 +497,9 @@ if ($page == 'admins' $name = validate($_POST['name'], 'name'); $email = $idna_convert->encode(validate($_POST['email'], 'email')); + $custom_notes = validate(str_replace("\r\n", "\n", $_POST['custom_notes']), 'custom_notes', '/^[^\0]*$/'); + $custom_notes_show = intval_ressource($_POST['custom_notes_show']); + if ($result['adminid'] == $userinfo['userid']) { $password = ''; @@ -724,6 +734,8 @@ if ($page == 'admins' 'mysqls' => $mysqls, 'ip' => $ipaddress, 'deactivated' => $deactivated, + 'custom_notes' => $custom_notes, + 'custom_notes_show' => $custom_notes_show, 'adminid' => $id ); @@ -751,7 +763,9 @@ if ($page == 'admins' `tickets_see_all` = :tickets_see_all, `mysqls` = :mysqls, `ip` = :ip, - `deactivated` = :deactivated + `deactivated` = :deactivated, + `custom_notes` = :custom_notes, + `custom_notes_show` = :custom_notes_show WHERE `adminid` = :adminid "); Database::pexecute($upd_stmt, $upd_data); diff --git a/admin_customers.php b/admin_customers.php index 8d5c22bf..7774074b 100644 --- a/admin_customers.php +++ b/admin_customers.php @@ -419,6 +419,9 @@ if ($page == 'customers' $def_language = validate($_POST['def_language'], 'default language'); $gender = intval_ressource($_POST['gender']); + $custom_notes = validate(str_replace("\r\n", "\n", $_POST['custom_notes']), 'custom_notes', '/^[^\0]*$/'); + $custom_notes_show = intval_ressource($_POST['custom_notes_show']); + $diskspace = intval_ressource($_POST['diskspace']); if (isset($_POST['diskspace_ul'])) { $diskspace = - 1; @@ -671,7 +674,9 @@ if ($page == 'customers' 'imap' => $email_imap, 'pop3' => $email_pop3, 'perlenabled' => $perlenabled, - 'theme' => $_theme + 'theme' => $_theme, + 'custom_notes' => $custom_notes, + 'custom_notes_show' => $custom_notes_show ); $ins_stmt = Database::prepare(" @@ -708,7 +713,9 @@ if ($page == 'customers' `imap` = :imap, `pop3` = :pop3, `perlenabled` = :perlenabled, - `theme` = :theme" + `theme` = :theme, + `custom_notes` = :custom_notes, + `custom_notes_show` = :custom_notes_show" ); Database::pexecute($ins_stmt, $ins_data); @@ -1065,6 +1072,9 @@ if ($page == 'customers' $move_to_admin = isset($_POST['move_to_admin']) ? intval_ressource($_POST['move_to_admin']) : 0; + $custom_notes = validate(str_replace("\r\n", "\n", $_POST['custom_notes']), 'custom_notes', '/^[^\0]*$/'); + $custom_notes_show = intval_ressource($_POST['custom_notes_show']); + $diskspace = intval_ressource($_POST['diskspace']); if (isset($_POST['diskspace_ul'])) { $diskspace = - 1; @@ -1400,7 +1410,9 @@ if ($page == 'customers' 'phpenabled' => $phpenabled, 'imap' => $email_imap, 'pop3' => $email_pop3, - 'perlenabled' => $perlenabled + 'perlenabled' => $perlenabled, + 'custom_notes' => $custom_notes, + 'custom_notes_show' => $custom_notes_show ); $upd_stmt = Database::prepare(" UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET @@ -1431,7 +1443,9 @@ if ($page == 'customers' `email_quota` = :email_quota, `imap` = :imap, `pop3` = :pop3, - `perlenabled` = :perlenabled + `perlenabled` = :perlenabled, + `custom_notes` = :custom_notes, + `custom_notes_show` = :custom_notes_show WHERE `customerid` = :customerid" ); Database::pexecute($upd_stmt, $upd_data); diff --git a/install/froxlor.sql b/install/froxlor.sql index e98b690e..48bfc0b5 100644 --- a/install/froxlor.sql +++ b/install/froxlor.sql @@ -132,6 +132,7 @@ CREATE TABLE `panel_admins` ( `reportsent` tinyint(4) unsigned NOT NULL default '0', `theme` varchar(255) NOT NULL default 'Sparkle', `custom_notes` text, + `custom_notes_show` tinyint(1) NOT NULL default '0', PRIMARY KEY (`adminid`), UNIQUE KEY `loginname` (`loginname`) ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_general_ci; @@ -192,6 +193,7 @@ CREATE TABLE `panel_customers` ( `perlenabled` tinyint(1) NOT NULL default '0', `theme` varchar(255) NOT NULL default 'Sparkle', `custom_notes` text, + `custom_notes_show` tinyint(1) NOT NULL default '0', PRIMARY KEY (`customerid`), UNIQUE KEY `loginname` (`loginname`) ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_general_ci; diff --git a/lib/formfields/admin/admin/formfield.admin_add.php b/lib/formfields/admin/admin/formfield.admin_add.php index dcb282a7..a89a6f9e 100644 --- a/lib/formfields/admin/admin/formfield.admin_add.php +++ b/lib/formfields/admin/admin/formfield.admin_add.php @@ -69,6 +69,14 @@ return array( 'type' => 'textarea', 'cols' => 60, 'rows' => 12 + ), + 'custom_notes_show' => array( + 'label' => $lng['usersettings']['custom_notes']['show'], + 'type' => 'checkbox', + 'values' => array( + array ('label' => $lng['panel']['yes'], 'value' => '1') + ), + 'value' => array() ) ) ), diff --git a/lib/formfields/admin/admin/formfield.admin_edit.php b/lib/formfields/admin/admin/formfield.admin_edit.php index aa096b9e..4a06a81e 100644 --- a/lib/formfields/admin/admin/formfield.admin_edit.php +++ b/lib/formfields/admin/admin/formfield.admin_edit.php @@ -83,6 +83,14 @@ return array( 'cols' => 60, 'rows' => 12, 'value' => $result['custom_notes'] + ), + 'custom_notes_show' => array( + 'label' => $lng['usersettings']['custom_notes']['show'], + 'type' => 'checkbox', + 'values' => array( + array ('label' => $lng['panel']['yes'], 'value' => '1') + ), + 'value' => array($result['custom_notes_show']) ) ) ), diff --git a/lib/formfields/admin/customer/formfield.customer_add.php b/lib/formfields/admin/customer/formfield.customer_add.php index fb239e32..54a7e863 100644 --- a/lib/formfields/admin/customer/formfield.customer_add.php +++ b/lib/formfields/admin/customer/formfield.customer_add.php @@ -130,6 +130,14 @@ return array( 'type' => 'textarea', 'cols' => 60, 'rows' => 12 + ), + 'custom_notes_show' => array( + 'label' => $lng['usersettings']['custom_notes']['show'], + 'type' => 'checkbox', + 'values' => array( + array ('label' => $lng['panel']['yes'], 'value' => '1') + ), + 'value' => array() ) ) ), diff --git a/lib/formfields/admin/customer/formfield.customer_edit.php b/lib/formfields/admin/customer/formfield.customer_edit.php index a9fc5bf5..b7e23476 100644 --- a/lib/formfields/admin/customer/formfield.customer_edit.php +++ b/lib/formfields/admin/customer/formfield.customer_edit.php @@ -139,6 +139,14 @@ return array( 'cols' => 60, 'rows' => 12, 'value' => $result['custom_notes'] + ), + 'custom_notes_show' => array( + 'label' => $lng['usersettings']['custom_notes']['show'], + 'type' => 'checkbox', + 'values' => array( + array ('label' => $lng['panel']['yes'], 'value' => '1') + ), + 'value' => array($result['custom_notes_show']) ) ) ), diff --git a/lng/english.lng.php b/lng/english.lng.php index 253377bd..6f662030 100644 --- a/lng/english.lng.php +++ b/lng/english.lng.php @@ -1835,3 +1835,4 @@ $lng['admin']['note'] = 'Note'; $lng['domains']['import_description'] = 'Detailed information about the structure of the import-file and how to import successfully, please visit http://redmine.froxlor.org/projects/froxlor/wiki/DomainBulkActionDoc'; $lng['usersettings']['custom_notes']['title'] = 'Custom notes'; $lng['usersettings']['custom_notes']['description'] = 'Feel free to put any notes you want/need in here. They will show up in the admin/customer overview for the corresponding user.'; +$lng['usersettings']['custom_notes']['show'] = 'Show your notes on the dashboard of the user'; diff --git a/lng/german.lng.php b/lng/german.lng.php index bba6e5d1..e5dc845b 100644 --- a/lng/german.lng.php +++ b/lng/german.lng.php @@ -1562,3 +1562,4 @@ $lng['admin']['note'] = 'Hinweis'; $lng['domains']['import_description'] = 'Detaillierte Informationen über den Aufbau der Importdatei und einen erfolgreichen Import gibt es hier: http://redmine.froxlor.org/projects/froxlor/wiki/DomainBulkActionDoc (englisch)'; $lng['usersettings']['custom_notes']['title'] = 'Eigene Notizen'; $lng['usersettings']['custom_notes']['description'] = 'Hier können Notizen je nach Lust und Laune eingetragen werden. Diese werden in der Administrator/Kunden-Übersicht bei dem jeweiligen Benutzer angezeigt.'; +$lng['usersettings']['custom_notes']['show'] = 'Zeige die Notizen auf dem Dashboard des Benutzers'; diff --git a/templates/Sparkle/admin/index/index.tpl b/templates/Sparkle/admin/index/index.tpl index 872e2edc..554f6842 100644 --- a/templates/Sparkle/admin/index/index.tpl +++ b/templates/Sparkle/admin/index/index.tpl @@ -179,6 +179,14 @@ $header + + + + + +
{$userinfo['custom_notes']}
+
+ diff --git a/templates/Sparkle/customer/index/index.tpl b/templates/Sparkle/customer/index/index.tpl index a73b640d..e6f80604 100644 --- a/templates/Sparkle/customer/index/index.tpl +++ b/templates/Sparkle/customer/index/index.tpl @@ -232,6 +232,11 @@ $header + + + + +
{$userinfo['email']}
{$userinfo['custom_notes']}