function build_cache_usergroups_single() { $pluginvalue = pluginsettingvalue('groups'); $allowthreadplugin = C::t('common_setting')->fetch('allowthreadplugin', true); $data_uf = C::t('common_usergroup_field')->range(); $data_ag = C::t('common_admingroup')->range(); foreach (C::t('common_usergroup')->range() as $gid => $data) { $data = array_merge($data, (array) $data_uf[$gid], (array) $data_ag[$gid]); $ratearray = array(); if ($data['raterange']) { foreach (explode("\n", $data['raterange']) as $rating) { $rating = explode("\t", $rating); $ratearray[$rating[0]] = array('isself' => $rating[1], 'min' => $rating[2], 'max' => $rating[3], 'mrpd' => $rating[4]); } } $data['raterange'] = $ratearray; $data['grouptitle'] = $data['color'] ? '<font color="' . $data['color'] . '">' . $data['grouptitle'] . '</font>' : $data['grouptitle']; $data['grouptype'] = $data['type']; $data['grouppublic'] = $data['system'] != 'private'; $data['groupcreditshigher'] = $data['creditshigher']; $data['groupcreditslower'] = $data['creditslower']; $data['maxspacesize'] = intval($data['maxspacesize']) * 1024 * 1024; $data['allowthreadplugin'] = !empty($allowthreadplugin[$data['groupid']]) ? $allowthreadplugin[$data['groupid']] : array(); $data['plugin'] = $pluginvalue[$data['groupid']]; unset($data['type'], $data['system'], $data['creditshigher'], $data['creditslower'], $data['groupavatar'], $data['admingid']); savecache('usergroup_' . $data['groupid'], $data); } }
function build_cache_usergroups_single() { $pluginvalue = pluginsettingvalue('groups'); $allowthreadplugin = unserialize(DB::result_first("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='allowthreadplugin'")); $query = DB::query("SELECT * FROM " . DB::table('common_usergroup') . " u\r\n\t\tLEFT JOIN " . DB::table('common_usergroup_field') . " uf ON u.groupid=uf.groupid\r\n\t\tLEFT JOIN " . DB::table('common_admingroup') . " a ON u.groupid=a.admingid"); while ($data = DB::fetch($query)) { $ratearray = array(); if ($data['raterange']) { foreach (explode("\n", $data['raterange']) as $rating) { $rating = explode("\t", $rating); $ratearray[$rating[0]] = array('isself' => $rating[1], 'min' => $rating[2], 'max' => $rating[3], 'mrpd' => $rating[4]); } } $data['raterange'] = $ratearray; $data['grouptitle'] = $data['color'] ? '<font color="' . $data['color'] . '">' . $data['grouptitle'] . '</font>' : $data['grouptitle']; $data['grouptype'] = $data['type']; $data['grouppublic'] = $data['system'] != 'private'; $data['groupcreditshigher'] = $data['creditshigher']; $data['groupcreditslower'] = $data['creditslower']; $data['maxspacesize'] = intval($data['maxspacesize']) * 1024 * 1024; $data['allowthreadplugin'] = !empty($allowthreadplugin[$data['groupid']]) ? $allowthreadplugin[$data['groupid']] : array(); $data['plugin'] = $pluginvalue[$data['groupid']]; unset($data['type'], $data['system'], $data['creditshigher'], $data['creditslower'], $data['groupavatar'], $data['admingid']); save_syscache('usergroup_' . $data['groupid'], $data); } }
function build_cache_forums() { $data = array(); /*vot*/ $query = DB::query("SELECT f.fid, f.type, f.name, f.fup, f.simple, f.status, f.allowpostspecial, ff.viewperm, ff.formulaperm, ff.viewperm, ff.postperm, ff.replyperm, ff.getattachperm, ff.postattachperm, ff.extra, ff.commentitem, a.uid FROM " . DB::table('forum_forum') . " f\r\n\t\tLEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=f.fid LEFT JOIN " . DB::table('forum_access') . " a ON (a.fid=f.fid AND a.allowview>'0') WHERE f.status<>'3' ORDER BY f.type, f.displayorder"); $pluginvalue = $forumlist = array(); $nopermdefault = array('viewperm' => array(), 'getattachperm' => array(), 'postperm' => array(7), 'replyperm' => array(7), 'postattachperm' => array(7)); $pluginvalue = pluginsettingvalue('forums'); $forumnoperms = array(); while ($forum = DB::fetch($query)) { $forum['orderby'] = bindec(($forum['simple'] & 128 ? 1 : 0) . ($forum['simple'] & 64 ? 1 : 0)); $forum['ascdesc'] = $forum['simple'] & 32 ? 'ASC' : 'DESC'; $forum['extra'] = unserialize($forum['extra']); if (!is_array($forum['extra'])) { $forum['extra'] = array(); } if (!isset($forumlist[$forum['fid']])) { $forum['name'] = strip_tags($forum['name']); if ($forum['uid']) { $forum['users'] = "\t{$forum['uid']}\t"; } unset($forum['uid']); if ($forum['fup']) { $forumlist[$forum['fup']]['count']++; } $forumlist[$forum['fid']] = $forum; } elseif ($forum['uid']) { if (!$forumlist[$forum['fid']]['users']) { $forumlist[$forum['fid']]['users'] = "\t"; } $forumlist[$forum['fid']]['users'] .= "{$forum['uid']}\t"; } } $data = array(); if (!empty($forumlist)) { foreach ($forumlist as $fid1 => $forum1) { if ($forum1['type'] == 'group' && $forum1['count']) { $data[$fid1] = formatforumdata($forum1, $pluginvalue); unset($data[$fid1]['users'], $data[$fid1]['allowpostspecial'], $data[$fid1]['commentitem']); foreach ($forumlist as $fid2 => $forum2) { if ($forum2['fup'] == $fid1 && $forum2['type'] == 'forum') { $data[$fid2] = formatforumdata($forum2, $pluginvalue); foreach ($forumlist as $fid3 => $forum3) { if ($forum3['fup'] == $fid2 && $forum3['type'] == 'sub') { $data[$fid3] = formatforumdata($forum3, $pluginvalue); } } } } } } } save_syscache('forums', $data); }
function build_cache_forums() { $data = array(); $forums = C::t('forum_forum')->fetch_all_forum(); $pluginvalue = $forumlist = array(); $pluginvalue = pluginsettingvalue('forums'); $forumnoperms = array(); foreach ($forums as $val) { $forum = array('fid' => $val['fid'], 'type' => $val['type'], 'name' => $val['name'], 'fup' => $val['fup'], 'simple' => $val['simple'], 'status' => $val['status'], 'allowpostspecial' => $val['allowpostspecial'], 'viewperm' => $val['viewperm'], 'formulaperm' => $val['formulaperm'], 'havepassword' => $val['password'], 'postperm' => $val['postperm'], 'replyperm' => $val['replyperm'], 'getattachperm' => $val['getattachperm'], 'postattachperm' => $val['postattachperm'], 'extra' => $val['extra'], 'commentitem' => $val['commentitem'], 'uid' => $val['uid'], 'archive' => $val['archive'], 'domain' => $val['domain']); $forum['orderby'] = bindec(($forum['simple'] & 128 ? 1 : 0) . ($forum['simple'] & 64 ? 1 : 0)); $forum['ascdesc'] = $forum['simple'] & 32 ? 'ASC' : 'DESC'; $forum['extra'] = unserialize($forum['extra']); if (!is_array($forum['extra'])) { $forum['extra'] = array(); } if (!isset($forumlist[$forum['fid']])) { if ($forum['uid']) { $forum['users'] = "\t{$forum['uid']}\t"; } unset($forum['uid']); if ($forum['fup']) { $forumlist[$forum['fup']]['count']++; } $forumlist[$forum['fid']] = $forum; } elseif ($forum['uid']) { if (!$forumlist[$forum['fid']]['users']) { $forumlist[$forum['fid']]['users'] = "\t"; } $forumlist[$forum['fid']]['users'] .= "{$forum['uid']}\t"; } } $data = array(); if (!empty($forumlist)) { foreach ($forumlist as $fid1 => $forum1) { if ($forum1['type'] == 'group' && $forum1['count']) { $data[$fid1] = formatforumdata($forum1, $pluginvalue); unset($data[$fid1]['users'], $data[$fid1]['allowpostspecial'], $data[$fid1]['commentitem']); foreach ($forumlist as $fid2 => $forum2) { if ($forum2['fup'] == $fid1 && $forum2['type'] == 'forum') { $data[$fid2] = formatforumdata($forum2, $pluginvalue); foreach ($forumlist as $fid3 => $forum3) { if ($forum3['fup'] == $fid2 && $forum3['type'] == 'sub') { $data[$fid3] = formatforumdata($forum3, $pluginvalue); } } } } } } } savecache('forums', $data); }
function build_cache_forums() { $data = array(); $query = DB::query("SELECT f.fid, f.type, f.name, f.fup, f.simple, f.status, f.allowpostspecial, ff.viewperm, ff.formulaperm, ff.viewperm, ff.postperm, ff.replyperm, ff.getattachperm, ff.postattachperm, ff.extra, ff.commentitem, ff.hidemenu, a.uid FROM " . DB::table('forum_forum') . " f\r\n\t\tLEFT JOIN " . DB::table('forum_forumfield') . " ff ON ff.fid=f.fid LEFT JOIN " . DB::table('forum_access') . " a ON a.fid=f.fid AND a.allowview>'0' WHERE f.status<>'3' ORDER BY f.type, f.displayorder"); $usergroups = $nopermgroup = $pluginvalue = $forumlist = array(); $nopermdefault = array('viewperm' => array(), 'getattachperm' => array(), 'postperm' => array(7), 'replyperm' => array(7), 'postattachperm' => array(7)); $pluginvalue = pluginsettingvalue('forums'); $squery = DB::query("SELECT groupid, type FROM " . DB::table('common_usergroup') . ""); while ($usergroup = DB::fetch($squery)) { $usergroups[$usergroup['groupid']] = $usergroup['type']; $type = $usergroup['type'] == 'member' ? 0 : 1; $nopermgroup[$type][] = $usergroup['groupid']; } $perms = array('viewperm', 'postperm', 'replyperm', 'getattachperm', 'postattachperm'); $forumnoperms = array(); while ($forum = DB::fetch($query)) { foreach ($perms as $perm) { $permgroups = explode("\t", $forum[$perm]); $membertype = $forum[$perm] ? array_intersect($nopermgroup[0], $permgroups) : TRUE; $forumnoperm = $forum[$perm] ? array_diff(array_keys($usergroups), $permgroups) : $nopermdefault[$perm]; foreach ($forumnoperm as $groupid) { $nopermtype = $membertype && $groupid == 7 ? 'login' : ($usergroups[$groupid] == 'system' || $usergroups[$groupid] == 'special' ? 'none' : ($membertype ? 'upgrade' : 'none')); $forumnoperms[$forum['fid']][$perm][$groupid] = array($nopermtype, $permgroups); } } $forum['orderby'] = bindec(($forum['simple'] & 128 ? 1 : 0) . ($forum['simple'] & 64 ? 1 : 0)); $forum['ascdesc'] = $forum['simple'] & 32 ? 'ASC' : 'DESC'; $forum['extra'] = unserialize($forum['extra']); if (!is_array($forum['extra'])) { $forum['extra'] = array(); } if (!isset($forumlist[$forum['fid']])) { $forum['name'] = strip_tags($forum['name']); if ($forum['uid']) { $forum['users'] = "\t{$forum['uid']}\t"; } unset($forum['uid']); if ($forum['fup']) { $forumlist[$forum['fup']]['count']++; } $forumlist[$forum['fid']] = $forum; } elseif ($forum['uid']) { if (!$forumlist[$forum['fid']]['users']) { $forumlist[$forum['fid']]['users'] = "\t"; } $forumlist[$forum['fid']]['users'] .= "{$forum['uid']}\t"; } } save_syscache('nopermission', $forumnoperms); $data = array(); if (!empty($forumlist)) { foreach ($forumlist as $fid1 => $forum1) { if ($forum1['type'] == 'group' && $forum1['count']) { $data[$fid1] = formatforumdata($forum1, $pluginvalue); unset($data[$fid1]['users'], $data[$fid1]['allowpostspecial'], $data[$fid1]['commentitem']); foreach ($forumlist as $fid2 => $forum2) { if ($forum2['fup'] == $fid1 && $forum2['type'] == 'forum') { $data[$fid2] = formatforumdata($forum2, $pluginvalue); foreach ($forumlist as $fid3 => $forum3) { if ($forum3['fup'] == $fid2 && $forum3['type'] == 'sub') { $data[$fid3] = formatforumdata($forum3, $pluginvalue); } } } } } } } save_syscache('forums', $data); }