* @copyright 2005-2006 The SquirrelMail Project Team, Alexandros Vellis * @license http://opensource.org/licenses/gpl-license.php GNU Public License * @version $Id: annotate_tests.php,v 1.2 2006/11/01 11:56:45 avel Exp $ * @package plugins * @subpackage imapmetadata */ if (file_exists('../../include/init.php')) { include_once('../../include/init.php'); } else if (file_exists('../../include/validate.php')) { define('SM_PATH','../../'); require_once(SM_PATH . 'include/validate.php'); require_once(SM_PATH . 'functions/global.php'); } require_once(SM_PATH . 'functions/imap.php'); require_once(SM_PATH . 'plugins/imapmetadata/imap_annotate.php'); require_once(SM_PATH . 'functions/date.php'); require_once(SM_PATH . 'functions/mime.php'); require_once(SM_PATH . 'functions/mailbox_display.php'); require_once(SM_PATH . 'functions/html.php'); require_once(SM_PATH . 'functions/plugin.php'); /* lets get the global vars we may need */ sqgetGlobalVar('key', $key, SQ_COOKIE); sqgetGlobalVar('username', $username, SQ_SESSION); sqgetGlobalVar('onetimepad',$onetimepad, SQ_SESSION); sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); sqgetGlobalVar('base_uri', $base_uri, SQ_SESSION); sqgetGlobalVar('imapmetadatatest', $imapmetadatatest, SQ_GET); $imapConnection = sqimap_login($username, $key, $imapServerAddress, $imapPort, 0); // Sample ways to call sqimap_get_annotation(): // // $annotations = sqimap_get_annotation($imapConnection, '*', '/*', array('value')); // $annotations = sqimap_get_annotation($imapConnection, '*', '/*', array('value.shared')); // $annotations = sqimap_get_annotation($imapConnection, 'INBOX', '/comment', array('value.shared')); /* Presentation */ // displayPageHeader($color, 'None'); echo '
'.$entry.' | '; foreach($attributes as $attr => $values) { echo ''.$attr.' is: '; foreach($values as $scope => $val) { echo ''.htmlspecialchars($val).' ('.$scope.') '; } echo ' |
dtree is ©2002-2003 Geir Landrö
'; } break; case 'set': case 'delete': $boxes = sqimap_mailbox_list_all($imapConnection); $mailbox = "INBOX"; $entry = "/comment"; $attribute = "value"; $scope = 'priv'; $value = 'This is a test.'; sqgetGlobalVar('mailbox', $mailbox, SQ_POST); sqgetGlobalVar('entry', $entry, SQ_POST); sqgetGlobalVar('attribute', $attribute, SQ_POST); sqgetGlobalVar('scope', $scope, SQ_POST); sqgetGlobalVar('value', $value, SQ_POST); sqgetGlobalVar('addannotation', $addannotation, SQ_POST); sqgetGlobalVar('deleteannotation', $deleteannotation, SQ_POST); echo ''; if(isset($addannotation)) { if(sqimap_set_annotation($imapConnection, $mailbox, $entry, array($attribute.'.'.$scope => $value), $response, $message, true)) { echo 'SETANNOTATION succeeded with adding/replacing annotation! :-)
'; } else { echo 'SETANNOTATION failed! Could not add/replace annotation. :-(
'; } } elseif(isset($deleteannotation)) { if(sqimap_delete_annotation($imapConnection, $mailbox, $entry, array($attribute.'.'.$scope), $response, $message, true)) { echo 'SETANNOTATION succeeded with deleting annotation! :-)
'; } else { echo 'SETANNOTATION failed! Could not delete annoation! :-(
'; } } break; } function dtree_recursive_array($array, $parent=0){ $space=""; global $counter; if(!isset($counter)) { $counter = 1; } if(is_array($array)){ while (list ($x, $tmp) = each ($array)){ echo "d.add($counter, $parent, '".$x."', '', '', ''"; if($x == 'shared') { echo ",'img/globe.gif', 'img/globe.gif'"; } elseif($x == 'priv') { echo ",'img/imgfolder.gif', 'img/imgfolder.gif'"; } echo ");\n"; $counter++; echo dtree_recursive_array($tmp, $counter-1); } } else { echo "d.add($counter, $parent, '$array');\n"; $counter++; } } /** * Print mailbox select widget. * * @param string $selectname name for the select HTML variable * @param string $selectedmbox which mailbox to be selected in the form * @param boolean $sub * @return string */ function imapmetadata_mailboxlist($selectname, $selectedmbox, $sub = false) { global $boxes_append, $boxes_admin, $imap_server_type, $default_sub_of_inbox; if(isset($boxes_admin) && $sub) { $boxes = $boxes_admin; } elseif(isset($boxes_append)) { $boxes = $boxes_append; } else { global $boxes; } if (count($boxes)) { $mailboxlist = '