Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattpiwik <matthieu.aubry@gmail.com>2012-09-10 11:37:01 +0400
committermattpiwik <matthieu.aubry@gmail.com>2012-09-10 11:37:01 +0400
commit840f205b3807e79804b5432a835241276d0decc0 (patch)
treeda66b0010908bfc62eec9ddddc6fb4fc44e0ee58
parent22c1119266b399b05b545d830df61400afe49095 (diff)
Fixes NOTICE when incorrect sites ids specified
git-svn-id: http://dev.piwik.org/svn/trunk@6959 59fd770c-687e-43c8-a1e3-f5a4ff64c105
-rw-r--r--core/Site.php12
-rw-r--r--plugins/CoreAdminHome/API.php3
-rw-r--r--plugins/UsersManager/API.php6
3 files changed, 15 insertions, 6 deletions
diff --git a/core/Site.php b/core/Site.php
index e6fb0ccd14..2fbf40597d 100644
--- a/core/Site.php
+++ b/core/Site.php
@@ -187,16 +187,15 @@ class Piwik_Site
/**
* Checks the given string for valid site ids and returns them as an array
*
- * @param string $string comma separated idSite list
+ * @param string $ids comma separated idSite list
* @return array of valid integer
*/
- static public function getIdSitesFromIdSitesString( $string )
+ static public function getIdSitesFromIdSitesString( $ids )
{
- if(is_array($string))
+ if(!is_array($ids))
{
- return $string;
+ $ids = explode(',', $ids);
}
- $ids = explode(',', $string);
$validIds = array();
foreach($ids as $id)
{
@@ -206,6 +205,9 @@ class Piwik_Site
$validIds[] = $id;
}
}
+ $validIds = array_filter($validIds);
+ $validIds = array_unique($validIds);
+
return $validIds;
}
diff --git a/plugins/CoreAdminHome/API.php b/plugins/CoreAdminHome/API.php
index ac341aa02e..c32f9914b9 100644
--- a/plugins/CoreAdminHome/API.php
+++ b/plugins/CoreAdminHome/API.php
@@ -71,6 +71,9 @@ class Piwik_CoreAdminHome_API
{
Piwik::checkUserIsSuperUser();
$idSites = Piwik_Site::getIdSitesFromIdSitesString($idSites);
+ if(empty($idSites)) {
+ throw new Exception("Specify a value for &idSites=");
+ }
// Ensure the specified dates are valid
$toInvalidate = $invalidDates = array();
$dates = explode(',', $dates);
diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php
index 5daded88c2..96734ff470 100644
--- a/plugins/UsersManager/API.php
+++ b/plugins/UsersManager/API.php
@@ -542,7 +542,11 @@ class Piwik_UsersManager_API
{
$idSites = Piwik_Site::getIdSitesFromIdSitesString($idSites);
}
-
+
+ if(empty($idSites))
+ {
+ throw new Exception('Specify at least one website ID in &idSites=');
+ }
// it is possible to set user access on websites only for the websites admin
// basically an admin can give the view or the admin access to any user for the websites he manages
Piwik::checkUserHasAdminAccess( $idSites );