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-09-12 19:42:39 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-09-12 19:42:39 +0400
commit19d5f67005fcb513253139ea149255c9ceb4320c (patch)
tree3de112844e749a241e62b81145cbf356f73767aa /plugins/SitesManager/Model.php
parent0aea1092d32050dfb0b0f6791061536a6777acbc (diff)
refs #4996 redirect only to trusted hosts (will have to remove this most likely again as you would have to register subdomains etc as well). Also added some missing test files
Diffstat (limited to 'plugins/SitesManager/Model.php')
-rw-r--r--plugins/SitesManager/Model.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/plugins/SitesManager/Model.php b/plugins/SitesManager/Model.php
index 9e77f48888..207f59bdfd 100644
--- a/plugins/SitesManager/Model.php
+++ b/plugins/SitesManager/Model.php
@@ -11,6 +11,7 @@ namespace Piwik\Plugins\SitesManager;
use Piwik\Db;
use Piwik\Common;
use Exception;
+use Piwik\Site;
class Model
{
@@ -59,4 +60,60 @@ class Model
return $site;
}
+
+ /**
+ * Returns the list of all the website IDs registered.
+ * Caller must check access.
+ *
+ * @return array The list of website IDs
+ */
+ public function getSitesId()
+ {
+ $result = Db::fetchAll("SELECT idsite FROM " . Common::prefixTable('site'));
+ $idSites = array();
+ foreach ($result as $idSite) {
+ $idSites[] = $idSite['idsite'];
+ }
+ return $idSites;
+ }
+
+ /**
+ * Returns the list of all URLs registered for the given idSite (main_url + alias URLs).
+ *
+ * @throws Exception if the website ID doesn't exist or the user doesn't have access to it
+ * @param int $idSite
+ * @return array list of URLs
+ */
+ public function getSiteUrlsFromId($idSite)
+ {
+ $urls = $this->getAliasSiteUrlsFromId($idSite);
+
+ $site = $this->getSiteFromId($idSite);
+
+ if (empty($site)) {
+ return $urls;
+ }
+
+ return array_merge(array($site['main_url']), $urls);
+ }
+
+ /**
+ * Returns the list of alias URLs registered for the given idSite.
+ * The website ID must be valid when calling this method!
+ *
+ * @param int $idSite
+ * @return array list of alias URLs
+ */
+ public function getAliasSiteUrlsFromId($idSite)
+ {
+ $db = Db::get();
+ $result = $db->fetchAll("SELECT url
+ FROM " . Common::prefixTable("site_url") . "
+ WHERE idsite = ?", $idSite);
+ $urls = array();
+ foreach ($result as $url) {
+ $urls[] = $url['url'];
+ }
+ return $urls;
+ }
}