On Sun, Dec 13, 2009 at 12:33 AM, Leinier Cruz Salfran <[email protected]> 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 > [email protected] /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 ticket[1] 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 [1]: http://trac.roundcube.net/ _______________________________________________ List info: http://lists.roundcube.net/dev/
