/**
 * Send the message if the UserBoard class exists (duh!) and the welcome
 * message has some content.
 *
 * @param $user User: the new User object being created
 * @param $byEmail Boolean: true if the account was created by e-mail
 * @return Boolean: true
 */
function wfSendUserBoardMessageOnRegistration($user, $byEmail)
{
    if (class_exists('UserBoard') && $user instanceof User) {
        $message = trim(wfMsgForContent('user-board-welcome-message'));
        // If the welcome message is empty, short-circuit right away.
        if (wfEmptyMsg('user-board-welcome-message', $message)) {
            return true;
        }
        // Just quit if we're in read-only mode
        if (wfReadOnly()) {
            return true;
        }
        $dbr = wfGetDB(DB_SLAVE);
        // Get all users who are in the 'sysop' group and aren't blocked from
        // the database
        $res = $dbr->select(array('user_groups', 'ipblocks'), array('ug_group', 'ug_user'), array('ug_group' => 'sysop', 'ipb_user' => null), __METHOD__, array(), array('ipblocks' => array('LEFT JOIN', 'ipb_user = ug_user')));
        $adminUids = array();
        foreach ($res as $row) {
            $adminUids[] = $row->ug_user;
        }
        // Pick one UID from the array of admin user IDs
        $random = array_rand(array_flip($adminUids), 1);
        $sender = User::newFromId($random);
        $senderUid = $sender->getId();
        $senderName = $sender->getName();
        // Send the message
        $b = new UserBoard();
        $b->sendBoardMessage($senderUid, $senderName, $user->getId(), $user->getName(), wfMsgForContent('user-board-welcome-message', $senderName));
    }
    return true;
}
 /**
  * Show the special page
  *
  * @param $params Mixed: parameter(s) passed to the page or null
  */
 public function execute($params)
 {
     global $wgRequest, $wgOut, $wgUser, $wgUserBoardScripts;
     // Add CSS & JS
     $wgOut->addExtensionStyle($wgUserBoardScripts . '/BoardBlast.css');
     $wgOut->addScriptFile($wgUserBoardScripts . '/BoardBlast.js');
     $output = '';
     // This feature is available only to logged-in users.
     if (!$wgUser->isLoggedIn()) {
         $wgOut->setPageTitle(wfMsg('boardblastlogintitle'));
         $wgOut->addWikiMsg('boardblastlogintext');
         return '';
     }
     if ($wgRequest->wasPosted()) {
         $wgOut->setPageTitle(wfMsg('messagesenttitle'));
         $b = new UserBoard();
         $count = 0;
         $user_ids_to = explode(',', $wgRequest->getVal('ids'));
         foreach ($user_ids_to as $user_id) {
             $user = User::newFromId($user_id);
             $user->loadFromId();
             $user_name = $user->getName();
             $b->sendBoardMessage($wgUser->getID(), $wgUser->getName(), $user_id, $user_name, $wgRequest->getVal('message'), 1);
             $count++;
         }
         $output .= wfMsg('messagesentsuccess');
     } else {
         $wgOut->setPageTitle(wfMsg('boardblasttitle'));
         $output .= $this->displayForm();
     }
     $wgOut->addHTML($output);
 }
Exemplo n.º 3
0
 /**
  * Execute the job
  *
  * @return bool
  */
 public function run()
 {
     // Load data from $this->params and $this->title
     $article = new WikiPage($this->title);
     $user_ids_to = $this->params['user_ids_to'];
     $message = $this->params['message'];
     $sender = $this->params['sender'];
     $user = User::newFromId($sender);
     $b = new UserBoard();
     $count = 0;
     $i = count($user_ids_to);
     $per_num = 100;
     $num = $i / $per_num;
     $int_num = ceil($num);
     for ($k = 1; $k <= $int_num; $k++) {
         $star = $per_num * ($k - 1);
         $res_arr = array_slice($user_ids_to, $star, $per_num);
         foreach ($res_arr as $user_id) {
             $user_to = User::newFromId($user_id);
             $user->loadFromId();
             $user_name = $user_to->getName();
             $b->sendBoardMessage($user->getID(), $user->getName(), $user_id, $user_name, $message, 1);
             // $count++;
         }
         wfDebug('Sending Board Blast batch ' . $k . '............................................');
         // ob_flush();
         //    flush();
     }
     return true;
 }
