コード例 #1
0
 public function handler()
 {
     access::verify_csrf();
     $form = $this->_get_form();
     $errors = array_fill_keys(array_keys($form), "");
     if ($_POST) {
         $post = new Validation($_POST);
         $post->add_rules("updates_enabled", array("valid", "numeric"));
         $post->add_rules("popular_enabled", array("valid", "numeric"));
         $post->add_rules("updates_limit", array("valid", "numeric"));
         $post->add_rules("popular_limit", array("valid", "numeric"));
         $post->add_rules("updates_description", "length[0,2048]");
         $post->add_rules("popular_description", "length[0,2048]");
         if ($post->validate()) {
             foreach (array("updates", "popular") as $album) {
                 $album_defn = unserialize(module::get_var("dynamic", $album));
                 $album_defn->enabled = $post["{$album}_enabled"];
                 $album_defn->description = $post["{$album}_description"];
                 $album_defn->limit = $post["{$album}_limit"] === "" ? null : $post["{$album}_limit"];
                 module::set_var("dynamic", $album, serialize($album_defn));
             }
             message::success(t("Dynamic Albums Configured"));
             url::redirect("admin/dynamic");
         } else {
             $form = arr::overwrite($form, $post->as_array());
             $errors = arr::overwrite($errors, $post->errors());
         }
     }
     print $this->_get_view($form, $errors);
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 public function index()
 {
     $form = $this->_get_form();
     if (request::method() == "post") {
         access::verify_csrf();
         if ($form->validate()) {
             module::set_var("strip_exif", "exiv_path", $_POST['exiv_path']);
             if ($_POST['exif_tags'] != "") {
                 module::set_var("strip_exif", "exif_remove", isset($_POST['exif_remove']) ? $_POST['exif_remove'] : false);
                 module::set_var("strip_exif", "exif_tags", $_POST['exif_tags']);
             } else {
                 module::set_var("strip_exif", "exif_remove", false);
                 module::set_var("strip_exif", "exif_tags", self::$defExifTags);
             }
             if ($_POST['iptc_tags'] != "") {
                 module::set_var("strip_exif", "iptc_remove", isset($_POST['iptc_remove']) ? $_POST['iptc_remove'] : false);
                 module::set_var("strip_exif", "iptc_tags", $_POST['iptc_tags']);
             } else {
                 module::set_var("strip_exif", "iptc_remove", false);
                 module::set_var("strip_exif", "iptc_tags", self::$defIptcTags);
             }
             if (isset($_POST['verbose'])) {
                 module::set_var("strip_exif", "verbose", $_POST['verbose']);
             }
             message::success(t("Settings have been saved"));
             url::redirect("admin/strip_exif");
         } else {
             message::error(t("There was a problem with the submitted form. Please check your values and try again."));
         }
     }
     print $this->_get_view();
 }
コード例 #4
0
 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"));
 }
コード例 #5
0
ファイル: admin_modules.php プロジェクト: xafr/gallery3
 public function save()
 {
     access::verify_csrf();
     $changes->activate = array();
     $changes->deactivate = array();
     $activated_names = array();
     $deactivated_names = array();
     foreach (module::available() as $module_name => $info) {
         if ($info->locked) {
             continue;
         }
         $desired = $this->input->post($module_name) == 1;
         if ($info->active && !$desired && module::is_active($module_name)) {
             $changes->deactivate[] = $module_name;
             $deactivated_names[] = $info->name;
             module::deactivate($module_name);
         } else {
             if (!$info->active && $desired && !module::is_active($module_name)) {
                 $changes->activate[] = $module_name;
                 $activated_names[] = $info->name;
                 module::install($module_name);
                 module::activate($module_name);
             }
         }
     }
     module::event("module_change", $changes);
     // @todo this type of collation is questionable from a i18n perspective
     if ($activated_names) {
         message::success(t("Activated: %names", array("names" => join(", ", $activated_names))));
     }
     if ($deactivated_names) {
         message::success(t("Deactivated: %names", array("names" => join(", ", $deactivated_names))));
     }
     url::redirect("admin/modules");
 }
