95 echo $parser->encode($ret); |
95 echo $parser->encode($ret); |
96 return $ret; |
96 return $ret; |
97 } |
97 } |
98 $ret = Array(); |
98 $ret = Array(); |
99 $ret['mode'] = $data['mode']; |
99 $ret['mode'] = $data['mode']; |
|
100 $ret['avatar_directory'] = getConfig('avatar_directory'); |
100 switch ( $data['mode'] ) |
101 switch ( $data['mode'] ) |
101 { |
102 { |
102 case 'fetch': |
103 case 'fetch': |
103 if ( !$template->theme_loaded ) |
104 if ( !$template->theme_loaded ) |
104 $template->load_theme(); |
105 $template->load_theme(); |
105 if ( !isset($data['have_template']) ) |
106 if ( !isset($data['have_template']) ) |
106 { |
107 { |
107 $ret['template'] = file_get_contents(ENANO_ROOT . '/themes/' . $template->theme . '/comment.tpl'); |
108 $ret['template'] = file_get_contents(ENANO_ROOT . '/themes/' . $template->theme . '/comment.tpl'); |
108 } |
109 } |
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 $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,u.user_has_avatar,u.avatar_type, 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 |
111 LEFT JOIN '.table_prefix.'users AS u |
111 ON (u.user_id=c.user_id) |
112 ON (u.user_id=c.user_id) |
112 LEFT JOIN '.table_prefix.'buddies AS b |
113 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) |
114 ON ( ( b.user_id=' . $session->user_id.' AND b.buddy_user_id=c.user_id ) OR b.user_id IS NULL) |
114 WHERE page_id=\'' . $this->page_id . '\' |
115 WHERE page_id=\'' . $this->page_id . '\' |
115 AND namespace=\'' . $this->namespace . '\' |
116 AND namespace=\'' . $this->namespace . '\' |
116 GROUP BY 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,b.is_friend |
117 GROUP BY c.comment_id,c.name,c.subject,c.comment_data,c.time,c.approved,u.user_level,u.user_id,u.signature,u.user_has_avatar,u.avatar_type,b.buddy_id,b.is_friend |
117 ORDER BY c.time ASC;'); |
118 ORDER BY c.time ASC;'); |
118 $count_appr = 0; |
119 $count_appr = 0; |
119 $count_total = 0; |
120 $count_total = 0; |
120 $count_unappr = 0; |
121 $count_unappr = 0; |
121 $ret['comments'] = Array(); |
122 $ret['comments'] = Array(); |
300 "('$this->page_id', '$this->namespace', '$name', '$subj', '$sql_text', $appr, $time, $session->user_id);"); |
301 "('$this->page_id', '$this->namespace', '$name', '$subj', '$sql_text', $appr, $time, $session->user_id);"); |
301 if(!$q) |
302 if(!$q) |
302 $db->die_json(); |
303 $db->die_json(); |
303 |
304 |
304 // Re-fetch |
305 // Re-fetch |
305 $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 |
306 $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,u.user_has_avatar,u.avatar_type FROM '.table_prefix.'comments AS c |
306 LEFT JOIN '.table_prefix.'users AS u |
307 LEFT JOIN '.table_prefix.'users AS u |
307 ON (u.user_id=c.user_id) |
308 ON (u.user_id=c.user_id) |
308 WHERE page_id=\'' . $this->page_id . '\' |
309 WHERE page_id=\'' . $this->page_id . '\' |
309 AND namespace=\'' . $this->namespace . '\' |
310 AND namespace=\'' . $this->namespace . '\' |
310 AND time='.$time.' ORDER BY comment_id DESC LIMIT 1;'); |
311 AND time='.$time.' ORDER BY comment_id DESC LIMIT 1;'); |
332 $ret['user_level_list'] = Array(); |
333 $ret['user_level_list'] = Array(); |
333 $ret['user_level_list']['guest'] = USER_LEVEL_GUEST; |
334 $ret['user_level_list']['guest'] = USER_LEVEL_GUEST; |
334 $ret['user_level_list']['member'] = USER_LEVEL_MEMBER; |
335 $ret['user_level_list']['member'] = USER_LEVEL_MEMBER; |
335 $ret['user_level_list']['mod'] = USER_LEVEL_MOD; |
336 $ret['user_level_list']['mod'] = USER_LEVEL_MOD; |
336 $ret['user_level_list']['admin'] = USER_LEVEL_ADMIN; |
337 $ret['user_level_list']['admin'] = USER_LEVEL_ADMIN; |
337 |
338 $ret['avatar_directory'] = getConfig('avatar_directory'); |
338 } |
339 } |
339 |
340 |
340 break; |
341 break; |
341 case 'approve': |
342 case 'approve': |
342 if ( !$this->perms->get_permissions('mod_comments') ) |
343 if ( !$this->perms->get_permissions('mod_comments') ) |