<?php

class custom_quota extends rcube_plugin
{
	public $task = 'mail';

	function init()
	{
		$rcmail = rcube::get_instance();
		if ($rcmail->task == '' || $rcmail->task == 'mail') {
			// ensure quota display is always enabled
			$rcmail->output->set_env('quota', true);
		}

		// attach to plugin hook
		$this->add_hook('quota', array($this, 'fetch_quota'));
	}

	public function fetch_quota($p)
	{
		// only update quota info if none was return from IMAP server
		if (!isset($p['total'])) {
			// custom code goes here.....

			// example result..
			// total available space in kilobytes
			$p['total'] = 1000;
			// total used space in kilobytes
			$p['used'] = 44;
			// stub for special key used in core for more detailed quota info
			// do not modify
			$p['all'] = array();
		}

		return $p;
	}
}