コード例 #6
0
ファイル: photos.php プロジェクト: hiwilson/gallery3
 /**
  * @see REST_Controller::_update($resource)
  */
 public function _update($photo)
 {
     access::verify_csrf();
     access::required("view", $photo);
     access::required("edit", $photo);
     $form = photo::get_edit_form($photo);
     if ($valid = $form->validate()) {
         if ($form->edit_photo->filename->value != $photo->name) {
             // Make sure that there's not a conflict
             if (Database::instance()->from("items")->where("parent_id", $photo->parent_id)->where("id <>", $photo->id)->where("name", $form->edit_photo->filename->value)->count_records()) {
                 $form->edit_photo->filename->add_error("conflict", 1);
                 $valid = false;
             }
         }
     }
     if ($valid) {
         $photo->title = $form->edit_photo->title->value;
         $photo->description = $form->edit_photo->description->value;
         $photo->rename($form->edit_photo->filename->value);
         $photo->save();
         module::event("photo_edit_form_completed", $photo, $form);
         log::success("content", "Updated photo", "<a href=\"photos/{$photo->id}\">view</a>");
         message::success(t("Saved photo %photo_title", array("photo_title" => p::clean($photo->title))));
         print json_encode(array("result" => "success", "location" => url::site("photos/{$photo->id}")));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
コード例 #7
0
ファイル: mediaUtils.php プロジェクト: pasterntt/dynao-CMS
 public static function deleteFile($id)
 {
     $values = [];
     for ($i = 1; $i <= 10; $i++) {
         $values[] = '`media' . $i . '` = ' . $id;
     }
     for ($i = 1; $i <= 10; $i++) {
         $values[] = '`medialist' . $i . '` LIKE "%|' . $id . '|%"';
     }
     $sql = sql::factory();
     $sql->query('SELECT id FROM ' . sql::table('structure_area') . ' WHERE ' . implode(' OR ', $values))->result();
     if ($sql->num()) {
         echo message::warning(lang::get('file_in_use'));
     } else {
         $sql = sql::factory();
         $sql->setTable('media');
         $sql->setWhere('id=' . $id);
         $sql->select('filename');
         $sql->result();
         if (unlink(dir::media($sql->get('filename')))) {
             $sql->delete();
             return message::success(lang::get('file_deleted'), true);
         } else {
             return message::warning(sprintf(lang::get('file_not_deleted'), dyn::get('hp_url'), $sql->get('filename')), true);
         }
     }
 }
コード例 #8
0
ファイル: users.php プロジェクト: Okat/gallery3
 public function _update($user)
 {
     if ($user->guest || $user->id != user::active()->id) {
         access::forbidden();
     }
     $form = user::get_edit_form($user);
     $valid = $form->validate();
     if ($valid) {
         $user->full_name = $form->edit_user->full_name->value;
         if ($form->edit_user->password->value) {
             $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;
             $new_locale = $desired_locale == "none" ? null : $desired_locale;
             if ($new_locale != $user->locale) {
                 // Delete the session based locale preference
                 setcookie("g_locale", "", time() - 24 * 3600, "/");
             }
             $user->locale = $new_locale;
         }
         $user->save();
         module::event("user_edit_form_completed", $user, $form);
         message::success(t("User information updated."));
         print json_encode(array("result" => "success", "resource" => url::site("users/{$user->id}")));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
コード例 #9
0
 public function saveprefs()
 {
     // Prevent Cross Site Request Forgery
     access::verify_csrf();
     // Figure out the values of the text boxes
     $str_phpmailer_path = Input::instance()->post("phpmailer_path");
     $str_phpmailer_from_addr = Input::instance()->post("phpmailer_from_address");
     $str_phpmailer_from_name = Input::instance()->post("phpmailer_from_name");
     $str_smtp_server = Input::instance()->post("phpmailer_smtp_server");
     $str_use_ssl = Input::instance()->post("phpmailer_use_ssl");
     $str_smtp_login = Input::instance()->post("phpmailer_smtp_login");
     $str_smtp_pass = Input::instance()->post("phpmailer_smtp_password");
     $str_smtp_port = Input::instance()->post("phpmailer_smtp_port");
     if (count($str_use_ssl) > 0) {
         $str_use_ssl = true;
     } else {
         $str_use_ssl = false;
     }
     // Save Settings.
     module::set_var("phpmailer", "phpmailer_path", $str_phpmailer_path);
     module::set_var("phpmailer", "phpmailer_from_address", $str_phpmailer_from_addr);
     module::set_var("phpmailer", "phpmailer_from_name", $str_phpmailer_from_name);
     module::set_var("phpmailer", "smtp_server", $str_smtp_server);
     module::set_var("phpmailer", "use_ssl", $str_use_ssl);
     module::set_var("phpmailer", "smtp_login", $str_smtp_login);
     module::set_var("phpmailer", "smtp_password", $str_smtp_pass);
     module::set_var("phpmailer", "smtp_port", $str_smtp_port);
     message::success(t("Your Settings Have Been Saved."));
     // Load Admin page.
     $view = new Admin_View("admin.html");
     $view->content = new View("admin_phpmailer.html");
     $view->content->phpmailer_form = $this->_get_admin_form();
     print $view;
 }
コード例 #10
0
 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;
 }
コード例 #11
0
 public function saveprefs()
 {
     // Prevent Cross Site Request Forgery
     access::verify_csrf();
     // Figure out which boxes where checked
     $linkOptions_array = Input::instance()->post("ContactOwnerLinkTypes");
     $ownerLink = false;
     $userLink = false;
     for ($i = 0; $i < count($linkOptions_array); $i++) {
         if ($linkOptions_array[$i] == "ContactOwner") {
             $ownerLink = true;
         }
         if ($linkOptions_array[$i] == "ContactUser") {
             $userLink = true;
         }
     }
     // Figure out the values of the text boxes
     $str_contactbutton = Input::instance()->post("owner_button_text");
     $str_contactemail = Input::instance()->post("owner_email");
     $str_contactname = Input::instance()->post("owner_name");
     $str_messageheader = Input::instance()->post("message_header");
     // Save Settings.
     module::set_var("contactowner", "contact_owner_link", $ownerLink);
     module::set_var("contactowner", "contact_user_link", $userLink);
     module::set_var("contactowner", "contact_button_text", $str_contactbutton);
     module::set_var("contactowner", "contact_owner_email", $str_contactemail);
     module::set_var("contactowner", "contact_owner_name", $str_contactname);
     module::set_var("contactowner", "contact_owner_header", $str_messageheader);
     message::success(t("Your Settings Have Been Saved."));
     // Load Admin page.
     $view = new Admin_View("admin.html");
     $view->content = new View("admin_contactowner.html");
     $view->content->contactowner_form = $this->_get_admin_form();
     print $view;
 }
コード例 #12
0
ファイル: reauthenticate.php プロジェクト: JasonWiki/docs
 public function auth()
 {
     if (!identity::active_user()->admin) {
         access::forbidden();
     }
     access::verify_csrf();
     $form = self::_form();
     $valid = $form->validate();
     $user = identity::active_user();
     if ($valid) {
         module::event("user_auth", $user);
         if (!request::is_ajax()) {
             message::success(t("Successfully re-authenticated!"));
         }
         url::redirect(Session::instance()->get_once("continue_url"));
     } else {
         $name = $user->name;
         log::warning("user", t("Failed re-authentication for %name", array("name" => $name)));
         module::event("user_auth_failed", $name);
         if (request::is_ajax()) {
             $v = new View("reauthenticate.html");
             $v->form = $form;
             $v->user_name = identity::active_user()->name;
             json::reply(array("html" => (string) $v));
         } else {
             self::_show_form($form);
         }
     }
 }
コード例 #13
0
 public function save()
 {
     access::verify_csrf();
     $form = $this->_get_edit_form_admin();
     if ($form->validate()) {
         module::set_var("gallery", "page_size", $form->edit_theme->page_size->value);
         $thumb_size = $form->edit_theme->thumb_size->value;
         if (module::get_var("gallery", "thumb_size") != $thumb_size) {
             graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize");
             graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), 100);
             module::set_var("gallery", "thumb_size", $thumb_size);
         }
         $resize_size = $form->edit_theme->resize_size->value;
         if (module::get_var("gallery", "resize_size") != $resize_size) {
             graphics::remove_rule("gallery", "resize", "gallery_graphics::resize");
             graphics::add_rule("gallery", "resize", "gallery_graphics::resize", array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 100);
             module::set_var("gallery", "resize_size", $resize_size);
         }
         module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value);
         // Sanitize values that get placed directly in HTML output by theme.
         module::set_var("gallery", "header_text", html::purify($form->edit_theme->header_text->value));
         module::set_var("gallery", "footer_text", html::purify($form->edit_theme->footer_text->value));
         module::set_var("gallery", "favicon_url", html::purify($form->edit_theme->favicon_url->value));
         module::set_var("gallery", "apple_touch_icon_url", html::purify($form->edit_theme->apple_touch_icon_url->value));
         module::event("theme_edit_form_completed", $form);
         message::success(t("Updated theme details"));
         url::redirect("admin/theme_options");
     } else {
         $view = new Admin_View("admin.html");
         $view->content = new View("admin_theme_options.html");
         $view->content->form = $form;
         print $view;
     }
 }
