当前位置: 首页>>代码示例>>PHP>>正文


PHP identity::active_user方法代码示例

本文整理汇总了PHP中identity::active_user方法的典型用法代码示例。如果您正苦于以下问题:PHP identity::active_user方法的具体用法?PHP identity::active_user怎么用?PHP identity::active_user使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在identity的用法示例。


在下文中一共展示了identity::active_user方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: 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

示例3: change_photo_test

 public function change_photo_test()
 {
     $controller = new Photos_Controller();
     $root = ORM::factory("item", 1);
     $photo = photo::create($root, MODPATH . "gallery/tests/test.jpg", "test.jpeg", "test", "test", identity::active_user()->id, "slug");
     $orig_name = $photo->name;
     $_POST["filename"] = "test.jpeg";
     $_POST["name"] = "new name";
     $_POST["title"] = "new title";
     $_POST["description"] = "new description";
     $_POST["slug"] = "new-slug";
     $_POST["csrf"] = access::csrf_token();
     access::allow(identity::everybody(), "edit", $root);
     ob_start();
     $controller->update($photo->id);
     $photo->reload();
     $results = ob_get_contents();
     ob_end_clean();
     $this->assert_equal(json_encode(array("result" => "success", "location" => "HTTP_REFERER")), $results);
     $this->assert_equal("new-slug", $photo->slug);
     $this->assert_equal("new title", $photo->title);
     $this->assert_equal("new description", $photo->description);
     // We don't change the name, yet.
     $this->assert_equal($orig_name, $photo->name);
 }
开发者ID:viosca,项目名称:gallery3,代码行数:25,代码来源:Photos_Controller_Test.php

示例4: 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

示例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: _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

示例7: 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

示例8: 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

示例9: 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

示例10: change

 function change($command, $group_id, $perm_id, $item_id)
 {
     access::verify_csrf();
     $group = identity::lookup_group($group_id);
     $perm = ORM::factory("permission", $perm_id);
     $item = ORM::factory("item", $item_id);
     access::required("view", $item);
     access::required("edit", $item);
     if (!empty($group) && $perm->loaded() && $item->loaded()) {
         switch ($command) {
             case "allow":
                 access::allow($group, $perm->name, $item);
                 break;
             case "deny":
                 access::deny($group, $perm->name, $item);
                 break;
             case "reset":
                 access::reset($group, $perm->name, $item);
                 break;
         }
         // If the active user just took away their own edit permissions, give it back.
         if ($perm->name == "edit") {
             if (!access::user_can(identity::active_user(), "edit", $item)) {
                 access::allow($group, $perm->name, $item);
             }
         }
     }
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:28,代码来源:permissions.php

示例11: 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

示例12: __construct

 public function __construct($theme = null)
 {
     if (!identity::active_user()->admin) {
         access::forbidden();
     }
     parent::__construct();
 }
开发者ID:ChrisRut,项目名称:gallery3,代码行数:7,代码来源:admin.php

示例13: 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

示例14: 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

示例15: 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


注:本文中的identity::active_user方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。