mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-21 09:03:38 +02:00
- in picture.php, $user['maxwidth'] and $user['maxheight'] can be unset if
NULL in database
- new table user_forbidden {user_id,need_update,forbidden_categories} and
deletion of field users.forbidden_categories
- new function calculate_permissions to update table user_forbidden when
needed
- simplification of include/user.inc.php
- in footer of each page, use "-" instead of "::" to separate page
information
git-svn-id: http://piwigo.org/svn/trunk@648 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
+42
-31
@@ -25,19 +25,7 @@
|
||||
// | USA. |
|
||||
// +-----------------------------------------------------------------------+
|
||||
|
||||
// retrieving user informations
|
||||
// $infos array is used to know the fields to retrieve in the table "users"
|
||||
// Each field becomes an information of the array $user.
|
||||
// Example :
|
||||
// status --> $user['status']
|
||||
$infos = array('id','username','mail_address','nb_image_line','nb_line_page',
|
||||
'status','language','maxwidth','maxheight','expand',
|
||||
'show_nb_comments','recent_period','template',
|
||||
'forbidden_categories');
|
||||
|
||||
$query_user = 'SELECT * FROM '.USERS_TABLE;
|
||||
$query_done = false;
|
||||
$user['is_the_guest'] = false;
|
||||
// retrieving connected user informations
|
||||
|
||||
if (isset($_COOKIE['id']))
|
||||
{
|
||||
@@ -79,37 +67,59 @@ DELETE FROM '.SESSIONS_TABLE.'
|
||||
}
|
||||
else
|
||||
{
|
||||
$query_user .= ' WHERE id = '.$row['user_id'];
|
||||
$query_done = true;
|
||||
$user['id'] = $row['user_id'];
|
||||
$user['is_the_guest'] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$query_done)
|
||||
if (!isset($user['id']))
|
||||
{
|
||||
$query_user .= ' WHERE id = 2';
|
||||
$user['id'] = 2;
|
||||
$user['is_the_guest'] = true;
|
||||
}
|
||||
$query_user .= ';';
|
||||
$row = mysql_fetch_array(pwg_query($query_user));
|
||||
|
||||
// affectation of each value retrieved in the users table into a variable
|
||||
// of the array $user.
|
||||
foreach ($infos as $info) {
|
||||
if (isset($row[$info]))
|
||||
$query = '
|
||||
SELECT u.*, uf.*
|
||||
FROM '.USERS_TABLE.' AS u LEFT JOIN '.USER_FORBIDDEN_TABLE.' AS uf
|
||||
ON id = user_id
|
||||
WHERE u.id = '.$user['id'].'
|
||||
;';
|
||||
$row = mysql_fetch_array(pwg_query($query));
|
||||
|
||||
// affectation of each value retrieved in the users table into a variable of
|
||||
// the array $user.
|
||||
foreach ($row as $key => $value)
|
||||
{
|
||||
if (!is_numeric($key))
|
||||
{
|
||||
// If the field is true or false, the variable is transformed into a
|
||||
// boolean value.
|
||||
if ($row[$info] == 'true' or $row[$info] == 'false')
|
||||
$user[$info] = get_boolean($row[$info]);
|
||||
if ($value == 'true' or $value == 'false')
|
||||
{
|
||||
$user[$key] = get_boolean($value);
|
||||
}
|
||||
else
|
||||
$user[$info] = $row[$info];
|
||||
}
|
||||
else
|
||||
{
|
||||
$user[$info] = '';
|
||||
{
|
||||
$user[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if no information were found about user in user_forbidden table OR the
|
||||
// forbidden categories must be updated
|
||||
if (!isset($user['need_update'])
|
||||
or !is_bool($user['need_update'])
|
||||
or $user['need_update'] == true)
|
||||
{
|
||||
$user['forbidden_categories'] = calculate_permissions($user['id']);
|
||||
}
|
||||
|
||||
// forbidden_categories is a must be empty, at least
|
||||
if (!isset($user['forbidden_categories']))
|
||||
{
|
||||
$user['forbidden_categories'] = '';
|
||||
}
|
||||
|
||||
// special for $user['restrictions'] array
|
||||
$user['restrictions'] = explode(',', $user['forbidden_categories']);
|
||||
if ($user['restrictions'][0] == '')
|
||||
@@ -120,9 +130,10 @@ if ($user['restrictions'][0] == '')
|
||||
$isadmin = false;
|
||||
if ($user['status'] == 'admin')
|
||||
{
|
||||
$isadmin =true;
|
||||
$isadmin = true;
|
||||
}
|
||||
// calculation of the number of picture to display per page
|
||||
$user['nb_image_page'] = $user['nb_image_line'] * $user['nb_line_page'];
|
||||
|
||||
init_userprefs($user);
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user