[imp] Here is a sample horde quota driver for dbmail-2

jacques-beaudoin@cspi.qc.ca jacques-beaudoin at cspi.qc.ca
Wed Oct 4 22:56:34 PDT 2006


Hi,

If any dbmail users nead to show quotas in horde/imp

This sample command.php will do it... enjoy

Best Regards

Jacques-Beaudoin at cspi.qc.ca


<?php
#
#    Horde quota driver for DBMAIL-2
#
#    Jacques-Beaudoin at cspi.qc.ca
#
#    Pointe de l'Ile school board,  Montréal
#
#    You must configure this in horde/imp/config/servers.php.
#
#   'quota' => array(
#       'driver' => 'command',
#       'params' => array(
#          'quota_path' => '/usr/bin/quota',
#          'grep_path'  => '/bin/grep'
#       )
#    )
#
#    but for code simplicity I don't use any
#    of these variables in my code
#
##################################################
#  Best methode: Gets quota directly with MYSQL  #
##################################################

   class IMP_Quota_command extends IMP_Quota {

      function getQuota() {

          global $imp;

          $imap_user = strtolower($imp['user']);

            if (mysql_connect ("localhost","horde","dbmail")) {
            }
            else {echo 'Mysql connect error...'.mysql_error();
            }

          mysql_select_db ('dbmail') or die ('Mysql select  
error...'.mysql_error());

          $sql = "SELECT curmail_size,maxmail_size FROM dbmail_users  
WHERE userid = '$imap_user'";

          $result = mysql_query ($sql);

          $usage = mysql_fetch_array($result);

          mysql_close();

          return array('usage' => $usage[0] , 'limit' => $usage[1]);
     }
   }

##################################################
#  Second methode: Gets quota with dbmail_users  #
##################################################
#
#  class IMP_Quota_command extends IMP_Quota {
#
#  function getQuota() {
#
#  global $imp;
#
#  $imap_user = strtolower($imp['user']);
#
#  $cmdline = "/usr/local/sbin/dbmail-users -l $imap_user | grep  
'Quotum' | sed 's/ //g' | sed 's/.*://' | sed 's/MB.*//'";
#  $junk = exec($cmdline, $usage_data, $return_code);
#  $usage = trim($usage_data[0]);
#
#  $cmdline = "/usr/local/sbin/dbmail-users -l $imap_user | grep  
'mailboxsize' | sed 's/ //g' | sed 's/.*://' | sed 's/MB.*//'";
#  $junk = exec($cmdline, $limit_data, $return_code);
#  $limit = trim($limit_data[0]);
#
#  return array('usage' => $usage * 1048576 , 'limit' => $limit * 1048576);
#
#  } }
#
###################################################

?>














More information about the imp mailing list