Skip to content
This repository was archived by the owner on Jun 13, 2018. It is now read-only.
Open
25 changes: 15 additions & 10 deletions upload/admins/pages/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,20 +159,25 @@
$position = $order->get_new($parent);

// Work-out if the page parent (if selected) has a seperate template or language to the default
$query_parent = $database->query("SELECT template, language FROM ".TABLE_PREFIX."pages WHERE page_id = '$parent'");
if($query_parent->numRows() > 0)
{
$fetch_parent = $query_parent->fetchRow( MYSQL_ASSOC );
$template = $fetch_parent['template'];
$language = $fetch_parent['language'];
} else {
$template = '';
$language = DEFAULT_LANGUAGE;
$template = '';
$language = DEFAULT_LANGUAGE;
if($parent != '0'){
$query_parent = $database->query("SELECT template, language FROM ".TABLE_PREFIX."pages WHERE page_id = '$parent'");
if($query_parent->numRows() > 0)
{
$fetch_parent = $query_parent->fetchRow( MYSQL_ASSOC );
$template = $fetch_parent['template'];
$language = $fetch_parent['language'];
}
}

// Insert page into pages table
$sql = 'INSERT INTO `'.TABLE_PREFIX.'pages` SET ';
$sql .= '`parent` = '.$parent.', ';
if($parent != '0'){
$sql .= '`parent` = '.$parent.', ';
}else{
$sql .= '`parent` = NULL, ';
}
$sql .= '`target` = "_top", ';
$sql .= '`page_title` = "'.$title.'", ';
$sql .= '`menu_title` = "'.$title.'", ';
Expand Down
25 changes: 18 additions & 7 deletions upload/admins/pages/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
);
$template->parse('page_list2', 'page_list_block2', true);
}
parent_list(0);
parent_list();

// Explode module permissions
$module_permissions = $_SESSION['MODULE_PERMISSIONS'];
Expand Down Expand Up @@ -241,13 +241,19 @@


