From: Daniel Hromada Date: Tue, 15 Mar 2011 22:41:51 +0000 (+0100) Subject: permissions moved to backend X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=bde5bc7a912775cd1c3da7f095980944afe70522;p=mirrors%2FKyberia-bloodline.git permissions moved to backend --- diff --git a/wwwroot/backend/mysql/permissions.inc b/wwwroot/backend/mysql/permissions.inc new file mode 100644 index 0000000..78e8556 --- /dev/null +++ b/wwwroot/backend/mysql/permissions.inc @@ -0,0 +1,125 @@ +query($q_np); + + while ($qr_np->next()) { + // nastavim si prava hlavnej zvolenej nody + if ($perms['node_permission'] == '' && $perms['node_system_access'] == '') { + + $perms['node_permission'] = $qr_np->getString('node_permission'); + $perms['node_system_access'] = $qr_np->getString('node_system_access'); + $perms['node_external_access'] = $qr_np->getString('node_external_access'); + + // r/w prava podla system accessu + if ($perms['node_system_access'] == 'public') { + $perms['r'] = 1; + $perms['w'] = 1; + } + elseif ($perms['node_system_access'] == 'moderated') { + $perms['r'] = 1; + $perms['w'] = 0; + } + elseif ($perms['node_system_access'] == 'private') { + $perms['r'] = 0; + $perms['w'] = 0; + } + + if ($qr_np->getInt('node_creator') == $user_id) { + $perms['node_permission'] = 'owner'; + $perms['r'] = 1; + $perms['w'] = 1; + break; + } + + if ($perms['node_system_access'] != 'private' + && !$_SESSION['user_id'] + && $perms['node_external_access'] == 'yes') { + $perms['r'] = 1; + $perms['w'] = 0; + break; + } + + } // if ($perms['node_permission'] == '' && $perms['node_system_access'] == '') + else { + // ked som v public alebo moderated fore a dalsie nadradene su uz privatne + if ($node_system_access != 'private' && $qr_np->getString('node_system_access') == 'private') + break; + // ked som v privatnom fore a dalsie nadradene su public alebo moderated + if ($node_system_access == 'private' && $qr_np->getString('node_system_access') != 'private') + break; + } + + $node_permission = $qr_np->getString('node_permission'); + $node_system_access = $qr_np->getString('node_system_access'); + + // nastavim r/w podla permissions a skoncim to + if ($node_permission == 'ban') { + $perms['r'] = 0; + $perms['w'] = 0; + break; + } + elseif ($node_permission == 'silence') { + $perms['r'] = 1; + $perms['w'] = 0; + break; + } + elseif ($node_permission == 'op') { + $perms['r'] = 1; + $perms['w'] = 1; + break; + } + elseif ($node_permission == 'master') { + $perms['r'] = 1; + $perms['w'] = 1; + break; + } + elseif ($node_permission == 'access') { + $perms['r'] = 1; + $perms['w'] = 1; + break; + } + + if ($qr_np->getInt('node_creator') == $user_id) { + $perms['node_permission'] = 'owner'; + $perms['r'] = 1; + $perms['w'] = 1; + break; + } + + } + return $perms; + } + +} + +?> \ No newline at end of file