aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorrub <rub@piwigo.org>2006-03-09 22:46:28 +0000
committerrub <rub@piwigo.org>2006-03-09 22:46:28 +0000
commit31d9ce16045bf58c0e83ba103c20de9f1e35439e (patch)
treee2fa2d1c95eecadcb4f9f25d64f342c0e2c7a442 /include
parent316d89a90b5cd61f41ea3f35112277608c2e2694 (diff)
Step 2 improvement issue 0000301:
o Add and use Functions Check of status o Restricted Access for user generic git-svn-id: http://piwigo.org/svn/trunk@1072 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/constants.php7
-rw-r--r--include/functions_user.inc.php65
2 files changed, 68 insertions, 4 deletions
diff --git a/include/constants.php b/include/constants.php
index 24c963d12..089e3b65d 100644
--- a/include/constants.php
+++ b/include/constants.php
@@ -37,6 +37,13 @@ define('GENERAL_ERROR', 202);
define('CRITICAL_MESSAGE', 203);
define('CRITICAL_ERROR', 204);
+// Access codes
+define('ACCESS_NONE', 0);
+define('ACCESS_GUEST', 1);
+define('ACCESS_CLASSIC', 2);
+define('ACCESS_ADMINISTRATOR', 3);
+define('ACCESS_WEBMASTER', 4);
+
// Table names
define('CATEGORIES_TABLE', $prefixeTable.'categories');
define('COMMENTS_TABLE', $prefixeTable.'comments');
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 64b12dfab..aa60ab64c 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -537,14 +537,71 @@ function log_user($user_id, $remember_me)
}
/*
- * Return if current is an administrator
+ * Return if current user have access to access_type definition
+ * Test does with user status
* @return bool
*/
-function is_admin()
+function is_autorize_status($access_type)
{
global $user;
-
- return ($user['status'] == 'webmaster' or $user['status'] == 'admin') ? true : false;
+
+ $access_type_status = ACCESS_NONE;
+ if (isset($user['status']))
+ {
+ switch ($user['status'])
+ {
+ case 'guest':
+ case 'generic':
+ {
+ $access_type_status = ACCESS_GUEST;
+ break;
+ }
+ case 'normal':
+ {
+ $access_type_status = ACCESS_CLASSIC;
+ break;
+ }
+ case 'admin':
+ {
+ $access_type_status = ACCESS_ADMINISTRATOR;
+ break;
+ }
+ case 'webmaster':
+ {
+ $access_type_status = ACCESS_WEBMASTER;
+ break;
+ }
+ }
+ }
+
+ return ($access_type_status >= $access_type);
+}
+
+/*
+ * Check if current user have access to access_type definition
+ * Stop action if there are not access
+ * Test does with user status
+ * @return none
+*/
+function check_status($access_type)
+{
+ global $lang;
+
+ if (!is_autorize_status($access_type))
+ {
+ echo '<div style="text-align:center;">'.$lang['access_forbiden'].'<br />';
+ echo '<a href="'.PHPWG_ROOT_PATH.'identification.php">'.$lang['identification'].'</a></div>';
+ exit();
+ }
+}
+
+/*
+ * Return if current user is an administrator
+ * @return bool
+*/
+function is_admin()
+{
+ return is_autorize_status(ACCESS_ADMINISTRATOR);
}
?> \ No newline at end of file