public function copy($id = null)
 {
     $group = $this->load_group($id);
     $newGroup = new ACLGroup();
     $newGroup->name = $group->name;
     $newGroup->code = $group->code;
     $newGroup->description = $group->description;
     if ($this->post) {
         $newGroup->name = $this->PostData('name');
         $newGroup->code = $this->PostData('code');
         $newGroup->description = $this->PostData('description');
         if ($newGroup->save()) {
             foreach ($group->rules() as $rule) {
                 $newRule = new ACLRule();
                 $newRule->aclgroup_id = $newGroup->id;
                 $newRule->acl_id = $rule->acl_id;
                 $newRule->action = $rule->action;
                 $newRule->url = $rule->url;
                 $newRule->notice = $rule->notice;
                 $newRule->error = $rule->error;
                 $newRule->save();
             }
             Site::Flash('notice', 'The group has been copied');
             Redirect("admin/acl/groups/{$newGroup->id}");
         }
     }
     $this->assign('group', $newGroup);
     $this->assign('originalGroup', $group);
     $this->title = "ACL :: Groups :: {$group->name} :: Copy";
     $this->render('aclgroup/copy.tpl');
 }
Exemplo n.º 2
0
 public function update_discounts($id = null)
 {
     $cart = $this->load_cart($id);
     $cart->check_discounts();
     Site::Flash('notice', 'The discounts have been updated');
     Redirect("admin/carts/{$cart->id}");
 }
 public function edit($permalink = null)
 {
     $this->tinymce = true;
     $event = self::load_event($permalink);
     if ($this->post) {
         $event->name = $this->PostData('name');
         $event->shortname = $this->PostData('shortname');
         $event->permalink = $this->PostData('permalink');
         $event->location = $this->PostData('location');
         $event->postcode = $this->PostData('postcode');
         $event->capacity = $this->PostData('capacity');
         $event->forum_id = $this->PostData('forum_id');
         $event->visible = $this->PostData('visible');
         $event->active = $this->PostData('active');
         $event->tournament_url = $this->PostData('tournament_url');
         $event->display_achievements = $this->PostData('display_achievements');
         $event->set_startdate($this->PostData('startdate'));
         $event->set_enddate($this->PostData('enddate'));
         $event->lock_seating = $this->PostData('lock_seating');
         $event->next = $this->PostData('next');
         $event->advertised = $this->PostData('advertised');
         if ($event->save()) {
             Site::Flash("notice", "The event has been edited");
             Redirect("admin/events/{$event->permalink}");
         }
     }
     $this->assign("event", $event);
     $this->title = "Edit Event";
     $this->render("event/edit.tpl");
 }
 public function user_index($nickname = null)
 {
     if (!$nickname) {
         $nickname = $this->GetData('nickname');
     }
     $user = User::find_by_nickname($nickname);
     $newaward = new LoyaltyAward();
     if ($this->post) {
         $newaward->user_id = $user->id;
         $newaward->points = $this->PostData("points");
         $newaward->justification = $this->PostData("justification");
         $newaward->awarded_by_id = Site::CurrentUser()->id;
         if (!$this->csrf) {
             Site::InstantFlash('error', 'Invalid form submission');
         } elseif ($newaward->save()) {
             Site::Flash("notice", "The loyalty points have been awarded");
             Redirect("admin/users/" . $user->permalink() . "/loyalty");
         } else {
             Site::InstantFlash('error', 'Unable to award loyalty points');
         }
     }
     $page = 1;
     if ($this->GetData('page')) {
         $page = $this->GetData('page');
     }
     $id = mysql_real_escape_string($user->id);
     $awards = LoyaltyAward::paginate("users.id = '{$id}'", "loyalty_awards.id DESC", $page, 50);
     $this->assign("user", $user);
     $this->assign("awards", $awards);
     $this->assign('newaward', $newaward);
     $this->title = "{$user->nickname} :: Loyalty";
     $this->render("loyalty_award/user_index.tpl");
 }
 public function edit()
 {
     $gateway = $this->getByID('PaymentGateway');
     $settings = $gateway->getSettings();
     $code = $this->getData('code');
     if (!isset($settings[$code])) {
         throw new Error404('Unable to find setting with the code supplied');
     }
     $setting = $settings[$code];
     if ($this->post) {
         $value = $this->postData('value');
         if (!$setting->obj) {
             $setting->obj = new PaymentGatewaySetting();
             $setting->obj->paymentgateway = $gateway;
             $setting->obj->paymentgateway_id = $gateway->id;
             $setting->obj->code = $setting->code;
         }
         $setting->obj->value = $this->postData('value');
         $setting->value = $setting->obj->value;
         if ($this->csrf && $setting->obj->save()) {
             Site::Flash('notice', 'The payment gateway setting has been updated');
             Redirect("admin/payments/gateways/{$gateway->id}");
         } elseif (!$this->csrf) {
             Site::Flash('error', 'Invalid form submission');
         }
     }
     $this->assign('gateway', $gateway);
     $this->assign('setting', $setting);
     $this->title = "Payment Gateways :: {$gateway->name} :: Settings :: {$setting->name}";
     $this->render('paymentgatewaysetting/edit.tpl');
 }
 public function delete($group_id = null, $id = null)
 {
     $group = self::load_group($group_id);
     $user_group = self::load_user_group($group->id, $id);
     $user_group->destroy();
     Site::Flash("notice", "{$user_group->user->nickname} has been removed from this group");
     if (isset($_GET['user'])) {
         Redirect("admin/users/{$user_group->user->permalink()}");
     }
     Redirect("admin/groups/{$group->id}");
 }
 public function delete($group_id = null, $id = null)
 {
     $group = self::load_group($group_id);
     $event_group = self::load_event_group($group->id, $id);
     $event_group->destroy();
     Site::Flash("notice", "{$event_group->event->name} has been removed from this group");
     if (isset($_GET['event'])) {
         Redirect("admin/users/{$user_group->event->name}");
     }
     Redirect("admin/groups/{$group->id}");
 }
 public function delete($id = null)
 {
     if (!$id) {
         $id = $this->GetData('id');
     }
     $redemption = DiscountRedemption::find_by_id($id);
     if (!$redemption || $redemption->user->id != Site::CurrentUser()->id) {
         throw new Error404();
     }
     $redemption->destroy();
     Site::Flash("notice", "Discount code removed successfully.");
     RedirectBack("bookings/pay/{$cart_id}/");
 }
 public function delete($permalink = null, $id = null)
 {
     $event = self::load_event();
     $ticket = self::load_ticket($event);
     if ($ticket->event_signups()) {
         Site::Flash("error", "Ticket cannot be deleted as it has bookings");
         Redirect("admin/events/{$event->permalink}");
     } else {
         $ticket->destroy();
         Site::Flash("notice", "The ticket has been deleted");
         Redirect("admin/events/{$event->permalink}");
     }
 }
 public function delete($permalink = null, $id = null)
 {
     $event = self::load_event();
     $service = self::load_service($event);
     if ($service->event_services()) {
         Site::Flash("error", "Service cannot be deleted as it has bookings");
         Redirect("admin/events/{$event->permalink}");
     } else {
         $service->destroy();
         Site::Flash("notice", "The service has been deleted");
         Redirect("admin/events/{$event->permalink}");
     }
 }
 public function edit($id = null)
 {
     $nickname = self::load_nickname($id);
     if ($this->method == "POST") {
         $nickname->nickname = $_POST['nickname'];
         if ($nickname->Save()) {
             Site::Flash("notice", "The nickname has been edited");
             Redirect("admin/nicknames");
         }
     }
     $this->assign("nickname", $nickname);
     $this->title = "Edit Bad Nickname";
     $this->render("badnickname/edit.tpl");
 }
