Esempio n. 1
0
 public static function getSiteKey(Site $site = null)
 {
     if ($site) {
         $siteKey = "site_" . $site->getId();
     } else {
         $siteKey = "default";
     }
     return $siteKey;
 }
 /**
  * Declares an association between this object and a Site object.
  *
  * @param      Site $v
  * @return     Sitefeed The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setSite(Site $v = null)
 {
     if ($v === null) {
         $this->setSiteId(NULL);
     } else {
         $this->setSiteId($v->getId());
     }
     $this->aSite = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Site object, it will not be re-added.
     if ($v !== null) {
         $v->addSitefeed($this);
     }
     return $this;
 }
 public function copySite(Site $s, $new_name, $seconds = 10)
 {
     if (!is_numeric($seconds) || !$seconds > 0) {
         throw new e\UnacceptableValueException(S_SPAN . c\M::UNACCEPTABLE_SECONDS . E_SPAN);
     }
     $this->service->siteCopy($s->getId(), $s->getName(), $new_name);
     // wait until it is done
     sleep($seconds);
     if ($this->service->isSuccessful()) {
         return $this;
     }
     throw new e\SiteCreationFailureException(S_SPAN . c\M::SITE_CREATION_FAILURE . E_SPAN . $this->service->getMessage());
 }
Esempio n. 4
0
 public function moveService(\Service $Service, \Site $Site, \User $user = null)
 {
     //Throws exception if user is not an administrator
     $this->checkUserIsAdmin($user);
     $this->em->getConnection()->beginTransaction();
     //suspend auto-commit
     try {
         //If the site or service have no ID - throw logic exception
         $site_id = $Site->getId();
         if (empty($site_id)) {
             throw new LogicException('Site has no ID');
         }
         $Service_id = $Service->getId();
         if (empty($Service_id)) {
             throw new LogicException('Service has no ID');
         }
         //find old site
         $old_Site = $Service->getParentSite();
         //If the Site has changed, then we move the site.
         if ($old_Site != $Site) {
             //Remove the service from the old site if it has an old site
             if (!empty($old_Site)) {
                 $old_Site->getServices()->removeElement($Service);
             }
             //Add Service to new Site
             $Site->addServiceDoJoin($Service);
             //persist
             $this->em->merge($Site);
             $this->em->merge($old_Site);
         }
         //close if
         $this->em->flush();
         $this->em->getConnection()->commit();
     } catch (Exception $e) {
         $this->em->getConnection()->rollback();
         $this->em->close();
         throw $e;
     }
 }
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Site $value A Site object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool(Site $obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         self::$instances[$key] = $obj;
     }
 }
foreach($siteUrls as $url)
{
	$posInUrl = strpos($pageUrl, $url);
	$trouve = ($posInUrl == 0);
}
if (! $trouve) {
	printDebug("Url is not ok !");
	redirectToUrlIfNecessary();
	loadImage($logo, $idSite);
	exit();
}
*/
/**
 * exit if visitor is cookie excluded from the stats
 */
if (isset($_COOKIE[COOKIE_NAME_NO_STAT . $site->getId()])) {
    printDebug("Excluded from stats with the cookie!");
    redirectToUrlIfNecessary();
    loadImage($logo, $idSite);
}
/*
 * page variables
 */
$a_vars = getRequestVar('a_vars', array(), 'array');
/*
 * visitor config, as saved in the database
 */
$userAgent = secureVar(@$_SERVER['HTTP_USER_AGENT']);
$os = getOs($userAgent);
$a_browser = getBrowserInfo($userAgent);
$resolution = getRequestVar('res', 'unknown', 'string');
Esempio n. 7
0
 public function setDefaultSite(Site $site = NULL)
 {
     if (isset($site)) {
         $this->getProperty()->defaultSiteId = $site->getId();
         $this->getProperty()->defaultSiteName = $site->getName();
     } else {
         $this->getProperty()->defaultSiteId = NULL;
         $this->getProperty()->defaultSiteName = NULL;
     }
     return $this;
 }
Esempio n. 8
0
 public function moveSite(\Site $Site, \NGI $NGI, \User $user = null)
 {
     //Check the portal is not in read only mode, throws exception if it is
     $this->checkPortalIsNotReadOnlyOrUserIsAdmin($user);
     //Throws exception if user is not an administrator
     $this->checkUserIsAdmin($user);
     $this->em->getConnection()->beginTransaction();
     // suspend auto-commit
     try {
         //If the NGI or site have no ID - throw logic exception
         $site_id = $Site->getId();
         if (empty($site_id)) {
             throw new LogicException('Site has no ID');
         }
         $ngi_id = $NGI->getId();
         if (empty($ngi_id)) {
             throw new LogicException('NGI has no ID');
         }
         //find old NGI
         $old_NGI = $Site->getNgi();
         //If the NGI has changed, then we move the site.
         if ($old_NGI != $NGI) {
             //Remove the site from the old NGI FIRST if it has an old NGI
             if (!empty($old_NGI)) {
                 $old_NGI->getSites()->removeElement($Site);
             }
             //Add site to new NGI
             $NGI->addSiteDoJoin($Site);
             //$Site->setNgiDoJoin($NGI);
             //persist
             $this->em->merge($NGI);
             $this->em->merge($old_NGI);
         }
         //close if
         $this->em->flush();
         $this->em->getConnection()->commit();
     } catch (\Exception $e) {
         $this->em->getConnection()->rollback();
         $this->em->close();
         throw $e;
     }
 }