3
* $ctrl_mappings: 'blog_settings' || Blog settings -> {{blog}} -> all except widgets
5
* @author {@link http://wonderwinds.com/ Ed Bennett}
6
* @author {@link http://daniel.hahler.de/ Daniel HAHLER}
7
* @author {@link http://fplanque.net/ Francois PLANQUE}
8
* @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
9
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
12
if(!defined('QP_MAIN_INIT')) die('fail');
14
param_action( 'edit' );
15
param( 'tab', 'string', 'general', true );
17
// Check permissions on requested blog and autoselect an appropriate blog if necessary.
18
// This will prevent a fat error when switching tabs and you have restricted perms on blog properties.
19
if( $selected = autoselect_blog( 'blog_properties', 'edit' ) ) // Includes perm check
21
// We have a blog to work on
22
if( set_working_blog( $selected ) ) // set $blog & memorize in user prefs
24
// Selected a new blog
25
$BlogCache = & get_Cache( 'BlogCache' );
26
$Blog = & $BlogCache->get_by_ID( $blog );
29
$edited_Blog = & $Blog;
33
// We could not find a blog we have edit perms on... Note: we may still have
34
// permission to edit categories!!
35
// redirect to blog list
36
header_redirect( '?ctrl=blogs' );
38
$Messages->add( T_('Sorry, you have no permission to edit blog properties.'), 'error' );
43
// Needed when generating static page for example
44
memorize_param( 'blog', 'integer', -1 );
46
if( $tab == 'template' || $tab == 'template_settings' )
48
$TemplateCache = & get_Cache( 'TemplateCache' );
49
$edited_Template = & $TemplateCache->get_by_ID( $Blog->template_ID );
52
if( ( $tab == 'perm' || $tab == 'permgroup' ) && ( empty( $blog ) || ! $Blog->advanced_perms ) )
54
// We're trying to access advanced perms but they're disabled!
55
$tab = 'features'; // the screen where you can enable advanced perms
56
if( $action == 'update' )
58
// make sure we don't update anything here
68
case 'filter2': // Edit blog form (depending on tab)
70
$current_User->check_perm( 'blog_properties', 'edit', true, $blog );
73
case 'update': // Update DB
75
$current_User->check_perm( 'blog_properties', 'edit', true, $blog );
80
if( $edited_Blog->load_from_Request( array() ) )
82
// Commit update to the DB
83
$edited_Blog->dbupdate();
84
$Messages->add( T_('The blog settings have been updated'), 'success' );
89
if( $edited_Blog->load_from_Request( array( 'urls' ) ) )
91
// Commit update to the DB
92
$edited_Blog->dbupdate();
93
$Messages->add( T_('The URL settings have been updated'), 'success' );
98
$old_cache_status = $edited_Blog->get_setting( 'cache_enabled' );
99
if( $edited_Blog->load_from_Request( array( 'features', 'pings', 'cache' ) ) )
101
// Commit update to the DB
102
$new_cache_status = $edited_Blog->get_setting( 'cache_enabled' );
103
$PageCache = new PageCache( $edited_Blog );
104
if( $old_cache_status == false && $new_cache_status == true )
106
// Caching has been turned ON
107
if( $PageCache->cache_create() )
109
$Messages->add( T_('Caching has been enabled for this blog.'), 'success' );
113
$Messages->add( T_('Caching could not be enabled for this blog. Check /cache/ folder file permissions.'), 'error' );
114
$edited_Blog->set_setting( 'cache_enabled', 0 );
117
elseif( $old_cache_status == true && $new_cache_status == false )
119
// Caching has been turned OFF
120
$PageCache->cache_delete();
121
$Messages->add( T_('Caching has been disabled for this blog. All cache contents have been purged.'), 'note' );
124
$edited_Blog->dbupdate();
125
$Messages->add( T_('The blog settings have been updated'), 'success' );
130
if( $edited_Blog->load_from_Request( array() ) )
132
// Commit update to the DB
133
$edited_Blog->dbupdate();
134
$Messages->add( T_('The blog template has been changed.')
135
.' <a href="'.$admin_url.'?ctrl=blog_settings&tab=template&blog='.$edited_Blog->ID.'">'.T_('Edit...').'</a>', 'success' );
136
header_redirect( $edited_Blog->gen_blogurl() );
140
case 'template_settings': // Update params/Settings
141
$edited_Template->load_params_from_Request();
142
if( ! param_errors_detected() )
145
$edited_Template->dbupdate_settings();
146
$Messages->add( T_('Template settings have been updated'), 'success' );
151
case 'plugin_settings': // Update Plugin params/Settings
152
load_funcs( 'plugins/_plugin.funcs.php' );
154
while( $loop_Plugin = & $Plugins->get_next() )
156
$pluginsettings = $loop_Plugin->GetDefaultBlogSettings( $tmp_params = array('for_editing' => true) );
157
if( empty( $pluginsettings ) )
161
// Loop through settings for this plugin
162
foreach( $pluginsettings as $set_name => $set_meta )
164
autoform_set_param_from_request( $set_name, $set_meta, $loop_Plugin, 'BlogSettings', $Blog );
167
if( ! param_errors_detected() )
171
$Messages->add( T_('Plugin settings have been updated'), 'success' );
176
blog_update_perms( $blog, 'user' );
177
$Messages->add( T_('The blog permissions have been updated'), 'success' );
181
blog_update_perms( $blog, 'group' );
182
$Messages->add( T_('The blog permissions have been updated'), 'success' );
189
$AdminUI->set_path( 'blogs', $tab );
191
// Display page header, menus & messages
192
$AdminUI->set_blog_list_params( 'blog_properties', 'edit', array(
193
'ctrl' => 'blog_settings', 'tab' => $tab, 'action' => 'edit' ), T_('List'), '?ctrl=blogs&blog=0' );
194
// Display <html><head>...</head> section (should be done early if actions do not redirect)
195
$AdminUI->disp_html_head();
196
// Display title, menu, messages, etc... (messages MUST be displayed AFTER the actions)
197
$AdminUI->disp_body_top();
198
// Begin payload block
199
$AdminUI->disp_payload_begin();
202
switch( $AdminUI->get_path(1) )
205
$next_action = 'update';
206
$AdminUI->disp_view( 'blogs/views/_blog_general.form.php' );
210
$AdminUI->disp_view( 'blogs/views/_blog_features.form.php' );
214
$AdminUI->disp_view( 'templates/views/_template_settings.form.php' );
215
$AdminUI->disp_view( 'templates/views/_template_select.view.php' );
218
case 'plugin_settings':
219
$AdminUI->disp_view( 'blogs/views/_blog_plugin_settings.form.php' );
223
$AdminUI->disp_view( 'blogs/views/_blog_urls.form.php' );
227
$AdminUI->disp_view( 'blogs/views/_blog_user_perm.form.php' );
231
$AdminUI->disp_view( 'blogs/views/_blog_group_perm.form.php' );
236
$AdminUI->disp_payload_end();
237
// Display body bottom, debug info, close </html>
238
$AdminUI->disp_global_footer();