";
if (isset($fatal) && $fatal) {
@@ -63,8 +62,10 @@ if (!$infos)
exit();
}
}
-
-printVar($infos);
+else
+{
+ printf("%s %s\n", _('Successfully added piwik user'), $account_name);
+}
include_once("foot.php");
?>
diff --git a/bureau/admin/piwik_site_dodel.php b/bureau/admin/piwik_site_dodel.php
new file mode 100644
index 00000000..716d271b
--- /dev/null
+++ b/bureau/admin/piwik_site_dodel.php
@@ -0,0 +1,77 @@
+ array ("post", "string", ""),
+ "siteid" => array ("request", "integer", -1),
+);
+getFields($fields);
+
+if ($siteid === -1) {
+ $error=_("Missing site parameters");
+ include('piwik_sitelist.php');
+ exit;
+}
+
+if(!empty($confirm_del) ) {
+
+ if (! $piwik->site_delete($siteid) ) {
+ $error=$err->errstr();
+ } else {
+ include_once('head.php');
+ __("Site supprimé avec succès\n");
+ }
+
+ include('piwik_sitelist.php');
+ exit;
+
+}
+
+include_once('head.php');
+
+?>
+
+
+
+
+
+
+
+
+
+
diff --git a/bureau/admin/piwik_sitelist.php b/bureau/admin/piwik_sitelist.php
index 480216ba..edffd772 100644
--- a/bureau/admin/piwik_sitelist.php
+++ b/bureau/admin/piwik_sitelist.php
@@ -1,6 +1,6 @@
----------------------------------------------------------------------
AlternC - Web Hosting System
Copyright (C) 2002 by the AlternC Development Team.
@@ -23,21 +23,62 @@
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
- Purpose of file: listing of mail accounts
+ 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) {
+
?>
+
+';
+ echo '
';
+ echo '';
+ echo '';
+ }
} // empty userlist
?>
-
diff --git a/bureau/admin/piwik_user_dodel.php b/bureau/admin/piwik_user_dodel.php
index dd3ec5af..65da8d74 100644
--- a/bureau/admin/piwik_user_dodel.php
+++ b/bureau/admin/piwik_user_dodel.php
@@ -23,8 +23,8 @@
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
- Original Author of file: Benjamin Sonntag
- Purpose of file: Delete ftp accounts
+ Original Author of file: François Serman
+ Purpose of file: Delete piwik accounts
----------------------------------------------------------------------
*/
require_once("../class/config.php");
@@ -36,20 +36,25 @@ $fields = array (
getFields($fields);
if (empty($login)) {
- $error=_("Missing login parameters");
- include('piwik_userlist.php');
- exit;
-
-}
+ $error=_("Missing login parameters");
+ include('piwik_userlist.php');
+ exit;
+}
-if(!empty($confirm_del) ) {
+if(!empty($confirm_del)) {
if (! $piwik->user_delete($login) ) {
$error=$err->errstr();
- include('piwik_userlist.php');
- exit;
+ } else {
+ include_once('head.php');
+ printf("Utilisateur %s supprimé avec succès\n", $login);
}
-} else {
- include_once('head.php');
+
+ include('piwik_userlist.php');
+ exit;
+}
+
+include_once('head.php');
+
?>
@@ -67,6 +72,4 @@ if(!empty($confirm_del) ) {
diff --git a/bureau/admin/piwik_useradmin.php b/bureau/admin/piwik_useradmin.php
new file mode 100644
index 00000000..d5e8f6cd
--- /dev/null
+++ b/bureau/admin/piwik_useradmin.php
@@ -0,0 +1,145 @@
+
+ ----------------------------------------------------------------------
+ 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: Admin piwik users right for piwik sites
+ ----------------------------------------------------------------------
+*/
+
+require_once("../class/config.php");
+include_once("head.php");
+
+$fields = array (
+ "user_name" => array ("request", "string", FALSE),
+ "site_id" => array ("post", "integer", -1),
+ "right" => array ("post", "string", FALSE),
+);
+getFields($fields);
+
+if ($user_name === FALSE)
+{
+ $error = _('No piwik user specified');
+}
+else
+{
+ // Add a user to a piwik website
+ if ($site_id != -1 && $right !== FALSE) {
+ $db->query("SELECT COUNT(*) AS ok FROM piwik_sites WHERE uid='$cuid' AND piwik_id='$site_id'");
+ $db->next_record();
+ if ($db->f('ok')!=1)
+ {
+ $error = _("You don't own this piwik website");
+ }
+ else
+ {
+ $db->query("SELECT COUNT(*) AS ok FROM piwik_users WHERE uid='$cuid' AND login='$user_name'");
+ $db->next_record();
+ if ($db->f('ok')!=1)
+ {
+ $error = _("You don't own this piwik user");
+ }
+ else
+ {
+ $piwik_rights = array("noaccess", "view", "admin");
+ if (in_array($right, $piwik_rights))
+ {
+ $api_data = $piwik->site_set_user_right($site_id, $user_name, $right);
+ if ($api_data === FALSE)
+ echo $error;
+ else
+ __('success');
+ }
+ else
+ {
+ $error = _("This right does not exist");
+ }
+ }
+ }
+ }
+
+ $user_piwik_sites = array();
+ $db->query("SELECT piwik_id FROM piwik_sites WHERE uid='$cuid'");
+ while ($db->next_record())
+ array_push($user_piwik_sites, $db->f('piwik_id'));
+ // Weird behaviour of php: array_push products an array such as:
+ // array_push(array(1,2,3) , 4) produces
+ // array(0 => 1, 1 => 2, 2 => 3, 3 => 4)
+ // So for further comparison, we need to exchange keys and values
+ $user_piwik_sites = array_flip($user_piwik_sites);
+
+ $user_piwik_users = array();
+ $db->query("SELECT login FROM piwik_users WHERE uid='$cuid'");
+ while ($db->next_record())
+ array_push ($user_piwik_users, $db->f('login'));
+ // Swap keys and values, see user_piwik_sites
+ $user_piwik_users = array_flip($user_piwik_users);
+}
+
+
+if (isset($error) && $error) {
+ echo "