root/branches/release-38/lib/MT/Core.pm @ 2245

Revision 2245, 37.3 kB (checked in by bchoate, 19 months ago)

Restored UserSessionTimeout setting.

  • Property svn:keywords set to Id Revision
Line 
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
7package MT::Core;
8
9use strict;
10use MT;
11use base 'MT::Component';
12
13# This is just to make our localization scanner happy
14sub trans {
15    return shift;
16}
17
18sub name {
19    return "Core";
20}
21
22my $core_registry;
23
24BEGIN {
25    $core_registry = {
26        version        => MT->VERSION,
27        schema_version => MT->schema_version,
28        object_drivers => {
29            'mysql' => {
30                label => 'MySQL Database',
31                dbd_package => 'DBD::mysql',
32                config_package => 'DBI::mysql',
33            },
34            'postgres' => {
35                label => 'PostgreSQL Database',
36                dbd_package => 'DBD::Pg',
37                dbd_version => '1.32',
38                config_package => 'DBI::postgres',
39            },
40            'sqlite' => {
41                label => 'SQLite Database',
42                dbd_package => 'DBD::SQLite',
43                config_package => 'DBI::sqlite',
44            },
45            'sqlite2' => {
46                label => 'SQLite Database (v2)',
47                dbd_package => 'DBD::SQLite2',
48                config_package => 'DBI::sqlite',
49            },
50        },
51        object_types   => {
52            'entry'           => 'MT::Entry',
53            'author'          => 'MT::Author',
54            'asset'           => 'MT::Asset',
55            'file'            => 'MT::Asset',
56            'asset.image'     => 'MT::Asset::Image',
57            'image'           => 'MT::Asset::Image',
58            'asset.audio'     => 'MT::Asset::Audio',
59            'audio'           => 'MT::Asset::Audio',
60            'asset.video'     => 'MT::Asset::Video',
61            'video'           => 'MT::Asset::Video',
62            'entry.page'      => 'MT::Page',
63            'page'            => 'MT::Page',
64            'category.folder' => 'MT::Folder',
65            'folder'          => 'MT::Folder',
66            'category'        => 'MT::Category',
67            'user'            => 'MT::Author',
68            'commenter'       => 'MT::Author',
69            'blog'            => 'MT::Blog',
70            'template'        => 'MT::Template',
71            'comment'         => 'MT::Comment',
72            'notification'    => 'MT::Notification',
73            'templatemap'     => 'MT::TemplateMap',
74            'banlist'         => 'MT::IPBanList',
75            'ipbanlist'       => 'MT::IPBanList',
76            'tbping'          => 'MT::TBPing',
77            'ping'            => 'MT::TBPing',
78            'ping_cat'        => 'MT::TBPing',
79            'log'             => 'MT::Log',
80            'log.ping'        => 'MT::Log::TBPing',
81            'log.entry'       => 'MT::Log::Entry',
82            'log.comment'     => 'MT::Log::Comment',
83            'log.system'      => 'MT::Log',
84            'tag'             => 'MT::Tag',
85            'role'            => 'MT::Role',
86            'association'     => 'MT::Association',
87            'permission'      => 'MT::Permission',
88            'fileinfo'        => 'MT::FileInfo',
89            'placement'       => 'MT::Placement',
90            'plugindata'      => 'MT::PluginData',
91            'session'         => 'MT::Session',
92            'trackback'       => 'MT::Trackback',
93            'config'          => 'MT::Config',
94            'objecttag'       => 'MT::ObjectTag',
95            'objectscore'     => 'MT::ObjectScore',
96            'objectasset'     => 'MT::ObjectAsset',
97            'touch'           => 'MT::Touch',
98
99            # TheSchwartz tables
100            'ts_job'        => 'MT::TheSchwartz::Job',
101            'ts_error'      => 'MT::TheSchwartz::Error',
102            'ts_exitstatus' => 'MT::TheSchwartz::ExitStatus',
103            'ts_funcmap'    => 'MT::TheSchwartz::FuncMap',
104        },
105        backup_instructions => \&load_backup_instructions,
106        permissions => {
107            'system.administer' => {
108                label => trans("System Administrator"),
109                group => 'sys_admin',
110                order => 0,
111            },
112            'system.create_blog' => {
113                label => trans("Create Blogs"),
114                group => 'sys_admin',
115                order => 100,
116            },
117            'system.manage_plugins' => {
118                label => trans('Manage Plugins'),
119                group => 'sys_admin',
120                order => 200,
121            },
122            'system.edit_templates' => {
123                label => trans('Manage Templates'),
124                group => 'sys_admin',
125                order => 250,
126            },
127            'system.view_log' => {
128                label => trans("View System Activity Log"),
129                group => 'sys_admin',
130                order => 300,
131            },
132
133            'blog.administer_blog' => {
134                label => trans("Blog Administrator"),
135                group => 'blog_admin',
136                order => 0,
137            },
138            'blog.edit_config' => {
139                label => trans("Configure Blog"),
140                group => 'blog_admin',
141                order => 100,
142            },
143            'blog.set_publish_paths' => {
144                label => trans('Set Publishing Paths'),
145                group => 'blog_admin',
146                order => 200,
147            },
148            'blog.edit_categories' => {
149                label => trans('Manage Categories'),
150                group => 'blog_admin',
151                order => 300,
152            },
153            'blog.edit_tags' => {
154                label => trans('Manage Tags'),
155                group => 'blog_admin',
156                order => 400,
157            },
158            'blog.edit_notifications' => {
159                label => trans('Manage Address Book'),
160                group => 'blog_admin',
161                order => 500,
162            },
163            'blog.view_blog_log' => {
164                label => trans('View Activity Log'),
165                group => 'blog_admin',
166                order => 600,
167            },
168
169            'blog.create_post' => {
170                label => trans('Create Entries'),
171                group => 'auth_pub',
172                order => 100,
173            },
174            'blog.publish_post' => {
175                label => trans('Publish Entries'),
176                group => 'auth_pub',
177                order => 200,
178            },
179            'blog.send_notifications' => {
180                label => trans('Send Notifications'),
181                group => 'auth_pub',
182                order => 300,
183            },
184            'blog.edit_all_posts' => {
185                label => trans('Edit All Entries'),
186                group => 'auth_pub',
187                order => 400,
188            },
189            'blog.manage_pages' => {
190                label => trans('Manage Pages'),
191                group => 'auth_pub',
192                order => 500,
193            },
194            'blog.rebuild' => {
195                label => trans('Publish Blog'),
196                group => 'auth_pub',
197                order => 600,
198            },
199
200            'blog.edit_templates' => {
201                label => trans('Manage Templates'),
202                group => 'blog_design',
203                order => 100,
204            },
205
206            'blog.upload' => {
207                label => trans("Upload File"),
208                group => 'blog_upload',
209                order => 100,
210            },
211            'blog.save_image_defaults' => {
212                label => trans('Save Image Defaults'),
213                group => 'blog_upload',
214                order => 200,
215            },
216            'blog.edit_assets' => {
217                label => trans('Manage Assets'),
218                group => 'blog_upload',
219                order => 300,
220            },
221
222            'blog.comment' => {
223                label => trans("Post Comments"),
224                group => 'blog_comment',
225                order => 100,
226            },
227            'blog.manage_feedback' => {
228                label => trans('Manage Feedback'),
229                group => 'blog_comment',
230                order => 200,
231            },
232        },
233        config_settings => {
234            'AtomApp' => {
235                type    => 'HASH',
236                default => {
237                    weblog => 'MT::AtomServer::Weblog::Legacy',
238                    '1.0'  => 'MT::AtomServer::Weblog',
239                    comments => 'MT::AtomServer::Comments',
240                },
241            },
242            'SchemaVersion'   => undef,
243            'MTVersion'       => undef,
244            'NotifyUpgrade'   => { default => 1 },
245            'Database'        => undef,
246            'DBHost'          => undef,
247            'DBSocket'        => undef,
248            'DBPort'          => undef,
249            'DBUser'          => undef,
250            'DBPassword'      => undef,
251            'DefaultLanguage' => {
252                default => 'en_US',
253            },
254            'LocalPreviews'   => { default => 0 },
255            'DefaultSiteRoot' => { default => '', },
256            'DefaultSiteURL'  => { default => '', },
257            'DefaultCommenterAuth' => { default => 'MovableType,LiveJournal,Vox' },
258            'TemplatePath'    => {
259                default => 'tmpl',
260                path    => 1,
261            },
262            'WeblogTemplatesPath' => {
263                default => 'default_templates',
264                path    => 1,
265            },
266            'AltTemplatePath' => {
267                default => 'alt-tmpl',
268                path    => 1,
269            },
270            'CSSPath'    => { default => 'css', },
271            'ImportPath' => {
272                default => 'import',
273                path    => 1,
274            },
275            'PluginPath' => {
276                default => 'plugins',
277                path    => 1,
278                type    => 'ARRAY',
279            },
280            'EnableArchivePaths' => { default => 0, },
281            'SearchTemplatePath' => {
282                default => 'search_templates',
283                path    => 1,
284            },
285            'ObjectDriver'  => undef,
286            'AllowedTextFilters' => undef,
287            'Serializer'    => { default => 'MT', },
288            'SendMailPath'  => { default => '/usr/lib/sendmail', },
289            'RsyncPath'     => undef,
290            'TimeOffset'    => { default => 0, },
291            'WSSETimeout'   => { default => 120, },
292            'StaticWebPath' => { default => '', },
293            'StaticFilePath' => undef,
294            'CGIPath'       => { default => '/cgi-bin/', },
295            'AdminCGIPath'  => undef,
296            'CookieDomain'  => undef,
297            'CookiePath'    => undef,
298            'MailEncoding'  => {
299                default => 'ISO-8859-1',
300            },
301            'MailTransfer'      => { default => 'sendmail' },
302            'SMTPServer'        => { default => 'localhost', },
303            'DebugEmailAddress' => undef,
304            'WeblogsPingURL' => { default => 'http://rpc.weblogs.com/RPC2', },
305            'BlogsPingURL'   => { default => 'http://ping.blo.gs/', },
306            'MTPingURL' => { default => 'http://www.movabletype.org/update/', },
307            'TechnoratiPingURL' =>
308              { default => 'http://rpc.technorati.com/rpc/ping', },
309            'GooglePingURL' =>
310              { default => 'http://blogsearch.google.com/ping/RPC2', },
311            'CGIMaxUpload'          => { default => 20_480_000 },
312            'DBUmask'               => { default => '0111', },
313            'HTMLUmask'             => { default => '0111', },
314            'UploadUmask'           => { default => '0111', },
315            'DirUmask'              => { default => '0000', },
316            'HTMLPerms'             => { default => '0666', },
317            'UploadPerms'           => { default => '0666', },
318            'NoTempFiles'           => { default => 0, },
319            'TempDir'               => { default => '/tmp', },
320            'RichTextEditor'        => { default => 'archetype', },
321            'EntriesPerRebuild'     => { default => 40, },
322            'UseNFSSafeLocking'     => { default => 0, },
323            'NoLocking'             => { default => 0, },
324            'NoHTMLEntities'        => { default => 1, },
325            'NoCDATA'               => { default => 0, },
326            'NoPlacementCache'      => { default => 0, },
327            'NoPublishMeansDraft'   => { default => 0, },
328            'IgnoreISOTimezones'    => { default => 0, },
329            'PingTimeout'           => { default => 60, },
330            'HTTPTimeout'           => { default => 60 },
331            'PingInterface'         => undef,
332            'HTTPInterface'         => undef,
333            'PingProxy'             => undef,
334            'HTTPProxy'             => undef,
335            'PingNoProxy'           => { default => 'localhost', },
336            'HTTPNoProxy'           => { default => 'localhost', },
337            'ImageDriver'           => { default => 'ImageMagick', },
338            'NetPBMPath'            => undef,
339            'AdminScript'           => { default => 'mt.cgi', },
340            'ActivityFeedScript'    => { default => 'mt-feed.cgi', },
341            'ActivityFeedItemLimit' => { default => 50, },
342            'CommentScript'         => { default => 'mt-comments.cgi', },
343            'TrackbackScript'       => { default => 'mt-tb.cgi', },
344            'SearchScript'          => { default => 'mt-search.cgi', },
345            'XMLRPCScript'          => { default => 'mt-xmlrpc.cgi', },
346            'ViewScript'            => { default => 'mt-view.cgi', },
347            'AtomScript'            => { default => 'mt-atom.cgi', },
348            'UpgradeScript'         => { default => 'mt-upgrade.cgi', },
349            'CheckScript'           => { default => 'mt-check.cgi', },
350            'NotifyScript'          => { default => 'mt-add-notify.cgi', },
351            'PublishCharset'        => {
352                default => 'utf-8',
353            },
354            'SafeMode'           => { default => 1, },
355            'GlobalSanitizeSpec' => {
356                default => 'a href,b,i,br/,p,strong,em,ul,ol,li,blockquote,pre',
357            },
358            'GenerateTrackBackRSS' => { default => 0, },
359
360            ## Search settings, copied from Jay's mt-search and integrated
361            ## into default config.
362            'NoOverride'          => { default => '', },
363            'RegexSearch'         => { default => 0, },
364            'CaseSearch'          => { default => 0, },
365            'ResultDisplay'       => { default => 'descend', },
366            'ExcerptWords'        => { default => 40, },
367            'SearchElement'       => { default => 'entries', },
368            'ExcludeBlogs'        => undef,
369            'IncludeBlogs'        => undef,
370            'DefaultTemplate'     => { default => 'default.tmpl', },
371            'Type'                => { default => 'straight', },
372            'MaxResults'          => { default => '20', },
373            'SearchCutoff'        => { default => '9999999', },
374            'CommentSearchCutoff' => { default => '30', },
375            'AltTemplate'         => {
376                type    => 'ARRAY',
377                default => 'feed results_feed.tmpl',
378            },
379            'SearchSortBy'    => undef,
380            'SearchSortOrder' => { default => 'ascend', },
381            'SearchNoOverride'      => { default => 'SearchMaxResults', },
382            'SearchResultDisplay'   => { alias => 'ResultDisplay', },
383            'SearchExcerptWords'    => { alias => 'ExcerptWords', },
384            'SearchDefaultTemplate' => { alias => 'DefaultTemplate', },
385            'SearchMaxResults'      => { alias => 'MaxResults', },
386            'SearchAltTemplate'     => { alias => 'AltTemplate' },
387            'SearchPrivateTags'     => { default => 0 },
388            'RegKeyURL' =>
389              { default => 'http://www.typekey.com/extras/regkeys.txt', },
390            'IdentitySystem' =>
391              { default => 'http://www.typekey.com/t/typekey', },
392            'SignOnURL' =>
393              { default => 'https://www.typekey.com/t/typekey/login?', },
394            'SignOffURL' =>
395              { default => 'https://www.typekey.com/t/typekey/logout?', },
396            'IdentityURL'     => { default => "http://profile.typekey.com/", },
397            'DynamicComments' => { default => 0, },
398            'SignOnPublicKey' => { default => '', },
399            'ThrottleSeconds' => { default => 20, },
400            'SearchCacheTTL'        => { default => 20, },
401            'SearchThrottleSeconds' => { default => 5 },
402            'SearchThrottleIPWhitelist' => undef,
403            'OneHourMaxPings'           => { default => 10, },
404            'OneDayMaxPings'            => { default => 50, },
405            'SupportURL'                => {
406                default => 'http://www.sixapart.com/movabletype/support/',
407            },
408            'NewsURL' => {
409                default => 'http://www.sixapart.com/movabletype/news/',
410            },
411            'NewsboxURL' => {
412                default => 'http://www.sixapart.com/movabletype/news/mt4_news_widget.html',
413            },
414            # 'MTNewsURL' => {
415            #     default => 'http://www.sixapart.com/movabletype/news/mt4_news_widget.html',
416            # },
417            'LearningNewsURL' => {
418                default => 'http://learning.movabletype.org/newsbox.html',
419            },
420            # 'HackingNewsURL' => {
421            #     default => 'http://hacking.movabletype.org/newsbox.html',
422            # },
423            'EmailAddressMain'      => undef,
424            'EmailReplyTo'          => undef,
425            'EmailNotificationBcc'  => { default => 1, },
426            'CommentSessionTimeout' => { default => 60 * 60 * 24 * 3, },
427            'UserSessionTimeout'    => { default => 60 * 60 * 4, },
428            'UserSessionCookieName' => { handler => \&UserSessionCookieName },
429            'UserSessionCookieDomain' => { default => '<$MTBlogHost exclude_port="1"$>' },
430            'UserSessionCookiePath' => { handler => \&UserSessionCookiePath },
431            'UserSessionCookieTimeout' => { default => 60 * 60 * 4, },
432            'LaunchBackgroundTasks' => { default => 0 },
433            'TypeKeyVersion'        => { default => '1.1' },
434            'TransparentProxyIPs'   => { default => 0, },
435            'DebugMode'             => { default => 0, },
436            'ShowIPInformation'     => { default => 0, },
437            'AllowComments'         => { default => 1, },
438            'AllowPings'            => { default => 1, },
439            'HelpURL'               => undef,
440            #'HelpURL'               => {
441            #    default => 'http://www.sixapart.com/movabletype/docs/4.0/',
442            #},
443            'UsePlugins'               => { default => 1, },
444            'PluginSwitch'             => { type    => 'HASH', },
445            'PluginSchemaVersion'      => { type    => 'HASH', },
446            'OutboundTrackbackLimit'   => { default => 'any', },
447            'OutboundTrackbackDomains' => { type    => 'ARRAY', },
448            'IndexBasename'            => { default => 'index', },
449            'LogExportEncoding'        => {
450                default => 'utf-8',
451            },
452            'ActivityFeedsRunTasks' => { default => 1, },
453            'ExportEncoding'        => {
454                default => 'utf-8',
455            },
456            'SQLSetNames'     => undef,
457            'UseSQLite2'      => { default => 0, },
458            'UseJcodeModule'  => { default => 0, },
459            'DefaultTimezone' => {
460                default => '0',
461            },
462            'CategoryNameNodash' => {
463                default => '0',
464            },
465            'DefaultListPrefs' => {
466                type    => 'HASH',
467            },
468            'DefaultEntryPrefs' => {
469                type    => 'HASH',
470                default => {
471                    type   => 'Default',         # Default|All|Custom
472                    button => 'Below',           # Above|Below|Both
473                    height => 162,               # textarea height
474                },
475            },
476            'DeleteFilesAtRebuild'      => { default => 1, },
477            'RebuildAtDelete'           => { default => 1, },
478            'MaxTagAutoCompletionItems' => { default => 10000, },
479            'NewUserAutoProvisioning' =>
480              { handler => \&NewUserAutoProvisioning, },
481            'NewUserTemplateBlogId'   => undef,
482            'DefaultUserLanguage'     => undef,
483            'DefaultUserTagDelimiter' => {
484                handler => \&DefaultUserTagDelimiter,
485                default => 'comma',
486            },
487            'AuthenticationModule' => { default => 'MT', },
488            'AuthLoginURL'         => undef,
489            'AuthLogoutURL'        => undef,
490            'DefaultAssignments'   => undef,
491            'AutoSaveFrequency'         => { default => 5 },
492            'FuturePostFrequency'       => { default => 1 },
493            'AssetCacheDir'             => { default => 'assets_c', },
494            'IncludesDir'               => { default => 'includes_c', },
495            'MemcachedServers'          => { type    => 'ARRAY', },
496            'MemcachedNamespace'        => undef,
497            'MemcachedDriver'           => { default => 'Cache::Memcached' },
498            'CommenterRegistration'     => {
499                type    => 'HASH',
500                default => {
501                    Allow  => '1',
502                    Notify => q(),
503                },
504            },
505            'CaptchaSourceImageBase'     => undef,
506            'SecretToken'                => { handler => \&SecretToken, },
507            ## NaughtyWordChars settings
508            'NwcSmartReplace' => { default => 0, },
509            'NwcReplaceField' =>
510              { default => 'title,text,text_more,keywords,excerpt,tags', },
511            'DisableNotificationPings'   => { default => 0 },
512            'SyncTarget' => { type => 'ARRAY' },
513            'RsyncOptions' => undef,
514            'UserpicAllowRect' => { default => 0 },
515            'UserpicMaxUpload' => { default => 0 },
516            'UserpicThumbnailSize' => { default => 100 },
517
518            # Basename settings
519            'AuthorBasenameLimit' => { default => 30 },
520            'PerformanceLogging' => { default => 0 },
521            'PerformanceLoggingPath' =>  { handler => \&PerformanceLoggingPath },
522            'PerformanceLoggingThreshold' => { default => 0.1 },
523            'ProcessMemoryCommand' => { handler => \&ProcessMemoryCommand },
524            'EnableAddressBook' => { default => 0 },
525            'SingleCommunity' => { default => 0 },
526        },
527        upgrade_functions => \&load_upgrade_fns,
528        applications      => {
529            'xmlrpc'   => { handler => 'MT::XMLRPCServer', },
530            'atom'     => { handler => 'MT::AtomServer', },
531            'feeds'    => { handler => 'MT::App::ActivityFeeds', },
532            'view'     => { handler => 'MT::App::Viewer', },
533            'notify'   => { handler => 'MT::App::NotifyList', },
534            'tb'       => { handler => 'MT::App::Trackback', },
535            'upgrade'  => { handler => 'MT::App::Upgrade', },
536            'wizard'   => { handler => 'MT::App::Wizard', },
537            'comments' => { handler => 'MT::App::Comments', },
538            'search'   => {
539                handler => 'MT::App::Search::Legacy', 
540                tags => sub { MT->app->load_core_tags },
541            },
542            'new_search'   => {
543                handler => 'MT::App::Search', 
544                tags    => sub { 
545                    require MT::Template::Context::Search;
546                    return MT::Template::Context::Search->load_core_tags();
547                },
548                methods => sub { MT->app->core_methods() },
549                default => sub { MT->app->core_parameters() },
550            },
551            'cms'      => {
552                handler         => 'MT::App::CMS',
553                cgi_base        => 'mt',
554                page_actions    => sub { MT->app->core_page_actions(@_) },
555                list_actions    => sub { MT->app->core_list_actions(@_) },
556                list_filters    => sub { MT->app->core_list_filters(@_) },
557                search_apis     => sub {
558                    require MT::CMS::Search;
559                    return MT::CMS::Search::core_search_apis(MT->app, @_);
560                },
561                menus           => sub { MT->app->core_menus() },
562                methods         => sub { MT->app->core_methods() },
563                widgets         => sub { MT->app->core_widgets() },
564                blog_stats_tabs => sub { MT->app->core_blog_stats_tabs() },
565                import_formats  => sub {
566                    require MT::Import;
567                    return MT::Import->core_import_formats();
568                },
569            },
570        },
571        archive_types => \&load_archive_types,
572        tags          => \&load_core_tags,
573        text_filters  => {
574            '__default__' => {
575                label   => 'Convert Line Breaks',
576                handler => 'MT::Util::html_text_transform',
577            },
578            'richtext' => {
579                label   => 'Rich Text',
580                handler => 'MT::Util::rich_text_transform',
581                condition => sub {
582                    my ($type) = @_;
583                    return 1 if $type && ($type ne 'comment');
584                },
585            },
586        },
587        richtext_editors => {
588            'archetype' => {
589                label => 'Movable Type Default',
590                template => 'archetype_editor.tmpl',
591            },
592        },
593        ping_servers  => {
594            'weblogs' => {
595                label => 'weblogs.com',
596                url   => 'http://rpc.weblogs.com/RPC2',
597            },
598            'technorati' => {
599                label => 'technorati.com',
600                url   => 'http://rpc.technorati.com/rpc/ping',
601            },
602            'google' => {
603                label => 'google.com',
604                url   => 'http://blogsearch.google.com/ping/RPC2',
605            },
606        },
607        commenter_authenticators => \&load_core_commenter_auth,
608        captcha_providers        => \&load_captcha_providers,
609        tasks                    => \&load_core_tasks,
610        default_templates        => \&load_default_templates,
611        template_sets => {
612            mt_blog => {
613                label => "Classic Blog",
614                order => 100,
615                # means, load from 'default_templates' registry
616                # which we've established for core templates with
617                # the MT 4.0 registry
618                templates => '*',
619            },
620        },
621        junk_filters             => \&load_junk_filters,
622        task_workers             => {
623            'mt_rebuild' => {
624                label => "Publishes content.",
625                class => 'MT::Worker::Publish',
626            },
627            'mt_sync' => {
628                label => "Synchronizes content to other server(s).",
629                class => 'MT::Worker::Sync',
630            },
631        },
632        archivers => {
633            'zip' => {
634                class => 'MT::Util::Archive::Zip',
635                label => 'zip',
636            },
637            'tgz' => {
638                class => 'MT::Util::Archive::Tgz',
639                label => 'tar.gz',
640            },
641        },
642        template_snippets        => {
643            'insert_entries' => {
644                trigger => 'entries',
645                label   => 'Entries List',
646                content => qq{<mt:Entries lastn="10">\n    \$0\n</mt:Entries>\n},
647            },
648            'blog_url' => {
649                trigger => 'blogurl',
650                label => 'Blog URL',
651                content => '<$mt:BlogURL$>$0',
652            },
653            'blog_id' => {
654                trigger => 'blogid',
655                label => 'Blog ID',
656                content => '<$mt:BlogID$>$0',
657            },
658            'blog_name' => {
659                trigger => 'blogname',
660                label => 'Blog Name',
661                content => '<$mt:BlogName$>$0',
662            },
663            'entry_body' => {
664                trigger => 'entrybody',
665                label => 'Entry Body',
666                content => '<$mt:EntryBody$>$0',
667            },
668            'entry_excerpt' => {
669                trigger => 'entryexcerpt',
670                label => 'Entry Excerpt',
671                content => '<$mt:EntryExcerpt$>$0',
672            },
673            'entry_link' => {
674                trigger => 'entrylink',
675                label => 'Entry Link',
676                content => '<$mt:EntryLink$>$0',
677            },
678            'entry_more' => {
679                trigger => 'entrymore',
680                label => 'Entry Extended Text',
681                content => '<$mt:EntryMore$>$0',
682            },
683            'entry_title' => {
684                trigger => 'entrytitle',
685                label => 'Entry Title',
686                content => '<$mt:EntryTitle$>$0',
687            },
688            'if' => {
689                trigger => 'mtif',
690                label => 'If Block',
691                content => qq{<mt:if name="variable">\n    \$0\n</mt:if>\n},
692            },
693            'if_else' => {
694                trigger => 'mtife',
695                label => 'If/Else Block',
696                content => qq{<mt:if name="variable">\n    \$0\n<mt:else>\n\n</mt:if>\n},
697            },
698            'include_module' => {
699                trigger => 'module',
700                label => 'Include Template Module',
701                content => '<$mt:Include module="$0"$>',
702            },
703            'include_file' => {
704                trigger => 'file',
705                label => 'Include Template File',
706                content => '<$mt:Include file="$0"$>',
707            },
708            'getvar' => {
709                trigger => 'get',
710                label => 'Get Variable',
711                content => '<$mt:var name="$0"$>',
712            },
713            'setvar' => {
714                trigger => 'set',
715                label => 'Set Variable',
716                content => '<$mt:var name="$0" value="value"$>',
717            },
718            'setvarblock' => {
719                trigger => 'setb',
720                label => 'Set Variable Block',
721                content => qq{<mt:SetVarBlock name="variable">\n    \$0\n</mt:SetVarBlock>\n},
722            },
723            'widget_manager' => {
724                trigger => 'widget',
725                label => 'Widget Set',
726                content => '<$mt:WidgetSet name="$0"$>',
727            },
728        },
729    };
730}
731
732sub id {
733    return 'core';
734}
735
736sub load_junk_filters {
737    require MT::JunkFilter;
738    return MT::JunkFilter->core_filters;
739}
740
741sub load_core_tasks {
742    my $cfg = MT->config;
743    return {
744        'FuturePost' => {
745            label     => 'Publish Scheduled Entries',
746            frequency => $cfg->FuturePostFrequency * 60,    # once per minute
747            code      => sub {
748                MT->instance->publisher->publish_future_posts;
749              }
750        },
751        'JunkExpiration' => {
752            label     => 'Junk Folder Expiration',
753            frequency => 12 * 60 * 60,             # no more than every 12 hours
754            code      => sub {
755                require MT::JunkFilter;
756                MT::JunkFilter->task_expire_junk;
757            },
758        },
759        'CleanTemporaryFiles' => {
760            label => 'Remove Temporary Files',
761            frequency => 60 * 60,   # once per hour
762            code => sub {
763                MT::Core->remove_temporary_files;
764            },
765        },
766        'RemoveExpiredUserSessions' => {
767            label => 'Remove Expired User Sessions',
768            frequency => 60 * 60 * 24,   # once a day
769            code => sub {
770                MT::Core->remove_expired_sessions;
771            },
772        },
773    };
774}
775
776sub remove_temporary_files {
777    require MT::Session;
778
779    my @files = MT::Session->load(
780        { kind => 'TF', start => [ undef, time - 60 * 60 ] },
781        { range => { start => 1 } } );
782    my $fmgr = MT::FileMgr->new('Local');
783    foreach my $f (@files) {
784        if ($fmgr->delete($f->name)) {
785            $f->remove;
786        }
787    }
788    # This is a silent task; no need to log removal of temporary files
789    return '';
790}
791
792sub remove_expired_sessions {
793    require MT::Session;
794
795    my $expired = MT->config->UserSessionTimeout;
796    my @sesss = MT::Session->load(
797        { kind => 'US', start => [ undef, time - $expired ] },
798        { range => { start => 1 } } );
799    foreach my $s (@sesss) {
800        $s->remove if !$s->get('remember');
801    }
802    return '';
803}
804
805sub load_default_templates {
806    require MT::DefaultTemplates;
807    return MT::DefaultTemplates->core_default_templates;
808}
809
810sub load_captcha_providers {
811    return MT->core_captcha_providers;
812}
813
814sub load_core_commenter_auth {
815    return MT->core_commenter_authenticators;
816}
817
818sub load_core_tags {
819    require MT::Template::ContextHandlers;
820    return MT::Template::Context::core_tags();
821}
822
823sub load_upgrade_fns {
824    require MT::Upgrade;
825    return MT::Upgrade->core_upgrade_functions;
826}
827
828sub load_backup_instructions {
829    require MT::BackupRestore;
830    return MT::BackupRestore::core_backup_instructions();
831}
832
833sub l10n_class { 'MT::L10N' }
834
835sub init_registry {
836    my $c = shift;
837    return $c->{registry} = $core_registry;
838}
839
840# Config handlers for these settings...
841
842sub load_archive_types {
843    require MT::WeblogPublisher;
844    return MT::WeblogPublisher->core_archive_types;
845}
846
847sub PerformanceLoggingPath {
848    my $cfg = shift;
849    my ($path, $default);
850    return $cfg->set_internal( 'PerformanceLoggingPath', @_ ) if @_;
851
852    unless ($path = $cfg->get_internal('PerformanceLoggingPath')) {
853        $path = $default = File::Spec->catdir(
854            MT->instance->static_file_path, 'support', 'logs');
855    }
856
857    # If the $path is not a writeable directory, we need to
858    # do some work to see if we can create it
859    if (! (-d $path and -w $path)) {
860        # Determine where MT should put its logging data.  It will be
861        # the first existing and writeable directory found or created
862        # between PerformanceLoggingPath configuration directive value
863        # and the default fallback of MT_DIR/support/logs.  If neither
864        # can be used, we return an undefined value and simply don't
865        # log the performance stats.
866        #
867        # However, we do log any such errors in the activity log to
868        # notify the user that there is a problem.
869
870        my @dirs = ( $path, ( $default && $path ne $default ? ( $default ) : () ) );
871        require File::Spec;   
872        foreach my $dir (@dirs) {
873            my $msg = '';
874            if (-d $dir and -w $dir) {
875                $path = $dir;
876            }
877            elsif (! -e $dir) {
878                require File::Path;
879                eval { File::Path::mkpath([$dir], 0, 0777); $path = $dir; };
880                if ($@) {
881                    $msg = MT->translate('Error creating performance logs directory, [_1]. Please either change the permissions to make it writable or specify an alternate using the PerformanceLoggingPath configuration directive: [_2]', $dir, $@);
882                }
883            }
884            elsif (-e $dir and ! -d $dir) {
885                $msg = MT->translate('Error creating performance logs: PerformanceLoggingPath setting must be a directory path, not a file: [_1]', $dir);
886            }
887            elsif (-e $dir and ! -w $dir) {
888                    $msg = MT->translate('Error creating performance logs: PerformanceLoggingPath directory exists but is not writeable: [_1]', $dir);                 
889            }
890
891            if ($msg) {
892                # Issue MT log within an eval block in the
893                # event that the plugin error is happening before
894                # the database has been initialized...
895                require MT::Log;
896                MT->log({  message => $msg, 
897                            class => 'system',
898                            level => MT::Log::ERROR() });
899            }
900            last if $path;
901        }
902    }
903    return $path;
904}
905
906sub ProcessMemoryCommand {
907    my $cfg = shift;
908    $cfg->set_internal( 'ProcessMemoryCommand', @_ ) if @_;
909    my $cmd = $cfg->get_internal('ProcessMemoryCommand');
910    unless ($cmd) {
911        my $os = $^O;
912        if ($os eq 'darwin') {
913            $cmd = 'ps $$ -o rss=';
914        }
915        elsif ($os eq 'linux') {
916            $cmd = 'ps -p $$ -o rss=';
917        }
918        elsif ($os eq 'MSWin32') {
919            $cmd = { command => q{tasklist /FI "PID eq $$" /FO TABLE /NH},
920                regex => qr/([\d,]+) K/ };
921        }
922    }
923    return $cmd;
924}
925
926sub SecretToken {
927    my $cfg = shift;
928    $cfg->set_internal( 'SecretToken', @_ ) if @_;
929    my $secret = $cfg->get_internal('SecretToken');
930    unless ($secret) {
931        my @alpha = ( 'a' .. 'z', 'A' .. 'Z', 0 .. 9 );
932        $secret = join '', map $alpha[ rand @alpha ], 1 .. 40;
933        $secret = $cfg->set_internal( 'SecretToken', $secret, 1 );
934        $cfg->save_config();
935    }
936    return $secret;
937}
938
939sub DefaultUserTagDelimiter {
940    my $mgr = shift;
941    return $mgr->set_internal( 'DefaultUserTagDelimiter', @_ ) if @_;
942    my $delim = $mgr->get_internal('DefaultUserTagDelimiter');
943    if ( lc $delim eq 'comma' ) {
944        return ord(',');
945    }
946    elsif ( lc $delim eq 'space' ) {
947        return ord(' ');
948    }
949    else {
950        return ord(',');
951    }
952}
953
954sub NewUserAutoProvisioning {
955    my $mgr = shift;
956    return $mgr->set_internal( 'NewUserAutoProvisioning', @_ ) if @_;
957    return 0 unless $mgr->DefaultSiteRoot && $mgr->DefaultSiteURL;
958    $mgr->get_internal('NewUserAutoProvisioning');
959}
960
961sub UserSessionCookieName {
962    my $mgr = shift;
963    return $mgr->set_internal( 'UserSessionCookieName', @_ ) if @_;
964    my $name = $mgr->get_internal('UserSessionCookieName');
965    return $name if defined $name;
966    if ($mgr->get_internal('SingleCommunity')) {
967        return 'mt_blog_user';
968    } else {
969        return 'mt_blog%b_user';
970    }
971}
972
973sub UserSessionCookiePath {
974    my $mgr = shift;
975    return $mgr->set_internal( 'UserSessionCookiePath', @_ ) if @_;
976    my $path = $mgr->get_internal('UserSessionCookiePath');
977    return $path if defined $path;
978    if ($mgr->get_internal('SingleCommunity')) {
979        return '/';
980    } else {
981        return '<$MTBlogRelativeURL$>';
982    }
983}
984
9851;
Note: See TracBrowser for help on using the browser.