Example #1
0
 /**
  * @return string An error message suitable for inclusion in the task log
  */
 static function check_index()
 {
     list($remaining) = search::stats();
     if ($remaining) {
         site_status::warning(t('Your search index needs to be updated.  <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/search_task::update_index?csrf=__CSRF__")))), "search_index_out_of_date");
     }
 }
 public function index()
 {
     // require_once(MODPATH . "aws_s3/lib/s3.php");
     $form = $this->_get_s3_form();
     if (request::method() == "post") {
         access::verify_csrf();
         if ($form->validate()) {
             module::set_var("aws_s3", "enabled", isset($_POST['enabled']) ? true : false);
             module::set_var("aws_s3", "access_key", $_POST['access_key']);
             module::set_var("aws_s3", "secret_key", $_POST['secret_key']);
             module::set_var("aws_s3", "bucket_name", $_POST['bucket_name']);
             module::set_var("aws_s3", "g3id", $_POST['g3id']);
             module::set_var("aws_s3", "url_str", $_POST['url_str']);
             module::set_var("aws_s3", "sig_exp", $_POST['sig_exp']);
             module::set_var("aws_s3", "use_ssl", isset($_POST['use_ssl']) ? true : false);
             if (module::get_var("aws_s3", "enabled") && !module::get_var("aws_s3", "synced", false)) {
                 site_status::warning(t('Your site has not yet been syncronised with your Amazon S3 bucket. Content will not appear correctly until you perform syncronisation. <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/aws_s3_task::sync?csrf=__CSRF__")))), "aws_s3_not_synced");
             }
             message::success(t("Settings have been saved"));
             url::redirect("admin/aws_s3");
         } else {
             message::error(t("There was a problem with the submitted form. Please check your values and try again."));
         }
     }
     $v = new Admin_View("admin.html");
     $v->page_title = t("Amazon S3 Configuration");
     $v->content = new View("admin_aws_s3.html");
     $v->content->form = $form;
     $v->content->end = "";
     echo $v;
 }
 static function uninstall()
 {
     $db = Database::instance();
     $db->query("DROP TABLE `search_records`");
     site_status::clear("search_index_out_of_date");
     module::delete("search");
 }
Example #4
0
 public function confirm($hash)
 {
     $pending_user = ORM::factory("pending_user")->where("hash", "=", $hash)->where("state", "=", 0)->find();
     if ($pending_user->loaded()) {
         // @todo add a request date to the pending user table and check that it hasn't expired
         $policy = module::get_var("registration", "policy");
         $pending_user->state = 1;
         $pending_user->save();
         if ($policy == "vistor") {
             $user = register::create_new_user($pending_user->id);
             message::success(t("Your registration request has been approved"));
             auth::login($user);
             Session::instance()->set("registration_first_usage", true);
             $pending_user->delete();
         } else {
             site_status::warning(t("There are pending user registration. <a href=\"%url\">Review now!</a>", array("url" => html::mark_clean(url::site("admin/register")), "locale" => module::get_var("gallery", "default_locale"))), "pending_user_registrations");
             message::success(t("Your registration request is awaiting administrator approval"));
             // added by Shad Laws, v2
             if (module::get_var("registration", "admin_notify") == 1) {
                 register::send_admin_notify($pending_user);
             }
         }
     } else {
         message::error(t("Your registration request is no longer valid, Please re-register."));
     }
     url::redirect(item::root()->abs_url());
 }
 public function saveprefs()
 {
     // Prevent Cross Site Request Forgery
     access::verify_csrf();
     // Save Settings.
     module::set_var("ratings", "showunderphoto", Input::instance()->post("showunderphoto"));
     module::set_var("ratings", "showinsidebar", Input::instance()->post("showinsidebar"));
     module::set_var("ratings", "imageword", Input::instance()->post("imageword"));
     module::set_var("ratings", "votestring", Input::instance()->post("votestring"));
     module::set_var("ratings", "castyourvotestring", Input::instance()->post("castyourvotestring"));
     #    module::set_var("ratings", "bgcolor", Input::instance()->post("bgcolor"));
     module::set_var("ratings", "fillcolor", Input::instance()->post("fillcolor"));
     module::set_var("ratings", "votedcolor", Input::instance()->post("votedcolor"));
     module::set_var("ratings", "hovercolor", Input::instance()->post("hovercolor"));
     module::set_var("ratings", "textcolor", Input::instance()->post("textcolor"));
     module::set_var("ratings", "regonly", Input::instance()->post("regonly"));
     $iconset = Input::instance()->post("iconset");
     $iconset = preg_replace("/\\/index\\.php/", "", $iconset);
     module::set_var("ratings", "iconset", $iconset);
     message::success(t("Your Settings Have Been Saved."));
     site_status::clear("ratings_configuration");
     // Load Admin page.
     $view = new Admin_View("admin.html");
     $view->content = new View("admin_ratings.html");
     $view->content->ratings_form = $this->_get_admin_form();
     print $view;
 }
Example #6
0
 static function update_index($task)
 {
     try {
         $completed = $task->get("completed", 0);
         $start = microtime(true);
         foreach (ORM::factory("item")->join("exif_records", "items.id", "exif_records.item_id", "left")->where("type", "photo")->open_paren()->where("exif_records.item_id", null)->orwhere("exif_records.dirty", 1)->close_paren()->find_all() as $item) {
             if (microtime(true) - $start > 1.5) {
                 break;
             }
             $completed++;
             exif::extract($item);
         }
         list($remaining, $total, $percent) = exif::stats();
         $task->set("completed", $completed);
         if ($remaining == 0 || !($remaining + $completed)) {
             $task->done = true;
             $task->state = "success";
             site_status::clear("exif_index_out_of_date");
             $task->percent_complete = 100;
         } else {
             $task->percent_complete = round(100 * $completed / ($remaining + $completed));
         }
         $task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
     } catch (Exception $e) {
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $task->log($e->__toString());
     }
 }
Example #7
0
 static function update_index($task)
 {
     try {
         $completed = $task->get("completed", 0);
         $start = microtime(true);
         foreach (ORM::factory("item")->join("exif_records", "items.id", "exif_records.item_id", "left")->where("type", "=", "photo")->and_open()->where("exif_records.item_id", "IS", null)->or_where("exif_records.dirty", "=", 1)->close()->find_all() as $item) {
             // The query above can take a long time, so start the timer after its done
             // to give ourselves a little time to actually process rows.
             if (!isset($start)) {
                 $start = microtime(true);
             }
             exif::extract($item);
             $completed++;
             if (microtime(true) - $start > 1.5) {
                 break;
             }
         }
         list($remaining, $total, $percent) = exif::stats();
         $task->set("completed", $completed);
         if ($remaining == 0 || !($remaining + $completed)) {
             $task->done = true;
             $task->state = "success";
             site_status::clear("exif_index_out_of_date");
             $task->percent_complete = 100;
         } else {
             $task->percent_complete = round(100 * $completed / ($remaining + $completed));
         }
         $task->status = t2("one record updated, index is %percent% up-to-date", "%count records updated, index is %percent% up-to-date", $completed, array("percent" => $percent));
     } catch (Exception $e) {
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $task->log((string) $e);
     }
 }
 static function upgrade($version)
 {
     log::info("aws_s3", "Commencing module upgrade (" . $version . ")");
     switch ($version) {
         case 0:
             log::info("aws_s3", "Installing version 1");
             @mkdir(VARPATH . "modules/aws_s3");
             @mkdir(VARPATH . "modules/aws_s3/log");
             // installation's unique identifier - allows multiple g3's pointing to the same s3 bucket.
             if (!module::get_var("aws_s3", "g3id")) {
                 module::set_var("aws_s3", "g3id", md5(time()));
             }
             module::set_var("aws_s3", "synced", false);
             module::set_var("aws_s3", "enabled", false);
             module::set_var("aws_s3", "access_key", "");
             module::set_var("aws_s3", "secret_key", "");
             module::set_var("aws_s3", "bucket_name", "");
             module::set_version("aws_s3", 1);
         case 1:
             log::info("aws_s3", "Upgrading to version 2");
             $db = Database::instance();
             $db->query("CREATE TABLE {aws_s3_meta} (\n                                `item_id` int(9) NOT NULL,\n                                `item_hash` varchar(32) NOT NULL DEFAULT '',\n                                `thumb_uploaded` smallint(1) NOT NULL DEFAULT 0,\n                                `resize_uploaded` smallint(1) NOT NULL DEFAULT 0,\n                                `fullsize_uploaded` smallint(1) NOT NULL DEFAULT 0,\n                                `local_deleted` smallint(1) NOT NULL DEFAULT 0,\n                                PRIMARY KEY (`item_id`)\n                ) DEFAULT CHARSET=utf8;");
             module::set_var("aws_s3", "upload_thumbs", true);
             module::set_var("aws_s3", "upload_resizes", true);
             module::set_var("aws_s3", "upload_fullsizes", true);
             module::set_var("aws_s3", "s3_storage_only", false);
             if (module::get_var("aws_s3", "synced")) {
                 // v1 has already synced this installation to s3. mark all the items with the relevant meta data
                 $items = ORM::factory("item")->find_all();
                 foreach ($items as $item) {
                     aws_s3::log("Updating S3 meta for item ID: " . $item->id);
                     $item->s3_thumb_uploaded = true;
                     if (!$item->is_album()) {
                         $item->s3_resize_uploaded = true;
                         $item->s3_fullsize_uploaded = true;
                     }
                     $item->s3_local_deleted = false;
                     $item->s3_item_hash = md5($item->relative_path());
                     $item->save_s3_meta();
                 }
             } else {
                 // check various states after upgrade from v1..
                 if (module::get_var("aws_s3", "access_key") != "" && module::get_var("aws_s3", "secret_key") != "" && module::get_var("aws_s3", "bucket_name") != "" && aws_s3::validate_access_details(module::get_var("aws_s3", "access_key"), module::get_var("aws_s3", "secret_key"), module::get_var("aws_s3", "bucket_name"))) {
                     // details are correct but hasn't been synced.
                     if (aws_s3::can_schedule()) {
                         // i can schedule this task
                         aws_s3::schedule_full_sync2();
                         site_status::warning("Your site has been scheduled for full Amazon S3 re-synchronisation. This message will clear when this has been completed.", "aws_s3_not_synced");
                     } else {
                         // i CAN'T schedule it..
                         site_status::warning(t('Your site has not been synchronised to Amazon S3. Until it has, your server will continue to serve image content to your visitors.<br />Click <a href="%url" class="g-dialog-link">here</a> to start the synchronisation task.', array("url" => html::mark_clean(url::site("admin/maintenance/start/aws_s3_task::manual_sync?csrf=__CSRF__")))), "aws_s3_not_synced");
                     }
                 } else {
                     site_status::warning(t('Amazon S3 module needs configuration. Click <a href="%url">here</a> to go to the configuration page.', array("url" => html::mark_clean(url::site("admin/aws_s3")))), "aws_s3_not_configured");
                 }
             }
             module::set_version("aws_s3", 2);
     }
     log::info("aws_s3", "Module upgrade complete");
 }
Example #9
0
 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $result = graphics::find_dirty_images_query();
     $remaining = $result->count();
     $completed = $task->get("completed", 0);
     $i = 0;
     foreach ($result as $row) {
         $item = ORM::factory("item", $row->id);
         if ($item->loaded) {
             graphics::generate($item);
         }
         $completed++;
         $remaining--;
         if (++$i == 2) {
             break;
         }
     }
     $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $remaining + $completed));
     if ($completed + $remaining > 0) {
         $task->percent_complete = (int) (100 * $completed / ($completed + $remaining));
     } else {
         $task->percent_complete = 100;
     }
     $task->set("completed", $completed);
     if ($remaining == 0) {
         $task->done = true;
         $task->state = "success";
         site_status::clear("graphics_dirty");
     }
 }
 public function activate()
 {
     access::verify_csrf();
     $post = new Validation($_POST);
     $post->add_rules("activate_users", "required");
     $post->add_rules("activate", "alpha_numeric");
     if ($post->validate()) {
         $names = array();
         if (!empty($post->activate)) {
             foreach ($post->activate as $id) {
                 $user = register::create_new_user($id);
                 $names[] = $user->name;
             }
             message::success(t("Activated %users.", array("users" => implode(", ", $names))));
         }
         $count = ORM::factory("pending_user")->where("state", "!=", 2)->count_all();
         if ($count == 0) {
             site_status::clear("pending_user_registrations");
         }
         url::redirect("admin/register");
     }
     list($form, $errors) = $this->_get_form();
     $form = array_merge($form, $post->as_array());
     $errors = array_merge($errors, $post->errors());
     print $this->_get_admin_view($form, $errors);
 }
Example #11
0
 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $errors = array();
     try {
         $result = graphics::find_dirty_images_query()->select("id")->execute();
         $total_count = $task->get("total_count", $result->count());
         $mode = $task->get("mode", "init");
         if ($mode == "init") {
             $task->set("total_count", $total_count);
             $task->set("mode", "process");
             batch::start();
         }
         $completed = $task->get("completed", 0);
         $ignored = $task->get("ignored", array());
         $i = 0;
         foreach ($result as $row) {
             if (array_key_exists($row->id, $ignored)) {
                 continue;
             }
             $item = ORM::factory("item", $row->id);
             if ($item->loaded()) {
                 try {
                     graphics::generate($item);
                     $completed++;
                     $errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title)));
                 } catch (Exception $e) {
                     $errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title)));
                     $errors[] = (string) $e;
                     $ignored[$item->id] = 1;
                 }
             }
             if (++$i == 2) {
                 break;
             }
         }
         $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $total_count));
         if ($completed < $total_count) {
             $task->percent_complete = (int) (100 * ($completed + count($ignored)) / $total_count);
         } else {
             $task->percent_complete = 100;
         }
         $task->set("completed", $completed);
         $task->set("ignored", $ignored);
         if ($task->percent_complete == 100) {
             $task->done = true;
             $task->state = "success";
             batch::stop();
             site_status::clear("graphics_dirty");
         }
     } catch (Exception $e) {
         Kohana_Log::add("error", (string) $e);
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $errors[] = (string) $e;
     }
     if ($errors) {
         $task->log($errors);
     }
 }