// Parent page list
function parent_list($parent)
function parent_list($parent = null)
{
global $admin, $database, $template, $field_set;

if(is_null($parent)){
$parent = 'is null';
}else{
$parent = ' = ' . $parent;
}

$admin_user_id = $admin->get_user_id();

$query = "SELECT `page_id`,`admin_groups`,`admin_users`,`menu_title`,`page_title`,`visibility`,`parent`,`level`,`viewing_groups`,`viewing_users` FROM ".TABLE_PREFIX."pages WHERE parent = '$parent' AND visibility!='deleted' ORDER BY position ASC";
$query = "SELECT `page_id`,`admin_groups`,`admin_users`,`menu_title`,`page_title`,`visibility`,`parent`,`level`,`viewing_groups`,`viewing_users` FROM ".TABLE_PREFIX."pages WHERE parent $parent AND visibility!='deleted' ORDER BY position ASC";
$get_pages = $database->query($query);
while($page = $get_pages->fetchRow( MYSQL_ASSOC )) {
if($admin->page_is_visible($page)==false)
Expand Down Expand Up @@ -302,7 +308,12 @@ function url_encode($string) {
return str_replace($entities, $replacements, rawurlencode($string));
}

function make_list($parent = 0, &$editable_pages = 0) {
function make_list($parent = null, &$editable_pages = 0) {
if(is_null($parent)){
$parent_cond = 'is null';
}else{
$parent_cond = ' = ' . $parent;
}
// Get objects and vars from outside this function
global $admin, $database, $TEXT, $MESSAGE, $HEADING, $par;
$template = new Template(THEME_PATH.'/templates');
Expand Down Expand Up @@ -333,7 +344,7 @@ function make_list($parent = 0, &$editable_pages = 0) {
}

// Get page list from database
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ';
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` '.$parent_cond.' ';
$sql .= (PAGE_TRASH != 'inline') ? 'AND `visibility` != \'deleted\' ' : ' ';
$sql .= 'ORDER BY `position` ASC';
$get_pages = $database->query($sql);
Expand Down Expand Up @@ -560,7 +571,7 @@ function print_list_page(){
$par['num_subs'] = 1;

$editable_pages = 0;
$loop = make_list(0, $editable_pages);
$loop = make_list(null, $editable_pages);
$template->set_var('PAGES_LIST_LOOP', $loop);
$template->parse('pages_list', 'page_list_block');
$template->parse('main', 'main_block');
Expand Down Expand Up @@ -684,4 +695,4 @@ function handle_search () {
}
// ----- BlackBird Search ID Hack Part II ----

?>
?>
12 changes: 8 additions & 4 deletions upload/admins/pages/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,11 +272,15 @@
}

// Parent page list
function parent_list($parent)
function parent_list($parent = null)
{
global $admin, $database, $template, $results_array,$field_set;

$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ORDER BY `position` ASC';
if(is_null($parent)){
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` IS NULL ORDER BY `position` ASC';
}else{
$sql = 'SELECT * FROM `'.TABLE_PREFIX.'pages` WHERE `parent` = '.$parent.' ORDER BY `position` ASC';
}
$get_pages = $database->query($sql);

while(false !== ($page = $get_pages->fetchRow( MYSQL_ASSOC ) ) )
Expand Down Expand Up @@ -351,7 +355,7 @@ function parent_list($parent)

$template->set_block('main_block', 'page_list_block2', 'page_list2');
if($admin->get_permission('pages_add_l0') == true OR $results_array['level'] == 0) {
if($results_array['parent'] == 0)
if(is_null($results_array['parent']))
{
$selected = ' selected="selected"';
} else {
Expand All @@ -365,7 +369,7 @@ function parent_list($parent)
);
$template->parse('page_list2', 'page_list_block2', true);
}
parent_list(0);
parent_list();

if($modified_ts == 'Unknown')
{
Expand Down
18 changes: 9 additions & 9 deletions upload/admins/pages/settings2.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
$description = htmlspecialchars(addslashes($admin->get_post('description')) );
$keywords = htmlspecialchars(addslashes($admin->get_post('keywords')) );
$page_code = htmlspecialchars(addslashes($admin->get_post('page_code')));
$parent = $admin->get_post_escaped('parent');
$parent = ($admin->get_post_escaped('parent') == '0') ? null : $admin->get_post_escaped('parent');
$visibility = $admin->get_post_escaped('visibility');
$template = $admin->get_post_escaped('template');
$target = $admin->get_post_escaped('target');
Expand Down Expand Up @@ -131,18 +131,18 @@
}

// Work out level and root parent
if ($parent!='0')
if (!is_null($parent))
{
$level = level_count($parent)+1;
$root_parent = root_parent($parent);
}
else {
$level = '0';
$root_parent = '0';
$root_parent = $page_id;
}

// Work-out what the link should be
if($parent == '0')
if(is_null($parent))
{
$link = '/'.page_filename($page_link);
// rename menu titles: index && intro to prevent clashes with intro page feature and WB core file /pages/index.php
Expand Down Expand Up @@ -178,21 +178,21 @@
}

// Update page with new order
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` SET `parent`='.$parent.', `position`='.$position.' WHERE `page_id`='.$page_id.'';
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` SET `parent`= ' . ((is_null($parent)) ? 'NULL' : $parent) . ' , `position`='.$position.' WHERE `page_id`='.$page_id.'';
$database->query($sql);

// Get page trail
$page_trail = get_page_trail($page_id);

// Update page settings in the pages table
$sql = 'UPDATE `'.TABLE_PREFIX.'pages` SET ';
$sql .= '`parent` = '.$parent.', ';
$sql .= '`parent` = ' . ((is_null($parent)) ? 'NULL' : $parent) . ', ';
$sql .= '`page_title` = "'.$page_title.'", ';
$sql .= '`menu_title` = "'.$menu_title.'", ';
$sql .= '`menu` = '.$menu.', ';
$sql .= '`level` = '.$level.', ';
$sql .= '`page_trail` = "'.$page_trail.'", ';
$sql .= '`root_parent` = '.$root_parent.', ';
$sql .= '`root_parent` = '.((is_null($root_parent)) ? 'NULL' : $root_parent).', ';
$sql .= '`link` = "'.$link.'", ';
$sql .= '`template` = "'.$template.'", ';
$sql .= '`target` = "'.$target.'", ';
Expand Down Expand Up @@ -282,7 +282,7 @@ function fix_page_trail($parent,$root_parent)
// Get objects and vars from outside this function
global $admin, $template, $database, $TEXT, $MESSAGE;
// Get page list from database
$query = "SELECT page_id FROM ".TABLE_PREFIX."pages WHERE parent = '$parent'";
$query = "SELECT page_id FROM ".TABLE_PREFIX."pages WHERE parent " . ((is_null($parent)) ? 'IS NULL' : "= '$parent'");
$get_pages = $database->query($query);
// Insert values into main page list
if($get_pages->numRows() > 0)
Expand All @@ -291,7 +291,7 @@ function fix_page_trail($parent,$root_parent)
{
// Fix page trail

$database->query("UPDATE ".TABLE_PREFIX."pages SET ".($root_parent != 0 ?"root_parent = '$root_parent', ":"")." page_trail = '".get_page_trail($page['page_id'])."' WHERE page_id = '".$page['page_id']."'");
$database->query("UPDATE ".TABLE_PREFIX."pages SET ".((is_null($root_parent)) ? "root_parent = '$root_parent', " : "")." page_trail = '".get_page_trail($page['page_id'])."' WHERE page_id = '".$page['page_id']."'");
// Run this query on subs
fix_page_trail($page['page_id'],$root_parent);
}
Expand Down
4 changes: 2 additions & 2 deletions upload/framework/class.frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function page_select()
$table_p = TABLE_PREFIX . 'pages';
$table_s = TABLE_PREFIX . 'sections';
$now = time();
$query_default = "SELECT `p`.`page_id`, `link` FROM `$table_p` AS `p` INNER JOIN `$table_s` USING(`page_id`) WHERE `parent` = '0'
$query_default = "SELECT `p`.`page_id`, `link` FROM `$table_p` AS `p` INNER JOIN `$table_s` USING(`page_id`) WHERE `parent` is null
AND `visibility` = 'public' AND (($now>=`publ_start` OR `publ_start`=0) AND ($now<=`publ_end` OR `publ_end`=0)) $this->sql_where_language ORDER BY `p`.`position` ASC LIMIT 1";
$get_default = $database->query( $query_default );
$default_num_rows = $get_default->numRows();
Expand Down Expand Up @@ -669,4 +669,4 @@ private function __find_files( &$aFilenames, &$aBasename, &$aStorrage, &$exeptio
}
}

?>
?>
2 changes: 1 addition & 1 deletion upload/framework/functions/function.root_parent.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function root_parent( $page_id )
{
return $parent;
} //$level == 1
elseif ( $parent == 0 )
elseif (is_null($parent))
{
return $page_id;
} //$parent == 0
Expand Down
12 changes: 6 additions & 6 deletions upload/install/save.php
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ function install_createGUID()
// Try installing tables
// Pages table
$pages = 'CREATE TABLE `'.TABLE_PREFIX.'pages` ( `page_id` INT NOT NULL auto_increment,'
. ' `parent` INT NOT NULL DEFAULT \'0\','
. ' `root_parent` INT NOT NULL DEFAULT \'0\','
. ' `parent` INT DEFAULT NULL,'
. ' `root_parent` INT DEFAULT NULL,'
. ' `level` INT NOT NULL DEFAULT \'0\','
. ' `link` TEXT NOT NULL,'
. ' `target` VARCHAR( 7 ) NOT NULL DEFAULT \'\' ,'
Expand All @@ -561,7 +561,7 @@ function install_createGUID()
. ' `position` INT NOT NULL DEFAULT \'0\','
. ' `menu` INT NOT NULL DEFAULT \'0\','
. ' `language` VARCHAR( 5 ) NOT NULL DEFAULT \'\' ,'
. ' `page_code` VARCHAR( 100 ) NOT NULL DEFAULT \'\' ,'
. ' `page_code` VARCHAR( 100 ) NOT NULL DEFAULT \'\' ,'
. ' `searching` INT NOT NULL DEFAULT \'0\','
. ' `admin_groups` TEXT NOT NULL ,'
. ' `admin_users` TEXT NOT NULL ,'
Expand All @@ -576,7 +576,7 @@ function install_createGUID()

// Sections table
$sections = 'CREATE TABLE `'.TABLE_PREFIX.'sections` ( `section_id` INT NOT NULL auto_increment,'
. ' `page_id` INT NOT NULL DEFAULT \'0\','
. ' `page_id` INT DEFAULT NULL,'
. ' `position` INT NOT NULL DEFAULT \'0\','
. ' `module` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
. ' `block` VARCHAR( 255 ) NOT NULL DEFAULT \'\' ,'
Expand Down Expand Up @@ -656,7 +656,7 @@ function install_createGUID()

// Users table
$users = 'CREATE TABLE `'.TABLE_PREFIX.'users` ( `user_id` INT NOT NULL auto_increment,'
. ' `group_id` INT NOT NULL DEFAULT \'0\','
. ' `group_id` INT DEFAULT NULL,'
. ' `groups_id` VARCHAR( 255 ) NOT NULL DEFAULT \'0\','
. ' `active` INT NOT NULL DEFAULT \'0\','
. ' `statusflags` INT NOT NULL DEFAULT \'6\','
Expand Down Expand Up @@ -1004,4 +1004,4 @@ function install_createGUID()
// redirect to the backend login
header("Location: ../install/support.php" );

?>
?>