Copyright (C) 2004-2005, Ryan Djurovich
Website Baker is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Website Baker is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Website Baker; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require('../../config.php');
require_once(WB_PATH.'/framework/class.admin.php');
$admin = new admin('Pages', 'pages');
// Include the WB functions file
require_once(WB_PATH.'/framework/functions.php');
?>
>
query($query);
// Insert values into main page list
if($get_pages->numRows() > 0) {
while($page = $get_pages->fetchRow()) {
// Get user perms
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
if($page['visibility'] == 'deleted') {
if(PAGE_TRASH == 'inline') {
$can_modify = true;
$editable_pages = $editable_pages+1;
} else {
$can_modify = false;
}
} elseif($page['visibility'] != 'deleted') {
$can_modify = true;
$editable_pages = $editable_pages+1;
}
} else {
$can_modify = false;
}
// Work out if we should show a plus or not
$get_page_subs = $database->query("SELECT page_id,admin_groups,admin_users FROM ".TABLE_PREFIX."pages WHERE parent = '".$page['page_id']."'");
if($get_page_subs->numRows() > 0) {
$display_plus = true;
} else {
$display_plus = false;
}
$display_plus = false;
// Work out how many pages there are for this parent
$num_pages = $get_pages->numRows();
?>
get_permission('pages_modify') == true AND $can_modify == true) { ?>
get_permission('pages_settings') == true AND $can_modify == true) { ?>
get_permission('pages_settings') == true AND $can_modify == true) { ?>
get_permission('pages_settings') == true AND $can_modify == true) { ?>
get_permission('pages_delete') == true AND $can_modify == true) { ?>
get_permission('pages_view') == true) {
?>
query("SELECT page_id FROM ".TABLE_PREFIX."pages WHERE visibility = 'deleted'");
if($query_trash->numRows() > 0) {
?>
:
:
:
:
set_file('page', 'template.html');
$template->set_block('page', 'main_block', 'main');
// Figure out if the no pages found message should be shown or not
if($editable_pages == 0) {
?>
get_group_id() == 1) {
$query = "SELECT * FROM ".TABLE_PREFIX."groups";
} else {
$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
}
$get_groups = $database->query($query);
$template->set_block('main_block', 'group_list_block', 'group_list');
// Insert admin group and current group first
$admin_group_name = $get_groups->fetchRow();
$template->set_var(array(
'ID' => 1,
'TOGGLE' => '',
'DISABLED' => ' disabled',
'LINK_COLOR' => '000000',
'CURSOR' => 'default',
'NAME' => $admin_group_name['name'],
'CHECKED' => ' checked'
)
);
$template->parse('group_list', 'group_list_block', true);
if($admin->get_group_id() != 1) {
$template->set_var(array(
'ID' => $admin->get_group_id(),
'TOGGLE' => '',
'DISABLED' => ' disabled',
'LINK_COLOR' => '000000',
'CURSOR' => 'default',
'NAME' => $admin->get_group_name(),
'CHECKED' => ' checked'
)
);
$template->parse('group_list', 'group_list_block', true);
}
while($group = $get_groups->fetchRow()) {
// Check if the group is allowed to edit pages
$system_permissions = explode(',', $group['system_permissions']);
if(is_numeric(array_search('pages_modify', $system_permissions))) {
$template->set_var(array(
'ID' => $group['group_id'],
'TOGGLE' => $group['group_id'],
'CHECKED' => '',
'DISABLED' => '',
'LINK_COLOR' => '',
'CURSOR' => 'pointer',
'NAME' => $group['name'],
'CHECKED' => ''
)
);
$template->parse('group_list', 'group_list_block', true);
}
}
// Group list 2
if($admin->get_group_id() == 1) {
$query = "SELECT * FROM ".TABLE_PREFIX."groups";
} else {
$query = "SELECT * FROM ".TABLE_PREFIX."groups WHERE group_id != '".$admin->get_group_id()."'";
}
$get_groups = $database->query($query);
$template->set_block('main_block', 'group_list_block2', 'group_list2');
// Insert admin group and current group first
$admin_group_name = $get_groups->fetchRow();
$template->set_var(array(
'ID' => 1,
'TOGGLE' => '',
'DISABLED' => ' disabled',
'LINK_COLOR' => '000000',
'CURSOR' => 'default',
'NAME' => $admin_group_name['name'],
'CHECKED' => ' checked'
)
);
$template->parse('group_list2', 'group_list_block2', true);
if($admin->get_group_id() != 1) {
$template->set_var(array(
'ID' => $admin->get_group_id(),
'TOGGLE' => '',
'DISABLED' => ' disabled',
'LINK_COLOR' => '000000',
'CURSOR' => 'default',
'NAME' => $admin->get_group_name(),
'CHECKED' => ' checked'
)
);
$template->parse('group_list2', 'group_list_block2', true);
}
while($group = $get_groups->fetchRow()) {
$template->set_var(array(
'ID' => $group['group_id'],
'TOGGLE' => $group['group_id'],
'CHECKED' => '',
'DISABLED' => '',
'LINK_COLOR' => '',
'CURSOR' => 'pointer',
'NAME' => $group['name'],
'CHECKED' => ''
)
);
$template->parse('group_list2', 'group_list_block2', true);
}
// Parent page list
$database = new database();
function parent_list($parent) {
global $admin, $database, $template;
$query = "SELECT * FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' ORDER BY position ASC";
$get_pages = $database->query($query);
while($page = $get_pages->fetchRow()) {
// Stop users from adding pages with a level of more than the set page level limit
if($page['level']+1 < PAGE_LEVEL_LIMIT) {
// Get user perms
$admin_groups = explode(',', str_replace('_', '', $page['admin_groups']));
$admin_users = explode(',', str_replace('_', '', $page['admin_users']));
if(is_numeric(array_search($admin->get_group_id(), $admin_groups)) OR is_numeric(array_search($admin->get_user_id(), $admin_users))) {
$can_modify = true;
} else {
$can_modify = false;
}
// Title -'s prefix
$title_prefix = '';
for($i = 1; $i <= $page['level']; $i++) { $title_prefix .= ' - '; }
$template->set_var(array(
'ID' => $page['page_id'],
'TITLE' => stripslashes($title_prefix.$page['page_title'])
)
);
if($can_modify == true) {
$template->set_var('DISABLED', '');
} else {
$template->set_var('DISABLED', ' disabled');
}
$template->parse('page_list2', 'page_list_block2', true);
}
parent_list($page['page_id']);
}
}
$template->set_block('main_block', 'page_list_block2', 'page_list2');
if($admin->get_permission('pages_add_l0') == true) {
$template->set_var(array(
'ID' => '0',
'TITLE' => $TEXT['NONE'],
'SELECTED' => ' selected',
'DISABLED' => ''
)
);
$template->parse('page_list2', 'page_list_block2', true);
}
parent_list(0);
// Explode module permissions
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
// Modules list
$template->set_block('main_block', 'module_list_block', 'module_list');
if($handle = opendir(WB_PATH.'/modules/')) {
while (false !== ($file = readdir($handle))) {
if($file != '.' AND $file != '..' AND $file != 'CVS' AND is_dir(WB_PATH."/modules/$file") AND file_exists(WB_PATH."/modules/$file/info.php")) {
// Include the modules info file
require(WB_PATH.'/modules/'.$file.'/info.php');
// Check if user is allowed to use this module
if(!isset($module_type)) { $module_type = 'unknown'; }
if(!is_numeric(array_search($file, $module_permissions)) AND $module_type == 'page') {
$template->set_var('VALUE', $file);
$template->set_var('NAME', $module_name);
if($file == 'wysiwyg') {
$template->set_var('SELECTED', ' selected');
} else {
$template->set_var('SELECTED', '');
}
$template->parse('module_list', 'module_list_block', true);
}
if(isset($module_type)) { unset($module_type); } // Unset module type
}
}
}
// Insert language headings
$template->set_var(array(
'HEADING_ADD_PAGE' => $HEADING['ADD_PAGE'],
'HEADING_MODIFY_INTRO_PAGE' => $HEADING['MODIFY_INTRO_PAGE']
)
);
// Insert language text and messages
$template->set_var(array(
'TEXT_TITLE' => $TEXT['TITLE'],
'TEXT_TYPE' => $TEXT['TYPE'],
'TEXT_PARENT' => $TEXT['PARENT'],
'TEXT_VISIBILITY' => $TEXT['VISIBILITY'],
'TEXT_PUBLIC' => $TEXT['PUBLIC'],
'TEXT_PRIVATE' => $TEXT['PRIVATE'],
'TEXT_REGISTERED' => $TEXT['REGISTERED'],
'TEXT_HIDDEN' => $TEXT['HIDDEN'],
'TEXT_NONE' => $TEXT['NONE'],
'TEXT_NONE_FOUND' => $TEXT['NONE_FOUND'],
'TEXT_ADD' => $TEXT['ADD'],
'TEXT_RESET' => $TEXT['RESET'],
'TEXT_ADMINISTRATORS' => $TEXT['ADMINISTRATORS'],
'TEXT_PRIVATE_VIEWERS' => $TEXT['PRIVATE_VIEWERS'],
'TEXT_REGISTERED_VIEWERS' => $TEXT['REGISTERED_VIEWERS'],
'INTRO_LINK' => $MESSAGE['PAGES']['INTRO_LINK'],
)
);
// Insert permissions values
if($admin->get_permission('pages_add') != true) {
$template->set_var('DISPLAY_ADD', 'hide');
} elseif($admin->get_permission('pages_add_l0') != true AND $editable_pages == 0) {
$template->set_var('DISPLAY_ADD', 'hide');
}
if($admin->get_permission('pages_intro') != true OR INTRO_PAGE != 'enabled') {
$template->set_var('DISPLAY_INTRO', 'hide');
}
// Parse template object
$template->parse('main', 'main_block', false);
$template->pparse('output', 'page');
// Print admin
$admin->print_footer();
?>