Example #12
0
 static function upgrade($version)
 {
     if ($version < 4) {
         // No longer necessary, make sure that it's cleared.
         site_status::clear("organize_needs_rest");
         module::set_version("organize", $version = 4);
     }
 }
 static function module_change($changes)
 {
     if (!module::is_active("tag") || in_array("tag", $changes->deactivate)) {
         site_status::warning(t("The DisplayTags module requires the Tags module.  <a href=\"%url\">Activate the Tags module now</a>", array("url" => html::mark_clean(url::site("admin/modules")))), "displaytags_needs_tag");
     } else {
         site_status::clear("displaytags_needs_tag");
     }
 }
Example #14
0
 static function module_change($changes)
 {
     if (!module::is_active("rss") || in_array("rss", $changes->deactivate)) {
         site_status::warning(t("The Slideshow module requires the RSS module.  <a href=\"%url\">Activate the RSS module now</a>", array("url" => html::mark_clean(url::site("admin/modules")))), "slideshow_needs_rss");
     } else {
         site_status::clear("slideshow_needs_rss");
     }
 }
 static function report_ppm_support($toolkit_id)
 {
     if (array_key_exists($toolkit_id, rawphoto_graphics::get_supported_toolkits())) {
         site_status::clear("rawphoto_needs_ppm_support");
     } else {
         site_status::warning(t('The <em>Raw Photos</em> module requires a supporting graphics toolkit. ' . '<a href="%activate_url">Activate</a> either ImageMagick or GraphicsMagick.', array("activate_url" => url::site("admin/graphics"))), "rawphoto_needs_ppm_support");
     }
 }
 static function update_overlays($task)
 {
     $errors = array();
     try {
         $mode = $task->get('mode', 'init');
         switch ($mode) {
             case 'init':
                 $q = emboss::find_dirty();
                 foreach ($q as $item) {
                     $ids[] = array('id' => $item->id, 'image_id' => $item->image_id, 'overlay_id' => $item->best_overlay_id);
                 }
                 $count = count($ids);
                 if ($count > 0) {
                     $task->set('ids', $ids);
                     $task->set('count', $count);
                     $task->set('current', 0);
                     $task->set('mode', 'continue');
                 } else {
                     $task->done = true;
                     $task->state = 'success';
                     $task->percent_complete = 100;
                     site_status::clear('emboss_dirty');
                     return;
                 }
                 break;
             case 'continue':
                 $ids = $task->get('ids');
                 $count = $task->get('count');
                 $current = $task->get('current');
                 break;
         }
         $i = 1 * $current;
         $id = $ids[$i];
         $current++;
         $task->set('current', $current);
         emboss_task::do_embossing($id['id'], $id['image_id'], $id['overlay_id']);
         if ($current >= $count) {
             $task->done = true;
             $task->state = 'success';
             $task->percent_complete = 100;
             $task->status = 'Complete';
             site_status::clear('emboss_dirty');
         } else {
             $task->percent_complete = $current / $count * 100;
             $task->status = t("Reembossed {$current} of {$count} photos");
         }
     } catch (Exception $e) {
         Kohana_Log::add('error', (string) $e);
         $task->done = true;
         $task->state = 'error';
         $task->status = $e->getMessage();
         $errors[] = (string) $e;
     }
     if ($errors) {
         $task->log($errors);
     }
 }
