setSitesFromArray() 공개 정적인 메소드

Sets the cached Site data with a non-associated array of site data.
public static setSitesFromArray ( array $sites )
$sites array The array of sites data. eg, array( array('idsite' => '1', 'name' => 'Site 1', ...), array('idsite' => '2', 'name' => 'Site 2', ...), )
예제 #1
0
파일: API.php 프로젝트: carriercomm/piwik
 /**
  * Returns the list of websites from the ID array in parameters.
  * The user access is not checked in this method so the ID have to be accessible by the user!
  *
  * @param array $idSites list of website ID
  * @param bool $limit
  * @return array
  */
 private function getSitesFromIds($idSites, $limit = false)
 {
     if (count($idSites) === 0) {
         return array();
     }
     if ($limit) {
         $limit = "LIMIT " . (int) $limit;
     }
     $db = Db::get();
     $sites = $db->fetchAll("SELECT *\n\t\t\t\t\t\t\t\tFROM " . Common::prefixTable("site") . "\n\t\t\t\t\t\t\t\tWHERE idsite IN (" . implode(", ", $idSites) . ")\n\t\t\t\t\t\t\t\tORDER BY idsite ASC {$limit}");
     Site::setSitesFromArray($sites);
     return $sites;
 }
예제 #2
0
파일: API.php 프로젝트: a4tunado/piwik
 /**
  * Returns the list of websites from the ID array in parameters.
  * The user access is not checked in this method so the ID have to be accessible by the user!
  *
  * @param array $idSites list of website ID
  * @param bool $limit
  * @return array
  */
 private function getSitesFromIds($idSites, $limit = false)
 {
     $sites = $this->getModel()->getSitesFromIds($idSites, $limit);
     Site::setSitesFromArray($sites);
     return $sites;
 }
예제 #3
0
파일: API.php 프로젝트: bossrabbit/piwik
 /**
  * Fetches the list of sites which names match the string pattern
  *
  * @param string $pattern
  * @param bool   $_restrictSitesToLogin
  * @return array|string
  */
 private function getSitesIdFromPattern($pattern, $_restrictSitesToLogin)
 {
     // First clear cache
     Site::clearCache();
     if (empty($pattern)) {
         /** @var Scheduler $scheduler */
         $scheduler = StaticContainer::getContainer()->get('Piwik\\Scheduler\\Scheduler');
         // Then, warm the cache with only the data we should have access to
         if (Piwik::hasUserSuperUserAccess() && !$scheduler->isRunningTask()) {
             APISitesManager::getInstance()->getAllSites();
         } else {
             APISitesManager::getInstance()->getSitesWithAtLeastViewAccess($limit = false, $_restrictSitesToLogin);
         }
     } else {
         $sites = Request::processRequest('SitesManager.getPatternMatchSites', array('pattern' => $pattern, 'showColumns' => '', 'hideColumns' => '', 'serialize' => 0, 'format' => 'original'));
         if (!empty($sites)) {
             $idSites = array();
             foreach ($sites as $site) {
                 $idSites[] = $site['idsite'];
             }
             $model = new ModelSitesManager();
             $sites = $model->getSitesFromIds($idSites);
             // getPatternMatchSites does not return all sites information...
             Site::setSitesFromArray($sites);
         }
     }
     // Both calls above have called Site::setSitesFromArray. We now get these sites:
     $sitesToProblablyAdd = Site::getSites();
     return $sitesToProblablyAdd;
 }