public function create() { $category = new AchievementCategory(); if ($this->post) { $category->category_name = $this->PostData("name"); $category->default_category = $this->PostData("default"); $category->image_only_display = $this->PostData("image_only_display"); if ($category->save()) { Site::Flash("notice", "The achievement category has been created"); if ($this->PostData('redirect')) { Site::Flash("redirect", true); Redirect("admin/achievements/categories/new"); } else { Redirect("admin/achievements/categories"); } } } $redirect = false; if (isset($this->site['flash']['redirect'])) { $redirect = true; } $this->assign("category", $category); $this->assign("redirect", $redirect); $this->title = "New Achievement Category"; $this->render("achievement_categories/create.tpl"); }
public function save() { if ($this->permalink == "") { $this->permalink = self::make_permalink($this->name); } // If this is a new event, create a new achievement category if (!$this->achievement_category_id) { $achievement_category = new AchievementCategory(); $achievement_category->category_name = $this->name; $achievement_category->save(); $this->achievement_category_id = $achievement_category->id; } $result = parent::save(self::table); if ($result && $this->next) { $id = mysql_real_escape_string($this->id); $events = Event::find_all("events.next = TRUE and events.id <> '{$id}'"); foreach ($events as $event) { $event->next = false; $event->save(); } } return $result; }