本文整理汇总了PHP中Site::CurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Site::CurrentUser方法的具体用法?PHP Site::CurrentUser怎么用?PHP Site::CurrentUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Site
的用法示例。
在下文中一共展示了Site::CurrentUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create()
{
$article = new Article();
if ($this->post) {
$article->title = $this->PostData('title');
$article->permalink = $this->PostData('permalink');
$article->summary = $this->PostData('summary');
$article->published = $this->PostData('published');
if ($this->PostData('publish_now') == 1) {
$article->publish_at = time();
} else {
$article->set_publish_at($this->PostData('publish_at'));
}
$article->user_id = Site::CurrentUser()->id;
if ($article->save()) {
$page = new ArticlePage();
$page->article_id = $article->id;
$page->title = $article->title;
$page->content = $this->PostData('fullbody');
$page->save();
Site::Flash("notice", "The article has been added");
Redirect("admin/articles/{$article->id}");
}
$this->assign("body", $this->PostData('fullbody'));
}
$this->assign("article", $article);
$this->tinymce = true;
$this->title = "Add Article";
$this->render("article/create.tpl");
}
示例2: 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");
}
示例3: selectLayout
protected function selectLayout()
{
if (strpos($_SERVER['REQUEST_URI'], "/admin") === 0) {
if (Site::CurrentUser() and Site::CurrentUser()->isAdmin() > 0) {
return "admin";
}
}
return "layout";
}
示例4: acknowledge
public function acknowledge($id = null)
{
$script = self::load_script($id);
if ($script->getAlert('bool') && !$script->acknowledged) {
$script->acknowledged = true;
$nickname = Site::CurrentUser()->nickname;
$script->addlog("Alert acknowledged by {$nickname}");
$script->save();
}
Site::flash("notice", "The script alert has been acknowledged.");
RedirectBack("admin/scripts");
}
示例5: delete
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}/");
}
示例6: index
public function index()
{
$page = 1;
if ($this->GetData('page')) {
$page = $this->GetData('page');
}
$user = Site::CurrentUser();
$id = mysql_real_escape_string($user->id);
$referrals = AffiliateReferral::paginate("referer.id = '{$id}'", "affiliate_referrals.created_at DESC, affiliate_referrals.id DESC", $page, 25);
$this->assign('user', $user);
$this->assign('referrals', $referrals);
$this->title = 'Referrals';
$this->render('affiliate_referral/index.tpl');
}
示例7: discounts
public function discounts()
{
$page = 1;
if ($this->GetData('page')) {
$page = $this->GetData('page');
}
$user = Site::CurrentUser();
$id = mysql_real_escape_string($user->id);
$discounts = LoyaltyDiscount::paginate("users.id = '{$id}'", "loyalty_discounts.id DESC", $page, 10);
$this->assign('user', $user);
$this->assign('discounts', $discounts);
$this->title = 'Loyalty Points :: Discount Codes';
$this->render('loyalty_award/discounts.tpl');
}
示例8: load_news
protected static function load_news($permalink = null, $published = true)
{
if (!$permalink) {
$permalink = $_GET['permalink'];
}
if (Site::CurrentUser() && Site::CurrentUser()->isAdmin() > 0) {
$published = false;
}
$news = News::find_by_permalink($permalink, $published);
if ($news) {
return $news;
} else {
Error404();
}
}
示例9: load_article
protected static function load_article($permalink = null)
{
if (!$permalink) {
$permalink = $_GET['permalink'];
}
$object = Article::find_by_permalink($permalink);
if ($object) {
if (Site::CurrentUser() && Site::CurrentUser()->isAdmin()) {
return $object;
} elseif (!$object->published || $object->publish_at > time()) {
throw new Error404('Article has not been published');
}
return $object;
} else {
throw new Error404('Unable to find the article');
}
}
示例10: load_event
protected static function load_event($permalink = null)
{
if (!$permalink) {
$permalink = $_GET['event_permalink'];
}
$event = Event::find_by_permalink($permalink);
if ($event) {
if (!$event->visible) {
self::restrict("admin");
}
if (!$event->check_user(Site::CurrentUser())) {
Error404();
}
return $event;
} else {
Error404();
}
}
示例11: 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;
}
}
示例12: render
public static function render($title = null, $headcontent = null)
{
self::init();
global $site;
global $config;
$smarty = new SmartySite();
$smarty->assign("title", $title);
$smarty->assign("site", $site);
$smarty->assign("content", "|--|CONTENT|--|");
$smarty->assign("headcontent", $headcontent);
$smarty->assign("next_event", Event::next_event());
$all_events = Event::find_all("events.visible = true", "events.startdate DESC");
$events = array();
foreach ($all_events as $event) {
if ($event->check_user(Site::CurrentUser())) {
$events[] = $event;
}
}
$smarty->assign("all_events", $events);
$output = $smarty->fetch("application/layout.tpl");
$output = explode("|--|CONTENT|--|", $output);
return array("header" => $output[0], "footer" => $output[1]);
}
示例13: create
public function create()
{
$news = new News();
if ($this->post) {
$news->title = $this->PostData('title');
$news->permalink = $this->PostData('permalink');
$news->summary = $this->PostData('summary');
$news->body = $this->PostData('body');
$news->fullbody = $this->PostData('fullbody');
$news->published = $this->PostData('published');
$news->tag_id = $this->PostData('tag_id');
$news->ipb_id = $this->PostData('ipb_id');
$news->image = $this->PostData('image');
if ($this->PostData('publish_now') == 1) {
$news->publish_at = time();
} else {
$news->set_publish_at($this->PostData('publish_at'));
}
$news->user_id = Site::CurrentUser()->id;
if ($news->Save()) {
$news->update_tags($this->PostData('tags'));
Site::Flash("notice", "The news has been added");
Redirect("admin/news");
}
}
$this->assign("news", $news);
$tags = array('' => 'None');
$allTags = Tag::find_all("tags.system = TRUE", "tags.tag ASC");
foreach ($allTags as $tag) {
$tags[$tag->id] = $tag->tag;
}
$this->assign("tags", $tags);
$this->tinymce = true;
$this->title = "Add News";
$this->render("news/create.tpl");
}
示例14: 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");
}
示例15: load_event
protected static function load_event($permalink = null)
{
if (!$permalink) {
$permalink = $_GET['permalink'];
}
$event = Event::find_by_permalink($permalink);
if ($event) {
if (!$event->visible) {
if (!Site::CurrentUser()->isAdmin()) {
throw new Error403();
}
}
if (!$event->check_user(Site::CurrentUser())) {
Error404();
}
return $event;
} else {
Error404();
}
}