From 5436a351ef6dd685483f022af6656bbf8b797cb6 Mon Sep 17 00:00:00 2001 From: rub Date: Fri, 2 May 2008 21:56:21 +0000 Subject: Resolved issue 0000823: Enhance upload functionalities First commit, others will be follow. Not hesitate to change my translations. Add upload configuration tabsheet (move and add configuration) Change and add define for access level Can show upload link every time Can restrict access upload.class.php Can choice category on upload page Add upload class not use for the moment Review quickly and temporary style of upload.tpl git-svn-id: http://piwigo.org/svn/trunk@2325 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/constants.php | 3 ++- include/functions_category.inc.php | 55 ++++++++++++++++++++++++++++++++++++++ include/functions_user.inc.php | 6 ++--- include/menubar.inc.php | 8 ++---- include/upload.class.php | 41 ++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 10 deletions(-) create mode 100644 include/upload.class.php (limited to 'include') 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 @@ + -- cgit v1.2.3