コード例 #1
0
/**
* Custom function to retrieve and return a formatted list of blocks
* Can be used when calling COM_siteHeader or COM_siteFooter
*
* Example:
* 1: Setup an array of blocks to display
* 2: Call COM_siteHeader or COM_siteFooter
*
*  $myblocks = array( 'site_menu', 'site_news', 'poll_block' );
*
* COM_siteHeader( array( 'CUSTOM_showBlocks', $myblocks )) ;
* COM_siteFooter( true, array( 'CUSTOM_showBlocks', $myblocks ));
*
* @param   array   $showblocks    An array of block names to retrieve and format
* @return  string                 Formated HTML containing site footer and optionally right blocks
*/
function CUSTOM_showBlocks($showblocks)
{
    global $_CONF, $_USER, $_TABLES;
    $retval = '';
    if (!isset($_USER['noboxes'])) {
        if (!empty($_USER['uid'])) {
            $noboxes = DB_getItem($_TABLES['userindex'], 'noboxes', "uid = {$_USER['uid']}");
        } else {
            $noboxes = 0;
        }
    } else {
        $noboxes = $_USER['noboxes'];
    }
    foreach ($showblocks as $block) {
        $sql = "SELECT bid, name,type,title,content,rdfurl,phpblockfn,help,allow_autotags,onleft FROM {$_TABLES['blocks']} WHERE name='{$block}'";
        $result = DB_query($sql);
        if (DB_numRows($result) == 1) {
            $A = DB_fetchArray($result);
            if ($A['onleft'] == 1) {
                $side = 'left';
            } else {
                $side = 'right';
            }
            $retval .= COM_formatBlock($A, $noboxes, $side);
        }
    }
    return $retval;
}
コード例 #2
0
ファイル: lib-common.php プロジェクト: alxstuart/ajfs.me
/**
* Shows Geeklog blocks
*
* Returns HTML for blocks on a given side and, potentially, for
* a given topic. Currently only used by static pages.
*
* @param        string      $side       Side to get blocks for (right or left for now)
* @param        string      $topic      Only get blocks for this topic
* @param        string      $name       Block name (not used)
* @see function COM_showBlock
* @return   string  HTML Formated blocks
*
*/
function COM_showBlocks($side, $topic = '', $name = 'all')
{
    global $_CONF, $_TABLES, $_USER, $LANG21, $topic, $page;
    $retval = '';
    // Get user preferences on blocks
    if (!isset($_USER['noboxes']) || !isset($_USER['boxes'])) {
        if (!COM_isAnonUser()) {
            $result = DB_query("SELECT boxes,noboxes FROM {$_TABLES['userindex']} " . "WHERE uid = '{$_USER['uid']}'");
            list($_USER['boxes'], $_USER['noboxes']) = DB_fetchArray($result);
        } else {
            $_USER['boxes'] = '';
            $_USER['noboxes'] = 0;
        }
    }
    $blocksql['mssql'] = "SELECT bid, is_enabled, name, type, title, tid, blockorder, cast(content as text) as content, ";
    $blocksql['mssql'] .= "rdfurl, rdfupdated, rdflimit, onleft, phpblockfn, help, owner_id, ";
    $blocksql['mssql'] .= "group_id, perm_owner, perm_group, perm_members, perm_anon, allow_autotags,UNIX_TIMESTAMP(rdfupdated) AS date ";
    $blocksql['mysql'] = "SELECT *,UNIX_TIMESTAMP(rdfupdated) AS date ";
    $blocksql['pgsql'] = 'SELECT *, date_part(\'epoch\', rdfupdated) AS date ';
    $commonsql = "FROM {$_TABLES['blocks']} WHERE is_enabled = 1";
    if ($side == 'left') {
        $commonsql .= " AND onleft = 1";
    } else {
        $commonsql .= " AND onleft = 0";
    }
    if (!empty($topic)) {
        $commonsql .= " AND (tid = '{$topic}' OR tid = 'all')";
    } else {
        if (COM_onFrontpage()) {
            $commonsql .= " AND (tid = 'homeonly' OR tid = 'all')";
        } else {
            $commonsql .= " AND (tid = 'all')";
        }
    }
    if (!empty($_USER['boxes'])) {
        $BOXES = str_replace(' ', ',', $_USER['boxes']);
        $commonsql .= " AND (bid NOT IN ({$BOXES}) OR bid = '-1')";
    }
    $commonsql .= ' ORDER BY blockorder,title ASC';
    $blocksql['mysql'] .= $commonsql;
    $blocksql['mssql'] .= $commonsql;
    $blocksql['pgsql'] .= $commonsql;
    $result = DB_query($blocksql);
    $nrows = DB_numRows($result);
    // convert result set to an array of associated arrays
    $blocks = array();
    for ($i = 0; $i < $nrows; $i++) {
        $blocks[] = DB_fetchArray($result);
    }
    // Check and see if any plugins have blocks to show
    $pluginBlocks = PLG_getBlocks($side, $topic, $name);
    $blocks = array_merge($blocks, $pluginBlocks);
    // sort the resulting array by block order
    $column = 'blockorder';
    $sortedBlocks = $blocks;
    $num_sortedBlocks = count($sortedBlocks);
    for ($i = 0; $i < $num_sortedBlocks - 1; $i++) {
        for ($j = 0; $j < $num_sortedBlocks - 1 - $i; $j++) {
            if ($sortedBlocks[$j][$column] > $sortedBlocks[$j + 1][$column]) {
                $tmp = $sortedBlocks[$j];
                $sortedBlocks[$j] = $sortedBlocks[$j + 1];
                $sortedBlocks[$j + 1] = $tmp;
            }
        }
    }
    $blocks = $sortedBlocks;
    // Loop though resulting sorted array and pass associative arrays
    // to COM_formatBlock
    foreach ($blocks as $A) {
        if ($A['type'] == 'dynamic' or SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) > 0) {
            $retval .= COM_formatBlock($A, $_USER['noboxes']);
        }
    }
    return $retval;
}
コード例 #3
0
ファイル: lib-block.php プロジェクト: Geeklog-Core/geeklog
/**
* Implements the [block:] autotag.
*
* @param    string  $op         operation to perform
* @param    string  $content    item (e.g. block text), including the autotag
* @param    array   $autotag    parameters used in the autotag
* @param    mixed               tag names (for $op='tagname') or formatted content
*
*/
function plugin_autotags_block($op, $content = '', $autotag = '')
{
    global $_CONF, $_TABLES, $LANG21, $_GROUPS;
    if ($op == 'tagname') {
        return array('block');
    } elseif ($op == 'permission' || $op == 'nopermission') {
        if ($op == 'permission') {
            $flag = true;
        } else {
            $flag = false;
        }
        $tagnames = array();
        if (isset($_GROUPS['Block Admin'])) {
            $group_id = $_GROUPS['Block Admin'];
        } else {
            $group_id = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Block Admin'");
        }
        $owner_id = SEC_getDefaultRootUser();
        if (COM_getPermTag($owner_id, $group_id, $_CONF['autotag_permissions_block'][0], $_CONF['autotag_permissions_block'][1], $_CONF['autotag_permissions_block'][2], $_CONF['autotag_permissions_block'][3]) == $flag) {
            $tagnames[] = 'block';
        }
        if (count($tagnames) > 0) {
            return $tagnames;
        }
    } elseif ($op == 'description') {
        return array('block' => $LANG21['autotag_desc_block']);
    } elseif ($op == 'parse') {
        $name = COM_applyFilter($autotag['parm1']);
        if (!empty($name)) {
            $result = DB_query("SELECT * " . "FROM {$_TABLES['blocks']} " . "WHERE name = '{$name}' AND is_enabled = 1");
            $A = DB_fetchArray($result);
            if (DB_numRows($result) > 0) {
                switch ($autotag['tag']) {
                    case 'block':
                        $px = explode(' ', trim($autotag['parm2']));
                        $css_class = "block-autotag";
                        $css_style = "";
                        if (is_array($px)) {
                            foreach ($px as $part) {
                                if (substr($part, 0, 6) == 'class:') {
                                    $a = explode(':', $part);
                                    // append a class
                                    $css_class .= ' ' . $a[1];
                                } elseif (substr($part, 0, 6) == 'width:') {
                                    $a = explode(':', $part);
                                    // add width style
                                    $css_style = ' style="width:' . $a[1] . '"';
                                } else {
                                    break;
                                }
                            }
                        }
                        $retval = COM_formatBlock($A, false, true);
                        // COM_formatBlock could return '' if wrong device, etc...
                        if ($retval != '') {
                            // the class block-autotag will always be included with the div
                            $retval = '<div class="' . $css_class . '"' . $css_style . '>' . $retval . '</div>';
                        }
                        break;
                }
                $content = str_replace($autotag['tagstr'], $retval, $content);
            }
        }
    }
    return $content;
}
コード例 #4
0
ファイル: lib-plugins.php プロジェクト: spacequad/glfusion
/**
* This function will allow plugins to support the use of custom autolinks
* in other site content. Plugins can now use this API when saving content
* and have the content checked for any autolinks before saving.
* The autolink would be like:  [story:20040101093000103 here]
*
* @param   string   $content   Content that should be parsed for autolinks
* @param    string  $namespace Optional Namespace or plugin name collecting tag info
* @param    string  $operation Optional Operation being performed
* @param   string   $plugin    Optional if you only want to parse using a specific plugin
*
*/
function PLG_replaceTags($content, $namespace = '', $operation = '', $plugin = '')
{
    global $_CONF, $_TABLES, $_BLOCK_TEMPLATE, $LANG32, $_AUTOTAGS, $mbMenu, $autoTagUsage;
    if (isset($_CONF['disable_autolinks']) && $_CONF['disable_autolinks'] == 1) {
        // autolinks are disabled - return $content unchanged
        return $content;
    }
    static $recursionCount = 0;
    if ($recursionCount > 5) {
        COM_errorLog("AutoTag infinite recursion detected on " . $namespace . " " . $operation);
        return $content;
    }
    $autolinkModules = PLG_collectTags();
    $autoTagUsage = PLG_autoTagPerms();
    if (!empty($namespace) && !empty($operation)) {
        $postFix = '.' . $namespace . '.' . $operation;
    } else {
        $postFix = '';
    }
    // For each supported module, scan the content looking for any AutoLink tags
    $tags = array();
    $contentlen = utf8_strlen($content);
    $content_lower = utf8_strtolower($content);
    foreach ($autolinkModules as $moduletag => $module) {
        $autotag_prefix = '[' . $moduletag . ':';
        $offset = 0;
        $prev_offset = 0;
        while ($offset < $contentlen) {
            $start_pos = utf8_strpos($content_lower, $autotag_prefix, $offset);
            if ($start_pos === false) {
                break;
            } else {
                $end_pos = utf8_strpos($content_lower, ']', $start_pos);
                $next_tag = utf8_strpos($content_lower, '[', $start_pos + 1);
                if ($end_pos > $start_pos and ($next_tag === false or $end_pos < $next_tag)) {
                    $taglength = $end_pos - $start_pos + 1;
                    $tag = utf8_substr($content, $start_pos, $taglength);
                    $parms = explode(' ', $tag);
                    // Extra test to see if autotag was entered with a space
                    // after the module name
                    if (utf8_substr($parms[0], -1) == ':') {
                        $startpos = utf8_strlen($parms[0]) + utf8_strlen($parms[1]) + 2;
                        $label = str_replace(']', '', utf8_substr($tag, $startpos));
                        $tagid = $parms[1];
                    } else {
                        $label = str_replace(']', '', utf8_substr($tag, utf8_strlen($parms[0]) + 1));
                        $parms = explode(':', $parms[0]);
                        if (count($parms) > 2) {
                            // whoops, there was a ':' in the tag id ...
                            array_shift($parms);
                            $tagid = implode(':', $parms);
                        } else {
                            $tagid = $parms[1];
                        }
                    }
                    $newtag = array('module' => $module, 'tag' => $moduletag, 'tagstr' => $tag, 'startpos' => $start_pos, 'length' => $taglength, 'parm1' => str_replace(']', '', $tagid), 'parm2' => $label);
                    $tags[] = $newtag;
                } else {
                    // Error: tags do not match - return with no changes
                    return $content . $LANG32[32];
                }
                $prev_offset = $offset;
                $offset = $end_pos;
            }
        }
    }
    // If we have found 1 or more AutoLink tag
    if (count($tags) > 0) {
        // Found the [tag] - Now process them all
        $recursionCount++;
        foreach ($tags as $autotag) {
            $permCheck = $autotag['tag'] . $postFix;
            if (empty($postFix) || !isset($autoTagUsage[$permCheck]) || $autoTagUsage[$permCheck] == 1) {
                $function = 'plugin_autotags_' . $autotag['module'];
                if ($autotag['module'] == 'glfusion' and (empty($plugin) or $plugin == 'glfusion')) {
                    $url = '';
                    $linktext = $autotag['parm2'];
                    if ($autotag['tag'] == 'story') {
                        $autotag['parm1'] = COM_applyFilter($autotag['parm1']);
                        $url = COM_buildUrl($_CONF['site_url'] . '/article.php?story=' . $autotag['parm1']);
                        if (empty($linktext)) {
                            $linktext = DB_getItem($_TABLES['stories'], 'title', "sid = '" . DB_escapeString($autotag['parm1']) . "'");
                        }
                    }
                    if (!empty($url)) {
                        $filelink = COM_createLink($linktext, $url);
                        $content = str_replace($autotag['tagstr'], $filelink, $content);
                    }
                    if ($autotag['tag'] == 'story_introtext') {
                        $url = '';
                        $linktext = '';
                        USES_lib_story();
                        if (isset($_USER['uid']) && $_USER['uid'] > 1) {
                            $result = DB_query("SELECT maxstories,tids,aids FROM {$_TABLES['userindex']} WHERE uid = {$_USER['uid']}");
                            $U = DB_fetchArray($result);
                        } else {
                            $U['maxstories'] = 0;
                            $U['aids'] = '';
                            $U['tids'] = '';
                        }
                        $sql = " (date <= NOW()) AND (draft_flag = 0)";
                        if (empty($topic)) {
                            $sql .= COM_getLangSQL('tid', 'AND', 's');
                        }
                        $sql .= COM_getPermSQL('AND', 0, 2, 's');
                        if (!empty($U['aids'])) {
                            $sql .= " AND s.uid NOT IN (" . str_replace(' ', ",", $U['aids']) . ") ";
                        }
                        if (!empty($U['tids'])) {
                            $sql .= " AND s.tid NOT IN ('" . str_replace(' ', "','", $U['tids']) . "') ";
                        }
                        $sql .= COM_getTopicSQL('AND', 0, 's') . ' ';
                        $userfields = 'u.uid, u.username, u.fullname';
                        $msql = "SELECT STRAIGHT_JOIN s.*, UNIX_TIMESTAMP(s.date) AS unixdate, " . 'UNIX_TIMESTAMP(s.expire) as expireunix, ' . $userfields . ", t.topic, t.imageurl " . "FROM {$_TABLES['stories']} AS s, {$_TABLES['users']} AS u, " . "{$_TABLES['topics']} AS t WHERE s.sid = '" . $autotag['parm1'] . "' AND (s.uid = u.uid) AND (s.tid = t.tid) AND" . $sql;
                        $result = DB_query($msql);
                        $nrows = DB_numRows($result);
                        if ($A = DB_fetchArray($result)) {
                            $story = new Story();
                            $story->loadFromArray($A);
                            $linktext = STORY_renderArticle($story, 'y');
                        }
                        $content = str_replace($autotag['tagstr'], $linktext, $content);
                    }
                    if ($autotag['tag'] == 'showblock') {
                        $blockName = COM_applyBasicFilter($autotag['parm1']);
                        $result = DB_query("SELECT * FROM {$_TABLES['blocks']} WHERE name = '" . DB_escapeString($blockName) . "'" . COM_getPermSQL('AND'));
                        if (DB_numRows($result) > 0) {
                            $skip = 0;
                            $B = DB_fetchArray($result);
                            $template = '';
                            $side = '';
                            $px = explode(' ', trim($autotag['parm2']));
                            if (is_array($px)) {
                                foreach ($px as $part) {
                                    if (substr($part, 0, 9) == 'template:') {
                                        $a = explode(':', $part);
                                        $template = $a[1];
                                        $skip++;
                                    } elseif (substr($part, 0, 5) == 'side:') {
                                        $a = explode(':', $part);
                                        $side = $a[1];
                                        $skip++;
                                        break;
                                    }
                                }
                                if ($skip != 0) {
                                    if (count($px) > $skip) {
                                        for ($i = 0; $i < $skip; $i++) {
                                            array_shift($px);
                                        }
                                        $caption = trim(implode(' ', $px));
                                    } else {
                                        $caption = '';
                                    }
                                }
                            }
                            if ($template != '') {
                                $_BLOCK_TEMPLATE[$blockName] = 'blockheader-' . $template . '.thtml,blockfooter-' . $template . '.thtml';
                            }
                            if ($side == 'left') {
                                $B['onleft'] = 1;
                            } else {
                                if ($side == 'right') {
                                    $B['onleft'] = 0;
                                }
                            }
                            $linktext = COM_formatBlock($B);
                            $content = str_replace($autotag['tagstr'], $linktext, $content);
                        } else {
                            $content = str_replace($autotag['tagstr'], '', $content);
                        }
                    }
                    if ($autotag['tag'] == 'menu') {
                        $menu = '';
                        $menuID = trim($autotag['parm1']);
                        $menuHTML = displayMenu($menuID);
                        $content = str_replace($autotag['tagstr'], $menuHTML, $content);
                    }
                    if (isset($_AUTOTAGS[$autotag['tag']])) {
                        $content = autotags_autotag('parse', $content, $autotag);
                    }
                } else {
                    if (function_exists($function) and (empty($plugin) or $plugin == $autotag['module'])) {
                        $content = $function('parse', $content, $autotag);
                    }
                }
            }
        }
        $recursionCount--;
    }
    return $content;
}
コード例 #5
0
ファイル: lib-widgets.php プロジェクト: spacequad/glfusion
function WIDGET_mootickerRSS($block = 'gl_mootickerRSS', $id = 'gl_mooticker')
{
    global $_CONF, $_TABLES, $LANG_WIDGETS;
    $query = "SELECT bid, rdfurl, rdflimit, UNIX_TIMESTAMP(rdfupdated) AS date FROM {$_TABLES['blocks']} WHERE type = 'portal' AND is_enabled = 0";
    // Update feeds from blocks where 'is_enabled' -tag is set to 0
    $blocksql['mysql'] = $query;
    $blocksql['mssql'] .= $query;
    $result = DB_query($blocksql);
    $nrows = DB_numRows($result);
    $blocks = array();
    for ($i = 0; $i < $nrows; $i++) {
        $blocks[] = DB_fetchArray($result);
    }
    // Loop though resulting sorted array and pass associative arrays
    // to COM_rdfCheck
    foreach ($blocks as $A) {
        COM_rdfCheck($A['bid'], $A['rdfurl'], $A['date'], $A['rdflimit']);
    }
    $retval = '';
    $result = DB_query("SELECT *, rdfupdated as date FROM {$_TABLES['blocks']} WHERE name='" . DB_escapeString($block) . "'");
    $numRows = DB_numRows($result);
    if ($numRows < 1 || $result == NULL) {
        return $retval;
    }
    $B = DB_fetchArray($result);
    if ($B['is_enabled'] == 0) {
        COM_formatBlock($B, true);
        $retval = <<<EOT
<script type="text/javascript">
var MooTicker=new Class({options:{controls:true,delay:2000,duration:800,blankimage:'{site_url}/images/speck.gif'},initialize:function(b,c){this.setOptions(c);this.element=\$(b)||null;this.element.addEvents({'mouseenter':this.stop.bind(this),'mouseleave':this.play.bind(this)});this.news=this.element.getElements('ul li');this.current=0;this.fx=[];this.news.getParent().setStyle('position','relative');var d=this;this.news.each(function(a,i){a.setStyle('position','absolute');this.fx[i]=new Fx.Style(a,'opacity',{duration:this.options.duration,onStart:function(){d.transitioning=true},onComplete:function(){d.transitioning=false}}).set(1);if(!i)return;a.setStyle('opacity',0)},this);if(this.options.controls)this.addControls();this.status='stop';window.addEvent('load',this.play.bind(this));return this},addControls:function(){var a=new Element('span',{'class':'controls'}).injectTop(this.element);this.arrowPrev=new Element('img',{'class':'control-prev','title':'{prev}','alt':'{prev}','src':this.options.blankimage}).inject(a);this.arrowNext=new Element('img',{'class':'control-next','title':'{next}','alt':'{next}','src':this.options.blankimage}).inject(a);this.arrowPrev.addEvent('click',this.previous.bind(this));this.arrowNext.addEvent('click',this.next.bind(this));return this},previous:function(){if(this.transitioning)return this;var a=(!this.current)?this.news.length-1:this.current-1;this.fx[this.current].start(0);this.fx[a].start(1);this.current=a;return this},next:function(){if(this.transitioning)return this;var a=(this.current==this.news.length-1)?0:this.current+1;this.fx[this.current].start(0);this.fx[a].start(1);this.current=a;return this},play:function(){if(this.status=='play')return this;this.status='play';this.timer=this.next.periodical(this.options.delay+this.options.duration,this);return this},stop:function(){this.status='stop';\$clear(this.timer);return this}});MooTicker.implement(new Options,new Events);
</script>
<script type="text/javascript">
         window.addEvent('domready', function() {
                 var x = new MooTicker('{$id}', {
                         controls: true,
                         delay: 2500,
                         duration: 600 });
         });
</script>
<div id="{$id}">
EOT;
        $retval = str_replace('{site_url}', $_CONF['site_url'], $retval);
        $retval = str_replace('{prev}', $LANG_WIDGETS['prev'], $retval);
        $retval = str_replace('{next}', $LANG_WIDGETS['next'], $retval);
        $retval .= '<span class="tickertitle">' . $LANG_WIDGETS['latest_news'] . ':</span>';
        $retval .= $B['content'] . '</div>';
    }
    return $retval;
}
コード例 #6
0
/**
* Shows Geeklog blocks
*
* Returns HTML for blocks on a given side and, potentially, for
* a given topic. Currently only used by static pages.
*
* @param        string      $side       Side to get blocks for (right or left for now)
* @param        string      $topic      Only get blocks for this topic
* @see function COM_showBlock
* @return   string  HTML Formated blocks
*
*/
function COM_showBlocks($side, $topic = '')
{
    global $_CONF, $_TABLES, $_USER, $LANG21, $topic, $page, $_TOPICS;
    $retval = '';
    // Get user preferences on blocks
    if (!isset($_USER['noboxes']) || !isset($_USER['boxes'])) {
        if (!COM_isAnonUser()) {
            $result = DB_query("SELECT boxes,noboxes FROM {$_TABLES['userindex']} " . "WHERE uid = '{$_USER['uid']}'");
            list($_USER['boxes'], $_USER['noboxes']) = DB_fetchArray($result);
        } else {
            $_USER['boxes'] = '';
            $_USER['noboxes'] = 0;
        }
    }
    $blocksql['mssql'] = "SELECT bid, is_enabled, name, b.type, title, blockorder, cast(content as text) as content, cache_time, ";
    $blocksql['mssql'] .= "rdfurl, rdfupdated, rdflimit, onleft, phpblockfn, help, owner_id, ";
    $blocksql['mssql'] .= "group_id, perm_owner, perm_group, perm_members, perm_anon, allow_autotags,UNIX_TIMESTAMP(rdfupdated) AS date ";
    $blocksql['mysql'] = "SELECT b.*,UNIX_TIMESTAMP(rdfupdated) AS date ";
    $blocksql['pgsql'] = 'SELECT b.*, date_part(\'epoch\', rdfupdated) AS date ';
    $blocksql['mysql'] .= "FROM {$_TABLES['blocks']} b, {$_TABLES['topic_assignments']} ta WHERE ta.type = 'block' AND ta.id = bid AND is_enabled = 1";
    $blocksql['mssql'] .= "FROM {$_TABLES['blocks']} b, {$_TABLES['topic_assignments']} ta WHERE ta.type = 'block' AND ta.id = bid AND is_enabled = 1";
    $blocksql['pgsql'] .= "FROM {$_TABLES['blocks']} b, {$_TABLES['topic_assignments']} ta WHERE ta.type = 'block' AND ta.id::integer = bid AND is_enabled = 1";
    $commonsql = '';
    if ($side === 'left') {
        $commonsql .= " AND onleft = 1";
    } else {
        $commonsql .= " AND onleft = 0";
    }
    // Figure out topic access
    $topic_access = 0;
    if (!empty($topic) && $topic != TOPIC_ALL_OPTION && $topic != TOPIC_HOMEONLY_OPTION) {
        $topic_index = TOPIC_getIndex($topic);
        if ($topic_index > 0) {
            $topic_access = $_TOPICS[$topic_index]['access'];
        }
    }
    if (!empty($topic) && $topic != TOPIC_ALL_OPTION && $topic != TOPIC_HOMEONLY_OPTION && $topic_access > 0) {
        // Retrieve list of inherited topics
        $tid_list = TOPIC_getChildList($topic);
        // Get list of blocks to display (except for dynamic). This includes blocks
        // for all topics, and child blocks that are inherited
        $commonsql .= " AND (ta.tid IN({$tid_list}) AND (ta.inherit = 1 OR (ta.inherit = 0 AND ta.tid = '{$topic}')) OR ta.tid = 'all')";
    } else {
        if (COM_onFrontpage()) {
            $commonsql .= " AND (ta.tid = '" . TOPIC_HOMEONLY_OPTION . "' OR ta.tid = '" . TOPIC_ALL_OPTION . "')";
        } else {
            $commonsql .= " AND (ta.tid = '" . TOPIC_ALL_OPTION . "')";
        }
    }
    if (!empty($_USER['boxes'])) {
        $BOXES = str_replace(' ', ',', $_USER['boxes']);
        $commonsql .= " AND (bid NOT IN ({$BOXES}) OR bid = '-1')";
    }
    $commonsql .= " GROUP BY bid ";
    $commonsql .= ' ORDER BY blockorder,title ASC';
    $blocksql['mysql'] .= $commonsql;
    $blocksql['mssql'] .= $commonsql;
    $blocksql['pgsql'] .= $commonsql;
    $result = DB_query($blocksql);
    $nrows = DB_numRows($result);
    // convert result set to an array of associated arrays
    $blocks = array();
    for ($i = 0; $i < $nrows; $i++) {
        $blocks[] = DB_fetchArray($result);
    }
    // Check and see if any plugins have blocks to show
    $pluginBlocks = PLG_getBlocks($side, $topic);
    $blocks = array_merge($blocks, $pluginBlocks);
    // sort the resulting array by block order
    $column = 'blockorder';
    $sortedBlocks = $blocks;
    $num_sortedBlocks = count($sortedBlocks);
    for ($i = 0; $i < $num_sortedBlocks - 1; $i++) {
        for ($j = 0; $j < $num_sortedBlocks - 1 - $i; $j++) {
            if ($sortedBlocks[$j][$column] > $sortedBlocks[$j + 1][$column]) {
                $tmp = $sortedBlocks[$j];
                $sortedBlocks[$j] = $sortedBlocks[$j + 1];
                $sortedBlocks[$j + 1] = $tmp;
            }
        }
    }
    $blocks = $sortedBlocks;
    // Loop though resulting sorted array and pass associative arrays
    // to COM_formatBlock
    foreach ($blocks as $A) {
        if ($A['type'] === 'dynamic' || SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']) > 0) {
            $retval .= COM_formatBlock($A, $_USER['noboxes']);
        }
    }
    return $retval;
}
コード例 #7
0
ファイル: forum.inc.php プロジェクト: spacequad/glfusion
function forum_showBlocks($showblocks)
{
    global $_CONF, $_USER, $_TABLES;
    $retval = '';
    if (!isset($_USER['noboxes'])) {
        if (!COM_isAnonUser()) {
            $noboxes = DB_getItem($_TABLES['userindex'], 'noboxes', "uid=" . (int) $_USER['uid']);
        } else {
            $noboxes = 0;
        }
    } else {
        $noboxes = $_USER['noboxes'];
    }
    foreach ($showblocks as $block) {
        $sql = "SELECT bid, name,type,title,content,rdfurl,phpblockfn,help,allow_autotags FROM {$_TABLES['blocks']} WHERE name='" . DB_escapeString($block) . "'";
        $result = DB_query($sql);
        if (DB_numRows($result) == 1) {
            $A = DB_fetchArray($result);
            $retval .= COM_formatBlock($A, $noboxes);
        }
    }
    return $retval;
}
コード例 #8
0
ファイル: library.php プロジェクト: hostellerie/nexpro
function nexcontent_showblocks(&$content, $location)
{
    global $content, $_CONF, $_TABLES;
    /* Check if category menu has been requested - requires page to be using customblock mode */
    $tag = '[categorymenu_' . $location;
    $categoryBlockHTML = nexcontent_getCategoryBlockTagHTML($content, $location);
    $sql = "SELECT bid, name,type,title,content,rdfurl,phpblockfn,help,allow_autotags FROM {$_TABLES['blocks']} ORDER BY blockorder,title asc";
    $result = DB_query($sql);
    $nrows = DB_numRows($result);
    $blockPosition = 0;
    for ($i = 1; $i <= $nrows; $i++) {
        $A = DB_fetchArray($result);
        $tag = '[block_' . $A['name'] . '_' . $location . ']';
        if (strpos($content, $tag) !== FALSE) {
            $blockPosition++;
            if ($blockPosition == 2) {
                $retval .= $categoryBlockHTML;
                $categoryBlockHTML = '';
            }
            $retval .= COM_formatBlock($A);
        }
    }
    if ($categoryBlockHTML != '') {
        $retval .= $categoryBlockHTML;
    }
    return $retval;
}