예제 #1
0
<?php

/**
 * phpari - A PHP Class Library for interfacing with Asterisk(R) ARI
 * Copyright (C) 2014  Nir Simionovich
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * Also add information on how to contact you by electronic and paper mail.
 *
 * Greenfield Technologies Ltd., hereby disclaims all copyright interest in
 * the library `phpari' (a library for creating smart telephony applications)
 * written by Nir Simionovich and its respective list of contributors.
 */
require_once "../vendor/autoload.php";
$conn = new phpari("hello-world");
//create new object
$mailboxes = new mailboxes($conn);
echo json_encode($mailboxes->mailboxes_list());
exit(0);
function sqimap_fill_mailbox_tree($mbx_ary, $mbxs = false)
{
    global $data_dir, $username, $list_special_folders_first, $folder_prefix, $trash_folder, $sent_folder, $draft_folder, $move_to_trash, $move_to_sent, $save_as_draft, $delimiter;
    $special_folders = array('INBOX', $sent_folder, $draft_folder, $trash_folder);
    /* create virtual root node */
    $mailboxes = new mailboxes();
    $mailboxes->is_root = true;
    $trail_del = false;
    if (isset($folder_prefix) && $folder_prefix != '') {
        $start = substr_count($folder_prefix, $delimiter);
        if (strrpos($folder_prefix, $delimiter) == strlen($folder_prefix) - 1) {
            $trail_del = true;
            $mailboxes->mailboxname_full = substr($folder_prefix, 0, strlen($folder_prefix) - 1);
        } else {
            $mailboxes->mailboxname_full = $folder_prefix;
            $start++;
        }
        $mailboxes->mailboxname_sub = $mailboxes->mailboxname_full;
    } else {
        $start = 0;
    }
    $cnt = count($mbx_ary);
    for ($i = 0; $i < $cnt; $i++) {
        if ($mbx_ary[$i]['mbx'] != '') {
            $mbx = new mailboxes();
            $mailbox = $mbx_ary[$i]['mbx'];
            switch ($mailbox) {
                case 'INBOX':
                    $mbx->is_inbox = true;
                    $mbx->is_special = true;
                    break;
                case $trash_folder:
                    $mbx->is_trash = true;
                    $mbx->is_special = true;
                    break;
                case $sent_folder:
                    $mbx->is_sent = true;
                    $mbx->is_special = true;
                    break;
                case $draft_folder:
                    $mbx->is_draft = true;
                    $mbx->is_special = true;
                    break;
            }
            if (isset($mbx_ary[$i]['unseen'])) {
                $mbx->unseen = $mbx_ary[$i]['unseen'];
            }
            if (isset($mbx_ary[$i]['nummessages'])) {
                $mbx->total = $mbx_ary[$i]['nummessages'];
            }
            $mbx->is_noselect = $mbx_ary[$i]['noselect'];
            $r_del_pos = strrpos($mbx_ary[$i]['mbx'], $delimiter);
            if ($r_del_pos) {
                $mbx->mailboxname_sub = substr($mbx_ary[$i]['mbx'], $r_del_pos + 1);
            } else {
                /* mailbox is root folder */
                $mbx->mailboxname_sub = $mbx_ary[$i]['mbx'];
            }
            $mbx->mailboxname_full = $mbx_ary[$i]['mbx'];
            $mailboxes->addMbx($mbx, $delimiter, $start, $list_special_folders_first);
        }
    }
    return $mailboxes;
}
예제 #3
0
function sqimap_fill_mailbox_tree($mbx_ary, $mbxs = false, $imap_stream)
{
    global $data_dir, $username, $list_special_folders_first, $folder_prefix, $trash_folder, $sent_folder, $draft_folder, $move_to_trash, $move_to_sent, $save_as_draft, $delimiter, $imap_server_type;
    $special_folders = array('INBOX', $sent_folder, $draft_folder, $trash_folder);
    /* create virtual root node */
    $mailboxes = new mailboxes();
    $mailboxes->is_root = true;
    $trail_del = false;
    $start = 0;
    if (isset($folder_prefix) && $folder_prefix != '') {
        $start = substr_count($folder_prefix, $delimiter);
        if (strrpos($folder_prefix, $delimiter) == strlen($folder_prefix) - 1) {
            $trail_del = true;
            $mailboxes->mailboxname_full = substr($folder_prefix, 0, strlen($folder_prefix) - 1);
        } else {
            $mailboxes->mailboxname_full = $folder_prefix;
            $start++;
        }
        $mailboxes->mailboxname_sub = $mailboxes->mailboxname_full;
    } else {
        $start = 0;
    }
    $cnt = count($mbx_ary);
    for ($i = 0; $i < $cnt; $i++) {
        if ($mbx_ary[$i]['mbx'] != '') {
            $mbx = new mailboxes();
            $mailbox = $mbx_ary[$i]['mbx'];
            /*
                sent subfolders messes up using existing code as subfolders
                were marked, but the parents were ordered somewhere else in
                the list, despite having "special folders at top" option set.
                Need a better method than this.
            */
            /*
                        if ($mailbox == 'INBOX') {
                            $mbx->is_special = true;
                        } elseif (stristr($trash_folder , $mailbox)) {
                            $mbx->is_special = true;
                        } elseif (stristr($sent_folder , $mailbox)) {
                            $mbx->is_special = true;
                        } elseif (stristr($draft_folder , $mailbox)) {
                            $mbx->is_special = true;
                        }
            
                        switch ($mailbox) {
                            case 'INBOX':
                                $mbx->is_inbox = true;
                                $mbx->is_special = true;
                                $mbx_ary[$i]['noselect'] = false;
                                break;
                            case $trash_folder:
                                $mbx->is_trash = true;
                                $mbx->is_special = true;
                                break;
                            case $sent_folder:
                                $mbx->is_sent = true;
                                $mbx->is_special = true;
                                break;
                            case $draft_folder:
                                $mbx->is_draft = true;
                                $mbx->is_special = true;
                                break;
                        }
            */
            $mbx->is_special |= $mbx->is_inbox = strtoupper($mailbox) == 'INBOX';
            $mbx->is_special |= $mbx->is_trash = isTrashMailbox($mailbox);
            $mbx->is_special |= $mbx->is_sent = isSentMailbox($mailbox);
            $mbx->is_special |= $mbx->is_draft = isDraftMailbox($mailbox);
            if (!$mbx->is_special) {
                $mbx->is_special = boolean_hook_function('special_mailbox', $mailbox, 1);
            }
            if (isset($mbx_ary[$i]['unseen'])) {
                $mbx->unseen = $mbx_ary[$i]['unseen'];
            }
            if (isset($mbx_ary[$i]['nummessages'])) {
                $mbx->total = $mbx_ary[$i]['nummessages'];
            }
            $mbx->is_noselect = $mbx_ary[$i]['noselect'];
            $mbx->is_noinferiors = $mbx_ary[$i]['noinferiors'];
            $r_del_pos = strrpos($mbx_ary[$i]['mbx'], $delimiter);
            if ($r_del_pos) {
                $mbx->mailboxname_sub = substr($mbx_ary[$i]['mbx'], $r_del_pos + 1);
            } else {
                /* mailbox is root folder */
                $mbx->mailboxname_sub = $mbx_ary[$i]['mbx'];
            }
            $mbx->mailboxname_full = $mbx_ary[$i]['mbx'];
            $mailboxes->addMbx($mbx, $delimiter, $start, $list_special_folders_first);
        }
    }
    sqimap_utf7_decode_mbx_tree($mailboxes);
    sqimap_get_status_mbx_tree($imap_stream, $mailboxes);
    return $mailboxes;
}
예제 #4
0
/**
 * Fills mailbox object
 *
 * Some code fragments are present in 1.3.0 - 1.4.4.
 * @param array $mbx_ary
 * @param $mbxs
 * @param stream $imap_stream imap connection resource
 * @return object see mailboxes class
 * @since 1.5.0
 */
