---------------------------------------------------------------------- AlternC - Web Hosting System Copyright (C) 2002 by the AlternC Development Team. http://alternc.org/ ---------------------------------------------------------------------- Based on: Valentin Lacambre's web hosting softwares: http://altern.org/ ---------------------------------------------------------------------- LICENSE This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. To read the license please visit http://www.gnu.org/copyleft/gpl.html ---------------------------------------------------------------------- Purpose of file: listing of piwik site, and manage associated credentials ---------------------------------------------------------------------- */ require_once("../class/config.php"); include_once("head.php"); include_once("piwik_utils.php"); $fields = array ( "site_id" => array ("request", "integer", -1), // alternc ID of the piwik site "right" => array ("post", "array", FALSE), // array of rights associated foreach user of $site_id ); getFields($fields); /* Get once alternc users and sites */ $piwik_alternc_users = $piwik->get_alternc_users(); $piwik_alternc_sites = $piwik->get_alternc_sites(); /* Form was submitted, need to deal with work to do. */ if ($right !== FALSE) { // Should this stay here, or in the API? if (!in_array($site_id, $piwik_alternc_sites)) $error = _("You don't own this piwik site!"); else { /* Foreach row of right, extract user, and selected credential */ foreach ($right AS $user => $cred) { /* Ensures that the user is legitimate for that user */ /* If not, we just break the loop, and set error message */ if (!in_array($user, $piwik_alternc_users)) { $error = sprintf('%s "%s"', _('You dont own user'), $user); break; } /* Ok, current user has right to manage this piwik user. Update rights. */ printf ("%s -> %s
\n", $user, $cred); if (!$piwik->site_set_user_right($site_id, $user, $cred)) { $error = $err->errstr(); break; } } } } /* If something went wrong, display error message, but continue with the page rendering */ if (isset($error) && $error) { echo "

$error

"; } /* Does current user still has quota ? */ if ($quota->cancreate("piwik")) { $quotapiwik=$quota->getquota('piwik'); /* If quota are still available, display form to let user add a new site */ if ($quotapiwik['u']>0) { ?>

"/> " />


0 } // cancreate piwik /* In that part, we'll manage the rights associated to a selected piwik site. */ /* The output is the following: */ /* [ site [v]] */ /* - user1 no access () view () admin () */ /* - user2 no access () view () admin () */ /* [ submit ] */ ?>

site_list(); /* If user didn't add a website, just do nothing but display there's no site */ if (empty($sitelist)){ __("No existing Piwik websites"); } else { /* Otherwize, display the html form, [ sitename, url, javascript code ] */ ?>
Javascript Code
name ?> main_url ?>

 
'; echo '
'; foreach ($piwik->get_users_access_from_site($site_id) AS $piwik_user => $cred) { printf("
%s:
\n\t
%s
\n", $piwik_user, piwik_right_widget('right', $piwik_user, $cred)); } echo '
'; echo ''; echo ''; } } // empty userlist ?>