Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / message / index.php
blob10f2ba570d5f7276ceb6077f751e08d283d0bac6
1 <?php /// $Id$
2 /// Main interface window for messaging
4 require('../config.php');
5 require('lib.php');
7 require_login(0, false);
9 if (isguest()) {
10 redirect($CFG->wwwroot);
13 if (empty($CFG->messaging)) {
14 error("Messaging is disabled on this site");
17 /// Optional variables that may be passed in
18 $tab = optional_param('tab', 'contacts'); // current tab - default to contacts
19 $addcontact = optional_param('addcontact', 0, PARAM_INT); // adding a contact
20 $removecontact = optional_param('removecontact', 0, PARAM_INT); // removing a contact
21 $blockcontact = optional_param('blockcontact', 0, PARAM_INT); // blocking a contact
22 $unblockcontact = optional_param('unblockcontact', 0, PARAM_INT); // unblocking a contact
23 $popup = optional_param('popup', false, PARAM_ALPHA); // If set then starts a new popup window
25 /// Popup a window if required and quit (usually from external links).
26 if ($popup) {
27 print_header();
28 echo '<script type="text/javascript">'."\n//<![CDATA[\n openpopup('/message/index.php', 'message', 'menubar=0,location=0,scrollbars,status,resizable,width=400,height=500', 0);\n//]]>\n</script>";
29 redirect("$CFG->wwwroot/");
30 exit;
33 /// Process any contact maintenance requests there may be
34 if ($addcontact and confirm_sesskey()) {
35 add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&amp;user2='.$USER->id, $addcontact);
36 message_add_contact($addcontact);
38 if ($removecontact and confirm_sesskey()) {
39 add_to_log(SITEID, 'message', 'remove contact', 'history.php?user1='.$removecontact.'&amp;user2='.$USER->id, $removecontact);
40 message_remove_contact($removecontact);
42 if ($blockcontact and confirm_sesskey()) {
43 add_to_log(SITEID, 'message', 'block contact', 'history.php?user1='.$blockcontact.'&amp;user2='.$USER->id, $blockcontact);
44 message_block_contact($blockcontact);
46 if ($unblockcontact and confirm_sesskey()) {
47 add_to_log(SITEID, 'message', 'unblock contact', 'history.php?user1='.$unblockcontact.'&amp;user2='.$USER->id, $unblockcontact);
48 message_unblock_contact($unblockcontact);
52 /// Header on this page
53 if ($tab == 'contacts') {
54 print_header(get_string('messages', 'message').' - '.format_string($SITE->fullname), '', '', '',
55 '<meta http-equiv="refresh" content="'. $CFG->message_contacts_refresh .'; url=index.php" />');
56 } else {
57 print_header(get_string('messages', 'message').' - '.format_string($SITE->fullname));
60 echo '<table cellspacing="2" cellpadding="2" border="0" align="center" width="95%">';
61 echo '<tr>';
63 /// Print out the tabs
64 echo '<td>';
65 $tabrow = array();
66 $tabrow[] = new tabobject('contacts', $CFG->wwwroot.'/message/index.php?tab=contacts',
67 get_string('contacts', 'message'));
68 $tabrow[] = new tabobject('search', $CFG->wwwroot.'/message/index.php?tab=search',
69 get_string('search', 'message'));
70 $tabrow[] = new tabobject('settings', $CFG->wwwroot.'/message/index.php?tab=settings',
71 get_string('settings', 'message'));
72 $tabrows = array($tabrow);
74 print_tabs($tabrows, $tab);
76 echo '</td>';
79 echo '</tr><tr>';
81 /// Print out contents of the tab
82 echo '<td>';
84 /// a print function is associated with each tab
85 $tabprintfunction = 'message_print_'.$tab;
86 if (function_exists($tabprintfunction)) {
87 $tabprintfunction();
90 echo '</td> </tr> </table>';
91 print_footer('none');