aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgweltas <gweltas@piwigo.org>2004-08-25 22:25:58 +0000
committergweltas <gweltas@piwigo.org>2004-08-25 22:25:58 +0000
commit11c2e5805334a637a4e304c27d0fdcf709e24772 (patch)
tree5ca4823ca75bb9d9a2d7dccd0774cbf9aa8aa4a0
parentc8fb7c2e36194e1f0687c4be6689a841f2615614 (diff)
- Deletion of obsolete functions in the administrative part
- Repair of virtual category management git-svn-id: http://piwigo.org/svn/trunk@496 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/cat_list.php39
-rw-r--r--admin/include/functions.php158
-rw-r--r--admin/infos_images.php7
-rw-r--r--include/functions.inc.php2
-rw-r--r--include/functions_category.inc.php4
-rw-r--r--include/functions_html.inc.php2
-rw-r--r--language/en_UK.iso-8859-1/common.lang.php16
-rw-r--r--picture.php2
8 files changed, 46 insertions, 184 deletions
diff --git a/admin/cat_list.php b/admin/cat_list.php
index 310cf78a7..a611ae3ba 100644
--- a/admin/cat_list.php
+++ b/admin/cat_list.php
@@ -38,8 +38,9 @@ $navigation=$lang['gallery_index'];
//--------------------------------------------------- virtual categories
if ( isset( $_GET['delete'] ) && is_numeric( $_GET['delete'] ) )
{
- delete_category( $_GET['delete'] );
- synchronize_all_users();
+ $to_delete_categories = array();
+ array_push($to_delete_categories,$_GET['delete']);
+ delete_categories( $to_delete_categories );
}
elseif ( isset( $_POST['submit'] ) )
{
@@ -49,14 +50,32 @@ elseif ( isset( $_POST['submit'] ) )
if ( !count( $errors ))
{
- // we have then to add the virtual category
- $parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL';
+ $parent_id = !empty($_GET['parent_id'])?$_GET['parent_id']:'NULL';
+ // As we don't create a virtual category every day, let's do (far) too much queries
+ if ($parent_id!='NULL')
+ {
+ $query = 'SELECT uppercats FROM '.CATEGORIES_TABLE;
+ $query.= ' WHERE id="'.$parent_id.'";';
+ $parent_uppercats = array_pop(mysql_fetch_array( mysql_query( $query )));
+ }
+
+ // we have then to add the virtual category
$query = 'INSERT INTO '.CATEGORIES_TABLE;
$query.= ' (name,id_uppercat,rank) VALUES ';
- $query.= " ('".$_POST['virtual_name']."',".$parent_id.",".$_POST['rank'].")";
- $query.= ';';
- mysql_query( $query );
- synchronize_all_users();
+ $query.= " ('".$_POST['virtual_name']."',".$parent_id.",".$_POST['rank'].");";
+ mysql_query( $query );
+
+ // And last we update the uppercats
+ $query = 'SELECT MAX(id) FROM '.CATEGORIES_TABLE.';';
+ $my_id = array_pop(mysql_fetch_array( mysql_query( $query )));
+ $query = 'UPDATE '.CATEGORIES_TABLE.' SET uppercats = "';
+ if (!empty($parent_uppercats))
+ {
+ $query.= $parent_uppercats.',';
+ }
+ $query.= $my_id;
+ $query.= '" WHERE id = '.$my_id.';';
+ mysql_query( $query );
}
}
@@ -223,12 +242,12 @@ while (list ($id,$category) = each($categories))
if ($category['visible'] == 'false')
{
$category_image = '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_folder_lock.gif"
- width="46" height="25" alt="'.$lang['cat_private'].'" title="'.$lang['cat_private'].'"/>';
+ alt="'.$lang['cat_private'].'" title="'.$lang['cat_private'].'"/>';
}
elseif (empty($category['dir']))
{
$category_image = '<img src="'.PHPWG_ROOT_PATH.'template/'.$user['template'].'/admin/images/icon_folder_link.gif"
- width="46" height="25" alt="'.$lang['cat_virtual'].'" title="'.$lang['cat_virtual'].'"/>';
+ alt="'.$lang['cat_virtual'].'" title="'.$lang['cat_virtual'].'"/>';
}
else
{
diff --git a/admin/include/functions.php b/admin/include/functions.php
index 54aa938f0..203ef37cf 100644
--- a/admin/include/functions.php
+++ b/admin/include/functions.php
@@ -555,164 +555,6 @@ function display_categories( $categories, $indent,
}
/**
- * Complete plain structure of the gallery
- *
- * Returns the plain structure (one level array) of the gallery. In the
- * returned array, each element is an array with jeys 'id' and
- * 'id_uppercat'. The function also fills the array $page['subcats'] which
- * associate (category_id => array of sub-categories id).
- *
- * @param bool $use_name
- * @return array
- */
-function get_plain_structure( $use_name = false )
-{
- global $page;
-
- $plain_structure = array();
-
- $query = 'SELECT id,id_uppercat';
- if ( $use_name ) $query.= ',name';
- $query.= ' FROM '.CATEGORIES_TABLE;
- $query.= ' ORDER BY id_uppercat ASC, rank ASC';
- $query.= ';';
-
- $subcats = array();
- $id_uppercat = 'NULL';
-
- $result = mysql_query( $query );
- while ( $row = mysql_fetch_array( $result ) )
- {
- $plain_structure[$row['id']]['id'] = $row['id'];
- if ( !isset( $row['id_uppercat'] ) ) $row['id_uppercat'] = 'NULL';
- $plain_structure[$row['id']]['id_uppercat'] = $row['id_uppercat'];
- if ( $use_name ) $plain_structure[$row['id']]['name'] = $row['name'];
- // subcats list
- if ( $row['id_uppercat'] != $id_uppercat )
- {
- $page['subcats'][$id_uppercat] = $subcats;
-
- $subcats = array();
- $id_uppercat = $row['id_uppercat'];
- }
- array_push( $subcats, $row['id'] );
- }
- mysql_free_result( $result );
-
- $page['subcats'][$id_uppercat] = $subcats;
-
- return $plain_structure;
-}
-
-/**
- * get N levels array representing structure under the given category
- *
- * create_structure returns the N levels array representing structure under
- * the given gategory id. It also updates the
- * $page['plain_structure'][id]['all_subcats_id'] and
- * $page['plain_structure'][id]['direct_subcats_ids'] for each sub category.
- *
- * @param int $id_uppercat
- * @return array
- */
-function create_structure( $id_uppercat )
-{
- global $page;
-
- $structure = array();
- $ids = get_subcats_ids( $id_uppercat );
- foreach ( $ids as $id ) {
- $category = $page['plain_structure'][$id];
-
- $category['subcats'] = create_structure( $id );
-
- $page['plain_structure'][$id]['all_subcats_ids'] =
- get_all_subcats_ids( $id );
-
- $page['plain_structure'][$id]['direct_subcats_ids'] =
- get_subcats_ids( $id );
-
- array_push( $structure, $category );
- }
- return $structure;
-}
-
-/**
- * returns direct sub-categories ids
- *
- * Returns an array containing all the direct sub-categories ids of the
- * given category. It uses the $page['subcats'] global array.
- *
- * @param int $id_uppercat
- * @return array
- */
-function get_subcats_ids( $id_uppercat )
-{
- global $page;
-
- if ( $id_uppercat == '' ) $id_uppercat = 'NULL';
-
- if ( isset( $page['subcats'][$id_uppercat] ) )
- return $page['subcats'][$id_uppercat];
- else
- return array();
-}
-
-/**
- * returns all sub-categories ids, not only direct ones
- *
- * Returns an array containing all the sub-categories ids of the given
- * category, not only direct ones. This function is recursive.
- *
- * @param int $category_id
- * @return array
- */
-function get_all_subcats_ids( $category_id )
-{
- $ids = array();
-
- $subcats = get_subcats_ids( $category_id );
- $ids = array_merge( $ids, $subcats );
- foreach ( $subcats as $subcat ) {
- // recursive call
- $sub_subcats = get_all_subcats_ids( $subcat );
- $ids = array_merge( $ids, $sub_subcats );
- }
- return array_unique( $ids );
-}
-
-/**
- * updates the column categories.uppercats
- *
- * @param int $category_id
- * @return void
- */
-function update_uppercats( $category_id )
-{
- global $page;
-
- $final_id = $category_id;
- $uppercats = array();
-
- array_push( $uppercats, $category_id );
- $uppercat = $page['plain_structure'][$category_id]['id_uppercat'];
-
- while ( $uppercat != 'NULL' )
- {
- array_push( $uppercats, $uppercat );
- $category_id = $page['plain_structure'][$category_id]['id_uppercat'];
- $uppercat = $page['plain_structure'][$category_id]['id_uppercat'];
- }
-
- $string_uppercats = implode( ',', array_reverse( $uppercats ) );
- $query = 'UPDATE '.CATEGORIES_TABLE;
- $query.= ' SET uppercats = '."'".$string_uppercats."'";
- $query.= ' WHERE id = '.$final_id;
- $query.= ';';
- mysql_query( $query );
-}
-
-/**
* returns an array with the ids of the restricted categories for the user
*
* Returns an array with the ids of the restricted categories for the
diff --git a/admin/infos_images.php b/admin/infos_images.php
index c0da67aa3..0cbfb54eb 100644
--- a/admin/infos_images.php
+++ b/admin/infos_images.php
@@ -25,8 +25,11 @@
// | USA. |
// +-----------------------------------------------------------------------+
-include_once( './admin/include/isadmin.inc.php' );
-include_once( './template/'.$user['template'].'/htmlfunctions.inc.php' );
+if( !defined("PHPWG_ROOT_PATH") )
+{
+ die ("Hacking attempt!");
+}
+include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
//-------------------------------------------------------------- initialization
$page['nb_image_page'] = 5;
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 8e09f24db..c15149e20 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -413,7 +413,7 @@ function notify( $type, $infos = '' )
while ( $row = mysql_fetch_array( $result ) )
{
$to = $row['mail_address'];
- include( PHPWG_ROOT_PATH.'language/'.$row['language'].'.php' );
+ include( PHPWG_ROOT_PATH.'language/'.$row['language'].'/common.lang.php' );
$content = $lang['mail_hello']."\n\n";
switch ( $type )
{
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 8ff06ede7..1b075f70a 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -607,7 +607,7 @@ SELECT COUNT(DISTINCT(id)) AS nb_total_images
// pictures within the short period
else if ( $page['cat'] == 'recent_pics' )
{
- $page['title'] = $lang['recent_pics_cat_title'];
+ $page['title'] = $lang['recent_pics_cat'];
// We must find the date corresponding to :
// today - $conf['periode_courte']
$date = time() - 60*60*24*$user['recent_period'];
@@ -625,7 +625,7 @@ SELECT COUNT(DISTINCT(id)) AS nb_total_images
// categories containing recent pictures
else if ( $page['cat'] == 'recent_cats' )
{
- $page['title'] = $lang['recent_cats_cat_title'];
+ $page['title'] = $lang['recent_cats_cat'];
$page['cat_nb_images'] = 0;
}
// most visited pictures
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 7fe37a42e..015eef155 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -251,7 +251,7 @@ function get_html_menu_category($category)
<ul class="menu">';
foreach ($category['subcats'] as $subcat)
{
- $menu.= get_html_menu_category($subcat, &$menu);
+ $menu.= get_html_menu_category($subcat);
}
$menu.= '
</ul>';
diff --git a/language/en_UK.iso-8859-1/common.lang.php b/language/en_UK.iso-8859-1/common.lang.php
index c1490b041..81c046818 100644
--- a/language/en_UK.iso-8859-1/common.lang.php
+++ b/language/en_UK.iso-8859-1/common.lang.php
@@ -63,6 +63,9 @@ $lang['new'] = 'New';
$lang['identification'] = 'Identification';
//Calendar
+$lang['calendar'] = 'calendar';
+$lang['calendar_hint'] = 'displays each day with pictures, month per month';
+$lang['calendar_picture_hint'] = 'displays pictures added on ';
$lang['month'][1] = 'January';
$lang['month'][2] = 'February';
$lang['month'][3] = 'March';
@@ -207,12 +210,10 @@ $lang['most_visited_cat_hint'] = 'displays most visited pictures';
$lang['most_visited_cat'] = 'most visited';
$lang['best_rated_cat_hint'] = 'displays pictures best rated';
$lang['best_rated_cat'] = 'best rated';
-$lang['recent_pics_cat_hint'] = 'displays most recent pictures';
-$lang['recent_pics_cat'] = 'recent pictures';
-$lang['recent_pics_cat_title'] = 'Recent pictures';
-$lang['recent_cats_cat_hint'] = 'displays recently updated categories';
-$lang['recent_cats_cat'] = 'updated categories';
-$lang['recent_cats_cat_title'] = 'Recently updated categories';
+$lang['recent_pics_cat_hint'] = 'Displays most recent pictures';
+$lang['recent_pics_cat'] = 'Last pictures';
+$lang['recent_cats_cat_hint'] = 'Displays recently updated categories';
+$lang['recent_cats_cat'] = 'Last categories';
$lang['visited'] = 'visited';
$lang['times'] = 'times';
$lang['customize_theme'] = 'interface theme';
@@ -255,9 +256,6 @@ $lang['hint_comments'] = 'See last users comments';
$lang['menu_login'] = 'login';
$lang['update_wrong_dirname'] = 'The name of directories and files must be composed of letters, figures, "-", "_" or "."';
$lang['hello'] = 'Hello';
-$lang['calendar'] = 'calendar';
-$lang['calendar_hint'] = 'displays each day with pictures, month per month';
-$lang['calendar_picture_hint'] = 'displays pictures added on ';
// search
$lang['search_wrong_date'] = ' : this date is not valid';
diff --git a/picture.php b/picture.php
index 78c80d884..891510b9f 100644
--- a/picture.php
+++ b/picture.php
@@ -723,7 +723,7 @@ if ( !$user['is_the_guest'] )
$url.='&amp;add_fav=1';
if ( $page['cat'] == 'search' )
{
- $url.= '&amp;search='.$_GET['search'].'&amp;mode='.$_GET['mode'];
+ $url.= '&amp;search='.$_GET['search'];
}
$template->assign_block_vars('favorite', array(
'FAVORITE_IMG' => PHPWG_ROOT_PATH.'template/'.$user['template'].'/theme/favorite.gif',