* @package plugins * @subpackage ldapfolderinfo */ 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/plugin.php'); require_once(SM_PATH . 'functions/html.php'); } /* SquirrelMail required files. */ require_once(SM_PATH . 'functions/imap.php'); /* LDAP stuff */ include_once(SM_PATH . 'plugins/ldapuserdata/functions.php'); include_once(SM_PATH . 'plugins/ldapfolderinfo/include/functions.inc.php'); include_once(SM_PATH . 'plugins/useracl/imap_acl.php'); global $ldap, $folderattributes, $ldap_base_dn, $permarray, $username; /* get globals we may need */ sqgetGlobalVar('username', $username, SQ_SESSION); sqgetGlobalVar('key', $key, SQ_COOKIE); sqgetGlobalVar('delimiter', $delimiter, SQ_SESSION); sqgetGlobalVar('onetimepad', $onetimepad, SQ_SESSION); sqgetGlobalVar('success', $success, SQ_GET); /* end of get globals */ $imapConnection = sqimap_login ($username, $key, $imapServerAddress, $imapPort, 0); // force retrieval of a non cached folderlist $boxes = sqimap_mailbox_list($imapConnection,true); /* Actions */ /* Actions are handled ATM by existing Squirrelmail scripts. */ /* if( (isset($_POST['subscribe']) || isset($_POST['unsubscribe']) ) && isset($_POST['mailbox']) ) { $mailbox = $_POST['mailbox']; if (isset($_POST['subscribe'])) { if($no_list_for_subscribe && $imap_server_type == 'cyrus') { if(!sqimap_mailbox_exists($imapConnection, $mailbox[0])) { header("Location: $location/folders.php?success=subscribe-doesnotexist"); sqimap_logout($imapConnection); exit(0); } } for ($i=0; $i < count($mailbox); $i++) { $mailbox[$i] = trim($mailbox[$i]); sqimap_subscribe ($imapConnection, $mailbox[$i]); } $success = 'subscribe'; } elseif($_POST['unsubscribe']) { for ($i=0; $i < count($mailbox); $i++) { $mailbox[$i] = trim($mailbox[$i]); sqimap_unsubscribe ($imapConnection, $mailbox[$i]); } $success = 'unsubscribe'; } } */ $boxes_all = sqimap_mailbox_list_all ($imapConnection); sqimap_logout($imapConnection); $folderinfo = ldapfolderinfo_cache_ldap($boxes_all); /** * ================== Presentation Logic ================== */ displayPageHeader($color, 'None'); bindtextdomain ('ldapfolderinfo', SM_PATH . 'plugins/ldapfolderinfo/locale'); textdomain ('ldapfolderinfo'); echo '
' . html_tag( 'table', '', 'center', $color[0], 'width="95%" cellpadding="1" cellspacing="0" border="0"' ) . html_tag( 'tr' ) . html_tag( 'td', '', 'center' ) . '' . _("Folders") . '' . html_tag( 'table', '', 'center', '', 'width="100%" cellpadding="5" cellspacing="0" border="0"' ) . html_tag( 'tr' ) . html_tag( 'td', '', 'center', $color[4] ); if ( isset($success) && $success ) { $td_str = ''; switch ($success) { case 'subscribe': $td_str .= _("Subscribed successfully!"); break; case 'unsubscribe': $td_str .= _("Unsubscribed successfully!"); break; case 'subscribe-doesnotexist': $td_str .= _("Subscription Unsuccessful - Folder does not exist."); break; } $td_str .= '
'; /* Subscribed Folders */ echo html_tag( 'table', html_tag( 'tr', html_tag( 'td', $td_str . '' . _("refresh folder list") . '' , 'center' ) ) , 'center', '', 'width="100%" cellpadding="4" cellspacing="0" border="0"' ); } echo "\n
"; /** * -------------------- UNSUBSCRIBE FOLDERS -------------------- */ echo html_tag( 'table', '', 'center', '', 'width="95%" cellpadding="4" cellspacing="0" border="0"' ) . html_tag( 'tr', html_tag( 'td', '' . _("Unsubscribe") . '', 'center', $color[9], 'colspan="2"' ) ) . html_tag( 'tr' ) . html_tag( 'td', '', 'center', $color[0], 'width="100%"' ); /* if ($count_special_folders < count($boxes)) { */ /* WTF? #1 */ echo '
'; echo _("You are already subscribed to these folders:") . '
'; echo ''; $toggle = false; for ($i = 0; $i < count($boxes); $i++) { $use_folder = true; if ((strtolower($boxes[$i]["unformatted"]) != "inbox") && ($boxes[$i]["unformatted"] != $trash_folder) && ($boxes[$i]["unformatted"] != $sent_folder) && ($boxes[$i]["unformatted"] != $draft_folder)) { $box = $boxes[$i]["unformatted-dm"]; $box2 = str_replace(' ', ' ', imap_utf7_decode_local($boxes[$i]["unformatted-disp"])); echo ''; /* Checked? */ echo ''; echo ''; } if(!$toggle) { $toggle = true; } elseif($toggle) { $toggle = false; } } echo '
'.$box2.''; if(isset($folderinfo[$box]['description'])) { echo $folderinfo[$box]['description']; } echo '
'; echo '

