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:
authorThomas Steur <thomas.steur@googlemail.com>2014-07-27 13:26:42 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-07-27 13:26:42 +0400
commit652eca35d707ef64faf4f518bdb82db817a9f63f (patch)
treef7fcff552b5f2668052d662561eb7bcc9c9dae68 /plugins/SitesManager/API.php
parent038771c897e7a91cb6f3aa5978dac0db0d0e11b4 (diff)
refs #5887 use a model so we do not have to expose the method in the API. I tried to write a test for this but was not able to since lots of IntegrationTest magic
Diffstat (limited to 'plugins/SitesManager/API.php')
-rw-r--r--plugins/SitesManager/API.php33
1 files changed, 10 insertions, 23 deletions
diff --git a/plugins/SitesManager/API.php b/plugins/SitesManager/API.php
index 5c1702ad8b..8eca58f47b 100644
--- a/plugins/SitesManager/API.php
+++ b/plugins/SitesManager/API.php
@@ -180,14 +180,18 @@ class API extends \Piwik\Plugin\API
public function getSiteFromId($idSite)
{
Piwik::checkUserHasViewAccess($idSite);
- $site = Db::get()->fetchRow("SELECT *
- FROM " . Common::prefixTable("site") . "
- WHERE idsite = ?", $idSite);
+
+ $site = $this->getModel()->getSiteFromId($idSite);
Site::setSitesFromArray(array($site));
return $site;
}
+ private function getModel()
+ {
+ return new Model();
+ }
+
/**
* Returns the list of alias URLs registered for the given idSite.
* The website ID must be valid when calling this method!
@@ -419,29 +423,12 @@ class API extends \Piwik\Plugin\API
* @param bool $limit
* @return array
*/
- public function getSitesFromIds($idSites, $limit = false)
+ private function getSitesFromIds($idSites, $limit = false)
{
- Piwik::checkUserHasViewAccess($idSites);
-
- if (count($idSites) === 0) {
- return array();
- }
-
- if ($limit) {
- $limit = "LIMIT " . (int)$limit;
- } else {
- $limit = '';
- }
-
- $idSites = array_map('intval', $idSites);
-
- $db = Db::get();
- $sites = $db->fetchAll("SELECT *
- FROM " . Common::prefixTable("site") . "
- WHERE idsite IN (" . implode(", ", $idSites) . ")
- ORDER BY idsite ASC $limit");
+ $sites = $this->getModel()->getSitesFromIds($idSites, $limit);
Site::setSitesFromArray($sites);
+
return $sites;
}