Exemplo n.º 12
0
 public function edit($id = null)
 {
     $group = self::load_group($id);
     if ($this->post) {
         $group->name = $_POST['name'];
         $group->description = $_POST['description'];
         if ($group->save()) {
             Site::Flash("notice", "The group has been updated");
             Redirect("admin/groups/{$group->id}");
         }
     }
     $this->assign("group", $group);
     $this->title = "Edit Group";
     $this->render("group/edit.tpl");
 }
 public function create()
 {
     $game = self::load_game();
     if ($this->post) {
         $gametype = new Gametype();
         $gametype->game_id = $game->id;
         $gametype->gametype = $_POST['gametype'];
         if ($gametype->Save()) {
             Site::Flash("notice", "The gametype has been created");
         } else {
             Site::Flash("error", "Unable to create gametype");
         }
     }
     Redirect("admin/games/{$game->id}");
 }
Exemplo n.º 14
0
 public function edit($id = null)
 {
     $tag = self::load_tag($id);
     if ($this->post) {
         $tag->tag = $this->PostData('tag');
         $tag->system = $this->PostData('system');
         $tag->hidden = $this->PostData('hidden');
         if ($tag->save()) {
             Site::Flash("notice", "The tag has been edited");
             Redirect("admin/tags/{$tag->id}");
         }
     }
     $this->assign("tag", $tag);
     $this->title = "Edit Tags";
     $this->render("tag/edit.tpl");
 }
 public function edit($id = null)
 {
     $account = $this->load_account($id);
     if ($this->post) {
         $account->name = $this->PostData('name');
         $account->code = $this->PostData('code');
         $account->description = $this->PostData('description');
         if ($account->save()) {
             Site::Flash('notice', 'The account has been updated');
             Redirect("admin/twitter/accounts/{$account->id}");
         }
     }
     $this->assign('account', $account);
     $this->title = "Twitter Account :: Edit {$account->name}";
     $this->render('twitter_account/edit.tpl');
 }
