Example #1
0
    function show_mes_outbox()
    {
        $search_text = EClassApi::getParam('search_text');
        $is_archive = Url::get('is_archive', 0);
        $table_topics = 'message_topics';
        $table_text = 'message_text';
        $url_archive = '';
        $url_cmd = '';
        if ($is_archive) {
            $table_topics = $table_topics . '_archive';
            $table_text = $table_text . '_archive';
            $url_cmd = '&cmd=archive';
            $url_archive = '&is_archive=1';
        }
        $condition = $table_topics . '.mt_owner_id =' . User::id() . ' 
					AND ' . $table_topics . '.mt_vid_folder = "sent" 
					AND ' . $table_topics . '.mt_newest = 0';
        if ($search_text && $search_text != "Account thành viên") {
            $condition .= " AND mt_to_name LIKE '%{$search_text}%' ";
        }
        $str_content = '<form name="message">
						<div id="boxFunctions">
							Chọn: 
							<a style="cursor:pointer" id="select_all">Tất cả</a>,
							<a style="cursor:pointer" id="select_read">Đã đọc</a>,
							<a style="cursor:pointer" id="select_unchecked">Không chọn</a>
							<div id="boxFunctionRight">
								<div id="btn_del_mess" align="center" class="btnAllNewFeedback" onmouseout="this.className=\'btnAllNewFeedback\'"  onmouseover="this.className=\'btnAllNewFeedbackHover\'"  style="width:40px;">
									<div class="btnRightAllFeedback" align="center" style="width:40px"><a title="Xóa tất cả tin nhặn đã chọn" href="javascript:void(0)" onClick="return delMessage(0,\'true\',\'outbox\')">Xoá</a></div>
								</div>
							</div>
						</div>
						
						';
        $str_content .= '<table cellpadding="3" cellspacing="0" border="0" width="100%">';
        $sql_count = 'SELECT COUNT(mt_id) AS total_row FROM ' . $table_topics . ' WHERE ' . $condition;
        $total_item = DB::fetch($sql_count, 'total_row', 0);
        $item_per_page = 15;
        $limit = '';
        $divID = 'mess_content';
        $url_path = WEB_DIR . 'ajax.php?act=personal&code=show_mes_outbox' . $url_archive . '&search_text=' . $search_text;
        require_once ROOT_PATH . 'core/ECPagging.php';
        $paging = ECPagging::AjaxPaging($limit, $total_item, $item_per_page, 5, 'page_mes', '', false, false, $url_path, $divID, true);
        $sql = 'SELECT ' . $table_text . '.msg_id,	' . $table_text . '.msg_author_name, ' . $table_text . '.msg_date, ' . $table_text . '.msg_post, ' . $table_topics . '.mt_id, ' . $table_topics . '.mt_ref_id, 
					' . $table_topics . '.mt_title, ' . $table_topics . '.mt_from_id, ' . $table_topics . '.mt_owner_id, ' . $table_topics . '.mt_read, ' . $table_topics . '.mt_owner_name, ' . $table_topics . '.mt_to_name, 
					account.avatar_url, account.img_server 
				FROM ' . $table_text . ', ' . $table_topics . ', account 
				WHERE ' . $table_text . '.msg_id  = ' . $table_topics . '.mt_msg_id AND ' . $table_topics . '.mt_from_id = account.id AND ' . $condition . ' 
				ORDER BY ' . $table_text . '.msg_date DESC ' . $limit;
        //echo $sql;
        //exit;
        $result = DB::query($sql);
        $stt = 0;
        if ($result) {
            while ($row = mysql_fetch_assoc($result)) {
                if ($stt < $item_per_page) {
                    if ($row['mt_ref_id']) {
                        $sourceTitle = DB::select($table_topics, 'mt_id = ' . $row['mt_ref_id']);
                        if ($sourceTitle['mt_title']) {
                            $row['mt_title'] = $sourceTitle['mt_title'];
                        }
                        //else
                        //{
                        //	$sentTitle = DB::select($table_topics,'mt_mgsid = ' . $row['mt_ref_id']);
                        //}
                        $row["mt_id"] = $row['mt_ref_id'];
                        $row['mt_ref_id'] = 0;
                    }
                    if ($row['avatar_url']) {
                        $row['avatar_url'] = EClassApi::getImageThumb($row['avatar_url'], 50, 50, 0, $row['img_server']);
                    } else {
                        $row['avatar_url'] = "style/images/50x50.gif";
                    }
                    //$row['msg_date'] = EClassApi::duration_time($row['msg_date']);
                    $msg_date = date('H:i | ', $row['msg_date']);
                    if (date('d.m.y', $row['msg_date']) == date('d.m.y', TIME_NOW)) {
                        $msg_date .= '<font color="green">H&#244;m nay</font>';
                    } else {
                        $msg_date .= date('d.m.y', $row['msg_date']);
                    }
                    $row['msg_date'] = $msg_date;
                    $row['msg_post'] = preg_replace("/\n/", "<br />", $row['msg_post']);
                    $row['msg_post'] = strip_tags(EClassApi::parseBBCode(EClassApi::convert_one_br($row['msg_post'])), '<br />');
                    if (strlen($row['msg_post']) > 40) {
                        $row['msg_post_short'] = EClassApi::word_limit($row['msg_post'], 40, ' ...');
                        //$row['msg_post_short'] = EClassApi::cleanHtml(EClassApi::word_limit($row['msg_post'],40,' ...'));
                    } else {
                        $row['msg_post_short'] = $row['msg_post'];
                        //$row['msg_post_short'] = EClassApi::cleanHtml($row['msg_post']);
                    }
                    //$str_title = '<a onclick="fn_show_mes_detail('.$row["mt_id"].')" rel="history" href="message.html'.$url_cmd.'#outbox/'.$row["mt_id"].'" id="a_'.$row["mt_id"].'" title="Hiển thị chi tiết" >'.$row["mt_title"].'</a> - <span class="textMestime">'.$row['msg_date'].'</span>';
                    if ($row['mt_owner_id'] != User::id()) {
                        $strUser = '******' . $row["mt_owner_name"] . '">' . $row["mt_owner_name"] . '</a>';
                    } else {
                        $strUser = '******' . $row["mt_to_name"] . '">' . $row["mt_to_name"] . '</a>';
                    }
                    if ($row["mt_read"] == 0 && !$is_archive) {
                        $str_title = '<a onclick="detail_reload_jcache = true;fn_show_mes_detail(' . $row["mt_id"] . ',1,\'outbox\')" rel="history" id="a_' . $row["mt_id"] . '" href="message.html?tab=gt' . $url_cmd . '#outbox/' . $row["mt_id"] . '" title="Hiển thị chi tiết" ><b>' . $row["mt_title"] . '</b></a>';
                        $read_class = ' unreadMessage';
                    } else {
                        $str_title = '<a onclick="detail_reload_jcache = true;fn_show_mes_detail(' . $row["mt_id"] . ',1,\'outbox\')" rel="history" id="a_' . $row["mt_id"] . '" href="message.html?tab=gt' . $url_cmd . '#outbox/' . $row["mt_id"] . '" title="Hiển thị chi tiết">' . $row["mt_title"] . '</a>';
                        $read_class = '';
                    }
                    $str_content .= '<tr id="' . $row["mt_id"] . '">
									<td align="center" class="listMessage' . $read_class . '"><input type="checkbox" class="rowbox' . $read_class . '" id="inbox_' . $row["mt_id"] . '" name="inbox[]" value="' . $row["mt_id"] . '"></td>
									<td align="center" class="listMessage' . $read_class . '">
										<a href="' . $row["msg_author_name"] . '"><img src="' . $row["avatar_url"] . '"/></a>
									</td>
									<td valign="top" class="listMessage' . $read_class . '" style="white-space:nowrap; padding-right:15px; vertical-align:middle;">
										<div>' . $strUser . '</div>
										<div class="textMestime">' . $row['msg_date'] . '</div>
									</td>
									<td valign="top" class="listMessage clickable' . $read_class . '" style="padding-right:15px;width:65%;" lang="' . $row["mt_id"] . '">
										<div style="margin-top:6px;">' . $str_title . '</div>
										<div style="margin:6px 0;color:#808080">' . $row['msg_post_short'] . '</div>
									</td>
									<td align="center" class="listMessage' . $read_class . '" style="padding-right:10px;"> <span><a title="Xóa tin nhắn" onClick="return delMessage(' . $row["mt_id"] . ',\'false\',\'inbox\')" href="javascript:void(0)" style="padding:20px;" class="deleteButton"> &nbsp;</a></span></td>
								</tr>
								';
                    /*$str_content .= '<tr id="'.$row["mt_id"].'">
                    			<td align="center" class="listMessage' . $read_class . '"><input type="checkbox" id="inbox_'.$row["mt_id"].'" name="inbox[]" value="'.$row["mt_id"].'"></td>
                    			<td align="center" class="listMessage' . $read_class . '">
                    				<a href="'.$row["mt_to_name"].'"><img src="'.$row["avatar_url"].'"  vspace="4" hspace="4"/></a>
                    				<div><a href="'.$row["mt_to_name"].'">'.$row["mt_to_name"].'</a></div>	
                    			</td>
                    			<td valign="top" style="width:65%;" class="listMessage' . $read_class . '">
                    				<div>'.$str_title.'</div>
                    				<div style="margin-top:6px">'.$row['msg_post_short'].'</div>
                    			</td>
                    			<td align="center" class="listMessage' . $read_class . '"> <span><a title="Xóa tin nhắn" onClick="delMessage('.$row["mt_id"].',\'false\',\'sent\')" href="javascript:void(0)"> <img src="style/images/icon_delete.gif" width="9" height="9" /></a></span></td>
                    		</tr>';*/
                }
                $stt++;
            }
        }
        if ($stt > 0) {
            $str_content .= '<tr><td></td><td>
								</td><td colspan="2"><div style="float:right">' . $paging . '</div><div style="clear:right"></div></td></tr>';
        } else {
            $str_content .= '<tr><td></td><td colspan="3">
								<center><div class="noMess">Không có Tin nhắn nào trong tin đã gửi</div></center>
								</td></tr>';
        }
        $str_content .= '</table></form>';
        echo $str_content;
        exit;
    }
