本文整理汇总了PHP中identity类的典型用法代码示例。如果您正苦于以下问题:PHP identity类的具体用法?PHP identity怎么用?PHP identity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了identity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: page_bottom
static function page_bottom($theme)
{
$u_o = 1;
if ($theme->item->owner_id != identity::active_user()->id && identity::active_user()->admin == 0) {
$u_o = 0;
}
if ($u_o == 0 || $u_o == 1 && module::get_var("google_analytics", "owneradmin_hidden") == 0) {
$google_code = '
<!-- Begin Google Analytics -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(["_setAccount", "' . module::get_var("google_analytics", "code") . '"]);
_gaq.push(["_trackPageview"]);
(function() {
var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<!-- End Google Analytics -->';
return $google_code;
}
}
开发者ID:HarriLu,项目名称:gallery3,代码行数:26,代码来源:google_analytics_theme.php
示例2: required
static function required($perm_name, $item)
{
// Original code from the required function in modules/gallery/helpers/access.php.
if (!access::can($perm_name, $item)) {
if ($perm_name == "view") {
// Treat as if the item didn't exist, don't leak any information.
throw new Kohana_404_Exception();
} else {
access::forbidden();
}
// Begin rWatcher modifications.
// Throw a 404 error when a user attempts to access a protected item,
// unless the password has been provided, or the user is the item's owner.
} elseif (module::get_var("albumpassword", "hideonly") == false) {
$item_protected = ORM::factory("albumpassword_idcache")->where("item_id", "=", $item->id)->order_by("cache_id")->find_all();
if (count($item_protected) > 0) {
$existing_password = ORM::factory("items_albumpassword")->where("id", "=", $item_protected[0]->password_id)->find();
if ($existing_password->loaded()) {
if (cookie::get("g3_albumpassword") != $existing_password->password && identity::active_user()->id != $item->owner_id && !identity::active_user()->admin) {
throw new Kohana_404_Exception();
}
}
}
}
}
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:25,代码来源:MY_access.php
示例3: get_email_form
static function get_email_form($user_id, $item_id = null)
{
// Determine name of the person the message is going to.
$str_to_name = "";
if ($user_id == -1) {
$str_to_name = module::get_var("contactowner", "contact_owner_name");
} else {
// Locate the record for the user specified by $user_id,
// use this to determine the user's name.
$userDetails = ORM::factory("user")->where("id", "=", $user_id)->find_all();
$str_to_name = $userDetails[0]->name;
}
// If item_id is set, include a link to the item.
$email_body = "";
if (!empty($item_id)) {
$item = ORM::factory("item", $item_id);
$email_body = "This message refers to <a href=\"" . url::abs_site("{$item->type}s/{$item->id}") . "\">this page</a>.";
}
// Make a new form with a couple of text boxes.
$form = new Forge("contactowner/sendemail/{$user_id}", "", "post", array("id" => "g-contact-owner-send-form"));
$sendmail_fields = $form->group("contactOwner");
$sendmail_fields->input("email_to")->label(t("To:"))->value($str_to_name)->id("g-contactowner-to-name");
$sendmail_fields->input("email_from")->label(t("From:"))->value(identity::active_user()->email)->id("g-contactowner-from-email")->rules('required|valid_email')->error_messages("required", t("You must enter a valid email address"))->error_messages("valid_email", t("You must enter a valid email address"))->error_messages("invalid", t("You must enter a valid email address"));
$sendmail_fields->input("email_subject")->label(t("Subject:"))->value("")->id("g-contactowner-subject")->rules('required')->error_messages("required", t("You must enter a subject"));
$sendmail_fields->textarea("email_body")->label(t("Message:"))->value($email_body)->id("g-contactowner-email-body")->rules('required')->error_messages("required", t("You must enter a message"));
// Add a captcha, if there's an active captcha module.
module::event("captcha_protect_form", $form);
// Add a save button to the form.
$sendmail_fields->submit("SendMessage")->value(t("Send"));
return $form;
}
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:31,代码来源:contactowner.php
示例4: change
public function change()
{
access::verify_csrf();
$active_provider = module::get_var("gallery", "identity_provider", "user");
$providers = identity::providers();
$new_provider = Input::instance()->post("provider");
if ($new_provider != $active_provider) {
module::deactivate($active_provider);
// Switch authentication
identity::reset();
module::set_var("gallery", "identity_provider", $new_provider);
module::install($new_provider);
module::activate($new_provider);
module::event("identity_provider_changed", $active_provider, $new_provider);
module::uninstall($active_provider);
message::success(t("Changed to %description", array("description" => $providers->{$new_provider})));
try {
Session::instance()->destroy();
} catch (Exception $e) {
// We don't care if there was a problem destroying the session.
}
url::redirect(item::root()->abs_url());
}
message::info(t("The selected provider \"%description\" is already active.", array("description" => $providers->{$new_provider})));
url::redirect("admin/identity");
}
开发者ID:viosca,项目名称:gallery3,代码行数:26,代码来源:admin_identity.php
示例5: get
static function get($block_id, $theme)
{
if (identity::active_user()->guest) {
return;
}
$block = "";
switch ($block_id) {
case "untagged_photo":
$attempts = 0;
do {
$item = item::random_query()->join("items_tags", "items.id", "items_tags.item_id", "left")->where("items.type", "!=", "album")->where("items_tags.item_id", "IS", null)->find_all(1)->current();
} while (!$item && $attempts++ < 3);
if ($item && $item->loaded()) {
$block = new Block();
$block->css_id = "g-tag-it-block";
$block->title = t("Tag it");
$block->content = new View("tag_it_block.html");
$block->content->item = $item;
$form = new Forge("tags/create/{$item->id}", "", "post", array("id" => "g-tag-it-add-tag-form", "class" => "g-short-form"));
$label = $item->is_album() ? t("Add tag to album") : ($item->is_photo() ? t("Add tag to photo") : t("Add tag to movie"));
$group = $form->group("add_tag")->label("Add Tag");
$group->input("name")->label($label)->rules("required")->id("name");
$group->hidden("item_id")->value($item->id);
$group->submit("")->value(t("Add Tag"));
$block->content->form = $form;
}
break;
}
return $block;
}
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:30,代码来源:tag_it_block.php
示例6: user_menu
static function user_menu($menu, $theme)
{
$user = identity::active_user();
if ($user->guest) {
$menu->append(Menu::factory("dialog")->id("user_menu_register")->css_id("g-register-menu")->url(url::site("register"))->label(t("Register")));
}
}
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:7,代码来源:register_event.php
示例7: _show_themed_error_page
/**
* Shows a themed error page.
* @see Kohana_Exception::handle
*/
private static function _show_themed_error_page(Exception $e)
{
// Create a text version of the exception
$error = Kohana_Exception::text($e);
// Add this exception to the log
Kohana_Log::add('error', $error);
// Manually save logs after exceptions
Kohana_Log::save();
if (!headers_sent()) {
if ($e instanceof Kohana_Exception) {
$e->sendHeaders();
} else {
header("HTTP/1.1 500 Internal Server Error");
}
}
$view = new Theme_View("page.html", "other", "error");
if ($e instanceof Kohana_404_Exception) {
$view->page_title = t("Dang... Page not found!");
$view->content = new View("error_404.html");
$user = identity::active_user();
$view->content->is_guest = $user && $user->guest;
if ($view->content->is_guest) {
$view->content->login_form = new View("login_ajax.html");
$view->content->login_form->form = auth::get_login_form("login/auth_html");
// Avoid anti-phishing protection by passing the url as session variable.
Session::instance()->set("continue_url", url::current(true));
}
} else {
$view->page_title = t("Dang... Something went wrong!");
$view->content = new View("error.html");
}
print $view;
}
开发者ID:andyst,项目名称:gallery3,代码行数:37,代码来源:MY_Kohana_Exception.php
示例8: create_comment_for_user_test
public function create_comment_for_user_test()
{
$rand = rand();
$root = ORM::factory("item", 1);
$admin = identity::admin_user();
$comment = comment::create($root, $admin, "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
$this->assert_equal($admin->full_name, $comment->author_name());
$this->assert_equal($admin->email, $comment->author_email());
$this->assert_equal($admin->url, $comment->author_url());
$this->assert_equal("text_{$rand}", $comment->text);
$this->assert_equal(1, $comment->item_id);
$this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
$this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
$this->assert_equal("HTTP_ACCEPT", $comment->server_http_accept);
$this->assert_equal("HTTP_ACCEPT_CHARSET", $comment->server_http_accept_charset);
$this->assert_equal("HTTP_ACCEPT_ENCODING", $comment->server_http_accept_encoding);
$this->assert_equal("HTTP_ACCEPT_LANGUAGE", $comment->server_http_accept_language);
$this->assert_equal("HTTP_CONNECTION", $comment->server_http_connection);
$this->assert_equal("HTTP_HOST", $comment->server_http_host);
$this->assert_equal("HTTP_REFERER", $comment->server_http_referer);
$this->assert_equal("HTTP_USER_AGENT", $comment->server_http_user_agent);
$this->assert_equal("QUERY_STRING", $comment->server_query_string);
$this->assert_equal("REMOTE_ADDR", $comment->server_remote_addr);
$this->assert_equal("REMOTE_HOST", $comment->server_remote_host);
$this->assert_equal("REMOTE_PORT", $comment->server_remote_port);
$this->assert_true(!empty($comment->created));
}
开发者ID:ChrisRut,项目名称:gallery3,代码行数:27,代码来源:Comment_Helper_Test.php
示例9: user_created
/**
* Create an album for the newly created user and give him view and edit permissions.
*/
static function user_created($user)
{
// Create a group with the same name, if necessary
$group_name = "auto: {$user->name}";
$group = identity::lookup_group_by_name($group_name);
if (!$group) {
$group = identity::create_group($group_name);
identity::add_user_to_group($user, $group);
}
// Create an album for the user, if it doesn't exist
$album = ORM::factory("item")->where("parent_id", "=", item::root()->id)->where("name", "=", $user->name)->find();
if (!$album->loaded()) {
$album->type = "album";
$album->name = $user->name;
$album->title = "{$user->name}'s album";
$album->parent_id = item::root()->id;
$album->sort_column = "weight";
$album->sort_order = "asc";
$album->save();
access::allow($group, "view", item::root());
access::allow($group, "view_full", $album);
access::allow($group, "edit", $album);
access::allow($group, "add", $album);
}
}
开发者ID:Glooper,项目名称:gallery3-contrib,代码行数:28,代码来源:user_albums_event.php
示例10: __construct
public function __construct($theme = null)
{
if (!identity::active_user()->admin) {
access::forbidden();
}
parent::__construct();
}
开发者ID:ChrisRut,项目名称:gallery3,代码行数:7,代码来源:admin.php
示例11: head
static function head($theme)
{
if (identity::active_user()->admin) {
$theme->css("server_add.css");
$theme->script("server_add.js");
}
}
开发者ID:ChrisRut,项目名称:gallery3,代码行数:7,代码来源:server_add_theme.php
示例12: upgrade
public function upgrade()
{
if (php_sapi_name() == "cli") {
// @todo this may screw up some module installers, but we don't have a better answer at
// this time.
$_SERVER["HTTP_HOST"] = "example.com";
} else {
if (!identity::active_user()->admin && !Session::instance()->get("can_upgrade", false)) {
access::forbidden();
}
}
$available = module::available();
// Upgrade gallery first
$gallery = $available["gallery"];
if ($gallery->code_version != $gallery->version) {
module::upgrade("gallery");
module::activate("gallery");
}
// Then upgrade the rest
foreach (module::available() as $id => $module) {
if ($id == "gallery") {
continue;
}
if ($module->active && $module->code_version != $module->version) {
module::upgrade($id);
}
}
if (php_sapi_name() == "cli") {
print "Upgrade complete\n";
} else {
url::redirect("upgrader");
}
}
开发者ID:ChrisRut,项目名称:gallery3,代码行数:33,代码来源:upgrader.php
示例13: load_themes
/**
* Load the active theme. This is called at bootstrap time. We will only ever have one theme
* active for any given request.
*/
static function load_themes()
{
$input = Input::instance();
$path = $input->server("PATH_INFO");
if (empty($path)) {
$path = "/" . $input->get("kohana_uri");
}
$config = Kohana_Config::instance();
$modules = $config->get("core.modules");
self::$is_admin = $path == "/admin" || !strncmp($path, "/admin/", 7);
self::$site_theme_name = module::get_var("gallery", "active_site_theme");
if (self::$is_admin) {
// Load the admin theme
self::$admin_theme_name = module::get_var("gallery", "active_admin_theme");
array_unshift($modules, THEMEPATH . self::$admin_theme_name);
// If the site theme has an admin subdir, load that as a module so that
// themes can provide their own code.
if (file_exists(THEMEPATH . self::$site_theme_name . "/admin")) {
array_unshift($modules, THEMEPATH . self::$site_theme_name . "/admin");
}
} else {
// Admins can override the site theme, temporarily. This lets us preview themes.
if (identity::active_user()->admin && ($override = $input->get("theme"))) {
if (file_exists(THEMEPATH . $override)) {
self::$site_theme_name = $override;
} else {
Kohana_Log::add("error", "Missing override theme: '{$override}'");
}
}
array_unshift($modules, THEMEPATH . self::$site_theme_name);
}
$config->set("core.modules", $modules);
}
开发者ID:andyst,项目名称:gallery3,代码行数:37,代码来源:theme.php
示例14: emailid
public function emailid($user_id)
{
// Display a form that a vistor can use to contact a registered user.
// If this page is disabled, show a 404 error.
if (module::get_var("contactowner", "contact_user_link") != true) {
throw new Kohana_404_Exception();
}
// Locate the record for the user specified by $user_id,
// use this to determine the user's name.
$userDetails = ORM::factory("user")->where("id", "=", $user_id)->find_all();
// Make a new form with a couple of text boxes.
$form = new Forge("contactowner/sendemail", "", "post", array("id" => "g-contact-owner-send-form"));
$sendmail_fields = $form->group("contactOwner");
$sendmail_fields->input("email_to")->label(t("To:"))->value($userDetails[0]->name);
$sendmail_fields->input("email_from")->label(t("From:"))->value(identity::active_user()->email);
$sendmail_fields->input("email_subject")->label(t("Subject:"))->value("");
$sendmail_fields->textarea("email_body")->label(t("Message:"))->value("");
$sendmail_fields->hidden("email_to_id")->value($user_id);
// Add a save button to the form.
$sendmail_fields->submit("SendMessage")->value(t("Send"));
// Set up and display the actual page.
$template = new Theme_View("page.html", "other", "Contact");
$template->content = new View("contactowner_emailform.html");
$template->content->sendmail_form = $form;
print $template;
}
开发者ID:Weerwolf,项目名称:gallery3-contrib,代码行数:26,代码来源:contactowner.php
示例15: context_menu
static function context_menu($menu, $theme, $item)
{
$link = ORM::factory("bitly_link")->where("item_id", "=", $item->id)->find();
if (!$link->loaded() && $theme->item->owner->id == identity::active_user()->id) {
$menu->get("options_menu")->append(Menu::factory("link")->id("bitly")->label(t("Shorten link with bit.ly"))->url(url::site("bitly/shorten/{$item->id}?csrf={$theme->csrf}"))->css_class("g-bitly-shorten ui-icon-link"));
}
}
开发者ID:Retroguy,项目名称:gallery3-contrib,代码行数:7,代码来源:bitly_event.php
示例16: site_menu
static function site_menu($menu, $theme)
{
if (identity::active_user()->guest && module::get_var("registration", "policy") != "admin_only") {
$menu->append(Menu::factory("dialog")->id("register_users")->label(t("Register"))->url(url::site("register")));
}
return $menu;
}
开发者ID:ChrisRut,项目名称:gallery3-contrib,代码行数:7,代码来源:register_event.php
示例17: upgrade
public function upgrade()
{
if (php_sapi_name() == "cli") {
// @todo this may screw up some module installers, but we don't have a better answer at
// this time.
$_SERVER["HTTP_HOST"] = "example.com";
} else {
if (!identity::active_user()->admin && !Session::instance()->get("can_upgrade", false)) {
access::forbidden();
}
try {
access::verify_csrf();
} catch (Exception $e) {
url::redirect("upgrader");
}
}
$available = module::available();
// Upgrade gallery first
$gallery = $available["gallery"];
if ($gallery->code_version != $gallery->version) {
module::upgrade("gallery");
module::activate("gallery");
}
// Then upgrade the rest
$failed = array();
foreach (module::available() as $id => $module) {
if ($id == "gallery") {
continue;
}
if ($module->active && $module->code_version != $module->version) {
try {
module::upgrade($id);
} catch (Exception $e) {
// @todo assume it's MODULE_FAILED_TO_UPGRADE for now
$failed[] = $id;
}
}
}
// If the upgrade failed, this will get recreated
site_status::clear("upgrade_now");
// Clear any upgrade check strings, we are probably up to date.
site_status::clear("upgrade_checker");
if (php_sapi_name() == "cli") {
if ($failed) {
print "Upgrade completed ** WITH FAILURES **\n";
print "The following modules were not successfully upgraded:\n";
print " " . implode($failed, "\n ") . "\n";
print "Try getting newer versions or deactivating those modules\n";
} else {
print "Upgrade complete\n";
}
} else {
if ($failed) {
url::redirect("upgrader?failed=" . join(",", $failed));
} else {
url::redirect("upgrader");
}
}
}
开发者ID:HarriLu,项目名称:gallery3,代码行数:59,代码来源:upgrader.php
示例18: is_admin
function is_admin()
{
if (identity::active_user()->admin) {
print json_encode(array("result" => "success", "csrf" => access::csrf_token()));
return;
}
print json_encode(array("result" => "failure"));
}
开发者ID:Weerwolf,项目名称:gallery3-contrib,代码行数:8,代码来源:json_album.php
示例19: site_menu
static function site_menu($menu, $theme)
{
$item = $theme->item();
$user = identity::active_user();
if ($item && ($item->is_photo() || $item->is_movie()) && $user->admin) {
$menu->get("options_menu")->append(Menu::factory("link")->id("ratingsclear")->label(t("Clear all ratings/votes"))->url(url::site("ratings/clear/{$theme->item->id}"))->css_class("g-dialog-link")->css_id("g-ratings"));
}
}
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:8,代码来源:ratings_event.php
示例20: album_menu
static function album_menu($menu, $theme)
{
// Make sure the user can view maps before displaying one.
if (module::get_var("tagsmap", "restrict_maps") == true && identity::active_user()->guest) {
return;
}
$menu->append(Menu::factory("link")->id("tagsmap")->label(t("View Map"))->url(url::site("tagsmap/googlemap/"))->css_id("g-tagsmap-link"));
}
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:8,代码来源:tagsmap_event.php
注:本文中的identity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论