includes/comment.php
changeset 108 1c7f59df9474
parent 86 c162ca39db8f
child 142 ca9118d9c0f2
equal deleted inserted replaced
107:4042c4dd5ba4 108:1c7f59df9474
   104           $template->load_theme();
   104           $template->load_theme();
   105         if ( !isset($data['have_template']) )
   105         if ( !isset($data['have_template']) )
   106         {
   106         {
   107           $ret['template'] = file_get_contents(ENANO_ROOT . '/themes/' . $template->theme . '/comment.tpl');
   107           $ret['template'] = file_get_contents(ENANO_ROOT . '/themes/' . $template->theme . '/comment.tpl');
   108         }
   108         }
   109         $q = $db->sql_query('SELECT c.comment_id,c.name,c.subject,c.comment_data,c.time,c.approved,u.user_level,u.user_id,u.signature FROM '.table_prefix.'comments AS c
   109         $q = $db->sql_query('SELECT c.comment_id,c.name,c.subject,c.comment_data,c.time,c.approved,u.user_level,u.user_id,u.signature, b.buddy_id IS NOT NULL AS is_buddy, ( b.is_friend IS NOT NULL AND b.is_friend=1 ) AS is_friend FROM '.table_prefix.'comments AS c
   110                                LEFT JOIN '.table_prefix.'users AS u
   110                                LEFT JOIN '.table_prefix.'users AS u
   111                                  ON (u.user_id=c.user_id)
   111                                  ON (u.user_id=c.user_id)
       
   112                                LEFT JOIN '.table_prefix.'buddies AS b
       
   113                                  ON ( ( b.user_id=' . $session->user_id.' AND b.buddy_user_id=c.user_id ) OR b.user_id IS NULL)
   112                                WHERE page_id=\'' . $this->page_id . '\'
   114                                WHERE page_id=\'' . $this->page_id . '\'
   113                                  AND namespace=\'' . $this->namespace . '\';');
   115                                  AND namespace=\'' . $this->namespace . '\'
       
   116                                GROUP BY c.comment_id
       
   117                                ORDER BY c.time ASC;');
   114         $count_appr = 0;
   118         $count_appr = 0;
   115         $count_total = 0;
   119         $count_total = 0;
   116         $count_unappr = 0;
   120         $count_unappr = 0;
   117         $ret['comments'] = Array();
   121         $ret['comments'] = Array();
   118         if (!$q)
   122         if (!$q)
   131             // Send the source
   135             // Send the source
   132             $row['comment_source'] = $row['comment_data'];
   136             $row['comment_source'] = $row['comment_data'];
   133             
   137             
   134             // Format text
   138             // Format text
   135             $row['comment_data'] = RenderMan::render($row['comment_data']);
   139             $row['comment_data'] = RenderMan::render($row['comment_data']);
       
   140             
       
   141             if ( $row['is_buddy'] == 1 && $row['is_friend'] == 0 )
       
   142             {
       
   143               $seed = md5(sha1(mt_rand() . microtime()));
       
   144               $wrapper = '
       
   145                 <div id="posthide_'.$seed.'" style="display: none;">
       
   146                   ' . $row['comment_data'] . '
       
   147                 </div>
       
   148                 <p><span style="opacity: 0.4; filter: alpha(opacity=40);">Post from foe hidden.</span> <span style="text-align: right;"><a href="#showpost" onclick="document.getElementById(\'posthide_'.$seed.'\').style.display=\'block\'; this.parentNode.parentNode.parentNode.removeChild(this.parentNode.parentNode); return false;">Display post</a></span></p>
       
   149               ';
       
   150               $row['comment_data'] = $wrapper;
       
   151             }
   136             
   152             
   137             // Format date
   153             // Format date
   138             $row['time'] = date('F d, Y h:i a', $row['time']);
   154             $row['time'] = date('F d, Y h:i a', $row['time']);
   139             
   155             
   140             // Format signature
   156             // Format signature