Example #2
0
 function list_comments()
 {
     global $display;
     require_once 'modules/Profile/db.php';
     $user_id = EClassApi::getParam('user_id');
     $user = DB::fetch('SELECT id, user_name FROM account WHERE id="' . $user_id . '"');
     $is_admin = false;
     if (User::is_admin()) {
         $is_admin = true;
     }
     $display->add('is_admin', $is_admin);
     $limit = '';
     $divID = 'comment_list';
     $cmd = 'comment_list_pagging';
     $item_per_page = 10;
     if (Url::get('cmd') == $cmd) {
         $display->add('load_ajax_page', true);
     } else {
         $display->add('load_ajax_page', false);
     }
     $url_path = WEB_DIR . "ajax.php?act=user&code=comments&user_id=" . $user['id'];
     $count = ProfileDB::get_total_comment($user['id']);
     require_once ROOT_PATH . 'core/ECPagging.php';
     $paging = ECPagging::AjaxPaging($limit, $count['acount'], $item_per_page, 5, 'comment_page_no', '', false, false, $url_path, $divID);
     $comments = ProfileDB::get_comments($user['id'], $item_per_page, $limit);
     $display->add('user_id', $user['id']);
     $display->add('is_login', (int) User::is_login());
     if (User::is_login()) {
         $display->add('cur_id', (int) User::$current->data['id']);
         $display->add('cur_user_name', User::$current->data['user_name']);
         if (User::$current->data['avatar_url'] == '') {
             $cur_avatar_url = 'style/images/50x50.gif';
         } else {
             $cur_avatar_url = EClassApi::getImageThumb(User::$current->data['avatar_url'], 50, 50, 0, User::$current->data['img_server']);
         }
         $display->add('cur_avatar', $cur_avatar_url);
     } else {
         $display->add('cur_id', '0');
         $display->add('cur_user_name', '');
         $display->add('cur_avatar', 'style/images/50x50.gif');
         $cur_avatar_url = "";
     }
     $display->add('comments', $comments);
     $display->add('paging', $paging);
     $display->add('user_name', User::$current->data['user_name']);
     $display->output('comment', false, 'Profile');
     System::halt();
 }