Last active
December 18, 2015 22:58
-
-
Save tpokorra/5857834 to your computer and use it in GitHub Desktop.
Kolab webadmin: select a unit, eg. KB, MB or GB for the quota to be stored
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -uNr kolab-webadmin.orig/lib/api/kolab_api_service_user.php kolab-webadmin/lib/api/kolab_api_service_user.php | |
--- kolab-webadmin.orig/lib/api/kolab_api_service_user.php 2013-06-18 11:33:48.541736452 +0200 | |
+++ kolab-webadmin/lib/api/kolab_api_service_user.php 2013-06-25 13:37:54.989123228 +0200 | |
@@ -125,6 +125,13 @@ | |
{ | |
//console("\$postdata to user_edit()", $postdata); | |
+ if ($postdata['mailquota-unit'] == 'gb') { | |
+ $postdata['mailquota'] *= 1024*1024; | |
+ } | |
+ if ($postdata['mailquota-unit'] == 'mb') { | |
+ $postdata['mailquota'] *= 1024; | |
+ } | |
+ | |
$user_attributes = $this->parse_input_attributes('user', $postdata); | |
$user = $postdata['id']; | |
diff -uNr kolab-webadmin.orig/lib/client/kolab_client_task_settings.php kolab-webadmin/lib/client/kolab_client_task_settings.php | |
--- kolab-webadmin.orig/lib/client/kolab_client_task_settings.php 2013-06-18 11:33:48.533737103 +0200 | |
+++ kolab-webadmin/lib/client/kolab_client_task_settings.php 2013-06-25 13:32:57.779123911 +0200 | |
@@ -33,6 +33,7 @@ | |
protected $form_element_types = array( | |
'text', 'select', 'multiselect', 'list', 'list-autocomplete', 'checkbox', 'password', 'ldap_url', | |
+ 'text-quota', | |
); | |
diff -uNr kolab-webadmin.orig/lib/kolab_client_task.php kolab-webadmin/lib/kolab_client_task.php | |
--- kolab-webadmin.orig/lib/kolab_client_task.php 2013-06-18 11:33:48.532737196 +0200 | |
+++ kolab-webadmin/lib/kolab_client_task.php 2013-06-25 13:34:56.557123349 +0200 | |
@@ -854,6 +854,10 @@ | |
} | |
break; | |
+ case 'text-quota': | |
+ $result['type'] = kolab_form::INPUT_TEXTQUOTA; | |
+ break; | |
+ | |
default: | |
$result['type'] = kolab_form::INPUT_TEXT; | |
if (isset($field['maxlength'])) { | |
diff -uNr kolab-webadmin.orig/lib/kolab_form.php kolab-webadmin/lib/kolab_form.php | |
--- kolab-webadmin.orig/lib/kolab_form.php 2013-06-18 11:33:48.533737103 +0200 | |
+++ kolab-webadmin/lib/kolab_form.php 2013-06-25 13:35:58.369123537 +0200 | |
@@ -38,6 +38,7 @@ | |
const INPUT_HIDDEN = 9; | |
const INPUT_CUSTOM = 10; | |
const INPUT_CONTENT = 20; | |
+ const INPUT_TEXTQUOTA = 30; | |
const TYPE_LIST = 1; | |
@@ -277,6 +278,11 @@ | |
$content = kolab_html::input($attribs); | |
break; | |
+ case self::INPUT_TEXTQUOTA: | |
+ $attribs['type'] = 'text'; | |
+ $content = kolab_html::inputquota($attribs); | |
+ break; | |
+ | |
case self::INPUT_CHECKBOX: | |
$attribs['type'] = 'checkbox'; | |
$content = kolab_html::input($attribs); | |
diff -uNr kolab-webadmin.orig/lib/kolab_html.php kolab-webadmin/lib/kolab_html.php | |
--- kolab-webadmin.orig/lib/kolab_html.php 2013-06-18 11:33:48.534737012 +0200 | |
+++ kolab-webadmin/lib/kolab_html.php 2013-06-25 13:37:03.944122847 +0200 | |
@@ -154,6 +154,33 @@ | |
} | |
/** | |
+ * Input element for mail quota. user can select the unit (GB, MB) | |
+ * | |
+ * @param array $attribs Element attributes | |
+ * | |
+ * @return string HTML output of the input | |
+ */ | |
+ public static function inputquota($attribs = array()) | |
+ { | |
+ $elem_attribs = array_merge(self::$input_attribs, self::$input_event_attribs, | |
+ self::$common_attribs, self::$event_attribs); | |
+ $selected_option_mb = $selected_option_gb = ""; | |
+ $selected_option_kb = "selected"; | |
+ if ($attribs['value'] >= 1024 && $attribs['value'] % 1024 == 0) { | |
+ $attribs['value'] /= 1024; | |
+ $selected_option_kb = ""; | |
+ $selected_option_mb = "selected"; | |
+ } | |
+ if ($attribs['value'] >= 1024 && $attribs['value'] % 1024 == 0) { | |
+ $attribs['value'] /= 1024; | |
+ $selected_option_mb = ""; | |
+ $selected_option_gb = "selected"; | |
+ } | |
+ | |
+ return sprintf('<input%s /><select name="%s-unit"><option value="kb" %s>KB</option><option value="mb" %s>MB</option><option value="gb" %s>GB</option></select>', self::attrib_string($attribs, $elem_attribs), $attribs['name'], $selected_option_kb, $selected_option_mb, $selected_option_gb); | |
+ } | |
+ | |
+ /** | |
* Textarea element. | |
* | |
* @param array $attribs Element attributes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sqlfile=/usr/share/doc/kolab-webadmin-3.1/kolab_wap-3.1.sql | |
if [ ! -f $sqlfile ] | |
then | |
sqlfile=/usr/share/doc/kolab-webadmin-3.0.4/kolab_wap-3.0.sql | |
fi | |
sed -r -i -e 's#"mailquota":\{"optional":true}#"mailquota":\{"type":"text-quota","optional":true}#g' $sqlfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment