[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/message/ -> user.php (source)

   1  <?php // $Id: user.php,v 1.29.2.3 2008/02/13 17:01:44 skodak Exp $
   2        
   3      require ('../config.php');
   4      require ('lib.php');
   5  
   6      require_login();
   7  
   8      if (isguest()) {
   9          redirect($CFG->wwwroot);
  10      }
  11  
  12      if (empty($CFG->messaging)) {
  13          error("Messaging is disabled on this site");
  14      }
  15  
  16  /// Script parameters
  17      $userid = required_param('id', PARAM_INT);
  18  
  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  
  24  /// Check the user we are talking to is valid
  25      if (! $user = get_record('user', 'id', $userid)) {
  26          error("User ID was incorrect");
  27      }
  28  
  29  /// Possibly change some contacts if requested
  30  
  31      if ($addcontact and confirm_sesskey()) {
  32          add_to_log(SITEID, 'message', 'add contact', 
  33                     'history.php?user1='.$addcontact.'&amp;user2='.$USER->id, $addcontact);
  34          message_add_contact($addcontact);
  35      }
  36      if ($removecontact and confirm_sesskey()) {
  37          add_to_log(SITEID, 'message', 'remove contact', 
  38                     'history.php?user1='.$removecontact.'&amp;user2='.$USER->id, $removecontact);
  39          message_remove_contact($removecontact);
  40      }
  41      if ($blockcontact and confirm_sesskey()) {
  42          add_to_log(SITEID, 'message', 'block contact', 
  43                     'history.php?user1='.$blockcontact.'&amp;user2='.$USER->id, $blockcontact);
  44          message_block_contact($blockcontact);
  45      }
  46      if ($unblockcontact and confirm_sesskey()) {
  47          add_to_log(SITEID, 'message', 'unblock contact', 
  48                     'history.php?user1='.$unblockcontact.'&amp;user2='.$USER->id, $unblockcontact);
  49          message_unblock_contact($unblockcontact);
  50      }
  51  
  52      print_header('','','','','',false,'','',false,'');
  53      echo '<table width="100%" cellpadding="0" cellspacing="0"><tr>';
  54      echo '<td width="100">';
  55      echo print_user_picture($user, SITEID, $user->picture, true, true, true, 'userwindow').'</td>';
  56      echo '<td valign="middle" align="center">';
  57  
  58      echo '<div class="name">'.fullname($user).'</div>';
  59  
  60      //echo '<br /><font size="1">';     /// Print login status of this user
  61      //if ($user->lastaccess) {
  62      //    if (time() - $user->lastaccess > $CFG->message_offline_time) {
  63      //        echo get_string('offline', 'message').': '.format_time(time() - $user->lastaccess);
  64      //    } else {
  65      //        echo get_string('lastaccess').': '.get_string('ago', 'message', format_time(time() - $user->lastaccess));
  66      //    }
  67      //} else {
  68      //    echo get_string("lastaccess").":". get_string("never");
  69      //}
  70      //echo '</font>';
  71  
  72      echo '<div class="commands">';
  73      if ($contact = get_record('message_contacts', 'userid', $USER->id, 'contactid', $user->id)) {
  74           if ($contact->blocked) {
  75               message_contact_link($user->id, 'add', false, 'user.php?id='.$user->id, true); 
  76               message_contact_link($user->id, 'unblock', false, 'user.php?id='.$user->id, true); 
  77           } else {
  78               message_contact_link($user->id, 'remove', false, 'user.php?id='.$user->id, true); 
  79               message_contact_link($user->id, 'block', false, 'user.php?id='.$user->id, true); 
  80           }
  81      } else {
  82           message_contact_link($user->id, 'add', false, 'user.php?id='.$user->id, true);
  83           message_contact_link($user->id, 'block', false, 'user.php?id='.$user->id, true);
  84      }
  85      message_history_link($user->id, 0, false, '', '', 'both');
  86      echo '</div>';
  87  
  88      echo '</td></tr></table>';
  89  
  90      print_footer('empty');
  91  
  92  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7