hello all
i want to share some modifications i made to roundcube code in order to get quota work .. i made this because i manage a computer with apache (only) and other with smtp and imap (only) and i want the user may be able to see his/her quota
i saw in the code (thanks to Roland Liebl for show me the file) that quota are retrieved via imap .. i don't have quotas via imap but in filesystem and my scenario is a little complex .. well, this changes modify some configuration variables and part of the code to process the quota
[config/main.inc.php]
$rcmail_config['quota'] = array( 'backend' => 'cmd', 'program' => '/usr/bin/ssh -i /usr/local/www/apache22/data/sitios/roundcubemail031/config/ssh_reporte reporte@madara.ipigto.rimed.cu /usr/bin/quota', 'program_parameters' => '-f /srv -v', 'zero_as_unlimited' => TRUE);
[program/steps/mail/func.inc]
function rcmail_quota_content($quota=NULL, $attrib=NULL)
{ global $CONFIG, $IMAP, $COMM_PATH, $RCMAIL;
$display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : '';
$quota = array( 'total' => 0, 'used' => 0, 'percent' => 0, );
switch ($CONFIG['quota']['backend']) { case 'imap': if (empty($quota)) { if (!$IMAP->get_capability('QUOTA')) return rcube_label('unknown'); else $quota = $IMAP->get_quota(); } break; case 'cmd': $user = split("@", $RCMAIL->user->get_username()); exec($CONFIG['quota']['program'] ." ". $CONFIG['quota']['program_parameters'] ." ". $user[0], $result); list($quota_fs, $quota['used'], $quota_sl, $quota['total']) = preg_split('/ /', trim($result[2])); if (substr($quota['used'], -1) == '*') { $quota['used'] = substr($quota['used'], 0, -1); } $quota['percent'] = (($quota['used'] * 100) / $quota['total']); break; default: return rcube_label('unknown'); break; } if ($quota && !($quota['total']==0 && $CONFIG['quota']['zero_as_unlimited'])) { $quota_result = sprintf('%s / %s (%.0f%%)', show_bytes($quota['used'] * 1024), show_bytes($quota['total'] * 1024), $quota['percent']);
if ($display == 'image') {
$quota_result = array(
'percent' => $quota['percent'],
'title' => $quota_result,
);
if ($attrib['width'])
$quota_result['width'] = $attrib['width'];
if ($attrib['height'])
$quota_result['height'] = $attrib['height'];
}
}
else return rcube_label('unlimited');
return $quota_result; }
i want to ask to roundcube developers to adopt this modifications in order to strengthen the quota retrieval system .. the complete configuration may be as follow:
[config/main.inc.php]
// Quota Retrieval System $rcmail_config['quota'] = array( 'backend' => 'imap', 'zero_as_unlimited' => TRUE);
$rcmail_config['quota'] = array( 'backend' => 'cmd', 'program' => '/usr/bin/quota', 'program_parameters' => '-f /filesystem -v', 'zero_as_unlimited' => TRUE);
well, that's all
List info: http://lists.roundcube.net/dev/
On Sun, Dec 13, 2009 at 12:33 AM, Leinier Cruz Salfran salfrancl@ipigto.rimed.cu wrote:
hello all
i want to share some modifications i made to roundcube code in order to get quota work .. i made this because i manage a computer with apache (only) and other with smtp and imap (only) and i want the user may be able to see his/her quota
i saw in the code (thanks to Roland Liebl for show me the file) that quota are retrieved via imap .. i don't have quotas via imap but in filesystem and my scenario is a little complex .. well, this changes modify some configuration variables and part of the code to process the quota
[config/main.inc.php]
$rcmail_config['quota'] = array( 'backend' => 'cmd', 'program' => '/usr/bin/ssh -i /usr/local/www/apache22/data/sitios/roundcubemail031/config/ssh_reporte reporte@madara.ipigto.rimed.cu /usr/bin/quota', 'program_parameters' => '-f /srv -v', 'zero_as_unlimited' => TRUE);
[program/steps/mail/func.inc]
function rcmail_quota_content($quota=NULL, $attrib=NULL)
{ global $CONFIG, $IMAP, $COMM_PATH, $RCMAIL;
$display = isset($_SESSION['quota_display']) ? $_SESSION['quota_display'] : '';
$quota = array( 'total' => 0, 'used' => 0, 'percent' => 0, );
switch ($CONFIG['quota']['backend']) { case 'imap': if (empty($quota)) { if (!$IMAP->get_capability('QUOTA')) return rcube_label('unknown'); else $quota = $IMAP->get_quota(); } break; case 'cmd': $user = split("@", $RCMAIL->user->get_username()); exec($CONFIG['quota']['program'] ." ". $CONFIG['quota']['program_parameters'] ." ". $user[0], $result); list($quota_fs, $quota['used'], $quota_sl, $quota['total']) = preg_split('/ /', trim($result[2])); if (substr($quota['used'], -1) == '*') { $quota['used'] = substr($quota['used'], 0, -1); } $quota['percent'] = (($quota['used'] * 100) / $quota['total']); break; default: return rcube_label('unknown'); break; } if ($quota && !($quota['total']==0 && $CONFIG['quota']['zero_as_unlimited'])) { $quota_result = sprintf('%s / %s (%.0f%%)', show_bytes($quota['used'] * 1024), show_bytes($quota['total'] * 1024), $quota['percent']);
if ($display == 'image') { $quota_result = array( 'percent' => $quota['percent'], 'title' => $quota_result, ); if ($attrib['width']) $quota_result['width'] = $attrib['width']; if ($attrib['height']) $quota_result['height'] = $attrib['height']; } } else return rcube_label('unlimited');
return $quota_result; }
i want to ask to roundcube developers to adopt this modifications in order to strengthen the quota retrieval system .. the complete configuration may be as follow:
[config/main.inc.php]
// Quota Retrieval System $rcmail_config['quota'] = array( 'backend' => 'imap', 'zero_as_unlimited' => TRUE);
$rcmail_config['quota'] = array( 'backend' => 'cmd', 'program' => '/usr/bin/quota', 'program_parameters' => '-f /filesystem -v', 'zero_as_unlimited' => TRUE);
well, that's all
Hey Leinier,
we are very open to your code, however, would opening a ticket1 and attaching a patch to it work for you? That's the recommended way to contribute code.
In general, personally, I'm very open to enhancing the quota system since not everyone runs IMAP servers capable of advertising the quota. :)
Cheers, Till
List info: http://lists.roundcube.net/dev/
El dom, 13-12-2009 a las 18:53 +0100, till escribió:
On Sun, Dec 13, 2009 at 12:33 AM, Leinier Cruz Salfran salfrancl@ipigto.rimed.cu wrote:
hello all
i want to share some modifications i made to roundcube code in order to get quota work .. i made this because i manage a computer with apache (only) and other with smtp and imap (only) and i want the user may be able to see his/her quota
Hey Leinier,
we are very open to your code, however, would opening a ticket1 and attaching a patch to it work for you? That's the recommended way to contribute code.
hello
i entered that site but i saw a lot of open tickets (mmmmm) .. i'll follow your advice and i'll use that site .. thanks
In general, personally, I'm very open to enhancing the quota system since not everyone runs IMAP servers capable of advertising the quota. :)
Cheers, Till
List info: http://lists.roundcube.net/dev/
Leinier Cruz Salfran wrote:
i entered that site but i saw a lot of open tickets (mmmmm) .. i'll follow your advice and i'll use that site .. thanks
I've added 'quota' hook. I think writing a plugin for such feature will be better.
Leinier Cruz Salfran wrote:
i entered that site but i saw a lot of open tickets (mmmmm)
Actually there's only one. http://trac.roundcube.net/ticket/1484793
El dom, 13-12-2009 a las 19:30 +0100, A.L.E.C escribió:
Leinier Cruz Salfran wrote:
i entered that site but i saw a lot of open tickets (mmmmm) .. i'll follow your advice and i'll use that site .. thanks
I've added 'quota' hook. I think writing a plugin for such feature will be better.
oh yes .. the right quota hook will be launched depending of 'backend' .. you will use the configuration variables that i suggested?
List info: http://lists.roundcube.net/dev/
El dom, 13-12-2009 a las 19:37 +0100, A.L.E.C escribió:
Leinier Cruz Salfran wrote:
i entered that site but i saw a lot of open tickets (mmmmm)
Actually there's only one. http://trac.roundcube.net/ticket/1484793
i saw
i made a modification because the old code doesn't process well the result of 'quota' program .. this code make it correct
case 'cmd':
$user = split("@", $RCMAIL->user->get_username());
exec($CONFIG['quota']['program'] ." ".
$CONFIG['quota']['program_parameters'] ." ". $user[0], $result); $field_number = 0; foreach (preg_split('/\s/', trim($result[2])) as $quota_field) { if (strlen($quota_field) > 0) { switch ($field_number) { case 1: $quota['used'] = $quota_field; if (substr($quota['used'], -1) == '*') { $quota['used'] = substr($quota['used'], 0, -1); } break; case 2: $quota['total'] = $quota_field; break; } $field_number++; } } $quota['percent'] = (($quota['used'] * 100) / $quota['total']); break;
List info: http://lists.roundcube.net/dev/
El dom, 13-12-2009 a las 15:57 -0500, Leinier Cruz Salfran escribió:
El dom, 13-12-2009 a las 19:37 +0100, A.L.E.C escribió:
Leinier Cruz Salfran wrote:
i entered that site but i saw a lot of open tickets (mmmmm)
Actually there's only one. http://trac.roundcube.net/ticket/1484793
i saw
i made a modification because the old code doesn't process well the result of 'quota' program .. this code make it correct
case 'cmd': $user = split("@", $RCMAIL->user->get_username()); exec($CONFIG['quota']['program'] ." ".
$CONFIG['quota']['program_parameters'] ." ". $user[0], $result); $field_number = 0; foreach (preg_split('/\s/', trim($result[2])) as $quota_field) { if (strlen($quota_field) > 0) { switch ($field_number) { case 1: $quota['used'] = $quota_field; if (substr($quota['used'], -1) == '*') { $quota['used'] = substr($quota['used'], 0, -1); } break; case 2:
sorry by this .. it is not '2' but '3'
case 1:
$quota['used'] = $quota_field;
if (substr($quota['used'], -1) == '*') { $quota['used']
= subst break; case 3: $quota['total'] = $quota_field; break;
field '2' is 'soft_limit' .. '3' is 'hard_limit' (the real limit)
$quota['total'] = $quota_field; break; } $field_number++; } } $quota['percent'] = (($quota['used'] * 100) / $quota['total']); break;
List info: http://lists.roundcube.net/dev/
List info: http://lists.roundcube.net/dev/