Esempio n. 1
0
 /**
  * Gets information about messages sent
  * @param  integer
  * @param  integer
  * @param  string
  * @return array
  */
 public static function get_message_data_sent($from, $number_of_items, $column, $direction)
 {
     $from = intval($from);
     $number_of_items = intval($number_of_items);
     if (!isset($direction)) {
         $column = 3;
         $direction = 'DESC';
     } else {
         $column = intval($column);
         if (!in_array($direction, array('ASC', 'DESC'))) {
             $direction = 'ASC';
         }
     }
     $table_message = Database::get_main_table(TABLE_MESSAGE);
     $request = api_is_xml_http_request();
     $sql = "SELECT\n                    id as col0, user_sender_id as col1, title as col2, send_date as col3, user_receiver_id as col4, msg_status as col5\n                FROM {$table_message}\n                WHERE\n                    user_sender_id=" . api_get_user_id() . " AND\n                    msg_status=" . MESSAGE_STATUS_OUTBOX . "\n                ORDER BY col{$column} {$direction}\n                LIMIT {$from}, {$number_of_items}";
     $sql_result = Database::query($sql);
     $i = 0;
     $message_list = array();
     while ($result = Database::fetch_row($sql_result)) {
         if ($request === true) {
             $message[0] = '<input type="checkbox" value=' . $result[0] . ' name="out[]">';
         } else {
             $message[0] = $result[0];
         }
         $class = 'class = "read"';
         $result[2] = Security::remove_XSS($result[2]);
         if ($request === true) {
             $userInfo = api_get_user_info($result[4]);
             $message[1] = '<a onclick="show_sent_message(' . $result[0] . ')" href="javascript:void(0)">' . $userInfo['complete_name'] . '</a>';
             $message[2] = '<a onclick="show_sent_message(' . $result[0] . ')" href="javascript:void(0)">' . str_replace("\\", "", $result[2]) . '</a>';
             $message[3] = api_convert_and_format_date($result[3], DATE_TIME_FORMAT_LONG);
             //date stays the same
             $message[4] = '&nbsp;&nbsp;<a onclick="delete_one_message_outbox(' . $result[0] . ')" href="javascript:void(0)"  >' . Display::return_icon('delete.png', get_lang('DeleteMessage')) . '</a>';
         } else {
             $link = '';
             if (isset($_GET['f']) && $_GET['f'] == 'social') {
                 $link = '&f=social';
             }
             $userInfo = api_get_user_info($result[4]);
             $message[1] = '<a ' . $class . ' onclick="show_sent_message (' . $result[0] . ')" href="../messages/view_message.php?id_send=' . $result[0] . $link . '">' . $result[2] . '</a><br />' . $userInfo['complete_name'];
             //$message[2] = '<a '.$class.' onclick="show_sent_message ('.$result[0].')" href="../messages/view_message.php?id_send='.$result[0].$link.'">'.$result[2].'</a>';
             $message[2] = api_convert_and_format_date($result[3], DATE_TIME_FORMAT_LONG);
             //date stays the same
             $message[3] = '<a href="outbox.php?action=deleteone&id=' . $result[0] . '&' . $link . '"  onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmDeleteMessage'))) . "'" . ')) return false;" >' . Display::return_icon('delete.png', get_lang('DeleteMessage')) . '</a>';
         }
         foreach ($message as $key => $value) {
             $message[$key] = $value;
         }
         $message_list[] = $message;
         $i++;
     }
     return $message_list;
 }
Esempio n. 2
0
function show_icon_edit(element_html) {
	ident="#edit_image";
	$(ident).show();
}

function hide_icon_edit(element_html)  {
	ident="#edit_image";
	$(ident).hide();
}