コード例 #14
0
ファイル: admin_identity.php プロジェクト: viosca/gallery3
 public function change()
 {
     access::verify_csrf();
     $active_provider = module::get_var("gallery", "identity_provider", "user");
     $providers = identity::providers();
     $new_provider = Input::instance()->post("provider");
     if ($new_provider != $active_provider) {
         module::deactivate($active_provider);
         // Switch authentication
         identity::reset();
         module::set_var("gallery", "identity_provider", $new_provider);
         module::install($new_provider);
         module::activate($new_provider);
         module::event("identity_provider_changed", $active_provider, $new_provider);
         module::uninstall($active_provider);
         message::success(t("Changed to %description", array("description" => $providers->{$new_provider})));
         try {
             Session::instance()->destroy();
         } catch (Exception $e) {
             // We don't care if there was a problem destroying the session.
         }
         url::redirect(item::root()->abs_url());
     }
     message::info(t("The selected provider \"%description\" is already active.", array("description" => $providers->{$new_provider})));
     url::redirect("admin/identity");
 }
コード例 #15
0
 function save($album_id)
 {
     access::verify_csrf();
     $album = ORM::factory("item", $album_id);
     access::required("edit", $album);
     if (Input::instance()->post("save")) {
         $titles = Input::instance()->post("title");
         $descriptions = Input::instance()->post("description");
         $filenames = Input::instance()->post("filename");
         $internetaddresses = Input::instance()->post("internetaddress");
         $tags = Input::instance()->post("tags");
         $enable_tags = module::is_active("tag");
         foreach (array_keys($titles) as $id) {
             $item = ORM::factory("item", $id);
             if ($item->loaded() && access::can("edit", $item)) {
                 $item->title = $titles[$id];
                 $item->description = $descriptions[$id];
                 $item->name = $filenames[$id];
                 $item->slug = $internetaddresses[$id];
                 $item->save();
                 if ($enable_tags) {
                     tag::clear_all($item);
                     foreach (explode(",", $tags[$id]) as $tag_name) {
                         if ($tag_name) {
                             tag::add($item, trim($tag_name));
                         }
                     }
                     tag::compact();
                 }
             }
         }
         message::success(t("Captions saved"));
     }
     url::redirect($album->abs_url());
 }
