diff options
author | mattab <matthieu.aubry@gmail.com> | 2015-06-11 06:46:28 +0300 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2015-06-11 06:46:28 +0300 |
commit | ce3538961e468069419d949bd7a302c682b42cb0 (patch) | |
tree | cb9f199771169859e25d6d59fea5c32268f96287 /plugins/SitesManager/Model.php | |
parent | 69810a07b94ffb9560c5c21be42635a35a42aa6e (diff) |
Make getSitesIdFromSiteUrl work well when user is not Super User + add integration tests
Diffstat (limited to 'plugins/SitesManager/Model.php')
-rw-r--r-- | plugins/SitesManager/Model.php | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/plugins/SitesManager/Model.php b/plugins/SitesManager/Model.php index 4b1c6609aa..7be060fca1 100644 --- a/plugins/SitesManager/Model.php +++ b/plugins/SitesManager/Model.php @@ -104,13 +104,10 @@ class Model /** * Returns the list of websites ID associated with a URL. * - * @param string $url - * @param string $urlBis - * @param string $urlTer - * @param string $urlQuater + * @param array $urls * @return array list of websites ID */ - public function getAllSitesIdFromSiteUrl($url, $urlBis, $urlTer, $urlQuater) + public function getAllSitesIdFromSiteUrl(array $urls) { $siteUrlTable = Common::prefixTable('site_url'); @@ -122,9 +119,7 @@ class Model WHERE (url = ? OR url = ? OR url = ? OR url = ?) ', // Bind - array( $url, $urlBis, $urlTer, $urlQuater, - $url, $urlBis, $urlTer, $urlQuater - ) + array_merge( $urls, $urls) ); return $ids; @@ -133,10 +128,11 @@ class Model /** * Returns the list of websites ID associated with a URL. * - * @param string $url + * @param string $login + * @param array $urls * @return array list of websites ID */ - public function getSitesIdFromSiteUrlHavingAccess($url, $urlBis, $login) + public function getSitesIdFromSiteUrlHavingAccess($login, $urls) { $siteUrlTable = Common::prefixTable('site_url'); $sqlAccessSite = Access::getSqlAccessSite('idsite'); @@ -144,14 +140,21 @@ class Model $ids = $this->getDb()->fetchAll( 'SELECT idsite FROM ' . $this->table . ' - WHERE (main_url = ? OR main_url = ?)' . + WHERE (main_url = ? OR main_url = ? OR main_url = ? OR main_url = ?)' . 'AND idsite IN (' . $sqlAccessSite . ') ' . 'UNION SELECT idsite FROM ' . $siteUrlTable . ' - WHERE (url = ? OR url = ?)' . + WHERE (url = ? OR url = ? OR url = ? OR url = ?)' . 'AND idsite IN (' . $sqlAccessSite . ')', - array($url, $urlBis, $login, $url, $urlBis, $login)); + + // Bind + array_merge( $urls, + array( $login ), + $urls, + array( $login ) + ) + ); return $ids; } |