</script>';
/*
 MAIN CODE
*/
$nameTools = get_lang('Messages');
$request = api_is_xml_http_request();
if (isset($_GET['form_reply']) || isset($_GET['form_delete'])) {
    $info_reply = array();
    $info_delete = array();
    if (isset($_GET['form_reply'])) {
        //allow to insert messages
        $info_reply = explode(base64_encode('&%ff..x'), $_GET['form_reply']);
        $count_reply = count($info_reply);
        $button_sent = urldecode($info_reply[4]);
    }
    if (isset($_GET['form_delete'])) {
        //allow to delete messages
        $info_delete = explode(',', $_GET['form_delete']);
        $count_delete = count($info_delete) - 1;
    }
    if (isset($button_sent)) {
Esempio n. 3
0
 /**
  * Returns a div html string with
  * @param   string  The message
  * @param   string  The message type (confirm,normal,warning,error)
  * @param   bool    Whether to XSS-filter or not
  * @return  string  Message wrapped into an HTML div
  */
 public static function return_message($message, $type = 'normal', $filter = true)
 {
     if ($filter) {
         $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
         //$message = Security::remove_XSS($message);
     }
     $class = "";
     switch ($type) {
         case 'warning':
             $class .= 'warning-message';
             break;
         case 'error':
             $class .= 'error-message';
             break;
         case 'confirmation':
         case 'confirm':
         case 'success':
             $class .= 'confirmation-message';
             break;
         case 'normal':
         default:
             $class .= 'normal-message';
     }
     return self::div($message, array('class' => $class));
 }
Esempio n. 4
0
 /**
  * Returns a div html string with
  * @param   string  The message
  * @param   string  The message type (confirm,normal,warning,error)
  * @param   bool    Whether to XSS-filter or not
  * @return  string  Message wrapped into an HTML div
  */
 public static function return_message($message, $type = 'normal', $filter = true)
 {
     if ($filter) {
         $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
     }
     Container::getSession()->getFlashBag()->add($type, $message);
     return '';
     /*
             $class = "";
             switch($type) {
                 case 'warning':
                    $class .= 'alert alert-warning';
                    break;
                 case 'error':
                    $class .= 'alert alert-danger';
                    break;
                 case 'confirmation':
                 case 'confirm':
                 case 'success':
                     $class .= 'alert alert-success';
                    break;
                 case 'normal':
                 default:
                     $class .= 'alert alert-info';
             }
     
             return self::div($message, array('class'=> $class));*/
 }
Esempio n. 5
0
 /**
  * Returns a div html string with
  * @param   string  The message
  * @param   string  The message type (confirm,normal,warning,error)
  * @param   bool    Whether to XSS-filter or not
  * @return  string  Message wrapped into an HTML div
  */
 public static function return_message($message, $type = 'normal', $filter = true)
 {
     if (empty($message)) {
         return '';
     }
     if ($filter) {
         $message = api_htmlentities($message, ENT_QUOTES, api_is_xml_http_request() ? 'UTF-8' : api_get_system_encoding());
     }
     Container::getSession()->getFlashBag()->add($type, $message);
     return '';
 }
Esempio n. 6
0
 static function outbox_display()
 {
     $request = api_is_xml_http_request();
     global $charset;
     $social_link = false;
     if ($_REQUEST['f'] == 'social') {
         $social_link = 'f=social';
     }
     $success = get_lang('SelectedMessagesDeleted') . '&nbsp</b><br /><a href="outbox.php?' . $social_link . '">' . get_lang('BackToOutbox') . '</a>';
     $html = null;
     if (isset($_REQUEST['action'])) {
         switch ($_REQUEST['action']) {
             case 'delete':
                 $number_of_selected_messages = count($_POST['id']);
                 if ($number_of_selected_messages != 0) {
                     foreach ($_POST['id'] as $index => $message_id) {
                         MessageManager::delete_message_by_user_receiver(api_get_user_id(), $message_id);
                     }
                 }
                 $html .= Display::return_message(api_xml_http_response_encode($success), 'normal', false);
                 break;
             case 'deleteone':
                 MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']);
                 $html .= Display::return_message(api_xml_http_response_encode($success), 'normal', false);
                 $html .= '<br/>';
                 break;
         }
     }
     // display sortable table with messages of the current user
     $table = new SortableTable('message_outbox', array('MessageManager', 'get_number_of_messages_sent'), array('MessageManager', 'get_message_data_sent'), 3, 20, 'DESC');
     $parameters['f'] = Security::remove_XSS($_GET['f']);
     $table->set_additional_parameters($parameters);
     $table->set_header(0, '', false, array('style' => 'width:15px;'));
     $table->set_header(1, get_lang('Messages'), false);
     $table->set_header(2, get_lang('Date'), true, array('style' => 'width:160px;'));
     $table->set_header(3, get_lang('Modify'), false, array('style' => 'width:70px;'));
     $table->set_form_actions(array('delete' => get_lang('DeleteSelectedMessages')));
     $html .= $table->return_table();
     return $html;
 }