aboutsummaryrefslogtreecommitdiffstats
path: root/admin/remote_site.php
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2004-12-12 21:06:39 +0000
committerplegall <plg@piwigo.org>2004-12-12 21:06:39 +0000
commit391fac78a80c9317e764a13d742c88d8fe0866fc (patch)
tree178c3f72dd0356c4c6ad05adae9d974dedbfa506 /admin/remote_site.php
parent9037726f5a658dc156ef444f2d90271ee2102711 (diff)
- in admin menu, status option for categories is not "permissions" but
"private or public" choice = different language item - get_cat_display_name changed : use $conf['level_separator'] to unify presentation - default values for category properties commentable, uploadable, status and visible (set in include/config.inc.php) used for category creation (admin/update, admin/remote_site, admin/cat_list) - use mass_inserts in admin/update for inserting new categories - only one query for counting the number of sub categories in admin/cat_list git-svn-id: http://piwigo.org/svn/trunk@642 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin/remote_site.php')
-rw-r--r--admin/remote_site.php80
1 files changed, 57 insertions, 23 deletions
diff --git a/admin/remote_site.php b/admin/remote_site.php
index 6f0279f21..66d6d6a58 100644
--- a/admin/remote_site.php
+++ b/admin/remote_site.php
@@ -176,7 +176,7 @@ function update_remote_site($listing_file, $site_id)
*/
function insert_remote_category($xml_content, $site_id, $id_uppercat, $level)
{
- global $counts, $removes;
+ global $counts, $removes, $conf;
$uppercats = '';
// 0. retrieving informations on the category to display
@@ -184,15 +184,18 @@ function insert_remote_category($xml_content, $site_id, $id_uppercat, $level)
if (is_numeric($id_uppercat))
{
$query = '
-SELECT name,uppercats,dir
+SELECT id,name,uppercats,dir,status,visible
FROM '.CATEGORIES_TABLE.'
WHERE id = '.$id_uppercat.'
;';
$row = mysql_fetch_array(pwg_query($query));
+ $parent = array('id' => $row['id'],
+ 'name' => $row['name'],
+ 'dir' => $row['dir'],
+ 'uppercats' => $row['uppercats'],
+ 'visible' => $row['visible'],
+ 'status' => $row['status']);
- $uppercats = $row['uppercats'];
- $name = $row['name'];
-
insert_remote_element($xml_content, $id_uppercat);
}
@@ -224,6 +227,39 @@ SELECT name,uppercats,dir
// array of new categories to insert
$inserts = array();
+ // calculate default value at category creation
+ $create_values = array();
+ if (isset($parent))
+ {
+ // at creation, must a category be visible or not ? Warning : if
+ // the parent category is invisible, the category is automatically
+ // create invisible. (invisible = locked)
+ if ('false' == $parent['visible'])
+ {
+ $create_values{'visible'} = 'false';
+ }
+ else
+ {
+ $create_values{'visible'} = $conf['newcat_default_visible'];
+ }
+ // at creation, must a category be public or private ? Warning :
+ // if the parent category is private, the category is
+ // automatically create private.
+ if ('private' == $parent['status'])
+ {
+ $create_values{'status'} = 'private';
+ }
+ else
+ {
+ $create_values{'status'} = $conf['newcat_default_status'];
+ }
+ }
+ else
+ {
+ $create_values{'visible'} = $conf['newcat_default_visible'];
+ $create_values{'status'} = $conf['newcat_default_status'];
+ }
+
foreach ($xml_dirs as $xml_dir)
{
// 5. Is the category already existing ? we create a subcat if not
@@ -239,9 +275,13 @@ SELECT name,uppercats,dir
$insert{'name'} = $name;
$insert{'site_id'} = $site_id;
$insert{'uppercats'} = 'undef';
- if (is_numeric($id_uppercat))
+ $insert{'commentable'} = $conf['newcat_default_commentable'];
+ $insert{'uploadable'} = 'false';
+ $insert{'status'} = $create_values{'status'};
+ $insert{'visible'} = $create_values{'visible'};
+ if (isset($parent))
{
- $insert{'id_uppercat'} = $id_uppercat;
+ $insert{'id_uppercat'} = $parent['id'];
}
array_push($inserts, $insert);
}
@@ -251,31 +291,25 @@ SELECT name,uppercats,dir
if (count($inserts) > 0)
{
// inserts all found categories
- $dbfields = array('dir','name','site_id','uppercats','id_uppercat');
+ $dbfields = array('dir','name','site_id','uppercats','id_uppercat',
+ 'commentable','uploadable','status','visible');
mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
$counts{'new_categories'}+= count($inserts);
// updating uppercats field
$query = '
-UPDATE '.CATEGORIES_TABLE.'
- SET uppercats = ';
- if ($uppercats != '')
- {
- $query.= "CONCAT('".$uppercats."',',',id)";
- }
- else
- {
- $query.= 'id';
- }
- $query.= '
- WHERE id_uppercat ';
- if (!is_numeric($id_uppercat))
+UPDATE '.CATEGORIES_TABLE;
+ if (isset($parent))
{
- $query.= 'IS NULL';
+ $query.= "
+ SET uppercats = CONCAT('".$parent['uppercats']."',',',id)
+ WHERE id_uppercat = ".$id_uppercat;
}
else
{
- $query.= '= '.$id_uppercat;
+ $query.= '
+ SET uppercats = id
+ WHERE id_uppercat IS NULL';
}
$query.= '
;';