o Proposition: improved display of 'x images in y sub-categories' or 'x images in this category' for cases when categories contain both images and sub-categories
o Good idea of this new way for way conf['guest_access'], but I kept last implementation for access methods (Could be useful on future development) git-svn-id: http://piwigo.org/svn/trunk@1851 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
20ba76b753
commit
6f03e29735
10 changed files with 65 additions and 25 deletions
|
@ -29,6 +29,11 @@
|
|||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Check Access and exit when user status is not ok |
|
||||
// +-----------------------------------------------------------------------+
|
||||
check_status(ACCESS_NONE);
|
||||
|
||||
//-------------------------------------------------------------- identification
|
||||
$errors = array();
|
||||
|
||||
|
|
|
@ -214,7 +214,9 @@ if (count($categories) > 0)
|
|||
(
|
||||
$category['nb_images'],
|
||||
$category['count_images'],
|
||||
$category['count_categories']
|
||||
$category['count_categories'],
|
||||
true,
|
||||
'<BR>'
|
||||
),
|
||||
'DESCRIPTION' => @$comment,
|
||||
'NAME' => $name,
|
||||
|
@ -249,7 +251,9 @@ if (count($categories) > 0)
|
|||
(
|
||||
$category['nb_images'],
|
||||
$category['count_images'],
|
||||
$category['count_categories']
|
||||
$category['count_categories'],
|
||||
true,
|
||||
'<BR>'
|
||||
),
|
||||
|
||||
'U_IMG_LINK' => make_index_url(
|
||||
|
|
|
@ -386,16 +386,25 @@ function rank_compare($a, $b)
|
|||
* @param array categories
|
||||
* @return string
|
||||
*/
|
||||
function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_categories, $short_message = true)
|
||||
function get_display_images_count($cat_nb_images, $cat_count_images, $cat_count_categories, $short_message = true, $Separator = '\n')
|
||||
{
|
||||
$display_text = '';
|
||||
|
||||
if ($cat_count_images>0)
|
||||
{//at least one image direct or indirect
|
||||
if ($cat_count_images > 0)
|
||||
{
|
||||
if ($cat_nb_images > 0 and $cat_nb_images < $cat_count_images)
|
||||
{
|
||||
$display_text.= get_display_images_count($cat_nb_images, $cat_nb_images, 0, $short_message, $Separator).$Separator;
|
||||
$cat_count_images-= $cat_nb_images;
|
||||
$cat_nb_images = 0;
|
||||
}
|
||||
|
||||
//at least one image direct or indirect
|
||||
$display_text.= l10n_dec('image_available', 'images_available', $cat_count_images);
|
||||
|
||||
if ($cat_count_categories==0 or $cat_nb_images>=$cat_count_images)
|
||||
{//no descendant categories or descendants do not contain images
|
||||
if ($cat_count_categories == 0 or $cat_nb_images == $cat_count_images)
|
||||
{
|
||||
//no descendant categories or descendants do not contain images
|
||||
if (! $short_message)
|
||||
{
|
||||
$display_text.= ' '.l10n('images_available_cpl');
|
||||
|
|
|
@ -470,7 +470,8 @@ function get_html_menu_category($categories)
|
|||
$category['nb_images'],
|
||||
$category['count_images'],
|
||||
$category['count_categories'],
|
||||
false
|
||||
false,
|
||||
' / '
|
||||
).'">';
|
||||
// show total number of images
|
||||
$menu.= '['.$category['count_images'].']';
|
||||
|
|
|
@ -435,7 +435,7 @@ SELECT cat_id
|
|||
$forbidden_array = array_diff($private_array, $authorized_array);
|
||||
|
||||
// if user is not an admin, locked categories are forbidden
|
||||
if ( $user_status!='administrator' and $user_status!='webmaster' )
|
||||
if (!is_admin($user_status))
|
||||
{
|
||||
$query = '
|
||||
SELECT id
|
||||
|
@ -981,7 +981,7 @@ SELECT '.$conf['user_fields']['id'].' AS id,
|
|||
*/
|
||||
function get_access_type_status($user_status='')
|
||||
{
|
||||
global $user;
|
||||
global $user, $conf;
|
||||
|
||||
if ($user_status == '' and isset($user['status']) )
|
||||
{
|
||||
|
@ -992,6 +992,21 @@ function get_access_type_status($user_status='')
|
|||
switch ($user_status)
|
||||
{
|
||||
case 'guest':
|
||||
{
|
||||
if
|
||||
(
|
||||
!isset($user) or
|
||||
($user['id']==$conf['guest_id'] and !$conf['guest_access'])
|
||||
)
|
||||
{
|
||||
$access_type_status = ACCESS_NONE;
|
||||
}
|
||||
else
|
||||
{
|
||||
$access_type_status = ACCESS_GUEST;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'generic':
|
||||
{
|
||||
$access_type_status = ACCESS_GUEST;
|
||||
|
@ -1022,18 +1037,9 @@ function get_access_type_status($user_status='')
|
|||
* Test does with user status
|
||||
* @return bool
|
||||
*/
|
||||
function is_autorize_status($access_type)
|
||||
function is_autorize_status($access_type, $user_status = '')
|
||||
{
|
||||
global $user, $conf;
|
||||
if (
|
||||
!isset($user) or
|
||||
($user['id']==$conf['guest_id'] and $conf['guest_access']==false)
|
||||
)
|
||||
{
|
||||
return ACCESS_NONE>=$access_type;
|
||||
}
|
||||
|
||||
return (get_access_type_status() >= $access_type);
|
||||
return (get_access_type_status($user_status) >= $access_type);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1042,9 +1048,9 @@ function is_autorize_status($access_type)
|
|||
* Test does with user status
|
||||
* @return none
|
||||
*/
|
||||
function check_status( $access_type )
|
||||
function check_status($access_type, $user_status = '')
|
||||
{
|
||||
if (!is_autorize_status($access_type) )
|
||||
if (!is_autorize_status($access_type, $user_status))
|
||||
{
|
||||
access_denied();
|
||||
}
|
||||
|
@ -1054,9 +1060,9 @@ function check_status( $access_type )
|
|||
* Return if user is an administrator
|
||||
* @return bool
|
||||
*/
|
||||
function is_admin()
|
||||
function is_admin($user_status = '')
|
||||
{
|
||||
return is_autorize_status(ACCESS_ADMINISTRATOR);
|
||||
return is_autorize_status(ACCESS_ADMINISTRATOR, $user_status);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
2
nbm.php
2
nbm.php
|
@ -27,8 +27,10 @@
|
|||
// +-----------------------------------------------------------------------+
|
||||
|
||||
|
||||
//--------------------------------------------------------------------- include
|
||||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||
check_status(ACCESS_NONE);
|
||||
include_once(PHPWG_ROOT_PATH.'include/functions_notification.inc.php');
|
||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||
include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
|
||||
|
|
|
@ -33,6 +33,11 @@ define('PHPWG_ROOT_PATH','./');
|
|||
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
||||
include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Check Access and exit when user status is not ok |
|
||||
// +-----------------------------------------------------------------------+
|
||||
check_status(ACCESS_NONE);
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | send a new password |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
|
|
@ -28,6 +28,12 @@
|
|||
//----------------------------------------------------------- include
|
||||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
||||
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | Check Access and exit when user status is not ok |
|
||||
// +-----------------------------------------------------------------------+
|
||||
check_status(ACCESS_NONE);
|
||||
|
||||
//----------------------------------------------------------- user registration
|
||||
|
||||
if (!$conf['allow_user_registration'])
|
||||
|
|
|
@ -43,6 +43,7 @@ function inc_exc_str($is_included)
|
|||
|
||||
define('PHPWG_ROOT_PATH','./');
|
||||
include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
|
||||
check_status(ACCESS_NONE);
|
||||
include_once( PHPWG_ROOT_PATH.'include/functions_search.inc.php' );
|
||||
|
||||
$page['body_id'] = 'thePopuphelpPage';
|
||||
|
|
1
ws.php
1
ws.php
|
@ -26,6 +26,7 @@
|
|||
define ('PHPWG_ROOT_PATH', './');
|
||||
|
||||
include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
|
||||
check_status(ACCESS_NONE);
|
||||
include_once(PHPWG_ROOT_PATH.'include/ws_core.inc.php');
|
||||
|
||||
if ( !$conf['allow_web_services'] )
|
||||
|
|
Loading…
Add table
Reference in a new issue