git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-571
require 'xnet.inc.php';
-new_skinned_page('xnet/groupe/asso.tpl', AUTH_PUBLIC);
+new_page('xnet/groupe/asso.tpl', AUTH);
if (!$globals->asso('id')) {
header("Location: ../");
}
if (!Env::has('liste')) header('Location: listes.php');
$liste = strtolower(Env::get('liste'));
-new_skinned_page('listes/admin.tpl', AUTH_MDP);
+new_page('listes/admin.tpl', AUTH_MDP);
$page->setType($globals->asso('cat'));
$page->useMenu();
***************************************************************************/
require_once 'xnet.inc.php';
-if (!Env::has('liste')) header('Location: index.php');
+if (!Env::has('liste')) header('Location: listes.php');
$liste = strtolower(Env::get('liste'));
-new_skinned_page('listes/archives.tpl', AUTH_COOKIE);
+new_page('listes/archives.tpl');
$page->setType($globals->asso('cat'));
$page->useMenu();
if (!Env::has('liste')) header('Location: listes.php');
$liste = strtolower(Env::get('liste'));
-new_skinned_page('listes/delete.tpl', AUTH_MDP);
+new_page('listes/delete.tpl', AUTH_MDP);
$page->setType($globals->asso('cat'));
$page->useMenu();
if (!Env::has('liste')) header('Location: listes.php');
$liste = strtolower(Env::get('liste'));
-new_skinned_page('listes/members.tpl', AUTH_MDP);
+new_page('listes/members.tpl', AUTH_MDP);
$page->setType($globals->asso('cat'));
$page->useMenu();
header("Location: {$_SERVER['PHP_SELF']}?liste={$matches[1]}");
}
-new_skinned_page('listes/moderate.tpl', AUTH_MDP);
+new_page('listes/moderate.tpl', AUTH_MDP);
$page->setType($globals->asso('cat'));
$page->useMenu();
if (!Env::has('liste')) header('Location: listes.php');
$liste = strtolower(Env::get('liste'));
-new_skinned_page('listes/options.tpl', AUTH_MDP);
+new_page('listes/options.tpl', AUTH_MDP);
$page->setType($globals->asso('cat'));
$page->useMenu();
XnetGlobals::init();
XnetSession::init();
-// {{{ function _new_page()
+// {{{ function new_skinned_page()
-function _new_page($type, $tpl_name, $min_auth, $admin=false)
+function new_page($tpl_name, $min_auth)
{
global $page,$globals;
require_once("xnet/page.inc.php");
- if (!empty($admin)) {
- $page = new XnetAdmin($tpl_name, $type);
- } else switch($min_auth) {
+ switch($min_auth) {
case AUTH_PUBLIC:
$page = new XnetPage($tpl_name, $type);
break;
- case AUTH_MDP:
+ default:
$page = new XnetAuth($tpl_name, $type);
}
+ $page->assign('xorg_tpl', $tpl_name);
+}
+
+// }}}
+// {{{ function new_group_page()
+function new_group_page($tpl_name)
+{
+ global $page,$globals;
+ require_once("xnet/page.inc.php");
+ $page = new XnetGroupPage($tpl_name);
$page->assign('xorg_tpl', $tpl_name);
}
// }}}
-// {{{ function new_skinned_page()
+// {{{ function new_groupadmin_page()
-function new_skinned_page($tpl_name, $min_auth)
+function new_groupadmin_page($tpl_name)
{
- _new_page(SKINNED, $tpl_name, $min_auth);
+ global $page,$globals;
+ require_once("xnet/page.inc.php");
+ $page = new XnetGroupAdmin($tpl_name);
+ $page->assign('xorg_tpl', $tpl_name);
}
// }}}
function new_admin_page($tpl_name)
{
- _new_page(SKINNED, $tpl_name, AUTH_MDP, true);
+ global $page,$globals;
+ require_once("xnet/page.inc.php");
+ $page = new XnetAdmin($tpl_name);
+ $page->assign('xorg_tpl', $tpl_name);
}
// }}}
$_SESSION['session']->doAuthX($this);
}
}
+
+ // }}}
}
// }}}
}
// }}}
+// {{{ class XnetGroupPage
+
+/** Une classe pour les pages réservées aux admins (authentifiés!).
+ */
+class XnetGroupPage extends XnetAuth
+{
+ // {{{ function XnetAdmin()
+
+ function XnetGroupPage($tpl, $type=SKINNED)
+ {
+ $this->XnetAuth($tpl, $type);
+ if (!is_member() && !has_perms()) {
+ $this->kill("You have not sufficient credentials");
+ }
+ }
+
+ // }}}
+}
+
+// }}}
+// {{{ class XnetGroupAdmin
+
+/** Une classe pour les pages réservées aux admins (authentifiés!).
+ */
+class XnetGroupAdmin extends XnetAuth
+{
+ // {{{ function XnetAdmin()
+
+ function XnetGroupAdmin($tpl, $type=SKINNED)
+ {
+ $this->XnetAuth($tpl, $type);
+ if (!may_update()) {
+ $this->kill("You have not sufficient credentials");
+ }
+ }
+
+ // }}}
+}
+
+// }}}
// {{{ class XnetAdmin
/** Une classe pour les pages réservées aux admins (authentifiés!).
}
// }}}
-
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>
}
// }}}
+// {{{ may_update
+
+function may_update() {
+ global $globals;
+ if (has_perms()) { return true; }
+ $res = $globals->xdb->query(
+ "SELECT perms
+ FROM groupex.membres
+ WHERE uid={?} AND asso_id={?}", Session::getInt('uid'), $globals->asso('id'));
+ return $res->fetchOneCell() == 'admin';
+}
+// }}}
+// {{{ is_member
+
+function is_member() {
+ global $globals;
+ $res = $globals->xdb->query(
+ "SELECT COUNT(*)
+ FROM groupex.membres
+ WHERE uid={?} AND asso_id={?}", Session::getInt('uid'), $globals->asso('id'));
+ return $res->fetchOneCell() == 1;
+}
+
+// }}}
// vim:set et sw=4 sts=4 sws=4 foldmethod=marker:
?>