| 1 | # Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd. |
|---|
| 2 | # This program is distributed under the terms of the |
|---|
| 3 | # GNU General Public License, version 2. |
|---|
| 4 | # |
|---|
| 5 | # $Id$ |
|---|
| 6 | |
|---|
| 7 | package MT::App::CMS; |
|---|
| 8 | |
|---|
| 9 | use strict; |
|---|
| 10 | use base qw( MT::App ); |
|---|
| 11 | |
|---|
| 12 | use MT::Util qw( format_ts epoch2ts perl_sha1_digest_hex perl_sha1_digest |
|---|
| 13 | Â Â remove_html ); |
|---|
| 14 | |
|---|
| 15 | sub LISTING_DATE_FORMATÂ ()Â Â Â {Â '%b %e, %Y'Â } |
|---|
| 16 | sub LISTING_DATETIME_FORMATÂ ()Â {Â '%b %e, %Y'Â } |
|---|
| 17 | sub LISTING_TIMESTAMP_FORMATÂ ()Â {Â "%Y-%m-%d %I:%M:%S%p"Â } |
|---|
| 18 | sub NEW_PHASEÂ ()Â {Â 1Â } |
|---|
| 19 | |
|---|
| 20 | sub id { 'cms' } |
|---|
| 21 | |
|---|
| 22 | sub init { |
|---|
| 23 |   my $app = shift; |
|---|
| 24 |   $app->SUPER::init(@_) or return; |
|---|
| 25 | Â Â $app->{state_params}Â =Â [ |
|---|
| 26 |     '_type', 'id',     'tab',   'offset', |
|---|
| 27 |     'filter', 'filter_val', 'blog_id', 'is_power_edit', |
|---|
| 28 |     'filter_key', 'type' |
|---|
| 29 | Â Â ]; |
|---|
| 30 | Â Â $app->{template_dir}Â Â Â Â Â =Â 'cms'; |
|---|
| 31 | Â Â $app->{plugin_template_path}Â =Â ''; |
|---|
| 32 | Â Â $app->{is_admin}Â Â Â Â Â Â Â =Â 1; |
|---|
| 33 | Â Â $app->{default_mode}Â Â Â Â Â =Â 'dashboard'; |
|---|
| 34 | Â Â $app; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | sub core_methods { |
|---|
| 38 |   my $app = shift; |
|---|
| 39 |   my $pkg = '$Core::MT::CMS::'; |
|---|
| 40 |   return { |
|---|
| 41 | Â Â Â Â 'tools'Â Â Â =>Â "${pkg}Tools::system_check", |
|---|
| 42 | Â Â Â Â 'dashboard'Â =>Â "${pkg}Dashboard::dashboard", |
|---|
| 43 | Â Â Â Â 'menu'Â Â Â =>Â '${pkg}Dashboard::dashboard', |
|---|
| 44 | Â Â Â Â 'admin'Â Â Â =>Â '${pkg}Dashboard::dashboard', |
|---|
| 45 | |
|---|
| 46 | Â Â Â Â ## Generic handlers |
|---|
| 47 | Â Â Â Â 'save'Â Â Â Â Â Â =>Â "${pkg}Common::save", |
|---|
| 48 | Â Â Â Â 'edit'Â Â Â Â Â Â =>Â "${pkg}Common::edit", |
|---|
| 49 | Â Â Â Â 'view'Â Â Â Â Â Â =>Â "${pkg}Common::edit", |
|---|
| 50 | Â Â Â Â 'list'Â Â Â Â Â Â =>Â "${pkg}Common::list", |
|---|
| 51 | Â Â Â Â 'delete'Â Â Â Â Â =>Â "${pkg}Common::delete", |
|---|
| 52 | Â Â Â Â 'search_replace'Â =>Â "${pkg}Search::search_replace", |
|---|
| 53 | |
|---|
| 54 | Â Â Â Â ## Edit methods |
|---|
| 55 | Â Â Â Â 'edit_role'Â =>Â "${pkg}User::edit_role", |
|---|
| 56 | |
|---|
| 57 | Â Â Â Â ## Listing methods |
|---|
| 58 | Â Â Â Â 'list_ping'Â Â Â =>Â "${pkg}TrackBack::list", |
|---|
| 59 | Â Â Â Â 'list_entry'Â Â =>Â "${pkg}Entry::list", |
|---|
| 60 | Â Â Â Â 'list_template'Â =>Â "${pkg}Template::list", |
|---|
| 61 | Â Â Â Â 'list_page'Â Â Â =>Â "${pkg}Page::list", |
|---|
| 62 | Â Â Â Â 'list_comment'Â =>Â { |
|---|
| 63 |       handler  => "${pkg}Comment::list", |
|---|
| 64 | Â Â Â Â Â Â permission =>Â 'view_feedback', |
|---|
| 65 | Â Â Â Â }, |
|---|
| 66 | Â Â Â Â 'list_member'Â Â Â =>Â "${pkg}User::list_member", |
|---|
| 67 | Â Â Â Â 'list_user'Â Â Â Â =>Â "${pkg}User::list", |
|---|
| 68 | Â Â Â Â 'list_author'Â Â Â =>Â "${pkg}User::list", |
|---|
| 69 | Â Â Â Â 'list_commenter'Â Â =>Â "${pkg}Comment::list_commenter", |
|---|
| 70 | Â Â Â Â 'list_asset'Â Â Â Â =>Â "${pkg}Asset::list", |
|---|
| 71 | Â Â Â Â 'list_blog'Â Â Â Â =>Â "${pkg}Blog::list", |
|---|
| 72 | Â Â Â Â 'list_category'Â Â =>Â "${pkg}Category::list", |
|---|
| 73 | Â Â Â Â 'list_tag'Â Â Â Â Â =>Â "${pkg}Tag::list", |
|---|
| 74 | Â Â Â Â 'list_association'Â =>Â "${pkg}User::list_association", |
|---|
| 75 | Â Â Â Â 'list_role'Â Â Â Â =>Â "${pkg}User::list_role", |
|---|
| 76 | |
|---|
| 77 | Â Â Â Â 'asset_insert'Â Â Â Â =>Â "${pkg}Asset::insert", |
|---|
| 78 | Â Â Â Â 'asset_userpic'Â Â Â Â =>Â "${pkg}User::asset_userpic", |
|---|
| 79 | Â Â Â Â 'save_commenter_perm'Â =>Â "${pkg}Comment::save_commenter_perm", |
|---|
| 80 | Â Â Â Â 'trust_commenter'Â Â Â =>Â "${pkg}Comment::trust_commenter", |
|---|
| 81 | Â Â Â Â 'ban_commenter'Â Â Â Â =>Â "${pkg}Comment::ban_commenter", |
|---|
| 82 | Â Â Â Â 'approve_item'Â Â Â Â =>Â "${pkg}Comment::approve_item", |
|---|
| 83 | Â Â Â Â 'unapprove_item'Â Â Â =>Â "${pkg}Comment::unapprove_item", |
|---|
| 84 | Â Â Â Â 'preview_entry'Â Â Â Â =>Â "${pkg}Entry::preview", |
|---|
| 85 | |
|---|
| 86 | Â Â Â Â ## Blog configuration screens |
|---|
| 87 | Â Â Â Â 'cfg_archives'Â Â Â =>Â "${pkg}Blog::cfg_archives", |
|---|
| 88 | Â Â Â Â 'cfg_prefs'Â Â Â Â =>Â "${pkg}Blog::cfg_prefs", |
|---|
| 89 | Â Â Â Â 'cfg_plugins'Â Â Â =>Â "${pkg}Plugin::cfg_plugins", |
|---|
| 90 | Â Â Â Â 'cfg_comments'Â Â Â =>Â "${pkg}Comment::cfg_comments", |
|---|
| 91 | Â Â Â Â 'cfg_trackbacks'Â Â =>Â "${pkg}TrackBack::cfg_trackbacks", |
|---|
| 92 | Â Â Â Â 'cfg_registration'Â =>Â "${pkg}Comment::cfg_registration", |
|---|
| 93 | Â Â Â Â 'cfg_spam'Â Â Â Â Â =>Â "${pkg}Comment::cfg_spam", |
|---|
| 94 | Â Â Â Â 'cfg_entry'Â Â Â Â =>Â "${pkg}Entry::cfg_entry", |
|---|
| 95 | Â Â Â Â 'cfg_web_services'Â =>Â "${pkg}Blog::cfg_web_services", |
|---|
| 96 | |
|---|
| 97 | Â Â Â Â ## Save |
|---|
| 98 | Â Â Â Â 'save_cat'Â Â Â =>Â "${pkg}Category::save", |
|---|
| 99 | Â Â Â Â 'save_entries'Â =>Â "${pkg}Entry::save_entries", |
|---|
| 100 | Â Â Â Â 'save_pages'Â Â =>Â "${pkg}Page::save_pages", |
|---|
| 101 | Â Â Â Â 'save_entry'Â Â =>Â "${pkg}Entry::save", |
|---|
| 102 | Â Â Â Â 'save_role'Â Â =>Â "${pkg}User::save_role", |
|---|
| 103 | |
|---|
| 104 | Â Â Â Â ## Delete |
|---|
| 105 | Â Â Â Â 'delete_entry'Â Â =>Â "${pkg}Entry::delete", |
|---|
| 106 | |
|---|
| 107 | Â Â Â Â ## List actions |
|---|
| 108 | Â Â Â Â 'enable_object'Â =>Â "${pkg}User::enable", |
|---|
| 109 | Â Â Â Â 'disable_object'Â =>Â "${pkg}User::disable", |
|---|
| 110 | Â Â Â Â 'list_action'Â Â =>Â "${pkg}Tools::do_list_action", |
|---|
| 111 | Â Â Â Â 'empty_junk'Â Â Â =>Â "${pkg}Comment::empty_junk", |
|---|
| 112 | Â Â Â Â 'handle_junk'Â Â =>Â "${pkg}Comment::handle_junk", |
|---|
| 113 | Â Â Â Â 'not_junk'Â Â Â Â =>Â "${pkg}Comment::not_junk", |
|---|
| 114 | |
|---|
| 115 | Â Â Â Â 'ping'Â Â Â Â Â Â Â Â =>Â "${pkg}Entry::send_pings", |
|---|
| 116 | Â Â Â Â 'rebuild_phase'Â Â Â =>Â "${pkg}Blog::rebuild_phase", |
|---|
| 117 | Â Â Â Â 'rebuild'Â Â Â Â Â Â =>Â "${pkg}Blog::rebuild_pages", |
|---|
| 118 | Â Â Â Â 'rebuild_new_phase'Â =>Â "${pkg}Blog::rebuild_new_phase", |
|---|
| 119 | Â Â Â Â 'start_rebuild'Â Â Â =>Â "${pkg}Blog::start_rebuild_pages", |
|---|
| 120 | Â Â Â Â 'rebuild_confirm'Â Â =>Â "${pkg}Blog::rebuild_confirm", |
|---|
| 121 | Â Â Â Â 'entry_notify'Â Â Â Â =>Â "${pkg}AddressBook::entry_notify", |
|---|
| 122 | Â Â Â Â 'send_notify'Â Â Â Â =>Â "${pkg}AddressBook::send_notify", |
|---|
| 123 | Â Â Â Â 'start_upload'Â Â Â Â =>Â "${pkg}Asset::start_upload", |
|---|
| 124 | Â Â Â Â 'upload_file'Â Â Â Â =>Â "${pkg}Asset::upload_file", |
|---|
| 125 | Â Â Â Â 'upload_userpic'Â Â Â =>Â "${pkg}User::upload_userpic", |
|---|
| 126 | Â Â Â Â 'complete_insert'Â Â =>Â "${pkg}Asset::complete_insert", |
|---|
| 127 | Â Â Â Â 'complete_upload'Â Â =>Â "${pkg}Asset::complete_upload", |
|---|
| 128 | Â Â Â Â 'start_upload_entry'Â =>Â "${pkg}Asset::start_upload_entry", |
|---|
| 129 | Â Â Â Â 'logout'Â Â Â Â Â Â Â =>Â { |
|---|
| 130 |       code      => sub { $_[0]->SUPER::logout(@_) }, |
|---|
| 131 | Â Â Â Â Â Â requires_login =>Â 0, |
|---|
| 132 | Â Â Â Â }, |
|---|
| 133 | Â Â Â Â 'start_recover'Â =>Â { |
|---|
| 134 |       code      => "${pkg}Tools::start_recover", |
|---|
| 135 | Â Â Â Â Â Â requires_login =>Â 0, |
|---|
| 136 | Â Â Â Â }, |
|---|
| 137 | Â Â Â Â 'recover'Â =>Â { |
|---|
| 138 |       code      => "${pkg}Tools::recover_password", |
|---|
| 139 | Â Â Â Â Â Â requires_login =>Â 0, |
|---|
| 140 | Â Â Â Â }, |
|---|
| 141 | |
|---|
| 142 | Â Â Â Â 'view_log'Â Â Â Â Â Â =>Â "${pkg}Log::view", |
|---|
| 143 | Â Â Â Â 'list_log'Â Â Â Â Â Â =>Â "${pkg}Log::view", |
|---|
| 144 | Â Â Â Â 'reset_log'Â Â Â Â Â Â =>Â "${pkg}Log::reset", |
|---|
| 145 | Â Â Â Â 'export_log'Â Â Â Â Â =>Â "${pkg}Log::export", |
|---|
| 146 | Â Â Â Â 'export_notification'Â =>Â "${pkg}AddressBook::export", |
|---|
| 147 | Â Â Â Â 'start_import'Â Â Â Â =>Â "${pkg}Import::start_import", |
|---|
| 148 | Â Â Â Â 'start_export'Â Â Â Â =>Â "${pkg}Export::start_export", |
|---|
| 149 | Â Â Â Â 'export'Â Â Â Â Â Â Â =>Â "${pkg}Export::export", |
|---|
| 150 | Â Â Â Â 'import'Â Â Â Â Â Â Â =>Â "${pkg}Import::do_import", |
|---|
| 151 | Â Â Â Â 'pinged_urls'Â Â Â Â Â =>Â "${pkg}Entry::pinged_urls", |
|---|
| 152 | Â Â Â Â 'save_entry_prefs'Â Â =>Â "${pkg}Entry::save_entry_prefs", |
|---|
| 153 | Â Â Â Â 'save_favorite_blogs'Â =>Â "${pkg}Blog::save_favorite_blogs", |
|---|
| 154 | Â Â Â Â 'folder_add'Â Â Â Â Â Â Â Â =>Â "${pkg}Category::category_add", |
|---|
| 155 | Â Â Â Â 'category_add'Â Â Â Â Â Â Â =>Â "${pkg}Category::category_add", |
|---|
| 156 | Â Â Â Â 'category_do_add'Â Â Â Â Â =>Â "${pkg}Category::category_do_add", |
|---|
| 157 | Â Â Â Â 'cc_return'Â Â Â Â Â Â Â Â =>Â "${pkg}Blog::cc_return", |
|---|
| 158 | Â Â Â Â 'reset_blog_templates'Â Â Â =>Â "${pkg}Template::reset_blog_templates", |
|---|
| 159 | Â Â Â Â 'handshake'Â Â Â Â Â Â Â Â =>Â "${pkg}Blog::handshake", |
|---|
| 160 | Â Â Â Â 'itemset_action'Â Â Â Â Â Â =>Â "${pkg}Tools::do_list_action", |
|---|
| 161 | Â Â Â Â 'page_action'Â Â Â Â Â Â Â =>Â "${pkg}Tools::do_page_action", |
|---|
| 162 | Â Â Â Â 'cfg_system'Â Â Â Â Â Â Â Â =>Â "${pkg}Tools::cfg_system_general", |
|---|
| 163 | Â Â Â Â 'cfg_system_users'Â Â Â Â Â =>Â "${pkg}User::cfg_system_users", |
|---|
| 164 | Â Â Â Â 'cfg_system_feedback'Â Â Â =>Â "${pkg}Comment::cfg_system_feedback", |
|---|
| 165 | Â Â Â Â 'save_plugin_config'Â Â Â Â =>Â "${pkg}Plugin::save_config", |
|---|
| 166 | Â Â Â Â 'reset_plugin_config'Â Â Â =>Â "${pkg}Plugin::reset_config", |
|---|
| 167 | Â Â Â Â 'save_cfg_system_feedback'Â =>Â "${pkg}Comment::save_cfg_system_feedback", |
|---|
| 168 | Â Â Â Â 'save_cfg_system_general'Â =>Â "${pkg}Tools::save_cfg_system_general", |
|---|
| 169 | Â Â Â Â 'save_cfg_system_users'Â Â =>Â "${pkg}User::save_cfg_system_users", |
|---|
| 170 | Â Â Â Â 'update_welcome_message'Â Â =>Â "${pkg}Blog::update_welcome_message", |
|---|
| 171 | Â Â Â Â 'upgrade'Â Â Â Â Â Â Â Â Â =>Â { |
|---|
| 172 |       code      => "${pkg}Tools::upgrade", |
|---|
| 173 | Â Â Â Â Â Â requires_login =>Â 0, |
|---|
| 174 | Â Â Â Â }, |
|---|
| 175 | Â Â Â Â 'plugin_control'Â Â Â Â Â Â =>Â "${pkg}Plugin::plugin_control", |
|---|
| 176 | Â Â Â Â 'recover_profile_password'Â =>Â "${pkg}User::recover_profile_password", |
|---|
| 177 | Â Â Â Â 'rename_tag'Â Â Â Â Â Â Â Â =>Â "${pkg}Tag::rename_tag", |
|---|
| 178 | Â Â Â Â 'remove_user_assoc'Â Â Â Â =>Â "${pkg}User::remove_user_assoc", |
|---|
| 179 | Â Â Â Â 'revoke_role'Â Â Â Â Â Â Â =>Â "${pkg}User::revoke_role", |
|---|
| 180 | Â Â Â Â 'grant_role'Â Â Â Â Â Â Â Â =>Â "${pkg}User::grant_role", |
|---|
| 181 | Â Â Â Â 'start_backup'Â Â Â Â Â Â Â =>Â "${pkg}Tools::start_backup", |
|---|
| 182 | Â Â Â Â 'start_restore'Â Â Â Â Â Â =>Â "${pkg}Tools::start_restore", |
|---|
| 183 | Â Â Â Â 'backup'Â Â Â Â Â Â Â Â Â Â =>Â "${pkg}Tools::backup", |
|---|
| 184 | Â Â Â Â 'backup_download'Â Â Â Â Â =>Â "${pkg}Tools::backup_download", |
|---|
| 185 | Â Â Â Â 'restore'Â Â Â Â Â Â Â Â Â =>Â "${pkg}Tools::restore", |
|---|
| 186 | Â Â Â Â 'restore_premature_cancel'Â =>Â "${pkg}Tools::restore_premature_cancel", |
|---|
| 187 | Â Â Â Â 'adjust_sitepath'Â Â Â Â Â =>Â "${pkg}Tools::adjust_sitepath", |
|---|
| 188 | Â Â Â Â 'system_check'Â Â Â Â Â Â Â =>Â "${pkg}Tools::system_check", |
|---|
| 189 | Â Â Â Â 'dialog_refresh_templates'Â =>Â "${pkg}Template::dialog_refresh_templates", |
|---|
| 190 | Â Â Â Â 'dialog_publishing_profile'Â =>Â "${pkg}Template::dialog_publishing_profile", |
|---|
| 191 | Â Â Â Â 'refresh_all_templates'Â Â =>Â "${pkg}Template::refresh_all_templates", |
|---|
| 192 | Â Â Â Â 'preview_template'Â Â Â Â Â =>Â "${pkg}Template::preview", |
|---|
| 193 | Â Â Â Â 'publish_index_templates'Â =>Â "${pkg}Template::publish_index_templates", |
|---|
| 194 | Â Â Â Â 'publish_archive_templates'=>Â "${pkg}Template::publish_archive_templates", |
|---|
| 195 | |
|---|
| 196 | Â Â Â Â ## Comment Replies |
|---|
| 197 |     reply     => "${pkg}Comment::reply", |
|---|
| 198 |     do_reply   => "${pkg}Comment::do_reply", |
|---|
| 199 | Â Â Â Â reply_preview =>Â "${pkg}Comment::reply_preview", |
|---|
| 200 | |
|---|
| 201 | Â Â Â Â ## Dialogs |
|---|
| 202 | Â Â Â Â 'dialog_restore_upload'Â =>Â "${pkg}Tools::dialog_restore_upload", |
|---|
| 203 | Â Â Â Â 'dialog_adjust_sitepath'Â =>Â "${pkg}Tools::dialog_adjust_sitepath", |
|---|
| 204 | Â Â Â Â 'dialog_post_comment'Â Â =>Â "${pkg}Comment::dialog_post_comment", |
|---|
| 205 | Â Â Â Â 'dialog_select_weblog'Â Â =>Â "${pkg}Blog::dialog_select_weblog", |
|---|
| 206 | Â Â Â Â 'dialog_select_sysadmin'Â =>Â "${pkg}User::dialog_select_sysadmin", |
|---|
| 207 | Â Â Â Â 'dialog_grant_role'Â Â Â =>Â "${pkg}User::dialog_grant_role", |
|---|
| 208 | Â Â Â Â 'dialog_select_author'Â Â =>Â "${pkg}User::dialog_select_author", |
|---|
| 209 | |
|---|
| 210 | Â Â Â Â ## AJAX handlers |
|---|
| 211 | Â Â Â Â 'delete_map'Â Â Â Â =>Â "${pkg}Template::delete_map", |
|---|
| 212 | Â Â Â Â 'add_map'Â Â Â Â Â Â =>Â "${pkg}Template::add_map", |
|---|
| 213 | Â Â Â Â 'js_tag_check'Â Â Â =>Â "${pkg}Tag::js_tag_check", |
|---|
| 214 | Â Â Â Â 'js_tag_list'Â Â Â Â =>Â "${pkg}Tag::js_tag_list", |
|---|
| 215 | Â Â Â Â 'convert_to_html'Â Â =>Â "${pkg}Tools::convert_to_html", |
|---|
| 216 | Â Â Â Â 'update_list_prefs'Â =>Â "${pkg}Tools::update_list_prefs", |
|---|
| 217 | Â Â Â Â 'js_add_category'Â Â =>Â "${pkg}Category::js_add_category", |
|---|
| 218 | Â Â Â Â 'remove_userpic'Â Â =>Â "${pkg}User::remove_userpic", |
|---|
| 219 | |
|---|
| 220 | Â Â Â Â # declared in MT::App |
|---|
| 221 |     'update_widget_prefs' => sub { return shift->update_widget_prefs(@_) }, |
|---|
| 222 | |
|---|
| 223 | Â Â Â Â 'js_recent_entries_for_tag'Â =>Â "${pkg}Tag::js_recent_entries_for_tag", |
|---|
| 224 | |
|---|
| 225 | Â Â Â Â ## DEPRECATED ## |
|---|
| 226 | Â Â Â Â 'list_pings'Â Â =>Â "${pkg}TrackBack::list", |
|---|
| 227 | Â Â Â Â 'list_entries'Â =>Â "${pkg}Entry::list", |
|---|
| 228 | Â Â Â Â 'list_pages'Â Â =>Â "${pkg}Page::list", |
|---|
| 229 | Â Â Â Â 'list_comments'Â =>Â { |
|---|
| 230 |       handler  => "${pkg}Comment::list", |
|---|
| 231 | Â Â Â Â Â Â permission =>Â 'view_feedback', |
|---|
| 232 | Â Â Â Â }, |
|---|
| 233 | Â Â Â Â 'list_authors'Â Â Â =>Â "${pkg}User::list", |
|---|
| 234 | Â Â Â Â 'list_assets'Â Â Â Â =>Â "${pkg}Asset::list", |
|---|
| 235 | Â Â Â Â 'list_cat'Â Â Â Â Â =>Â "${pkg}Category::list", |
|---|
| 236 | Â Â Â Â 'list_blogs'Â Â Â Â =>Â "${pkg}Blog::list", |
|---|
| 237 | Â Â Â Â 'list_associations'Â =>Â "${pkg}User::list_association", |
|---|
| 238 | Â Â Â Â 'list_roles'Â Â Â Â =>Â "${pkg}User::list_role", |
|---|
| 239 | Â Â }; |
|---|
| 240 | } |
|---|
| 241 | |
|---|
| 242 | sub core_widgets { |
|---|
| 243 |   my $app = shift; |
|---|
| 244 |   my $pkg = '$Core::MT::CMS::'; |
|---|
| 245 |   return { |
|---|
| 246 | Â Â Â Â new_install =>Â { |
|---|
| 247 | Â Â Â Â Â Â template =>Â 'widget/new_install.tmpl', |
|---|
| 248 |       set   => 'main',  # forces this widget to the main group |
|---|
| 249 | Â Â Â Â Â Â singular =>Â 1, |
|---|
| 250 | Â Â Â Â }, |
|---|
| 251 | Â Â Â Â new_user =>Â { |
|---|
| 252 | Â Â Â Â Â Â template =>Â 'widget/new_user.tmpl', |
|---|
| 253 |       set   => 'main',  # forces this widget to the main group |
|---|
| 254 | Â Â Â Â Â Â singular =>Â 1, |
|---|
| 255 | Â Â Â Â }, |
|---|
| 256 | Â Â Â Â new_version =>Â { |
|---|
| 257 | Â Â Â Â Â Â template =>Â 'widget/new_version.tmpl', |
|---|
| 258 |       set   => 'main', |
|---|
| 259 | Â Â Â Â Â Â singular =>Â 1, |
|---|
| 260 |       handler => "${pkg}Dashboard::new_version_widget", |
|---|
| 261 | Â Â Â Â }, |
|---|
| 262 | Â Â Â Â this_is_you =>Â { |
|---|
| 263 |       label  => 'This is You', |
|---|
| 264 | Â Â Â Â Â Â template =>Â 'widget/this_is_you.tmpl', |
|---|
| 265 |       handler => "${pkg}Dashboard::this_is_you_widget", |
|---|
| 266 |       set   => 'sidebar', |
|---|
| 267 | Â Â Â Â Â Â singular =>Â 1, |
|---|
| 268 | Â Â Â Â }, |
|---|
| 269 | Â Â Â Â mt_shortcuts =>Â { |
|---|
| 270 |       label  => 'Handy Shortcuts', |
|---|
| 271 | Â Â Â Â Â Â template =>Â 'widget/mt_shortcuts.tmpl', |
|---|
| 272 | Â Â Â Â Â Â singular =>Â 1, |
|---|
| 273 |       set   => 'sidebar', |
|---|
| 274 | Â Â Â Â }, |
|---|
| 275 | Â Â Â Â mt_news =>Â { |
|---|
| 276 |       label  => 'Movable Type News', |
|---|
| 277 | Â Â Â Â Â Â template =>Â 'widget/mt_news.tmpl', |
|---|
| 278 |       handler => "${pkg}Dashboard::mt_news_widget", |
|---|
| 279 | Â Â Â Â Â Â singular =>Â 1, |
|---|
| 280 |       set   => 'sidebar', |
|---|
| 281 | Â Â Â Â }, |
|---|
| 282 | Â Â Â Â blog_stats =>Â { |
|---|
| 283 |       label  => 'Blog Stats', |
|---|
| 284 | Â Â Â Â Â Â template =>Â 'widget/blog_stats.tmpl', |
|---|
| 285 |       handler => "${pkg}Dashboard::mt_blog_stats_widget", |
|---|
| 286 | Â Â Â Â Â Â singular =>Â 1, |
|---|
| 287 |       set   => 'main', |
|---|
| 288 | Â Â Â Â }, |
|---|
| 289 | Â Â }; |
|---|
| 290 | } |
|---|
| 291 | |
|---|
| 292 | sub core_blog_stats_tabs { |
|---|
| 293 |   my $app = shift; |
|---|
| 294 |   my $pkg = '$Core::MT::CMS::'; |
|---|
| 295 |   return { |
|---|
| 296 | Â Â Â Â entry =>Â { |
|---|
| 297 |       label  => 'Entries', |
|---|
| 298 | Â Â Â Â Â Â template =>Â 'widget/blog_stats_entry.tmpl', |
|---|
| 299 |       handler => "${pkg}Dashboard::mt_blog_stats_widget_entry_tab", |
|---|
| 300 |       stats  => "${pkg}Dashboard::generate_dashboard_stats_entry_tab", |
|---|
| 301 | Â Â Â Â }, |
|---|
| 302 | Â Â Â Â comment =>Â { |
|---|
| 303 |       label  => 'Comments', |
|---|
| 304 | Â Â Â Â Â Â template =>Â 'widget/blog_stats_comment.tmpl', |
|---|
| 305 |       handler => "${pkg}Dashboard::mt_blog_stats_widget_comment_tab", |
|---|
| 306 |       stats  => "${pkg}Dashboard::generate_dashboard_stats_comment_tab", |
|---|
| 307 | Â Â Â Â }, |
|---|
| 308 | Â Â Â Â tag_cloud =>Â { |
|---|
| 309 |       label  => 'Tag Cloud', |
|---|
| 310 | Â Â Â Â Â Â template =>Â 'widget/blog_stats_tag_cloud.tmpl', |
|---|
| 311 | Â Â Â Â }, |
|---|
| 312 | Â Â }; |
|---|
| 313 | } |
|---|
| 314 | |
|---|
| 315 | sub core_page_actions { |
|---|
| 316 |   return { |
|---|
| 317 | Â Â Â Â list_templates =>Â { |
|---|
| 318 | Â Â Â Â Â Â refresh_all_blog_templates =>Â { |
|---|
| 319 | Â Â Â Â Â Â Â Â label =>Â "Refresh Blog Templates", |
|---|
| 320 | Â Â Â Â Â Â Â Â dialog =>Â 'dialog_refresh_templates', |
|---|
| 321 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 322 | Â Â Â Â Â Â Â Â Â Â MT->app->blog, |
|---|
| 323 | Â Â Â Â Â Â Â Â }, |
|---|
| 324 | Â Â Â Â Â Â Â Â order =>Â 1000, |
|---|
| 325 | Â Â Â Â Â Â }, |
|---|
| 326 | Â Â Â Â Â Â refresh_global_templates =>Â { |
|---|
| 327 | Â Â Â Â Â Â Â Â label =>Â "Refresh Global Templates", |
|---|
| 328 | Â Â Â Â Â Â Â Â handler =>Â '$Core::MT::CMS::Template::refresh_all_templates', |
|---|
| 329 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 330 |           ! MT->app->blog, |
|---|
| 331 | Â Â Â Â Â Â Â Â }, |
|---|
| 332 | Â Â Â Â Â Â Â Â order =>Â 1000, |
|---|
| 333 | Â Â Â Â Â Â Â Â continue_prompt =>Â MT->translate('This action will restore your global templates to factory settings without creating a backup. Click OK to continue or Cancel to abort.'), |
|---|
| 334 | Â Â Â Â Â Â }, |
|---|
| 335 | Â Â Â Â Â Â publishing_profile =>Â { |
|---|
| 336 | Â Â Â Â Â Â Â Â label =>Â "Use Publishing Profile", |
|---|
| 337 | Â Â Â Â Â Â Â Â dialog =>Â 'dialog_publishing_profile', |
|---|
| 338 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 339 | Â Â Â Â Â Â Â Â Â Â MT->app->blog, |
|---|
| 340 | Â Â Â Â Â Â Â Â }, |
|---|
| 341 | Â Â Â Â Â Â Â Â order =>Â 1100, |
|---|
| 342 | Â Â Â Â Â Â }, |
|---|
| 343 | Â Â Â Â }, |
|---|
| 344 | Â Â }; |
|---|
| 345 | } |
|---|
| 346 | |
|---|
| 347 | sub init_plugins { |
|---|
| 348 |   my $app = shift; |
|---|
| 349 | |
|---|
| 350 | Â Â # This has to be done prior to plugin initialization since we |
|---|
| 351 | Â Â # may have plugins that register themselves using some of the |
|---|
| 352 | Â Â # older callback names. The callback aliases are declared |
|---|
| 353 | Â Â # in init_core_callbacks. |
|---|
| 354 | Â Â $app->init_core_callbacks(); |
|---|
| 355 | Â Â $app->SUPER::init_plugins(@_); |
|---|
| 356 | } |
|---|
| 357 | |
|---|
| 358 | sub init_request { |
|---|
| 359 |   my $app = shift; |
|---|
| 360 | Â Â $app->SUPER::init_request(@_); |
|---|
| 361 | Â Â $app->set_no_cache; |
|---|
| 362 | Â Â $app->{requires_login}Â =Â 1 |
|---|
| 363 |    unless exists $app->{requires_login};  # by default, we require login |
|---|
| 364 | |
|---|
| 365 |   my $mode = $app->mode; |
|---|
| 366 | |
|---|
| 367 | Â Â # Global 'blog_id' parameter check; if we get something |
|---|
| 368 | Â Â # other than an integer, die |
|---|
| 369 |   if (my $blog_id = $app->param('blog_id')) { |
|---|
| 370 |     if ($blog_id ne int($blog_id)) { |
|---|
| 371 |       die $app->translate("Invalid request"); |
|---|
| 372 | Â Â Â Â } |
|---|
| 373 | Â Â } |
|---|
| 374 | |
|---|
| 375 |   unless (defined $app->{upgrade_required}) { |
|---|
| 376 | Â Â Â Â $app->{upgrade_required}Â =Â 0; |
|---|
| 377 |     if (  ( $mode ne 'logout' ) |
|---|
| 378 |       && ( $mode ne 'start_recover' ) |
|---|
| 379 |       && ( $mode ne 'recover' ) |
|---|
| 380 |       && ( $mode ne 'upgrade' ) ) |
|---|
| 381 | Â Â Â Â { |
|---|
| 382 |       my $schema = $app->config('SchemaVersion'); |
|---|
| 383 |       my $version = $app->config('MTVersion'); |
|---|
| 384 |       if ( !$schema || ( $schema < $app->schema_version ) |
|---|
| 385 |        || ( ( !$version || ( $version < $app->version_number ) ) |
|---|
| 386 | Â Â Â Â Â Â Â Â &&Â $app->config->NotifyUpgrade )Â )Â { |
|---|
| 387 | Â Â Â Â Â Â Â Â $app->{upgrade_required}Â =Â 1; |
|---|
| 388 | Â Â Â Â Â Â } |
|---|
| 389 |       else { |
|---|
| 390 |         foreach my $plugin (@MT::Components) { |
|---|
| 391 |           if ( $plugin->needs_upgrade ) { |
|---|
| 392 | Â Â Â Â Â Â Â Â Â Â Â Â $app->{upgrade_required}Â =Â 1; |
|---|
| 393 | Â Â Â Â Â Â Â Â Â Â Â Â last; |
|---|
| 394 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 395 | Â Â Â Â Â Â Â Â } |
|---|
| 396 | Â Â Â Â Â Â } |
|---|
| 397 | Â Â Â Â } |
|---|
| 398 | Â Â } |
|---|
| 399 | |
|---|
| 400 |   if ($app->{upgrade_required}) { |
|---|
| 401 | Â Â Â Â $app->{requires_login}Â =Â 0; |
|---|
| 402 | Â Â Â Â $app->mode('upgrade'); |
|---|
| 403 | Â Â } |
|---|
| 404 | } |
|---|
| 405 | |
|---|
| 406 | sub core_list_actions { |
|---|
| 407 |   my $app = shift; |
|---|
| 408 |   my $pkg = '$Core::MT::CMS::'; |
|---|
| 409 |   return { |
|---|
| 410 | Â Â Â Â 'entry'Â =>Â { |
|---|
| 411 | Â Â Â Â Â Â 'set_published'Â =>Â { |
|---|
| 412 |         label   => "Publish Entries", |
|---|
| 413 |         order   => 100, |
|---|
| 414 |         code    => "${pkg}Entry::publish_entries", |
|---|
| 415 | Â Â Â Â Â Â Â Â permission =>Â 'edit_all_posts,publish_post', |
|---|
| 416 |         condition => sub { |
|---|
| 417 |           return 0 if $app->mode eq 'view'; |
|---|
| 418 |           return $app->blog && $app->blog->site_path ? 1 : 0; |
|---|
| 419 | Â Â Â Â Â Â Â Â Â } |
|---|
| 420 | Â Â Â Â Â Â }, |
|---|
| 421 | Â Â Â Â Â Â 'set_draft'Â =>Â { |
|---|
| 422 |         label   => "Unpublish Entries", |
|---|
| 423 |         order   => 200, |
|---|
| 424 |         code    => "${pkg}Entry::draft_entries", |
|---|
| 425 | Â Â Â Â Â Â Â Â permission =>Â 'edit_all_posts,publish_post', |
|---|
| 426 |         condition => sub { |
|---|
| 427 |           return 0 if $app->mode eq 'view'; |
|---|
| 428 |           return $app->blog && $app->blog->site_path ? 1 : 0; |
|---|
| 429 | Â Â Â Â Â Â Â Â Â } |
|---|
| 430 | Â Â Â Â Â Â }, |
|---|
| 431 | Â Â Â Â Â Â 'add_tags'Â =>Â { |
|---|
| 432 |         label    => "Add Tags...", |
|---|
| 433 |         order    => 300, |
|---|
| 434 |         code    => "${pkg}Tag::add_tags_to_entries", |
|---|
| 435 |         input    => 1, |
|---|
| 436 | Â Â Â Â Â Â Â Â input_label =>Â 'Tags to add to selected entries', |
|---|
| 437 |         permission => 'edit_all_posts', |
|---|
| 438 |         condition  => sub { |
|---|
| 439 |           return $app->mode ne 'view'; |
|---|
| 440 | Â Â Â Â Â Â Â Â Â } |
|---|
| 441 | Â Â Â Â Â Â }, |
|---|
| 442 | Â Â Â Â Â Â 'remove_tags'Â =>Â { |
|---|
| 443 |         label    => "Remove Tags...", |
|---|
| 444 |         order    => 400, |
|---|
| 445 |         code    => "${pkg}Tag::remove_tags_from_entries", |
|---|
| 446 |         input    => 1, |
|---|
| 447 | Â Â Â Â Â Â Â Â input_label =>Â 'Tags to remove from selected entries', |
|---|
| 448 |         permission => 'edit_all_posts', |
|---|
| 449 |         condition  => sub { |
|---|
| 450 |           return $app->mode ne 'view'; |
|---|
| 451 | Â Â Â Â Â Â Â Â Â } |
|---|
| 452 | Â Â Â Â Â Â }, |
|---|
| 453 | Â Â Â Â Â Â 'open_batch_editor'Â =>Â { |
|---|
| 454 |         label   => "Batch Edit Entries", |
|---|
| 455 |         code   => "${pkg}Entry::open_batch_editor", |
|---|
| 456 |         order   => 500, |
|---|
| 457 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 458 |           return 0 if $app->mode eq 'view'; |
|---|
| 459 | Â Â Â Â Â Â Â Â Â Â $app->param('blog_id') |
|---|
| 460 | Â Â Â Â Â Â Â Â Â Â Â &&Â (Â $app->user->is_superuser() |
|---|
| 461 | Â Â Â Â Â Â Â Â Â Â Â Â ||Â $app->permissions->can_edit_all_posts ); |
|---|
| 462 | Â Â Â Â Â Â Â Â }, |
|---|
| 463 | Â Â Â Â Â Â }, |
|---|
| 464 | Â Â Â Â }, |
|---|
| 465 | Â Â Â Â 'page'Â =>Â { |
|---|
| 466 | Â Â Â Â Â Â 'set_published'Â =>Â { |
|---|
| 467 |         label   => "Publish Pages", |
|---|
| 468 |         order   => 100, |
|---|
| 469 |         code    => "${pkg}Entry::publish_entries", |
|---|
| 470 | Â Â Â Â Â Â Â Â permission =>Â 'manage_pages', |
|---|
| 471 |         condition => sub { |
|---|
| 472 |           return 0 if $app->mode eq 'view'; |
|---|
| 473 |           return $app->blog && $app->blog->site_path ? 1 : 0; |
|---|
| 474 | Â Â Â Â Â Â Â Â }, |
|---|
| 475 | Â Â Â Â Â Â }, |
|---|
| 476 | Â Â Â Â Â Â 'set_draft'Â =>Â { |
|---|
| 477 |         label   => "Unpublish Pages", |
|---|
| 478 |         order   => 200, |
|---|
| 479 |         code    => "${pkg}Entry::draft_entries", |
|---|
| 480 | Â Â Â Â Â Â Â Â permission =>Â 'manage_pages', |
|---|
| 481 |         condition => sub { |
|---|
| 482 |           return 0 if $app->mode eq 'view'; |
|---|
| 483 |           return $app->blog && $app->blog->site_path ? 1 : 0; |
|---|
| 484 | Â Â Â Â Â Â Â Â }, |
|---|
| 485 | Â Â Â Â Â Â }, |
|---|
| 486 | Â Â Â Â Â Â 'add_tags'Â =>Â { |
|---|
| 487 |         label    => "Add Tags...", |
|---|
| 488 |         order    => 300, |
|---|
| 489 |         code    => "${pkg}Tag::add_tags_to_entries", |
|---|
| 490 |         input    => 1, |
|---|
| 491 | Â Â Â Â Â Â Â Â input_label =>Â 'Tags to add to selected pages', |
|---|
| 492 |         permission => 'manage_pages', |
|---|
| 493 |         condition  => sub { |
|---|
| 494 |           return $app->mode ne 'view'; |
|---|
| 495 | Â Â Â Â Â Â Â Â }, |
|---|
| 496 | Â Â Â Â Â Â }, |
|---|
| 497 | Â Â Â Â Â Â 'remove_tags'Â =>Â { |
|---|
| 498 |         label    => "Remove Tags...", |
|---|
| 499 |         order    => 400, |
|---|
| 500 |         code    => "${pkg}Tag::remove_tags_from_entries", |
|---|
| 501 |         input    => 1, |
|---|
| 502 | Â Â Â Â Â Â Â Â input_label =>Â 'Tags to remove from selected pages', |
|---|
| 503 |         permission => 'manage_pages', |
|---|
| 504 |         condition  => sub { |
|---|
| 505 |           return $app->mode ne 'view'; |
|---|
| 506 | Â Â Â Â Â Â Â Â }, |
|---|
| 507 | Â Â Â Â Â Â }, |
|---|
| 508 | Â Â Â Â Â Â 'open_batch_editor'Â =>Â { |
|---|
| 509 |         label   => "Batch Edit Pages", |
|---|
| 510 |         code   => "${pkg}Entry::open_batch_editor", |
|---|
| 511 |         order   => 500, |
|---|
| 512 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 513 |           return 0 if $app->mode eq 'view'; |
|---|
| 514 | Â Â Â Â Â Â Â Â Â Â $app->param('blog_id') |
|---|
| 515 | Â Â Â Â Â Â Â Â Â Â Â &&Â (Â $app->user->is_superuser() |
|---|
| 516 | Â Â Â Â Â Â Â Â Â Â Â Â ||Â $app->permissions->can_manage_pages ); |
|---|
| 517 | Â Â Â Â Â Â Â Â }, |
|---|
| 518 | Â Â Â Â Â Â }, |
|---|
| 519 | Â Â Â Â }, |
|---|
| 520 | Â Â Â Â 'asset'Â =>Â { |
|---|
| 521 | Â Â Â Â Â Â 'add_tags'Â =>Â { |
|---|
| 522 |         label    => "Add Tags...", |
|---|
| 523 |         order    => 100, |
|---|
| 524 |         code    => "${pkg}Tag::add_tags_to_assets", |
|---|
| 525 |         input    => 1, |
|---|
| 526 | Â Â Â Â Â Â Â Â input_label =>Â 'Tags to add to selected assets', |
|---|
| 527 |         permission => 'edit_assets', |
|---|
| 528 | Â Â Â Â Â Â }, |
|---|
| 529 | Â Â Â Â Â Â 'remove_tags'Â =>Â { |
|---|
| 530 |         label    => "Remove Tags...", |
|---|
| 531 |         order    => 200, |
|---|
| 532 |         code    => "${pkg}Tag::remove_tags_from_assets", |
|---|
| 533 |         input    => 1, |
|---|
| 534 | Â Â Â Â Â Â Â Â input_label =>Â 'Tags to remove from selected assets', |
|---|
| 535 |         permission => 'edit_assets', |
|---|
| 536 | Â Â Â Â Â Â }, |
|---|
| 537 | Â Â Â Â }, |
|---|
| 538 | Â Â Â Â 'ping'Â =>Â { |
|---|
| 539 | Â Â Â Â Â Â 'unapprove_ping'Â =>Â { |
|---|
| 540 |         label   => "Unpublish TrackBack(s)", |
|---|
| 541 |         order   => 100, |
|---|
| 542 |         code    => "${pkg}Comment::unapprove_item", |
|---|
| 543 | Â Â Â Â Â Â Â Â permission =>Â 'manage_feedback,publish_post', |
|---|
| 544 | Â Â Â Â Â Â }, |
|---|
| 545 | Â Â Â Â }, |
|---|
| 546 | Â Â Â Â 'comment'Â =>Â { |
|---|
| 547 | Â Â Â Â Â Â 'unapprove_comment'Â =>Â { |
|---|
| 548 |         label   => "Unpublish Comment(s)", |
|---|
| 549 |         order   => 100, |
|---|
| 550 |         code    => "${pkg}Comment::unapprove_item", |
|---|
| 551 | Â Â Â Â Â Â Â Â permission =>Â 'manage_feedback,publish_post', |
|---|
| 552 |         condition => sub { |
|---|
| 553 |           return 1; |
|---|
| 554 | Â Â Â Â Â Â Â Â }, |
|---|
| 555 | Â Â Â Â Â Â }, |
|---|
| 556 | Â Â Â Â Â Â 'trust_commenter'Â =>Â { |
|---|
| 557 |         label   => "Trust Commenter(s)", |
|---|
| 558 |         order   => 200, |
|---|
| 559 |         code    => "${pkg}Comment::trust_commenter_by_comment", |
|---|
| 560 | Â Â Â Â Â Â Â Â permission =>Â 'manage_feedback', |
|---|
| 561 | Â Â Â Â Â Â }, |
|---|
| 562 | Â Â Â Â Â Â 'untrust_commenter'Â =>Â { |
|---|
| 563 |         label   => "Untrust Commenter(s)", |
|---|
| 564 |         order   => 300, |
|---|
| 565 |         code    => "${pkg}Comment::untrust_commenter_by_comment", |
|---|
| 566 | Â Â Â Â Â Â Â Â permission =>Â 'manage_feedback', |
|---|
| 567 | Â Â Â Â Â Â }, |
|---|
| 568 | Â Â Â Â Â Â 'ban_commenter'Â =>Â { |
|---|
| 569 |         label   => "Ban Commenter(s)", |
|---|
| 570 |         order   => 400, |
|---|
| 571 |         code    => "${pkg}Comment::ban_commenter_by_comment", |
|---|
| 572 | Â Â Â Â Â Â Â Â permission =>Â 'manage_feedback', |
|---|
| 573 | Â Â Â Â Â Â }, |
|---|
| 574 | Â Â Â Â Â Â 'unban_commenter'Â =>Â { |
|---|
| 575 |         label   => "Unban Commenter(s)", |
|---|
| 576 |         order   => 500, |
|---|
| 577 |         code    => "${pkg}Comment::unban_commenter_by_comment", |
|---|
| 578 | Â Â Â Â Â Â Â Â permission =>Â 'manage_feedback', |
|---|
| 579 | Â Â Â Â Â Â }, |
|---|
| 580 | Â Â Â Â }, |
|---|
| 581 | Â Â Â Â 'commenter'Â =>Â { |
|---|
| 582 | Â Â Â Â Â Â 'untrust'Â =>Â { |
|---|
| 583 |         label   => "Untrust Commenter(s)", |
|---|
| 584 |         order   => 100, |
|---|
| 585 |         code    => "{$pkg}Comment::untrust_commenter", |
|---|
| 586 | Â Â Â Â Â Â Â Â permission =>Â 'manage_feedback', |
|---|
| 587 | Â Â Â Â Â Â }, |
|---|
| 588 | Â Â Â Â Â Â 'unban'Â =>Â { |
|---|
| 589 |         label   => "Unban Commenter(s)", |
|---|
| 590 |         order   => 200, |
|---|
| 591 |         code    => "${pkg}Comment::unban_commenter", |
|---|
| 592 | Â Â Â Â Â Â Â Â permission =>Â 'manage_feedback', |
|---|
| 593 | Â Â Â Â Â Â }, |
|---|
| 594 | Â Â Â Â }, |
|---|
| 595 | Â Â Â Â 'author'Â =>Â { |
|---|
| 596 | Â Â Â Â Â Â 'recover_passwords'Â =>Â { |
|---|
| 597 | Â Â Â Â Â Â Â Â label =>Â "Recover Password(s)", |
|---|
| 598 | Â Â Â Â Â Â Â Â order =>Â 100, |
|---|
| 599 | Â Â Â Â Â Â Â Â continue_prompt_handler =>Â sub { |
|---|
| 600 | Â Â Â Â Â Â Â Â Â Â MT->translate("_WARNING_PASSWORD_RESET_MULTI"); |
|---|
| 601 | Â Â Â Â Â Â Â Â }, |
|---|
| 602 |         code   => "${pkg}Tools::recover_passwords", |
|---|
| 603 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 604 | Â Â Â Â Â Â Â Â Â Â (Â $app->user->is_superuser() |
|---|
| 605 | Â Â Â Â Â Â Â Â Â Â Â Â Â &&Â MT::Auth->can_recover_password ); |
|---|
| 606 | Â Â Â Â Â Â Â Â }, |
|---|
| 607 | Â Â Â Â Â Â }, |
|---|
| 608 | Â Â Â Â Â Â 'delete_user'Â =>Â { |
|---|
| 609 |         label      => "Delete", |
|---|
| 610 |         order      => 200, |
|---|
| 611 | Â Â Â Â Â Â Â Â continue_prompt_handler =>Â sub { |
|---|
| 612 | Â Â Â Â Â Â Â Â Â Â $app->config->ExternalUserManagement |
|---|
| 613 |             ? MT->translate("_WARNING_DELETE_USER_EUM") |
|---|
| 614 | Â Â Â Â Â Â Â Â Â Â Â Â :Â MT->translate("_WARNING_DELETE_USER"); |
|---|
| 615 | Â Â Â Â Â Â Â Â }, |
|---|
| 616 |         code   => "${pkg}Common::delete", |
|---|
| 617 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 618 | Â Â Â Â Â Â Â Â Â Â $app->user->is_superuser(); |
|---|
| 619 | Â Â Â Â Â Â Â Â }, |
|---|
| 620 | Â Â Â Â Â Â }, |
|---|
| 621 | Â Â Â Â }, |
|---|
| 622 | Â Â Â Â 'blog'Â =>Â { |
|---|
| 623 | Â Â Â Â Â Â refresh_blog_templates =>Â { |
|---|
| 624 | Â Â Â Â Â Â Â Â label =>Â "Refresh Template(s)", |
|---|
| 625 | Â Â Â Â Â Â Â Â code =>Â sub { |
|---|
| 626 |           my $app = MT->app; |
|---|
| 627 |           $app->param('backup', 1); |
|---|
| 628 |           require MT::CMS::Template; |
|---|
| 629 |           MT::CMS::Template::refresh_all_templates($app, @_) |
|---|
| 630 | Â Â Â Â Â Â Â Â }, |
|---|
| 631 | Â Â Â Â Â Â }, |
|---|
| 632 | Â Â Â Â }, |
|---|
| 633 | Â Â Â Â 'template'Â =>Â { |
|---|
| 634 | Â Â Â Â Â Â refresh_tmpl_templates =>Â { |
|---|
| 635 | Â Â Â Â Â Â Â Â label =>Â "Refresh Template(s)", |
|---|
| 636 | Â Â Â Â Â Â Â Â code =>Â "${pkg}Template::refresh_individual_templates", |
|---|
| 637 | Â Â Â Â Â Â Â Â permission =>Â 'edit_templates', |
|---|
| 638 | Â Â Â Â Â Â Â Â order =>Â 100, |
|---|
| 639 | Â Â Â Â Â Â }, |
|---|
| 640 | Â Â Â Â Â Â publish_index_templates =>Â { |
|---|
| 641 | Â Â Â Â Â Â Â Â label =>Â "Publish Template(s)", |
|---|
| 642 | Â Â Â Â Â Â Â Â code =>Â "${pkg}Template::publish_index_templates", |
|---|
| 643 | Â Â Â Â Â Â Â Â permission =>Â 'rebuild', |
|---|
| 644 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 645 |           my $app = MT->app; |
|---|
| 646 |           my $tmpl_type = $app->param('filter_key'); |
|---|
| 647 |           return $app->mode eq 'itemset_action' ? 1 |
|---|
| 648 |              : !$app->blog           ? 0 |
|---|
| 649 |              : !$tmpl_type           ? 0 |
|---|
| 650 |              : $tmpl_type eq 'index_templates' ? 1 |
|---|
| 651 | Â Â Â Â Â Â Â Â Â Â Â Â Â :Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0 |
|---|
| 652 | Â Â Â Â Â Â Â Â Â Â Â Â Â ; |
|---|
| 653 | Â Â Â Â Â Â Â Â }, |
|---|
| 654 | Â Â Â Â Â Â Â Â order =>Â 200, |
|---|
| 655 | Â Â Â Â Â Â }, |
|---|
| 656 | Â Â Â Â Â Â publish_archive_templates =>Â { |
|---|
| 657 |         label   => "Publish Template(s)", |
|---|
| 658 |         code    => "${pkg}Template::publish_archive_templates", |
|---|
| 659 | Â Â Â Â Â Â Â Â permission =>Â 'rebuild', |
|---|
| 660 |         condition => sub { |
|---|
| 661 |           my $app    = MT->app; |
|---|
| 662 |           my $tmpl_type = $app->param('filter_key'); |
|---|
| 663 |           return $app->mode eq 'itemset_action' ? 1 |
|---|
| 664 |            : !$app->blog ? 0 |
|---|
| 665 |            : !$tmpl_type ? 0 |
|---|
| 666 |            : $tmpl_type eq 'archive_templates' ? 1 |
|---|
| 667 | Â Â Â Â Â Â Â Â Â Â Â :Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 0; |
|---|
| 668 | Â Â Â Â Â Â Â Â }, |
|---|
| 669 | Â Â Â Â Â Â Â Â order =>Â 300, |
|---|
| 670 | Â Â Â Â Â Â }, |
|---|
| 671 | Â Â Â Â Â Â copy_templates =>Â { |
|---|
| 672 | Â Â Â Â Â Â Â Â label =>Â "Clone Template(s)", |
|---|
| 673 | Â Â Â Â Â Â Â Â code =>Â "${pkg}Template::clone_templates", |
|---|
| 674 | Â Â Â Â Â Â Â Â permission =>Â 'edit_templates', |
|---|
| 675 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 676 |           my $app    = MT->app; |
|---|
| 677 |           my $tmpl_type = $app->param('filter_key'); |
|---|
| 678 |           return $tmpl_type eq 'system_templates' ? 0 |
|---|
| 679 |            : $tmpl_type  eq 'email_templates' ? 0 |
|---|
| 680 | Â Â Â Â Â Â Â Â Â Â Â :Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â 1; |
|---|
| 681 | Â Â Â Â Â Â Â Â }, |
|---|
| 682 | Â Â Â Â Â Â Â Â order =>Â 400, |
|---|
| 683 | Â Â Â Â Â Â }, |
|---|
| 684 | Â Â Â Â }, |
|---|
| 685 | Â Â }; |
|---|
| 686 | } |
|---|
| 687 | |
|---|
| 688 | sub _entry_label { |
|---|
| 689 |   my $app = MT->instance; |
|---|
| 690 |   my $type = $app->param('type') || 'entry'; |
|---|
| 691 | Â Â $app->model($type)->class_label_plural; |
|---|
| 692 | } |
|---|
| 693 | |
|---|
| 694 | sub core_list_filters { |
|---|
| 695 |   my $app = shift; |
|---|
| 696 |   return { |
|---|
| 697 | Â Â Â Â asset =>Â sub { |
|---|
| 698 |       require MT::CMS::Asset; |
|---|
| 699 |       return MT::CMS::Asset::asset_list_filters($app, @_); |
|---|
| 700 | Â Â Â Â }, |
|---|
| 701 | Â Â Â Â entry =>Â { |
|---|
| 702 | Â Â Â Â Â Â published =>Â { |
|---|
| 703 | Â Â Â Â Â Â Â Â label =>Â sub { |
|---|
| 704 |           $app->translate( 'Published [_1]', _entry_label ); |
|---|
| 705 | Â Â Â Â Â Â Â Â }, |
|---|
| 706 |         order  => 100, |
|---|
| 707 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 708 |           my ( $terms, $args ) = @_; |
|---|
| 709 | Â Â Â Â Â Â Â Â Â Â $terms->{status}Â =Â 2; |
|---|
| 710 | Â Â Â Â Â Â Â Â }, |
|---|
| 711 | Â Â Â Â Â Â }, |
|---|
| 712 | Â Â Â Â Â Â unpublished =>Â { |
|---|
| 713 | Â Â Â Â Â Â Â Â label =>Â sub { |
|---|
| 714 |           $app->translate( 'Unpublished [_1]', _entry_label ); |
|---|
| 715 | Â Â Â Â Â Â Â Â }, |
|---|
| 716 |         order  => 200, |
|---|
| 717 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 718 |           my ( $terms, $args ) = @_; |
|---|
| 719 | Â Â Â Â Â Â Â Â Â Â $terms->{status}Â =Â 1; |
|---|
| 720 | Â Â Â Â Â Â Â Â }, |
|---|
| 721 | Â Â Â Â Â Â }, |
|---|
| 722 | Â Â Â Â Â Â scheduled =>Â { |
|---|
| 723 | Â Â Â Â Â Â Â Â label =>Â sub { |
|---|
| 724 |           $app->translate( 'Scheduled [_1]', _entry_label ); |
|---|
| 725 | Â Â Â Â Â Â Â Â }, |
|---|
| 726 |         order  => 300, |
|---|
| 727 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 728 |           my ( $terms, $args ) = @_; |
|---|
| 729 | Â Â Â Â Â Â Â Â Â Â $terms->{status}Â =Â 4; |
|---|
| 730 | Â Â Â Â Â Â Â Â }, |
|---|
| 731 | Â Â Â Â Â Â }, |
|---|
| 732 | Â Â Â Â Â Â my_posts =>Â { |
|---|
| 733 | Â Â Â Â Â Â Â Â label =>Â sub { |
|---|
| 734 |           $app->translate( 'My [_1]', _entry_label ); |
|---|
| 735 | Â Â Â Â Â Â Â Â }, |
|---|
| 736 |         order  => 400, |
|---|
| 737 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 738 |           my ( $terms, $args ) = @_; |
|---|
| 739 | Â Â Â Â Â Â Â Â Â Â $terms->{author_id}Â =Â $app->user->id; |
|---|
| 740 | Â Â Â Â Â Â Â Â }, |
|---|
| 741 | Â Â Â Â Â Â }, |
|---|
| 742 | Â Â Â Â Â Â received_comments_in_last_7_days =>Â { |
|---|
| 743 | Â Â Â Â Â Â Â Â label =>Â sub { |
|---|
| 744 | Â Â Â Â Â Â Â Â Â Â $app->translate(Â '[_1] with comments in the last 7 days', |
|---|
| 745 | Â Â Â Â Â Â Â Â Â Â Â Â _entry_label ); |
|---|
| 746 | Â Â Â Â Â Â Â Â }, |
|---|
| 747 |         order  => 500, |
|---|
| 748 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 749 |           my ( $terms, $args ) = @_; |
|---|
| 750 |           my $ts = time - 10 * 24 * 60 * 60; |
|---|
| 751 |           $ts = epoch2ts( MT->app->blog, $ts ); |
|---|
| 752 | Â Â Â Â Â Â Â Â Â Â $args->{join}Â =Â MT::Comment->join_on( |
|---|
| 753 | Â Â Â Â Â Â Â Â Â Â Â Â 'entry_id', |
|---|
| 754 | Â Â Â Â Â Â Â Â Â Â Â Â { |
|---|
| 755 |               created_on => [ $ts, undef ], |
|---|
| 756 |               junk_status => [ 0,  1 ] |
|---|
| 757 | Â Â Â Â Â Â Â Â Â Â Â Â }, |
|---|
| 758 |             { range_incl => { created_on => 1 }, unique => 1 } |
|---|
| 759 | Â Â Â Â Â Â Â Â Â Â ); |
|---|
| 760 | Â Â Â Â Â Â Â Â Â Â # Since we're selecting content from the mt_entry |
|---|
| 761 | Â Â Â Â Â Â Â Â Â Â # table, but we want to sort by the joined |
|---|
| 762 | Â Â Â Â Â Â Â Â Â Â # 'comment_created_on' column, we have to specify the |
|---|
| 763 | Â Â Â Â Â Â Â Â Â Â # sort column as a reference and a full field name, |
|---|
| 764 | Â Â Â Â Â Â Â Â Â Â # to prevent MT from adding a 'entry_' prefix to |
|---|
| 765 | Â Â Â Â Â Â Â Â Â Â # the column name. |
|---|
| 766 | Â Â Â Â Â Â Â Â Â Â $args->{sort}Â Â Â =Â \'comment_created_on'; |
|---|
| 767 | Â Â Â Â Â Â Â Â Â Â $args->{direction}Â =Â 'descend'; |
|---|
| 768 | Â Â Â Â Â Â Â Â }, |
|---|
| 769 | Â Â Â Â Â Â }, |
|---|
| 770 | Â Â Â Â Â Â _by_date =>Â { |
|---|
| 771 | Â Â Â Â Â Â Â Â label =>Â sub { |
|---|
| 772 |           my $app = MT->instance; |
|---|
| 773 |           my $val = $app->param('filter_val'); |
|---|
| 774 |           my ( $from, $to ) = split /-/, $val; |
|---|
| 775 |           $from = undef unless $from =~ m/^\d{8}$/; |
|---|
| 776 |           $to  = undef unless $to  =~ m/^\d{8}$/; |
|---|
| 777 |           my $format = '%x'; |
|---|
| 778 |           $from = format_ts( |
|---|
| 779 |             $format, $from . '000000', |
|---|
| 780 |             undef,  MT->current_language |
|---|
| 781 |           ) if $from; |
|---|
| 782 |           $to = format_ts( |
|---|
| 783 |             $format, $to . '000000', |
|---|
| 784 |             undef,  MT->current_language |
|---|
| 785 |           ) if $to; |
|---|
| 786 |           my $label = _entry_label; |
|---|
| 787 | |
|---|
| 788 |           if ( $from && $to ) { |
|---|
| 789 |             return $app->translate( |
|---|
| 790 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â '[_1] posted between [_2] and [_3]', |
|---|
| 791 |               $label, $from, $to ); |
|---|
| 792 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 793 |           elsif ($from) { |
|---|
| 794 |             return $app->translate( "[_1] posted since [_2]", |
|---|
| 795 |               $label, $from ); |
|---|
| 796 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 797 |           elsif ($to) { |
|---|
| 798 |             return $app->translate( "[_1] posted on or before [_2]", |
|---|
| 799 |               $label, $to ); |
|---|
| 800 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 801 | Â Â Â Â Â Â Â Â }, |
|---|
| 802 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 803 |           my ( $terms, $args ) = @_; |
|---|
| 804 |           my $val = $app->param('filter_val'); |
|---|
| 805 |           my ( $from, $to ) = split /-/, $val; |
|---|
| 806 |           $from = undef unless $from =~ m/^\d{8}$/; |
|---|
| 807 |           $from .= '000000'; |
|---|
| 808 |           $to = undef unless $to =~ m/^\d{8}$/; |
|---|
| 809 |           $to .= '235959'; |
|---|
| 810 | Â Â Â Â Â Â Â Â Â Â $terms->{authored_on}Â = |
|---|
| 811 |            [ MT::Object::ts2db($from), MT::Object::ts2db($to) ]; |
|---|
| 812 | Â Â Â Â Â Â Â Â Â Â $args->{range_incl}{authored_on}Â =Â 1; |
|---|
| 813 | Â Â Â Â Â Â Â Â }, |
|---|
| 814 | Â Â Â Â Â Â }, |
|---|
| 815 | Â Â Â Â }, |
|---|
| 816 | Â Â Â Â ping =>Â { |
|---|
| 817 | Â Â Â Â Â Â default =>Â { |
|---|
| 818 |         label  => 'Non-spam TrackBacks', |
|---|
| 819 |         order  => 100, |
|---|
| 820 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 821 |           my ( $terms, $args ) = @_; |
|---|
| 822 |           $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 823 | Â Â Â Â Â Â Â Â }, |
|---|
| 824 | Â Â Â Â Â Â }, |
|---|
| 825 | Â Â Â Â Â Â my_posts =>Â { |
|---|
| 826 |         label  => 'TrackBacks on my entries', |
|---|
| 827 |         order  => 200, |
|---|
| 828 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 829 |           my ( $terms, $args ) = @_; |
|---|
| 830 |           require MT::Entry; |
|---|
| 831 |           my $app = MT->instance; |
|---|
| 832 |           $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 833 |           require MT::Trackback; |
|---|
| 834 | Â Â Â Â Â Â Â Â Â Â $args->{join}Â =Â MT::Trackback->join_on( |
|---|
| 835 | Â Â Â Â Â Â Â Â Â Â Â Â undef, |
|---|
| 836 | Â Â Â Â Â Â Â Â Â Â Â Â { |
|---|
| 837 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â id =>Â \'= tbping_tb_id', |
|---|
| 838 | Â Â Â Â Â Â Â Â Â Â Â Â }, |
|---|
| 839 | Â Â Â Â Â Â Â Â Â Â Â Â { |
|---|
| 840 |               join => MT::Entry->join_on( |
|---|
| 841 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â undef, |
|---|
| 842 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â { |
|---|
| 843 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â id =>Â \'= trackback_entry_id', |
|---|
| 844 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â author_id =>Â $app->user->id |
|---|
| 845 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } |
|---|
| 846 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
|---|
| 847 | Â Â Â Â Â Â Â Â Â Â Â Â }, |
|---|
| 848 | Â Â Â Â Â Â Â Â Â Â ); |
|---|
| 849 | Â Â Â Â Â Â Â Â }, |
|---|
| 850 | Â Â Â Â Â Â }, |
|---|
| 851 | Â Â Â Â Â Â published =>Â { |
|---|
| 852 |         label  => 'Published TrackBacks', |
|---|
| 853 |         order  => 200, |
|---|
| 854 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 855 |           my ( $terms, $args ) = @_; |
|---|
| 856 | Â Â Â Â Â Â Â Â Â Â $terms->{visible}Â =Â 1; |
|---|
| 857 | Â Â Â Â Â Â Â Â }, |
|---|
| 858 | Â Â Â Â Â Â }, |
|---|
| 859 | Â Â Â Â Â Â unpublished =>Â { |
|---|
| 860 |         label  => 'Unpublished TrackBacks', |
|---|
| 861 |         order  => 300, |
|---|
| 862 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 863 |           my ( $terms, $args ) = @_; |
|---|
| 864 |           $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 865 | Â Â Â Â Â Â Â Â Â Â $terms->{visible}Â =Â 0; |
|---|
| 866 | Â Â Â Â Â Â Â Â }, |
|---|
| 867 | Â Â Â Â Â Â }, |
|---|
| 868 | Â Â Â Â Â Â spam =>Â { |
|---|
| 869 |         label  => 'TrackBacks marked as Spam', |
|---|
| 870 |         order  => 400, |
|---|
| 871 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 872 |           my ( $terms, $args ) = @_; |
|---|
| 873 | Â Â Â Â Â Â Â Â Â Â $terms->{junk_status}Â =Â -1; |
|---|
| 874 | Â Â Â Â Â Â Â Â }, |
|---|
| 875 | Â Â Â Â Â Â }, |
|---|
| 876 | Â Â Â Â Â Â last_7_days =>Â { |
|---|
| 877 |         label  => 'All TrackBacks in the last 7 days', |
|---|
| 878 |         order  => 700, |
|---|
| 879 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 880 |           my ( $terms, $args ) = @_; |
|---|
| 881 |           my $ts = time - 7 * 24 * 60 * 60; |
|---|
| 882 |           $ts = epoch2ts( MT->app->blog, $ts ); |
|---|
| 883 |           $terms->{created_on} = [ $ts, undef ]; |
|---|
| 884 | Â Â Â Â Â Â Â Â Â Â $args->{range_incl}{created_on}Â =Â 1; |
|---|
| 885 |           $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 886 | Â Â Â Â Â Â Â Â }, |
|---|
| 887 | Â Â Â Â Â Â }, |
|---|
| 888 | Â Â Â Â }, |
|---|
| 889 | Â Â Â Â comment =>Â { |
|---|
| 890 | Â Â Â Â Â Â default =>Â { |
|---|
| 891 |         label  => 'Non-spam Comments', |
|---|
| 892 |         order  => 100, |
|---|
| 893 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 894 |           my ( $terms, $args ) = @_; |
|---|
| 895 |           $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 896 | Â Â Â Â Â Â Â Â }, |
|---|
| 897 | Â Â Â Â Â Â }, |
|---|
| 898 | Â Â Â Â Â Â my_posts =>Â { |
|---|
| 899 |         label  => 'Comments on my entries', |
|---|
| 900 |         order  => 200, |
|---|
| 901 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 902 |           my ( $terms, $args ) = @_; |
|---|
| 903 |           require MT::Entry; |
|---|
| 904 |           my $app = MT->instance; |
|---|
| 905 |           $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 906 | Â Â Â Â Â Â Â Â Â Â # This join syntax employs a hack that allows us |
|---|
| 907 | Â Â Â Â Â Â Â Â Â Â # to do joins on abitrary columns. Typically, |
|---|
| 908 | Â Â Â Â Â Â Â Â Â Â # objectdriver joins are applied with the primary |
|---|
| 909 | Â Â Â Â Â Â Â Â Â Â # key column of the driving table (here, |
|---|
| 910 | Â Â Â Â Â Â Â Â Â Â # mt_comment.comment_id), but we actually want to |
|---|
| 911 | Â Â Â Â Â Â Â Â Â Â # join to the mt_entry table where the entry_id |
|---|
| 912 | Â Â Â Â Â Â Â Â Â Â # matches to mt_comment.comment_entry_id (not the |
|---|
| 913 | Â Â Â Â Â Â Â Â Â Â # primary key). So by specifying NO 'join' column |
|---|
| 914 | Â Â Â Â Â Â Â Â Â Â # (which is always compared with the primary key), |
|---|
| 915 | Â Â Â Â Â Â Â Â Â Â # we specify the actual join conditions in the |
|---|
| 916 | Â Â Â Â Â Â Â Â Â Â # terms. And using a reference for the |
|---|
| 917 | Â Â Â Â Â Â Â Â Â Â # 'comment_entry_id' column name, to pass that |
|---|
| 918 | Â Â Â Â Â Â Â Â Â Â # on directly to the SQL statement that is generated. |
|---|
| 919 | Â Â Â Â Â Â Â Â Â Â $args->{join}Â =Â MT::Entry->join_on( |
|---|
| 920 | Â Â Â Â Â Â Â Â Â Â Â Â undef, |
|---|
| 921 | Â Â Â Â Â Â Â Â Â Â Â Â { |
|---|
| 922 |               id    => \'= comment_entry_id', |
|---|
| 923 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â author_id =>Â $app->user->id |
|---|
| 924 | Â Â Â Â Â Â Â Â Â Â Â Â } |
|---|
| 925 | Â Â Â Â Â Â Â Â Â Â ); |
|---|
| 926 | Â Â Â Â Â Â Â Â }, |
|---|
| 927 | Â Â Â Â Â Â }, |
|---|
| 928 | Â Â Â Â Â Â unpublished =>Â { |
|---|
| 929 |         label  => 'Pending comments', |
|---|
| 930 |         order  => 300, |
|---|
| 931 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 932 |           my ( $terms, $args ) = @_; |
|---|
| 933 |           $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 934 | Â Â Â Â Â Â Â Â Â Â $terms->{visible}Â =Â 0; |
|---|
| 935 | Â Â Â Â Â Â Â Â }, |
|---|
| 936 | Â Â Â Â Â Â }, |
|---|
| 937 | Â Â Â Â Â Â spam =>Â { |
|---|
| 938 |         label  => 'Spam Comments', |
|---|
| 939 |         order  => 400, |
|---|
| 940 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 941 |           my ( $terms, $args ) = @_; |
|---|
| 942 | Â Â Â Â Â Â Â Â Â Â $terms->{junk_status}Â =Â -1; |
|---|
| 943 | Â Â Â Â Â Â Â Â }, |
|---|
| 944 | Â Â Â Â Â Â }, |
|---|
| 945 | Â Â Â Â Â Â published =>Â { |
|---|
| 946 |         label  => 'Published comments', |
|---|
| 947 |         order  => 500, |
|---|
| 948 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 949 |           my ( $terms, $args ) = @_; |
|---|
| 950 | Â Â Â Â Â Â Â Â Â Â $terms->{visible}Â =Â 1; |
|---|
| 951 | Â Â Â Â Â Â Â Â }, |
|---|
| 952 | Â Â Â Â Â Â }, |
|---|
| 953 | Â Â Â Â Â Â #Â Â Â Â Â Â my_comments => { |
|---|
| 954 |       #        label  => 'My comments', |
|---|
| 955 |       #        order  => 600, |
|---|
| 956 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â handler => sub { |
|---|
| 957 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â my ( $terms, $args ) = @_; |
|---|
| 958 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â $terms->{commenter_id} = $app->user->id; |
|---|
| 959 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â }, |
|---|
| 960 | Â Â Â Â Â Â #Â Â Â Â Â Â }, |
|---|
| 961 | Â Â Â Â Â Â last_7_days =>Â { |
|---|
| 962 |         label  => 'Comments in the last 7 days', |
|---|
| 963 |         order  => 700, |
|---|
| 964 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 965 |           my ( $terms, $args ) = @_; |
|---|
| 966 |           my $ts = time - 7 * 24 * 60 * 60; |
|---|
| 967 |           $ts = epoch2ts( MT->app->blog, $ts ); |
|---|
| 968 |           $terms->{created_on} = [ $ts, undef ]; |
|---|
| 969 | Â Â Â Â Â Â Â Â Â Â $args->{range_incl}{created_on}Â =Â 1; |
|---|
| 970 |           $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 971 | Â Â Â Â Â Â Â Â }, |
|---|
| 972 | Â Â Â Â Â Â }, |
|---|
| 973 | Â Â Â Â Â Â #Â Â Â Â Â Â last_24_hours => { |
|---|
| 974 |       #        label  => 'All comments in the last 24 hours', |
|---|
| 975 |       #        order  => 800, |
|---|
| 976 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â handler => sub { |
|---|
| 977 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â my ( $terms, $args ) = @_; |
|---|
| 978 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â my $ts = time - 24 * 60 * 60; |
|---|
| 979 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â $ts = epoch2ts( MT->app->blog, $ts ); |
|---|
| 980 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â $terms->{created_on} = [ $ts, undef ]; |
|---|
| 981 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â $args->{range_incl}{created_on} = 1; |
|---|
| 982 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â Â Â $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 983 | Â Â Â Â Â Â #Â Â Â Â Â Â Â Â }, |
|---|
| 984 | Â Â Â Â Â Â #Â Â Â Â Â Â }, |
|---|
| 985 | Â Â Â Â Â Â _comments_by_user =>Â { |
|---|
| 986 | Â Â Â Â Â Â Â Â label =>Â sub { |
|---|
| 987 |           my $app   = MT->app; |
|---|
| 988 |           my $user_id = $app->param('filter_val'); |
|---|
| 989 |           my $user  = MT::Author->load($user_id); |
|---|
| 990 |           require MT::Author; |
|---|
| 991 |           return $app->translate( |
|---|
| 992 | Â Â Â Â Â Â Â Â Â Â Â Â "All comments by [_1] '[_2]'", |
|---|
| 993 | Â Â Â Â Â Â Â Â Â Â Â Â ( |
|---|
| 994 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $user->type ==Â MT::Author::COMMENTER() |
|---|
| 995 |               ? $app->translate("Commenter") |
|---|
| 996 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â :Â $app->translate("Author") |
|---|
| 997 | Â Â Â Â Â Â Â Â Â Â Â Â ), |
|---|
| 998 | Â Â Â Â Â Â Â Â Â Â Â Â ( |
|---|
| 999 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $user->nickname |
|---|
| 1000 |               ? $user->nickname . ' (' . $user->name . ')' |
|---|
| 1001 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â :Â $user->name |
|---|
| 1002 | Â Â Â Â Â Â Â Â Â Â Â Â ) |
|---|
| 1003 | Â Â Â Â Â Â Â Â Â Â ); |
|---|
| 1004 | Â Â Â Â Â Â Â Â }, |
|---|
| 1005 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1006 |           my ( $terms, $args ) = @_; |
|---|
| 1007 |           my $cmtr_id = int( MT->app->param('filter_val') ); |
|---|
| 1008 | Â Â Â Â Â Â Â Â Â Â $terms->{commenter_id}Â =Â $cmtr_id; |
|---|
| 1009 | Â Â Â Â Â Â Â Â }, |
|---|
| 1010 | Â Â Â Â Â Â }, |
|---|
| 1011 | Â Â Â Â Â Â _comments_by_entry =>Â { |
|---|
| 1012 | Â Â Â Â Â Â Â Â label =>Â sub { |
|---|
| 1013 |           my $entry_id = MT->app->param('filter_val'); |
|---|
| 1014 |           my $entry  = MT::Entry->load($entry_id); |
|---|
| 1015 |           return MT->translate( "All comments for [_1] '[_2]'", |
|---|
| 1016 |             $entry->class_label, $entry->title ); |
|---|
| 1017 | Â Â Â Â Â Â Â Â }, |
|---|
| 1018 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1019 |           my ( $terms, $args ) = @_; |
|---|
| 1020 |           my $entry_id = int( MT->app->param('filter_val') ); |
|---|
| 1021 | Â Â Â Â Â Â Â Â Â Â $terms->{entry_id}Â =Â $entry_id; |
|---|
| 1022 |           $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 1023 | Â Â Â Â Â Â Â Â }, |
|---|
| 1024 | Â Â Â Â Â Â }, |
|---|
| 1025 | Â Â Â Â Â Â _by_date =>Â { |
|---|
| 1026 | Â Â Â Â Â Â Â Â label =>Â sub { |
|---|
| 1027 |           my $app = MT->instance; |
|---|
| 1028 |           my $val = $app->param('filter_val'); |
|---|
| 1029 |           my ( $from, $to ) = split /-/, $val; |
|---|
| 1030 |           $from = undef unless $from =~ m/^\d{8}$/; |
|---|
| 1031 |           $to  = undef unless $to  =~ m/^\d{8}$/; |
|---|
| 1032 |           my $format = '%x'; |
|---|
| 1033 |           $from = format_ts( |
|---|
| 1034 |             $format, $from . '000000', |
|---|
| 1035 |             undef,  MT->current_language |
|---|
| 1036 |           ) if $from; |
|---|
| 1037 |           $to = format_ts( |
|---|
| 1038 |             $format, $to . '000000', |
|---|
| 1039 |             undef,  MT->current_language |
|---|
| 1040 |           ) if $to; |
|---|
| 1041 | |
|---|
| 1042 |           if ( $from && $to ) { |
|---|
| 1043 |             return $app->translate( |
|---|
| 1044 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â 'Comments posted between [_1] and [_2]', |
|---|
| 1045 |               $from, $to ); |
|---|
| 1046 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 1047 |           elsif ($from) { |
|---|
| 1048 |             return $app->translate( "Comments posted since [_1]", |
|---|
| 1049 |               $from ); |
|---|
| 1050 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 1051 |           elsif ($to) { |
|---|
| 1052 |             return $app->translate( |
|---|
| 1053 |               "Comments posted on or before [_1]", $to ); |
|---|
| 1054 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 1055 | Â Â Â Â Â Â Â Â }, |
|---|
| 1056 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1057 |           my ( $terms, $args ) = @_; |
|---|
| 1058 |           my $val = $app->param('filter_val'); |
|---|
| 1059 |           my ( $from, $to ) = split /-/, $val; |
|---|
| 1060 |           $from = undef unless $from =~ m/^\d{8}$/; |
|---|
| 1061 |           $from .= '000000'; |
|---|
| 1062 |           $to = undef unless $to =~ m/^\d{8}$/; |
|---|
| 1063 |           $to .= '235959'; |
|---|
| 1064 |           $terms->{junk_status} = [ 0, 1 ]; |
|---|
| 1065 | Â Â Â Â Â Â Â Â Â Â $terms->{created_on}Â = |
|---|
| 1066 |            [ MT::Object::ts2db($from), MT::Object::ts2db($to) ]; |
|---|
| 1067 | Â Â Â Â Â Â Â Â Â Â $args->{range_incl}{created_on}Â =Â 1; |
|---|
| 1068 | Â Â Â Â Â Â Â Â }, |
|---|
| 1069 | Â Â Â Â Â Â }, |
|---|
| 1070 | Â Â Â Â }, |
|---|
| 1071 | Â Â Â Â template =>Â { |
|---|
| 1072 | Â Â Â Â Â Â index_templates =>Â { |
|---|
| 1073 |         label  => "Index Templates", |
|---|
| 1074 |         order  => 100, |
|---|
| 1075 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1076 |           my ( $terms, $args ) = @_; |
|---|
| 1077 | Â Â Â Â Â Â Â Â Â Â # FIXME: enumeration of types |
|---|
| 1078 | Â Â Â Â Â Â Â Â Â Â $terms->{type}Â =Â 'index'; |
|---|
| 1079 | Â Â Â Â Â Â Â Â }, |
|---|
| 1080 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 1081 | Â Â Â Â Â Â Â Â Â Â $app->param('blog_id'); |
|---|
| 1082 | Â Â Â Â Â Â Â Â }, |
|---|
| 1083 | Â Â Â Â Â Â }, |
|---|
| 1084 | Â Â Â Â Â Â archive_templates =>Â { |
|---|
| 1085 |         label  => "Archive Templates", |
|---|
| 1086 |         order  => 200, |
|---|
| 1087 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1088 |           my ( $terms, $args ) = @_; |
|---|
| 1089 | Â Â Â Â Â Â Â Â Â Â $terms->{type}Â = |
|---|
| 1090 |            [ 'individual', 'page', 'archive', 'category' ]; |
|---|
| 1091 | Â Â Â Â Â Â Â Â }, |
|---|
| 1092 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 1093 | Â Â Â Â Â Â Â Â Â Â $app->param('blog_id'); |
|---|
| 1094 | Â Â Â Â Â Â Â Â }, |
|---|
| 1095 | Â Â Â Â Â Â }, |
|---|
| 1096 | Â Â Â Â Â Â module_templates =>Â { |
|---|
| 1097 |         label  => "Template Modules", |
|---|
| 1098 |         order  => 400, |
|---|
| 1099 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1100 |           my ($terms) = @_; |
|---|
| 1101 | Â Â Â Â Â Â Â Â Â Â $terms->{type}Â =Â 'custom'; |
|---|
| 1102 | Â Â Â Â Â Â Â Â }, |
|---|
| 1103 | Â Â Â Â Â Â }, |
|---|
| 1104 | Â Â Â Â Â Â email_templates =>Â { |
|---|
| 1105 |         label  => "E-mail Templates", |
|---|
| 1106 |         order  => 300, |
|---|
| 1107 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1108 |           my ($terms) = @_; |
|---|
| 1109 | Â Â Â Â Â Â Â Â Â Â $terms->{type}Â =Â 'email'; |
|---|
| 1110 | Â Â Â Â Â Â Â Â }, |
|---|
| 1111 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 1112 | Â Â Â Â Â Â Â Â Â Â !$app->param('blog_id'); |
|---|
| 1113 | Â Â Â Â Â Â Â Â }, |
|---|
| 1114 | Â Â Â Â Â Â }, |
|---|
| 1115 | Â Â Â Â Â Â system_templates =>Â { |
|---|
| 1116 |         label  => "System Templates", |
|---|
| 1117 |         order  => 200, |
|---|
| 1118 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1119 |           my ($terms) = @_; |
|---|
| 1120 |           my $scope; |
|---|
| 1121 |           my $set; |
|---|
| 1122 |           if ( my $blog_id = $app->param('blog_id') ) { |
|---|
| 1123 |             my $blog = $app->model('blog')->load($blog_id); |
|---|
| 1124 |             $set  = $blog->template_set; |
|---|
| 1125 |             $scope .= 'system'; |
|---|
| 1126 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 1127 |           else { |
|---|
| 1128 | Â Â Â Â Â Â Â Â Â Â Â Â $terms->{blog_id}Â =Â 0; |
|---|
| 1129 |             $scope = 'global:system'; |
|---|
| 1130 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 1131 |           my @tmpl_path = ( $set && ($set ne 'mt_blog')) ? ("template_sets", $set, 'templates', $scope) : ("default_templates", $scope); |
|---|
| 1132 |           my $sys_tmpl = MT->registry(@tmpl_path) || {}; |
|---|
| 1133 |           $terms->{type} = [ keys %$sys_tmpl ]; |
|---|
| 1134 | Â Â Â Â Â Â Â Â }, |
|---|
| 1135 | Â Â Â Â Â Â Â Â condition =>Â sub { |
|---|
| 1136 | Â Â Â Â Â Â Â Â Â Â $app->param('blog_id'); |
|---|
| 1137 | Â Â Â Â Â Â Â Â }, |
|---|
| 1138 | Â Â Â Â Â Â }, |
|---|
| 1139 | Â Â Â Â }, |
|---|
| 1140 | Â Â Â Â tag =>Â { |
|---|
| 1141 | Â Â Â Â Â Â entry =>Â { |
|---|
| 1142 | Â Â Â Â Â Â Â Â label =>Â 'Tags with entries', |
|---|
| 1143 | Â Â Â Â Â Â Â Â order =>Â 100, |
|---|
| 1144 | Â Â Â Â Â Â }, |
|---|
| 1145 | Â Â Â Â Â Â page =>Â { |
|---|
| 1146 | Â Â Â Â Â Â Â Â label =>Â 'Tags with pages', |
|---|
| 1147 | Â Â Â Â Â Â Â Â order =>Â 200, |
|---|
| 1148 | Â Â Â Â Â Â }, |
|---|
| 1149 | Â Â Â Â Â Â asset =>Â { |
|---|
| 1150 | Â Â Â Â Â Â Â Â label =>Â 'Tags with assets', |
|---|
| 1151 | Â Â Â Â Â Â Â Â order =>Â 300, |
|---|
| 1152 | Â Â Â Â Â Â }, |
|---|
| 1153 | Â Â Â Â }, |
|---|
| 1154 | Â Â Â Â sys_user =>Â { |
|---|
| 1155 | Â Â Â Â Â Â enabled =>Â { |
|---|
| 1156 | Â Â Â Â Â Â Â Â label =>Â 'Enabled Users', |
|---|
| 1157 | Â Â Â Â Â Â Â Â order =>Â 100, |
|---|
| 1158 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1159 |           my ($terms) = @_; |
|---|
| 1160 | Â Â Â Â Â Â Â Â Â Â $terms->{status}Â =Â 1; |
|---|
| 1161 | Â Â Â Â Â Â Â Â }, |
|---|
| 1162 | Â Â Â Â Â Â }, |
|---|
| 1163 | Â Â Â Â Â Â disabled =>Â { |
|---|
| 1164 | Â Â Â Â Â Â Â Â label =>Â "Disabled Users", |
|---|
| 1165 | Â Â Â Â Â Â Â Â order =>Â 200, |
|---|
| 1166 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1167 |           my ($terms) = @_; |
|---|
| 1168 | Â Â Â Â Â Â Â Â Â Â $terms->{status}Â =Â 2; |
|---|
| 1169 | Â Â Â Â Â Â Â Â }, |
|---|
| 1170 | Â Â Â Â Â Â }, |
|---|
| 1171 | Â Â Â Â Â Â pending =>Â { |
|---|
| 1172 | Â Â Â Â Â Â Â Â label =>Â "Pending Users", |
|---|
| 1173 | Â Â Â Â Â Â Â Â order =>Â 300, |
|---|
| 1174 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1175 |           my ($terms) = @_; |
|---|
| 1176 | Â Â Â Â Â Â Â Â Â Â $terms->{status}Â =Â 3; |
|---|
| 1177 | Â Â Â Â Â Â Â Â }, |
|---|
| 1178 | Â Â Â Â Â Â }, |
|---|
| 1179 | Â Â Â Â }, |
|---|
| 1180 | Â Â Â Â user =>Â { |
|---|
| 1181 | Â Â Â Â Â Â author =>Â { |
|---|
| 1182 |         label  => 'Authors', |
|---|
| 1183 |         order  => 100, |
|---|
| 1184 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1185 |           my ($terms) = @_; |
|---|
| 1186 |           require MT::Author; |
|---|
| 1187 | Â Â Â Â Â Â Â Â Â Â $terms->{type}Â =Â MT::Author::AUTHOR(); |
|---|
| 1188 | Â Â Â Â Â Â Â Â }, |
|---|
| 1189 | Â Â Â Â Â Â }, |
|---|
| 1190 | Â Â Â Â Â Â commenter =>Â { |
|---|
| 1191 |         label  => 'Commenters', |
|---|
| 1192 |         order  => 200, |
|---|
| 1193 | Â Â Â Â Â Â Â Â handler =>Â sub { |
|---|
| 1194 |           my ($terms) = @_; |
|---|
| 1195 |           require MT::Author; |
|---|
| 1196 | Â Â Â Â Â Â Â Â Â Â $terms->{type}Â =Â MT::Author::COMMENTER(); |
|---|
| 1197 | Â Â Â Â Â Â Â Â }, |
|---|
| 1198 | Â Â Â Â Â Â }, |
|---|
| 1199 | Â Â Â Â }, |
|---|
| 1200 | Â Â }; |
|---|
| 1201 | } |
|---|
| 1202 | |
|---|
| 1203 | sub core_menus { |
|---|
| 1204 |   my $app = shift; |
|---|
| 1205 |   return { |
|---|
| 1206 | Â Â Â Â 'create'Â =>Â { |
|---|
| 1207 | Â Â Â Â Â Â label =>Â "Create", |
|---|
| 1208 | Â Â Â Â Â Â order =>Â 100, |
|---|
| 1209 | Â Â Â Â }, |
|---|
| 1210 | Â Â Â Â 'manage'Â =>Â { |
|---|
| 1211 | Â Â Â Â Â Â label =>Â "Manage", |
|---|
| 1212 | Â Â Â Â Â Â order =>Â 200, |
|---|
| 1213 | Â Â Â Â }, |
|---|
| 1214 | Â Â Â Â 'design'Â =>Â { |
|---|
| 1215 | Â Â Â Â Â Â label =>Â "Design", |
|---|
| 1216 | Â Â Â Â Â Â order =>Â 300, |
|---|
| 1217 | Â Â Â Â }, |
|---|
| 1218 | Â Â Â Â 'prefs'Â =>Â { |
|---|
| 1219 | Â Â Â Â Â Â label =>Â "Preferences", |
|---|
| 1220 | Â Â Â Â Â Â order =>Â 400, |
|---|
| 1221 | Â Â Â Â }, |
|---|
| 1222 | Â Â Â Â 'tools'Â =>Â { |
|---|
| 1223 | Â Â Â Â Â Â label =>Â "Tools", |
|---|
| 1224 | Â Â Â Â Â Â order =>Â 500, |
|---|
| 1225 | Â Â Â Â }, |
|---|
| 1226 | |
|---|
| 1227 | Â Â Â Â 'create:blog'Â =>Â { |
|---|
| 1228 | Â Â Â Â Â Â label =>Â "Blog", |
|---|
| 1229 | Â Â Â Â Â Â order =>Â 100, |
|---|
| 1230 |       view => "system", |
|---|
| 1231 | Â Â Â Â }, |
|---|
| 1232 | Â Â Â Â 'create:blog'Â =>Â { |
|---|
| 1233 |       label   => "Blog", |
|---|
| 1234 |       order   => 200, |
|---|
| 1235 |       view    => "system", |
|---|
| 1236 |       mode    => "view", |
|---|
| 1237 |       args    => { _type => "blog" }, |
|---|
| 1238 | Â Â Â Â Â Â permission =>Â "create_blog", |
|---|
| 1239 | Â Â Â Â }, |
|---|
| 1240 | Â Â Â Â 'create:user'Â =>Â { |
|---|
| 1241 |       label   => "User", |
|---|
| 1242 |       order   => 200, |
|---|
| 1243 |       view    => "system", |
|---|
| 1244 |       mode    => "view", |
|---|
| 1245 |       args    => { _type => "author" }, |
|---|
| 1246 | Â Â Â Â Â Â permission =>Â "administer", |
|---|
| 1247 |       condition => sub { |
|---|
| 1248 |         return !MT->config->ExternalUserManagement; |
|---|
| 1249 | Â Â Â Â Â Â }, |
|---|
| 1250 | Â Â Â Â }, |
|---|
| 1251 | Â Â Â Â 'create:entry'Â =>Â { |
|---|
| 1252 |       label   => "Entry", |
|---|
| 1253 |       order   => 100, |
|---|
| 1254 |       mode    => 'view', |
|---|
| 1255 |       args    => { _type => 'entry' }, |
|---|
| 1256 | Â Â Â Â Â Â permission =>Â 'create_post', |
|---|
| 1257 |       view    => "blog", |
|---|
| 1258 | Â Â Â Â }, |
|---|
| 1259 | Â Â Â Â 'create:page'Â =>Â { |
|---|
| 1260 |       label   => "Page", |
|---|
| 1261 |       order   => 200, |
|---|
| 1262 |       mode    => 'view', |
|---|
| 1263 |       args    => { _type => 'page' }, |
|---|
| 1264 | Â Â Â Â Â Â permission =>Â 'manage_pages', |
|---|
| 1265 |       view    => "blog", |
|---|
| 1266 | Â Â Â Â }, |
|---|
| 1267 | Â Â Â Â 'create:file'Â =>Â { |
|---|
| 1268 |       label   => "Upload File", |
|---|
| 1269 |       order   => 300, |
|---|
| 1270 |       dialog   => 'start_upload', |
|---|
| 1271 | Â Â Â Â Â Â permission =>Â 'upload,edit_assets', |
|---|
| 1272 |       view    => "blog", |
|---|
| 1273 | Â Â Â Â }, |
|---|
| 1274 | |
|---|
| 1275 | Â Â Â Â 'manage:blog'Â =>Â { |
|---|
| 1276 | Â Â Â Â Â Â label =>Â "Blogs", |
|---|
| 1277 |       mode => "list_blog", |
|---|
| 1278 | Â Â Â Â Â Â order =>Â 100, |
|---|
| 1279 |       view => "system", |
|---|
| 1280 | Â Â Â Â }, |
|---|
| 1281 | Â Â Â Â 'manage:user'Â =>Â { |
|---|
| 1282 |       label   => "Users", |
|---|
| 1283 |       mode    => "list_user", |
|---|
| 1284 |       order   => 200, |
|---|
| 1285 | Â Â Â Â Â Â permission =>Â "administer", |
|---|
| 1286 |       view    => "system", |
|---|
| 1287 | Â Â Â Â }, |
|---|
| 1288 | Â Â Â Â 'manage:entry'Â =>Â { |
|---|
| 1289 |       label   => "Entries", |
|---|
| 1290 |       mode    => 'list_entry', |
|---|
| 1291 |       order   => 1000, |
|---|
| 1292 |       condition => sub { |
|---|
| 1293 |         return 1 if $app->user->is_superuser; |
|---|
| 1294 |         if ( $app->param('blog_id') ) { |
|---|
| 1295 |           my $perms = $app->user->permissions($app->param('blog_id')); |
|---|
| 1296 |           return 1 if $perms->can_create_post || $perms->can_publish_post || $perms->can_edit_all_posts; |
|---|
| 1297 | Â Â Â Â Â Â Â Â } |
|---|
| 1298 |         else { |
|---|
| 1299 |           require MT::Permission; |
|---|
| 1300 |           my @blogs = |
|---|
| 1301 |             map { $_->blog_id } |
|---|
| 1302 |              grep { $_->can_create_post || $_->can_publish_post || $_->can_edit_all_posts } |
|---|
| 1303 | Â Â Â Â Â Â Â Â Â Â Â Â Â MT::Permission->load(Â {Â author_id =>Â $app->user->id }Â ); |
|---|
| 1304 |           return 1 if @blogs; |
|---|
| 1305 | Â Â Â Â Â Â Â Â } |
|---|
| 1306 |         return 0; |
|---|
| 1307 | Â Â Â Â Â Â }, |
|---|
| 1308 | Â Â Â Â Â Â #permission => 'create_post,publish_post,edit_all_posts', |
|---|
| 1309 | Â Â Â Â }, |
|---|
| 1310 | Â Â Â Â 'manage:comment'Â =>Â { |
|---|
| 1311 |       label   => "Comments", |
|---|
| 1312 |       mode    => 'list_comment', |
|---|
| 1313 |       order   => 2000, |
|---|
| 1314 |       condition => sub { |
|---|
| 1315 |         return 1 if $app->user->is_superuser; |
|---|
| 1316 |         if ( $app->param('blog_id') ) { |
|---|
| 1317 |           my $perms = $app->user->permissions($app->param('blog_id')); |
|---|
| 1318 |           return 1 if $perms->can_create_post || $perms->can_manage_feedback || $perms->can_edit_all_posts || $perms->can_comment; |
|---|
| 1319 | Â Â Â Â Â Â Â Â } |
|---|
| 1320 |         else { |
|---|
| 1321 |           require MT::Permission; |
|---|
| 1322 |           my @blogs = |
|---|
| 1323 |             map { $_->blog_id } |
|---|
| 1324 |              grep { $_->can_create_post || $_->can_manage_feedback || $_->can_edit_all_posts || $_->can_comment } |
|---|
| 1325 | Â Â Â Â Â Â Â Â Â Â Â Â Â MT::Permission->load(Â {Â author_id =>Â $app->user->id }Â ); |
|---|
| 1326 |           return 1 if @blogs; |
|---|
| 1327 | Â Â Â Â Â Â Â Â } |
|---|
| 1328 |         return 0; |
|---|
| 1329 | Â Â Â Â Â Â }, |
|---|
| 1330 | Â Â Â Â Â Â #permission => 'create_post,edit_all_posts,manage_feedback,comment', |
|---|
| 1331 | Â Â Â Â }, |
|---|
| 1332 | Â Â Â Â 'manage:asset'Â =>Â { |
|---|
| 1333 |       label   => "Assets", |
|---|
| 1334 |       mode    => 'list_asset', |
|---|
| 1335 |       order   => 3000, |
|---|
| 1336 | Â Â Â Â Â Â permission =>Â 'edit_assets', |
|---|
| 1337 | Â Â Â Â }, |
|---|
| 1338 | Â Â Â Â 'manage:page'Â =>Â { |
|---|
| 1339 |       label   => "Pages", |
|---|
| 1340 |       mode    => 'list_pages', |
|---|
| 1341 |       order   => 4000, |
|---|
| 1342 | Â Â Â Â Â Â permission =>Â 'manage_pages', |
|---|
| 1343 | Â Â Â Â }, |
|---|
| 1344 | Â Â Â Â 'manage:ping'Â =>Â { |
|---|
| 1345 |       label   => "TrackBacks", |
|---|
| 1346 |       mode    => 'list_pings', |
|---|
| 1347 |       order   => 5000, |
|---|
| 1348 | Â Â Â Â Â Â permission =>Â 'create_post,edit_all_posts,manage_feedback', |
|---|
| 1349 | Â Â Â Â }, |
|---|
| 1350 | Â Â Â Â 'manage:category'Â =>Â { |
|---|
| 1351 |       label   => "Categories", |
|---|
| 1352 |       mode    => 'list_cat', |
|---|
| 1353 |       order   => 6000, |
|---|
| 1354 | Â Â Â Â Â Â permission =>Â 'edit_categories', |
|---|
| 1355 |       view    => "blog", |
|---|
| 1356 | Â Â Â Â }, |
|---|
| 1357 | Â Â Â Â 'manage:folder'Â =>Â { |
|---|
| 1358 |       label   => "Folders", |
|---|
| 1359 |       mode    => 'list_cat', |
|---|
| 1360 |       args    => { _type => 'folder' }, |
|---|
| 1361 |       order   => 7000, |
|---|
| 1362 | Â Â Â Â Â Â permission =>Â 'manage_pages', |
|---|
| 1363 |       view    => "blog", |
|---|
| 1364 | Â Â Â Â }, |
|---|
| 1365 | Â Â Â Â 'manage:tag'Â =>Â { |
|---|
| 1366 |       label       => "Tags", |
|---|
| 1367 |       mode       => 'list_tag', |
|---|
| 1368 |       order       => 8000, |
|---|
| 1369 |       permission    => 'edit_tags', |
|---|
| 1370 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1371 | Â Â Â Â }, |
|---|
| 1372 | Â Â Â Â 'manage:blog_user'Â =>Â { |
|---|
| 1373 |       label       => "Users", |
|---|
| 1374 |       mode       => 'list_member', |
|---|
| 1375 |       order       => 9000, |
|---|
| 1376 |       view       => "blog", |
|---|
| 1377 |       permission    => 'administer_blog', |
|---|
| 1378 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1379 | Â Â Â Â }, |
|---|
| 1380 | Â Â Â Â 'manage:notification'Â =>Â { |
|---|
| 1381 |       label       => "Address Book", |
|---|
| 1382 |       mode       => 'list', |
|---|
| 1383 |       args       => { _type => 'notification' }, |
|---|
| 1384 |       order       => 10000, |
|---|
| 1385 |       permission    => 'edit_notifications', |
|---|
| 1386 |       view       => "blog", |
|---|
| 1387 |       condition     => sub { |
|---|
| 1388 |         return $app->config->EnableAddressBook; |
|---|
| 1389 | Â Â Â Â Â Â }, |
|---|
| 1390 | Â Â Â Â }, |
|---|
| 1391 | |
|---|
| 1392 | Â Â Â Â 'design:template'Â =>Â { |
|---|
| 1393 |       label     => "Templates", |
|---|
| 1394 |       mode     => 'list', |
|---|
| 1395 |       args     => { _type => 'template' }, |
|---|
| 1396 |       order     => 100, |
|---|
| 1397 |       permission  => 'edit_templates', |
|---|
| 1398 |       system_permission  => 'edit_templates', |
|---|
| 1399 | Â Â Â Â }, |
|---|
| 1400 | |
|---|
| 1401 | Â Â Â Â 'prefs:general'Â =>Â { |
|---|
| 1402 |       label   => "General", |
|---|
| 1403 |       order   => 100, |
|---|
| 1404 |       mode    => "cfg_system", |
|---|
| 1405 |       view    => "system", |
|---|
| 1406 | Â Â Â Â Â Â permission =>Â "administer", |
|---|
| 1407 | Â Â Â Â }, |
|---|
| 1408 | Â Â Â Â 'prefs:user'Â =>Â { |
|---|
| 1409 |       label   => "User", |
|---|
| 1410 |       order   => 200, |
|---|
| 1411 |       mode    => "cfg_system_users", |
|---|
| 1412 |       view    => "system", |
|---|
| 1413 | Â Â Â Â Â Â permission =>Â "administer", |
|---|
| 1414 | Â Â Â Â }, |
|---|
| 1415 | Â Â Â Â 'prefs:feedback'Â =>Â { |
|---|
| 1416 |       label   => "Feedback", |
|---|
| 1417 |       order   => 300, |
|---|
| 1418 |       mode    => "cfg_system_feedback", |
|---|
| 1419 |       view    => "system", |
|---|
| 1420 | Â Â Â Â Â Â permission =>Â "administer", |
|---|
| 1421 | Â Â Â Â }, |
|---|
| 1422 | Â Â Â Â 'prefs:settings'Â =>Â { |
|---|
| 1423 |       label       => "General", |
|---|
| 1424 |       mode       => 'cfg_prefs', |
|---|
| 1425 |       order       => 100, |
|---|
| 1426 |       permission    => 'administer_blog,edit_config,set_publish_paths', |
|---|
| 1427 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1428 |       view       => "blog", |
|---|
| 1429 | Â Â Â Â }, |
|---|
| 1430 | Â Â Â Â 'prefs:publishing'Â =>Â { |
|---|
| 1431 |       label       => "Publishing", |
|---|
| 1432 |       mode       => 'cfg_archives', |
|---|
| 1433 |       order       => 110, |
|---|
| 1434 |       permission    => 'administer_blog,edit_config,set_publish_paths', |
|---|
| 1435 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1436 |       view       => "blog", |
|---|
| 1437 | Â Â Â Â }, |
|---|
| 1438 | Â Â Â Â 'prefs:entry'Â =>Â { |
|---|
| 1439 |       label       => "Entry", |
|---|
| 1440 |       mode       => 'cfg_entry', |
|---|
| 1441 |       order       => 120, |
|---|
| 1442 |       permission    => 'administer_blog,edit_config,set_publish_paths', |
|---|
| 1443 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1444 |       view       => "blog", |
|---|
| 1445 | Â Â Â Â }, |
|---|
| 1446 | Â Â Â Â 'prefs:comment'Â =>Â { |
|---|
| 1447 |       label       => "Comment", |
|---|
| 1448 |       mode       => 'cfg_comments', |
|---|
| 1449 |       order       => 130, |
|---|
| 1450 |       permission    => 'administer_blog,edit_config,set_publish_paths', |
|---|
| 1451 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1452 |       view       => "blog", |
|---|
| 1453 | Â Â Â Â }, |
|---|
| 1454 | Â Â Â Â 'prefs:trackback'Â =>Â { |
|---|
| 1455 |       label       => "TrackBack", |
|---|
| 1456 |       mode       => 'cfg_trackbacks', |
|---|
| 1457 |       order       => 140, |
|---|
| 1458 |       permission    => 'administer_blog,edit_config,set_publish_paths', |
|---|
| 1459 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1460 |       view       => "blog", |
|---|
| 1461 | Â Â Â Â }, |
|---|
| 1462 | Â Â Â Â 'prefs:registration'Â =>Â { |
|---|
| 1463 |       label       => "Registration", |
|---|
| 1464 |       mode       => 'cfg_registration', |
|---|
| 1465 |       order       => 150, |
|---|
| 1466 |       permission    => 'administer_blog,edit_config,set_publish_paths', |
|---|
| 1467 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1468 |       view       => "blog", |
|---|
| 1469 | Â Â Â Â }, |
|---|
| 1470 | Â Â Â Â 'prefs:spam'Â =>Â { |
|---|
| 1471 |       label       => "Spam", |
|---|
| 1472 |       mode       => 'cfg_spam', |
|---|
| 1473 |       order       => 160, |
|---|
| 1474 |       permission    => 'administer_blog,edit_config,set_publish_paths', |
|---|
| 1475 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1476 |       view       => "blog", |
|---|
| 1477 | Â Â Â Â }, |
|---|
| 1478 | Â Â Â Â 'prefs:web_services'Â =>Â { |
|---|
| 1479 |       label       => "Web Services", |
|---|
| 1480 |       mode       => 'cfg_web_services', |
|---|
| 1481 |       order       => 170, |
|---|
| 1482 |       permission    => 'administer_blog,edit_config,set_publish_paths', |
|---|
| 1483 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1484 |       view       => "blog", |
|---|
| 1485 | Â Â Â Â }, |
|---|
| 1486 | |
|---|
| 1487 | Â Â Â Â 'tools:plugins'Â =>Â { |
|---|
| 1488 |       label       => "Plugins", |
|---|
| 1489 |       order       => 100, |
|---|
| 1490 |       mode       => "cfg_plugins", |
|---|
| 1491 |       permission    => "administer_blog", |
|---|
| 1492 | Â Â Â Â Â Â system_permission =>Â "manage_plugins", |
|---|
| 1493 | Â Â Â Â }, |
|---|
| 1494 | Â Â Â Â 'tools:activity_log'Â =>Â { |
|---|
| 1495 |       label       => "Activity Log", |
|---|
| 1496 |       order       => 200, |
|---|
| 1497 |       mode       => "view_log", |
|---|
| 1498 |       permission    => "view_blog_log", |
|---|
| 1499 | Â Â Â Â Â Â system_permission =>Â "view_log", |
|---|
| 1500 | Â Â Â Â }, |
|---|
| 1501 | Â Â Â Â 'tools:import'Â =>Â { |
|---|
| 1502 |       label       => "Import", |
|---|
| 1503 |       order       => 300, |
|---|
| 1504 |       mode       => "start_import", |
|---|
| 1505 |       view       => "blog", |
|---|
| 1506 |       permission    => "administer_blog", |
|---|
| 1507 |     },          |
|---|
| 1508 | Â Â Â Â 'tools:export'Â =>Â { |
|---|
| 1509 |       label       => "Export", |
|---|
| 1510 |       order       => 400, |
|---|
| 1511 |       mode       => "start_export", |
|---|
| 1512 |       view       => "blog", |
|---|
| 1513 |       permission    => "administer_blog", |
|---|
| 1514 |     },          |
|---|
| 1515 | Â Â Â Â 'tools:backup'Â =>Â { |
|---|
| 1516 |       label       => "Backup", |
|---|
| 1517 |       order       => 500, |
|---|
| 1518 |       mode       => "start_backup", |
|---|
| 1519 |       permission    => "administer_blog", |
|---|
| 1520 | Â Â Â Â }, |
|---|
| 1521 | Â Â Â Â 'tools:restore'Â =>Â { |
|---|
| 1522 |       label       => "Restore", |
|---|
| 1523 |       order       => 600, |
|---|
| 1524 |       mode       => "start_restore", |
|---|
| 1525 |       permission    => "administer_blog", |
|---|
| 1526 |       view       => "system", |
|---|
| 1527 | Â Â Â Â }, |
|---|
| 1528 | Â Â Â Â 'tools:system_information'Â =>Â { |
|---|
| 1529 |       label       => "System Information", |
|---|
| 1530 |       order       => 700, |
|---|
| 1531 |       mode       => "tools", |
|---|
| 1532 |       view       => "system", |
|---|
| 1533 | Â Â Â Â }, |
|---|
| 1534 | Â Â Â Â 'tools:ip_info'Â =>Â { |
|---|
| 1535 |       label       => "IP Banning", |
|---|
| 1536 |       mode       => 'list', |
|---|
| 1537 |       args       => { _type => 'banlist' }, |
|---|
| 1538 |       order       => 900, |
|---|
| 1539 |       permission    => 'manage_feedback', |
|---|
| 1540 |       condition     => sub { |
|---|
| 1541 | Â Â Â Â Â Â Â Â $app->config->ShowIPInformation; |
|---|
| 1542 | Â Â Â Â Â Â }, |
|---|
| 1543 |       view       => "blog", |
|---|
| 1544 | Â Â Â Â }, |
|---|
| 1545 | |
|---|
| 1546 | Â Â Â Â # System menu which is actually separate |
|---|
| 1547 | Â Â Â Â # in the CMS navigation |
|---|
| 1548 | Â Â Â Â 'system'Â =>Â { |
|---|
| 1549 | Â Â Â Â Â Â label =>Â "System Overview", |
|---|
| 1550 |       mode => 'dashboard', |
|---|
| 1551 | Â Â Â Â Â Â order =>Â 10000, |
|---|
| 1552 | Â Â Â Â }, |
|---|
| 1553 | Â Â Â Â 'system:user'Â =>Â { |
|---|
| 1554 |       label       => "Users", |
|---|
| 1555 |       mode       => 'list_authors', |
|---|
| 1556 |       order       => 100, |
|---|
| 1557 |       permission    => 'administer_blog', |
|---|
| 1558 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1559 | Â Â Â Â }, |
|---|
| 1560 | Â Â Â Â 'system:blog'Â =>Â { |
|---|
| 1561 | Â Â Â Â Â Â label =>Â "Blogs", |
|---|
| 1562 |       mode => 'list_blogs', |
|---|
| 1563 | Â Â Â Â Â Â order =>Â 200, |
|---|
| 1564 | Â Â Â Â }, |
|---|
| 1565 | Â Â Â Â 'system:template'Â =>Â { |
|---|
| 1566 |       label       => "Global Templates", |
|---|
| 1567 |       mode       => 'list_template', |
|---|
| 1568 |       order       => 250, |
|---|
| 1569 | Â Â Â Â Â Â system_permission =>Â 'edit_templates', |
|---|
| 1570 | Â Â Â Â }, |
|---|
| 1571 | Â Â Â Â 'system:settings'Â =>Â { |
|---|
| 1572 |       label       => "Settings", |
|---|
| 1573 |       mode       => 'cfg_system', |
|---|
| 1574 |       order       => 300, |
|---|
| 1575 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1576 | Â Â Â Â }, |
|---|
| 1577 | Â Â Â Â 'system:plugins'Â =>Â { |
|---|
| 1578 |       label       => "Plugins", |
|---|
| 1579 |       mode       => 'cfg_plugins', |
|---|
| 1580 |       order       => 400, |
|---|
| 1581 | Â Â Â Â Â Â system_permission =>Â 'manage_plugins', |
|---|
| 1582 | Â Â Â Â }, |
|---|
| 1583 | Â Â Â Â 'system:log'Â =>Â { |
|---|
| 1584 |       label       => "Activity Log", |
|---|
| 1585 |       mode       => 'view_log', |
|---|
| 1586 |       order       => 500, |
|---|
| 1587 | Â Â Â Â Â Â system_permission =>Â 'view_log', |
|---|
| 1588 | Â Â Â Â }, |
|---|
| 1589 | Â Â Â Â 'system:tools'Â =>Â { |
|---|
| 1590 |       label       => "Tools", |
|---|
| 1591 |       mode       => 'tools', |
|---|
| 1592 |       order       => 600, |
|---|
| 1593 | Â Â Â Â Â Â system_permission =>Â 'administer', |
|---|
| 1594 | Â Â Â Â }, |
|---|
| 1595 | Â Â }; |
|---|
| 1596 | } |
|---|
| 1597 | |
|---|
| 1598 | sub init_core_callbacks { |
|---|
| 1599 |   my $app = shift; |
|---|
| 1600 |   my $pkg = 'cms_'; |
|---|
| 1601 |   my $pfx = '$Core::MT::CMS::'; |
|---|
| 1602 | Â Â $app->_register_core_callbacks( |
|---|
| 1603 | Â Â Â Â { |
|---|
| 1604 | Â Â Â Â Â Â # notification callbacks |
|---|
| 1605 |       $pkg . 'save_permission_filter.notification' => "${pfx}AddressBook::can_save", |
|---|
| 1606 |       $pkg . 'save_filter.notification' => "${pfx}AddressBook::save_filter", |
|---|
| 1607 |       $pkg . 'post_delete.notification' => "${pfx}AddressBook::post_delete", |
|---|
| 1608 | |
|---|
| 1609 | Â Â Â Â Â Â # banlist callbacks |
|---|
| 1610 |       $pkg . 'save_permission_filter.banlist' => "${pfx}BanList::can_save", |
|---|
| 1611 |       $pkg . 'save_filter.banlist' => "${pfx}BanList::save_filter", |
|---|
| 1612 | |
|---|
| 1613 | Â Â Â Â Â Â # associations |
|---|
| 1614 |       $pkg . 'delete_permission_filter.association' => "${pfx}User::can_delete_association", |
|---|
| 1615 | |
|---|
| 1616 | Â Â Â Â Â Â # user callbacks |
|---|
| 1617 |       $pkg . 'edit.author' => "${pfx}User::edit", |
|---|
| 1618 |       $pkg . 'view_permission_filter.author' => "${pfx}User::can_view", |
|---|
| 1619 |       $pkg . 'save_permission_filter.author' => "${pfx}User::can_save", |
|---|
| 1620 |       $pkg . 'delete_permission_filter.author' => "${pfx}User::can_delete", |
|---|
| 1621 |       $pkg . 'save_filter.author' => "${pfx}User::save_filter", |
|---|
| 1622 |       $pkg . 'pre_save.author'  => "${pfx}User::pre_save", |
|---|
| 1623 |       $pkg . 'post_save.author'  => "${pfx}User::post_save", |
|---|
| 1624 |       $pkg . 'post_delete.author' => "${pfx}User::post_delete", |
|---|
| 1625 | |
|---|
| 1626 | Â Â Â Â Â Â # blog callbacks |
|---|
| 1627 |       $pkg . 'edit.blog' => "${pfx}Blog::edit", |
|---|
| 1628 | Â Â Â Â Â Â $pkg |
|---|
| 1629 |        . 'view_permission_filter.blog' => "${pfx}Blog::can_view", |
|---|
| 1630 | Â Â Â Â Â Â $pkg |
|---|
| 1631 |        . 'save_permission_filter.blog' => "${pfx}Blog::can_save", |
|---|
| 1632 | Â Â Â Â Â Â $pkg |
|---|
| 1633 |        . 'delete_permission_filter.blog' => "${pfx}Blog::can_delete", |
|---|
| 1634 |       $pkg . 'pre_save.blog'  => "${pfx}Blog::pre_save", |
|---|
| 1635 |       $pkg . 'post_save.blog'  => "${pfx}Blog::post_save", |
|---|
| 1636 |       $pkg . 'save_filter.blog' => "${pfx}Blog::save_filter", |
|---|
| 1637 |       $pkg . 'post_delete.blog' => "${pfx}Blog::post_delete", |
|---|
| 1638 | |
|---|
| 1639 | Â Â Â Â Â Â # folder callbacks |
|---|
| 1640 |       $pkg . 'edit.folder' => "${pfx}Folder::edit", |
|---|
| 1641 |       $pkg . 'view_permission_filter.folder' => "${pfx}Folder::can_view", |
|---|
| 1642 |       $pkg . 'save_permission_filter.folder' => "${pfx}Folder::can_save", |
|---|
| 1643 |       $pkg . 'delete_permission_filter.folder' => "${pfx}Folder::can_delete", |
|---|
| 1644 |       $pkg . 'pre_save.folder'  => "${pfx}Folder::pre_save", |
|---|
| 1645 |       $pkg . 'post_save.folder'  => "${pfx}Folder::post_save", |
|---|
| 1646 |       $pkg . 'save_filter.folder' => "${pfx}Folder::save_filter", |
|---|
| 1647 |       $pkg . 'post_delete.folder' => "${pfx}Folder::post_delete", |
|---|
| 1648 | |
|---|
| 1649 | Â Â Â Â Â Â # category callbacks |
|---|
| 1650 |       $pkg . 'edit.category' => "${pfx}Category::edit", |
|---|
| 1651 |       $pkg . 'view_permission_filter.category' => "${pfx}Category::can_view", |
|---|
| 1652 |       $pkg . 'save_permission_filter.category' => "${pfx}Category::can_save", |
|---|
| 1653 |       $pkg . 'delete_permission_filter.category' => "${pfx}Category::can_delete", |
|---|
| 1654 |       $pkg . 'pre_save.category'  => "${pfx}Category::pre_save", |
|---|
| 1655 |       $pkg . 'post_save.category'  => "${pfx}Category::post_save", |
|---|
| 1656 |       $pkg . 'save_filter.category' => "${pfx}Category::save_filter", |
|---|
| 1657 |       $pkg . 'post_delete.category' => "${pfx}Category::post_delete", |
|---|
| 1658 | |
|---|
| 1659 | Â Â Â Â Â Â # comment callbacks |
|---|
| 1660 |       $pkg . 'edit.comment' => "${pfx}Comment::edit", |
|---|
| 1661 |       $pkg . 'view_permission_filter.comment' => "${pfx}Comment::can_view", |
|---|
| 1662 |       $pkg . 'save_permission_filter.comment' => "${pfx}Comment::can_save", |
|---|
| 1663 |       $pkg . 'delete_permission_filter.comment' => "${pfx}Comment::can_delete", |
|---|
| 1664 |       $pkg . 'pre_save.comment'  => "${pfx}Comment::pre_save", |
|---|
| 1665 |       $pkg . 'post_save.comment'  => "${pfx}Comment::post_save", |
|---|
| 1666 |       $pkg . 'post_delete.comment' => "${pfx}Comment::post_delete", |
|---|
| 1667 | |
|---|
| 1668 | Â Â Â Â Â Â # commenter callbacks |
|---|
| 1669 |       $pkg . 'edit.commenter' => "${pfx}Comment::edit_commenter", |
|---|
| 1670 |       $pkg . 'view_permission_filter.commenter' => "${pfx}Comment::can_view_commenter", |
|---|
| 1671 |       $pkg . 'delete_permission_filter.commenter' => "${pfx}Comment::can_delete_commenter", |
|---|
| 1672 | |
|---|
| 1673 | Â Â Â Â Â Â # entry callbacks |
|---|
| 1674 |       $pkg . 'edit.entry' => "${pfx}Entry::edit", |
|---|
| 1675 |       $pkg . 'view_permission_filter.entry' => "${pfx}Entry::can_view", |
|---|
| 1676 |       $pkg . 'delete_permission_filter.entry' => "${pfx}Entry::can_delete", |
|---|
| 1677 |       $pkg . 'pre_save.entry'  => "${pfx}Entry::pre_save", |
|---|
| 1678 |       $pkg . 'post_save.entry'  => "${pfx}Entry::post_save", |
|---|
| 1679 |       $pkg . 'post_delete.entry' => "${pfx}Entry::post_delete", |
|---|
| 1680 | |
|---|
| 1681 | Â Â Â Â Â Â # page callbacks |
|---|
| 1682 |       $pkg . 'edit.page' => "${pfx}Page::edit", |
|---|
| 1683 |       $pkg . 'view_permission_filter.page' => "${pfx}Page::can_view", |
|---|
| 1684 |       $pkg . 'delete_permission_filter.page' => "${pfx}Page::can_delete", |
|---|
| 1685 |       $pkg . 'pre_save.page'  => "${pfx}Page::pre_save", |
|---|
| 1686 |       $pkg . 'post_save.page'  => "${pfx}Page::post_save", |
|---|
| 1687 |       $pkg . 'post_delete.page' => "${pfx}Page::post_delete", |
|---|
| 1688 | |
|---|
| 1689 | Â Â Â Â Â Â # ping callbacks |
|---|
| 1690 |       $pkg . 'edit.ping' => "${pfx}TrackBack::edit", |
|---|
| 1691 |       $pkg . 'view_permission_filter.ping' => "${pfx}TrackBack::can_view", |
|---|
| 1692 |       $pkg . 'save_permission_filter.ping' => "${pfx}TrackBack::can_save", |
|---|
| 1693 |       $pkg . 'delete_permission_filter.ping' => "${pfx}TrackBack::can_delete", |
|---|
| 1694 |       $pkg . 'pre_save.ping'  => "${pfx}TrackBack::pre_save", |
|---|
| 1695 |       $pkg . 'post_save.ping'  => "${pfx}TrackBack::post_save", |
|---|
| 1696 |       $pkg . 'post_delete.ping' => "${pfx}TrackBack::post_delete", |
|---|
| 1697 | |
|---|
| 1698 | Â Â Â Â Â Â # template callbacks |
|---|
| 1699 |       $pkg . 'edit.template' => "${pfx}Template::edit", |
|---|
| 1700 |       $pkg . 'view_permission_filter.template' => "${pfx}Template::can_view", |
|---|
| 1701 |       $pkg . 'save_permission_filter.template' => "${pfx}Template::can_save", |
|---|
| 1702 |       $pkg . 'delete_permission_filter.template' => "${pfx}Template::can_delete", |
|---|
| 1703 |       $pkg . 'pre_save.template'  => "${pfx}Template::pre_save", |
|---|
| 1704 |       $pkg . 'post_save.template'  => "${pfx}Template::post_save", |
|---|
| 1705 |       $pkg . 'post_delete.template' => "${pfx}Template::post_delete", |
|---|
| 1706 | |
|---|
| 1707 | Â Â Â Â Â Â # tags |
|---|
| 1708 |       $pkg . 'delete_permission_filter.tag' => "${pfx}Tag::can_delete", |
|---|
| 1709 |       $pkg . 'post_delete.tag' => "${pfx}Tag::post_delete", |
|---|
| 1710 | |
|---|
| 1711 | Â Â Â Â Â Â # junk-related callbacks |
|---|
| 1712 | Â Â Â Â Â Â #'HandleJunk' => \&_builtin_spam_handler, |
|---|
| 1713 | Â Â Â Â Â Â #'HandleNotJunk' => \&_builtin_spam_unhandler, |
|---|
| 1714 |       $pkg . 'not_junk_test' => "${pfx}Common::not_junk_test", |
|---|
| 1715 | |
|---|
| 1716 | Â Â Â Â Â Â # assets |
|---|
| 1717 |       $pkg . 'edit.asset' => "${pfx}Asset::edit", |
|---|
| 1718 |       $pkg . 'view_permission_filter.asset' => "${pfx}Asset::can_view", |
|---|
| 1719 |       $pkg . 'delete_permission_filter.asset' => "${pfx}Asset::can_delete", |
|---|
| 1720 |       $pkg . 'pre_save.asset'  => "${pfx}Asset::pre_save", |
|---|
| 1721 |       $pkg . 'post_save.asset'  => "${pfx}Asset::post_save", |
|---|
| 1722 |       $pkg . 'post_delete.asset' => "${pfx}Asset::post_delete", |
|---|
| 1723 | Â Â Â Â Â Â 'template_param.edit_asset'Â =>Â "${pfx}Asset::template_param_edit", |
|---|
| 1724 | Â Â Â Â } |
|---|
| 1725 | Â Â ); |
|---|
| 1726 | } |
|---|
| 1727 | |
|---|
| 1728 | sub user_can_admin_commenters { |
|---|
| 1729 |   my $app  = shift; |
|---|
| 1730 |   my $perms = $app->permissions; |
|---|
| 1731 | Â Â $app->user->is_superuser() |
|---|
| 1732 | Â Â Â ||Â (Â $perms |
|---|
| 1733 | Â Â Â Â &&Â (Â $perms->can_administer_blog ||Â $perms->can_manage_feedback )Â ); |
|---|
| 1734 | } |
|---|
| 1735 | |
|---|
| 1736 | sub validate_magic { |
|---|
| 1737 |   my $app = shift; |
|---|
| 1738 |   if ( my $feed_token = $app->param('feed_token') ) { |
|---|
| 1739 |     return unless $app->user; |
|---|
| 1740 |     my $pw = $app->user->api_password; |
|---|
| 1741 |     return undef if ( $pw || '' ) eq ''; |
|---|
| 1742 |     my $auth_token = perl_sha1_digest_hex( 'feed:' . $pw ); |
|---|
| 1743 |     return $feed_token eq $auth_token; |
|---|
| 1744 | Â Â } |
|---|
| 1745 |   else { |
|---|
| 1746 |     return $app->SUPER::validate_magic(@_); |
|---|
| 1747 | Â Â } |
|---|
| 1748 | } |
|---|
| 1749 | |
|---|
| 1750 | sub is_authorized { |
|---|
| 1751 |   my $app   = shift; |
|---|
| 1752 |   my $blog_id = $app->param('blog_id'); |
|---|
| 1753 | Â Â $app->permissions(undef); |
|---|
| 1754 |   return 1 unless $blog_id; |
|---|
| 1755 |   return unless my $user = $app->user; |
|---|
| 1756 |   my $perms = $app->permissions( $user->permissions($blog_id) ); |
|---|
| 1757 | Â Â $perms |
|---|
| 1758 |    ? 1 |
|---|
| 1759 | Â Â Â :Â $app->error( |
|---|
| 1760 | Â Â Â Â $app->translate("You are not authorized to log in to this blog.")Â ); |
|---|
| 1761 | } |
|---|
| 1762 | |
|---|
| 1763 | sub set_default_tmpl_params { |
|---|
| 1764 |   my $app = shift; |
|---|
| 1765 | Â Â $app->SUPER::set_default_tmpl_params(@_); |
|---|
| 1766 |   my ($tmpl) = @_; |
|---|
| 1767 |   my $param = {}; |
|---|
| 1768 | |
|---|
| 1769 |   my $mode   = $app->mode; |
|---|
| 1770 |   my $auth_mode = $app->config('AuthenticationModule'); |
|---|
| 1771 |   my ($pref) = split /\s+/, $auth_mode; |
|---|
| 1772 | |
|---|
| 1773 | Â Â # TODO - remove after testing or after new IA is defined |
|---|
| 1774 | Â Â $param->{app_layout_fixed}Â =Â 0; |
|---|
| 1775 | Â Â $param->{athena_nav}Â Â Â Â =Â 1; |
|---|
| 1776 | |
|---|
| 1777 | Â Â $param->{"auth_mode_$pref"}Â =Â 1; |
|---|
| 1778 | Â Â $param->{mt_news}Â Â Â Â Â Â =Â $app->config('NewsURL'); |
|---|
| 1779 | Â Â $param->{mt_support}Â Â Â Â =Â $app->config('SupportURL'); |
|---|
| 1780 |   my $lang = lc MT->current_language || 'en_us'; |
|---|
| 1781 |   $param->{language_id} = ( $lang !~ /en[_-]us/ ) ? $lang : ''; |
|---|
| 1782 | Â Â $param->{mode}Â =Â $app->mode; |
|---|
| 1783 | |
|---|
| 1784 |   my $blog_id = $app->param('blog_id') || 0; |
|---|
| 1785 |   my $blog; |
|---|
| 1786 |   my $blog_class = $app->model('blog'); |
|---|
| 1787 |   $blog ||= $blog_class->load($blog_id) if $blog_id; |
|---|
| 1788 |   if ( my $auth = $app->user ) { |
|---|
| 1789 | Â Â Â Â $param->{is_administrator}Â =Â $auth->is_superuser; |
|---|
| 1790 | Â Â Â Â $param->{can_create_blog}Â =Â $auth->can_create_blog; |
|---|
| 1791 | Â Â Â Â $param->{can_view_log}Â ||=Â $auth->can_view_log; |
|---|
| 1792 | Â Â Â Â $param->{can_manage_plugins}Â Â =Â $auth->can_manage_plugins; |
|---|
| 1793 | Â Â Â Â $param->{can_edit_templates}Â Â =Â $auth->can_edit_templates; |
|---|
| 1794 | Â Â Â Â $param->{can_publish_feedbacks}Â =Â $auth->is_superuser; |
|---|
| 1795 | Â Â Â Â $param->{can_search_replace}Â Â =Â $auth->is_superuser; |
|---|
| 1796 | Â Â Â Â $param->{has_authors_button}Â Â =Â $auth->is_superuser; |
|---|
| 1797 | Â Â Â Â $param->{author_id}Â Â Â Â Â Â Â =Â $auth->id; |
|---|
| 1798 | Â Â Â Â $param->{author_name}Â Â Â Â Â Â =Â $auth->name; |
|---|
| 1799 | Â Â Â Â $param->{author_display_name}Â Â =Â $auth->nickname ||Â $auth->name; |
|---|
| 1800 | Â Â } |
|---|
| 1801 | |
|---|
| 1802 |   if ( my $perms = $app->permissions ) { |
|---|
| 1803 |     my $perm_hash = $perms->to_hash; |
|---|
| 1804 |     foreach my $perm_name ( keys %$perm_hash ) { |
|---|
| 1805 |       my $perm_token = $perm_name; |
|---|
| 1806 |       $perm_token =~ s/^permission\.//; |
|---|
| 1807 | Â Â Â Â Â Â $param->{$perm_token}Â =Â $perm_hash->{$perm_name} |
|---|
| 1808 |        if defined $perm_hash->{$perm_name}; |
|---|
| 1809 | Â Â Â Â } |
|---|
| 1810 | Â Â Â Â $param->{can_edit_entries}Â =Â $param->{can_create_post} |
|---|
| 1811 | Â Â Â Â Â ||Â $param->{can_edit_all_entries} |
|---|
| 1812 | Â Â Â Â Â ||Â $param->{can_publish_post}; |
|---|
| 1813 | Â Â Â Â $param->{can_search_replace}Â =Â $param->{can_edit_all_posts}; |
|---|
| 1814 | Â Â Â Â $param->{can_edit_authors}Â Â =Â $param->{can_administer_blog}; |
|---|
| 1815 | Â Â Â Â $param->{can_access_assets}Â =Â $param->{can_create_post} |
|---|
| 1816 | Â Â Â Â Â ||Â $param->{can_edit_all_posts} |
|---|
| 1817 | Â Â Â Â Â ||Â $param->{can_edit_assets}; |
|---|
| 1818 | Â Â Â Â $param->{can_edit_commenters}Â Â =Â $param->{can_manage_feedback}; |
|---|
| 1819 | Â Â Â Â Â Â Â $param->{has_manage_label}Â =Â $param->{can_edit_templates} |
|---|
| 1820 | Â Â Â Â Â ||Â $param->{can_administer_blog} |
|---|
| 1821 | Â Â Â Â Â ||Â $param->{can_edit_categories} |
|---|
| 1822 | Â Â Â Â Â ||Â $param->{can_edit_config} |
|---|
| 1823 | Â Â Â Â Â ||Â $param->{can_edit_tags} |
|---|
| 1824 | Â Â Â Â Â ||Â $param->{can_set_publish_paths} |
|---|
| 1825 | Â Â Â Â Â ||Â $param->{show_ip_info}; |
|---|
| 1826 | Â Â Â Â $param->{has_posting_label}Â =Â $param->{can_create_post} |
|---|
| 1827 | Â Â Â Â Â ||Â $param->{can_edit_entries} |
|---|
| 1828 | Â Â Â Â Â ||Â $param->{can_access_assets}; |
|---|
| 1829 | Â Â Â Â $param->{has_community_label}Â =Â $param->{can_edit_entries} |
|---|
| 1830 | Â Â Â Â Â ||Â $param->{can_edit_notifications}; |
|---|
| 1831 | Â Â Â Â $param->{can_publish_feedbacks}Â =Â $param->{can_manage_feedback} |
|---|
| 1832 | Â Â Â Â Â ||Â $param->{can_publish_post} |
|---|
| 1833 | Â Â Â Â Â ||Â $param->{can_edit_all_posts}; |
|---|
| 1834 | Â Â Â Â $param->{can_view_log}Â Â Â =Â $param->{can_view_blog_log}; |
|---|
| 1835 | Â Â Â Â $param->{can_publish_post}Â =Â $param->{can_publish_post} |
|---|
| 1836 | Â Â Â Â Â ||Â $param->{can_edit_all_posts}; |
|---|
| 1837 | Â Â Â Â $param->{show_ip_info}Â =Â $app->config->ShowIPInformation |
|---|
| 1838 | Â Â Â Â Â &&Â $param->{can_manage_feedback}; |
|---|
| 1839 | Â Â } |
|---|
| 1840 | |
|---|
| 1841 |   my $static_app_url = $app->static_path; |
|---|
| 1842 |   $param->{help_url} = $app->help_url() || $static_app_url . 'docs/'; |
|---|
| 1843 | |
|---|
| 1844 | Â Â $param->{show_ip_info}Â ||=Â $app->config('ShowIPInformation'); |
|---|
| 1845 |   my $type = $app->param('_type') || ''; |
|---|
| 1846 | |
|---|
| 1847 |   $param->{ "mode_$mode" . ( $type ? "_$type" : '' ) } = 1; |
|---|
| 1848 | Â Â $param->{return_args}Â ||=Â $app->make_return_args; |
|---|
| 1849 | Â Â $tmpl->param($param); |
|---|
| 1850 | } |
|---|
| 1851 | |
|---|
| 1852 | sub build_page { |
|---|
| 1853 |   my $app = shift; |
|---|
| 1854 |   my ( $page, $param ) = @_; |
|---|
| 1855 |   $param ||= {}; |
|---|
| 1856 | |
|---|
| 1857 |   my $blog_id = $app->param('blog_id') || 0; |
|---|
| 1858 |   my $blog; |
|---|
| 1859 |   my $blog_class = $app->model('blog'); |
|---|
| 1860 |   $blog ||= $blog_class->load($blog_id) if $blog_id; |
|---|
| 1861 |   if ( $blog_id && $page ne 'login.tmpl' ) { |
|---|
| 1862 |     if ($blog) { |
|---|
| 1863 | Â Â Â Â Â Â $param->{blog_name}Â =Â $blog->name; |
|---|
| 1864 | Â Â Â Â Â Â $param->{blog_id}Â Â =Â $blog->id; |
|---|
| 1865 | Â Â Â Â Â Â $param->{blog_url}Â =Â $blog->site_url; |
|---|
| 1866 | Â Â Â Â Â Â $param->{blog_template_set}Â =Â $blog->template_set; |
|---|
| 1867 | Â Â Â Â } |
|---|
| 1868 |     else { |
|---|
| 1869 |       $app->error( $app->translate( "No such blog [_1]", $blog_id ) ); |
|---|
| 1870 | Â Â Â Â } |
|---|
| 1871 | Â Â } |
|---|
| 1872 |   if ( $page ne 'login.tmpl' ) { |
|---|
| 1873 |     if ( ref $app eq 'MT::App::CMS' ) { |
|---|
| 1874 | Â Â Â Â Â Â $param->{system_overview_nav}Â =Â 1 |
|---|
| 1875 |        unless $blog_id |
|---|
| 1876 |        || exists $param->{system_overview_nav} |
|---|
| 1877 | Â Â Â Â Â Â Â ||Â $param->{no_breadcrumbs}; |
|---|
| 1878 |       $param->{quick_search} = 1 unless defined $param->{quick_search}; |
|---|
| 1879 | Â Â Â Â } |
|---|
| 1880 | Â Â } |
|---|
| 1881 | |
|---|
| 1882 | Â Â $app->build_blog_selector($param); |
|---|
| 1883 | Â Â $app->build_menus($param); |
|---|
| 1884 |   if (!ref($page) || ($page->isa('MT::Template') && !$page->param('page_actions'))) { |
|---|
| 1885 | Â Â Â Â $param->{page_actions}Â ||=Â $app->page_actions(Â $app->mode ); |
|---|
| 1886 | Â Â } |
|---|
| 1887 | |
|---|
| 1888 |   $app->SUPER::build_page( $page, $param ); |
|---|
| 1889 | } |
|---|
| 1890 | |
|---|
| 1891 | sub build_blog_selector { |
|---|
| 1892 |   my $app = shift; |
|---|
| 1893 |   my ($param) = @_; |
|---|
| 1894 | |
|---|
| 1895 |   return if exists $param->{top_blog_loop}; |
|---|
| 1896 | |
|---|
| 1897 |   my $blog = $app->blog; |
|---|
| 1898 |   my $blog_id = $blog->id if $blog; |
|---|
| 1899 |   $param->{dynamic_all} = $blog->custom_dynamic_templates eq 'all' if $blog; |
|---|
| 1900 | |
|---|
| 1901 |   my $blog_class = $app->model('blog'); |
|---|
| 1902 |   my $auth = $app->user or return; |
|---|
| 1903 | |
|---|
| 1904 | Â Â # Any access to a blog will put it on the top of your |
|---|
| 1905 | Â Â # recently used blogs list (the blog selector) |
|---|
| 1906 |   $app->add_to_favorite_blogs($blog_id) if $blog_id; |
|---|
| 1907 | |
|---|
| 1908 |   my %args; |
|---|
| 1909 | Â Â $args{join}Â = |
|---|
| 1910 | Â Â Â MT::Permission->join_on(Â 'blog_id', |
|---|
| 1911 |      { author_id => $auth->id, permissions => { not => "'comment'" } } ); |
|---|
| 1912 | Â Â $args{limit}Â =Â 11;Â Â # don't load more than 11 |
|---|
| 1913 |   my @blogs = $blog_class->load( undef, \%args ); |
|---|
| 1914 | |
|---|
| 1915 |   my @fav_blogs = @{ $auth->favorite_blogs || [] }; |
|---|
| 1916 |   @fav_blogs = grep { $_ != $blog_id } @fav_blogs if $blog_id; |
|---|
| 1917 | |
|---|
| 1918 | Â Â # Special case for when a user only has access to a single blog. |
|---|
| 1919 |   if ( (!defined($app->param('blog_id'))) && ( @blogs == 1 ) && ( scalar @fav_blogs <= 1 ) ) { |
|---|
| 1920 | |
|---|
| 1921 | Â Â Â Â # User only has visibility to a single blog. Don't |
|---|
| 1922 | Â Â Â Â # bother giving them a dashboard link for 'all blogs', or |
|---|
| 1923 | Â Â Â Â # to 'select a blog'. |
|---|
| 1924 | Â Â Â Â $param->{single_blog_mode}Â =Â 1; |
|---|
| 1925 |     my $blog = $blogs[0]; |
|---|
| 1926 |     $blog_id = $blog->id; |
|---|
| 1927 |     my $perms = MT::Permission->load( |
|---|
| 1928 | Â Â Â Â Â Â { |
|---|
| 1929 |         blog_id  => $blog_id, |
|---|
| 1930 | Â Â Â Â Â Â Â Â author_id =>Â $auth->id |
|---|
| 1931 | Â Â Â Â Â Â } |
|---|
| 1932 | Â Â Â Â ); |
|---|
| 1933 |     if ( !$app->blog ) { |
|---|
| 1934 |       if ( $app->mode eq 'dashboard' ) { |
|---|
| 1935 |         $app->param( 'blog_id', $blog_id ); |
|---|
| 1936 | Â Â Â Â Â Â Â Â $param->{blog_id}Â Â =Â $blog_id; |
|---|
| 1937 | Â Â Â Â Â Â Â Â $param->{blog_name}Â =Â $blog->name; |
|---|
| 1938 | Â Â Â Â Â Â Â Â $app->permissions($perms); |
|---|
| 1939 | Â Â Â Â Â Â Â Â $app->blog($blog); |
|---|
| 1940 | Â Â Â Â Â Â } |
|---|
| 1941 |       else { |
|---|
| 1942 |         @fav_blogs = ($blog_id); |
|---|
| 1943 |         $blog_id  = undef; |
|---|
| 1944 | Â Â Â Â Â Â } |
|---|
| 1945 | Â Â Â Â } |
|---|
| 1946 | Â Â } |
|---|
| 1947 |   elsif ( @blogs && ( @blogs <= 10 ) ) { |
|---|
| 1948 | |
|---|
| 1949 | Â Â Â Â # This user only has visibility to 10 or fewer blogs; |
|---|
| 1950 | Â Â Â Â # no need to reference their 'favorite' blogs list. |
|---|
| 1951 |     my @ids = map { $_->id } @blogs; |
|---|
| 1952 |     if ($blog_id) { |
|---|
| 1953 |       @ids = grep { $_ != $blog_id } @ids; |
|---|
| 1954 | Â Â Â Â } |
|---|
| 1955 |     @fav_blogs = @ids; |
|---|
| 1956 |     if ( $auth->is_superuser ) { |
|---|
| 1957 | |
|---|
| 1958 | Â Â Â Â Â Â # Better check to see if there are more than |
|---|
| 1959 | Â Â Â Â Â Â # 10 blogs in the system; if so, a superuser |
|---|
| 1960 | Â Â Â Â Â Â # will still want the 'Select a blog...' chooser. |
|---|
| 1961 | Â Â Â Â Â Â # Otherwise, hide it. |
|---|
| 1962 |       my $all_blog_count = $blog_class->count(); |
|---|
| 1963 |       if ( $all_blog_count < 11 ) { |
|---|
| 1964 | Â Â Â Â Â Â Â Â $param->{selector_hide_chooser}Â =Â 1; |
|---|
| 1965 | Â Â Â Â Â Â } |
|---|
| 1966 | Â Â Â Â } |
|---|
| 1967 |     else { |
|---|
| 1968 | |
|---|
| 1969 | Â Â Â Â Â Â # This user is not a superuser and only has |
|---|
| 1970 | Â Â Â Â Â Â # 10 blogs, so they don't need a 'select blog' |
|---|
| 1971 | Â Â Â Â Â Â # link... |
|---|
| 1972 | Â Â Â Â Â Â $param->{selector_hide_chooser}Â =Â 1; |
|---|
| 1973 | Â Â Â Â } |
|---|
| 1974 | Â Â } |
|---|
| 1975 | Â Â $param->{selector_hide_chooser}Â ||=Â 0; |
|---|
| 1976 | |
|---|
| 1977 | Â Â # Logic for populating the blog selector control |
|---|
| 1978 | Â Â #Â Â * Pull list of 'favorite blogs' from user record |
|---|
| 1979 | Â Â #Â Â * Load all of those blogs so we can display them |
|---|
| 1980 | Â Â #Â Â * Exclude the current blog from the favorite list so it isn't |
|---|
| 1981 | Â Â #Â Â Â shown twice. |
|---|
| 1982 |   @blogs = $blog_class->load( { id => \@fav_blogs } ) if @fav_blogs; |
|---|
| 1983 |   my %blogs = map { $_->id => $_ } @blogs; |
|---|
| 1984 |   @blogs = (); |
|---|
| 1985 |   foreach my $id (@fav_blogs) { |
|---|
| 1986 |     push @blogs, $blogs{$id} if $blogs{$id}; |
|---|
| 1987 | Â Â } |
|---|
| 1988 | |
|---|
| 1989 |   my @data; |
|---|
| 1990 |   if (@blogs) { |
|---|
| 1991 |     my @perms = grep { !$_->is_empty } MT::Permission->load( |
|---|
| 1992 | Â Â Â Â Â Â { |
|---|
| 1993 | Â Â Â Â Â Â Â Â author_id =>Â $auth->id, |
|---|
| 1994 |         blog_id  => \@fav_blogs, |
|---|
| 1995 | Â Â Â Â Â Â } |
|---|
| 1996 | Â Â Â Â ); |
|---|
| 1997 |     my %perms = map { $_->blog_id => $_ } @perms; |
|---|
| 1998 |     for my $blog (@blogs) { |
|---|
| 1999 |       my $perm = $perms{ $blog->id }; |
|---|
| 2000 | Â Â Â Â Â Â next |
|---|
| 2001 |        unless $auth->is_superuser || ( $perm && !$perm->is_empty ); |
|---|
| 2002 |       push @data, |
|---|
| 2003 | Â Â Â Â Â Â Â { |
|---|
| 2004 |         top_blog_id  => $blog->id, |
|---|
| 2005 | Â Â Â Â Â Â Â Â top_blog_name =>Â $blog->name |
|---|
| 2006 | Â Â Â Â Â Â Â }; |
|---|
| 2007 | Â Â Â Â Â Â $data[-1]{top_blog_selected}Â =Â 1 |
|---|
| 2008 |        if $blog_id && ( $blog->id == $blog_id ); |
|---|
| 2009 | Â Â Â Â } |
|---|
| 2010 | Â Â } |
|---|
| 2011 | Â Â $param->{top_blog_loop}Â =Â \@data; |
|---|
| 2012 |   if ( !$app->user->can_create_blog |
|---|
| 2013 | Â Â Â Â &&Â (Â $param->{single_blog_mode}Â ||Â scalar(@data)Â <=Â 1Â )Â ) |
|---|
| 2014 | Â Â { |
|---|
| 2015 | Â Â Â Â $param->{no_submenu}Â =Â 1; |
|---|
| 2016 | Â Â } |
|---|
| 2017 | } |
|---|
| 2018 | |
|---|
| 2019 | sub build_menus { |
|---|
| 2020 |   my $app = shift; |
|---|
| 2021 |   my ($param) = @_; |
|---|
| 2022 |   return if exists $param->{top_nav_loop}; |
|---|
| 2023 | |
|---|
| 2024 |   my $menus  = $app->registry('menus'); |
|---|
| 2025 |   my $blog  = $app->blog; |
|---|
| 2026 |   my $blog_id = $blog->id if $blog; |
|---|
| 2027 | |
|---|
| 2028 |   my @top_ids = grep { !/:/ } keys %$menus; |
|---|
| 2029 |   my @top; |
|---|
| 2030 |   my @sys; |
|---|
| 2031 |   my $user = $app->user |
|---|
| 2032 |    or return; |
|---|
| 2033 |   my $perms = $app->permissions || $user->permissions; |
|---|
| 2034 |   my $view = $blog_id ? "blog" : "system"; |
|---|
| 2035 | |
|---|
| 2036 |   my $hide_disabled_options = $app->config('HideDisabledMenus') || 0; |
|---|
| 2037 | |
|---|
| 2038 |   my $admin = |
|---|
| 2039 | Â Â Â $user->is_superuser();Â Â # || ($perms && $perms->has('administer_blog')); |
|---|
| 2040 | |
|---|
| 2041 |   foreach my $id (@top_ids) { |
|---|
| 2042 |     my $menu = $menus->{$id}; |
|---|
| 2043 |     next if $menu->{view} && $menu->{view} ne $view; |
|---|
| 2044 |     if (my $cond = $menu->{condition}) { |
|---|
| 2045 |       if (!ref($cond)) { |
|---|
| 2046 |         $cond = $menu->{condition} = $app->handler_to_coderef($cond); |
|---|
| 2047 | Â Â Â Â Â Â } |
|---|
| 2048 |       next unless $cond->(); |
|---|
| 2049 | Â Â Â Â } |
|---|
| 2050 | |
|---|
| 2051 | Â Â Â Â $menu->{allowed}Â =Â 1; |
|---|
| 2052 | Â Â Â Â $menu->{'id'}Â =Â $id; |
|---|
| 2053 | |
|---|
| 2054 |     my @sub_ids = grep { m/^$id:/ } keys %$menus; |
|---|
| 2055 |     my @sub; |
|---|
| 2056 |     foreach my $sub_id (@sub_ids) { |
|---|
| 2057 |       my $sub = $menus->{$sub_id}; |
|---|
| 2058 | Â Â Â Â Â Â next |
|---|
| 2059 |        if $sub->{view} |
|---|
| 2060 |        && ( $sub->{view} ne $view ); |
|---|
| 2061 | Â Â Â Â Â Â $sub->{'id'}Â =Â $sub_id; |
|---|
| 2062 |       if (my $cond = $sub->{condition}) { |
|---|
| 2063 |         if (!ref($cond)) { |
|---|
| 2064 |           $cond = $sub->{condition} = $app->handler_to_coderef($cond); |
|---|
| 2065 | Â Â Â Â Â Â Â Â } |
|---|
| 2066 |         next unless $cond->(); |
|---|
| 2067 | Â Â Â Â Â Â } |
|---|
| 2068 |       push @sub, $sub; |
|---|
| 2069 | Â Â Â Â } |
|---|
| 2070 | |
|---|
| 2071 |     if ( |
|---|
| 2072 |       my $p = |
|---|
| 2073 | Â Â Â Â Â Â Â $blog_id |
|---|
| 2074 |       ? $menu->{permission} |
|---|
| 2075 | Â Â Â Â Â Â ||Â $menu->{system_permission} |
|---|
| 2076 | Â Â Â Â Â Â :Â $menu->{system_permission} |
|---|
| 2077 | Â Â Â Â Â Â ||Â $menu->{permission} |
|---|
| 2078 | Â Â Â Â Â ) |
|---|
| 2079 | Â Â Â Â { |
|---|
| 2080 |       my $allowed = 0; |
|---|
| 2081 |       my @p = split /,/, $p; |
|---|
| 2082 |       foreach my $p (@p) { |
|---|
| 2083 |         my $perm = 'can_' . $p; |
|---|
| 2084 |         $allowed = 1, last if ( $perms && $perms->$perm() ) || $admin; |
|---|
| 2085 | Â Â Â Â Â Â } |
|---|
| 2086 | Â Â Â Â Â Â $menu->{allowed}Â =Â $allowed; |
|---|
| 2087 | Â Â Â Â } |
|---|
| 2088 |     elsif ( !$perms && !$blog_id ) { |
|---|
| 2089 |       $menu->{allowed} = 0 if $menu->{system_permission} && !$admin; |
|---|
| 2090 | Â Â Â Â } |
|---|
| 2091 | |
|---|
| 2092 |     next if $hide_disabled_options && (! $menu->{allowed}); |
|---|
| 2093 | |
|---|
| 2094 |     if (@sub) { |
|---|
| 2095 |       if ( $id eq 'system' ) { |
|---|
| 2096 |         push @sys, $menu; |
|---|
| 2097 | Â Â Â Â Â Â } |
|---|
| 2098 |       else { |
|---|
| 2099 |         push @top, $menu; |
|---|
| 2100 | Â Â Â Â Â Â } |
|---|
| 2101 | |
|---|
| 2102 |       my $has_sub = 0; |
|---|
| 2103 |       foreach my $sub (@sub) { |
|---|
| 2104 |         my $sys_only = $sub->{id} =~ m/^system:/; |
|---|
| 2105 | Â Â Â Â Â Â Â Â $sub->{allowed}Â =Â 1; |
|---|
| 2106 |         if ( $sub->{mode} ) { |
|---|
| 2107 | Â Â Â Â Â Â Â Â Â Â $sub->{link}Â =Â $app->uri( |
|---|
| 2108 | Â Â Â Â Â Â Â Â Â Â Â Â mode =>Â $sub->{mode}, |
|---|
| 2109 | Â Â Â Â Â Â Â Â Â Â Â Â args =>Â { |
|---|
| 2110 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â %{Â $sub->{args}Â ||Â {}Â }, |
|---|
| 2111 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ( |
|---|
| 2112 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $blog_id |
|---|
| 2113 |                  && !$sys_only ? ( blog_id => $blog_id ) : () |
|---|
| 2114 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ) |
|---|
| 2115 | Â Â Â Â Â Â Â Â Â Â Â Â } |
|---|
| 2116 | Â Â Â Â Â Â Â Â Â Â ); |
|---|
| 2117 | Â Â Â Â Â Â Â Â } |
|---|
| 2118 | Â Â Â Â Â Â Â Â $sub->{allowed}Â =Â 0 |
|---|
| 2119 |          if $sub->{view} && ( $sub->{view} ne $view ); |
|---|
| 2120 |         if ( $sub->{allowed} ) { |
|---|
| 2121 |           my $sub_perms = |
|---|
| 2122 |            ( $sys_only || ( $sub->{view} || '' ) eq 'system' ) |
|---|
| 2123 |            ? $app->user->permissions(0) |
|---|
| 2124 | Â Â Â Â Â Â Â Â Â Â Â :Â $perms; |
|---|
| 2125 |           if ( |
|---|
| 2126 | Â Â Â Â Â Â Â Â Â Â Â Â $sub_perms |
|---|
| 2127 | Â Â Â Â Â Â Â Â Â Â Â Â &&Â ( |
|---|
| 2128 |               my $p = |
|---|
| 2129 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $blog_id |
|---|
| 2130 |               ? $sub->{permission} |
|---|
| 2131 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ||Â $sub->{system_permission} |
|---|
| 2132 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â :Â $sub->{system_permission} |
|---|
| 2133 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â ||Â $sub->{permission} |
|---|
| 2134 | Â Â Â Â Â Â Â Â Â Â Â Â ) |
|---|
| 2135 | Â Â Â Â Â Â Â Â Â Â Â ) |
|---|
| 2136 | Â Â Â Â Â Â Â Â Â Â { |
|---|
| 2137 |             my $allowed = 0; |
|---|
| 2138 |             my @p = split /,/, $p; |
|---|
| 2139 |             foreach my $p (@p) { |
|---|
| 2140 |               my $perm = 'can_' . $p; |
|---|
| 2141 |               $allowed = 1, last |
|---|
| 2142 |                if ( $sub_perms && $sub_perms->$perm() ) |
|---|
| 2143 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ||Â $admin; |
|---|
| 2144 | Â Â Â Â Â Â Â Â Â Â Â Â } |
|---|
| 2145 | Â Â Â Â Â Â Â Â Â Â Â Â $sub->{allowed}Â =Â $allowed; |
|---|
| 2146 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 2147 |           elsif ( !$sub_perms && !$blog_id ) { |
|---|
| 2148 | Â Â Â Â Â Â Â Â Â Â Â Â $sub->{allowed}Â =Â 0 |
|---|
| 2149 |              if ( $sub->{system_permission} || $sub->{permission} ) |
|---|
| 2150 | Â Â Â Â Â Â Â Â Â Â Â Â Â &&Â !$admin; |
|---|
| 2151 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 2152 |           $has_sub = 1 if $sub->{allowed}; |
|---|
| 2153 | Â Â Â Â Â Â Â Â } |
|---|
| 2154 | Â Â Â Â Â Â } |
|---|
| 2155 |       if ( $menu->{mode} ) { |
|---|
| 2156 |         my $sys_only = 1 if $menu->{id} eq 'system'; |
|---|
| 2157 | Â Â Â Â Â Â Â Â $menu->{link}Â =Â $app->uri( |
|---|
| 2158 | Â Â Â Â Â Â Â Â Â Â mode =>Â $menu->{mode}, |
|---|
| 2159 | Â Â Â Â Â Â Â Â Â Â args =>Â { |
|---|
| 2160 | Â Â Â Â Â Â Â Â Â Â Â Â %{Â $menu->{args}Â ||Â {}Â }, |
|---|
| 2161 | Â Â Â Â Â Â Â Â Â Â Â Â ( |
|---|
| 2162 | Â Â Â Â Â Â Â Â Â Â Â Â Â Â $blog_id |
|---|
| 2163 |                && !$sys_only ? ( blog_id => $blog_id ) : () |
|---|
| 2164 | Â Â Â Â Â Â Â Â Â Â Â Â ) |
|---|
| 2165 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 2166 | Â Â Â Â Â Â Â Â ); |
|---|
| 2167 | Â Â Â Â Â Â } |
|---|
| 2168 |       @sub = sort { $a->{order} <=> $b->{order} } @sub; |
|---|
| 2169 | |
|---|
| 2170 |       @sub = grep { $_->{allowed} } @sub if $hide_disabled_options; |
|---|
| 2171 |       if ( !$menu->{mode} ) { |
|---|
| 2172 | Â Â Â Â Â Â Â Â $menu->{link}Â =Â $sub[0]->{link}; |
|---|
| 2173 | Â Â Â Â Â Â } |
|---|
| 2174 | Â Â Â Â Â Â $menu->{sub_nav_loop}Â =Â \@sub; |
|---|
| 2175 | |
|---|
| 2176 |       if ( $menu->{allowed} ) { |
|---|
| 2177 |         $menu->{allowed} = 0 unless $has_sub; |
|---|
| 2178 | Â Â Â Â Â Â } |
|---|
| 2179 | Â Â Â Â } |
|---|
| 2180 | Â Â } |
|---|
| 2181 | |
|---|
| 2182 |   @top = grep { $_->{allowed} } @top if $hide_disabled_options; |
|---|
| 2183 |   @sys = grep { $_->{allowed} } @sys if $hide_disabled_options; |
|---|
| 2184 |   @top = sort { $a->{order} <=> $b->{order} } @top; |
|---|
| 2185 | Â Â $param->{top_nav_loop}Â =Â \@top; |
|---|
| 2186 | Â Â $param->{sys_nav_loop}Â =Â \@sys; |
|---|
| 2187 | } |
|---|
| 2188 | |
|---|
| 2189 | sub return_to_dashboard { |
|---|
| 2190 |   my $app = shift; |
|---|
| 2191 |   my (%param) = @_; |
|---|
| 2192 |   $param{redirect} = 1 unless %param; |
|---|
| 2193 |   my $blog_id = $app->param('blog_id'); |
|---|
| 2194 |   $param{blog_id} = $blog_id if $blog_id; |
|---|
| 2195 |   return $app->redirect( $app->uri( mode => 'dashboard', args => \%param ) ); |
|---|
| 2196 | } |
|---|
| 2197 | |
|---|
| 2198 | sub list_pref { |
|---|
| 2199 |   my $app   = shift; |
|---|
| 2200 |   my ($list)  = @_; |
|---|
| 2201 |   my $updating = $app->mode eq 'update_list_prefs'; |
|---|
| 2202 |   unless ($updating) { |
|---|
| 2203 |     my $pref = $app->request("list_pref_$list"); |
|---|
| 2204 |     return $pref if defined $pref; |
|---|
| 2205 | Â Â } |
|---|
| 2206 | |
|---|
| 2207 |   my $cookie = $app->cookie_val('mt_list_pref') || ''; |
|---|
| 2208 |   my $mode = $app->mode; |
|---|
| 2209 | |
|---|
| 2210 | Â Â # defaults: |
|---|
| 2211 |   my $d = $app->config->DefaultListPrefs || {}; |
|---|
| 2212 |   my %default = ( |
|---|
| 2213 |     Rows    => 25, |
|---|
| 2214 |     Format   => 'Compact', |
|---|
| 2215 |     SortOrder => 'Ascend',   # Ascend|Descend |
|---|
| 2216 |     Button   => 'Above',    # Above|Below|Both |
|---|
| 2217 |     DateFormat => 'Relative',  # Relative|Full |
|---|
| 2218 | Â Â ); |
|---|
| 2219 |   if ( ( $list eq 'comment' ) || ( $list eq 'ping' ) ) { |
|---|
| 2220 | Â Â Â Â $default{Format}Â =Â 'expanded'; |
|---|
| 2221 | Â Â } |
|---|
| 2222 |   $default{$_} = lc( $d->{$_} ) for keys %$d; |
|---|
| 2223 |   my $list_pref; |
|---|
| 2224 |   if ( $list eq 'main_menu' ) { |
|---|
| 2225 |     $list_pref = { |
|---|
| 2226 | Â Â Â Â Â Â 'sort'Â =>Â 'name', |
|---|
| 2227 |       order => $default{SortOrder} || 'ascend', |
|---|
| 2228 |       view  => $default{Format} || 'compact', |
|---|
| 2229 |       dates => $default{DateFormat} || 'relative', |
|---|
| 2230 | Â Â Â Â }; |
|---|
| 2231 | Â Â } |
|---|
| 2232 |   else { |
|---|
| 2233 |     $list_pref = { |
|---|
| 2234 |       rows => $default{Rows}    || 25, |
|---|
| 2235 |       view => $default{Format}   || 'compact', |
|---|
| 2236 |       bar  => $default{Button}   || 'above', |
|---|
| 2237 | Â Â Â Â Â Â dates =>Â $default{DateFormat}Â ||Â 'relative', |
|---|
| 2238 | Â Â Â Â }; |
|---|
| 2239 | Â Â } |
|---|
| 2240 |   my @list_prefs = split /;/, $cookie; |
|---|
| 2241 |   my $new_cookie = ''; |
|---|
| 2242 |   foreach my $pref (@list_prefs) { |
|---|
| 2243 |     my ( $name, $prefs ) = $pref =~ m/^(\w+):(.*)$/; |
|---|
| 2244 |     next unless $name && $prefs; |
|---|
| 2245 |     if ( $name eq $list ) { |
|---|
| 2246 |       my @prefs = split /,/, $prefs; |
|---|
| 2247 |       foreach (@prefs) { |
|---|
| 2248 |         my ( $k, $v ) = split /=/; |
|---|
| 2249 |         $list_pref->{$k} = $v if exists $list_pref->{$k}; |
|---|
| 2250 | Â Â Â Â Â Â } |
|---|
| 2251 | Â Â Â Â } |
|---|
| 2252 |     else { |
|---|
| 2253 |       $new_cookie .= ( $new_cookie ne '' ? ';' : '' ) . $pref; |
|---|
| 2254 | Â Â Â Â } |
|---|
| 2255 | Â Â } |
|---|
| 2256 | |
|---|
| 2257 |   if ($updating) { |
|---|
| 2258 |     my $updated = 0; |
|---|
| 2259 |     if ( my $limit = $app->param('limit') ) { |
|---|
| 2260 |       $limit = 20 if $limit eq 'none'; |
|---|
| 2261 |       $list_pref->{rows} = $limit > 0 ? $limit : 20; |
|---|
| 2262 |       $updated = 1; |
|---|
| 2263 | Â Â Â Â } |
|---|
| 2264 |     if ( my $view = $app->param('verbosity') ) { |
|---|
| 2265 |       if ( $view =~ m!^compact|expanded$! ) { |
|---|
| 2266 | Â Â Â Â Â Â Â Â $list_pref->{view}Â =Â $view; |
|---|
| 2267 |         $updated = 1; |
|---|
| 2268 | Â Â Â Â Â Â } |
|---|
| 2269 | Â Â Â Â } |
|---|
| 2270 |     if ( my $bar = $app->param('actions') ) { |
|---|
| 2271 |       if ( $bar =~ m!^above|below|both$! ) { |
|---|
| 2272 | Â Â Â Â Â Â Â Â $list_pref->{bar}Â =Â $bar; |
|---|
| 2273 |         $updated = 1; |
|---|
| 2274 | Â Â Â Â Â Â } |
|---|
| 2275 | Â Â Â Â } |
|---|
| 2276 |     if ( my $ord = $app->param('order') ) { |
|---|
| 2277 |       if ( $ord =~ m!^ascend|descend$! ) { |
|---|
| 2278 | Â Â Â Â Â Â Â Â $list_pref->{order}Â =Â $ord; |
|---|
| 2279 |         $updated = 1; |
|---|
| 2280 | Â Â Â Â Â Â } |
|---|
| 2281 | Â Â Â Â } |
|---|
| 2282 |     if ( my $sort = $app->param('sort') ) { |
|---|
| 2283 |       if ( $sort =~ m!^name|created|updated$! ) { |
|---|
| 2284 | Â Â Â Â Â Â Â Â $list_pref->{'sort'}Â =Â $sort; |
|---|
| 2285 |         $updated = 1; |
|---|
| 2286 | Â Â Â Â Â Â } |
|---|
| 2287 | Â Â Â Â } |
|---|
| 2288 |     if ( my $dates = $app->param('dates') ) { |
|---|
| 2289 |       if ( $dates =~ m!^relative|full$! ) { |
|---|
| 2290 | Â Â Â Â Â Â Â Â $list_pref->{'dates'}Â =Â $dates; |
|---|
| 2291 |         $updated = 1; |
|---|
| 2292 | Â Â Â Â Â Â } |
|---|
| 2293 | Â Â Â Â } |
|---|
| 2294 | |
|---|
| 2295 |     if ($updated) { |
|---|
| 2296 |       my @list_prefs; |
|---|
| 2297 |       foreach ( keys %$list_pref ) { |
|---|
| 2298 |         push @list_prefs, $_ . '=' . $list_pref->{$_}; |
|---|
| 2299 | Â Â Â Â Â Â } |
|---|
| 2300 |       my $prefs = join ',', @list_prefs; |
|---|
| 2301 |       $new_cookie .= |
|---|
| 2302 |        ( $new_cookie ne '' ? ';' : '' ) . $list . ':' . $prefs; |
|---|
| 2303 | Â Â Â Â Â Â $app->bake_cookie( |
|---|
| 2304 |         -name  => 'mt_list_pref', |
|---|
| 2305 |         -value  => $new_cookie, |
|---|
| 2306 | Â Â Â Â Â Â Â Â -expires =>Â '+10y' |
|---|
| 2307 | Â Â Â Â Â Â ); |
|---|
| 2308 | Â Â Â Â } |
|---|
| 2309 | Â Â } |
|---|
| 2310 | |
|---|
| 2311 |   if ( $list_pref->{rows} ) { |
|---|
| 2312 |     $list_pref->{ "limit_" . $list_pref->{rows} } = $list_pref->{rows}; |
|---|
| 2313 | Â Â } |
|---|
| 2314 |   if ( $list_pref->{view} ) { |
|---|
| 2315 |     $list_pref->{ "view_" . $list_pref->{view} } = 1; |
|---|
| 2316 | Â Â } |
|---|
| 2317 |   if ( $list_pref->{dates} ) { |
|---|
| 2318 |     $list_pref->{ "dates_" . $list_pref->{dates} } = 1; |
|---|
| 2319 | Â Â } |
|---|
| 2320 |   if ( $list_pref->{bar} ) { |
|---|
| 2321 |     if ( lc $list_pref->{bar} eq 'both' ) { |
|---|
| 2322 | Â Â Â Â Â Â $list_pref->{"position_actions_both"}Â Â =Â 1; |
|---|
| 2323 | Â Â Â Â Â Â $list_pref->{"position_actions_top"}Â Â =Â 1; |
|---|
| 2324 | Â Â Â Â Â Â $list_pref->{"position_actions_bottom"}Â =Â 1; |
|---|
| 2325 | Â Â Â Â } |
|---|
| 2326 |     elsif ( lc $list_pref->{bar} eq 'below' ) { |
|---|
| 2327 | Â Â Â Â Â Â $list_pref->{"position_actions_bottom"}Â =Â 1; |
|---|
| 2328 | Â Â Â Â } |
|---|
| 2329 |     elsif ( lc $list_pref->{bar} eq 'above' ) { |
|---|
| 2330 | Â Â Â Â Â Â $list_pref->{"position_actions_top"}Â =Â 1; |
|---|
| 2331 | Â Â Â Â } |
|---|
| 2332 | Â Â } |
|---|
| 2333 |   if ( $list_pref->{'sort'} ) { |
|---|
| 2334 |     $list_pref->{ 'sort_' . $list_pref->{'sort'} } = 1; |
|---|
| 2335 | Â Â } |
|---|
| 2336 |   if ( $list_pref->{'order'} ) { |
|---|
| 2337 |     $list_pref->{ 'order_' . $list_pref->{'order'} } = 1; |
|---|
| 2338 | Â Â } |
|---|
| 2339 |   $app->request( "list_pref_$list", $list_pref ); |
|---|
| 2340 | } |
|---|
| 2341 | |
|---|
| 2342 | sub make_feed_link { |
|---|
| 2343 |   my $app = shift; |
|---|
| 2344 |   my ( $view, $params ) = @_; |
|---|
| 2345 |   my $user = $app->user; |
|---|
| 2346 |   return if ( $user->api_password || '' ) eq ''; |
|---|
| 2347 | |
|---|
| 2348 |   $params ||= {}; |
|---|
| 2349 | Â Â $params->{view}Â Â Â =Â $view; |
|---|
| 2350 | Â Â $params->{username}Â =Â $user->name; |
|---|
| 2351 |   $params->{token}  = perl_sha1_digest_hex( 'feed:' . $user->api_password ); |
|---|
| 2352 | Â Â $app->base |
|---|
| 2353 |    . $app->mt_path |
|---|
| 2354 |    . $app->config('ActivityFeedScript') |
|---|
| 2355 |    . $app->uri_params( args => $params ); |
|---|
| 2356 | } |
|---|
| 2357 | |
|---|
| 2358 | sub show_error { |
|---|
| 2359 |   my $app = shift; |
|---|
| 2360 |   my ($param) = @_; |
|---|
| 2361 | |
|---|
| 2362 | Â Â # handle legacy scalar error string signature |
|---|
| 2363 |   $param = { error => $param } unless ref($param) eq 'HASH'; |
|---|
| 2364 | |
|---|
| 2365 |   my $mode = $app->mode; |
|---|
| 2366 |   if ( $mode eq 'rebuild' ) { |
|---|
| 2367 | |
|---|
| 2368 |     my $r = MT::Request->instance; |
|---|
| 2369 |     if (my $tmpl = $r->cache('build_template')) { |
|---|
| 2370 | Â Â Â Â Â Â # this is the template that likely caused the rebuild error |
|---|
| 2371 |       push @{ $param->{button_loop} ||= [] }, { |
|---|
| 2372 |         link => $app->uri( mode => 'view', args => { blog_id => $tmpl->blog_id, '_type' => 'template', id => $tmpl->id }), |
|---|
| 2373 | Â Â Â Â Â Â Â Â label =>Â $app->translate("Edit Template"), |
|---|
| 2374 | Â Â Â Â Â Â }; |
|---|
| 2375 | Â Â Â Â } |
|---|
| 2376 | |
|---|
| 2377 |     my $blog_id = $app->param('blog_id'); |
|---|
| 2378 |     my $url   = $app->uri( |
|---|
| 2379 | Â Â Â Â Â Â mode =>Â 'rebuild_confirm', |
|---|
| 2380 |       args => { blog_id => $blog_id } |
|---|
| 2381 | Â Â Â Â ); |
|---|
| 2382 | Â Â Â Â $param->{goback}Â ||=Â qq{window.location='$url'}; |
|---|
| 2383 | Â Â Â Â $param->{value}Â ||=Â $app->translate('Go Back'); |
|---|
| 2384 | Â Â } |
|---|
| 2385 | |
|---|
| 2386 |   return $app->SUPER::show_error($param); |
|---|
| 2387 | } |
|---|
| 2388 | |
|---|
| 2389 | sub load_default_entry_prefs { |
|---|
| 2390 |   my $app = shift; |
|---|
| 2391 |   my $prefs; |
|---|
| 2392 |   require MT::Permission; |
|---|
| 2393 |   my $blog_id; |
|---|
| 2394 |   $blog_id = $app->blog->id if $app->blog; |
|---|
| 2395 |   my $perm = MT::Permission->load( { blog_id => $blog_id, author_id => 0 } ); |
|---|
| 2396 |   my %default = %{ $app->config->DefaultEntryPrefs }; |
|---|
| 2397 |   if ( $perm && $perm->entry_prefs ) { |
|---|
| 2398 |     $prefs = $perm->entry_prefs; |
|---|
| 2399 | Â Â } |
|---|
| 2400 |   else { |
|---|
| 2401 |     if ( lc( $default{type} ) eq 'custom' ) { |
|---|
| 2402 |       my %map = ( |
|---|
| 2403 |         Category  => 'category', |
|---|
| 2404 |         Excerpt  => 'excerpt', |
|---|
| 2405 |         Keywords  => 'keywords', |
|---|
| 2406 |         Tags    => 'tags', |
|---|
| 2407 | Â Â Â Â Â Â Â Â Publishing =>Â 'publishing', |
|---|
| 2408 |         Feedback  => 'feedback', |
|---|
| 2409 | Â Â Â Â Â Â ); |
|---|
| 2410 |       my @p; |
|---|
| 2411 |       foreach my $p ( keys %map ) { |
|---|
| 2412 |         push @p, $map{$p} . ':' . ( $default{$p} || $default{ lc $p } ) |
|---|
| 2413 |          if ( $default{$p} || $default{ lc $p } ); |
|---|
| 2414 | Â Â Â Â Â Â } |
|---|
| 2415 |       $prefs = join ',', @p; |
|---|
| 2416 |       $prefs ||= 'Custom'; |
|---|
| 2417 | Â Â Â Â } |
|---|
| 2418 |     elsif ( lc( $default{type} ) ne 'default' ) { |
|---|
| 2419 |       $prefs = 'Advanced'; |
|---|
| 2420 | Â Â Â Â } |
|---|
| 2421 |     $default{button} = 'Bottom' if lc( $default{button} ) eq 'below'; |
|---|
| 2422 |     $default{button} = 'Top'  if lc( $default{button} ) eq 'above'; |
|---|
| 2423 |     $prefs .= '|' . $default{button} if $prefs; |
|---|
| 2424 | Â Â } |
|---|
| 2425 |   $prefs ||= 'Default|Bottom'; |
|---|
| 2426 |   return $prefs; |
|---|
| 2427 | } |
|---|
| 2428 | |
|---|
| 2429 | sub load_template_prefs { |
|---|
| 2430 |   my $app = shift; |
|---|
| 2431 |   my ($prefs) = @_; |
|---|
| 2432 |   my %param; |
|---|
| 2433 | |
|---|
| 2434 |   if ( !$prefs ) { |
|---|
| 2435 |     $prefs = ''; |
|---|
| 2436 | Â Â } |
|---|
| 2437 |   my @p = split /,/, $prefs; |
|---|
| 2438 |   for my $p (@p) { |
|---|
| 2439 |     if ( $p =~ m/^(.+?):(\d+)$/ ) { |
|---|
| 2440 |       $param{ 'disp_prefs_height_' . $1 } = $2; |
|---|
| 2441 | Â Â Â Â } |
|---|
| 2442 | Â Â } |
|---|
| 2443 | Â Â \%param; |
|---|
| 2444 | } |
|---|
| 2445 | |
|---|
| 2446 | sub _parse_entry_prefs { |
|---|
| 2447 |   my $app = shift; |
|---|
| 2448 |   my ( $prefs, $param ) = @_; |
|---|
| 2449 | |
|---|
| 2450 |   my @p = split /,/, $prefs; |
|---|
| 2451 |   for my $p (@p) { |
|---|
| 2452 |     if ( $p =~ m/^(.+?):(\d+)$/ ) { |
|---|
| 2453 |       my ( $name, $num ) = ( $1, $2 ); |
|---|
| 2454 |       if ($num) { |
|---|
| 2455 |         $param->{ 'disp_prefs_height_' . $name } = $num; |
|---|
| 2456 | Â Â Â Â Â Â } |
|---|
| 2457 |       $param->{ 'disp_prefs_show_' . $name } = 1; |
|---|
| 2458 | Â Â Â Â } |
|---|
| 2459 |     else { |
|---|
| 2460 |       $p = 'Default' if lc($p) eq 'basic'; |
|---|
| 2461 |       if ( ( lc($p) eq 'advanced' ) || ( lc($p) eq 'default' ) ) { |
|---|
| 2462 |         $param->{ 'disp_prefs_' . $p } = 1; |
|---|
| 2463 |         foreach my $def ( |
|---|
| 2464 | Â Â Â Â Â Â Â Â Â Â qw(title body category tags keywords feedback publishing )) |
|---|
| 2465 | Â Â Â Â Â Â Â Â { |
|---|
| 2466 |           $param->{ 'disp_prefs_show_' . $def } = 1; |
|---|
| 2467 | Â Â Â Â Â Â Â Â } |
|---|
| 2468 |         if ( lc($p) eq 'advanced' ) { |
|---|
| 2469 |           foreach my $def (qw(excerpt feedback)) { |
|---|
| 2470 |             $param->{ 'disp_prefs_show_' . $def } = 1; |
|---|
| 2471 | Â Â Â Â Â Â Â Â Â Â } |
|---|
| 2472 | Â Â Â Â Â Â Â Â } |
|---|
| 2473 | Â Â Â Â Â Â } |
|---|
| 2474 |       else { |
|---|
| 2475 |         $param->{ 'disp_prefs_show_' . $p } = 1; |
|---|
| 2476 | Â Â Â Â Â Â } |
|---|
| 2477 | Â Â Â Â } |
|---|
| 2478 | Â Â } |
|---|
| 2479 | } |
|---|
| 2480 | |
|---|
| 2481 | sub load_entry_prefs { |
|---|
| 2482 |   my $app = shift; |
|---|
| 2483 |   my ($prefs) = @_; |
|---|
| 2484 |   my %param; |
|---|
| 2485 |   my $pos; |
|---|
| 2486 |   my $is_from_db = 1; |
|---|
| 2487 | |
|---|
| 2488 | Â Â # defaults: |
|---|
| 2489 |   if ( !$prefs ) { |
|---|
| 2490 |     $prefs = $app->load_default_entry_prefs; |
|---|
| 2491 |     ( $prefs, $pos ) = split /\|/, $prefs; |
|---|
| 2492 |     $is_from_db = 0; |
|---|
| 2493 |     $app->_parse_entry_prefs( $prefs, \%param ); |
|---|
| 2494 |     my @fields; |
|---|
| 2495 |     foreach ( keys %param ) { |
|---|
| 2496 |       if (m/^disp_prefs_show_(.+)/) { |
|---|
| 2497 |         push @fields, { name => $1 }; |
|---|
| 2498 | Â Â Â Â Â Â } |
|---|
| 2499 | Â Â Â Â } |
|---|
| 2500 | Â Â Â Â $param{disp_prefs_default_fields}Â =Â \@fields; |
|---|
| 2501 | Â Â } |
|---|
| 2502 |   else { |
|---|
| 2503 |     ( $prefs, $pos ) = split /\|/, $prefs; |
|---|
| 2504 | Â Â } |
|---|
| 2505 |   $app->_parse_entry_prefs( $prefs, \%param ); |
|---|
| 2506 |   if ($is_from_db) { |
|---|
| 2507 |     my $default_prefs = $app->load_default_entry_prefs; |
|---|
| 2508 |     ( $default_prefs, my ($default_pos) ) = split /\|/, $default_prefs; |
|---|
| 2509 |     $pos ||= $default_pos; |
|---|
| 2510 |     $app->_parse_entry_prefs( $default_prefs, \my %def_param ); |
|---|
| 2511 |     my @fields; |
|---|
| 2512 |     foreach ( keys %def_param ) { |
|---|
| 2513 |       if (m/^disp_prefs_show_(.+)/) { |
|---|
| 2514 |         push @fields, { name => $1 }; |
|---|
| 2515 | Â Â Â Â Â Â } |
|---|
| 2516 | Â Â Â Â } |
|---|
| 2517 |     if ( $prefs eq 'Default' ) { |
|---|
| 2518 |       foreach my $p ( keys %param ) { |
|---|
| 2519 |         delete $param{$p} if $p =~ m/^disp_prefs_show_/; |
|---|
| 2520 | Â Â Â Â Â Â } |
|---|
| 2521 | Â Â Â Â } |
|---|
| 2522 |     if ( $param{disp_prefs_Default} ) { |
|---|
| 2523 | |
|---|
| 2524 | Â Â Â Â Â Â # apply default settings |
|---|
| 2525 |       %param = ( %def_param, %param ); |
|---|
| 2526 | Â Â Â Â } |
|---|
| 2527 | Â Â Â Â $param{disp_prefs_default_fields}Â =Â \@fields; |
|---|
| 2528 | Â Â } |
|---|
| 2529 |   $pos ||= 'Bottom'; |
|---|
| 2530 |   if (  !exists $param{'disp_prefs_Default'} |
|---|
| 2531 |     && !exists $param{'disp_prefs_Advanced'} ) |
|---|
| 2532 | Â Â { |
|---|
| 2533 | Â Â Â Â $param{'disp_prefs_Custom'}Â =Â 1; |
|---|
| 2534 | Â Â } |
|---|
| 2535 |   if ( lc $pos eq 'both' ) { |
|---|
| 2536 | Â Â Â Â $param{'position_actions_top'}Â Â =Â 1; |
|---|
| 2537 | Â Â Â Â $param{'position_actions_bottom'}Â =Â 1; |
|---|
| 2538 | Â Â Â Â $param{'position_actions_both'}Â Â =Â 1; |
|---|
| 2539 | Â Â } |
|---|
| 2540 |   else { |
|---|
| 2541 |     $param{ 'position_actions_' . $pos } = 1; |
|---|
| 2542 | Â Â } |
|---|
| 2543 | Â Â \%param; |
|---|
| 2544 | } |
|---|
| 2545 | |
|---|
| 2546 | sub _convert_word_chars { |
|---|
| 2547 |   my ( $app, $s ) = @_; |
|---|
| 2548 |   return '' unless $s; |
|---|
| 2549 |   return |
|---|