Dokeos PHP Cross Reference Learning Management Systems

Source: /main/messages/inbox.php - 187 lines - 6724 bytes - Summary - Text - Print

   1  <?php
   2  /* For licensing terms, see /license.txt */
   3  /**
   4  *    @package dokeos.messages
   5  */
   6  
   7  // name of the language file that needs to be included
   8  $language_file = array('registration','messages','userInfo');
   9  $cidReset = true;
  10  require_once  '../inc/global.inc.php';
  11  require_once api_get_path(LIBRARY_PATH).'message.lib.php';
  12  
  13  api_block_anonymous_users();
  14  if (isset($_GET['messages_page_nr'])) {
  15      $social_link = '';
  16      if ($_REQUEST['f']=='social') {
  17          $social_link = '?f=social';
  18      }
  19      if (api_get_setting('allow_social_tool')=='true' &&  api_get_setting('allow_message_tool')=='true') {
  20          header('Location:inbox.php'.$social_link);
  21      }
  22  }
  23  if (api_get_setting('allow_message_tool')!='true'){
  24      api_not_allowed();    
  25  }
  26  //$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js" type="text/javascript" language="javascript"></script>';
  27  $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.js" type="text/javascript" language="javascript"></script>';
  28  $htmlHeadXtra[] = '<link rel="stylesheet" href="'.api_get_path(WEB_LIBRARY_PATH).'javascript/thickbox.css" type="text/css" media="projection, screen">';
  29  
  30  $htmlHeadXtra[]='<script language="javascript">
  31  
  32  function show_icon_edit(element_html) {    
  33      ident="#edit_image";
  34      $(ident).show();
  35  }        
  36  
  37  function hide_icon_edit(element_html)  {
  38      ident="#edit_image";
  39      $(ident).hide();
  40  }        
  41          
  42  </script>';
  43  
  44  /*
  45          MAIN CODE
  46  */
  47  $nameTools = get_lang('Messages');
  48  $request=api_is_xml_http_request();
  49  if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
  50      $info_reply=array();
  51      $info_delete=array();
  52      
  53      if ( isset($_GET['form_reply']) ) {
  54          //allow to insert messages
  55          $info_reply=explode(base64_encode('&%ff..x'),$_GET['form_reply']);
  56          $count_reply=count($info_reply);
  57          $button_sent=urldecode($info_reply[4]);
  58      }
  59      
  60      if ( isset($_GET['form_delete']) ) {
  61          //allow to delete messages
  62          $info_delete=explode(',',$_GET['form_delete']);
  63          $count_delete=(count($info_delete)-1);
  64      }
  65      
  66      if ( isset($button_sent) ) {
  67          $title     = api_convert_encoding(urldecode($info_reply[0]),'UTF-8',$charset);
  68          $content   = api_convert_encoding(str_replace("\\","",urldecode($info_reply[1])),'UTF-8',$charset);
  69          $title     = Security::remove_XSS($title);
  70          $content   = Security::remove_XSS($content,COURSEMANAGERLOWSECURITY);
  71  
  72          $user_reply= $info_reply[2];
  73          $user_email_base=str_replace(')','(',$info_reply[5]);
  74          $user_email_prepare=explode('(',$user_email_base);
  75          if (count($user_email_prepare)==1) {
  76              $user_email=trim($user_email_prepare[0]);
  77          } elseif (count($user_email_prepare)==3) {
  78              $user_email=trim($user_email_prepare[1]);
  79          }
  80          $user_id_by_email=MessageManager::get_user_id_by_email($user_email);
  81  
  82          if ($info_reply[6]=='save_form') {
  83              $user_id_by_email=$info_reply[2];
  84          }
  85          if ( isset($user_reply) && !is_null($user_id_by_email) && strlen($info_reply[0]) >0) {
  86              MessageManager::send_message($user_id_by_email, $title, $content);
  87              MessageManager::display_success_message($user_id_by_email);
  88              inbox_display();
  89              exit;
  90          } elseif (is_null($user_id_by_email)) {
  91              $message_box=get_lang('ErrorSendingMessage');
  92              Display::display_error_message(api_xml_http_response_encode($message_box),false);
  93              inbox_display();
  94              exit;
  95          }
  96      } elseif (trim($info_delete[0])=='delete' ) {
  97          for ($i=1;$i<=$count_delete;$i++) {
  98              MessageManager::delete_message_by_user_receiver(api_get_user_id(), $info_delete[$i]);
  99          }
 100              $message_box=get_lang('SelectedMessagesDeleted');
 101              Display::display_normal_message(api_xml_http_response_encode($message_box),false);
 102                 inbox_display();
 103              exit;
 104      }
 105  }
 106  
 107  
 108  $link_ref="new_message.php";
 109  $table_message = Database::get_main_table(TABLE_MESSAGE);
 110  
 111  
 112  //api_display_tool_title(api_xml_http_response_encode(get_lang('Inbox')));
 113  if ($_GET['f']=='social') {
 114      $this_section = SECTION_SOCIAL;
 115      $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/social/home.php','name' => get_lang('Social'));
 116      $interbreadcrumb[]= array ('url' => '#','name' => get_lang('Inbox'));    
 117  } else {
 118      $this_section = SECTION_MYPROFILE;
 119      $interbreadcrumb[]= array ('url' => api_get_path(WEB_PATH).'main/auth/profile.php','name' => get_lang('Profile'));
 120      $interbreadcrumb[]= array ('url' => 'outbox.php','name' => get_lang('Inbox'));
 121  }
 122  
 123  Display::display_header('');
 124  
 125  // Display actions
 126  echo '<div class="actions">';
 127  if (api_get_setting('allow_social_tool') == 'true') {
 128    echo '<a href="'.api_get_path(WEB_PATH).'main/social/home.php">'.Display::return_icon('pixel.gif',get_lang('Home'),array('class' => 'toolactionplaceholdericon toolactionshome')).get_lang('Home').'</a>';
 129  } else {
 130    $social_parameter = '';
 131    if ($_GET['f']=='social' || api_get_setting('allow_social_tool') == 'true') {
 132      $social_parameter = '?f=social';
 133    } else {
 134      echo '<a href="'.api_get_path(WEB_PATH).'main/auth/profile.php?type=reduced">'.Display::return_icon('pixel.gif', get_lang('EditNormalProfile'),array('class'=>'actionplaceholdericon actionedit')).'&nbsp;'.get_lang('EditNormalProfile').'</a>';
 135    }
 136  }
 137  echo '<a href="'.api_get_path(WEB_PATH).'main/messages/inbox.php?f=social">'.Display::return_icon('pixel.gif',get_lang('Inbox'), array('class' => 'toolactionplaceholdericon toolactioninbox')).get_lang('Inbox').'</a>';
 138  echo '<a href="'.api_get_path(WEB_PATH).'main/messages/new_message.php?f=social">'.Display::return_icon('pixel.gif',get_lang('ComposeMessage'), array('class' => 'toolactionplaceholdericon toolactionsinvite')).get_lang('ComposeMessage').'</a>';
 139  echo '<a href="'.api_get_path(WEB_PATH).'main/messages/outbox.php?f=social">'.Display::return_icon('pixel.gif',get_lang('Outbox'), array('class' => 'toolactionplaceholdericon toolactionoutbox')).get_lang('Outbox').'</a>';
 140  echo '</div>';
 141  // Start content
 142  echo '<div id="content">';
 143  
 144  echo '<div id="social-content">';
 145      $id_content_right = '';
 146      //LEFT CONTENT            
 147      if (api_get_setting('allow_social_tool') != 'true') {
 148        //
 149      } else {
 150          require_once api_get_path(LIBRARY_PATH).'social.lib.php';
 151          $id_content_right = 'social-content-right';
 152          echo '<div id="social-content-left">';    
 153              //this include the social menu div
 154              SocialManager::show_social_menu('messages_inbox');
 155          echo '</div>';        
 156      }
 157  
 158      echo '<div id="'.$id_content_right.'">';
 159              //MAIN CONTENT
 160              if (!isset($_GET['del_msg'])) {    
 161                  inbox_display();
 162              } else {
 163                  $num_msg = intval($_POST['total']);
 164                  for ($i=0;$i<$num_msg;$i++) {
 165                      if($_POST[$i]) {
 166                          //the user_id was necesarry to delete a message??
 167                          MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_POST['_'.$i]);
 168                      }
 169                  }
 170                  inbox_display();
 171              }
 172      echo '</div>';    
 173  echo '</div>';
 174  
 175  //End content
 176  echo '</div>';
 177  
 178  // Actions
 179  echo '<div class="actions">';
 180  echo '</div>';
 181  
 182  
 183  /*
 184          FOOTER
 185  */
 186  
 187  Display::display_footer();

title

Description

title

Description

title

Description

title

title

Body