summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMarc Poulhiès <github@kataplop.net>2009-06-11 09:06:31 +0200
committerMarc Poulhiès <github@kataplop.net>2009-06-11 09:06:31 +0200
commit7815315dbf98f87c4e115a09cb116ac0bc4ca62e (patch)
tree700d62e41c666d282d3a7eb2287e187d841e45c0 /modules
parent315969e24e3ce4cbf06e5160e4738c083b2338be (diff)
parent68fd196d66e2d21f571ff3b5a673f18cd129abf9 (diff)
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules')
-rw-r--r--modules/gallery/controllers/admin_maintenance.php8
-rw-r--r--modules/gallery/controllers/admin_theme_options.php (renamed from modules/gallery/controllers/admin_theme_details.php)6
-rw-r--r--modules/gallery/controllers/packager.php (renamed from modules/gallery/controllers/package.php)10
-rw-r--r--modules/gallery/controllers/upgrader.php29
-rw-r--r--modules/gallery/views/kohana_error_page.php2
-rw-r--r--modules/gallery/views/permissions_browse.html.php2
-rw-r--r--modules/gallery/views/upgrader.html.php16
-rw-r--r--modules/gallery_unit_test/controllers/gallery_unit_test.php7
-rw-r--r--modules/rss/helpers/rss_theme.php16
-rw-r--r--modules/user/controllers/users.php2
10 files changed, 73 insertions, 25 deletions
diff --git a/modules/gallery/controllers/admin_maintenance.php b/modules/gallery/controllers/admin_maintenance.php
index c169de75..7c5934a3 100644
--- a/modules/gallery/controllers/admin_maintenance.php
+++ b/modules/gallery/controllers/admin_maintenance.php
@@ -61,7 +61,7 @@ class Admin_Maintenance_Controller extends Admin_Controller {
log::info("tasks", t("Task %task_name started (task id %task_id)",
array("task_name" => $task->name, "task_id" => $task->id)),
- html::anchor(url::site("admin/maintenance"), t("maintenance")));
+ html::anchor("admin/maintenance", t("maintenance")));
print $view;
}
@@ -81,7 +81,7 @@ class Admin_Maintenance_Controller extends Admin_Controller {
log::info("tasks", t("Task %task_name resumed (task id %task_id)",
array("task_name" => $task->name, "task_id" => $task->id)),
- html::anchor(url::site("admin/maintenance"), t("maintenance")));
+ html::anchor("admin/maintenance", t("maintenance")));
print $view;
}
@@ -152,14 +152,14 @@ class Admin_Maintenance_Controller extends Admin_Controller {
case "success":
log::success("tasks", t("Task %task_name completed (task id %task_id)",
array("task_name" => $task->name, "task_id" => $task->id)),
- html::anchor(url::site("admin/maintenance"), t("maintenance")));
+ html::anchor("admin/maintenance", t("maintenance")));
message::success(t("Task completed successfully"));
break;
case "error":
log::error("tasks", t("Task %task_name failed (task id %task_id)",
array("task_name" => $task->name, "task_id" => $task->id)),
- html::anchor(url::site("admin/maintenance"), t("maintenance")));
+ html::anchor("admin/maintenance", t("maintenance")));
message::success(t("Task failed"));
break;
}
diff --git a/modules/gallery/controllers/admin_theme_details.php b/modules/gallery/controllers/admin_theme_options.php
index 97696df5..2716ed93 100644
--- a/modules/gallery/controllers/admin_theme_details.php
+++ b/modules/gallery/controllers/admin_theme_options.php
@@ -17,10 +17,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Admin_Theme_Details_Controller extends Admin_Controller {
+class Admin_Theme_Options_Controller extends Admin_Controller {
public function index() {
$view = new Admin_View("admin.html");
- $view->content = new View("admin_theme_details.html");
+ $view->content = new View("admin_theme_options.html");
$view->content->form = theme::get_edit_form_admin();
print $view;
}
@@ -58,7 +58,7 @@ class Admin_Theme_Details_Controller extends Admin_Controller {
module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value);
message::success(t("Updated theme details"));
- url::redirect("admin/theme_details");
+ url::redirect("admin/theme_options");
} else {
$view = new Admin_View("admin.html");
$view->content = $form;
diff --git a/modules/gallery/controllers/package.php b/modules/gallery/controllers/packager.php
index f5146fc8..da0a7983 100644
--- a/modules/gallery/controllers/package.php
+++ b/modules/gallery/controllers/packager.php
@@ -17,12 +17,14 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
-class Package_Controller extends Controller {
- function index() {
- if (PHP_SAPI != 'cli') {
- Kohana::show_404();
+class Packager_Controller extends Controller {
+ function package() {
+ if (PHP_SAPI != "cli") {
+ access::forbidden();
}
+ $_SERVER["HTTP_HOST"] = "example.com";
+
try {
$this->_reset(); // empty and reinstall the standard modules
$this->_dump_database(); // Dump the database
diff --git a/modules/gallery/controllers/upgrader.php b/modules/gallery/controllers/upgrader.php
index 0d5bb4f6..5eb96fdd 100644
--- a/modules/gallery/controllers/upgrader.php
+++ b/modules/gallery/controllers/upgrader.php
@@ -19,20 +19,33 @@
*/
class Upgrader_Controller extends Controller {
public function index() {
- // Todo: give the admin a chance to log in here
- if (!user::active()->admin) {
- access::forbidden();
+ $session = Session::instance();
+
+ // Make sure we have an upgrade token
+ if (!($upgrade_token = $session->get("upgrade_token", null))) {
+ $session->set("upgrade_token", $upgrade_token = md5(rand()));
+ }
+
+ // If the upgrade token exists, then bless this session
+ if (file_exists(TMPPATH . $upgrade_token)) {
+ $session->set("can_upgrade", true);
+ @unlink(TMPPATH . $upgrade_token);
}
$view = new View("upgrader.html");
+ $view->can_upgrade = user::active()->admin || $session->get("can_upgrade");
+ $view->upgrade_token = $upgrade_token;
$view->available = module::available();
$view->done = Input::instance()->get("done");
print $view;
}
public function upgrade() {
- // Todo: give the admin a chance to log in here
- if (!user::active()->admin) {
+ 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();
}
@@ -51,6 +64,10 @@ class Upgrader_Controller extends Controller {
}
}
- url::redirect("upgrader?done=1");
+ if (php_sapi_name() == "cli") {
+ print "Upgrade complete\n";
+ } else {
+ url::redirect("upgrader?done=1");
+ }
}
}
diff --git a/modules/gallery/views/kohana_error_page.php b/modules/gallery/views/kohana_error_page.php
index d9bf9698..6bf48549 100644
--- a/modules/gallery/views/kohana_error_page.php
+++ b/modules/gallery/views/kohana_error_page.php
@@ -59,7 +59,7 @@
</head>
<body>
<? try { $user = user::active(); } catch (Exception $e) { } ?>
- <? $admin = isset($user) && $user->admin ?>
+ <? $admin = php_sapi_name() == "cli" || isset($user) && $user->admin ?>
<div class="big_box" id="framework_error">
<h1>
<?= t("Dang... Something went wrong!") ?>
diff --git a/modules/gallery/views/permissions_browse.html.php b/modules/gallery/views/permissions_browse.html.php
index 8bb2e830..36394877 100644
--- a/modules/gallery/views/permissions_browse.html.php
+++ b/modules/gallery/views/permissions_browse.html.php
@@ -27,7 +27,7 @@
<? if (!$htaccess_works): ?>
<ul id="gMessage">
<li class="gError">
- <?= t("Oh no! Your server needs a configuration change in order for you to hide photos! Ask your server administrator to set <a %attrs><i>AllowOverride FileInfo Options</i></a> to fix this.", array("attrs" => "href=\"http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride\" target=\"_blank\"")) ?>
+ <?= t("Oh no! Your server needs a configuration change in order for you to hide photos! Ask your server administrator to enable <a %mod_rewrite_attrs>mod_rewrite</a> and set <a %apache_attrs><i>AllowOverride FileInfo Options</i></a> to fix this.", array("mod_rewrite_attrs" => "href=\"http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html\" target=\"_blank\"", "apache_attrs" => "href=\"http://httpd.apache.org/docs/2.0/mod/core.html#allowoverride\" target=\"_blank\"")) ?>
</li>
</ul>
<? endif ?>
diff --git a/modules/gallery/views/upgrader.html.php b/modules/gallery/views/upgrader.html.php
index 6b9a0110..fa21e196 100644
--- a/modules/gallery/views/upgrader.html.php
+++ b/modules/gallery/views/upgrader.html.php
@@ -9,6 +9,9 @@
font-family: Trebuchet MS;
font-size: 1.1em;
}
+ h1 {
+ font-size: 1.4em;
+ }
div#outer {
width: 650px;
background: white;
@@ -93,11 +96,17 @@
.gray_on_done {
opacity: <?= $done ? "0.5" : "1" ?>;
}
+ pre {
+ display: inline;
+ margin: 0px;
+ padding: 0px;
+ }
</style>
<body>
<div id="outer">
<img src="<?= url::file("modules/gallery/images/gallery.png") ?>" />
<div id="inner">
+ <? if ($can_upgrade): ?>
<? if ($done): ?>
<div id="confirmation">
<div>
@@ -158,6 +167,13 @@
<? endforeach ?>
</p>
<? endif ?>
+ <? else: // can_upgrade ?>
+ <h1> <?= t("Who are you?") ?> </h1>
+ <p>
+ <?= t("You're not logged in as an administrator, so we have to verify you to make sure it's ok for you to do an upgrade. To prove you can run an upgrade, create a file called %name in your <b>gallery3/var/tmp</b> directory.", array("name" => "<br/><b>$upgrade_token</b>")) ?>
+ </p>
+ <a href="<?= url::site("upgrader?") ?>"><?= t("Ok, I've done that") ?></a>
+ <? endif // can_upgrade ?>
</div>
<div id="footer">
<p>
diff --git a/modules/gallery_unit_test/controllers/gallery_unit_test.php b/modules/gallery_unit_test/controllers/gallery_unit_test.php
index 56220a19..8f3353dc 100644
--- a/modules/gallery_unit_test/controllers/gallery_unit_test.php
+++ b/modules/gallery_unit_test/controllers/gallery_unit_test.php
@@ -23,6 +23,13 @@ class Gallery_Unit_Test_Controller extends Controller {
print Kohana::show_404();
}
+ // Jump through some hoops to satisfy the way that we check for the site_domain in
+ // config.php. We structure this such that the code in config will leave us with a
+ // site_domain of "." (for historical reasons)
+ // @todo: for tests, we should force the site_domain to something like example.com
+ $_SERVER["SCRIPT_FILENAME"] = "index.php";
+ $_SERVER["SCRIPT_NAME"] = "./index.php";
+
$original_config = DOCROOT . "var/database.php";
$test_config = VARPATH . "database.php";
if (!file_exists($original_config)) {
diff --git a/modules/rss/helpers/rss_theme.php b/modules/rss/helpers/rss_theme.php
index d47d3313..54bba210 100644
--- a/modules/rss/helpers/rss_theme.php
+++ b/modules/rss/helpers/rss_theme.php
@@ -40,12 +40,16 @@ class rss_theme_Core {
$block->css_id = "gRss";
$block->title = t("Available RSS Feeds");
$block->content = new View("rss_block.html");
- $block->content->feeds = array(
- t("New photos or movies") => url::site("rss/updates"),
- t("All new comments") => url::site("rss/comments"),
- sprintf(t("Comments on %s"),
- $theme->item()->title) => url::site("rss/comments/{$theme->item()->id}")
- );
+ // @todo consider pushing the code for the feeds back to the associated modules
+ // and create an event 'generate_rss_feeds' that modules can respond to create
+ // the list of feeds.
+ $feeds = array(t("New photos or movies") => url::site("rss/updates"));
+ if (module::is_active("comment")) {
+ $feeds[t("All new comments")] = url::site("rss/comments");
+ $feeds[sprintf(t("Comments on %s"), $theme->item()->title)] =
+ url::site("rss/comments/{$theme->item()->id}");
+ }
+ $block->content->feeds = $feeds;
return $block;
}
}
diff --git a/modules/user/controllers/users.php b/modules/user/controllers/users.php
index f28f598a..46f799c5 100644
--- a/modules/user/controllers/users.php
+++ b/modules/user/controllers/users.php
@@ -33,12 +33,14 @@ class Users_Controller extends REST_Controller {
$user->password = $form->edit_user->password->value;
}
$user->email = $form->edit_user->email->value;
+ $user->url = $form->edit_user->url->value;
if ($form->edit_user->locale) {
$desired_locale = $form->edit_user->locale->value;
$user->locale = $desired_locale == "none" ? null : $desired_locale;
}
$user->save();
+ message::success(t("User information updated."));
print json_encode(
array("result" => "success",
"resource" => url::site("users/{$user->id}")));