Example #17
0
 /**
  * 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");
     // Normally Router::find_uri() strips off the url suffix for us, but we're working off of the
     // PATH_INFO here so we need to strip it off manually
     if ($suffix = Kohana::config("core.url_suffix")) {
         $path = preg_replace("#" . preg_quote($suffix) . "\$#u", "", $path);
     }
     self::$is_admin = $path == "/admin" || !strncmp($path, "/admin/", 7);
     self::$site_theme_name = module::get_var("gallery", "active_site_theme");
     // If the site theme doesn't exist, fall back to wind.
     if (!file_exists(THEMEPATH . self::$site_theme_name . "/theme.info")) {
         site_status::error(t("Theme '%name' is missing.  Falling back to the Wind theme.", array("name" => self::$site_theme_name)), "missing_site_theme");
         module::set_var("gallery", "active_site_theme", self::$site_theme_name = "wind");
     }
     if (self::$is_admin) {
         // Load the admin theme
         self::$admin_theme_name = module::get_var("gallery", "active_admin_theme");
         // If the admin theme doesn't exist, fall back to admin_wind.
         if (!file_exists(THEMEPATH . self::$admin_theme_name . "/theme.info")) {
             site_status::error(t("Admin theme '%name' is missing!  Falling back to the Wind theme.", array("name" => self::$admin_theme_name)), "missing_admin_theme");
             module::set_var("gallery", "active_admin_theme", self::$admin_theme_name = "admin_wind");
         }
         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");
         }
         // 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::$admin_theme_name = $override;
                 array_unshift($modules, THEMEPATH . self::$admin_theme_name);
             } else {
                 Kohana_Log::add("error", "Missing override admin theme: '{$override}'");
             }
         }
     } 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 site theme: '{$override}'");
             }
         }
         array_unshift($modules, THEMEPATH . self::$site_theme_name);
     }
     $config->set("core.modules", $modules);
 }
 static function module_change($changes)
 {
     // Gallery version must be >= 32
     if (module::get_version("gallery") < 32) {
         site_status::warning(t("The module 'Module Order' requires Gallery core version of 32 or higher."), "moduleorder_needs_higherversion");
     } else {
         site_status::clear("moduleorder_needs_higherversion");
     }
 }
 static function module_change($changes)
 {
     // If EXIF is deactivated, display a warning that it is required for this module to function properly.
     if (!module::is_active("exif") || in_array("exif", $changes->deactivate)) {
         site_status::warning(t("The EXIF_GPS module requires the EXIF module.  " . "<a href=\"%url\">Activate the EXIF module now</a>", array("url" => html::mark_clean(url::site("admin/modules")))), "exif_gps_needs_exif");
     } else {
         site_status::clear("exif_gps_needs_exif");
     }
 }
 static function module_change($changes)
 {
     // Display a warning message if the RSS module is not installed.
     if (!module::is_active("rss") || in_array("rss", $changes->deactivate)) {
         site_status::warning(t("The MiniSlide Show module requires the RSS module.  " . "<a href=\"%url\">Activate the RSS module now</a>", array("url" => url::site("admin/modules"))), "minislideshow_needs_rss");
     } else {
         site_status::clear("minislideshow_needs_rss");
     }
 }
 static function module_change($changes)
 {
     // See if the Tags module is installed,
     //   tell the user to install it if it isn't.
     if (!module::is_active("tag") || in_array("tag", $changes->deactivate)) {
         site_status::warning(t("The TagsMap module requires the Tags module.  " . "<a href=\"%url\">Activate the Tags module now</a>", array("url" => url::site("admin/modules"))), "tagsmap_needs_tag");
     } else {
         site_status::clear("tagsmap_needs_tag");
     }
 }
Example #22
0
 static function check_config()
 {
     $public_key = module::get_var("recaptcha", "public_key");
     $private_key = module::get_var("recaptcha", "private_key");
     if (empty($public_key) || empty($private_key)) {
         site_status::warning(t("reCAPTCHA is not quite ready!  Please configure the <a href=\"%url\">reCAPTCHA Keys</a>", array("url" => html::mark_clean(url::site("admin/recaptcha")))), "recaptcha_config");
     } else {
         site_status::clear("recaptcha_config");
     }
 }
 static function module_change($changes)
 {
     // See if the Photo Annotation module is installed,
     // tell the user to install it if it isn't.
     if (!module::is_active("photoannotation") || in_array("photoannotation", $changes->deactivate)) {
         site_status::warning(t("The Picasa Faces module requires the Photo Annotation module.  " . "<a href=\"%url\">Activate the Photo Annotation module now</a>", array("url" => url::site("admin/modules"))), "picasa_faces_needs_photoannotation");
     } else {
         site_status::clear("picasa_faces_needs_photoannotation");
     }
 }
Example #24
0
 public function index()
 {
     // If modules need upgrading, this will get recreated in module::available()
     site_status::clear("upgrade_now");
     $view = new Admin_View("admin.html");
     $view->page_title = t("Modules");
     $view->content = new View("admin_modules.html");
     $view->content->available = module::available();
     print $view;
 }
 function remind_me_later()
 {
     access::verify_csrf();
     site_status::clear("upgrade_checker");
     if ($referer = Input::instance()->server("HTTP_REFERER")) {
         url::redirect($referer);
     } else {
         url::redirect(item::root()->abs_url());
     }
 }
Example #26
0
 static function check_config($paths = null)
 {
     if ($paths === null) {
         $paths = unserialize(module::get_var("server_add", "authorized_paths"));
     }
     if (empty($paths)) {
         site_status::warning(t("Server Add needs configuration. <a href=\"%url\">Configure it now!</a>", array("url" => url::site("admin/server_add"))), "server_add_configuration");
     } else {
         site_status::clear("server_add_configuration");
     }
 }
Example #27
0
 static function check_config($paths = null)
 {
     if ($paths === null) {
         $paths = unserialize(module::get_var("videos", "authorized_paths"));
     }
     if (empty($paths)) {
         site_status::warning(t("Videos needs configuration. <a href=\"%url\">Configure it now!</a>", array("url" => html::mark_clean(url::site("admin/videos")))), "videos_configuration");
     } else {
         site_status::clear("videos_configuration");
     }
 }
Example #28
0
 /**
  * Task that rebuilds all dirty images.
  * @param Task_Model the task
  */
 static function rebuild_dirty_images($task)
 {
     $errors = array();
     try {
         $result = graphics::find_dirty_images_query();
         $completed = $task->get("completed", 0);
         $ignored = $task->get("ignored", array());
         $remaining = $result->count() - count($ignored);
         $i = 0;
         foreach ($result as $row) {
             if (array_key_exists($row->id, $ignored)) {
                 continue;
             }
             $item = ORM::factory("item", $row->id);
             if ($item->loaded) {
                 try {
                     graphics::generate($item);
                     $ignored[$item->id] = 1;
                     $errors[] = t("Successfully rebuilt images for '%title'", array("title" => html::purify($item->title)));
                 } catch (Exception $e) {
                     $errors[] = t("Unable to rebuild images for '%title'", array("title" => html::purify($item->title)));
                     $errors[] = $e->__toString();
                 }
             }
             $completed++;
             $remaining--;
             if (++$i == 2) {
                 break;
             }
         }
         $task->status = t2("Updated: 1 image. Total: %total_count.", "Updated: %count images. Total: %total_count.", $completed, array("total_count" => $remaining + $completed));
         if ($completed + $remaining > 0) {
             $task->percent_complete = (int) (100 * $completed / ($completed + $remaining));
         } else {
             $task->percent_complete = 100;
         }
         $task->set("completed", $completed);
         $task->set("ignored", $ignored);
         if ($remaining == 0) {
             $task->done = true;
             $task->state = "success";
             site_status::clear("graphics_dirty");
         }
     } catch (Exception $e) {
         $task->done = true;
         $task->state = "error";
         $task->status = $e->getMessage();
         $errors[] = $e->__toString();
     }
     if ($errors) {
         $task->log($errors);
     }
 }
Example #29
0
 public function index()
 {
     $view = new Admin_View("admin.html");
     $view->page_title = t("Theme choice");
     $view->content = new View("admin_themes.html");
     $view->content->admin = module::get_var("gallery", "active_admin_theme");
     $view->content->site = module::get_var("gallery", "active_site_theme");
     $view->content->themes = $this->_get_themes();
     site_status::clear("missing_site_theme");
     site_status::clear("missing_admin_theme");
     print $view;
 }
 static function activate()
 {
     site_status::warning(t("Activate."), "gd_init_configuration");
     if (module::get_var("gallery", "resize_size") != 800) {
         module::set_var("gallery", "resize_size", 800);
     }
     if (module::get_var("gallery", "thumb_size") != 200) {
         module::set_var("gallery", "thumb_size", 200);
     }
     if (module::get_var("gallery", "page_size") != 50) {
         module::set_var("gallery", "page_size", 50);
     }
 }