28.08.2017, 22:17
Witam, próbuje edytować plugin Statystyki top i chciałbym do tabelki z np. Last Thread dodać prefixy, oczywiście jeżeli są.
Aktualnie mam tak, ucinek kodu pluginu
dodałem do zapytania t.prefix oraz zmienną [$tpl['prefix'] = build_prefixes($row['prefix']);
Myślałem, że to wystarczy, ale pokazuje tylko array
[attachment=12564]
Co bym musiał zrobić, żeby zadziałało?
Aktualnie mam tak, ucinek kodu pluginu
Kod PHP:
public function widget_LastThreads()
{
global $db, $lang, $mybb, $templates, $theme, $topStats;
require_once MYBB_ROOT."inc/class_parser.php";
require_once MYBB_ROOT."inc/functions_search.php";
$parser = new postParser;
$permsql = "";
$onlyusfids = array();
$group_permissions = forum_permissions();
foreach($group_permissions as $fid => $forum_permissions)
{
if(isset($forum_permissions['canonlyviewownthreads']) && $forum_permissions['canonlyviewownthreads'] == 1)
{
$onlyusfids[] = $fid;
}
}
if(!empty($onlyusfids))
{
$permsql .= "AND ((t.fid IN(".implode(',', $onlyusfids).") AND t.uid='{$mybb->user['uid']}') OR t.fid NOT IN(".implode(',', $onlyusfids)."))";
}
$unsearchforums = get_unsearchable_forums();
if($unsearchforums)
{
$permsql .= " AND t.fid NOT IN ($unsearchforums)";
}
$inactiveforums = get_inactive_forums();
if($inactiveforums)
{
$permsql .= " AND t.fid NOT IN ($inactiveforums)";
}
$tpl['ignore_forums'] = '';
if(!empty($mybb->settings['topStats_IgnoreForums_LastThreads']))
{
$tpl['ignore_forums'] = "AND t.fid NOT IN ({$mybb->settings['topStats_IgnoreForums_LastThreads']})";
}
$tpl['row'] = '';
$sql = "SELECT t.uid, t.tid, t.prefix, t.subject, t.dateline, t.fid, u.usergroup, u.displaygroup, u.avatar, u.avatardimensions, u.username, u.uid
FROM ".TABLE_PREFIX."threads AS t
INNER JOIN ".TABLE_PREFIX."users AS u USING (uid)
WHERE 1=1 {$tpl['ignore_forums']} {$unapproved_where} {$permsql} AND t.visible='1' AND t.closed NOT LIKE 'moved|%'
ORDER BY t.tid DESC LIMIT ". (int)$this->getConfig('Limit_LastThreads') ."";
$result = $db->query($sql);
while ($row = $db->fetch_array($result))
{
$forumpermissions[$row['fid']] = forum_permissions($row['fid']);
if(isset($forumpermissions[$row['fid']]['canonlyviewownthreads']) && $forumpermissions[$row['fid']]['canonlyviewownthreads'] == 1 && $row['uid'] != $mybb->user['uid'])
{
continue;
}
$subject = $parser->parse_badwords(htmlspecialchars_uni($row['subject']));
$tpl['subject'] = (my_strlen($subject) > 30) ? my_substr($subject, 0, 30) . "..." : $subject;
$tpl['username'] = format_name($row['username'], $row['usergroup'], $row['displaygroup']);
$tpl['profilelink'] = build_profile_link($tpl['username'], $row['uid']);
$tpl['date'] = my_date('relative', $row['dateline']);
$tpl['subjectlink'] = get_thread_link($row['tid']);
$tpl['prefix'] = build_prefixes($row['prefix']);
$useravatar = format_avatar(htmlspecialchars_uni($row['avatar']), $row['avatardimensions'], my_strtolower($this->getConfig('AvatarWidth')));
(!$this->getConfig('Status_Avatar')) ? '' : eval("\$tpl['avatar'] = \"".$templates->get("topStats_LastThreadsAvatar")."\";");
eval("\$tpl['row'] .= \"" . $templates->get("topStats_LastThreadsRow") . "\";");
}
eval("\$topStats['LastThreads'] = \"" . $templates->get("topStats_LastThreads") . "\";");
}
Myślałem, że to wystarczy, ale pokazuje tylko array
[attachment=12564]
Co bym musiał zrobić, żeby zadziałało?