當前位置: 首頁>>代碼示例>>PHP>>正文


PHP identity::guest方法代碼示例

本文整理匯總了PHP中identity::guest方法的典型用法代碼示例。如果您正苦於以下問題:PHP identity::guest方法的具體用法?PHP identity::guest怎麽用?PHP identity::guest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在identity的用法示例。


在下文中一共展示了identity::guest方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: create_comment_for_guest_test

 public function create_comment_for_guest_test()
 {
     $comment = ORM::factory("comment");
     $comment->item_id = item::root()->id;
     $comment->text = "text";
     $comment->author_id = identity::guest()->id;
     $comment->guest_name = "name";
     $comment->guest_email = "email@email.com";
     $comment->guest_url = "http://url.com";
     $comment->save();
     $this->assert_equal("name", $comment->author_name());
     $this->assert_equal("email@email.com", $comment->author_email());
     $this->assert_equal("http://url.com", $comment->author_url());
     $this->assert_equal("text", $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:andyst,項目名稱:gallery3,代碼行數:31,代碼來源:Comment_Helper_Test.php

示例2: create_comment_for_guest_test

 public function create_comment_for_guest_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $comment = comment::create($root, identity::guest(), "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
     $this->assert_equal("name_{$rand}", $comment->author_name());
     $this->assert_equal("email_{$rand}", $comment->author_email());
     $this->assert_equal("url_{$rand}", $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,代碼行數:26,代碼來源:Comment_Helper_Test.php

示例3: deleting_an_item_deletes_its_comments_too_test

 public function deleting_an_item_deletes_its_comments_too_test()
 {
     $rand = rand();
     $album = album::create(ORM::factory("item", 1), "test_{$rand}", "test_{$rand}");
     $comment = comment::create($album, identity::guest(), "text_{$rand}", "name_{$rand}", "email_{$rand}", "url_{$rand}");
     $album->delete();
     $deleted_comment = ORM::factory("comment", $comment->id);
     $this->assert_false($deleted_comment->loaded);
 }
開發者ID:ChrisRut,項目名稱:gallery3,代碼行數:9,代碼來源:Comment_Event_Test.php

示例4: deleting_an_item_deletes_its_comments_too_test

 public function deleting_an_item_deletes_its_comments_too_test()
 {
     $album = test::random_album();
     $comment = ORM::factory("comment");
     $comment->item_id = $album->id;
     $comment->author_id = identity::guest()->id;
     $comment->guest_name = "test";
     $comment->text = "text";
     $comment->save();
     $album->delete();
     $this->assert_false(ORM::factory("comment", $comment->id)->loaded());
 }
開發者ID:andyst,項目名稱:gallery3,代碼行數:12,代碼來源:Comment_Event_Test.php

示例5: viewable_test

 public function viewable_test()
 {
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), rand(), rand());
     $item = self::_create_random_item($album);
     identity::set_active_user(identity::guest());
     // We can see the item when permissions are granted
     access::allow(identity::everybody(), "view", $album);
     $this->assert_equal(1, ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
     // We can't see the item when permissions are denied
     access::deny(identity::everybody(), "view", $album);
     $this->assert_equal(0, ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
 }
開發者ID:viosca,項目名稱:gallery3,代碼行數:13,代碼來源:Item_Helper_Test.php

示例6: viewable_test

 public function viewable_test()
 {
     $album = test::random_album();
     $item = test::random_photo($album);
     $album->reload();
     identity::set_active_user(identity::guest());
     // We can see the item when permissions are granted
     access::allow(identity::everybody(), "view", $album);
     $this->assert_equal(1, ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
     // We can't see the item when permissions are denied
     access::deny(identity::everybody(), "view", $album);
     $this->assert_equal(0, ORM::factory("item")->viewable()->where("id", "=", $item->id)->count_all());
 }
開發者ID:assad2012,項目名稱:gallery3-appfog,代碼行數:13,代碼來源:Item_Helper_Test.php

示例7: post_fails_without_permissions_test

 public function post_fails_without_permissions_test()
 {
     access::deny(identity::everybody(), "edit", item::root());
     identity::set_active_user(identity::guest());
     try {
         $request->params->name = "test tag";
         tags_rest::post($request);
     } catch (Exception $e) {
         $this->assert_equal(403, $e->getCode());
         return;
     }
     $this->assert_true(false, "Shouldnt get here");
 }
開發者ID:joericochuyt,項目名稱:gallery3,代碼行數:13,代碼來源:Tags_Rest_Helper_Test.php

示例8: cant_view_comments_for_unviewable_items_test

 public function cant_view_comments_for_unviewable_items_test()
 {
     $root = ORM::factory("item", 1);
     $album = album::create($root, rand(), rand(), rand());
     $comment = comment::create($album, identity::guest(), "text", "name", "email", "url");
     identity::set_active_user(identity::guest());
     // We can see the comment when permissions are granted on the album
     access::allow(identity::everybody(), "view", $album);
     $this->assert_equal(1, ORM::factory("comment")->viewable()->where("comments.id", "=", $comment->id)->count_all());
     // We can't see the comment when permissions are denied on the album
     access::deny(identity::everybody(), "view", $album);
     $this->assert_equal(0, ORM::factory("comment")->viewable()->where("comments.id", "=", $comment->id)->count_all());
 }
開發者ID:viosca,項目名稱:gallery3,代碼行數:13,代碼來源:Comment_Model_Test.php

示例9: setup

 public function setup()
 {
     Input::instance()->ip_address = "1.1.1.1";
     request::set_user_agent("Akismet_Helper_Test");
     $root = ORM::factory("item", 1);
     $this->_comment = comment::create($root, identity::guest(), "This is a comment", "John Doe", "john@gallery2.org", "http://gallery2.org");
     foreach ($this->_comment->list_fields("comments") as $name => $field) {
         if (strpos($name, "server_") === 0) {
             $this->_comment->{$name} = substr($name, strlen("server_"));
         }
     }
     $this->_comment->save();
     module::set_var("akismet", "api_key", "TEST_KEY");
 }
開發者ID:viosca,項目名稱:gallery3,代碼行數:14,代碼來源:Akismet_Helper_Test.php

示例10: cant_view_comments_for_unviewable_items_test

 public function cant_view_comments_for_unviewable_items_test()
 {
     $album = test::random_album();
     $comment = ORM::factory("comment");
     $comment->item_id = $album->id;
     $comment->author_id = identity::admin_user()->id;
     $comment->text = "text";
     $comment->save();
     identity::set_active_user(identity::guest());
     // We can see the comment when permissions are granted on the album
     access::allow(identity::everybody(), "view", $album);
     $this->assert_true(ORM::factory("comment")->viewable()->where("comments.id", "=", $comment->id)->count_all());
     // We can't see the comment when permissions are denied on the album
     access::deny(identity::everybody(), "view", $album);
     $this->assert_false(ORM::factory("comment")->viewable()->where("comments.id", "=", $comment->id)->count_all());
 }
開發者ID:kandsten,項目名稱:gallery3,代碼行數:16,代碼來源:Comment_Model_Test.php

示例11: set_active_user

 static function set_active_user($access_token)
 {
     if (empty($access_token)) {
         identity::set_active_user(identity::guest());
         return;
     }
     $key = ORM::factory("user_access_token")->where("access_key", "=", $access_token)->find();
     if (!$key->loaded()) {
         throw new Rest_Exception("Forbidden", 403);
     }
     $user = identity::lookup_user($key->user_id);
     if (empty($user)) {
         throw new Rest_Exception("Forbidden", 403);
     }
     identity::set_active_user($user);
 }
開發者ID:andyst,項目名稱:gallery3,代碼行數:16,代碼來源:rest.php

示例12: post_fails_without_permissions_test

 public function post_fails_without_permissions_test()
 {
     // We have to remove edit permissions from everywhere
     Database::instance()->query("UPDATE {access_caches} SET edit_1=0");
     identity::set_active_user(identity::guest());
     try {
         $request = new stdClass();
         $request->params = new stdClass();
         $request->params->name = "test tag";
         tags_rest::post($request);
     } catch (Exception $e) {
         $this->assert_equal(403, $e->getCode());
         return;
     }
     $this->assert_true(false, "Shouldnt get here");
 }
開發者ID:andyst,項目名稱:gallery3,代碼行數:16,代碼來源:Tags_Rest_Helper_Test.php

示例13: illegal_access_test

 public function illegal_access_test()
 {
     $album = test::random_album();
     $photo = test::random_photo($album);
     $album->reload();
     access::deny(identity::everybody(), "view", $album);
     identity::set_active_user(identity::guest());
     $request = new stdClass();
     $request->url = rest::url("data", $photo, "thumb");
     $request->params = new stdClass();
     $request->params->size = "thumb";
     try {
         data_rest::get($request);
         $this->assert_true(false);
     } catch (Kohana_404_Exception $e) {
         // pass
     }
 }
開發者ID:HarriLu,項目名稱:gallery3,代碼行數:18,代碼來源:Data_Rest_Helper_Test.php

示例14: _make_comment

 private function _make_comment()
 {
     $comment = ORM::factory("comment");
     $comment->item_id = item::root()->id;
     $comment->author_id = identity::guest()->id;
     $comment->text = "This is a comment";
     $comment->guest_name = "John Doe";
     $comment->guest_email = "john@gallery2.org";
     $comment->guest_url = "http://gallery2.org";
     $comment->save();
     // Set the server fields to a known placeholder
     foreach ($comment->list_fields("comments") as $name => $field) {
         if (strpos($name, "server_") === 0) {
             $comment->{$name} = substr($name, strlen("server_"));
         }
     }
     return $comment->save();
 }
開發者ID:Joe7,項目名稱:gallery3,代碼行數:18,代碼來源:Akismet_Helper_Test.php

示例15: set_active_user

 static function set_active_user($access_key)
 {
     if (empty($access_key)) {
         if (module::get_var("rest", "allow_guest_access")) {
             identity::set_active_user(identity::guest());
             return;
         } else {
             throw new Rest_Exception("Forbidden", 403);
         }
     }
     $key = ORM::factory("user_access_key")->where("access_key", "=", $access_key)->find();
     if (!$key->loaded()) {
         throw new Rest_Exception("Forbidden", 403);
     }
     $user = identity::lookup_user($key->user_id);
     if (empty($user)) {
         throw new Rest_Exception("Forbidden", 403);
     }
     identity::set_active_user($user);
 }
開發者ID:kandsten,項目名稱:gallery3,代碼行數:20,代碼來源:rest.php


注:本文中的identity::guest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。