function wfDeleteBoardMessage($ub_id)
{
    global $wgUser;
    $b = new UserBoard();
    if ($b->doesUserOwnMessage($wgUser->getID(), $ub_id) || $wgUser->isAllowed('userboard-delete')) {
        $b->deleteMessage($ub_id);
    }
    return 'ok';
}
function wfDeleteBoardMessage($ub_id)
{
    global $wgUser;
    // Don't allow deleting messages when the database is locked for some reason
    if (wfReadOnly()) {
        return '';
    }
    $b = new UserBoard();
    if ($b->doesUserOwnMessage($wgUser->getID(), $ub_id) || $wgUser->isAllowed('userboard-delete')) {
        $b->deleteMessage($ub_id);
    }
    return 'ok';
}
    public function displayMessages($user_id, $user_id_2 = 0, $count = 10, $page = 0)
    {
        global $wgUser, $wgTitle;
        $output = '';
        // Prevent E_NOTICE
        $messages = $this->getUserBoardMessages($user_id, $user_id_2, $count, $page);
        if ($messages) {
            foreach ($messages as $message) {
                $user = Title::makeTitle(NS_USER, $message['user_name_from']);
                $avatar = new wAvatar($message['user_id_from'], 'm');
                $board_to_board = '';
                $board_link = '';
                $message_type_label = '';
                $delete_link = '';
                if ($wgUser->getName() != $message['user_name_from']) {
                    $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($message['user_name'], $message['user_name_from']) . '">' . wfMsgHtml('userboard_board-to-board') . '</a>';
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($message['user_name_from']) . '">' . wfMsgHtml('userboard_sendmessage', $message['user_name_from']) . '</a>';
                }
                if ($wgUser->getName() == $message['user_name'] || $wgUser->isAllowed('userboard-delete')) {
                    $delete_link = "<span class=\"user-board-red\">\r\n\t\t\t\t\t\t\t<a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$message['id']})\">" . wfMsgHtml('userboard_delete') . '</a>
						</span>';
                }
                if ($message['type'] == 1) {
                    $message_type_label = '(' . wfMsgHtml('userboard_private') . ')';
                }
                $message_text = $message['message_text'];
                # $message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i", 'cut_link_text', $message['message_text'] );
                $output .= "<div class=\"user-board-message\">\r\n\t\t\t\t\t<div class=\"user-board-message-from\">\r\n\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$message['user_name_from']}\">{$message['user_name_from']}</a> {$message_type_label}\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"user-board-message-time\">" . wfMsgHtml('userboard_posted_ago', $this->getTimeAgo($message['timestamp'])) . "</div>\r\n\t\t\t\t\t<div class=\"user-board-message-content\">\r\n\t\t\t\t\t\t<div class=\"user-board-message-image\">\r\n\t\t\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$message['user_name_from']}\">{$avatar->getAvatarURL()}</a>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"user-board-message-body\">\r\n\t\t\t\t\t\t\t{$message_text}\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"cleared\"></div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"user-board-message-links\">\r\n\t\t\t\t\t\t{$board_link}\r\n\t\t\t\t\t\t{$board_to_board}\r\n\t\t\t\t\t\t{$delete_link}\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>";
            }
        } elseif ($wgUser->getName() == $wgTitle->getText()) {
            $output .= '<div class="no-info-container">' . wfMsgHtml('userboard_nomessages') . '</div>';
        }
        return $output;
    }
    /**
     * Get the user board for a given user.
     *
     * @param $user_id Integer: user's ID number
     * @param $user_name String: user name
     */
    function getUserBoard($user_id, $user_name)
    {
        global $wgUser, $wgOut, $wgUserProfileDisplay, $wgUserProfileScripts;
        // Anonymous users cannot have user boards
        if ($user_id == 0) {
            return '';
        }
        // Don't display anything if user board on social profiles isn't
        // enabled in site configuration
        if ($wgUserProfileDisplay['board'] == false) {
            return '';
        }
        $output = '';
        // Prevent E_NOTICE
        $wgOut->addScriptFile($wgUserProfileScripts . '/UserProfilePage.js');
        $rel = new UserRelationship($user_name);
        $friends = $rel->getRelationshipList(1, 4);
        $stats = new UserStats($user_id, $user_name);
        $stats_data = $stats->getUserStats();
        $total = $stats_data['user_board'];
        // If the user is viewing their own profile or is allowed to delete
        // board messages, add the amount of private messages to the total
        // sum of board messages.
        if ($wgUser->getName() == $user_name || $wgUser->isAllowed('userboard-delete')) {
            $total = $total + $stats_data['user_board_priv'];
        }
        $output .= '<div class="user-section-heading">
			<div class="user-section-title">' . wfMsg('user-board-title') . '</div>
			<div class="user-section-actions">
				<div class="action-right">';
        if ($wgUser->getName() == $user_name) {
            if ($friends) {
                $output .= '<a href="' . UserBoard::getBoardBlastURL() . '">' . wfMsg('user-send-board-blast') . '</a>';
            }
            if ($total > 10) {
                $output .= wfMsgExt('pipe-separator', 'escapenoentities');
            }
        }
        if ($total > 10) {
            $output .= '<a href="' . UserBoard::getUserBoardURL($user_name) . '">' . wfMsg('user-view-all') . '</a>';
        }
        $output .= '</div>
				<div class="action-left">';
        if ($total > 10) {
            $output .= wfMsg('user-count-separator', '10', $total);
        } elseif ($total > 0) {
            $output .= wfMsg('user-count-separator', $total, $total);
        }
        $output .= '</div>
				<div class="cleared"></div>
			</div>
		</div>
		<div class="cleared"></div>';
        if ($wgUser->getName() !== $user_name) {
            if ($wgUser->isLoggedIn() && !$wgUser->isBlocked()) {
                $output .= '<div class="user-page-message-form">
						<input type="hidden" id="user_name_to" name="user_name_to" value="' . addslashes($user_name) . '" />
						<span style="color:#797979;">' . wfMsgHtml('userboard_messagetype') . '</span>
						<select id="message_type">
							<option value="0">' . wfMsgHtml('userboard_public') . '</option>
							<option value="1">' . wfMsgHtml('userboard_private') . '</option>
						</select><p>
						<textarea name="message" id="message" cols="43" rows="4"/></textarea>
						<div class="user-page-message-box-button">
							<input type="button" value="' . wfMsg('userboard_sendbutton') . '" class="site-button" onclick="javascript:send_message();" />
						</div>
					</div>';
            } else {
                $login_link = SpecialPage::getTitleFor('Userlogin');
                $output .= '<div class="user-page-message-form">' . wfMsg('user-board-login-message', $login_link->escapeFullURL()) . '</div>';
            }
        }
        $output .= '<div id="user-page-board">';
        $b = new UserBoard();
        $output .= $b->displayMessages($user_id, 0, 10);
        $output .= '</div>';
        return $output;
    }
