function __construct(ImportURLModel $importURL, SiteModel $site = null) { $this->importURL = $importURL; $this->realurl = $importURL->getUrl(); if ($site) { $this->site = $site; } else { $siteRepo = new SiteRepository(); $this->site = $siteRepo->loadById($importURL->getSiteId()); } if ($importURL->getCountryId()) { $countryRepo = new CountryRepository(); $this->country = $countryRepo->loadById($importURL->getCountryId()); } if ($importURL->getAreaId()) { $areaRepo = new AreaRepository(); $this->area = $areaRepo->loadById($importURL->getAreaId()); } $groupRepository = new GroupRepository(); $this->group = $groupRepository->loadById($importURL->getGroupId()); }
public function loadClashForImportUrl(ImportURLModel $importURL) { global $DB; $sql = "SELECT import_url_information.* FROM import_url_information WHERE " . "is_enabled='1' AND expired_at IS NULL AND site_id=:site_id AND url_canonical=:url_canonical "; $params = array('site_id' => $importURL->getSiteId(), 'url_canonical' => $importURL->getUrlCanonical()); if ($importURL->getId()) { $sql .= " AND id != :id"; $params['id'] = $importURL->getId(); } $stat = $DB->prepare($sql); $stat->execute($params); if ($stat->rowCount() > 0) { $iurl = new ImportURLModel(); $iurl->setFromDataBaseRow($stat->fetch()); return $iurl; } }