Exemplo n.º 16
0
 public function delete($id = null)
 {
     $acl = $this->load_acl($id);
     if ($this->post) {
         try {
             $acl->destroy();
             Site::Flash('notice', 'The ACL has been removed');
         } catch (Error500 $e) {
             Site::Flash('error', 'Unable to delete ACL: ' . $e->getMessage());
         }
         Redirect("admin/acl");
     }
     $this->assign('acl', $acl);
     $this->title = "ACL :: Delete";
     $this->render('acl/delete.tpl');
 }
Exemplo n.º 17
0
 public function edit($id = null)
 {
     $game = self::load_game($id);
     if ($this->post) {
         $game->name = $_POST['name'];
         $game->shortname = $_POST['shortname'];
         $game->url = $_POST['url'];
         if ($game->Save()) {
             Site::Flash("notice", "The game has been edited");
             Redirect("admin/games");
         }
     }
     $this->assign("game", $game);
     $this->title = "Edit Game";
     $this->render("game/edit.tpl");
 }
 public function edit($id = null)
 {
     $category = self::load_category($id);
     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 edited");
             Redirect("admin/achievements/categories");
         }
     }
     $this->assign("category", $category);
     $this->title = "Edit Achievement";
     $this->render("achievement_categories/edit.tpl");
 }
