Example #1
0
<?php

include 'classes.php';
echo "auto include <BR>";
sm_include('Messages');
$msg =& new messages('imap', array('username' => 'username', 'host' => 'localhost', 'password' => 'password', 'port' => 143, 'type' => 'imap'));
echo '<pre>';
if ($msg->Connect()) {
    $msg->login();
} else {
    echo "boeeeeeee";
}
exit;
Example #2
0
 function messages($id, $properties)
 {
     /* initialise folderproperties */
     /* also set the global defaults.
           the value of the properties is in de following form:
           array('value',int) with array[0] the actual value and array[1] WRITE|READ|LOOKUP access.
           WRITE access should be set on init where the admin prefs with ACL's are read. Those
           ACL's also contains information about if it's allowed to override admin prefs by user
           preferences. If the user may change the pref then those changes are stored in the 
           userpref location. 
           In the end a simple read/write/lookup is left. 
           
           Second thought, value is not an array, those arrays with ACL should be created when
           the user hits the config module. Messages should not contain config change stuff, Just
           feed it with the configuration and handle read/write/lookup access to preferences somewhere
           else.
           
           Before the messages class is loaded the actual properties array is a mix from admin prefs
           / userprefs. The Acl's on the prefs decides which one is stored in the properties.
        */
     $aFolderProps = array('prefix' => '', 'special' => array('SENT' => false, 'DRAFTS' => false, 'TRASH' => false, 'CONTACTS' => false, 'CALENDAR' => false, 'TODO' => false, 'NOTES' => false, 'EVENTS' => false), 'default_sort_dir' => 0, 'default_sort_hdr' => 'date', 'default_move_to_trash' => false, 'default_auto_expunge' => false, 'default_initial_mailbox' => false, 'default_initial_tree' => 'lsub', 'default_namespace' => array());
     $this->id = $id;
     $this->type = $properties['type'];
     /* imap, (pop3, nntp) */
     $this->host = $properties['host'];
     /* including ssl:// or tls:// */
     $this->port = $properties['port'];
     $this->username = $properties['username'];
     $this->password = $properties['password'];
     if (isset($properties['decrypt']) && isset($properties['enc_password'])) {
         /* callback function */
         $this->password = $this->properties['decrypt']($this->properties['enc_password']);
     } else {
         if (isset($properties['password'])) {
             $this->password = $properties['password'];
         }
     }
     if (isset($properties['ignore_capability'])) {
         $this->ignore_capability = $properties['ignore_capability'];
     }
     /* folder settings merged with defaults */
     if (isset($properties['folders'])) {
         $aFolderProps = $properties['folders'];
         foreach ($aFolderProps as $key => $value) {
             $aFolderProps[$key] = $value;
         }
     }
     $this->aFolderProps = $aFolderProps;
     if (isset($properties['cached_lsub'])) {
         /* cached data format: array (expirationtime, cached folders, streamformat */
         if (time() < $properties['cached_lsub'][0]) {
             $lsub_tree = new mailboxlist();
             $lsub_tree->loadFromStream($properties['cached_lsub'][1], $properties['cached_lsub'][2]);
             $this->folders_lsub = $lsub_tree;
         }
     }
     if (isset($properties['cached_list'])) {
         /* cached data format: array (expirationtime, cached folders, streamformat */
         if (time < $properties['cached_list'][0]) {
             $list_tree = new mailboxlist();
             $list_tree->loadFromStream($properties['cached_list'][1], $properties['cached_list'][2]);
             $this->folders_list = $lsub_tree;
         }
     }
     /* attach the backend code */
     $backend = $this->type . '_backend';
     /* include the backend. dependencies are resolved with help from central file with locations
        and depencies */
     sm_include($backend);
     /* auto set the resource on a connect */
     $this->backend =& new $backend(&$this->resource);
     /* TODO:
           define a set of capabilities for the message class which can be disabled by the
           backend class so we can decide inside messages which methods are supported.
        */
     /* global permissions regarding sort, thread, filter */
     /* TODO
     		DEFAULTACL
     		ALLOW_THREAD
     		ALLOW_SORT
     		ALLOW_FILTER
     		ALLOW_PREVIEW
             */
 }
Example #3
0
<?php

include 'classes.php';
sm_include('mailboxtree');
include 'config.php';
sm_include('Messages');
sm_include('imap_backend');
session_start();
global $msg;
if (!isset($_SESSION["msg"])) {
    $msg =& new messages('imap', array('username' => $username, 'host' => $host, 'password' => $password, 'port' => $port, 'type' => 'imap'));
    $_SESSION["msg"] =& $msg;
} else {
    $msg =& $_SESSION["msg"];
}
$aTreeProps = array();
echo '<pre>';
if ($msg->Connect()) {
    $msg->login($username, $password, $host);
} else {
    echo "LOGIN FAILED";
}
if (isset($_POST['refresh']) && $_POST['refresh']) {
    if (isset($msg->mailboxtree_LIST)) {
        unset($msg->mailboxtree_LIST);
    }
}
if (isset($_POST['showlabel']) && $_POST['showlabel']) {
    $aTreeProps['showlabel'] = true;
    $_POST['showlabel'] = true;
} else {