Exemplo n.º 8
0
function getNewMessagesLink() {
	global $wgUser, $wgScriptPath;
	$new_messages = UserBoard::getNewMessageCount( $wgUser->getID() );
	$output = '';
	if ( $new_messages > 0 ) {
		$board_link = SpecialPage::getTitleFor( 'UserBoard' );
		$output .= '<p>
			<img src="' . $wgScriptPath . '/extensions/SocialProfile/images/emailIcon.gif" alt="" border="" />
			<span class="profile-on"><a href="' . $board_link->escapeFullURL() . '" rel="nofollow">'
				. wfMsg( 'mp-request-new-message' ) .
			'</a></span>
		</p>';
	}
	return $output;
}
Exemplo n.º 9
0
    /**
     * Get the user board for a given user.
     *
     * @param $user_id Integer: user's ID number
     * @param $user_name String: user name
     */
    function getUserBoard($user_id, $user_name)
    {
        global $wgUser, $wgOut, $wgUserProfileDisplay;
        // Anonymous users cannot have user boards
        if ($user_id == 0) {
            return '';
        }
        // Don't display anything if user board on social profiles isn't
        // enabled in site configuration
        if ($wgUserProfileDisplay['board'] == false) {
            return '';
        }
        $output = '';
        // Prevent E_NOTICE
        // Add JS
        $wgOut->addModules('ext.socialprofile.userprofile.js');
        $rel = new UserRelationship($user_name);
        $friends = $rel->getRelationshipList(1, 4);
        $stats = new UserStats($user_id, $user_name);
        $stats_data = $stats->getUserStats();
        $total = $stats_data['user_board'];
        // If the user is viewing their own profile or is allowed to delete
        // board messages, add the amount of private messages to the total
        // sum of board messages.
        if ($wgUser->getName() == $user_name || $wgUser->isAllowed('userboard-delete')) {
            $total = $total + $stats_data['user_board_priv'];
        }
        $output .= '<div class="panel panel-default"><div class="user-section-heading panel-heading">
			<div class="user-section-title">' . wfMessage('user-board-title')->escaped() . '</div>
			<div class="user-section-actions">
				<div class="action-right">';
        if ($wgUser->getName() == $user_name) {
            if ($friends) {
                $output .= '<a href="' . UserBoard::getBoardBlastURL() . '">' . wfMessage('user-send-board-blast')->escaped() . '</a>';
            }
            if ($total > 10) {
                $output .= wfMessage('pipe-separator')->escaped();
            }
        }
        if ($total > 10) {
            $output .= '<a href="' . UserBoard::getUserBoardURL($user_name) . '">' . wfMessage('user-view-all')->escaped() . '</a>';
        }
        $output .= '</div>
				<div class="action-left">';
        if ($total > 10) {
            $output .= wfMessage('user-count-separator', '10', $total)->escaped();
        } elseif ($total > 0) {
            $output .= wfMessage('user-count-separator', $total, $total)->escaped();
        }
        $output .= '</div>
				<div class="cleared"></div>
			</div>
		</div>
		<div class="cleared"></div> <div class="panel-body">';
        if ($wgUser->getName() != $user_name) {
            if ($wgUser->isLoggedIn() && !$wgUser->isBlocked()) {
                $output .= '<div class="user-page-message-form">
						<input type="hidden" id="user_name_to" name="user_name_to" value="' . addslashes($user_name) . '" />
						<span class="profile-board-message-type">' . wfMessage('userboard_messagetype')->escaped() . '</span>
						<select id="message_type">
							<option value="0">' . wfMessage('userboard_public')->escaped() . '</option>
							<option value="1">' . wfMessage('userboard_private')->escaped() . '</option>
						</select><p><div class="form-group" style="padding:14px;">
                                      <textarea class="form-control" name="message" id="message" placeholder=""></textarea>
                                    </div>
						
						<div class="user-page-message-box-button">
							<input type="button" value="' . wfMessage('userboard_sendbutton')->escaped() . '" class="site-button mw-ui-button mw-ui-progressive" />
						</div>
					</div>';
            } else {
                $login_link = SpecialPage::getTitleFor('Userlogin');
                $output .= '<div class="user-page-message-form">' . wfMessage('user-board-login-message', $login_link->getFullURL())->escaped() . '</div>';
            }
        }
        $output .= '<div id="user-page-board">';
        $b = new UserBoard();
        $output .= $b->displayMessages($user_id, 0, 10);
        $output .= '</div></div></div>';
        return $output;
    }