'; echo '
'; /** * -------------------- SUBSCRIBE TO FOLDERS (1) -------------------------- */ echo html_tag( 'table', '', 'center', '', 'width="95%" cellpadding="4" cellspacing="0" border="0"' ) . html_tag( 'tr', html_tag( 'td', '' . _("Subscribe to Global Folders") . '', 'center', $color[9], 'colspan="2"' ) ) . html_tag( 'tr' ) . html_tag( 'td', '', 'center', $color[0], 'width="100%"' ); $box = ''; $box2 = ''; for ($i = 0, $q = 0; $i < count($boxes_all); $i++) { $use_folder = true; for ($p = 0; $p < count ($boxes); $p++) { if ($boxes_all[$i]['unformatted'] == $boxes[$p]['unformatted']) { $use_folder = false; continue; } else if ($boxes_all[$i]['unformatted-dm'] == $folder_prefix) { $use_folder = false; } } if ($use_folder == true) { $box[$q] = $boxes_all[$i]['unformatted-dm']; $box2[$q] = str_replace(' ', ' ', imap_utf7_decode_local($boxes_all[$i]['unformatted-disp'])); $q++; } } if ($box && $box2) { echo '
'; echo _("You can subscribe to the following global shared folders of this system:") . '

'; echo ''; for ($q = 0; $q < count($box); $q++) { if(!ereg("^user\.",$box[$q])) { echo ''; echo ''; echo ''; echo ''; if(!$toggle) { $toggle = true; } elseif($toggle) { $toggle = false; } } } echo '
'; if(isset($folderinfo[$box[$q]]['description'])) { echo $folderinfo[$box[$q]]['description']; } echo '
'; echo '

' . '\n" . '
'; } else { echo _("No folders were found to subscribe to!"); } echo '
'; /* * --------------- SUBSCRIBE TO OTHER USERS' FOLDERS (2) ------------- */ echo html_tag( 'table', '', 'center', '', 'width="95%" cellpadding="4" cellspacing="0" border="0"' ) . html_tag( 'tr', html_tag( 'td', '' . _("Subscribe to Folders shared by Other Users") . '', 'center', $color[9], 'colspan="2"' ) ) . html_tag( 'tr' ) . html_tag( 'td', '', 'center', $color[0], 'width="100%"' ). '
'; echo _("Other users on this system share the following folders:") . '

'; $none = true; echo ''; $toggle = false; for ($q = 0; $q < count($box); $q++) { if(ereg("^user\.",$box[$q])) { $none = false; echo ''; echo ''; echo ''; } if(!$toggle) { $toggle = true; } elseif($toggle) { $toggle = false; } } echo '
'; if(isset($folderinfo[$box[$q]]['description'])) { echo $folderinfo[$box[$q]]['description']; } echo '
'; if($none) { echo _("There are no other users that allow access to their folders at this time."); } else { echo '

' . '\n" . '
'; } echo '
';