aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/constants.php3
-rw-r--r--include/functions_category.inc.php55
-rw-r--r--include/functions_user.inc.php6
-rw-r--r--include/menubar.inc.php8
-rw-r--r--include/upload.class.php41
5 files changed, 103 insertions, 10 deletions
diff --git a/include/constants.php b/include/constants.php
index 814d18f3e..6b05d683a 100644
--- a/include/constants.php
+++ b/include/constants.php
@@ -36,11 +36,12 @@ define('CRITICAL_MESSAGE', 203);
define('CRITICAL_ERROR', 204);
// Access codes
-define('ACCESS_NONE', 0);
+define('ACCESS_FREE', 0);
define('ACCESS_GUEST', 1);
define('ACCESS_CLASSIC', 2);
define('ACCESS_ADMINISTRATOR', 3);
define('ACCESS_WEBMASTER', 4);
+define('ACCESS_CLOSED', 5);
// Table names
if (!defined('CATEGORIES_TABLE'))
diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php
index 2adbb200a..94b2411d2 100644
--- a/include/functions_category.inc.php
+++ b/include/functions_category.inc.php
@@ -452,4 +452,59 @@ function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_
return $display_text;
}
+/**
+ * returns the link of upload menu
+ *
+ * @param null
+ * @return string or null
+ */
+function get_upload_menu_link()
+{
+ global $conf, $page, $user;
+
+ $show_link = false;
+ $arg_link = null;
+
+ if (is_autorize_status($conf['upload_user_access']))
+ {
+ if (isset($page['category']) and $page['category']['uploadable'] )
+ {
+ // upload a picture in the category
+ $show_link = true;
+ $arg_link = 'cat='.$page['category']['id'];
+ }
+ else
+ if ($conf['upload_link_everytime'])
+ {
+ // upload a picture in the category
+ $query = '
+SELECT
+ 1
+FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.'
+ ON id = cat_id and user_id = '.$user['id'].'
+WHERE
+ uploadable = \'true\'
+ '.get_sql_condition_FandF
+ (
+ array
+ (
+ 'visible_categories' => 'id',
+ ),
+ 'AND'
+ ).'
+LIMIT 1';
+
+ $show_link = mysql_num_rows(pwg_query($query)) <> 0;
+ }
+ }
+ if ($show_link)
+ {
+ return get_root_url().'upload.php'.(empty($arg_link) ? '' : '?'.$arg_link);
+ }
+ else
+ {
+ return;
+ }
+}
+
?>
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 6630e2dae..d2c9530e2 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -1088,7 +1088,7 @@ function get_user_status($user_status)
}
/*
- * Return access_type definition of uuser
+ * Return access_type definition of user
* Test does with user status
* @return bool
*/
@@ -1101,7 +1101,7 @@ function get_access_type_status($user_status='')
case 'guest':
{
$access_type_status =
- ($conf['guest_access'] ? ACCESS_GUEST : ACCESS_NONE);
+ ($conf['guest_access'] ? ACCESS_GUEST : ACCESS_FREE);
break;
}
case 'generic':
@@ -1126,7 +1126,7 @@ function get_access_type_status($user_status='')
}
default:
{
- $access_type_status = ACCESS_NONE;
+ $access_type_status = ACCESS_FREE;
break;
}
}
diff --git a/include/menubar.inc.php b/include/menubar.inc.php
index 4f7b5fe61..03e941226 100644
--- a/include/menubar.inc.php
+++ b/include/menubar.inc.php
@@ -39,6 +39,7 @@ $template->assign(
'MENU_CATEGORIES_CONTENT' => get_categories_menu(),
'U_CATEGORIES' => make_index_url(array('section' => 'categories')),
'U_LOST_PASSWORD' => get_root_url().'password.php',
+ 'U_UPLOAD' => get_upload_menu_link()
)
);
@@ -304,12 +305,7 @@ $template->append(
)
);
-if (isset($page['category']) and $page['category']['uploadable'] )
-{ // upload a picture in the category
- $url = get_root_url().'upload.php?cat='.$page['category']['id'];
- $template->assign('U_UPLOAD', $url);
-}
-
trigger_action('loc_end_menubar');
$template->assign_var_from_handle('MENUBAR', 'menubar');
+
?>
diff --git a/include/upload.class.php b/include/upload.class.php
new file mode 100644
index 000000000..f9587ddb8
--- /dev/null
+++ b/include/upload.class.php
@@ -0,0 +1,41 @@
+<?php
+// +-----------------------------------------------------------------------+
+// | Piwigo - a PHP based picture gallery |
+// +-----------------------------------------------------------------------+
+// | Copyright(C) 2008 Piwigo Team http://piwigo.org |
+// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
+// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
+// +-----------------------------------------------------------------------+
+// | This program 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 |
+// | |
+// | This program 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 this program; if not, write to the Free Software |
+// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
+// | USA. |
+// +-----------------------------------------------------------------------+
+
+class Upload
+{
+ function Upload()
+ {
+ }
+
+ /**
+ * Return list of Uploadable categories
+ *
+ * @param void
+ * @return array
+ */
+ function get_cat()
+ {
+ }
+}
+
+?>