Ticket #354: commentwall-walltowall.diff

File commentwall-walltowall.diff, 4.6 kB (added by justinr, 3 months ago)

Wall-to-wall patch (fixed)

  • mod/commentwall/lib.php

    old new  
    8282                 
    8383                return get_records_sql($query); 
    8484        } 
     85 
     86 
     87        /** 
     88         * Retrieve the wall-to-wall for a given pair of userids. 
     89         * 
     90         * @return mixed Array of comment objects, else returns false. 
     91         * @param unknown_type $userid The user / wall we are retrieving 
     92         * @param unknown_type $limit Limit on the search 
     93         * @param unknown_type $offset Offset 
     94         */ 
     95        function commentwall_getwalltowall($userid, $otherid, $limit = 10, $offset = 0) 
     96        { 
     97                global $CFG; 
     98                 
     99                $query = "SELECT * FROM " . $CFG->prefix . "commentwall " .  
     100                         "WHERE (wallowner=" . $userid . " AND comment_owner=" . $otherid . ") OR ". 
     101                         "(wallowner=" . $otherid . " AND comment_owner=" . $userid . ") ". 
     102                         "ORDER BY posted desc LIMIT " . $offset . "," . $limit; 
     103                 
     104                //echo $query; 
     105                 
     106                return get_records_sql($query); 
     107        } 
     108 
    85109         
    86110        /** 
    87111         * Add a comment to a wall. 
     
    223247                $text = $comment_obj->content; 
    224248                 
    225249                $replytowall = __gettext("Post reply"); 
    226                 $replytootherwall = sprintf(__gettext("Reply on %s's wall"), $comment_owner_username); 
     250                $replytootherwall = sprintf(__gettext("%s's wall"), $comment_owner_username); 
     251                $walltowall = __gettext("Wall-to-wall"); 
    227252                $delete = __gettext("Delete"); 
    228253                 
    229                 $doaction = "{$CFG->wwwroot}mod/commentwall/do_action.php?owner=" . page_owner(). "&return_url=" .urlencode($_SERVER['REQUEST_URI']); 
     254                $doaction = "{$CFG->wwwroot}mod/commentwall/do_action.php?owner=" . $comment_obj->wallowner. "&return_url=" .urlencode($_SERVER['REQUEST_URI']); 
    230255 
    231256                $replybar = ""; 
    232257                if (isloggedin()) 
    233258                { 
    234259                        //$replybar .= "<a href=\"#commentwall_form_-1\">$replytowall</a>"; 
    235                        if (($comment_obj->wallowner != $comment_obj->comment_owner) && ($comment_obj->comment_owner != 0)) 
     260                  if (($comment_obj->wallowner != $comment_obj->comment_owner) && ($comment_obj->comment_owner != 0)) { 
    236261                                $replybar .= "<a href=\"{$CFG->wwwroot}mod/commentwall/index.php?owner={$comment_obj->comment_owner}&wallowner={$comment_obj->comment_owner}&comment_owner={$_SESSION['userid']}&reply={$comment_obj->ident}&return_url=" .urlencode($_SERVER['REQUEST_URI'])."\">$replytootherwall</a> | ";     
    237          
    238                         if ((commentwall_permissions_check($comment_obj->comment_owner)) 
    239                         || (commentwall_permissions_check($comment_obj->wallowner))) 
    240                                 $replybar.= "<a href=\"$doaction&action=commentwall::delete&ident={$comment_obj->ident}\">$delete</a>"; 
     262                                $replybar .= "<a href=\"{$CFG->wwwroot}mod/commentwall/walltowall.php?owner={$comment_obj->wallowner}&other={$comment_obj->comment_owner}&return_url=" .urlencode($_SERVER['REQUEST_URI'])."\">$walltowall</a> | "; 
     263                  } 
     264                  if ((commentwall_permissions_check($comment_obj->comment_owner)) 
     265                      || (commentwall_permissions_check($comment_obj->wallowner))) 
     266                    $replybar.= "<a href=\"$doaction&action=commentwall::delete&ident={$comment_obj->ident}\">$delete</a>"; 
    241267                } 
    242268 
    243269 
     
    314340                ) 
    315341                { 
    316342            // $owner = page_owner(); 
    317             $html = "<div id=\"commentwall_title\"><h2>" . sprintf(__gettext("%s's comment wall"), user_info("name", page_owner())) . "</h2></div>"; 
     343            $html = "<div id=\"commentwall_title\"><h2>" . sprintf(__gettext("Write on %s's comment wall"), user_info("name", $owner)) . "</h2></div>"; 
    318344 
    319345            if (($showalltxt) && ($wall)) 
    320346            { 
     
    322348            } 
    323349 
    324350 
    325             $html .= commentwall_post_form(page_owner()); 
     351            $html .= commentwall_post_form($owner); 
    326352                 
    327353                if (!$wall) { 
    328354                        $html .= "<p>" . __gettext("No comments on this wall, why not be the first?") . "</p>"; 
  • mod/commentwall/walltowall.php

    old new  
     1<?php 
     2  /** wall-to-wall viewing page */ 
     3 
     4  // Load the Elgg framework 
     5 
     6require_once("../../includes.php"); 
     7global $CFG, $messages; 
     8 
     9/* 
     10 * Variable initialisation 
     11 */ 
     12 
     13$owner = optional_param('owner', page_owner()); 
     14     
     15$other = required_param('other'); 
     16 
     17$offset = optional_param('offset', 0); 
     18$limit = optional_param('limit', 10); 
     19     
     20$title = sprintf(__gettext("%s and %s's Wall-to-wall"), user_info("name", $owner), user_info("name", $other)); 
     21     
     22$wall = commentwall_getwalltowall($owner, $other, $limit, $offset); 
     23 
     24$html = commentwall_displaywall_html($wall, true, $other); 
     25$html.= commentwall_display_footer($owner, $limit, $offset); 
     26     
     27templates_page_output($title, $html); 
     28     
     29?>