Exemplo n.º 10
0
    /**
     * Show the special page
     *
     * @param $params Mixed: parameter(s) passed to the page or null
     */
    public function execute($params)
    {
        global $wgUser, $wgOut, $wgRequest, $wgScriptPath, $wgHooks, $wgUserBoardScripts;
        // This hooked function adds a global JS variable that UserBoard.js
        // uses to the HTML
        $wgHooks['MakeGlobalVariablesScript'][] = 'SpecialViewUserBoard::addJSGlobals';
        // Add CSS & JS
        $wgOut->addExtensionStyle($wgUserBoardScripts . '/UserBoard.css');
        $wgOut->addScriptFile($wgUserBoardScripts . '/UserBoard.js');
        $ub_messages_show = 25;
        $user_name = $wgRequest->getVal('user');
        $user_name_2 = $wgRequest->getVal('conv');
        $user_id_2 = '';
        // Prevent E_NOTICE
        $page = $wgRequest->getInt('page', 1);
        /**
         * Redirect Non-logged in users to Login Page
         * It will automatically return them to the UserBoard page
         */
        if ($wgUser->getID() == 0 && $user_name == '') {
            $login = SpecialPage::getTitleFor('Userlogin');
            $wgOut->redirect($login->getFullURL('returnto=Special:UserBoard'));
            return false;
        }
        /**
         * If no user is set in the URL, we assume its the current user
         */
        if (!$user_name) {
            $user_name = $wgUser->getName();
        }
        $user_id = User::idFromName($user_name);
        $user = Title::makeTitle(NS_USER, $user_name);
        $user_safe = str_replace('&', '%26', $user_name);
        if ($user_name_2) {
            $user_id_2 = User::idFromName($user_name_2);
            $user_2 = Title::makeTitle(NS_USER, $user_name);
            $user_safe_2 = urlencode($user_name_2);
        }
        /**
         * Error message for username that does not exist (from URL)
         */
        if ($user_id == 0) {
            $wgOut->showErrorPage('error', 'userboard_noexist');
            return false;
        }
        /**
         * Config for the page
         */
        $per_page = $ub_messages_show;
        $b = new UserBoard();
        $ub_messages = $b->getUserBoardMessages($user_id, $user_id_2, $ub_messages_show, $page);
        if (!$user_id_2) {
            $stats = new UserStats($user_id, $user_name);
            $stats_data = $stats->getUserStats();
            $total = $stats_data['user_board'];
            // If user is viewing their own board or is allowed to delete
            // others' board messages, show the total count of board messages
            // to them (public + private messages)
            if ($wgUser->getName() == $user_name || $wgUser->isAllowed('userboard-delete')) {
                $total = $total + $stats_data['user_board_priv'];
            }
        } else {
            $total = $b->getUserBoardToBoardCount($user_id, $user_id_2);
        }
        if (!$user_id_2) {
            if (!($wgUser->getName() == $user_name)) {
                $wgOut->setPageTitle(wfMsg('userboard_owner', $user_name));
            } else {
                $b->clearNewMessageCount($wgUser->getID());
                $wgOut->setPageTitle(wfMsg('userboard_yourboard'));
            }
        } else {
            if ($wgUser->getName() == $user_name) {
                $wgOut->setPageTitle(wfMsg('userboard_yourboardwith', $user_name_2));
            } else {
                $wgOut->setPageTitle(wfMsg('userboard_otherboardwith', $user_name, $user_name_2));
            }
        }
        $output = '<div class="user-board-top-links">';
        $output .= '<a href="' . $user->escapeFullURL() . '">&lt; ' . wfMsg('userboard_backprofile', $user_name) . '</a>';
        $output .= '</div>';
        $board_to_board = '';
        // Prevent E_NOTICE
        if ($page == 1) {
            $start = 1;
        } else {
            $start = ($page - 1) * $per_page + 1;
        }
        $end = $start + count($ub_messages) - 1;
        if ($wgUser->getName() != $user_name) {
            $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($wgUser->getName(), $user_name) . '">' . wfMsg('userboard_boardtoboard') . '</a>';
        }
        if ($total) {
            $output .= '<div class="user-page-message-top">
			<span class="user-page-message-count">' . wfMsg('userboard_showingmessages', $total, $start, $end, $end - $start + 1) . "</span> {$board_to_board}\n\t\t\t</div>";
        }
        /**
         * Build next/prev nav
         */
        $qs = '';
        if ($user_id_2) {
            $qs = "&conv={$user_safe_2}";
        }
        $numofpages = $total / $per_page;
        if ($numofpages > 1) {
            $output .= '<div class="page-nav">';
            if ($page > 1) {
                $output .= '<a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page - 1) . "{$qs}\">" . wfMsg('userboard_prevpage') . '</a>';
            }
            if ($total % $per_page != 0) {
                $numofpages++;
            }
            if ($numofpages >= 9 && $page < $total) {
                $numofpages = 9 + $page;
                if ($numofpages >= $total / $per_page) {
                    $numofpages = $total / $per_page + 1;
                }
            }
            for ($i = 1; $i <= $numofpages; $i++) {
                if ($i == $page) {
                    $output .= $i . ' ';
                } else {
                    $output .= '<a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page={$i}{$qs}\">{$i}</a> ";
                }
            }
            if ($total - $per_page * $page > 0) {
                $output .= ' <a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page + 1) . "{$qs}\">" . wfMsg('userboard_nextpage') . '</a>';
            }
            $output .= '</div><p>';
        }
        /**
         * Build next/prev nav
         */
        $can_post = false;
        $user_name_from = '';
        // Prevent E_NOTICE
        if (!$user_id_2) {
            if ($wgUser->getName() != $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name, ENT_QUOTES);
            }
        } else {
            if ($wgUser->getName() == $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name_2, ENT_QUOTES);
                $user_name_from = htmlspecialchars($user_name, ENT_QUOTES);
            }
        }
        if ($wgUser->isBlocked()) {
            // only let them post to admins
            //$user_to = User::newFromId( $user_id );
            // if( !$user_to->isAllowed( 'delete' ) ) {
            $can_post = false;
            // }
        }
        if ($can_post) {
            if ($wgUser->isLoggedIn() && !$wgUser->isBlocked()) {
                $output .= '<div class="user-page-message-form">
					<input type="hidden" id="user_name_to" name="user_name_to" value="' . $user_name_to . '"/>
					<input type="hidden" id="user_name_from" name="user_name_from" value="' . $user_name_from . '"/>
					<span class="user-board-message-type">' . wfMsg('userboard_messagetype') . ' </span>
					<select id="message_type">
						<option value="0">' . wfMsg('userboard_public') . '</option>
						<option value="1">' . wfMsg('userboard_private') . '</option>
					</select>
					<p>
					<textarea name="message" id="message" cols="63" rows="4"></textarea>

					<div class="user-page-message-box-button">
						<input type="button" value="' . wfMsg('userboard_sendbutton') . '" class="site-button" onclick="javascript:UserBoard.sendMessage(' . $per_page . ');" />
					</div>

				</div>';
            } else {
                $login_link = SpecialPage::getTitleFor('Userlogin');
                $output .= '<div class="user-page-message-form">' . wfMsg('userboard_loggedout', $login_link->escapeFullURL()) . '</div>';
            }
        }
        $output .= '<div id="user-page-board">';
        if ($ub_messages) {
            foreach ($ub_messages as $ub_message) {
                $user = Title::makeTitle(NS_USER, $ub_message['user_name_from']);
                $avatar = new wAvatar($ub_message['user_id_from'], 'm');
                $board_to_board = '';
                $board_link = '';
                $ub_message_type_label = '';
                $delete_link = '';
                if ($wgUser->getName() != $ub_message['user_name_from']) {
                    $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($user_name, $ub_message['user_name_from']) . '">' . wfMsg('userboard_boardtoboard') . '</a>';
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . wfMsg('userboard_sendmessage', $ub_message['user_name_from']) . '</a>';
                } else {
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . wfMsg('userboard_myboard') . '</a>';
                }
                // If the user owns this private message or they are allowed to
                // delete board messages, show the "delete" link to them
                if ($wgUser->getName() == $ub_message['user_name'] || $wgUser->isAllowed('userboard-delete')) {
                    $delete_link = "<span class=\"user-board-red\">\n\t\t\t\t\t\t<a href=\"javascript:void(0);\" onclick=\"javascript:UserBoard.deleteMessage({$ub_message['id']})\">" . wfMsg('userboard_delete') . '</a>
					</span>';
                }
                // Mark private messages as such
                if ($ub_message['type'] == 1) {
                    $ub_message_type_label = '(' . wfMsg('userboard_private') . ')';
                }
                // had global function to cut link text if too long and no breaks
                // $ub_message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i", 'cut_link_text', $ub_message['message_text'] );
                $ub_message_text = $ub_message['message_text'];
                $output .= "<div class=\"user-board-message\">\n\t\t\t\t\t<div class=\"user-board-message-from\">\n\t\t\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message['user_name_from']}}\">{$ub_message['user_name_from']} </a> {$ub_message_type_label}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"user-board-message-time\">" . wfMsgHtml('userboard_posted_ago', $b->getTimeAgo($ub_message['timestamp'])) . "</div>\n\t\t\t\t\t<div class=\"user-board-message-content\">\n\t\t\t\t\t\t<div class=\"user-board-message-image\">\n\t\t\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message['user_name_from']}\">{$avatar->getAvatarURL()}</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"user-board-message-body\">\n\t\t\t\t\t\t\t{$ub_message_text}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"cleared\"></div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"user-board-message-links\">\n\t\t\t\t\t\t{$board_link}\n\t\t\t\t\t\t{$board_to_board}\n\t\t\t\t\t\t{$delete_link}\n\t\t\t\t\t</div>\n\t\t\t\t</div>";
            }
        } else {
            $invite_title = SpecialPage::getTitleFor('InviteContacts');
            $output .= '<p>' . wfMsg('userboard_nomessages', $invite_title->escapeFullURL()) . '</p>';
        }
        $output .= '</div>';
        $wgOut->addHTML($output);
    }
