Exemple #1
0
/**
* Show topic administration form
*
* @param    string  tid     ID of topic to edit
* @param    array   $T      An array of topic fields (optional)
* @return   string          HTML for the topic editor
*
*/
function TOPIC_edit($tid = '', $T = array(), $msg = '')
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG27, $LANG_ACCESS, $LANG_ADMIN, $MESSAGE, $_IMAGE_TYPE;
    USES_lib_admin();
    $retval = '';
    $topicEdit = 0;
    $assoc_stories_published = 0;
    $assoc_stories_draft = 0;
    $assoc_images = 0;
    $assoc_comments = 0;
    $assoc_trackbacks = 0;
    if (!empty($tid)) {
        $topicEdit = 1;
        // existing topic - pull fields from DB
        $result = DB_query("SELECT * FROM {$_TABLES['topics']} WHERE tid ='" . DB_escapeString($tid) . "'");
        $A = DB_fetchArray($result);
        $access = SEC_inGroup('Topic Admin') ? 3 : SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 0 or $access == 2) {
            $retval .= COM_showMessageText($LANG27[13], $LANG27[12], true);
            COM_accessLog("User {$_USER['username']} tried to illegally create or edit topic {$tid}.");
            return $retval;
        }
        // ok let's see what is associated with this topic
        $result2 = DB_query("SELECT bid FROM {$_TABLES['blocks']} WHERE tid = '{$tid}'");
        $assoc_blocks = DB_numRows($result2);
        $result2 = DB_query("SELECT fid FROM {$_TABLES['syndication']} WHERE topic = '{$tid}'");
        $assoc_feeds = DB_numRows($result2);
        $result2 = DB_query("SELECT sid FROM {$_TABLES['storysubmission']} WHERE tid = '{$tid}'");
        $assoc_stories_submitted = DB_numRows($result2);
        $result2 = DB_query("SELECT sid, draft_flag FROM {$_TABLES['stories']} WHERE tid = '{$tid}'");
        $total_assoc_stories = DB_numRows($result2);
        if ($total_assoc_stories > 0) {
            for ($i = 0; $i < $total_assoc_stories; $i++) {
                $S = DB_fetchArray($result2);
                if ($S['draft_flag'] == 0) {
                    $assoc_stories_published += 1;
                } else {
                    $assoc_stories_draft += 1;
                }
                $result3 = DB_query("SELECT ai_filename FROM {$_TABLES['article_images']} WHERE ai_sid = '{$S['sid']}'");
                $assoc_images += DB_numRows($result3);
                $result3 = DB_query("SELECT cid FROM {$_TABLES['comments']} WHERE sid = '{$S['sid']}' AND type = 'article'");
                $assoc_comments += DB_numRows($result3);
                $result3 = DB_query("SELECT cid FROM {$_TABLES['trackback']} WHERE sid = '{$S['sid']}' AND type = 'article'");
                $assoc_trackbacks += DB_numRows($result3);
            }
        }
    } else {
        // new topic - retain field values if any in case of failed validation
        $A = array();
        $A['tid'] = isset($T['tid']) ? $T['tid'] : '';
        $A['topic'] = isset($T['topic']) ? $T['topic'] : '';
        $A['sortnum'] = isset($T['sortnum']) ? $T['sortnum'] : 0;
        $A['limitnews'] = isset($T['limitnews']) ? $T['limitnews'] : '';
        // leave empty!
        $A['is_default'] = isset($T['is_default']) && $T['is_default'] == 'on' ? 1 : 0;
        $A['archive_flag'] = isset($T['archive_flag']) && $T['archive_flag'] == 'on' ? 1 : 0;
        $A['sort_by'] = isset($T['sort_by']) ? $T['sort_by'] : 0;
        $A['sort_dir'] = isset($T['sort_dir']) && $T['sort_dir'] == 'ASC' ? 'ASC' : 'DESC';
        $A['owner_id'] = isset($T['owner_id']) ? $T['owner_id'] : '';
        $A['group_id'] = isset($T['group_id']) ? $T['group_id'] : '';
        $A['imageurl'] = isset($T['imageurl']) ? $T['imageurl'] : '';
        $assoc_stories_submitted = 0;
        $assoc_blocks = 0;
        $assoc_feeds = 0;
        if ($A['sortnum'] != '') {
            $tidSortNumber = DB_getItem($_TABLES['topics'], 'sortnum', 'tid="' . DB_escapeString($A['sortnum']) . '"');
            $newSortNum = $tidSortNumber;
        } else {
            $newSortNum = 0;
        }
        $A['sortnum'] = $newSortNum;
        // an empty owner_id signifies this is a new block, set to current user
        // this will also set the default values for group_id as well as the
        // default values for topic permissions
        if (empty($A['owner_id'])) {
            $A['owner_id'] = $_USER['uid'];
            // this is the one instance where we default the group
            // most topics should belong to the Topic Admin group
            if (isset($_GROUPS['Topic Admin'])) {
                $A['group_id'] = $_GROUPS['Topic Admin'];
            } else {
                $A['group_id'] = SEC_getFeatureGroup('topic.edit');
            }
            SEC_setDefaultPermissions($A, $_CONF['default_permissions_topic']);
        } else {
            if (isset($T['perm_owner'])) {
                $A['perm_owner'] = SEC_getPermissionValue($T['perm_owner']);
                $A['perm_group'] = SEC_getPermissionValue($T['perm_group']);
                $A['perm_members'] = SEC_getPermissionValue($T['perm_members']);
                $A['perm_anon'] = SEC_getPermissionValue($T['perm_anon']);
            } else {
                SEC_setDefaultPermissions($A, $_CONF['default_permissions_topic']);
            }
        }
        $access = 3;
    }
    // display the topic editor
    $topic_templates = new Template($_CONF['path_layout'] . 'admin/topic');
    $topic_templates->set_file('editor', 'topiceditor.thtml');
    // generate input for topic id
    if (!empty($topicEdit) && SEC_hasRights('topic.edit')) {
        $tid_input = $tid . '<input type="hidden" size="20" maxlength="128" name="tid" value="' . $tid . '"' . XHTML . '>';
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="delete"%s' . XHTML . '>';
        $jsconfirm = ' onclick="return doubleconfirm(\'' . $LANG27[40] . '\',\'' . $LANG27[6] . '\');"';
        $topic_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $topic_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        $topic_templates->clear_var('lang_donotusespaces');
    } else {
        $tid_input = '<input class="required alphanumeric" type="text" size="20" maxlength="128" name="tid" id="tid" value="' . $tid . '"' . XHTML . '>';
        $topic_templates->set_var('lang_donotusespaces', $LANG27[5]);
    }
    $topic_templates->set_var('tid_input', $tid_input);
    $topic_templates->set_var('lang_topicid', $LANG27[2]);
    $topic_templates->set_var('topic_id', $A['tid']);
    $topic_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $topic_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $topic_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = {$A['owner_id']}"));
    $topic_templates->set_var('owner_name', $ownername);
    $topic_templates->set_var('owner', $ownername);
    $topic_templates->set_var('owner_id', $A['owner_id']);
    $topic_templates->set_var('owner_dropdown', COM_buildOwnerList('owner_id', $A['owner_id']));
    $topic_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $topic_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $topic_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $topic_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $topic_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $topic_templates->set_var('lang_permissions_key', $LANG_ACCESS['permissionskey']);
    $topic_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $sort_select = '<select id="sortnum" name="sortnum">' . LB;
    $sort_select .= '<option value="0">' . 'First Position' . '</option>' . LB;
    $result = DB_query("SELECT tid,topic,sortnum FROM {$_TABLES['topics']} ORDER BY sortnum ASC");
    if ($topicEdit == 1) {
        $testvar = 10;
    } else {
        $testvar = 0;
    }
    $order = 10;
    while ($row = DB_fetchArray($result)) {
        if ($row['tid'] != $tid) {
            $test_sortnum = $order + $testvar;
            $sort_select .= '<option value="' . $row['tid'] . '"' . ($A['sortnum'] == $test_sortnum ? ' selected="selected"' : '') . '>' . $row['topic'] . ' (' . $row['tid'] . ')' . '</option>' . LB;
        }
        $order += 10;
    }
    $sort_select .= '</select>' . LB;
    // show sort order only if they specified sortnum as the sort method
    if ($_CONF['sortmethod'] != 'alpha') {
        $topic_templates->set_var('lang_sortorder', $LANG27[41]);
        if ($A['sortnum'] == 0) {
            $A['sortnum'] = '';
        }
        $topic_templates->set_var('sort_order', $sort_select);
    } else {
        $topic_templates->set_var('lang_sortorder', $LANG27[14]);
        $topic_templates->set_var('sort_order', $LANG27[15]);
    }
    $topic_templates->set_var('lang_storiesperpage', $LANG27[11]);
    if ($A['limitnews'] == 0) {
        $topic_templates->set_var('story_limit', '');
    } else {
        $topic_templates->set_var('story_limit', $A['limitnews']);
    }
    $topic_templates->set_var('default_limit', $_CONF['limitnews']);
    $topic_templates->set_var('lang_defaultis', $LANG27[16]);
    $topic_templates->set_var('lang_topicname', $LANG27[3]);
    $topic_templates->set_var('topic_name', htmlentities($A['topic']));
    if (empty($A['tid'])) {
        $A['imageurl'] = '/images/topics/';
    }
    $topic_templates->set_var('lang_topicimage', $LANG27[4]);
    $topic_templates->set_var('lang_uploadimage', $LANG27[27]);
    $topic_templates->set_var('icon_dimensions', $_CONF['max_topicicon_width'] . ' x ' . $_CONF['max_topicicon_height']);
    $topic_templates->set_var('lang_maxsize', $LANG27[28]);
    $topic_templates->set_var('max_url_length', 255);
    $topic_templates->set_var('image_url', $A['imageurl']);
    if (@getimagesize($_CONF['path_html'] . $A['imageurl']) !== false) {
        $topic_templates->set_var('topicimage', $_CONF['site_url'] . $A['imageurl']);
    }
    $topic_templates->set_var('lang_defaulttopic', $LANG27[22]);
    $topic_templates->set_var('lang_defaulttext', $LANG27[23]);
    if ($A['is_default'] == 1) {
        $topic_templates->set_var('default_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('default_checked', '');
    }
    $topic_templates->set_var('lang_sort_story_by', $LANG27[35]);
    $topic_templates->set_var('lang_sort_story_dir', $LANG27[36]);
    $sortSelect = '<select name="sort_by" id="sort_by">' . LB;
    $sortSelect .= '<option value="0"' . ($A['sort_by'] == 0 ? ' selected="selected"' : '') . '>' . $LANG27[30] . '</option>' . LB;
    $sortSelect .= '<option value="1"' . ($A['sort_by'] == 1 ? ' selected="selected"' : '') . '>' . $LANG27[31] . '</option>' . LB;
    $sortSelect .= '<option value="2"' . ($A['sort_by'] == 2 ? ' selected="selected"' : '') . '>' . $LANG27[32] . '</option>' . LB;
    $sortSelect .= '</select>' . LB;
    $topic_templates->set_var('story_sort_select', $sortSelect);
    $sort_dir = '<select name="sort_dir" id="sort_dir">' . LB;
    $sort_dir .= '<option value="ASC"' . ($A['sort_dir'] == 'ASC' ? ' selected="selected"' : '') . '>' . $LANG27[33] . '</option>' . LB;
    $sort_dir .= '<option value="DESC"' . ($A['sort_dir'] == 'DESC' ? ' selected="selected"' : '') . '>' . $LANG27[34] . '</option>' . LB;
    $sort_dir .= '</select>';
    $topic_templates->set_var('story_sort_dir', $sort_dir);
    $topic_templates->set_var('lang_archivetopic', $LANG27[25]);
    $topic_templates->set_var('lang_archivetext', $LANG27[26]);
    $topic_templates->set_var('archive_disabled', '');
    if ($A['archive_flag'] == 1) {
        $topic_templates->set_var('archive_checked', 'checked="checked"');
    } else {
        $topic_templates->set_var('archive_checked', '');
        // Only 1 topic can be the archive topic - so check if there already is one
        if (DB_count($_TABLES['topics'], 'archive_flag', '1') > 0) {
            $topic_templates->set_var('archive_disabled', 'disabled');
        }
    }
    $assoc_stories = ($assoc_stories_published > 0 or $assoc_stories_draft > 0 or $assoc_stories_submitted > 0 or $assoc_images > 0 or $assoc_comments > 0 or $assoc_trackbacks > 0);
    if ($assoc_blocks > 0 or $assoc_feeds > 0 or $assoc_stories) {
        $topic_templates->set_var('lang_assoc_objects', $LANG27[43]);
        if ($assoc_stories_published > 0) {
            $topic_templates->set_var('lang_assoc_stories_published', $LANG27[44]);
            $topic_templates->set_var('assoc_stories_published', $assoc_stories_published);
            $topic_templates->set_var('published_story_admin_link', COM_createLink($LANG27[52], $_CONF['site_admin_url'] . '/story.php'));
        }
        if ($assoc_stories_draft > 0) {
            $topic_templates->set_var('lang_assoc_stories_draft', $LANG27[45]);
            $topic_templates->set_var('assoc_stories_draft', $assoc_stories_draft);
            $topic_templates->set_var('draft_story_admin_link', COM_createLink($LANG27[52], $_CONF['site_admin_url'] . '/story.php'));
        }
        if ($assoc_stories_submitted > 0) {
            $topic_templates->set_var('lang_assoc_stories_submitted', $LANG27[46]);
            $topic_templates->set_var('assoc_stories_submitted', $assoc_stories_submitted);
            $topic_templates->set_var('moderation_link', COM_createLink($LANG27[53], $_CONF['site_admin_url'] . '/moderation.php'));
        }
        if ($assoc_images > 0) {
            $topic_templates->set_var('lang_assoc_images', $LANG27[47]);
            $topic_templates->set_var('assoc_images', $assoc_images);
        }
        if ($assoc_comments > 0) {
            $topic_templates->set_var('lang_assoc_comments', $LANG27[48]);
            $topic_templates->set_var('assoc_comments', $assoc_comments);
        }
        if ($assoc_trackbacks > 0) {
            $topic_templates->set_var('lang_assoc_trackbacks', $LANG27[49]);
            $topic_templates->set_var('assoc_trackbacks', $assoc_trackbacks);
        }
        if ($assoc_blocks > 0) {
            $topic_templates->set_var('lang_assoc_blocks', $LANG27[50]);
            $topic_templates->set_var('assoc_blocks', $assoc_blocks);
            $topic_templates->set_var('block_admin_link', COM_createLink($LANG27[54], $_CONF['site_admin_url'] . '/block.php'));
        }
        if ($assoc_feeds > 0) {
            $topic_templates->set_var('lang_assoc_feeds', $LANG27[51]);
            $topic_templates->set_var('assoc_feeds', $assoc_feeds);
            $topic_templates->set_var('syndication_admin_link', COM_createLink($LANG27[55], $_CONF['site_admin_url'] . '/syndication.php'));
        }
    }
    $topic_templates->set_var('gltoken_name', CSRF_TOKEN);
    $topic_templates->set_var('gltoken', SEC_createToken());
    $topic_templates->parse('output', 'editor');
    if ($msg != '') {
        $retval .= COM_showMessageText($msg);
    }
    $retval .= COM_startBlock($LANG27[1], '', COM_getBlockTemplate('_admin_block', 'header'));
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/topic.php', 'text' => $LANG_ADMIN['topic_list']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $retval .= ADMIN_createMenu($menu_arr, $LANG27[57], $_CONF['layout_url'] . '/images/icons/topic.' . $_IMAGE_TYPE);
    $retval .= $topic_templates->finish($topic_templates->get_var('output'));
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
/**
 * Converts permissions to numeric values
 * This function will take all permissions for an object and get the numeric value
 * that can then be used to save the database.
 *
 * @param        array $perm_owner   Array of owner permissions  These arrays are set up by SEC_getPermissionsHTML
 * @param        array $perm_group   Array of group permissions
 * @param        array $perm_members Array of member permissions
 * @param        array $perm_anon    Array of anonymous user permissions
 * @return       array       returns numeric equivalent for each permissions array (2 = read, 3=edit/read)
 * @see  SEC_getPermissionsHTML
 * @see  SEC_getPermissionValue
 */
function SEC_getPermissionValues($perm_owner, $perm_group, $perm_members, $perm_anon)
{
    global $_SEC_VERBOSE;
    if ($_SEC_VERBOSE) {
        COM_errorLog('**** Inside SEC_getPermissionValues ****', 1);
    }
    if (is_array($perm_owner)) {
        $perm_owner = SEC_getPermissionValue($perm_owner);
    } else {
        $perm_owner = 0;
    }
    if (is_array($perm_group)) {
        $perm_group = SEC_getPermissionValue($perm_group);
    } else {
        $perm_group = 0;
    }
    if (is_array($perm_members)) {
        $perm_members = SEC_getPermissionValue($perm_members);
    } else {
        $perm_members = 0;
    }
    if (is_array($perm_anon)) {
        $perm_anon = SEC_getPermissionValue($perm_anon);
    } else {
        $perm_anon = 0;
    }
    if ($_SEC_VERBOSE) {
        COM_errorLog('perm_owner = ' . $perm_owner, 1);
        COM_errorLog('perm_group = ' . $perm_group, 1);
        COM_errorLog('perm_member = ' . $perm_members, 1);
        COM_errorLog('perm_anon = ' . $perm_anon, 1);
        COM_errorLog('**** Leaving SEC_getPermissionValues ****', 1);
    }
    return array($perm_owner, $perm_group, $perm_members, $perm_anon);
}
Exemple #3
0
/**
* Shows the block editor
*
* This will show a block edit form.  If this is a glFusion default block it will
* send it off to BLOCK_editDefault().
*
* @param    string  $bid    ID of block to edit
* @param    array   $B      An array of block fields (optional)
* @return   string          HTML for block editor
*
*/
function BLOCK_edit($bid = '', $B = array())
{
    global $_CONF, $_GROUPS, $_TABLES, $_USER, $LANG01, $LANG21, $LANG24, $LANG_ACCESS, $LANG_ADMIN, $LANG_postmodes, $MESSAGE, $_IMAGE_TYPE;
    USES_lib_admin();
    $retval = '';
    $A = array();
    if (!empty($bid)) {
        $result = DB_query("SELECT * FROM {$_TABLES['blocks']} WHERE bid ='" . DB_escapeString($bid) . "'");
        $A = DB_fetchArray($result);
        $access = SEC_hasAccess($A['owner_id'], $A['group_id'], $A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']);
        if ($access == 2 || $access == 0 || BLOCK_hasTopicAccess($A['tid']) < 3) {
            $retval .= COM_showMessageText($LANG21[45], $LANG_ACCESS['accessdenied'], true);
            COM_accessLog("User {$_USER['username']} tried to illegally create or edit block " . $bid);
            return $retval;
        }
        if ($A['type'] == 'gldefault') {
            $retval .= BLOCK_editDefault($A, $access);
            return $retval;
        }
    } else {
        $A['bid'] = isset($B['bid']) ? $B['bid'] : 0;
        $A['is_enabled'] = isset($B['is_enabled']) ? $B['is_enabled'] : 1;
        $A['name'] = isset($B['name']) ? $B['name'] : '';
        $A['type'] = isset($B['type']) ? $B['type'] : 'normal';
        $A['title'] = isset($B['title']) ? $B['title'] : '';
        $A['tid'] = isset($B['tid']) ? $B['tid'] : 'All';
        $A['blockorder'] = isset($B['blockorder']) ? $B['blockorder'] : 0;
        $A['content'] = isset($B['content']) ? $B['content'] : '';
        $A['allow_autotags'] = isset($B['allow_autotags']) && $B['allow_autotags'] == 1 ? 1 : 0;
        $A['rdfurl'] = isset($B['rdfurl']) ? $B['rdfurl'] : '';
        $A['rdfupdated'] = isset($B['rdfupdated']) ? $B['rdfupdated'] : '';
        $A['rdflimit'] = isset($B['rdflimit']) ? $B['rdflimit'] : 0;
        $A['onleft'] = isset($B['onleft']) ? $B['onleft'] : 0;
        $A['phpblockfn'] = isset($B['phpblockfn']) ? $B['phpblockfn'] : '';
        $A['help'] = isset($B['help']) ? $B['help'] : '';
        $A['owner_id'] = isset($B['owner_id']) ? $B['owner_id'] : $_USER['uid'];
        if (isset($B['group_id'])) {
            $A['group_id'] = $B['group_id'];
        } else {
            if (isset($_GROUPS['Block Admin'])) {
                $A['group_id'] = $_GROUPS['Block Admin'];
            } else {
                $A['group_id'] = SEC_getFeatureGroup('block.edit');
            }
        }
        if (isset($B['perm_owner'])) {
            $A['perm_owner'] = SEC_getPermissionValue($B['perm_owner']);
            $A['perm_group'] = SEC_getPermissionValue($B['perm_group']);
            $A['perm_members'] = SEC_getPermissionValue($B['perm_members']);
            $A['perm_anon'] = SEC_getPermissionValue($B['perm_anon']);
        } else {
            SEC_setDefaultPermissions($A, $_CONF['default_permissions_block']);
        }
        $access = 3;
    }
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/block.php', 'text' => $LANG_ADMIN['block_list']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $block_templates = new Template($_CONF['path_layout'] . 'admin/block');
    $block_templates->set_file('editor', 'blockeditor.thtml');
    $block_templates->set_var('start_block_editor', COM_startBlock($LANG21[3], '', COM_getBlockTemplate('_admin_block', 'header')));
    if (!empty($bid) && SEC_hasrights('block.delete')) {
        $delbutton = '<input type="submit" value="' . $LANG_ADMIN['delete'] . '" name="delete"%s >';
        $jsconfirm = ' onclick="return confirm(\'' . $MESSAGE[76] . '\');"';
        $block_templates->set_var('delete_option', sprintf($delbutton, $jsconfirm));
        $block_templates->set_var('delete_option_no_confirmation', sprintf($delbutton, ''));
        $block_templates->set_var('lang_delete', $LANG_ADMIN['delete']);
        $block_templates->set_var('lang_delete_confirm', $MESSAGE[76]);
    }
    $block_templates->set_var('block_bid', $A['bid']);
    // standard Admin strings
    $block_templates->set_var('lang_blocktitle', $LANG_ADMIN['title']);
    $block_templates->set_var('lang_enabled', $LANG_ADMIN['enabled']);
    $block_templates->set_var('lang_blockhelpurl', $LANG_ADMIN['help_url']);
    $block_templates->set_var('lang_topic', $LANG_ADMIN['topic']);
    $block_templates->set_var('lang_save', $LANG_ADMIN['save']);
    $block_templates->set_var('lang_cancel', $LANG_ADMIN['cancel']);
    $block_templates->set_var('lang_blocktype', $LANG_ADMIN['type']);
    $block_templates->set_var('lang_allowed_html', $LANG01[123]);
    $block_templates->set_var('block_title', htmlspecialchars($A['title'], ENT_QUOTES, COM_getEncodingt()));
    $block_templates->set_var('lang_enabled', $LANG21[53]);
    if ($A['is_enabled'] == 1) {
        $block_templates->set_var('is_enabled', 'checked="checked"');
    } else {
        $block_templates->set_var('is_enabled', '');
    }
    $block_templates->set_var('block_help', $A['help']);
    $block_templates->set_var('lang_includehttp', $LANG21[51]);
    $block_templates->set_var('lang_explanation', $LANG21[52]);
    $block_templates->set_var('block_name', $A['name']);
    $block_templates->set_var('lang_blockname', $LANG21[48]);
    $block_templates->set_var('lang_nospaces', $LANG21[49]);
    $block_templates->set_var('lang_all', $LANG21[7]);
    $block_templates->set_var('lang_homeonly', $LANG21[43]);
    $block_templates->set_var('lang_nohomepage', $LANG21[44]);
    if ($A['tid'] == 'all') {
        $block_templates->set_var('all_selected', 'selected="selected"');
    } else {
        if ($A['tid'] == 'homeonly') {
            $block_templates->set_var('homeonly_selected', 'selected="selected"');
        } else {
            if ($A['tid'] == 'allnhp') {
                $block_templates->set_var('nohomepage_selected', 'selected="selected"');
            }
        }
    }
    $block_templates->set_var('topic_options', COM_topicList('tid,topic', $A['tid'], 1, true));
    $block_templates->set_var('lang_side', $LANG21[39]);
    $block_templates->set_var('lang_left', $LANG21[40]);
    $block_templates->set_var('lang_right', $LANG21[41]);
    if ($A['onleft'] == 1) {
        $block_templates->set_var('left_selected', 'selected="selected"');
    } else {
        if ($A['onleft'] == 0) {
            $block_templates->set_var('right_selected', 'selected="selected"');
        }
    }
    $block_templates->set_var('lang_blockorder', $LANG21[9]);
    $block_templates->set_var('block_order', $A['blockorder']);
    $block_templates->set_var('lang_normalblock', $LANG21[12]);
    $block_templates->set_var('lang_phpblock', $LANG21[27]);
    $block_templates->set_var('lang_portalblock', $LANG21[11]);
    if ($A['type'] == 'normal') {
        $block_templates->set_var('normal_selected', 'selected="selected"');
    } else {
        if ($A['type'] == 'phpblock') {
            $block_templates->set_var('php_selected', 'selected="selected"');
        } else {
            if ($A['type'] == 'portal') {
                $block_templates->set_var('portal_selected', 'selected="selected"');
            }
        }
    }
    $block_templates->set_var('lang_accessrights', $LANG_ACCESS['accessrights']);
    $block_templates->set_var('lang_owner', $LANG_ACCESS['owner']);
    $ownername = COM_getDisplayName($A['owner_id']);
    $block_templates->set_var('owner_username', DB_getItem($_TABLES['users'], 'username', "uid = '{$A['owner_id']}'"));
    $block_templates->set_var('owner_name', $ownername);
    $block_templates->set_var('owner', $ownername);
    $block_templates->set_var('owner_id', $A['owner_id']);
    $block_templates->set_var('lang_group', $LANG_ACCESS['group']);
    $block_templates->set_var('group_dropdown', SEC_getGroupDropdown($A['group_id'], $access));
    $block_templates->set_var('lang_permissions', $LANG_ACCESS['permissions']);
    $block_templates->set_var('lang_perm_key', $LANG_ACCESS['permissionskey']);
    $block_templates->set_var('permissions_editor', SEC_getPermissionsHTML($A['perm_owner'], $A['perm_group'], $A['perm_members'], $A['perm_anon']));
    $block_templates->set_var('lang_permissions_msg', $LANG_ACCESS['permmsg']);
    $block_templates->set_var('lang_phpblockoptions', $LANG21[28]);
    $block_templates->set_var('lang_blockfunction', $LANG21[29]);
    $block_templates->set_var('block_phpblockfn', $A['phpblockfn']);
    $block_templates->set_var('lang_phpblockwarning', $LANG21[30]);
    $block_templates->set_var('lang_portalblockoptions', $LANG21[13]);
    $block_templates->set_var('lang_rdfurl', $LANG21[14]);
    $block_templates->set_var('max_url_length', 255);
    $block_templates->set_var('block_rdfurl', $A['rdfurl']);
    $block_templates->set_var('lang_rdflimit', $LANG21[62]);
    $block_templates->set_var('block_rdflimit', $A['rdflimit']);
    $block_templates->set_var('lang_lastrdfupdate', $LANG21[15]);
    if ($A['rdfupdated'] == '1000-01-01 00:00:00') {
        $block_templates->set_var('block_rdfupdated', '');
    } else {
        $block_templates->set_var('block_rdfupdated', $A['rdfupdated']);
    }
    $block_templates->set_var('lang_normalblockoptions', $LANG21[16]);
    $block_templates->set_var('lang_blockcontent', $LANG21[17]);
    $block_templates->set_var('lang_autotags', $LANG21[66]);
    $block_templates->set_var('lang_use_autotags', $LANG21[67]);
    $block_templates->set_var('block_content', htmlspecialchars($A['content'], ENT_QUOTES, COM_getEncodingt()));
    $block_templates->set_var('block_text', htmlspecialchars($A['content'], ENT_QUOTES, COM_getEncodingt()));
    $block_templates->set_var('block_html', htmlspecialchars($A['content'], ENT_QUOTES, COM_getEncodingt()));
    if ($A['allow_autotags'] == 1) {
        $block_templates->set_var('allow_autotags', 'checked="checked"');
    } else {
        $block_templates->set_var('allow_autotags', '');
    }
    $block_templates->set_var('gltoken_name', CSRF_TOKEN);
    $block_templates->set_var('gltoken', SEC_createToken());
    $block_templates->set_var('admin_menu', ADMIN_createMenu($menu_arr, $LANG21[71], $_CONF['layout_url'] . '/images/icons/block.' . $_IMAGE_TYPE));
    $block_templates->set_var('end_block', COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer')));
    PLG_templateSetVars('blockeditor', $block_templates);
    $block_templates->parse('output', 'editor');
    $retval .= $block_templates->finish($block_templates->get_var('output'));
    return $retval;
}