コード例 #16
0
ファイル: rest.php プロジェクト: kandsten/gallery3
 public function reset_api_key()
 {
     access::verify_csrf();
     rest::reset_access_key();
     message::success(t("Your REST API key has been reset."));
     json::reply(array("result" => "success"));
 }
コード例 #17
0
 public function save()
 {
     access::verify_csrf();
     $form = theme::get_edit_form_admin();
     if ($form->validate()) {
         module::set_var("gallery", "page_size", $form->edit_theme->page_size->value);
         $thumb_size = $form->edit_theme->thumb_size->value;
         $thumb_dirty = false;
         if (module::get_var("gallery", "thumb_size") != $thumb_size) {
             graphics::remove_rule("gallery", "thumb", "gallery_graphics::resize");
             graphics::add_rule("gallery", "thumb", "gallery_graphics::resize", array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), 100);
             module::set_var("gallery", "thumb_size", $thumb_size);
         }
         $resize_size = $form->edit_theme->resize_size->value;
         $resize_dirty = false;
         if (module::get_var("gallery", "resize_size") != $resize_size) {
             graphics::remove_rule("gallery", "resize", "gallery_graphics::resize");
             graphics::add_rule("gallery", "resize", "gallery_graphics::resize", array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), 100);
             module::set_var("gallery", "resize_size", $resize_size);
         }
         module::set_var("gallery", "header_text", $form->edit_theme->header_text->value);
         module::set_var("gallery", "footer_text", $form->edit_theme->footer_text->value);
         module::set_var("gallery", "show_credits", $form->edit_theme->show_credits->value);
         message::success(t("Updated theme details"));
         url::redirect("admin/theme_options");
     } else {
         $view = new Admin_View("admin.html");
         $view->content = $form;
         print $view;
     }
 }
