function up_get_MBcolumn($id)
{
    global $boarddir, $context, $user_info, $scripturl;
    foreach ($context['blocks-init'] as $row) {
        if ($row['id'] == $id) {
            $id_block = $row['id'];
            $content = "";
            $perms = '';
            $perms = array();
            $title = $row['title'];
            $icon = $row['icon'];
            $active = $row['active'];
            if ($row['perms']) {
                $perms = $row['perms'];
            }
            if (!$perms) {
                $perms = array();
            }
            $perms = !empty($perms) ? explode(',', $perms) : '';
            $viewblock = !empty($perms) ? false : true;
            if ($viewblock === false) {
                foreach ($user_info['groups'] as $group_id) {
                    if (in_array($group_id, $perms)) {
                        $viewblock = true;
                    }
                }
            }
            if ($active == "checked" && ($viewblock === true || $user_info['is_admin'])) {
                switch ($row['personal']) {
                    // HTML Block
                    case '1':
                        if ($row['content'] != "") {
                            $content = "" . stripslashes($row['content']) . "";
                        }
                        //Print
                        $title = $user_info['is_admin'] ? '<a href="' . $scripturl . '?action=adminportal;area=ultimate_portal_blocks;sa=blocks-edit;id=' . $row['id'] . ';personal=' . $row['personal'] . '">' . $title . '</a>' : $title;
                        head_block($icon, $title, $id_block, $row['bk_collapse'], $row['bk_no_title'], $row['bk_style']);
                        echo $content;
                        footer_block(trim($row['bk_style']));
                        break;
                        // PHP Block
                    // PHP Block
                    case '2':
                        $title = $user_info['is_admin'] ? '<a href="' . $scripturl . '?action=adminportal;area=ultimate_portal_blocks;sa=blocks-edit;id=' . $row['id'] . ';personal=' . $row['personal'] . ';type-php=created">' . $title . '</a>' : $title;
                        head_block($icon, $title, $id_block, $row['bk_collapse'], $row['bk_no_title'], $row['bk_style']);
                        require_once $boarddir . "/up-php-blocks/" . $row['file'];
                        footer_block(trim($row['bk_style']));
                        break;
                        // System Block
                    // System Block
                    default:
                        $title = $user_info['is_admin'] ? '<a href="' . $scripturl . '?action=adminportal;area=ultimate_portal_blocks;sa=blocks-edit;id=' . $row['id'] . ';personal=' . $row['personal'] . ';type-php=system">' . $title . '</a>' : $title;
                        head_block($icon, $title, $id_block, $row['bk_collapse'], $row['bk_no_title'], $row['bk_style']);
                        require_once $boarddir . "/up-blocks/" . $row['file'];
                        footer_block(trim($row['bk_style']));
                        break;
                }
            }
        }
        unset($viewblock);
    }
}
function template_edit_block_php()
{
    global $context, $txt, $settings, $scripturl;
    //Preview
    if ($context['preview']) {
        echo '
		<table align="center" width="70%">
			<tr>
				<td>';
        head_block($context['icon'], $context['title'], -10, $context['bk_collapse'], $context['bk_no_title'], $context['bk_style']);
        $context['content'] = trim($context['content'], '<?php');
        $context['content'] = trim($context['content'], '?>');
        eval($context['content']);
        footer_block($context['bk_style']);
        echo '			
				</td>
			</tr>
		</table><br />';
    }
    //End Preview
    echo '
	<form method="post" action="', $scripturl, '?action=adminportal;area=ultimate_portal_blocks;sa=blocks-php-edit;id=' . $context['id'] . ';type-php=' . $context['type_php'] . '" accept-charset="', $context['character_set'], '">	
	<div id="admincenter">
		<div class="cat_bar">
			<h3 class="catbg">
				', $txt['ultport_add_bk_php_titles'], '
			</h3>
		</div>												
		<div class="windowbg2">
			<span class="topslice"><span></span></span>
			<div class="content">
				<dl class="settings">
					<dt>
						<span><label for="ultport_add_bk_title">', $txt['ultport_add_bk_title'], '</label></span>
					</dt>
					<dd>
						<input type="text" value="', $context['title'], '" name="bk-title" size="50" />
					</dd>';
    if (!empty($context['folder_images'])) {
        echo '	
					<dt>
						<span><label for="ultport_add_bk_icon">', $txt['ultport_add_bk_icon'], '</label></span>
					</dt>				
					<dd>
						<table width="100%">
							<tr>';
        $i = 1;
        foreach ($context['folder_images'] as $folder) {
            echo '
								<td>
									<input ' . ($context['icon'] == $folder['value'] ? 'checked="checked"' : '') . ' value="' . $folder['value'] . '" type="radio" name="icon">&nbsp;', $folder['image'] . '
								</td>';
            $i++;
            if ($i == 6) {
                echo '</tr><tr>';
                $i = 1;
            }
        }
        echo '</tr>
						</table>
					</dd>						
				</dl>';
    }
    echo '
				<div style="margin: 10px;" align="center">
					<textarea id="content" name="content" rows="20" cols="80" style="width: 99.2%">', $context['content'], '</textarea>
				</div>
				<dl class="settings">
					<dt>
						<span><label for="ultport_add_bk_collapse">', $txt['ultport_add_bk_collapse'], '</label></span>
					</dt>
					<dd>
						<input type="checkbox" name="can_collapse" value="on" ', !empty($context['bk_collapse']) ? 'checked="checked"' : '', ' />
					</dd>
					<dt>
						<span><label for="ultport_add_bk_style">', $txt['ultport_add_bk_style'], '</label></span>
					</dt>
					<dd>
						<input type="checkbox" name="bk_style" value="on" ', !empty($context['bk_style']) ? 'checked="checked"' : '', ' />
					</dd>
					<dt>
						<span><label for="ultport_add_bk_no_title">', $txt['ultport_add_bk_no_title'], '</label></span>
					</dt>
					<dd>
						<input type="checkbox" name="no_title" value="on" ', !empty($context['bk_no_title']) ? 'checked="checked"' : '', ' />
					</dd>
				</dl>	
				<hr class="hrcolor clear" />
				<div class="righttext">
					<input type="hidden" name="sc" value="', $context['session_id'], '" />
					<input type="hidden" name="use_folder" value="', $context['use_folder'], '" />&nbsp;
					<input type="submit" name="save" value="', $txt['ultport_button_save'], '" />&nbsp;
					<input type="submit" name="preview" value="', $txt['ultport_button_preview'], '" />
				</div>	
			</div>	
			<span class="botslice"><span></span></span>	
		</div>		
	</div>
	</form>';
}