コード例 #1
0
ファイル: gallery_event.php プロジェクト: andyst/gallery3
 static function identity_provider_changed($old_provider, $new_provider)
 {
     $admin = identity::admin_user();
     db::build()->update("tasks")->set("owner_id", $admin->id)->execute();
     db::build()->update("items")->set("owner_id", $admin->id)->execute();
     db::build()->update("logs")->set("user_id", $admin->id)->execute();
 }
コード例 #2
0
 private function _get_admin_view($form, $errors)
 {
     $v = new Admin_View("admin.html");
     $v->content = new View("admin_register.html");
     $v->content->action = "admin/register/update";
     $v->content->policy_list = array("admin_only" => t("Only site administrators can create new user accounts."), "visitor" => t("Visitors can create accounts and no administrator approval is required."), "admin_approval" => t("Visitors can create accounts but administrator approval is required."));
     $admin = identity::admin_user();
     $v->content->disable_email = empty($admin->email) || $form["policy"] == "admin_only" ? "disabled" : "";
     if (empty($admin->email)) {
         module::set_var("registration", "email_verification", false);
     }
     $v->content->group_list = array();
     foreach (identity::groups() as $group) {
         if ($group->id != identity::everybody()->id && $group->id != identity::registered_users()->id) {
             $v->content->group_list[$group->id] = $group->name;
         }
     }
     $hidden = array("csrf" => access::csrf_token());
     if (count($v->content->group_list)) {
         $v->content->group_list = array("" => t("Choose the default group")) + $v->content->group_list;
     } else {
         $hidden["group"] = "";
     }
     $v->content->hidden = $hidden;
     $v->content->pending = ORM::factory("pending_user")->find_all();
     $v->content->activate = "admin/register/activate";
     $v->content->form = $form;
     $v->content->errors = $errors;
     return $v;
 }
コード例 #3
0
 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));
 }
コード例 #4
0
ファイル: gallery_event.php プロジェクト: ChrisRut/gallery3
 static function identity_provider_changed($old_provider, $new_provider)
 {
     $admin = identity::admin_user();
     $db = Database::instance();
     $db->from("tasks")->set(array("owner_id" => $admin->id))->where("1 = 1")->update();
     $db->from("items")->set(array("owner_id" => $admin->id))->where("1 = 1")->update();
     $db->from("logs")->set(array("user_id" => $admin->id))->where("1 = 1")->update();
 }
コード例 #5
0
 public function post_test()
 {
     identity::set_active_user(identity::admin_user());
     $request = new stdClass();
     $request->params = new stdClass();
     $request->params->entity = new stdClass();
     $request->params->entity->name = "test tag";
     $this->assert_equal(array("url" => url::site("rest/tag/1")), tags_rest::post($request));
 }
コード例 #6
0
ファイル: gallery_event.php プロジェクト: HarriLu/gallery3
 static function identity_provider_changed($old_provider, $new_provider)
 {
     $admin = identity::admin_user();
     db::build()->update("tasks")->set("owner_id", $admin->id)->execute();
     db::build()->update("items")->set("owner_id", $admin->id)->execute();
     db::build()->update("logs")->set("user_id", $admin->id)->execute();
     module::set_var("gallery", "email_from", $admin->email);
     module::set_var("gallery", "email_reply_to", $admin->email);
 }
コード例 #7
0
 static function user_before_delete($user)
 {
     // When deleting a user, all of that user's items get re-assigned to the admin account,
     //   so the file sizes need to be reassigned to the admin user as well.
     $admin = identity::admin_user();
     $admin_record = ORM::factory("users_space_usage")->where("owner_id", "=", $admin->id)->find();
     $deleted_user_record = ORM::factory("users_space_usage")->where("owner_id", "=", $user->id)->find();
     if ($deleted_user_record->loaded()) {
         $admin_record->fullsize = $admin_record->fullsize + $deleted_user_record->fullsize;
         $admin_record->resize = $admin_record->resize + $deleted_user_record->resize;
         $admin_record->thumb = $admin_record->thumb + $deleted_user_record->thumb;
         $admin_record->save();
         $deleted_user_record->delete();
     }
 }
コード例 #8
0
 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());
 }
コード例 #9
0
 public function teardown()
 {
     try {
         $group = identity::lookup_group_by_name("access_test");
         if (!empty($group)) {
             $group->delete();
         }
     } catch (Exception $e) {
     }
     try {
         access::delete_permission("access_test");
     } catch (Exception $e) {
     }
     try {
         $user = identity::lookup_user_by_name("access_test");
         if (!empty($user)) {
             $user->delete();
         }
     } catch (Exception $e) {
     }
     // Reset some permissions that we mangle below
     access::allow(identity::everybody(), "view", item::root());
     identity::set_active_user(identity::admin_user());
 }
コード例 #10
0
 public function teardown()
 {
     identity::set_active_user(identity::admin_user());
 }
コード例 #11
0
 public function teardown()
 {
     list($_GET, $_POST, $_SERVER) = $this->_save;
     identity::set_active_user(identity::admin_user());
 }