本文整理汇总了PHP中Site::InstantFlash方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::InstantFlash方法的具体用法?PHP Site::InstantFlash怎么用?PHP Site::InstantFlash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site
的用法示例。
在下文中一共展示了Site::InstantFlash方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_index
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");
}
示例2: show
public function show($id = null)
{
$cart = $this->load_cart($id);
if (!$cart->paid) {
$cart->check_discounts();
$manualGateway = null;
$gateways = null;
$allGateways = PaymentGateway::find_all('', 'paymentgateways.position ASC');
foreach ($allGateways as $gateway) {
$gateways[$gateway->id] = $gateway->name;
if ($gateway->code == 'manual') {
$manualGateway = $gateway;
}
}
$payment = new PaymentTransaction();
$payment->cart_id = $cart->id;
$payment->cart = $cart;
$payment->paymentgateway = $manualGateway;
$payment->paymentgateway_id = $manualGateway->id;
$payment->externalid = (string) $cart;
$payment->amount = Money($cart->cost());
$payment->sender = $cart->user->email;
$payment->status = 'ptsTaken';
$payment->processResponse = array('notes' => '');
if ($this->post) {
$payment->paymentgateway_id = $this->postData('paymentgateway_id');
$payment->externalid = $this->postData('externalid');
$payment->sender = $this->postData('sender');
$payment->amount = $this->postData('amount');
$payment->processResponse = array('notes' => $this->postData('notes'));
$payment->method = $gateways[$payment->paymentgateway_id];
if ($payment->save()) {
Email::send_user_paymentconfirmation($payment);
$cart->mark_paid($payment, 'Manually Paid');
Email::send_payment_complete(array(), "", $cart);
Site::Flash('notice', 'The cart has been paid for');
Redirect("admin/carts/{$cart->id}");
} else {
Site::InstantFlash('error', 'Invalid payment');
}
echo '<pre>';
print_r($payment);
die;
}
$this->assign('payment', $payment);
$this->assign('gateways', $gateways);
}
$this->assign('cart', $cart);
$this->title = "Cart :: {$cart->id}";
$this->render('cart/show.tpl');
}
示例3: updateTwitch
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);
}
示例4: updateGateway
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);
}
示例5: run
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;
}
}
示例6: delete
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');
}
示例7: edit
public function edit()
{
$event = self::load_event();
if ($event->enddate <= time()) {
Site::Flash("error", "It is not possible to change your seat");
Redirect("{$event->permalink}/seating");
}
$seat = self::load_seat($event);
if ($seat->event_signup->id) {
Site::Flash("error", "The seat has already been chosen");
Redirect("{$seat->event->permalink}/seating/{$seat->seating_plan->permalink}");
}
// Fetch signups
$event_id = mysql_real_escape_string($event->id);
$user_id = mysql_real_escape_string(Site::CurrentUser()->id);
$signups = EventSignup::find_all("event_signups.event_id = '{$event_id}' AND (event_signups.user_id = '{$user_id}' OR event_signups.manager_id = '{$user_id}') AND event_signups.paid = true AND event_tickets.participant = true");
$total = count($signups);
if ($total == 0) {
Site::Flash("error", "You need to be a paid participant to choose your seat");
Redirect("{$seat->event->permalink}/seating/{$seat->seating_plan->permalink}");
}
$eligible = array();
foreach ($signups as $signup) {
if ($signup->event_seat_id && $event->lock_seating) {
// A seat is assigned, and seating is locked - No
continue;
}
if (!$signup->event_ticket->seating_group_id && !$seat->seating_group_id && !$seat->disabled) {
// Seat is not disabled, there's no group on the ticket or the seat, so we're good
$eligible[$signup->id] = $signup;
continue;
}
if ($signup->event_ticket->seating_group_id && $seat->seating_group_id && $signup->event_ticket->seating_group_id == $seat->seating_group_id) {
// Seat has a group, and it's the same as the ticket, this is good
$eligible[$signup->id] = $signup;
}
}
if (count($eligible) == 0) {
if (count($signups) == 0) {
Site::Flash("error", "You need to be a paid participant to choose your seat");
} else {
Site::Flash('error', 'You have no bookings that can choose this seat');
}
Redirect("{$seat->event->permalink}/seating/{$seat->seating_plan->permalink}");
}
if (count($eligible) == 1) {
$signup = current($eligible);
$signup->event_seat_id = $seat->id;
if ($signup->save()) {
Site::Flash("notice", "You have chosen seat {$seat->label}");
//Email::send_event_checkin($signup);
} else {
Site::Flash('error', 'Unable to choose seat, please try again');
}
Redirect("{$seat->event->permalink}/seating/{$seat->seating_plan->permalink}");
}
// We have more than one eligible booking, we need the user to select which one
if ($this->post) {
$id = $this->postData('signup');
if (!$this->csrf) {
Site::InstantFlash('error', 'Invalid form submission');
} elseif (!$id || !array_key_exists($id, $eligible)) {
Site::InstantFlash('error', 'Please select a valid event booking');
} else {
$eligible[$id]->event_seat_id = $seat->id;
if ($eligible[$id]->save()) {
Site::Flash('notice', "You have chosen seat {$seat->label}");
//Email::send_event_checkin($signup);
Redirect("{$seat->event->permalink}/seating/{$seat->seating_plan->permalink}");
} else {
Site::InstantFlash('error', 'Unable to choose seat, please try again');
}
}
}
$this->assign("event", $event);
$this->assign("seat", $seat);
$this->assign("signups", $eligible);
$this->title = "{$event->name} :: Seating Plan";
$this->render("event_seat/edit.tpl");
}
示例8: award
public function award()
{
if ($this->post) {
$achievement = $this->load_achievement($this->PostData('achievement_id'));
$user_temp = $this->PostData('users');
if (!is_array($user_temp)) {
$user_temp = explode(',', $user_temp);
}
$error_on = array();
$success = 0;
foreach ($user_temp as $name_temp) {
$user_id = mysql_real_escape_string($name_temp);
$user = User::find_by_id($user_id);
if ($user) {
if ($achievement->award($user, $this->PostData("category_id"))) {
$success++;
} else {
$error_on[] = $name;
}
} else {
$error_on[] = $name;
}
}
if (count($user_temp) == 1) {
if ($success == 1) {
Site::InstantFlash("notice", "{$user->nickname} has been awarded {$achievement->name}");
} else {
Site::InstantFlash("error", "Unable to award achievement");
}
} else {
if ($success == 0) {
Site::InstantFlash("error", "Unable to award achievements to any of the users listed");
} elseif (count($error_on) > 0) {
Site::InstantFlash("error", "Awarded achievement to {$success} user" . ($success != 1 ? "s" : "") . ", failed to award to " . implode(", ", $error_on));
} else {
Site::InstantFlash("notice", "Awarded achievements to all users listed.");
}
}
}
$filters = array();
$pageQuery = '';
if ($this->GetData('query')) {
$pageQuery = $this->GetData('query');
$query = mysql_real_escape_string($this->GetData('query'));
$filters[] = "users.nickname LIKE '%{$query}%'";
}
$filter = implode('AND', $filters);
$achievement_id = null;
if ($this->GetData('achievement_id')) {
$achievement_id = $this->GetData('achievement_id');
}
$page = 1;
if ($this->GetData('page')) {
$page = $this->GetData('page');
}
$users = User::paginate($filter, 'users.nickname ASC', $page, 50);
$achievements = Achievement::find_all("", "achievements.created_at ASC");
$achlist = array();
foreach ($achievements as $ach) {
$achlist[$ach->id] = "{$ach->id}. {$ach->name}";
}
// Yay - Magic Numbers!
$category_id = 11;
$categories = array();
$all_categories = array();
$all_categories = AchievementCategory::find_all();
foreach ($all_categories as $category) {
$event = Event::find("achievement_category_id={$category->id}");
if (!$event || $event->check_user(Site::CurrentUser()) && $event->display_achievements) {
$categories[$category->id] = $category->category_name;
if ($category->default_category) {
$category_id = $category->id;
}
}
}
if ($this->GetData('category_id')) {
$category_id = $this->GetData('category_id');
}
$this->assign("achievements", $achlist);
$this->assign("categories", $categories);
$this->assign("category_id", $category_id);
$this->assign("achievement_id", $achievement_id);
$this->assign("users", $users);
$this->assign('pagequery', $pageQuery);
$this->title = "Award Achievement";
$this->render("achievement/award.tpl");
}
示例9: create2
public function create2($group_id = null, $acl_id = null)
{
$group = $this->load_group($group_id);
if (!$acl_id) {
$acl_id = $this->GetData('acl_id');
}
$acl = ACL::find_by_id($acl_id);
if (!$acl) {
Site::Flash('error', 'Unable to find the ACL selected');
Redirect("admin/acl/groups/{$group->id}/rules/new");
}
if ($this->post) {
$ids = $this->PostData('actions');
$urls = $this->PostData('urls');
if (is_array($ids)) {
$count = 0;
foreach ($ids as $id => $action) {
if (!$action) {
continue;
}
$rule = new ACLRule();
$rule->aclgroup_id = $group->id;
$rule->acl_id = $id;
$rule->action = $action;
if ($rule->action == 'araRedirect') {
if (isset($urls[$id])) {
$rule->url = $urls[$id];
}
}
if ($rule->save()) {
$count++;
}
}
$plural = 's have';
if ($count == 1) {
$plural = ' has';
}
Site::Flash('notice', "{$count} rule{$plural} been added");
Redirect("admin/acl/groups/{$group->id}");
} else {
Site::InstantFlash('error', 'No ACLs selected');
}
}
$controller = mysql_real_escape_string($acl->controller);
$id = mysql_real_escape_string($acl->id);
$ids = array();
$group_id = mysql_real_escape_string($group->id);
$currentRules = ACLRule::Find_all("aclgroups.id = '{$group_id}' AND (acls.controller = '{$controller}' OR acls.id = '{$id}')");
foreach ($currentRules as $rule) {
$ids[$rule->acl->id] = $rule->acl->id;
}
$rulesql = '';
if (count($ids) > 0) {
$rulesql = ' AND NOT acls.id IN (' . implode(', ', $ids) . ')';
}
$acls = ACL::find_all("(acls.controller = '{$controller}' OR acls.id = '{$id}'){$rulesql}", "acls.action ASC");
if (count($acls) == 0) {
Site::Flash('error', 'There are no more ACLs to add in this section');
Redirect("admin/acl/groups/{$group->id}/rules/new");
}
$this->assign('acl', $acl);
$this->assign('acls', $acls);
$this->assign('group', $group);
$this->title = "ACL :: Groups :: {$group->name} :: New Rule";
$this->render("aclrule/create2.tpl");
}