2005-01-05 15:31:43 +00:00
|
|
|
<?php /// $Id$
|
|
|
|
/// Main interface window for messaging
|
2004-12-16 12:40:36 +00:00
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
require('../config.php');
|
|
|
|
require('lib.php');
|
2004-12-16 12:40:36 +00:00
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
require_login(0, false);
|
2004-12-16 12:40:36 +00:00
|
|
|
|
2005-01-31 07:11:42 +00:00
|
|
|
if (empty($CFG->messaging)) {
|
|
|
|
error("Messaging is disabled on this site");
|
|
|
|
}
|
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
/// Optional variables that may be passed in
|
|
|
|
$tab = optional_param('tab', 'contacts'); // current tab - default to contacts
|
|
|
|
$addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact
|
|
|
|
$removecontact = optional_param('removecontact', 0, PARAM_INT); // removing a contact
|
|
|
|
$blockcontact = optional_param('blockcontact', 0, PARAM_INT); // blocking a contact
|
|
|
|
$unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact
|
|
|
|
$popup = optional_param('popup', false, PARAM_ALPHA); // If set then starts a new popup window
|
2005-01-01 16:00:35 +00:00
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
/// Popup a window if required and quit (usually from external links).
|
|
|
|
if ($popup) {
|
|
|
|
print_header();
|
|
|
|
echo '<script language="JavaScript" type="text/javascript">'."\n openpopup('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\n</script>";
|
|
|
|
redirect("$CFG->wwwroot/");
|
|
|
|
exit;
|
|
|
|
}
|
2004-12-31 02:17:44 +00:00
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
/// Process any contact maintenance requests there may be
|
|
|
|
if ($addcontact and confirm_sesskey()) {
|
|
|
|
add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&user2='.$USER->id, $addcontact);
|
|
|
|
message_add_contact($addcontact);
|
|
|
|
}
|
|
|
|
if ($removecontact and confirm_sesskey()) {
|
|
|
|
add_to_log(SITEID, 'message', 'remove contact', 'history.php?user1='.$removecontact.'&user2='.$USER->id, $removecontact);
|
|
|
|
message_remove_contact($removecontact);
|
|
|
|
}
|
|
|
|
if ($blockcontact and confirm_sesskey()) {
|
|
|
|
add_to_log(SITEID, 'message', 'block contact', 'history.php?user1='.$blockcontact.'&user2='.$USER->id, $blockcontact);
|
|
|
|
message_block_contact($blockcontact);
|
|
|
|
}
|
|
|
|
if ($unblockcontact and confirm_sesskey()) {
|
|
|
|
add_to_log(SITEID, 'message', 'unblock contact', 'history.php?user1='.$unblockcontact.'&user2='.$USER->id, $unblockcontact);
|
|
|
|
message_unblock_contact($unblockcontact);
|
|
|
|
}
|
2004-12-16 12:40:36 +00:00
|
|
|
|
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
/// Header on this page
|
|
|
|
if ($tab == 'contacts') {
|
|
|
|
print_header(get_string('messages', 'message').' - '.$SITE->fullname, '', '', '',
|
|
|
|
'<meta http-equiv="refresh" content="'. $CFG->message_contacts_refresh .'; url=index.php" />');
|
|
|
|
} else {
|
|
|
|
print_header(get_string('messages', 'message').' - '.$SITE->fullname);
|
|
|
|
}
|
2004-12-28 13:49:15 +00:00
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
echo '<table cellspacing="2" cellpadding="2" border="0" align="center" width="95%">';
|
|
|
|
echo '<tr>';
|
2004-12-16 12:40:36 +00:00
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
/// Print out all tabs with labels and colours
|
|
|
|
$tabs = array('contacts','search','settings');
|
|
|
|
foreach ($tabs as $thistab) {
|
|
|
|
$classname = ($tab == $thistab) ? 'generaltabselected' : 'generaltab';
|
|
|
|
echo '<th class="'.$classname.'"><a href="'.$CFG->wwwroot.'/message/index.php?tab='.$thistab.'">';
|
|
|
|
echo get_string($thistab,'message');
|
|
|
|
echo '</a></th>';
|
|
|
|
}
|
|
|
|
echo '</tr><tr>';
|
2004-12-16 12:40:36 +00:00
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
/// Print out contents of the tab
|
2005-01-28 17:40:04 +00:00
|
|
|
echo '<td colspan="3"">';
|
2004-12-16 12:40:36 +00:00
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
/// a print function is associated with each tab
|
|
|
|
$tabprintfunction = 'message_print_'.$tab;
|
|
|
|
if (function_exists($tabprintfunction)) {
|
|
|
|
$tabprintfunction();
|
|
|
|
}
|
2004-12-16 12:40:36 +00:00
|
|
|
|
2005-01-05 15:31:43 +00:00
|
|
|
echo '</td> </tr> </table>';
|
|
|
|
echo ' </body> </html>';
|