本文整理汇总了PHP中access类的典型用法代码示例。如果您正苦于以下问题:PHP access类的具体用法?PHP access怎么用?PHP access使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了access类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 (!user::active()->admin && !Session::instance()->get("can_upgrade", false)) {
access::forbidden();
}
}
// Upgrade gallery and user first
module::install("gallery");
module::install("user");
// Then upgrade the rest
foreach (module::available() as $id => $module) {
if ($id == "gallery") {
continue;
}
if ($module->active && $module->code_version != $module->version) {
module::install($id);
}
}
if (php_sapi_name() == "cli") {
print "Upgrade complete\n";
} else {
url::redirect("upgrader?done=1");
}
}
示例2: saveprefs
public function saveprefs()
{
// Prevent Cross Site Request Forgery
access::verify_csrf();
$form = $this->_get_admin_form();
// Figure out which boxes where checked
$shareOpts_array = Input::instance()->post("ShareOptions");
$IconsButton = false;
$HTMLLinksButton = false;
for ($i = 0; $i < count($shareOpts_array); $i++) {
if ($shareOpts_array[$i] == "Icons") {
$IconsButton = true;
}
if ($shareOpts_array[$i] == "HTMLLinks") {
$HTMLLinksButton = true;
}
}
// Save Settings.
module::set_var("sharephoto", "Icons", $IconsButton);
module::set_var("sharephoto", "HTMLLinks", $HTMLLinksButton);
message::success(t("Your Selection Has Been Saved."));
// Load Admin page.
$view = new Admin_View("admin.html");
$view->content = new View("admin_sharephoto.html");
$view->content->sharephoto_form = $form;
print $view;
}
示例3: saveprefs
public function saveprefs()
{
// Process the admin form.
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Save user specified settings to the database.
$str_slideshow_url = Input::instance()->post("slideshow_url");
module::set_var("minislideshow", "slideshow_url", $str_slideshow_url);
$str_slideshow_shuffle = Input::instance()->post("shuffle");
module::set_var("minislideshow", "shuffle", $str_slideshow_shuffle);
$str_slideshow_dropshadow = Input::instance()->post("dropshadow");
module::set_var("minislideshow", "dropshadow", $str_slideshow_dropshadow);
$str_slideshow_show_title = Input::instance()->post("show_title");
module::set_var("minislideshow", "show_title", $str_slideshow_show_title);
$str_slideshow_trans_in_type = Input::instance()->post("trans_in_type");
module::set_var("minislideshow", "trans_in_type", $str_slideshow_trans_in_type);
$str_slideshow_trans_out_type = Input::instance()->post("trans_out_type");
module::set_var("minislideshow", "trans_out_type", $str_slideshow_trans_out_type);
$str_slideshow_mask = Input::instance()->post("mask");
module::set_var("minislideshow", "mask", $str_slideshow_mask);
$str_slideshow_use_full_image = Input::instance()->post("use_full_image");
module::set_var("minislideshow", "use_full_image", $str_slideshow_use_full_image);
$str_slideshow_delay = Input::instance()->post("delay");
module::set_var("minislideshow", "delay", $str_slideshow_delay);
// Display a success message and load the admin screen.
message::success(t("Your Settings Have Been Saved."));
$view = new Admin_View("admin.html");
$view->content = new View("admin_minislideshow.html");
$view->content->minislideshow_form = $this->_get_admin_form();
print $view;
}
示例4: handler
public function handler()
{
access::verify_csrf();
$form = $this->_get_form();
if ($form->validate()) {
module::set_var("social_share", "general_impage_only", $form->general_settings->general_impage_only->value);
module::set_var("social_share", "facebook_share_enabled", $form->facebook_share_settings->facebook_share_enabled->value);
module::set_var("social_share", "facebook_share_layout", $form->facebook_share_settings->facebook_share_layout->value);
module::set_var("social_share", "facebook_share_link_text", $form->facebook_share_settings->facebook_share_link_text->value);
module::set_var("social_share", "facebook_like_enabled", $form->facebook_like_settings->facebook_like_enabled->value);
module::set_var("social_share", "facebook_like_appId", $form->facebook_like_settings->facebook_like_appId->value);
module::set_var("social_share", "facebook_like_adminId", $form->facebook_like_settings->facebook_like_adminId->value);
module::set_var("social_share", "facebook_like_site_name", $form->facebook_like_settings->facebook_like_site_name->value);
module::set_var("social_share", "facebook_like_code_type", $form->facebook_like_settings->facebook_like_code_type->value);
module::set_var("social_share", "facebook_like_show_faces", $form->facebook_like_settings->facebook_like_show_faces->value, true);
module::set_var("social_share", "facebook_like_send", $form->facebook_like_settings->facebook_like_send->value, true);
module::set_var("social_share", "facebook_like_action", $form->facebook_like_settings->facebook_like_action->value);
module::set_var("social_share", "facebook_like_layout", $form->facebook_like_settings->facebook_like_layout->value);
module::set_var("social_share", "google_enabled", $form->google_settings->google_enabled->value);
module::set_var("social_share", "google_size", $form->google_settings->google_size->value);
module::set_var("social_share", "google_annotation", $form->google_settings->google_annotation->value);
module::set_var("social_share", "pinterest_enabled", $form->pinterest_settings->pinterest_enabled->value);
module::set_var("social_share", "pinterest_count_location", $form->pinterest_settings->pinterest_count_location->value);
module::set_var("social_share", "twitter_enabled", $form->twitter_settings->twitter_enabled->value);
module::set_var("social_share", "twitter_count_location", $form->twitter_settings->twitter_count_location->value);
module::set_var("social_share", "twitter_size", $form->twitter_settings->twitter_size->value);
message::success(t("Your settings have been saved."));
url::redirect("admin/social_share");
}
print $this->_get_view($form);
}
示例5: delete
static function delete($request)
{
list($tag, $item) = rest::resolve($request->url);
access::required("edit", $item);
$tag->remove($item);
$tag->save();
}
示例6: saveprefs
public function saveprefs()
{
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Figure out which boxes where checked
$dlLinks_array = Input::instance()->post("DownloadLinkOptions");
$fButton = false;
$download_original_button = false;
for ($i = 0; $i < count($dlLinks_array); $i++) {
if ($dlLinks_array[$i] == "fButton") {
$fButton = true;
}
}
if (module::is_active("keeporiginal")) {
$keeporiginal_array = Input::instance()->post("DownloadOriginalOptions");
for ($i = 0; $i < count($keeporiginal_array); $i++) {
if ($keeporiginal_array[$i] == "DownloadOriginalImage") {
$download_original_button = true;
}
}
module::set_var("downloadfullsize", "DownloadOriginalImage", $download_original_button);
}
// Save Settings.
module::set_var("downloadfullsize", "fButton", $fButton);
message::success(t("Your Selection Has Been Saved."));
// Load Admin page.
$view = new Admin_View("admin.html");
$view->content = new View("admin_downloadfullsize.html");
$view->content->downloadlinks_form = $this->_get_admin_form();
print $view;
}
示例7: rename
public function rename($id)
{
access::verify_csrf();
$tag = ORM::factory("tag", $id);
if (!$tag->loaded) {
kohana::show_404();
}
$form = tag::get_rename_form($tag);
$valid = $form->validate();
if ($valid) {
$new_name = $form->rename_tag->inputs["name"]->value;
$new_tag = ORM::factory("tag")->where("name", $new_name)->find();
if ($new_tag->loaded) {
$form->rename_tag->inputs["name"]->add_error("in_use", 1);
$valid = false;
}
}
if ($valid) {
$old_name = $tag->name;
$tag->name = $new_name;
$tag->save();
$message = t("Renamed tag %old_name to %new_name", array("old_name" => $old_name, "new_name" => $tag->name));
message::success($message);
log::success("tags", $message);
print json_encode(array("result" => "success", "location" => url::site("admin/tags"), "tag_id" => $tag->id, "new_tagname" => html::clean($tag->name)));
} else {
print json_encode(array("result" => "error", "form" => $form->__toString()));
}
}
示例8: edit
public function edit()
{
access::verify_csrf();
$form = $this->_get_admin_form();
if ($form->validate()) {
$options = $form->tag_cloud_options;
$valid = true;
if (preg_match("/^0x[0-9A-Fa-f]{6}\$/", $options->tagcolor->value) == 0) {
$options->tagcolor->add_error("not_valid", 1);
$valid = false;
}
if (preg_match("/^0x[0-9A-Fa-f]{6}\$/", $options->background_color->value) == 0) {
$options->background_color->add_error("not_valid", 1);
$valid = false;
}
if ($valid) {
module::set_var("tag_cloud", "tagcolor", $options->tagcolor->value);
module::set_var("tag_cloud", "mouseover", $options->mouseover->value);
module::set_var("tag_cloud", "background_color", $options->background_color->value);
module::set_var("tag_cloud", "transparent", $options->transparent->value);
module::set_var("tag_cloud", "speed", $options->speed->value);
module::set_var("tag_cloud", "distribution", $options->distribution->value);
message::success(t("Tag cloud options updated successfully"));
url::redirect("admin/tag_cloud");
}
}
$view = new Admin_View("admin.html");
$view->content = new View("admin_tag_cloud.html");
$view->content->form = $form;
print $view;
}
示例9: initialize
static function initialize()
{
$db = Database::instance();
$db->query("CREATE TABLE IF NOT EXISTS {users} (\n `id` int(9) NOT NULL auto_increment,\n `name` varchar(32) NOT NULL,\n `full_name` varchar(255) NOT NULL,\n `password` varchar(64) NOT NULL,\n `login_count` int(10) unsigned NOT NULL DEFAULT 0,\n `last_login` int(10) unsigned NOT NULL DEFAULT 0,\n `email` varchar(64) default NULL,\n `admin` BOOLEAN default 0,\n `guest` BOOLEAN default 0,\n `hash` char(32) default NULL,\n `url` varchar(255) default NULL,\n `locale` char(10) default NULL,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`hash`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {groups} (\n `id` int(9) NOT NULL auto_increment,\n `name` char(64) default NULL,\n `special` BOOLEAN default 0,\n PRIMARY KEY (`id`),\n UNIQUE KEY(`name`))\n DEFAULT CHARSET=utf8;");
$db->query("CREATE TABLE IF NOT EXISTS {groups_users} (\n `group_id` int(9) NOT NULL,\n `user_id` int(9) NOT NULL,\n PRIMARY KEY (`group_id`, `user_id`),\n UNIQUE KEY(`user_id`, `group_id`))\n DEFAULT CHARSET=utf8;");
$everybody = ORM::factory("group");
$everybody->name = "Everybody";
$everybody->special = true;
$everybody->save();
$registered = ORM::factory("group");
$registered->name = "Registered Users";
$registered->special = true;
$registered->save();
$guest = ORM::factory("user");
$guest->name = "guest";
$guest->full_name = "Guest User";
$guest->password = "";
$guest->guest = true;
$guest->save();
$admin = ORM::factory("user");
$admin->name = "admin";
$admin->full_name = "Gallery Administrator";
$admin->password = "admin";
$admin->email = "unknown@unknown.com";
$admin->admin = true;
$admin->save();
$root = ORM::factory("item", 1);
access::allow($everybody, "view", $root);
access::allow($everybody, "view_full", $root);
access::allow($registered, "view", $root);
access::allow($registered, "view_full", $root);
module::set_version("user", 2);
module::set_var("user", "mininum_password_length", 5);
}
示例10: get
static function get($block_id, $theme)
{
$block = "";
// Only display on album pages that the user can edit.
$item = $theme->item();
if (!$item || !$item->is_album() || !access::can("edit", $item)) {
return;
}
switch ($block_id) {
case "batch_tag":
// Make a new sidebar block.
$block = new Block();
$block->css_id = "g-batch-tag";
$block->title = t("Batch Tag");
$block->content = new View("batchtag_block.html");
// Make a new form to place in the sidebar block.
$form = new Forge("batchtag/tagitems", "", "post", array("id" => "g-batch-tag-form"));
$label = t("Tag everything in this album:");
$group = $form->group("add_tag")->label("Add Tag");
$group->input("name")->label($label)->rules("required|length[1,64]");
$group->checkbox("tag_subitems")->label(t("Include sub-albums?"))->value(true)->checked(false);
$group->hidden("item_id")->value($item->id);
$group->submit("")->value(t("Add Tag"));
$block->content->batch_tag_form = $form;
break;
}
return $block;
}
示例11: rename
public function rename($id)
{
access::verify_csrf();
$tag = ORM::factory("tag", $id);
if (!$tag->loaded()) {
throw new Kohana_404_Exception();
}
$in_place_edit = InPlaceEdit::factory($tag->name)->action("admin/tags/rename/{$tag->id}")->rules(array("required", "length[1,64]"));
if ($in_place_edit->validate()) {
$old_name = $tag->name;
$new_name_or_list = $in_place_edit->value();
$tag_list = explode(",", $new_name_or_list);
$tag->name = array_shift($tag_list);
$tag->save();
if (!empty($tag_list)) {
$this->_copy_items_for_tags($tag, $tag_list);
$message = t("Split tag <i>%old_name</i> into <i>%tag_list</i>", array("old_name" => $old_name, "tag_list" => $new_name_or_list));
} else {
$message = t("Renamed tag <i>%old_name</i> to <i>%new_name</i>", array("old_name" => $old_name, "new_name" => $tag->name));
}
message::success($message);
log::success("tags", $message);
json::reply(array("result" => "success", "location" => url::site("admin/tags")));
} else {
json::reply(array("result" => "error", "form" => (string) $in_place_edit->render()));
}
}
示例12: site_menu
static function site_menu($menu, $theme)
{
$item = $theme->item();
if ($item && $item->is_album() && access::can("edit", $item)) {
$menu->get("options_menu")->append(Menu::factory("link")->id("captionator")->label(t("Caption album"))->css_id("g-menu-captionator-link")->url(url::site("captionator/dialog/{$item->id}")));
}
}
示例13: site_menu
static function site_menu($menu, $theme)
{
$item = $theme->item();
if ($can_add = $item && access::can("add", $item)) {
$menu->get("add_menu")->append(Menu::factory("dialog")->id("embed_add")->label(t("Embed Video"))->url(url::site("form/add/embedded_videos/{$item->id}")));
}
}
示例14: saveprefs
public function saveprefs()
{
// Save user preferences to the database.
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Make sure the user filled out the form properly.
$form = $this->_get_admin_form();
if ($form->validate()) {
Kohana_Log::add("error", print_r($form, 1));
// Save settings to Gallery's database.
foreach (iptc::keys() as $keyword => $iptcvar) {
$checkbox = false;
for ($i = 0; $i < count($form->Global->{$keyword}); $i++) {
if ($form->Global->{$keyword}->value[$i] == $keyword) {
$checkbox = true;
}
}
module::set_var("iptc", "show_" . $keyword, $checkbox);
}
// Display a success message and redirect back to the TagsMap admin page.
message::success(t("Your settings have been saved."));
url::redirect("admin/iptc");
}
// Else show the page with errors
$view = new Admin_View("admin.html");
$view->content = new View("admin_iptc.html");
$view->content->iptc_form = $form;
print $view;
}
示例15: save
public function save($module_name, $var_name)
{
access::verify_csrf();
module::set_var($module_name, $var_name, Input::instance()->post("value"));
message::success(t("Saved value for %var (%module_name)", array("var" => $var_name, "module_name" => $module_name)));
json::reply(array("result" => "success"));
}