Ejemplo n.º 1
0
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     $runData->contextAdd("site", $site);
     // get redirects
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $c->addOrderAscending("url");
     $redirects = DB_DomainRedirectPeer::instance()->select($c);
     $ra = array();
     foreach ($redirects as $r) {
         $ra[] = $r->getUrl();
     }
     $runData->contextAdd("redirects", $ra);
 }
Ejemplo n.º 2
0
 /**
  * Marks the site as "deleted" and invalidates all the cache related to the site.
  *
  * @param unknown_type $runData
  */
 public function deleteSiteEvent($runData)
 {
     $site = $runData->getTemp("site");
     $user = $runData->getUser();
     $c = new Criteria();
     $c->add("user_id", $user->getUserId());
     $c->add("site_id", $site->getSiteId());
     $c->add("founder", true);
     $rel = DB_AdminPeer::instance()->selectOne($c);
     if (!$rel) {
         throw new ProcessException(_("Sorry, you have no permissions to delete this site."));
     }
     $db = Database::connection();
     $db->begin();
     $oldUnixName = $site->getUnixName();
     $site->setDeleted(true);
     // remove some data.
     $c = new Criteria();
     $c->add('site_id', $site->getSiteId());
     DB_AnonymousAbuseFlagPeer::instance()->delete($c);
     DB_DomainRedirectPeer::instance()->delete($c);
     DB_EmailInvitationPeer::instance()->delete($c);
     DB_MemberApplicationPeer::instance()->delete($c);
     DB_MemberInvitationPeer::instance()->delete($c);
     // now clear cache!
     $keys = array();
     $keys[] = 'site..' . $site->getUnixName();
     $keys[] = 'site_cd..' . $site->getCustomDomain();
     $mc = OZONE::$memcache;
     foreach ($keys as $k) {
         $mc->delete($k);
     }
     $outdater = new Outdater();
     $outdater->siteEvent('delete', $site);
     $outdater->siteEvent('sitewide_change', $site);
     // change site name!!!
     $site->setUnixName($site->getUnixName() . '..del..' . time());
     $site->save();
     // remove custom domain link
     // rename the files
     @rename(WIKIDOT_ROOT . '/web/files--sites/' . $oldUnixName, WIKIDOT_ROOT . '/web/files--sites/' . $site->getUnixName());
     // delete custom domain link
     if ($site->getCustomDomain()) {
         @unlink(WIKIDOT_ROOT . '/web/custom--domains/' . $site->getCustomDomain());
         $site->setCustomDomain(null);
     }
     $db->commit();
 }