public function build($runData)
 {
     $site = $runData->getTemp("site");
     $fsettings = $site->getForumSettings();
     $tips = array();
     if (!$fsettings) {
         $tips['forum'] = true;
     }
     // site tags
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $t = DB_SiteTagPeer::instance()->selectOne($c);
     if (!$t) {
         $tips['tags'] = true;
     }
     // count members... ???
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $co = DB_MemberPeer::instance()->selectCount($c);
     if ($co < 4) {
         $tips['invite'] = true;
     }
     if (count($tips) > 0) {
         $runData->contextAdd("tips", $tips);
     }
     $runData->contextAdd('site', $site);
 }
 public function build($runData)
 {
     $site = $runData->getTemp("site");
     // get tags
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $dbTags = DB_SiteTagPeer::instance()->select($c);
     $tags = '';
     foreach ($dbTags as $dbTag) {
         $tags .= htmlspecialchars($dbTag->getTag()) . ' ';
     }
     $tags = trim($tags);
     $runData->contextAdd("tags", $tags);
     $runData->contextAdd("site", $site);
 }
Example #3
0
 public function saveGeneralEvent($runData)
 {
     $pl = $runData->getParameterList();
     $name = trim($pl->getParameterValue("name"));
     $subtitle = trim($pl->getParameterValue("subtitle"));
     $description = trim($pl->getParameterValue("description"));
     $tags = strtolower(trim($pl->getParameterValue("tags")));
     $defaultPage = WDStringUtils::toUnixName($pl->getParameterValue("default_page"));
     $errors = array();
     if (strlen($name) < 1) {
         $errors['name'] = _("Site name must be present.");
     } elseif (strlen8($name) > 30) {
         $errors['name'] = _("Site name should not be longer than 30 characters.");
     }
     if (strlen8($subtitle) > 50) {
         $errors['subtitle'] = _("Subtitle should not be longer than 50 characters");
     }
     if (strlen8($description) > 300) {
         $errors['description'] = _("Description should not be longer than 300 characters");
     }
     if (strlen8($tags) > 128) {
         $errors['tags'] = _('"Tags" field too long.');
     }
     if ($defaultPage == "") {
         $errors['defaultPage'] = _("Default landing page should be given and be somehow valid.");
     }
     if (strlen($defaultPage) > 80) {
         $errors['defaultPage'] = _("Default landing page name is too long.");
     }
     if (count($errors) > 0) {
         $runData->ajaxResponseAdd("formErrors", $errors);
         throw new ProcessException("Form errors", "form_errors");
     }
     $site = $runData->getTemp("site");
     $changed = false;
     if ($site->getName() !== $name) {
         $site->setName($name);
         $changed = true;
     }
     if ($site->getSubtitle() !== $subtitle) {
         $site->setSubtitle($subtitle);
         $changed = true;
     }
     if ($site->getDescription() !== $description) {
         $site->setDescription($description);
         $changed = true;
     }
     if ($site->getDefaultPage() !== $defaultPage) {
         $site->setDefaultPage($defaultPage);
         $changed = true;
     }
     $db = Database::connection();
     $db->begin();
     if ($changed) {
         $site->save();
         // outdate cache for sure ;-)
         $outdater = new Outdater();
         $outdater->siteEvent("sitewide_change");
     }
     $c = new Criteria();
     $c->add("site_id", $site->getSiteId());
     $dbTags = DB_SiteTagPeer::instance()->select($c);
     $tags = preg_split("/[ ,]+/", $tags);
     $tags = array_unique($tags);
     foreach ($dbTags as $dbTag) {
         if (in_array($dbTag->getTag(), $tags)) {
             unset($tags[array_search($dbTag->getTag(), $tags)]);
         } else {
             DB_SiteTagPeer::instance()->deleteByPrimaryKey($dbTag->getTagId());
         }
     }
     // insert all other
     foreach ($tags as $tag) {
         if (trim($tag) != '') {
             $dbTag = new DB_SiteTag();
             $dbTag->setSiteId($site->getSiteId());
             $dbTag->setTag($tag);
             $dbTag->save();
         }
     }
     $db->commit();
     if (GlobalProperties::$UI_SLEEP) {
         sleep(1);
     }
 }