Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SOme code tidyups, and fixes for missing langauge strings as per bug …
…2340
  • Loading branch information
moodler committed Jan 5, 2005
1 parent 180545d commit e848159
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 64 deletions.
3 changes: 3 additions & 0 deletions lang/en/message.php
Expand Up @@ -9,6 +9,7 @@
$string['blockcontact'] = 'Block contact';
$string['blockedmessages'] = '$a message(s) to/from blocked users';
$string['context'] = 'context';
$string['contacts'] = 'Contacts';
$string['deletemessagesdays'] = 'Number of days before old messages are automatically deleted';
$string['discussion'] = 'Discussion';
$string['emailmessages'] = 'Email messages when I am offline';
Expand Down Expand Up @@ -39,10 +40,12 @@
$string['pagerefreshes'] = 'This page refreshes automatically every $a seconds';
$string['removecontact'] = 'Remove contact';
$string['savemysettings'] = 'Save my settings';
$string['search'] = 'Search';
$string['searchforperson'] = 'Search for a person';
$string['searchmessages'] = 'Search messages';
$string['sendmessage'] = 'Send message';
$string['sendmessageto'] = 'Send message to $a';
$string['settings'] = 'Settings';
$string['settingssaved'] = 'Your settings have been saved';
$string['showmessagewindow'] = 'Automatically show Message window when I get new messages (your browser needs to be set so that it doesn\'t block popups on this site)';
$string['strftimedaydatetime'] = '%%A, %%d %%B %%Y, %%I:%%M %%p';
Expand Down
127 changes: 63 additions & 64 deletions message/index.php
@@ -1,76 +1,75 @@
<?php
/// main interface window for messaging
<?php /// $Id$
/// Main interface window for messaging

require('../config.php');
require('lib.php');
require('../config.php');
require('lib.php');

require_login(0, false);
require_login(0, false);

/// 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
/// 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

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;
}
/// 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;
}

if ($addcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&amp;user2='.$USER->id, $addcontact);
message_add_contact($addcontact);
}
if ($removecontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'remove contact', 'history.php?user1='.$removecontact.'&amp;user2='.$USER->id, $removecontact);
message_remove_contact($removecontact);
}
if ($blockcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'block contact', 'history.php?user1='.$blockcontact.'&amp;user2='.$USER->id, $blockcontact);
message_block_contact($blockcontact);
}
if ($unblockcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'unblock contact', 'history.php?user1='.$unblockcontact.'&amp;user2='.$USER->id, $unblockcontact);
message_unblock_contact($unblockcontact);
}
/// Process any contact maintenance requests there may be
if ($addcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'add contact', 'history.php?user1='.$addcontact.'&amp;user2='.$USER->id, $addcontact);
message_add_contact($addcontact);
}
if ($removecontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'remove contact', 'history.php?user1='.$removecontact.'&amp;user2='.$USER->id, $removecontact);
message_remove_contact($removecontact);
}
if ($blockcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'block contact', 'history.php?user1='.$blockcontact.'&amp;user2='.$USER->id, $blockcontact);
message_block_contact($blockcontact);
}
if ($unblockcontact and confirm_sesskey()) {
add_to_log(SITEID, 'message', 'unblock contact', 'history.php?user1='.$unblockcontact.'&amp;user2='.$USER->id, $unblockcontact);
message_unblock_contact($unblockcontact);
}


/// a print function is associated with each tab
$tabprintfunction = 'message_print_'.$tab;

/// 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);
}

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);
}
echo '<table cellspacing="2" cellpadding="2" border="0" align="center" width="95%">';
echo '<tr>';

?>
/// 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>';

<table cellspacing="2" cellpadding="2" border="0" align="center" width="95%">
<tr>
<th class="<?php echo ($tab == 'contacts') ? 'generaltabselected' : 'generaltab' ?>">
<a href="<?php echo $CFG->wwwroot.'/message/index.php' ?>?tab=contacts">contacts</a>
</th>
<th class="<?php echo ($tab == 'search') ? 'generaltabselected' : 'generaltab' ?>">
<a href="<?php echo $CFG->wwwroot.'/message/index.php' ?>?tab=search">search</a>
</th>
<th class="<?php echo ($tab == 'settings') ? 'generaltabselected' : 'generaltab' ?>">
<a href="<?php echo $CFG->wwwroot.'/message/index.php' ?>?tab=settings">settings</a>
</th>
</tr>
<tr>
<td colspan="3" bgcolor="#ffffff">
<?php if (function_exists($tabprintfunction)) $tabprintfunction(); ?>
</td>
</tr>
</table>
/// Print out contents of the tab
echo '<td colspan="3" bgcolor="'.$THEME->cellcontent.'">';

/// a print function is associated with each tab
$tabprintfunction = 'message_print_'.$tab;
if (function_exists($tabprintfunction)) {
$tabprintfunction();
}

</body>
</html>
echo '</td> </tr> </table>';
echo ' </body> </html>';

0 comments on commit e848159

Please sign in to comment.