function sqimap_fill_mailbox_tree($mbx_ary, $mbxs = false, $imap_stream)
{
    global $data_dir, $username, $list_special_folders_first, $folder_prefix, $trash_folder, $sent_folder, $draft_folder, $move_to_trash, $move_to_sent, $save_as_draft, $delimiter, $imap_server_type;
    // $special_folders = array ('INBOX', $sent_folder, $draft_folder, $trash_folder);
    /* create virtual root node */
    $mailboxes = new mailboxes();
    $mailboxes->is_root = true;
    $trail_del = false;
    $start = 0;
    if (isset($folder_prefix) && $folder_prefix != '') {
        $start = substr_count($folder_prefix, $delimiter);
        if (strrpos($folder_prefix, $delimiter) == strlen($folder_prefix) - 1) {
            $mailboxes->mailboxname_full = substr($folder_prefix, 0, strlen($folder_prefix) - 1);
        } else {
            $mailboxes->mailboxname_full = $folder_prefix;
            $start++;
        }
        $mailboxes->mailboxname_sub = $mailboxes->mailboxname_full;
    } else {
        $start = 0;
    }
    $cnt = count($mbx_ary);
    for ($i = 0; $i < $cnt; $i++) {
        if ($mbx_ary[$i]['mbx'] != '') {
            $mbx = new mailboxes();
            $mailbox = $mbx_ary[$i]['mbx'];
            /*
             * Set the is_special flag if it concerned a special mailbox.
             * Used for displaying the special folders on top in the mailbox
             * tree displaying code.
             */
            $mbx->is_special |= $mbx->is_inbox = strtoupper($mailbox) == 'INBOX';
            $mbx->is_special |= $mbx->is_trash = isTrashMailbox($mailbox);
            $mbx->is_special |= $mbx->is_sent = isSentMailbox($mailbox);
            $mbx->is_special |= $mbx->is_draft = isDraftMailbox($mailbox);
            if (!$mbx->is_special) {
                $mbx->is_special = boolean_hook_function('special_mailbox', $mailbox, 1);
            }
            if (isset($mbx_ary[$i]['unseen'])) {
                $mbx->unseen = $mbx_ary[$i]['unseen'];
            }
            if (isset($mbx_ary[$i]['nummessages'])) {
                $mbx->total = $mbx_ary[$i]['nummessages'];
            }
            $mbx->is_noselect = $mbx_ary[$i]['noselect'];
            $mbx->is_noinferiors = $mbx_ary[$i]['noinferiors'];
            $r_del_pos = strrpos($mbx_ary[$i]['mbx'], $delimiter);
            if ($r_del_pos) {
                $mbx->mailboxname_sub = substr($mbx_ary[$i]['mbx'], $r_del_pos + 1);
            } else {
                /* mailbox is root folder */
                $mbx->mailboxname_sub = $mbx_ary[$i]['mbx'];
            }
            $mbx->mailboxname_full = $mbx_ary[$i]['mbx'];
            $mailboxes->addMbx($mbx, $delimiter, $start, $list_special_folders_first);
        }
    }
    sqimap_utf7_decode_mbx_tree($mailboxes);
    sqimap_get_status_mbx_tree($imap_stream, $mailboxes);
    return $mailboxes;
}
예제 #5
0
<?php

/**
 * phpari - A PHP Class Library for interfacing with Asterisk(R) ARI
 * Copyright (C) 2014  Nir Simionovich
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 * Also add information on how to contact you by electronic and paper mail.
 *
 * Greenfield Technologies Ltd., hereby disclaims all copyright interest in
 * the library `phpari' (a library for creating smart telephony applications)
 * written by Nir Simionovich and its respective list of contributors.
 */
require_once "../vendor/autoload.php";
$conn = new phpari("hello-world");
//create new object
$mailboxes = new mailboxes($conn);
echo json_encode($mailboxes->mailbox_change_state('testMailBox', 0, 0));
exit(0);