コード例 #18
0
 public function update()
 {
     //Get the ordered list of modules
     $modulerawlist = explode("&", trim($_POST['modulelist'], "&"));
     //Make sure that gallery and user modules are first in the list
     $current_weight = 2;
     $identity_provider = module::get_var("gallery", "identity_provider");
     foreach ($modulerawlist as $row) {
         $currentry = explode("=", $row);
         $currentry = explode(":", $currentry[1]);
         if ($currentry[0] == "gallery") {
             $modulelist[0] = $row;
         } elseif ($currentry[0] == $identity_provider) {
             $modulelist[1] = $row;
         } else {
             $modulelist[$current_weight] = $row;
             $current_weight++;
         }
     }
     ksort($modulelist);
     //Write the correct weight values
     $current_weight = 0;
     foreach ($modulelist as $row) {
         $current_weight++;
         $currentry = explode("=", $row);
         $currentry = explode(":", $currentry[1]);
         db::build()->update("modules")->set("weight", $current_weight)->where("id", "=", $currentry[1])->execute();
     }
     message::success(t("Your settings have been saved."));
     url::redirect("admin/moduleorder");
     print $this->_get_view();
 }
コード例 #19
0
ファイル: Specprojects.php プロジェクト: HappyKennyD/teest
 public function action_index()
 {
     $type = $this->request->param('type');
     $search = Security::xss_clean(Arr::get($_POST, 'search', ''));
     if ($post = $this->request->post()) {
         $title = Security::xss_clean(Arr::get($post, 'title1', ''));
         if ($title != '') {
             $titles = ORM::factory('Specprojecttitle', $type);
             $titles->title = $title;
             $titles->save();
             message::success('Успешно изменено');
             $this->redirect('manage/specprojects/' . $type);
         } else {
             message::error('Поле не может быть пустым.');
             $this->redirect('manage/specprojects/' . $type);
         }
     }
     if (!empty($search)) {
         $this->redirect('manage/specprojects/' . $type . '/search/' . $search);
     }
     $public = ORM::factory('Publication')->join('spec_projects', 'LEFT')->on('publication.id', '=', 'spec_projects.id_publication')->select('publication.*', 'spec_projects.spec_published', 'spec_projects.in_slider', 'spec_projects.in_middle', 'spec_projects.in_bottom')->where('spec_projects.sproject', '=', $type)->order_by('order', 'desc')->order_by('date', 'DESC');
     $paginate = Paginate::factory($public)->paginate(NULL, NULL, 10)->render();
     $public = $public->find_all();
     $title = ORM::factory('Specprojecttitle', $type)->title;
     $this->set('title', $title);
     $this->set('list', $public)->set('type', $type);
     $this->set('paginate', $paginate);
 }