Exemplo n.º 19
0
 protected function updateTwitch($twitch, $success, $url)
 {
     if ($this->post) {
         $twitch->channel = $this->postData('channel');
         $twitch->name = $this->postData('name');
         $twitch->title = $this->postData('title');
         $twitch->public = $this->postData('public');
         if ($this->csrf && $twitch->save()) {
             Site::Flash('notice', $success);
             Redirect($url);
         } elseif (!$this->csrf) {
             Site::InstantFlash('error', 'Invalid form submission');
         }
     }
     $this->assign('twitch', $twitch);
 }
 public function delete($permalink = null, $id = null)
 {
     $event = $this->load_event($permalink);
     $group = $this->load_group($event, $id);
     if ($this->post && $this->csrf) {
         $group->destroy();
         Site::Flash('notice', 'The group has been deleted');
         Redirect("admin/events/{$event->permalink}/seating/groups");
     } elseif (!$this->csrf) {
         Site::InstantFlash('Invalid form submission');
     }
     $this->assign('event', $event);
     $this->assign('group', $group);
     $this->title = "{$event->name} :: Delete {$group->name}";
     $this->render('seating_group/delete.tpl');
 }
 public function edit($article_id = null, $id = null)
 {
     $article = self::load_article($article_id);
     $page = self::load_page($article, $id);
     if ($this->post) {
         $page->title = $this->PostData('title');
         $page->content = $this->PostData('fullbody');
         if ($page->save()) {
             Site::Flash("notice", "The page has been edited");
             Redirect("admin/articles/{$article->id}");
         }
     }
     $this->assign("page", $page);
     $this->tinymce = true;
     $this->title = "Edit Article Page";
     $this->render("article_page/edit.tpl");
 }
 protected function updateGateway($gateway, $success, $url)
 {
     if ($this->post) {
         $gateway->name = $this->postData('name');
         $gateway->code = $this->postData('code');
         $gateway->classname = $this->postData('classname');
         $gateway->enabled = $this->postData('enabled');
         $gateway->public = $this->postData('public');
         if ($this->csrf && $gateway->save()) {
             Site::Flash('notice', $success);
             Redirect($url);
         } elseif (!$this->csrf) {
             Site::InstantFlash('error', 'Invalid form submission');
         }
     }
     $this->assign('gateway', $gateway);
 }
Exemplo n.º 23
0
 public function fix_order($id = null)
 {
     $survey = self::load_survey($id);
     $i = 1;
     foreach ($survey->questions() as $question) {
         $question->position = $i;
         $question->save();
         $j = 1;
         foreach ($question->options() as $option) {
             $option->position = $j;
             $option->save();
             $j++;
         }
         $i++;
     }
     Site::Flash('notice', 'The question order has been fixed');
     Redirect("admin/surveys/{$survey->id}");
 }
 public function edit($id = null)
 {
     global $site;
     $server = self::load_gameserver($id);
     if ($this->post) {
         $server->address = $_POST['address'];
         $server->port = $_POST['port'];
         $server->qstat = $_POST['qstat'];
         if ($server->Save()) {
             Site::Flash("notice", "The game server has been edited");
             Redirect("admin/servers");
         }
     }
     $this->assign("server", $server);
     $this->assign("site", $site);
     $this->title = "Edit Game Server";
     $this->render("gameserver/edit.tpl");
 }
