$id = Banana::$spool->ids[$id];
}
$options = array ('-m ' . $id);
- if (Banana::$spool->overview) {
- if (Banana::$spool->overview[$id]) {
- $options[] = '-p ' . $id . ':' . Banana::$spool->overview[$id]->storage['offset'];
- } else {
- $key = max(array_keys(Banana::$spool->overview));
- if ($key < $id) {
- $options[] = '-p ' . $key . ':' . Banana::$spool->overview[$key]->storage['offset'];
- }
- }
- }
+ $this->getMBoxPosition($options, $id);
return $this->callHelper('-b', $options);
}
private function getCount()
{
$options = array();
- if (Banana::$spool->overview) {
- $key = max(array_keys(Banana::$spool->overview));
- $options[] = '-p ' . $key . ':' . Banana::$spool->overview[$key]->storage['offset'];
- }
+ $this->getMBoxPosition($options);
$val =& $this->callHelper('-c', $options);
if (!$val) {
return 0;
$headers = null;
$options = array();
$options[] = "-m $firstid:$lastid";
- if (Banana::$spool->overview) {
- if (isset(Banana::$spool->overview[$firstid])) {
- $options[] = '-p ' . $firstid . ':' . Banana::$spool->overview[$firstid]->storage['offset'];
- } else {
- $key = max(array_keys(Banana::$spool->overview));
- if ($key < $firstid) {
- $options[] = '-p ' . $key . ':' . Banana::$spool->overview[$key]->storage['offset'];
- }
- }
- }
+ $this->getMboxPosition($options, $firstid);
$lines =& $this->callHelper('-d', $options, $msg_headers);
if (!$lines) {
return $headers;
#######
# MBox parser
#######
+
+ /** Add the '-p' optioin for callHelper
+ */
+ private function getMBoxPosition(array &$option, $id = null)
+ {
+ if (Banana::$spool->overview) {
+ if (!is_null($id) && Banana::$spool->overview[$id]) {
+ $key = $id;
+ } else {
+ $key = max(array_keys(Banana::$spool->overview));
+ if (!is_null($id) && $key >= $id) {
+ return;
+ }
+ }
+ if (isset(Banana::$spool->overview[$key]->storage['offset'])) {
+ $options[] = '-p ' . $key . ':' . Banana::$spool->overview[$key]->storage['offset'];
+ }
+ }
+ }
private function &callHelper($action, array $options = array(), array $headers = array())
{
exec($cmd, $out, $return);
if ($this->debug) {
$this->bt[] = array('action' => $cmd, 'time' => (microtime(true) - $start),
- 'code' => $return, 'response' => count($out));
+ 'code' => $return, 'response' => count($out), 'error' => $return ? "Helper failed" : null);
}
if ($return != 0) {
$this->_lasterrorno = 1;