コード例 #20
0
 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;
 }
コード例 #21
0
 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);
 }
コード例 #22
0
ファイル: photos.php プロジェクト: scarygary/gallery3
 /**
  * @see REST_Controller::_update($resource)
  */
 public function _update($photo)
 {
     access::verify_csrf();
     access::required("view", $photo);
     access::required("edit", $photo);
     $form = photo::get_edit_form($photo);
     $valid = $form->validate();
     if ($valid = $form->validate()) {
         if ($form->edit_item->filename->value != $photo->name || $form->edit_item->slug->value != $photo->slug) {
             // Make sure that there's not a name or slug conflict
             if ($row = Database::instance()->select(array("name", "slug"))->from("items")->where("parent_id", $photo->parent_id)->where("id <>", $photo->id)->open_paren()->where("name", $form->edit_item->filename->value)->orwhere("slug", $form->edit_item->slug->value)->close_paren()->get()->current()) {
                 if ($row->name == $form->edit_item->filename->value) {
                     $form->edit_item->filename->add_error("name_conflict", 1);
                 }
                 if ($row->slug == $form->edit_item->slug->value) {
                     $form->edit_item->slug->add_error("slug_conflict", 1);
                 }
                 $valid = false;
             }
         }
     }
     if ($valid) {
         $photo->title = $form->edit_item->title->value;
         $photo->description = $form->edit_item->description->value;
         $photo->slug = $form->edit_item->slug->value;
         $photo->rename($form->edit_item->filename->value);
         $photo->save();
         module::event("item_edit_form_completed", $photo, $form);
         log::success("content", "Updated photo", "<a href=\"{$photo->url()}\">view</a>");
         message::success(t("Saved photo %photo_title", array("photo_title" => html::purify($photo->title))));
         print json_encode(array("result" => "success"));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
コード例 #23
0
 public function saveprefs()
 {
     // Prevent Cross Site Request Forgery
     access::verify_csrf();
     $form = $this->_get_admin_form();
     if ($form->validate()) {
         Kohana_Log::add("error", print_r($form, 1));
         module::set_var("tag_albums", "tag_page_title", $form->Tag_Albums_Tag_Sort->tag_page_title->value);
         module::set_var("tag_albums", "tag_index", $form->Tag_Albums_Tag_Sort->tag_index->value);
         module::set_var("tag_albums", "tag_index_scope", count($form->Tag_Albums_Tag_Sort->tag_index_scope->value));
         module::set_var("tag_albums", "tag_index_filter_top", count($form->Tag_Albums_Tag_Sort->tag_index_filter_top->value));
         module::set_var("tag_albums", "tag_index_filter_bottom", count($form->Tag_Albums_Tag_Sort->tag_index_filter_bottom->value));
         module::set_var("tag_albums", "tag_sort_by", $form->Tag_Albums_Tag_Sort->tag_sort_by->value);
         module::set_var("tag_albums", "tag_sort_direction", $form->Tag_Albums_Tag_Sort->tag_sort_direction->value);
         module::set_var("tag_albums", "subalbum_sort_by", $form->Tag_Albums_Tag_Item_Sort->subalbum_sort_by->value);
         module::set_var("tag_albums", "subalbum_sort_direction", $form->Tag_Albums_Tag_Item_Sort->subalbum_sort_direction->value);
         message::success(t("Your settings have been saved."));
         url::redirect("admin/tag_albums");
     }
     // Else show the page with errors
     $view = new Admin_View("admin.html");
     $view->content = new View("admin_tag_albums.html");
     $view->content->tag_albums_form = $form;
     print $view;
 }
コード例 #24
0
 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;
 }
コード例 #25
0
ファイル: users.php プロジェクト: kstyrvoll/gallery3
 public function _update($user)
 {
     if ($user->guest || $user->id != user::active()->id) {
         access::forbidden();
     }
     $form = user::get_edit_form($user);
     $valid = $form->validate();
     if ($valid) {
         $user->full_name = $form->edit_user->full_name->value;
         if ($form->edit_user->password->value) {
             $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}")));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
コード例 #26
0
 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;
 }
コード例 #27
0
 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);
 }