Exemplo n.º 11
0
<?php

require_once "../common/UserBoard.php";
require_once 'Flow.php';
// Setup a new user
$u1 = new User(uniqid('user_'), "dummypass");
$u1->setName("Dummy user");
// Add it to the userboard
$ub = new UserBoard();
$ub->addUser($u1);
// Get the flow for the user, fill it with a status msg
$u1flow = new Flow($u1->getID());
$u1flow->addStatus("Wow it's so exciting ommayggod!");
$u1flow->addStatus("Now I'm really bored");
$u1flow->addStatus("Tomorrow I kill @the_sckr's dog.");
// Recall all the users from the userboard and iterate their statuses
$users = $ub->getAll();
date_default_timezone_set("EET");
foreach ($users as $u) {
    $uflow = new Flow($u->getID());
    $ustatuses = $uflow->getAll();
    if (count($ustatuses) > 0) {
        echo "Status flow of: " . $u->getID() . " (" . $u->getName() . ")\n";
        foreach ($ustatuses as $time => $status) {
            echo "\t" . date("d/m/y @ H:i:s", $time) . ": {$status}\n";
        }
    } else {
        echo "stale user!";
    }
}
Exemplo n.º 12
0
    /**
     * Show the special page
     *
     * @param $params Mixed: parameter(s) passed to the page or null
     */
    public function execute($params)
    {
        $out = $this->getOutput();
        $request = $this->getRequest();
        $currentUser = $this->getUser();
        // Set the page title, robot policies, etc.
        $this->setHeaders();
        // Add CSS & JS
        $out->addModuleStyles('ext.socialprofile.userboard.css');
        $out->addModules('ext.socialprofile.userboard.js');
        $ub_messages_show = 25;
        $user_name = $request->getVal('user');
        $user_name_2 = $request->getVal('conv');
        $user_id_2 = '';
        // Prevent E_NOTICE
        $page = $request->getInt('page', 1);
        /**
         * Redirect Non-logged in users to Login Page
         * It will automatically return them to the UserBoard page
         */
        if ($currentUser->getID() == 0 && $user_name == '') {
            $login = SpecialPage::getTitleFor('Userlogin');
            $out->redirect($login->getFullURL('returnto=Special:UserBoard'));
            return false;
        }
        /**
         * If no user is set in the URL, we assume its the current user
         */
        if (!$user_name) {
            $user_name = $currentUser->getName();
        }
        $user_id = User::idFromName($user_name);
        $user = Title::makeTitle(NS_USER, $user_name);
        if ($user_name_2) {
            $user_id_2 = User::idFromName($user_name_2);
            $user_2 = Title::makeTitle(NS_USER, $user_name);
        }
        /**
         * Error message for username that does not exist (from URL)
         */
        if ($user_id == 0) {
            $out->showErrorPage('error', 'userboard_noexist');
            return false;
        }
        /**
         * Config for the page
         */
        $per_page = $ub_messages_show;
        $b = new UserBoard();
        $ub_messages = $b->getUserBoardMessages($user_id, $user_id_2, $ub_messages_show, $page);
        if (!$user_id_2) {
            $stats = new UserStats($user_id, $user_name);
            $stats_data = $stats->getUserStats();
            $total = $stats_data['user_board'];
            // If user is viewing their own board or is allowed to delete
            // others' board messages, show the total count of board messages
            // to them (public + private messages)
            if ($currentUser->getName() == $user_name || $currentUser->isAllowed('userboard-delete')) {
                $total = $total + $stats_data['user_board_priv'];
            }
        } else {
            $total = $b->getUserBoardToBoardCount($user_id, $user_id_2);
        }
        if (!$user_id_2) {
            if (!($currentUser->getName() == $user_name)) {
                $out->setPageTitle($this->msg('userboard_owner', $user_name)->parse());
            } else {
                $b->clearNewMessageCount($currentUser->getID());
                $out->setPageTitle($this->msg('userboard_yourboard')->parse());
            }
        } else {
            if ($currentUser->getName() == $user_name) {
                $out->setPageTitle($this->msg('userboard_yourboardwith', $user_name_2)->parse());
            } else {
                $out->setPageTitle($this->msg('userboard_otherboardwith', $user_name, $user_name_2)->parse());
            }
        }
        $output = '<div class="user-board-top-links">';
        $output .= '<a href="' . htmlspecialchars($user->getFullURL()) . '">&lt; ' . $this->msg('userboard_backprofile', $user_name)->parse() . '</a>';
        $output .= '</div>';
        $board_to_board = '';
        // Prevent E_NOTICE
        if ($page == 1) {
            $start = 1;
        } else {
            $start = ($page - 1) * $per_page + 1;
        }
        $end = $start + count($ub_messages) - 1;
        if ($currentUser->getName() != $user_name) {
            $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($currentUser->getName(), $user_name) . '">' . $this->msg('userboard_boardtoboard')->plain() . '</a>';
        }
        if ($total) {
            $output .= '<div class="user-page-message-top">
			<span class="user-page-message-count">' . $this->msg('userboard_showingmessages', $total, $start, $end, $end - $start + 1)->parse() . "</span> {$board_to_board}\n\t\t\t</div>";
        }
        /**
         * Build next/prev navigation links
         */
        $qs = array();
        if ($user_id_2) {
            $qs['conv'] = $user_name_2;
        }
        $numofpages = $total / $per_page;
        if ($numofpages > 1) {
            $output .= '<div class="page-nav">';
            if ($page > 1) {
                $output .= Linker::link($this->getPageTitle(), $this->msg('userboard_prevpage')->plain(), array(), array('user' => $user_name, 'page' => $page - 1) + $qs);
            }
            if ($total % $per_page != 0) {
                $numofpages++;
            }
            if ($numofpages >= 9 && $page < $total) {
                $numofpages = 9 + $page;
                if ($numofpages >= $total / $per_page) {
                    $numofpages = $total / $per_page + 1;
                }
            }
            for ($i = 1; $i <= $numofpages; $i++) {
                if ($i == $page) {
                    $output .= $i . ' ';
                } else {
                    $output .= Linker::link($this->getPageTitle(), $i, array(), array('user' => $user_name, 'page' => $i) + $qs) . $this->msg('word-separator')->plain();
                }
            }
            if ($total - $per_page * $page > 0) {
                $output .= $this->msg('word-separator')->plain() . Linker::link($this->getPageTitle(), $this->msg('userboard_nextpage')->plain(), array(), array('user' => $user_name, 'page' => $page + 1) + $qs);
            }
            $output .= '</div><p>';
        }
        $can_post = false;
        $user_name_from = '';
        // Prevent E_NOTICE
        if (!$user_id_2) {
            if ($currentUser->getName() != $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name, ENT_QUOTES);
            }
        } else {
            if ($currentUser->getName() == $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name_2, ENT_QUOTES);
                $user_name_from = htmlspecialchars($user_name, ENT_QUOTES);
            }
        }
        if ($currentUser->isBlocked()) {
            // only let them post to admins
            //$user_to = User::newFromId( $user_id );
            // if( !$user_to->isAllowed( 'delete' ) ) {
            $can_post = false;
            // }
        }
        if ($can_post) {
            if ($currentUser->isLoggedIn() && !$currentUser->isBlocked()) {
                $output .= '<div class="user-page-message-form">
					<input type="hidden" id="user_name_to" name="user_name_to" value="' . $user_name_to . '"/>
					<input type="hidden" id="user_name_from" name="user_name_from" value="' . $user_name_from . '"/>
					<span class="user-board-message-type">' . $this->msg('userboard_messagetype')->plain() . ' </span>
					<select id="message_type">
						<option value="0">' . $this->msg('userboard_public')->plain() . '</option>
						<option value="1">' . $this->msg('userboard_private')->plain() . '</option>
					</select>
					<p>
					<textarea name="message" id="message" cols="63" rows="4"></textarea>

					<div class="user-page-message-box-button">
						<input type="button" value="' . $this->msg('userboard_sendbutton')->plain() . '" class="site-button" data-per-page="' . $per_page . '" />
					</div>

				</div>';
            } else {
                $output .= '<div class="user-page-message-form">' . $this->msg('userboard_loggedout')->parse() . '</div>';
            }
        }
        $output .= '<div id="user-page-board">';
        if ($ub_messages) {
            foreach ($ub_messages as $ub_message) {
                $user = Title::makeTitle(NS_USER, $ub_message['user_name_from']);
                $avatar = new wAvatar($ub_message['user_id_from'], 'm');
                $board_to_board = '';
                $board_link = '';
                $ub_message_type_label = '';
                $delete_link = '';
                if ($currentUser->getName() != $ub_message['user_name_from']) {
                    $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($user_name, $ub_message['user_name_from']) . '">' . $this->msg('userboard_boardtoboard')->plain() . '</a>';
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . $this->msg('userboard_sendmessage', $ub_message['user_name_from'])->parse() . '</a>';
                } else {
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . $this->msg('userboard_myboard')->plain() . '</a>';
                }
                // If the user owns this private message or they are allowed to
                // delete board messages, show the "delete" link to them
                if ($currentUser->getName() == $ub_message['user_name'] || $currentUser->isAllowed('userboard-delete')) {
                    $delete_link = "<span class=\"user-board-red\">\n\t\t\t\t\t\t<a href=\"javascript:void(0);\" data-message-id=\"{$ub_message['id']}\">" . $this->msg('userboard_delete')->plain() . '</a>
					</span>';
                }
                // Mark private messages as such
                if ($ub_message['type'] == 1) {
                    $ub_message_type_label = '(' . $this->msg('userboard_private')->plain() . ')';
                }
                // had global function to cut link text if too long and no breaks
                // $ub_message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i", 'cut_link_text', $ub_message['message_text'] );
                $ub_message_text = $ub_message['message_text'];
                $userPageURL = htmlspecialchars($user->getFullURL());
                $output .= "<div class=\"user-board-message\">\n\t\t\t\t\t<div class=\"user-board-message-content\">\n\t\t\t\t\t\t<div class=\"user-board-message-image\">\n\t\t\t\t\t\t\t<a href=\"{$userPageURL}\" title=\"{$ub_message['user_name_from']}\">{$avatar->getAvatarURL()}</a>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<a href=\"{$userPageURL}\" title=\"{$ub_message['user_name_from']}}\">{$ub_message['user_name_from']} </a> {$ub_message_type_label}\n\t\t\t\t\t\t<div class=\"user-board-message-time\">" . $this->msg('userboard_posted_ago', $b->getTimeAgo($ub_message['timestamp']))->parse() . "</div>\n\t\t\t\t\t\t<div class=\"user-board-message-body\">\n\t\t\t\t\t\t\t{$ub_message_text}\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"cleared\"></div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class=\"user-board-message-links\">\n\t\t\t\t\t\t{$board_link}\n\t\t\t\t\t\t{$board_to_board}\n\t\t\t\t\t\t{$delete_link}\n\t\t\t\t\t</div>\n\t\t\t\t</div>";
            }
        } else {
            $output .= '<p>' . $this->msg('userboard_nomessages')->parse() . '</p>';
        }
        $output .= '</div>';
        $out->addHTML($output);
    }
    /**
     * Show the special page
     *
     * @param $params Mixed: parameter(s) passed to the page or null
     */
    public function execute($params)
    {
        global $wgUser, $wgOut, $wgRequest, $wgScriptPath, $wgUserBoardScripts;
        // Add CSS
        $wgOut->addExtensionStyle($wgUserBoardScripts . '/UserBoard.css');
        $ub_messages_show = 25;
        $user_name = $wgRequest->getVal('user');
        $user_name_2 = $wgRequest->getVal('conv');
        $user_id_2 = '';
        // Prevent E_NOTICE
        $page = $wgRequest->getVal('page');
        /**
         * Redirect Non-logged in users to Login Page
         * It will automatically return them to the UserBoard page
         */
        if ($wgUser->getID() == 0 && $user_name == '') {
            $login = SpecialPage::getTitleFor('Userlogin');
            $wgOut->redirect($login->getFullURL('returnto=Special:UserBoard'));
            return false;
        }
        /**
         * If no user is set in the URL, we assume its the current user
         */
        if (!$user_name) {
            $user_name = $wgUser->getName();
        }
        $user_id = User::idFromName($user_name);
        $user = Title::makeTitle(NS_USER, $user_name);
        $user_safe = str_replace('&', '%26', $user_name);
        if ($user_name_2) {
            $user_id_2 = User::idFromName($user_name_2);
            $user_2 = Title::makeTitle(NS_USER, $user_name);
            $user_safe_2 = urlencode($user_name_2);
        }
        /**
         * Error message for username that does not exist (from URL)
         */
        if ($user_id == 0) {
            $wgOut->showErrorPage('error', 'userboard_noexist');
            return false;
        }
        /**
         * Config for the page
         */
        $per_page = $ub_messages_show;
        if (!$page || !is_numeric($page)) {
            $page = 1;
        }
        $b = new UserBoard();
        $ub_messages = $b->getUserBoardMessages($user_id, $user_id_2, $ub_messages_show, $page);
        if (!$user_id_2) {
            $stats = new UserStats($user_id, $user_name);
            $stats_data = $stats->getUserStats();
            $total = $stats_data['user_board'];
            // If user is viewing their own board or is allowed to delete
            // others' board messages, show the total count of board messages
            // to them (public + private messages)
            if ($wgUser->getName() == $user_name || $wgUser->isAllowed('userboard-delete')) {
                $total = $total + $stats_data['user_board_priv'];
            }
        } else {
            $total = $b->getUserBoardToBoardCount($user_id, $user_id_2);
        }
        if (!$user_id_2) {
            if (!($wgUser->getName() == $user_name)) {
                $wgOut->setPageTitle(wfMsg('userboard_owner', $user_name));
            } else {
                $b->clearNewMessageCount($wgUser->getID());
                $wgOut->setPageTitle(wfMsg('userboard_yourboard'));
            }
        } else {
            if ($wgUser->getName() == $user_name) {
                $wgOut->setPageTitle(wfMsg('userboard_yourboardwith', $user_name_2));
            } else {
                $wgOut->setPageTitle(wfMsg('userboard_otherboardwith', $user_name, $user_name_2));
            }
        }
        $output = '<div class="user-board-top-links">';
        $output .= '<a href="' . $user->escapeFullURL() . '">&lt; ' . wfMsg('userboard_backprofile', $user_name) . '</a>';
        $output .= '</div>';
        $output .= "<script type=\"text/javascript\">/*<![CDATA[*/\r\n\t\t\tvar _DELETE_CONFIRM = \"" . wfMsg('userboard_confirmdelete') . "\";\r\n\t\t\tvar posted = 0;\r\n\t\t\tfunction send_message() {\r\n\t\t\t\tif( document.getElementById('message').value && !posted ) {\r\n\t\t\t\t\tposted = 1;\r\n\t\t\t\t\tencodedName = encodeURIComponent( document.getElementById('user_name_to').value );\r\n\t\t\t\t\tencodedMsg = encodeURIComponent( document.getElementById('message').value );\r\n\t\t\t\t\tmessageType = document.getElementById('message_type').value;\r\n\t\t\t\t\tsajax_request_type = 'POST';\r\n\t\t\t\t\tsajax_do_call( 'wfSendBoardMessage', [ encodedName, encodedMsg, messageType, {$per_page} ], function( originalRequest ) {\r\n\t\t\t\t\t\t\tposted = 0;\r\n\t\t\t\t\t\t\tif( document.getElementById('user_name_from').value ) { // its a board to board\r\n\t\t\t\t\t\t\t\tuser_1 = document.getElementById('user_name_from').value;\r\n\t\t\t\t\t\t\t\tuser_2 = document.getElementById('user_name_to').value;\r\n\t\t\t\t\t\t\t} else {\r\n\t\t\t\t\t\t\t\tuser_1 = document.getElementById('user_name_to').value;\r\n\t\t\t\t\t\t\t\tuser_2 = '';\r\n\t\t\t\t\t\t\t}\r\n\t\t\t\t\t\t\tvar params = ( user_2 ) ? '&conv=' + user_2 : '';\r\n\t\t\t\t\t\t\tvar url = wgScriptPath + '/index.php?title=Special:UserBoard&user='******'POST';\r\n\t\t\t\t\tsajax_do_call( 'wfDeleteBoardMessage', [ id ], function( originalRequest ) {\r\n\t\t\t\t\t\twindow.location.reload();\r\n\t\t\t\t\t});\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t/*]]>*/</script>";
        $board_to_board = '';
        // Prevent E_NOTICE
        if ($page == 1) {
            $start = 1;
        } else {
            $start = ($page - 1) * $per_page + 1;
        }
        $end = $start + count($ub_messages) - 1;
        if ($wgUser->getName() != $user_name) {
            $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($wgUser->getName(), $user_name) . '">' . wfMsg('userboard_boardtoboard') . '</a>';
        }
        if ($total) {
            $output .= '<div class="user-page-message-top">
			<span class="user-page-message-count" style="font-size:11px;color:#666666;">' . wfMsg('userboard_showingmessages', $total, $start, $end, $end - $start + 1) . ".</span> {$board_to_board}</span>\r\n\t\t\t</div>";
        }
        /**
         * Build next/prev nav
         */
        if ($user_id_2) {
            $qs = "&conv={$user_safe_2}";
        }
        $numofpages = $total / $per_page;
        if ($numofpages > 1) {
            $output .= '<div class="page-nav">';
            if ($page > 1) {
                $output .= '<a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page - 1) . "{$qs}\">" . wfMsg('userboard_prevpage') . '</a>';
            }
            if ($total % $per_page != 0) {
                $numofpages++;
            }
            if ($numofpages >= 9 && $page < $total) {
                $numofpages = 9 + $page;
                if ($numofpages >= $total / $per_page) {
                    $numofpages = $total / $per_page + 1;
                }
            }
            for ($i = 1; $i <= $numofpages; $i++) {
                if ($i == $page) {
                    $output .= $i . ' ';
                } else {
                    $output .= '<a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page={$i}{$qs}\">{$i}</a> ";
                }
            }
            if ($total - $per_page * $page > 0) {
                $output .= ' <a href="' . $wgScriptPath . "/index.php?title=Special:UserBoard&user={$user_safe}&page=" . ($page + 1) . "{$qs}\">" . wfMsg('userboard_nextpage') . '</a>';
            }
            $output .= '</div><p>';
        }
        /**
         * Build next/prev nav
         */
        $can_post = false;
        $user_name_from = '';
        // Prevent E_NOTICE
        if (!$user_id_2) {
            if ($wgUser->getName() != $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name, ENT_QUOTES);
            }
        } else {
            if ($wgUser->getName() == $user_name) {
                $can_post = true;
                $user_name_to = htmlspecialchars($user_name_2, ENT_QUOTES);
                $user_name_from = htmlspecialchars($user_name, ENT_QUOTES);
            }
        }
        if ($wgUser->isBlocked()) {
            // only let them post to admins
            $user_to = User::newFromId($user_id);
            $user_to->loadFromId();
            // if( !$user_to->isAllowed( 'delete' ) ) {
            $can_post = false;
            // }
        }
        if ($can_post) {
            if ($wgUser->isLoggedIn() && !$wgUser->isBlocked()) {
                $output .= '<div class="user-page-message-form">
					<input type="hidden" id="user_name_to" name="user_name_to" value="' . $user_name_to . '"/>
					<input type="hidden" id="user_name_from" name="user_name_from" value="' . $user_name_from . '"/>
					<span style="color:#797979;">' . wfMsg('userboard_messagetype') . ' </span>
					<select id="message_type">
						<option value="0">' . wfMsg('userboard_public') . '</option>
						<option value="1">' . wfMsg('userboard_private') . '</option>
					</select>
					<p>
					<textarea name="message" id="message" cols="63" rows="4"></textarea>

					<div class="user-page-message-box-button">
						<input type="button" value="' . wfMsg('userboard_sendbutton') . '" class="site-button" onclick="javascript:send_message();" />
					</div>

				</div>';
            } else {
                $login_link = SpecialPage::getTitleFor('Userlogin');
                $output .= '<div class="user-page-message-form">' . wfMsg('userboard_loggedout', $login_link->escapeFullURL()) . '</div>';
            }
        }
        $output .= '<div id="user-page-board">';
        if ($ub_messages) {
            foreach ($ub_messages as $ub_message) {
                $user = Title::makeTitle(NS_USER, $ub_message['user_name_from']);
                $avatar = new wAvatar($ub_message['user_id_from'], 'm');
                $board_to_board = '';
                $board_link = '';
                $ub_message_type_label = '';
                $delete_link = '';
                if ($wgUser->getName() != $ub_message['user_name_from']) {
                    $board_to_board = '<a href="' . UserBoard::getUserBoardToBoardURL($user_name, $ub_message['user_name_from']) . '">' . wfMsg('userboard_boardtoboard') . '</a>';
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . wfMsg('userboard_sendmessage', $ub_message['user_name_from']) . '</a>';
                } else {
                    $board_link = '<a href="' . UserBoard::getUserBoardURL($ub_message['user_name_from']) . '">' . wfMsg('userboard_myboard') . '</a>';
                }
                if ($wgUser->getName() == $ub_message['user_name'] || $wgUser->isAllowed('userboard-delete')) {
                    $delete_link = "<span class=\"user-board-red\">\r\n\t\t\t\t\t\t<a href=\"javascript:void(0);\" onclick=\"javascript:delete_message({$ub_message['id']})\">" . wfMsg('userboard_delete') . '</a>
					</span>';
                }
                if ($ub_message['type'] == 1) {
                    $ub_message_type_label = '(' . wfMsg('userboard_private') . ')';
                }
                // had global function to cut link text if too long and no breaks
                // $ub_message_text = preg_replace_callback( "/(<a[^>]*>)(.*?)(<\/a>)/i", 'cut_link_text', $ub_message['message_text'] );
                $ub_message_text = $ub_message['message_text'];
                $output .= "<div class=\"user-board-message\" style=\"width:550px\">\r\n\t\t\t\t\t<div class=\"user-board-message-from\">\r\n\t\t\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message['user_name_from']}}\">{$ub_message['user_name_from']} </a> {$ub_message_type_label}\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"user-board-message-time\">" . wfMsgHtml('userboard_posted_ago', $b->getTimeAgo($ub_message['timestamp'])) . "</div>\r\n\t\t\t\t\t<div class=\"user-board-message-content\">\r\n\t\t\t\t\t\t<div class=\"user-board-message-image\">\r\n\t\t\t\t\t\t\t<a href=\"{$user->escapeFullURL()}\" title=\"{$ub_message['user_name_from']}\">{$avatar->getAvatarURL()}</a>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"user-board-message-body\">\r\n\t\t\t\t\t\t\t{$ub_message_text}\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t<div class=\"cleared\"></div>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"user-board-message-links\">\r\n\t\t\t\t\t\t{$board_link}\r\n\t\t\t\t\t\t{$board_to_board}\r\n\t\t\t\t\t\t{$delete_link}\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>";
            }
        } else {
            $invite_title = SpecialPage::getTitleFor('InviteContacts');
            $output .= '<p>' . wfMsg('userboard_nomessages', $invite_title->escapeFullURL()) . '</p>';
        }
        $output .= '</div>';
        $wgOut->addHTML($output);
    }
 public function getBoard($board_id)
 {
     $result = UserBoard::getBoardById($board_id);
     return response()->view('board', ["board" => $result["board"], "profile" => $result["profile"], "posts" => $result["posts"]]);
 }