Exemplo n.º 25
0
 public function run($action)
 {
     $controller = get_class($this);
     $user = Site::CurrentUser();
     if ($user) {
         $group = $user->aclgroup;
     } else {
         $group = ACLGroup::find_by_code('guest');
     }
     if (!$group) {
         throw new Error500('Unable to find ACL group');
     }
     $rule = $this->getRule($group, $controller, $action);
     if (!$rule) {
         throw new Error403('You do not have permission to access this resource');
     }
     switch ($rule->action) {
         case 'araDeny':
             if ($rule->error) {
                 Site::InstantFlash('error', $rule->error);
             } elseif ($rule->notice) {
                 Site::InstantFlash('notice', $rule->notice);
             }
             throw new Error403('You do not have permission to access this resource');
         case 'araRedirect':
             if ($rule->error) {
                 Site::Flash('error', $rule->error);
             } elseif ($rule->notice) {
                 Site::Flash('notice', $rule->notice);
             }
             $uri = $_SERVER["REQUEST_URI"];
             if (substr($uri, 0, 1) == '/') {
                 $uri = substr($uri, 1);
             }
             Site::Flash('redirect', $uri);
             Redirect($rule->url);
             break;
         case 'araAllow':
             $params = func_get_args();
             array_shift($params);
             call_user_func_array(array($this, $action), $params);
             break;
     }
 }
 public function edit($survey_id = null, $question_id = null, $id = null)
 {
     $this->tinymce = true;
     $survey = self::load_survey($survey_id);
     $question = self::load_question($survey, $question_id);
     $option = self::load_option($question, $id);
     if ($this->post) {
         $option->value = $this->PostData("value");
         if ($option->Save()) {
             Site::Flash("notice", "The option has been edited");
             Redirect("admin/surveys/{$survey->id}/questions/{$question->id}#options");
         }
     }
     $this->assign("survey", $survey);
     $this->assign("question", $question);
     $this->assign("option", $option);
     $this->title = "Edit Option";
     $this->render("survey_question_option/edit.tpl");
 }
 public function edit($id = null)
 {
     $slideshow = self::load_slideshow($id);
     if ($this->method == "POST") {
         $slideshow->name = $_POST['name'];
         $slideshow->title = $_POST['title'];
         $slideshow->body = $_POST['body'];
         $slideshow->link = $_POST['link'];
         $slideshow->image = $_POST['image'];
         if ($slideshow->Save()) {
             Site::Flash("notice", "The slide has been edited");
             Redirect("admin/slideshow");
         }
     }
     $this->assign("slideshow", $slideshow);
     $this->tinymce = true;
     $this->title = "Edit Slide";
     $this->render("slideshow/edit.tpl");
 }
 public function move($permalink = null)
 {
     $event = self::load_event($permalink);
     $event_id = mysql_real_escape_string($event->id);
     $signup_id = mysql_real_escape_string($_GET['seat']);
     $signup = EventSignup::find("event_signups.event_id = '{$event_id}' AND event_tickets.participant = true AND event_signups.paid = true AND event_signups.id = '{$signup_id}'");
     if (!$signup) {
         Error404();
     }
     if (isset($_GET['destination'])) {
         $anchor = '';
         if ($_GET['destination'] == "unseat") {
             $signup->event_seat_id = null;
             if ($signup->save()) {
                 Site::Flash("notice", "{$signup->user->nickname} has been unseated");
             } else {
                 Site::Flash("error", "Unable to unseat {$signup->user->nickname}");
             }
         } else {
             $destination = self::load_seat($_GET['destination'], $event);
             if ($destination) {
                 $anchor = "#{$destination->seating_plan->permalink}-";
                 if ($destination->event_signup->id) {
                     $destination->event_signup->event_seat_id = null;
                     $destination->event_signup->save();
                 }
                 $signup->event_seat_id = $destination->id;
                 if ($signup->save()) {
                     //Email::send_event_checkin($signup);
                     Site::Flash("notice", "{$signup->user->nickname} has been moved to {$destination->label}");
                 } else {
                     Site::Flash("error", "Unable to move {$signup->user->nickname}");
                 }
             }
         }
         Redirect("admin/events/{$event->permalink}/seating{$anchor}");
     }
     $this->assign("event", $event);
     $this->assign("signup", $signup);
     $this->title = "{$event->name} Seating";
     $this->render("event_seat/move.tpl");
 }
 public function edit($permalink = null)
 {
     $this->tinymce = true;
     $content = self::load_content($permalink);
     if ($_SERVER['REQUEST_METHOD'] == "POST") {
         $content->title = $_POST['title'];
         $content->permalink = $_POST['permalink'];
         $content->body = $_POST['body'];
         $content->layout = $_POST['layout'];
         $content->internal = $_POST['internal'];
         $content->navbar = $_POST['navbar'];
         if ($content->Save()) {
             Site::Flash("notice", "The content page has been edited");
             Redirect("admin/content");
         }
     }
     $this->assign("content", $content);
     $this->title = "Edit Content Page";
     $this->render("content/edit.tpl");
 }
 public function edit($permalink = null)
 {
     $event = $this->load_event();
     $content = $this->load_content($event, $permalink);
     $this->tinymce = true;
     if ($this->post) {
         $content->title = $this->PostData('title');
         $content->permalink = $this->PostData('permalink');
         $content->body = $this->PostData('body');
         $content->internal = $this->PostData('internal');
         $content->navbar = $this->PostData('navbar');
         if ($content->Save()) {
             Site::Flash("notice", "The event content page has been edited");
             Redirect("admin/events/{$event->permalink}/content");
         }
     }
     $this->assign("content", $content);
     $this->assign("event", $event);
     $this->title = "Edit Event Content Page";
     $this->render("event_content/edit.tpl");
 }