コード例 #28
0
ファイル: admin_languages.php プロジェクト: hiwilson/gallery3
 private function _save_api_key($form)
 {
     $new_key = $form->sharing->api_key->value;
     if ($new_key && !l10n_client::validate_api_key($new_key)) {
         $form->sharing->api_key->add_error("invalid", 1);
         $valid = false;
     } else {
         $valid = true;
     }
     if ($valid) {
         $old_key = l10n_client::api_key();
         l10n_client::api_key($new_key);
         if ($old_key && !$new_key) {
             message::success(t("Your API key has been cleared."));
         } else {
             if ($old_key && $new_key && $old_key != $new_key) {
                 message::success(t("Your API key has been changed."));
             } else {
                 if (!$old_key && $new_key) {
                     message::success(t("Your API key has been saved."));
                 }
             }
         }
         log::success(t("gallery"), t("l10n_client API key changed."));
         url::redirect("admin/languages");
     } else {
         // Show the page with form errors
         $this->index($form);
     }
 }
コード例 #29
0
 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;
 }
コード例 #30
0
 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()) {
         // Save settings to Gallery's database.
         module::set_var("exif_gps", "googlemap_api_key", $form->Global->google_api_key->value);
         module::set_var("exif_gps", "googlemap_max_autozoom", $form->Global->max_auto_zoom_level->value);
         module::set_var("exif_gps", "markercluster_gridsize", $form->markercluster->markercluster_gridsize->value);
         module::set_var("exif_gps", "markercluster_maxzoom", $form->markercluster->markercluster_maxzoom->value);
         module::set_var("exif_gps", "sidebar_zoom", $form->Sidebar->sidebar_default_zoom->value);
         module::set_var("exif_gps", "sidebar_mapformat", $form->Sidebar->sidebar_mapformat->value);
         module::set_var("exif_gps", "sidebar_maptype", $form->Sidebar->sidebar_maptype->value);
         module::set_var("exif_gps", "largemap_maptype", $form->LargeMap->largemap_maptype->value);
         module::set_var("exif_gps", "toolbar_map_album", $form->Global->toolbar_map_album->value);
         module::set_var("exif_gps", "toolbar_map_user", $form->Global->toolbar_map_user->value);
         module::set_var("exif_gps", "restrict_maps", $form->Global->restrict_maps->value);
         // Display a success message and redirect back to the TagsMap admin page.
         message::success(t("Your settings have been saved."));
         url::redirect("admin/exif_gps");
     }
     // Else show the page with errors
     $view = new Admin_View("admin.html");
     $view->content = new View("admin_exif_gps.html");
     $view->content->exifgps_form = $form;
     print $view;
 }