~quam-plures-core/quam-plures/qp5_colls-blogs_chaps-cats

« back to all changes in this revision

Viewing changes to qp_inc/items/items.ctrl.php

  • Committer: EdB
  • Date: 2013-03-12 06:26:03 UTC
  • Revision ID: 1912webworks@gmail.com-20130312062603-tnlb5zco5mglydqj
lots of changes in this branch. tested and functional, but not going into merge just yet ...

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
2
/**
3
 
 * This file implements the UI controller for managing posts.
4
 
 *
5
 
 * Quam Plures - {@link http://quamplures.net/}
6
 
 * Released under GNU GPL License - {@link http://quamplures.net/license.html}
7
 
 * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
8
 
 * @copyright (c)2003-2009 by Francois PLANQUE - {@link http://fplanque.net/}
9
 
 *
10
 
 * {@internal Open Source relicensing agreement:
11
 
 * }}
12
 
 *
13
 
 * {@internal Below is a list of authors who have contributed to design/coding of this file: }}
14
 
 * @author fplanque: Francois PLANQUE.
15
 
 *
 
3
 * $ctrl_mappings: 'items' || Items -> {{blog}} -> all except Comments
 
4
 *
 
5
 * @author {@link http://wonderwinds.com/ Ed Bennett}
 
6
 * @author {@link http://fplanque.net/ Francois PLANQUE}
 
7
 * @copyright (c) 2009 by {@link http://quamplures.net/ the Quam Plures project}
 
8
 * @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3
16
9
 * @package items
17
10
 */
18
 
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
 
11
if(!defined('QP_MAIN_INIT')) die('fail');
19
12
 
20
 
/**
21
 
 * @var AdminUI
22
 
 */
23
13
global $AdminUI;
24
 
 
25
 
/**
26
 
 * @var UserSettings
27
 
 */
28
 
global $UserSettings;
29
 
 
30
 
/**
31
 
 * @var User
32
 
 */
 
14
global $Blog;
33
15
global $current_User;
34
 
 
35
 
/**
36
 
 * @var Blog
37
 
 */
38
 
global $Blog;
39
 
 
40
16
global $dispatcher;
 
17
global $UserSettings;
41
18
 
42
19
$action = param_action( 'list' );
43
20
 
44
 
$AdminUI->set_path( 'items' );  // Sublevel may be attached below
 
21
$AdminUI->set_path( 'items' ); // Sublevel may be attached below
45
22
 
46
23
if( param( 'store_panel_settings', 'integer' ) )
47
 
{ // store panel and sidebar settings
 
24
{
 
25
        // store panel and sidebar settings
48
26
        param( 'panel_settings', 'string' );
49
27
        $UserSettings->set( 'write_panels', explode( ' ', trim( $panel_settings ) ) );
50
28
        param( 'sidebar_setting', 'string' );
52
30
        $UserSettings->dbupdate();
53
31
}
54
32
 
55
 
/*
56
 
 * Init the objects we want to work on.
57
 
 *
58
 
 * Autoselect a blog where we have PERMISSION to browse (preferably the last used blog):
59
 
 * Note: for some actions, we'll get the blog from the post ID
60
 
 */
 
33
// Init the objects we want to work on
 
34
// Autoselect a blog where we have PERMISSION to browse (preferably the last used blog):
 
35
// Note: for some actions, we'll get the blog from the post ID
61
36
switch( $action )
62
37
{
63
38
        case 'edit_links':
64
 
                param( 'item_ID', 'integer', true, true );
65
 
                $ItemCache = & get_Cache( 'ItemCache' );
66
 
                $edited_Item = & $ItemCache->get_by_ID( $item_ID );
67
 
                // Load the blog we're in:
 
39
        param( 'item_ID', 'integer', true, true );
 
40
        $ItemCache = & get_Cache( 'ItemCache' );
 
41
        $edited_Item = & $ItemCache->get_by_ID( $item_ID );
 
42
        // Load the blog we're in
 
43
        $Blog = & $edited_Item->get_Blog();
 
44
        break;
 
45
 
 
46
        case 'unlink':
 
47
        // Name of the iframe we want some action to come back to
 
48
        param( 'iframe_name', 'string', '', true );
 
49
        param( 'link_ID', 'integer', true );
 
50
        $LinkCache = & get_Cache( 'LinkCache' );
 
51
        if( ( $edited_Link = & $LinkCache->get_by_ID( $link_ID, false ) ) !== false )
 
52
        {
 
53
                // We have a link, get the Item it is attached to
 
54
                $edited_Item = & $edited_Link->Item;
 
55
                // Load the blog we're in
68
56
                $Blog = & $edited_Item->get_Blog();
69
 
                break;
70
 
 
71
 
        case 'unlink':
72
 
                // Name of the iframe we want some action to come back to:
73
 
                param( 'iframe_name', 'string', '', true );
74
 
 
75
 
                param( 'link_ID', 'integer', true );
76
 
                $LinkCache = & get_Cache( 'LinkCache' );
77
 
                if( ($edited_Link = & $LinkCache->get_by_ID( $link_ID, false )) !== false )
78
 
                {       // We have a link, get the Item it is attached to:
79
 
                        $edited_Item = & $edited_Link->Item;
80
 
 
81
 
                        // Load the blog we're in:
 
57
                set_working_blog( $Blog->ID );
 
58
        }
 
59
        else
 
60
        {
 
61
                // We could not find the link to edit
 
62
                $Messages->add( T_('Requested link does not exist any longer.'), 'error' );
 
63
                unset( $edited_Link );
 
64
                unset( $link_ID );
 
65
                if( $mode == 'iframe' )
 
66
                {
 
67
                        $action = 'edit_links';
 
68
                        param( 'item_ID', 'integer', true, true );
 
69
                        $ItemCache = & get_Cache( 'ItemCache' );
 
70
                        $edited_Item = & $ItemCache->get_by_ID( $item_ID );
 
71
                        // Load the blog we're in
82
72
                        $Blog = & $edited_Item->get_Blog();
83
 
                        set_working_blog( $Blog->ID );
84
73
                }
85
74
                else
86
 
                {       // We could not find the link to edit:
87
 
                        $Messages->add( T_('Requested link does not exist any longer.'), 'error' );
88
 
                        unset( $edited_Link );
89
 
                        unset( $link_ID );
90
 
                        if( $mode == 'iframe' )
91
 
                        {
92
 
                                $action = 'edit_links';
93
 
                                param( 'item_ID', 'integer', true, true );
94
 
                                $ItemCache = & get_Cache( 'ItemCache' );
95
 
                                $edited_Item = & $ItemCache->get_by_ID( $item_ID );
96
 
                                // Load the blog we're in:
97
 
                                $Blog = & $edited_Item->get_Blog();
98
 
                        }
99
 
                        else
100
 
                        {
101
 
                                $action = 'nil';
102
 
                        }
 
75
                {
 
76
                        $action = 'nil';
103
77
                }
104
 
                break;
 
78
        }
 
79
        break;
105
80
 
106
81
        case 'edit':
107
82
        case 'history':
108
 
                // Load post to edit:
109
 
                param( 'p', 'integer', true, true );
110
 
                $ItemCache = & get_Cache( 'ItemCache' );
111
 
                $edited_Item = & $ItemCache->get_by_ID( $p );
112
 
 
113
 
                // Load the blog we're in:
114
 
                $Blog = & $edited_Item->get_Blog();
115
 
                set_working_blog( $Blog->ID );
116
 
 
117
 
                // Where are we going to redirect to?
118
 
                param( 'redirect_to', 'string', url_add_param( $admin_url, 'ctrl=items&filter=restore&blog='.$Blog->ID.'&highlight='.$edited_Item->ID, '&' ) );
119
 
                break;
 
83
        // Load post to edit
 
84
        param( 'p', 'integer', true, true );
 
85
        $ItemCache = & get_Cache( 'ItemCache' );
 
86
        $edited_Item = & $ItemCache->get_by_ID( $p );
 
87
        // Load the blog we're in
 
88
        $Blog = & $edited_Item->get_Blog();
 
89
        set_working_blog( $Blog->ID );
 
90
        // Where are we going to redirect to?
 
91
        param( 'redirect_to', 'string', url_add_param( $admin_url, 'ctrl=items&filter=restore&blog='.$Blog->ID.'&highlight='.$edited_Item->ID, '&' ) );
 
92
        break;
120
93
 
121
94
        case 'update_edit':
122
95
        case 'update':
124
97
        case 'publish':
125
98
        case 'deprecate':
126
99
        case 'delete':
127
 
                // Note: we need to *not* use $p in the cases above or it will conflict with the list display
 
100
        // Note: we need to *not* use $p in the cases above or it will conflict with the list display
128
101
        case 'edit_switchtab': // this gets set as action by JS, when we switch tabs
129
 
                // Load post to edit:
130
 
                param( 'post_ID', 'integer', true, true );
131
 
                $ItemCache = & get_Cache( 'ItemCache' );
132
 
                $edited_Item = & $ItemCache->get_by_ID( $post_ID );
133
 
 
134
 
                // Load the blog we're in:
135
 
                $Blog = & $edited_Item->get_Blog();
136
 
                set_working_blog( $Blog->ID );
137
 
 
 
102
        // Load post to edit
 
103
        param( 'post_ID', 'integer', true, true );
 
104
        $ItemCache = & get_Cache( 'ItemCache' );
 
105
        $edited_Item = & $ItemCache->get_by_ID( $post_ID );
 
106
        // Load the blog we're in
 
107
        $Blog = & $edited_Item->get_Blog();
 
108
        set_working_blog( $Blog->ID );
 
109
        // Where are we going to redirect to?
 
110
        param( 'redirect_to', 'string', url_add_param( $admin_url, 'ctrl=items&filter=restore&blog='.$Blog->ID.'&highlight='.$edited_Item->ID, '&' ) );
 
111
        // What form button has been pressed?
 
112
        param( 'save', 'string', '' );
 
113
        $exit_after_save = ( $action != 'update_edit' );
 
114
        break;
 
115
 
 
116
        case 'new':
 
117
        case 'new_switchtab': // this gets set as action by JS, when we switch tabs
 
118
        case 'create_edit':
 
119
        case 'create':
 
120
        case 'create_publish':
 
121
        case 'list':
 
122
        if( $action == 'list' )
 
123
        {
 
124
                // We only need view permission
 
125
                $selected = autoselect_blog( 'blog_ismember', 'view' );
 
126
        }
 
127
        else
 
128
        {
 
129
                // We need posting permission
 
130
                $selected = autoselect_blog( 'blog_post_statuses', 'edit' );
 
131
        }
 
132
        if( ! $selected )
 
133
        {
 
134
                // No blog could be selected
 
135
                $Messages->add( T_('Sorry, you have no permission to post yet.'), 'error' );
 
136
                $action = 'nil';
 
137
        }
 
138
        else
 
139
        {
 
140
                if( set_working_blog( $selected ) ) // set $blog & memorize in user prefs
 
141
                {
 
142
                        // Selected a new blog
 
143
                        $BlogCache = & get_Cache( 'BlogCache' );
 
144
                        $Blog = & $BlogCache->get_by_ID( $blog );
 
145
                }
138
146
                // Where are we going to redirect to?
139
 
                param( 'redirect_to', 'string', url_add_param( $admin_url, 'ctrl=items&filter=restore&blog='.$Blog->ID.'&highlight='.$edited_Item->ID, '&' ) );
140
 
 
141
 
                // What form button has been pressed?
 
147
                param( 'redirect_to', 'string', url_add_param( $admin_url, 'ctrl=items&filter=restore&blog='.$Blog->ID, '&' ) );
 
148
                // What form buttton has been pressed?
142
149
                param( 'save', 'string', '' );
143
 
                $exit_after_save = ( $action != 'update_edit' );
144
 
                break;
145
 
 
146
 
        case 'new':
147
 
        case 'new_switchtab': // this gets set as action by JS, when we switch tabs
148
 
        case 'create_edit':
149
 
        case 'create':
150
 
        case 'create_publish':
151
 
        case 'list':
152
 
                if( $action == 'list' )
153
 
                {       // We only need view permission
154
 
                        $selected = autoselect_blog( 'blog_ismember', 'view' );
155
 
                }
156
 
                else
157
 
                {       // We need posting permission
158
 
                        $selected = autoselect_blog( 'blog_post_statuses', 'edit' );
159
 
                }
160
 
 
161
 
                if( ! $selected  )
162
 
                { // No blog could be selected
163
 
                        $Messages->add( T_('Sorry, you have no permission to post yet.'), 'error' );
164
 
                        $action = 'nil';
165
 
                }
166
 
                else
167
 
                {
168
 
                        if( set_working_blog( $selected ) )     // set $blog & memorize in user prefs
169
 
                        {       // Selected a new blog:
170
 
                                $BlogCache = & get_Cache( 'BlogCache' );
171
 
                                $Blog = & $BlogCache->get_by_ID( $blog );
172
 
                        }
173
 
 
174
 
                        // Where are we going to redirect to?
175
 
                        param( 'redirect_to', 'string', url_add_param( $admin_url, 'ctrl=items&filter=restore&blog='.$Blog->ID, '&' ) );
176
 
 
177
 
                        // What form buttton has been pressed?
178
 
                        param( 'save', 'string', '' );
179
 
                        $exit_after_save = ( $action != 'create_edit' );
180
 
                }
181
 
                break;
 
150
                $exit_after_save = ( $action != 'create_edit' );
 
151
        }
 
152
        break;
182
153
 
183
154
        default:
184
 
                debug_die( 'unhandled action 1:'.htmlspecialchars($action) );
 
155
        debug_die( 'unhandled action 1:'.htmlspecialchars( $action ) );
185
156
}
186
157
 
187
 
 
188
 
/**
189
 
 * Perform action:
190
 
 */
 
158
// Perform action
191
159
switch( $action )
192
160
{
193
 
        case 'nil':
194
 
                // Do nothing
195
 
                break;
 
161
        case 'nil':
 
162
        // Do nothing
 
163
        break;
196
164
 
197
165
        case 'new':
198
 
                $set_issue_date = 'now';
199
 
                $item_issue_date = date_i18n( locale_datefmt(), $localtimenow );
200
 
                $item_issue_time = date( 'H:i:s', $localtimenow );
 
166
        $set_issue_date = 'now';
 
167
        $item_issue_date = date_i18n( locale_datefmt(), $localtimenow );
 
168
        $item_issue_time = date( 'H:i:s', $localtimenow );
201
169
 
202
170
        case 'new_switchtab': // this gets set as action by JS, when we switch tabs
203
 
                // New post form  (can be a bookmarklet form if mode == bookmarklet )
204
 
 
205
 
                load_class('items/model/_item.class.php');
206
 
                $edited_Item = new Item();
207
 
 
208
 
                $edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
209
 
 
210
 
                // We use the request variables to fill the edit form, because we need to be able to pass those values
211
 
                // from tab to tab via javascript when the editor wants to switch views...
212
 
                // Also used by bookmarklet
213
 
                $edited_Item->load_from_Request( true ); // needs Blog set
214
 
 
215
 
                $edited_Item->status = param( 'post_status', 'string', NULL );          // 'published' or 'draft' or ...
216
 
                // We know we can use at least one status,
217
 
                // but we need to make sure the requested/default one is ok:
218
 
                $edited_Item->status = $Blog->get_allowed_item_status( $edited_Item->status );
219
 
 
220
 
 
221
 
                param( 'post_extracats', 'array', array() );
222
 
 
223
 
                $edited_Item->set('main_cat_ID', param( 'post_category', 'integer', $Blog->get_default_cat_ID() ));
224
 
                if( $edited_Item->main_cat_ID && $allow_cross_posting < 3 && $edited_Item->get_blog_ID() != $blog )
225
 
                { // the main cat is not in the list of categories; this happens, if the user switches blogs during editing:
226
 
                        $edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
227
 
                }
228
 
                $post_extracats = param( 'post_extracats', 'array', $post_extracats );
229
 
 
230
 
                param( 'item_tags', 'string', '' );
231
 
 
232
 
                // Trackback addresses (never saved into item)
233
 
                param( 'trackback_url', 'string', '' );
234
 
 
235
 
                // Page title:
236
 
                $AdminUI->title = T_('New post:').' ';
237
 
                if( param( 'item_typ_ID', 'integer', NULL ) !== NULL )
238
 
                {
239
 
                        switch( $item_typ_ID )
240
 
                        {
241
 
                                case 1000:
242
 
                                        $AdminUI->title = T_('New page:').' ';
243
 
                                        break;
244
 
 
245
 
                                case 1600:
246
 
                                        $AdminUI->title = T_('New intro:').' ';
247
 
                                        break;
248
 
 
249
 
                                case 2000:
250
 
                                        $AdminUI->title = T_('New podcast episode:').' ';
251
 
                                        break;
252
 
 
253
 
                                case 3000:
254
 
                                        $AdminUI->title = T_('New link:').' ';
255
 
                                        break;
256
 
                        }
257
 
                }
258
 
 
259
 
                $AdminUI->title_titlearea = $AdminUI->title;
260
 
                $js_doc_title_prefix = $AdminUI->title;
261
 
 
262
 
                // Params we need for tab switching:
 
171
        // New post form (can be a bookmarklet form if mode == bookmarklet )
 
172
        $edited_Item = new Item();
 
173
        $edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
 
174
        // We use the request variables to fill the edit form, because we need to be able to pass those values
 
175
        // from tab to tab via javascript when the editor wants to switch views...
 
176
        // Also used by bookmarklet
 
177
        $edited_Item->load_from_Request( true ); // needs Blog set
 
178
        $edited_Item->status = param( 'post_status', 'string', NULL ); // 'published' or 'draft' or ...
 
179
        // We know we can use at least one status,
 
180
        // but we need to make sure the requested/default one is ok:
 
181
        $edited_Item->status = $Blog->get_allowed_item_status( $edited_Item->status );
 
182
        param( 'post_extracats', 'array', array() );
 
183
        $edited_Item->set('main_cat_ID', param( 'post_category', 'integer', $Blog->get_default_cat_ID() ));
 
184
        if( $edited_Item->main_cat_ID && $allow_cross_posting < 3 && $edited_Item->get_blog_ID() != $blog )
 
185
        {
 
186
                // the main cat is not in the list of categories; this happens, if the user switches blogs during editing
 
187
                $edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
 
188
        }
 
189
        $post_extracats = param( 'post_extracats', 'array', $post_extracats );
 
190
        param( 'item_tags', 'string', '' );
 
191
        // Trackback addresses (never saved into item)
 
192
        param( 'trackback_url', 'string', '' );
 
193
        // Page title
 
194
        $AdminUI->title = T_('New post:').' ';
 
195
        if( param( 'item_typ_ID', 'integer', NULL ) !== NULL )
 
196
        {
 
197
                switch( $item_typ_ID )
 
198
                {
 
199
                        case 1000:
 
200
                        $AdminUI->title = T_('New page:').' ';
 
201
                        break;
 
202
 
 
203
                        case 1500:
 
204
                        case 1520:
 
205
                        case 1530:
 
206
                        case 1570:
 
207
                        $AdminUI->title = T_('New intro:').' ';
 
208
                        break;
 
209
 
 
210
                        case 2000:
 
211
                        $AdminUI->title = T_('New podcast episode:').' ';
 
212
                        break;
 
213
 
 
214
                        case 3000:
 
215
                        $AdminUI->title = T_('New link:').' ';
 
216
                        break;
 
217
                }
 
218
        }
 
219
        $AdminUI->title_titlearea = $AdminUI->title;
 
220
        $js_doc_title_prefix = $AdminUI->title;
 
221
        // Params we need for tab switching
 
222
        $tab_switch_params = 'blog='.$blog;
 
223
        break;
 
224
 
 
225
        case 'edit_switchtab': // this gets set as action by JS, when we switch tabs
 
226
        // This is somewhat in between new and edit...
 
227
        // Check permission based on DB status
 
228
        $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
 
229
        $edited_Item->status = param( 'post_status', 'string', NULL ); // 'published' or 'draft' or ...
 
230
        // We know we can use at least one status,
 
231
        // but we need to make sure the requested/default one is ok
 
232
        $edited_Item->status = $Blog->get_allowed_item_status( $edited_Item->status );
 
233
        // We use the request variables to fill the edit form, because we need to be able to pass those values
 
234
        // from tab to tab via javascript when the editor wants to switch views...
 
235
        $edited_Item->load_from_Request( true ); // needs Blog set
 
236
        param( 'post_extracats', 'array', array() );
 
237
        $edited_Item->set('main_cat_ID', param( 'post_category', 'integer', $edited_Item->main_cat_ID ));
 
238
        if( $edited_Item->main_cat_ID && $allow_cross_posting < 3 && $edited_Item->get_blog_ID() != $blog )
 
239
        {
 
240
                // the main cat is not in the list of categories; this happens, if the user switches blogs during editing
 
241
                $edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
 
242
        }
 
243
        $post_extracats = param( 'post_extracats', 'array', $post_extracats );
 
244
        param( 'item_tags', 'string', '' );
 
245
        // Trackback addresses (never saved into item)
 
246
        param( 'trackback_url', 'string', '' );
 
247
        // Page title
 
248
        $js_doc_title_prefix = T_('Editing post').': ';
 
249
        $AdminUI->title = $js_doc_title_prefix.$edited_Item->dget( 'title', 'htmlhead' );
 
250
        $AdminUI->title_titlearea = sprintf( T_('Editing post #%d: %s'), $edited_Item->ID, $Blog->get( 'name' ) );
 
251
        // Params we need for tab switching
 
252
        $tab_switch_params = 'p='.$edited_Item->ID;
 
253
        break;
 
254
 
 
255
        case 'history':
 
256
        // Check permission
 
257
        $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
 
258
        break;
 
259
 
 
260
        case 'edit':
 
261
        // Check permission
 
262
        $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
 
263
        $post_comment_status = $edited_Item->get( 'comment_status' );
 
264
        $post_extracats = $edited_Item->get_Chapter_IDs();
 
265
        $item_tags = implode( ', ', $edited_Item->get_tags() );
 
266
        $trackback_url = '';
 
267
        $set_issue_date = 'set';
 
268
        // Page title
 
269
        $js_doc_title_prefix = T_('Editing post').': ';
 
270
        $AdminUI->title = $js_doc_title_prefix.$edited_Item->dget( 'title', 'htmlhead' );
 
271
        $AdminUI->title_titlearea = sprintf( T_('Editing post #%d: %s'), $edited_Item->ID, $Blog->get( 'name' ) );
 
272
        // Params we need for tab switching
 
273
        $tab_switch_params = 'p='.$edited_Item->ID;
 
274
        break;
 
275
 
 
276
        case 'create_edit':
 
277
        case 'create':
 
278
        case 'create_publish':
 
279
        // We need early decoding of these in order to check permissions
 
280
        param( 'post_category', 'integer', true );
 
281
        param( 'post_extracats', 'array', array() );
 
282
        param( 'post_status', 'string', 'published' );
 
283
        // Only use "published" if something other than "private" or "protected" has been selected
 
284
        if( $action == 'create_publish' )
 
285
        {
 
286
                if( ! in_array( $post_status, array( 'private', 'protected' ) ) )
 
287
                { 
 
288
                        $post_status = 'published';
 
289
                        $set_issue_date = 'now';
 
290
                }
 
291
                else
 
292
                {
 
293
                        // Tblue> - Perhaps this should be an error (?). Message contents could be confusing.
 
294
                        $Messages->add( sprintf( T_( 'The post has been created but not published because it seems like you wanted to set its status to "%s" instead. If you really want to make it public, manually change its status to "Published" and click the "Save" button.' ),
 
295
                        $post_status == 'protected' ? T_( 'Protected' ) : T_( 'Private' ) ), 'error' );
 
296
                }
 
297
        }
 
298
        // make sure main cat is in extracat list and there are no duplicates
 
299
        $post_extracats[] = $post_category;
 
300
        $post_extracats = array_unique( $post_extracats );
 
301
        // Check permission on statuses
 
302
        $current_User->check_perm( 'cats_post!'.$post_status, 'edit', true, $post_extracats );
 
303
        // CREATE NEW POST
 
304
        $edited_Item = new Item();
 
305
        // Set the params we already got
 
306
        $edited_Item->set( 'status', $post_status );
 
307
        $edited_Item->set( 'main_cat_ID', $post_category );
 
308
        $edited_Item->set( 'extra_cat_IDs', $post_extracats );
 
309
        // Set object params
 
310
        $edited_Item->load_from_Request( /* editing? */ ( $action == 'create_edit' ) );
 
311
        $Plugins->trigger_event( 'AdminBeforeItemEditCreate', array(
 
312
                'Item' => & $edited_Item
 
313
        ) );
 
314
        if( $Messages->count('error') )
 
315
        {
 
316
                // There have been some validation errors
 
317
                // Params we need for tab switching
263
318
                $tab_switch_params = 'blog='.$blog;
264
319
                break;
265
 
 
266
 
 
267
 
        case 'edit_switchtab': // this gets set as action by JS, when we switch tabs
268
 
                // This is somewhat in between new and edit...
269
 
 
270
 
                // Check permission based on DB status:
271
 
                $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
272
 
 
273
 
                $edited_Item->status = param( 'post_status', 'string', NULL );          // 'published' or 'draft' or ...
274
 
                // We know we can use at least one status,
275
 
                // but we need to make sure the requested/default one is ok:
276
 
                $edited_Item->status = $Blog->get_allowed_item_status( $edited_Item->status );
277
 
 
278
 
                // We use the request variables to fill the edit form, because we need to be able to pass those values
279
 
                // from tab to tab via javascript when the editor wants to switch views...
280
 
                $edited_Item->load_from_Request( true ); // needs Blog set
281
 
 
282
 
                param( 'post_extracats', 'array', array() );
283
 
                $edited_Item->set('main_cat_ID', param( 'post_category', 'integer', $edited_Item->main_cat_ID ));
284
 
                if( $edited_Item->main_cat_ID && $allow_cross_posting < 3 && $edited_Item->get_blog_ID() != $blog )
285
 
                { // the main cat is not in the list of categories; this happens, if the user switches blogs during editing:
286
 
                        $edited_Item->set('main_cat_ID', $Blog->get_default_cat_ID());
287
 
                }
288
 
                $post_extracats = param( 'post_extracats', 'array', $post_extracats );
289
 
 
290
 
                param( 'item_tags', 'string', '' );
291
 
 
292
 
                // Trackback addresses (never saved into item)
293
 
                param( 'trackback_url', 'string', '' );
294
 
 
295
 
                // Page title:
296
 
                $js_doc_title_prefix = T_('Editing post').': ';
297
 
                $AdminUI->title = $js_doc_title_prefix.$edited_Item->dget( 'title', 'htmlhead' );
298
 
                $AdminUI->title_titlearea = sprintf( T_('Editing post #%d: %s'), $edited_Item->ID, $Blog->get('name') );
299
 
 
300
 
                // Params we need for tab switching:
301
 
                $tab_switch_params = 'p='.$edited_Item->ID;
302
 
                break;
303
 
 
304
 
        case 'history':
305
 
                // Check permission:
306
 
                $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
307
 
                break;
308
 
 
309
 
        case 'edit':
310
 
                // Check permission:
311
 
                $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
312
 
 
313
 
                $post_comment_status = $edited_Item->get( 'comment_status' );
314
 
                $post_extracats = $edited_Item->get_Chapter_IDs();
315
 
 
316
 
                $item_tags = implode( ', ', $edited_Item->get_tags() );
317
 
                $trackback_url = '';
318
 
 
319
 
                $set_issue_date = 'set';
320
 
 
321
 
                // Page title:
322
 
                $js_doc_title_prefix = T_('Editing post').': ';
323
 
                $AdminUI->title = $js_doc_title_prefix.$edited_Item->dget( 'title', 'htmlhead' );
324
 
                $AdminUI->title_titlearea = sprintf( T_('Editing post #%d: %s'), $edited_Item->ID, $Blog->get('name') );
325
 
 
326
 
                // Params we need for tab switching:
327
 
                $tab_switch_params = 'p='.$edited_Item->ID;
328
 
                break;
329
 
 
330
 
 
331
 
        case 'create_edit':
332
 
        case 'create':
333
 
        case 'create_publish':
334
 
                // We need early decoding of these in order to check permissions:
335
 
                param( 'post_category', 'integer', true );
336
 
                param( 'post_extracats', 'array', array() );
337
 
                param( 'post_status', 'string', 'published' );
338
 
 
339
 
                if( $action == 'create_publish' )
340
 
                {
341
 
                        if( ! in_array( $post_status, array( 'private', 'protected' ) ) )
342
 
                        {       /* Only use "published" if something other than "private"
343
 
                                   or "protected" has been selected: */
344
 
                                $post_status = 'published';
345
 
                                $set_issue_date = 'now';
346
 
                        }
347
 
                        else
348
 
                        {
349
 
                                // Tblue> - Perhaps this should be an error (?).
350
 
                                //        - Message contents could be confusing.
351
 
                                $Messages->add( sprintf( T_( 'The post has been created but not published because it seems like you wanted to set its status to "%s" instead.  If you really want to make it public, manually change its status to "Published" and click the "Save" button.' ),
352
 
                                        $post_status == 'protected' ? T_( 'Protected' ) : T_( 'Private' ) ), 'error' );
353
 
                        }
354
 
 
355
 
                }
356
 
 
357
 
                // make sure main cat is in extracat list and there are no duplicates
358
 
                $post_extracats[] = $post_category;
359
 
                $post_extracats = array_unique( $post_extracats );
360
 
                // Check permission on statuses:
361
 
                $current_User->check_perm( 'cats_post!'.$post_status, 'edit', true, $post_extracats );
362
 
 
363
 
 
364
 
                // CREATE NEW POST:
365
 
                load_class('items/model/_item.class.php');
366
 
                $edited_Item = new Item();
367
 
 
368
 
                // Set the params we already got:
369
 
                $edited_Item->set( 'status', $post_status );
370
 
                $edited_Item->set( 'main_cat_ID', $post_category );
371
 
                $edited_Item->set( 'extra_cat_IDs', $post_extracats );
372
 
 
373
 
                // Set object params:
374
 
                $edited_Item->load_from_Request( /* editing? */ ($action == 'create_edit') );
375
 
 
376
 
                $Plugins->trigger_event( 'AdminBeforeItemEditCreate', array( 'Item' => & $edited_Item ) );
377
 
 
378
 
                if( $Messages->count('error') )
379
 
                {       // There have been some validation errors:
380
 
                        // Params we need for tab switching:
381
 
                        $tab_switch_params = 'blog='.$blog;
382
 
                        break;
383
 
                }
384
 
 
385
 
                // INSERT NEW POST INTO DB:
386
 
                $edited_Item->dbinsert();
387
 
 
388
 
                // post post-publishing operations:
389
 
                param( 'trackback_url', 'string' );
390
 
                if( !empty( $trackback_url ) )
391
 
                {
392
 
                        if( $edited_Item->status != 'published' )
393
 
                        {
394
 
                                $Messages->add( T_('Post not publicly published: skipping trackback...'), 'info' );
395
 
                        }
396
 
                        else
397
 
                        { // trackback now:
398
 
                                load_funcs('comments/_trackback.funcs.php');
399
 
                                trackbacks( $trackback_url, $edited_Item->content, $edited_Item->title, $edited_Item->ID);
400
 
                        }
401
 
                }
402
 
 
403
 
                // Execute or schedule notifications & pings:
404
 
                $edited_Item->handle_post_processing( $exit_after_save );
405
 
 
406
 
                $Messages->add( T_('Post has been created.'), 'success' );
407
 
 
408
 
                if( ! $exit_after_save )
409
 
                {       // We want to continue editing...
410
 
                        $tab_switch_params = 'p='.$edited_Item->ID;
411
 
                        $action = 'edit';       // It's basically as if we had updated
412
 
                        break;
413
 
                }
414
 
 
415
 
                if( $edited_Item->status == 'published' )
416
 
                {       // fp> I noticed that after publishing a new post, I always want to see how the blog looks like
417
 
                  // If anyone doesn't want that, we can make this optional...
418
 
                        $edited_Item->load_Blog();
419
 
                  $redirect_to = $edited_Item->Blog->gen_blogurl();
420
 
                }
421
 
 
422
 
                // REDIRECT / EXIT
423
 
                header_redirect( $redirect_to );
424
 
                // Switch to list mode:
425
 
                // $action = 'list';
426
 
                //init_list_mode();
427
 
                break;
428
 
 
 
320
        }
 
321
        // INSERT NEW POST INTO DB
 
322
        $edited_Item->dbinsert();
 
323
        // post post-publishing operations
 
324
        param( 'trackback_url', 'string' );
 
325
        if( ! empty( $trackback_url ) )
 
326
        {
 
327
                if( $edited_Item->status != 'published' )
 
328
                {
 
329
                        $Messages->add( T_('Post not publicly published: skipping trackback...'), 'info' );
 
330
                }
 
331
                else
 
332
                {
 
333
                        // trackback now
 
334
                        load_funcs( 'comments/_trackback.funcs.php' );
 
335
                        trackbacks( $trackback_url, $edited_Item->content, $edited_Item->title, $edited_Item->ID);
 
336
                }
 
337
        }
 
338
        // Execute or schedule notifications & pings
 
339
        $edited_Item->handle_post_processing( $exit_after_save );
 
340
        $Messages->add( T_('Post has been created.'), 'success' );
 
341
        if( ! $exit_after_save )
 
342
        {
 
343
                // We want to continue editing...
 
344
                $tab_switch_params = 'p='.$edited_Item->ID;
 
345
                $action = 'edit'; // It's basically as if we had updated
 
346
                break;
 
347
        }
 
348
        if( $edited_Item->status == 'published' )
 
349
        {
 
350
                // fp> I noticed that after publishing a new post, I always want to see how the
 
351
                // blog looks like. If anyone doesn't want that, we can make this optional...
 
352
                $edited_Item->load_Blog();
 
353
                $redirect_to = $edited_Item->Blog->gen_blogurl();
 
354
        }
 
355
 
 
356
        // REDIRECT / EXIT
 
357
        header_redirect( $redirect_to );
 
358
        // Switch to list mode
 
359
        // $action = 'list';
 
360
        // init_list_mode();
 
361
        break;
429
362
 
430
363
        case 'update_edit':
431
364
        case 'update':
432
365
        case 'update_publish':
433
 
                // Check edit permission:
434
 
                $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
435
 
 
436
 
                // We need early decoding of these in order to check permissions:
437
 
                param( 'post_category', 'integer', true );
438
 
                param( 'post_extracats', 'array', array() );
439
 
                param( 'post_status', 'string', 'published' );
440
 
 
441
 
                if( $action == 'update_publish' )
442
 
                {
443
 
                        if( ! in_array( $post_status, array( 'private', 'protected' ) ) )
444
 
                        {       /* Only use "published" if something other than "private"
445
 
                                   or "protected" has been selected: */
446
 
                                $post_status = 'published';
447
 
                                $set_issue_date = 'now';
448
 
                        }
449
 
                        else
450
 
                        {
451
 
                                // Tblue> - Perhaps this should be an error (?).
452
 
                                //        - Message contents could be confusing.
453
 
                                $Messages->add( sprintf( T_( 'The post has been updated but not published because it seems like you wanted to set its status to "%s" instead. If you really want to make it public, manually change its status to "Published" and click the "Save" button.' ),
454
 
                                                                        $post_status == 'protected' ? T_( 'Protected' ) : T_( 'Private' ) ), 'error' );
455
 
                        }
456
 
 
457
 
                }
458
 
 
459
 
                // make sure main cat is in extracat list and there are no duplicates
460
 
                $post_extracats[] = $post_category;
461
 
                $post_extracats = array_unique( $post_extracats );
462
 
                // Check permission on statuses:
463
 
                $current_User->check_perm( 'cats_post!'.$post_status, 'edit', true, $post_extracats );
464
 
 
465
 
                // Is this post already published?
466
 
                $was_published = $edited_Item->status == 'published';
467
 
 
468
 
                // Load tags and extra categories to allow the system to check
469
 
                // whether they have been changed. While this could look like
470
 
                // "yet another unnecessary SQL query", it prevents deleting all
471
 
                // the tags/categories just to insert the same all over data again.
472
 
                $edited_Item->get_tags();
473
 
                $edited_Item->get_Chapter_IDs();
474
 
 
475
 
                // UPDATE POST:
476
 
                // Set the params we already got:
477
 
                $edited_Item->set( 'status', $post_status );
478
 
                $edited_Item->set( 'main_cat_ID', $post_category );
479
 
                $edited_Item->set( 'extra_cat_IDs', $post_extracats );
480
 
 
481
 
                // Set object params:
482
 
                $edited_Item->load_from_Request( false );
483
 
 
484
 
                $Plugins->trigger_event( 'AdminBeforeItemEditUpdate', array( 'Item' => & $edited_Item ) );
485
 
 
486
 
                // Params we need for tab switching (in case of error or if we save&edit)
487
 
                $tab_switch_params = 'p='.$edited_Item->ID;
488
 
 
489
 
                if( $Messages->count('error') )
490
 
                {       // There have been some validation errors:
491
 
                        break;
492
 
                }
493
 
 
494
 
                // UPDATE POST IN DB:
495
 
                $edited_Item->dbupdate();
496
 
 
497
 
                // post post-publishing operations:
498
 
                param( 'trackback_url', 'string' );
499
 
                if( !empty( $trackback_url ) )
500
 
                {
501
 
                        if( $edited_Item->status != 'published' )
502
 
                        {
503
 
                                $Messages->add( T_('Post not publicly published: skipping trackback...'), 'info' );
504
 
                        }
505
 
                        else
506
 
                        { // trackback now:
507
 
                                load_funcs('comments/_trackback.funcs.php');
508
 
                                trackbacks( $trackback_url, $edited_Item->content, $edited_Item->title, $edited_Item->ID );
509
 
                        }
510
 
                }
511
 
 
512
 
                // Execute or schedule notifications & pings:
513
 
                $edited_Item->handle_post_processing( $exit_after_save );
514
 
 
515
 
                $Messages->add( T_('Post has been updated.'), 'success' );
516
 
 
517
 
                if( ! $exit_after_save )
518
 
                {       // We want to continue editing...
519
 
                        break;
520
 
                }
521
 
 
522
 
                /* fp> I noticed that after publishing a new post, I always want
523
 
                 *     to see how the blog looks like. If anyone doesn't want that,
524
 
                 *     we can make this optional...
525
 
                 */
526
 
                if( ! $was_published && $edited_Item->status == 'published' )
527
 
                {       /* The post's last status wasn't "published", but we're going
528
 
                           to publish it now. Redirect to the blog: */
529
 
                        $edited_Item->load_Blog();
530
 
                        $redirect_to = $edited_Item->Blog->gen_blogurl();
531
 
                }
532
 
 
533
 
                // REDIRECT / EXIT
534
 
                header_redirect( $redirect_to );
535
 
                // Switch to list mode:
536
 
                // $action = 'list';
537
 
                // init_list_mode();
538
 
                break;
539
 
 
 
366
        // Check edit permission
 
367
        $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
 
368
 
 
369
        // We need early decoding of these in order to check permissions
 
370
        param( 'post_category', 'integer', true );
 
371
        param( 'post_extracats', 'array', array() );
 
372
        param( 'post_status', 'string', 'published' );
 
373
 
 
374
        if( $action == 'update_publish' )
 
375
        {
 
376
                // Only use "published" if something other than "private" or "protected" has been selected
 
377
                if( ! in_array( $post_status, array( 'private', 'protected' ) ) )
 
378
                {
 
379
                        $post_status = 'published';
 
380
                        $set_issue_date = 'now';
 
381
                }
 
382
                else
 
383
                {
 
384
                        // Tblue> - Perhaps this should be an error (?). Message contents could be confusing.
 
385
                        $Messages->add( sprintf( T_( 'The post has been updated but not published because it seems like you wanted to set its status to "%s" instead. If you really want to make it public, manually change its status to "Published" and click the "Save" button.' ),
 
386
                        $post_status == 'protected' ? T_( 'Protected' ) : T_( 'Private' ) ), 'error' );
 
387
                }
 
388
        }
 
389
 
 
390
        // make sure main cat is in extracat list and there are no duplicates
 
391
        $post_extracats[] = $post_category;
 
392
        $post_extracats = array_unique( $post_extracats );
 
393
        // Check permission on statuses
 
394
        $current_User->check_perm( 'cats_post!'.$post_status, 'edit', true, $post_extracats );
 
395
 
 
396
        // Is this post already published?
 
397
        $was_published = $edited_Item->status == 'published';
 
398
 
 
399
        // Load tags and extra categories to allow the system to check
 
400
        // whether they have been changed. While this could look like
 
401
        // "yet another unnecessary SQL query", it prevents deleting all
 
402
        // the tags/categories just to insert the same all over data again.
 
403
        $edited_Item->get_tags();
 
404
        $edited_Item->get_Chapter_IDs();
 
405
 
 
406
        // UPDATE POST
 
407
        // Set the params we already got
 
408
        $edited_Item->set( 'status', $post_status );
 
409
        $edited_Item->set( 'main_cat_ID', $post_category );
 
410
        $edited_Item->set( 'extra_cat_IDs', $post_extracats );
 
411
        // Set object params
 
412
        $edited_Item->load_from_Request( false );
 
413
 
 
414
        $Plugins->trigger_event( 'AdminBeforeItemEditUpdate', array(
 
415
                'Item' => & $edited_Item
 
416
        ) );
 
417
 
 
418
        // Params we need for tab switching (in case of error or if we save&edit)
 
419
        $tab_switch_params = 'p='.$edited_Item->ID;
 
420
 
 
421
        if( $Messages->count('error') )
 
422
        {
 
423
                // There have been some validation errors
 
424
                break;
 
425
        }
 
426
 
 
427
        // UPDATE POST IN DB
 
428
        $edited_Item->dbupdate();
 
429
 
 
430
        // post post-publishing operations
 
431
        param( 'trackback_url', 'string' );
 
432
        if( ! empty( $trackback_url ) )
 
433
        {
 
434
                if( $edited_Item->status != 'published' )
 
435
                {
 
436
                        $Messages->add( T_('Post not publicly published: skipping trackback...'), 'info' );
 
437
                }
 
438
                else
 
439
                {
 
440
                        // trackback now
 
441
                        load_funcs( 'comments/_trackback.funcs.php' );
 
442
                        trackbacks( $trackback_url, $edited_Item->content, $edited_Item->title, $edited_Item->ID );
 
443
                }
 
444
        }
 
445
 
 
446
        // Execute or schedule notifications & pings
 
447
        $edited_Item->handle_post_processing( $exit_after_save );
 
448
        $Messages->add( T_('Post has been updated.'), 'success' );
 
449
 
 
450
        if( ! $exit_after_save )
 
451
        {
 
452
                // We want to continue editing...
 
453
                break;
 
454
        }
 
455
 
 
456
        // fp> I noticed that after publishing a new post, I always want to see how the
 
457
        // blog looks like. If anyone doesn't want that, we can make this optional...
 
458
        // The post's last status wasn't "published", but we're going to publish it now. Redirect to the blog
 
459
        if( ! $was_published && $edited_Item->status == 'published' )
 
460
        {
 
461
                $edited_Item->load_Blog();
 
462
                $redirect_to = $edited_Item->Blog->gen_blogurl();
 
463
        }
 
464
 
 
465
        // REDIRECT / EXIT
 
466
        header_redirect( $redirect_to );
 
467
        // Switch to list mode
 
468
        // $action = 'list';
 
469
        // init_list_mode();
 
470
        break;
540
471
 
541
472
        case 'publish':
542
 
                // Publish NOW:
543
 
 
544
 
                $post_status = 'published';
545
 
                // Check permissions:
546
 
                /* TODO: Check extra categories!!! */
547
 
                $current_User->check_perm( 'item_post!'.$post_status, 'edit', true, $edited_Item );
548
 
                $current_User->check_perm( 'edit_timestamp', 'any', true ) ;
549
 
 
550
 
                $edited_Item->set( 'status', $post_status );
551
 
 
552
 
                $post_date = date('Y-m-d H:i:s', $localtimenow);
553
 
                $edited_Item->set( 'datestart', $post_date );
554
 
                $edited_Item->set( 'datemodified', $post_date );
555
 
 
556
 
                // UPDATE POST IN DB:
557
 
                $edited_Item->dbupdate();
558
 
 
559
 
                // Execute or schedule notifications & pings:
560
 
                $edited_Item->handle_post_processing();
561
 
 
562
 
                $Messages->add( T_('Post has been published.'), 'success' );
563
 
 
564
 
                // fp> I noticed that after publishing a new post, I always want to see how the blog looks like
565
 
                // If anyone doesn't want that, we can make this optional...
566
 
                $edited_Item->load_Blog();
567
 
                $redirect_to = $edited_Item->Blog->gen_blogurl();
568
 
 
569
 
                // REDIRECT / EXIT
570
 
                header_redirect( $redirect_to );
571
 
                // Switch to list mode:
572
 
                // $action = 'list';
573
 
                // init_list_mode();
574
 
                break;
575
 
 
 
473
        // Publish NOW
 
474
        $post_status = 'published';
 
475
        // Check permissions
 
476
        // @todo (0000) Check extra categories!!!
 
477
        $current_User->check_perm( 'item_post!'.$post_status, 'edit', true, $edited_Item );
 
478
        $current_User->check_perm( 'edit_timestamp', 'any', true ) ;
 
479
        $edited_Item->set( 'status', $post_status );
 
480
        $post_date = date( 'Y-m-d H:i:s', $localtimenow );
 
481
        $edited_Item->set( 'datestart', $post_date );
 
482
        $edited_Item->set( 'datemodified', $post_date );
 
483
 
 
484
        // UPDATE POST IN DB
 
485
        $edited_Item->dbupdate();
 
486
 
 
487
        // Execute or schedule notifications & pings
 
488
        $edited_Item->handle_post_processing();
 
489
        $Messages->add( T_('Post has been published.'), 'success' );
 
490
 
 
491
        // fp> I noticed that after publishing a new post, I always want to see how the
 
492
        // blog looks like. If anyone doesn't want that, we can make this optional...
 
493
        $edited_Item->load_Blog();
 
494
        $redirect_to = $edited_Item->Blog->gen_blogurl();
 
495
 
 
496
        // REDIRECT / EXIT
 
497
        header_redirect( $redirect_to );
 
498
        // Switch to list mode
 
499
        // $action = 'list';
 
500
        // init_list_mode();
 
501
        break;
576
502
 
577
503
        case 'deprecate':
578
 
 
579
 
                $post_status = 'deprecated';
580
 
                // Check permissions:
581
 
                /* TODO: Check extra categories!!! */
582
 
                $current_User->check_perm( 'item_post!'.$post_status, 'edit', true, $edited_Item );
583
 
 
584
 
                $edited_Item->set( 'status', $post_status );
585
 
                $edited_Item->set( 'datemodified', date('Y-m-d H:i:s',$localtimenow) );
586
 
 
587
 
                // UPDATE POST IN DB:
588
 
                $edited_Item->dbupdate();
589
 
 
590
 
                $Messages->add( T_('Post has been deprecated.'), 'success' );
591
 
 
592
 
                // REDIRECT / EXIT
593
 
                header_redirect( $redirect_to );
594
 
                // Switch to list mode:
595
 
                // $action = 'list';
596
 
                // init_list_mode();
597
 
                break;
598
 
 
 
504
        $post_status = 'deprecated';
 
505
        // Check permissions
 
506
        /* @todo (0000) Check extra categories!!! */
 
507
        $current_User->check_perm( 'item_post!'.$post_status, 'edit', true, $edited_Item );
 
508
        $edited_Item->set( 'status', $post_status );
 
509
        $edited_Item->set( 'datemodified', date( 'Y-m-d H:i:s', $localtimenow ) );
 
510
 
 
511
        // UPDATE POST IN DB
 
512
        $edited_Item->dbupdate();
 
513
        $Messages->add( T_('Post has been deprecated.'), 'success' );
 
514
 
 
515
        // REDIRECT / EXIT
 
516
        header_redirect( $redirect_to );
 
517
        // Switch to list mode
 
518
        // $action = 'list';
 
519
        // init_list_mode();
 
520
        break;
599
521
 
600
522
        case 'delete':
601
 
                // Delete an Item:
602
 
 
603
 
                // Check permission:
604
 
                $current_User->check_perm( 'blog_del_post', '', true, $blog );
605
 
 
606
 
                // fp> TODO: non javascript confirmation
607
 
                // $AdminUI->title = T_('Deleting post...');
608
 
 
609
 
                $Plugins->trigger_event( 'AdminBeforeItemEditDelete', array( 'Item' => & $edited_Item ) );
610
 
 
611
 
                if( ! $Messages->count('error') )
612
 
                {       // There have been no validation errors:
613
 
                        // DELETE POST FROM DB:
614
 
                        $edited_Item->dbdelete();
615
 
 
616
 
                        $Messages->add( T_('Post has been deleted.'), 'success' );
617
 
                }
618
 
 
619
 
                // REDIRECT / EXIT
620
 
                header_redirect( $redirect_to );
621
 
                // Switch to list mode:
622
 
                // $action = 'list';
623
 
                // init_list_mode();
624
 
                break;
625
 
 
 
523
        // Delete an Item
 
524
        // Check permission
 
525
        $current_User->check_perm( 'blog_del_post', '', true, $blog );
 
526
 
 
527
        // fp> TODO: non javascript confirmation
 
528
        // $AdminUI->title = T_('Deleting post...');
 
529
 
 
530
        $Plugins->trigger_event( 'AdminBeforeItemEditDelete',
 
531
                array( 'Item' => & $edited_Item,
 
532
        ) );
 
533
 
 
534
        if( ! $Messages->count('error') )
 
535
        {
 
536
                // There have been no validation errors
 
537
                // DELETE POST FROM DB
 
538
                $edited_Item->dbdelete();
 
539
                $Messages->add( T_('Post has been deleted.'), 'success' );
 
540
        }
 
541
 
 
542
        // REDIRECT / EXIT
 
543
        header_redirect( $redirect_to );
 
544
        // Switch to list mode
 
545
        // $action = 'list';
 
546
        // init_list_mode();
 
547
        break;
626
548
 
627
549
        case 'list':
628
 
                init_list_mode();
629
 
 
630
 
                if( $ItemList->single_post )
631
 
                {       // We have requested to view a SINGLE specific post:
632
 
                        $action = 'view';
633
 
                }
634
 
                break;
635
 
 
 
550
        init_list_mode();
 
551
        if( $ItemList->single_post )
 
552
        {
 
553
                // We have requested to view a SINGLE specific post
 
554
                $action = 'view';
 
555
        }
 
556
        break;
636
557
 
637
558
        case 'edit_links':
638
 
                // Display attachment list
639
 
 
640
 
                // Check permission:
641
 
                $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
642
 
                break;
643
 
 
 
559
        // Display attachment list
 
560
        // Check permission
 
561
        $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
 
562
        break;
644
563
 
645
564
        case 'unlink':
646
 
                // Delete a link:
647
 
 
648
 
                // Check permission:
649
 
                $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
650
 
 
651
 
                // Unlink File from Item:
652
 
                $msg = sprintf( T_('Link has been deleted from &laquo;%s&raquo;.'), $edited_Link->Item->dget('title') );
653
 
                $edited_Link->dbdelete( true );
654
 
                unset($edited_Link);
655
 
                $Messages->add( $msg, 'success' );
656
 
 
657
 
                // go on to view:
658
 
                //$p = $edited_Item->ID;
659
 
                //init_list_mode();
660
 
                //$action = 'view';
661
 
                // REDIRECT / EXIT
662
 
                if( $mode == 'iframe' )
663
 
                {
664
 
                        header_redirect( regenerate_url( '', 'action=edit_links&mode=iframe&item_ID='.$edited_Item->ID, '', '&' ) );
665
 
                }
666
 
                else
667
 
                {
668
 
                        header_redirect( regenerate_url( '', 'p='.$edited_Item->ID, '', '&' ) );
669
 
                }
670
 
                break;
671
 
 
 
565
        // Delete a link
 
566
        // Check permission
 
567
        $current_User->check_perm( 'item_post!CURSTATUS', 'edit', true, $edited_Item );
 
568
 
 
569
        // Unlink File from Item
 
570
        $msg = sprintf( T_('Link has been deleted from &laquo;%s&raquo;.'), $edited_Link->Item->dget('title') );
 
571
        $edited_Link->dbdelete( true );
 
572
        unset( $edited_Link );
 
573
        $Messages->add( $msg, 'success' );
 
574
 
 
575
        // go on to view
 
576
        // $p = $edited_Item->ID;
 
577
        // init_list_mode();
 
578
        // $action = 'view';
 
579
 
 
580
        // REDIRECT / EXIT
 
581
        if( $mode == 'iframe' )
 
582
        {
 
583
                header_redirect( regenerate_url( '', 'action=edit_links&mode=iframe&item_ID='.$edited_Item->ID, '', '&' ) );
 
584
        }
 
585
        else
 
586
        {
 
587
                header_redirect( regenerate_url( '', 'p='.$edited_Item->ID, '', '&' ) );
 
588
        }
 
589
        break;
672
590
 
673
591
        default:
674
 
                debug_die( 'unhandled action 2' );
 
592
        debug_die( 'unhandled action 2' );
675
593
}
676
594
 
677
595
/**
679
597
 */
680
598
function init_list_mode()
681
599
{
682
 
        global $tab, $Blog, $UserSettings, $ItemList;
 
600
        global $Blog;
 
601
        global $ItemList;
 
602
        global $tab;
 
603
        global $UserSettings;
683
604
 
684
 
        if ( param( 'p', 'integer', NULL ) || param( 'title', 'string', NULL ) )
685
 
        {       // Single post requested, do not filter any post types. If the user
 
605
        if( param( 'p', 'integer', NULL ) || param( 'title', 'string', NULL ) )
 
606
        {
 
607
                // Single post requested, do not filter any post types. If the user
686
608
                // has clicked a post link on the dashboard and previously has selected
687
609
                // a tab which would filter this post, it wouldn't be displayed now.
688
610
                $tab = 'full';
689
611
        }
690
612
        else
691
 
        {       // Store/retrieve preferred tab from UserSettings:
 
613
        {
 
614
                // Store/retrieve preferred tab from UserSettings
692
615
                $UserSettings->param_Request( 'tab', 'pref_browse_tab', 'string', NULL, true /* memorize */, true /* force */ );
693
616
        }
694
617
 
695
 
        /*
696
 
         * Init list of posts to display:
697
 
         */
698
 
        load_class('items/model/_itemlist.class.php');
699
 
 
700
 
        // Create empty List:
 
618
        // Init list of posts to display
 
619
        // Create empty List
701
620
        $ItemList = new ItemList2( $Blog, NULL, NULL, $UserSettings->get('results_per_page'), 'ItemCache', '', $tab /* filterset name */ ); // COPY (func)
702
621
 
703
622
        $ItemList->set_default_filters( array(
704
 
                        'visibility_array' => array( 'published', 'protected', 'private', 'draft', 'deprecated', 'redirected' ),
705
 
                ) );
 
623
                'visibility_array' => array( 'published', 'protected', 'private', 'draft', 'deprecated', 'redirected' ),
 
624
        ) );
706
625
 
707
626
        switch( $tab )
708
627
        {
709
628
                case 'full':
710
 
                        $ItemList->set_default_filters( array(
711
 
                                        'types' => NULL, // All types (suited for tab with full posts)
712
 
                                ) );
713
 
                        break;
 
629
                $ItemList->set_default_filters( array(
 
630
                        'types' => NULL, // All types (suited for tab with full posts)
 
631
                ) );
 
632
                break;
714
633
 
715
634
                case 'list':
716
 
                        // Nothing special
717
 
                        break;
 
635
                // Nothing special
 
636
                break;
718
637
 
719
638
                case 'pages':
720
 
                        $ItemList->set_default_filters( array(
721
 
                                        'types' => '1000', // Pages
722
 
                                ) );
723
 
                        break;
 
639
                $ItemList->set_default_filters( array(
 
640
                        'types' => '1000', // Pages
 
641
                ) );
 
642
                break;
724
643
 
725
644
                case 'intros':
726
 
                        $ItemList->set_default_filters( array(
727
 
                                        'types' => '1500,1520,1530,1570,1600', // Intros
728
 
                                ) );
729
 
                        break;
 
645
                $ItemList->set_default_filters( array(
 
646
                        'types' => '1500,1520,1530,1570,1600', // Intros
 
647
                ) );
 
648
                break;
730
649
 
731
650
                case 'podcasts':
732
 
                        $ItemList->set_default_filters( array(
733
 
                                        'types' => '2000', // Podcasts
734
 
                                ) );
735
 
                        break;
 
651
                $ItemList->set_default_filters( array(
 
652
                        'types' => '2000', // Podcasts
 
653
                ) );
 
654
                break;
736
655
 
737
656
                case 'links':
738
 
                        $ItemList->set_default_filters( array(
739
 
                                        'types' => '3000', // Links
740
 
                                ) );
741
 
                        break;
 
657
                $ItemList->set_default_filters( array(
 
658
                        'types' => '3000', // Links
 
659
                        ) );
 
660
                break;
742
661
 
743
662
                case 'tracker':
744
 
                        // In tracker mode, we want a different default sort:
745
 
                        $ItemList->set_default_filters( array(
746
 
                                        'orderby' => 'priority',
747
 
                                        'order' => 'ASC' ) );
748
 
                        break;
 
663
                // In tracker mode, we want a different default sort
 
664
                $ItemList->set_default_filters( array(
 
665
                        'orderby' => 'priority',
 
666
                        'order' => 'ASC',
 
667
                ) );
 
668
                break;
749
669
 
750
670
                default:
751
 
                        // Delete the pref_browse_tab setting so that the default
752
 
                        // (full) gets used the next time the user wants to browse
753
 
                        // a blog and we don't run into the same error again.
754
 
                        $UserSettings->delete( 'pref_browse_tab' );
755
 
                        $UserSettings->dbupdate();
756
 
                        debug_die( 'Unknown filterset ['.$tab.']' );
 
671
                // Delete the pref_browse_tab setting so that the default (full) gets used the next
 
672
                // time the user wants to browse a blog and we don't run into the same error again.
 
673
                $UserSettings->delete( 'pref_browse_tab' );
 
674
                $UserSettings->dbupdate();
 
675
                debug_die( 'Unknown filterset ['.$tab.']' );
757
676
        }
758
677
 
759
 
        // Init filter params:
 
678
        // Init filter params
760
679
        if( ! $ItemList->load_from_Request() )
761
 
        { // If we could not init a filterset from request
762
 
                // typically happens when we could no fall back to previously saved filterset...
 
680
        {
 
681
                // If we could not init a filterset from request typically happens when we
 
682
                // could no fall back to previously saved filterset...
763
683
        }
764
684
}
765
685
 
766
 
/**
767
 
 * Configure page navigation:
768
 
 */
 
686
// Configure page navigation
769
687
switch( $action )
770
688
{
771
689
        case 'new':
773
691
        case 'create_edit':
774
692
        case 'create':
775
693
        case 'create_publish':
776
 
                // Generate available blogs list:
777
 
                $AdminUI->set_coll_list_params( 'blog_post_statuses', 'edit',
778
 
                                                array( 'ctrl' => 'items', 'action' => 'new' ), NULL, '',
779
 
                                                'return b2edit_reload( document.getElementById(\'item_checkchanges\'), \''.$dispatcher.'\', %s )' );
780
 
 
781
 
                // We don't check the following earlier, because we want the blog switching buttons to be available:
782
 
                if( ! blog_has_cats( $blog ) )
783
 
                {
784
 
                        $Messages->add( sprintf( T_('Since this blog has no categories, you cannot post into it. You must <a %s>create categories</a> first.'), 'href="'.$dispatcher.'?ctrl=chapters&amp;blog='.$blog.'"') , 'error' );
785
 
                        $action = 'nil';
786
 
                        break;
787
 
                }
788
 
 
789
 
                /* NOBREAK */
 
694
        // Generate available blogs list
 
695
        $AdminUI->set_blog_list_params( 'blog_post_statuses', 'edit',
 
696
                array( 'ctrl' => 'items', 'action' => 'new' ), NULL, '',
 
697
                'return b2edit_reload( document.getElementById(\'item_checkchanges\'), \''.$dispatcher.'\', %s )' );
 
698
 
 
699
        // We don't check the following earlier, because we want the blog switching buttons to be available
 
700
        if( ! blog_has_cats( $blog ) )
 
701
        {
 
702
                $Messages->add( sprintf( T_('Since this blog has no categories, you cannot post into it. You must <a %s>create categories</a> first.'), 'href="'.$dispatcher.'?ctrl=cats&amp;blog='.$blog.'"'), 'error' );
 
703
                $action = 'nil';
 
704
                break;
 
705
        }
 
706
 
 
707
        /* NOBREAK */
790
708
 
791
709
        case 'edit':
792
710
        case 'edit_switchtab': // this gets set as action by JS, when we switch tabs
793
711
        case 'update_edit':
794
712
        case 'update': // on error
795
713
        case 'update_publish': // on error
796
 
                // Get tab ("simple" or "expert") from Request or UserSettings:
797
 
                $tab = $UserSettings->param_Request( 'tab', 'pref_edit_tab', 'string', NULL, true /* memorize */, true /* force */ );
 
714
        // Get tab ("simple" or "expert") from Request or UserSettings
 
715
        $tab = $UserSettings->param_Request( 'tab', 'pref_edit_tab', 'string', NULL, true /* memorize */, true /* force */ );
798
716
 
799
717
                switch( $action )
800
718
                {
803
721
                        case 'update_edit':
804
722
                        case 'update': // on error
805
723
                        case 'update_publish': // on error
806
 
                                if( ! $current_User->check_perm( 'blog_del_post', 'any', false, $edited_Item->get_blog_ID() ) )
807
 
                                { // User has no right to delete this post
808
 
                                        break;
809
 
                                }
810
 
                                $AdminUI->global_icon( T_('Delete this post'), 'delete', '?ctrl=items&amp;action=delete&amp;post_ID='.$edited_Item->ID,
811
 
                                                 T_('delete'), 4, 3, array(
812
 
                                                                'onclick' => 'return confirm(\''.TS_('You are about to delete this post!\\nThis cannot be undone!').'\')',
813
 
                                                                'style' => 'margin-right: 3ex;',        // Avoid misclicks by all means!
814
 
                                                 ) );
 
724
                        if( ! $current_User->check_perm( 'blog_del_post', 'any', false, $edited_Item->get_blog_ID() ) )
 
725
                        {
 
726
                                // User has no right to delete this post
815
727
                                break;
 
728
                        }
 
729
                        $AdminUI->global_icon( T_('Delete this post'), 'delete', '?ctrl=items&amp;action=delete&amp;post_ID='.$edited_Item->ID,
 
730
                                T_('delete'), 4, 3, array(
 
731
                                        'onclick' => 'return confirm(\''.TS_('You are about to delete this post!\\nThis cannot be undone!').'\')',
 
732
                                        'style' => 'margin-right: 3ex;', // Avoid misclicks by all means!
 
733
                        ) );
 
734
                        break;
816
735
                }
817
 
 
818
 
                $AdminUI->global_icon( T_('Cancel editing!'), 'close', $redirect_to, T_('cancel'), 4, 2 );
819
 
 
 
736
                $AdminUI->global_icon( T_('Cancel editing!'), 'close', $redirect_to, T_('cancel'), 3, 4 );
820
737
                break;
821
738
 
822
739
        case 'view':
823
 
                // We're displaying a SINGLE specific post:
824
 
                $AdminUI->title = $AdminUI->title_titlearea = T_('View post & comments');
825
 
                break;
 
740
        // We're displaying a SINGLE specific post
 
741
        $AdminUI->title = $AdminUI->title_titlearea = T_('View post & comments');
 
742
        break;
826
743
 
827
744
        case 'list':
828
 
                // We're displaying a list of posts:
829
 
 
830
 
                $AdminUI->title = $AdminUI->title_titlearea = T_('Browse blog');
831
 
 
832
 
                // Generate available blogs list:
833
 
                $AdminUI->set_coll_list_params( 'blog_ismember', 'view', array( 'ctrl' => 'items', 'tab' => $tab, 'filter' => 'restore' ) );
834
 
 
835
 
                /*
836
 
                 * Add sub menu entries:
837
 
                 * We do this here instead of _header because we need to include all filter params into regenerate_url()
838
 
                 */
839
 
                attach_browse_tabs();
840
 
 
841
 
                break;
 
745
        // We're displaying a list of posts
 
746
        $AdminUI->title = $AdminUI->title_titlearea = T_('Browse blog');
 
747
        // Generate available blogs list
 
748
        $AdminUI->set_blog_list_params( 'blog_ismember', 'view', array( 'ctrl' => 'items', 'tab' => $tab, 'filter' => 'restore' ) );
 
749
        // Add sub menu entries
 
750
        // We do this here instead of _header because we need to include all filter params into regenerate_url()
 
751
        attach_browse_tabs();
 
752
        break;
842
753
 
843
754
        case 'edit_links':
844
 
                // Embedded iframe:
845
 
                $tab = '';
846
 
                $mode = 'iframe';
847
 
                break;
 
755
        // Embedded iframe
 
756
        $tab = '';
 
757
        $mode = 'iframe';
 
758
        break;
848
759
}
849
760
 
850
 
if( !empty($tab) )
 
761
if( ! empty( $tab ) )
851
762
{
852
763
        $AdminUI->append_path_level( $tab );
853
764
}
854
765
 
855
 
 
856
 
// Load the appropriate blog navigation styles (including calendar, comment forms...):
 
766
// Load the appropriate blog navigation styles (including calendar, comment forms...)
857
767
require_css( $rsc_url.'css/blog_base.css' );
858
768
 
859
769
// Load the appropriate ITEM/POST styles depending on the blog's template:
862
772
        $content_css = ''; // start this empty
863
773
        $TemplateCache = & get_Cache( 'TemplateCache' );
864
774
        $Template = $TemplateCache->get_by_ID( $Blog->template_ID );
865
 
        if( is_file( $templates_path.$Template->folder.'/item.css' ) )
 
775
        if( is_file( $templates_path.$Template->folder.'/tinymce.css' ) )
866
776
        {
867
 
                require_css( $templates_url.$Template->folder.'/item.css' );
 
777
                require_css( $templates_url.$Template->folder.'/tinymce.css' );
868
778
        }
869
779
}
870
780
 
871
 
// Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
 
781
// Display <html><head>...</head> section (should be done early if actions do not redirect)
872
782
$AdminUI->disp_html_head();
873
 
 
874
 
// Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
875
 
$AdminUI->disp_body_top( $mode != 'iframe' );   // do NOT display stupid messages in iframe (UGLY UGLY UGLY!!!!)
876
 
 
877
 
 
878
 
/**
879
 
 * Display payload:
880
 
 */
 
783
// Display title, menu, messages, etc... (messages MUST be displayed AFTER the actions)
 
784
$AdminUI->disp_body_top( $mode != 'iframe' ); // do NOT display messages in iframe
 
785
 
 
786
// Display payload
881
787
switch( $action )
882
788
{
883
789
        case 'nil':
884
 
                // Do nothing
885
 
                break;
 
790
        // Do nothing
 
791
        break;
886
792
 
887
 
  case 'new_switchtab': // this gets set as action by JS, when we switch tabs
 
793
        case 'new_switchtab': // this gets set as action by JS, when we switch tabs
888
794
        case 'edit_switchtab': // this gets set as action by JS, when we switch tabs
889
 
                $bozo_start_modified = true;    // We want to start with a form being already modified
 
795
        $bozo_start_modified = true; // We want to start with a form being already modified
890
796
        case 'new':
891
797
        case 'create_edit':
892
798
        case 'create':
893
799
        case 'create_publish':
894
800
        case 'edit':
895
801
        case 'update_edit':
896
 
        case 'update':  // on error
897
 
        case 'update_publish':  // on error
898
 
                // Begin payload block:
899
 
                $AdminUI->disp_payload_begin();
900
 
 
901
 
                $item_title = $edited_Item->title;
902
 
                $item_content = $edited_Item->content;
903
 
 
904
 
                // Format content for editing, if we were not already in editing...
905
 
                $Plugins_admin = & get_Cache('Plugins_admin');
906
 
                $Plugins_admin->unfilter_contents( $item_title /* by ref */, $item_content /* by ref */, $edited_Item->get_renderers_validated() );
907
 
 
908
 
                // Display VIEW:
909
 
                $AdminUI->disp_view( 'items/views/_item_expert.form.php' );
910
 
 
911
 
                // End payload block:
912
 
                $AdminUI->disp_payload_end();
913
 
                break;
 
802
        case 'update': // on error
 
803
        case 'update_publish': // on error
 
804
        // Begin payload block
 
805
        $AdminUI->disp_payload_begin();
 
806
 
 
807
        $item_title = $edited_Item->title;
 
808
        $item_content = $edited_Item->content;
 
809
 
 
810
        // Format content for editing, if we were not already in editing...
 
811
        $Plugins_admin = & get_Cache('Plugins_admin');
 
812
        $Plugins_admin->unfilter_contents( $item_title /* by ref */, $item_content /* by ref */, $edited_Item->get_renderers_validated() );
 
813
 
 
814
        // Display VIEW
 
815
        $AdminUI->disp_view( 'items/views/_item_expert.form.php' );
 
816
        // End payload block
 
817
        $AdminUI->disp_payload_end();
 
818
        break;
914
819
 
915
820
        case 'view':
916
821
        case 'delete':
917
 
                // View a single post:
918
 
 
919
 
                // Memorize 'p' in case we reload while changing some display settings
920
 
                memorize_param( 'p', 'integer', NULL );
921
 
 
922
 
                // Begin payload block:
923
 
                $AdminUI->disp_payload_begin();
924
 
 
925
 
                // We use the "full" view for displaying single posts:
 
822
        // View a single post
 
823
        // Memorize 'p' in case we reload while changing some display settings
 
824
        memorize_param( 'p', 'integer', NULL );
 
825
        // Begin payload block
 
826
        $AdminUI->disp_payload_begin();
 
827
        // We use the "full" view for displaying single posts
 
828
        $AdminUI->disp_view( 'items/views/_item_list_full.view.php' );
 
829
        // End payload block
 
830
        $AdminUI->disp_payload_end();
 
831
        break;
 
832
 
 
833
        case 'edit_links':
 
834
        // View attachments
 
835
        $AdminUI->disp_view( 'items/views/_item_links.view.php' );
 
836
        break;
 
837
 
 
838
        case 'history':
 
839
        memorize_param( 'action', 'string', NULL );
 
840
        // Begin payload block
 
841
        $AdminUI->disp_payload_begin();
 
842
        // view
 
843
        $AdminUI->disp_view( 'items/views/_item_history.view.php' );
 
844
        // End payload block
 
845
        $AdminUI->disp_payload_end();
 
846
        break;
 
847
 
 
848
        case 'list':
 
849
        default:
 
850
        // Begin payload block
 
851
        $AdminUI->disp_payload_begin();
 
852
        // fplanque> Note: this is depressing, but I have to put a table back here
 
853
        // just because IE supports standards really badly! :'(
 
854
        echo '<table class="browse" cellspacing="0" cellpadding="0" border="0"><tr>';
 
855
        echo '<td class="browse_left_col">';
 
856
        switch( $tab )
 
857
        {
 
858
                case 'tracker':
 
859
                // Display VIEW
 
860
                $AdminUI->disp_view( 'items/views/_item_list_track.view.php' );
 
861
                break;
 
862
 
 
863
                case 'full':
 
864
                // Display VIEW
926
865
                $AdminUI->disp_view( 'items/views/_item_list_full.view.php' );
927
 
 
928
 
                // End payload block:
929
 
                $AdminUI->disp_payload_end();
930
 
 
931
 
                break;
932
 
 
933
 
        case 'edit_links':
934
 
                // View attachments
935
 
                $AdminUI->disp_view( 'items/views/_item_links.view.php' );
936
 
                break;
937
 
 
938
 
        case 'history':
939
 
                memorize_param( 'action', 'string', NULL );
940
 
 
941
 
                // Begin payload block:
942
 
                $AdminUI->disp_payload_begin();
943
 
 
944
 
                // view:
945
 
                $AdminUI->disp_view( 'items/views/_item_history.view.php' );
946
 
 
947
 
                // End payload block:
948
 
                $AdminUI->disp_payload_end();
949
 
                break;
950
 
 
951
 
        case 'list':
952
 
        default:
953
 
                // Begin payload block:
954
 
                $AdminUI->disp_payload_begin();
955
 
 
956
 
                // fplanque> Note: this is depressing, but I have to put a table back here
957
 
                // just because IE supports standards really badly! :'(
958
 
                echo '<table class="browse" cellspacing="0" cellpadding="0" border="0"><tr>';
959
 
 
960
 
                echo '<td class="browse_left_col">';
961
 
 
962
 
                        switch( $tab )
963
 
                        {
964
 
                                case 'tracker':
965
 
                                        // Display VIEW:
966
 
                                        $AdminUI->disp_view( 'items/views/_item_list_track.view.php' );
967
 
                                        break;
968
 
 
969
 
                                case 'full':
970
 
                                        // Display VIEW:
971
 
                                        $AdminUI->disp_view( 'items/views/_item_list_full.view.php' );
972
 
                                        break;
973
 
 
974
 
                                case 'list':
975
 
                                case 'pages':
976
 
                                case 'intros':
977
 
                                case 'podcasts':
978
 
                                default:
979
 
                                        // Display VIEW:
980
 
                                        $AdminUI->disp_view( 'items/views/_item_list_table.view.php' );
981
 
                                        break;
982
 
                        }
983
 
 
984
 
                        // TODO: a specific field for the backoffice, at the bottom of the page
985
 
                        // would be used for moderation rules.
986
 
                        if( $Blog->get( 'notes' ) )
987
 
                        {
988
 
                                $block_item_Widget = new Widget( 'block_item' );
989
 
                                $block_item_Widget->title = T_('Notes');
990
 
                                // show a quicklink to edit if user has permission:
991
 
/* fp> TODO: use an action icon (will appear on the right)
992
 
                                if( $current_User->check_perm( 'blog_properties', 'edit', false, $blog ) )
993
 
                                        $block_item_Widget->title .=    ' <a href="?ctrl=coll_settings&amp;tab=advanced&amp;blog='.$Blog->ID.'#ffield_blog_notes">'.get_icon( 'edit' ).'</a>';
994
 
*/
995
 
                                $block_item_Widget->disp_template_replaced( 'block_start' );
996
 
                                $Blog->disp( 'notes', 'htmlbody' );
997
 
                                $block_item_Widget->disp_template_replaced( 'block_end' );
998
 
                        }
999
 
 
1000
 
                echo '</td>';
1001
 
 
1002
 
                echo '<td class="browse_right_col">';
1003
 
                        // Display VIEW:
1004
 
                        $AdminUI->disp_view( 'items/views/_item_list_sidebar.view.php' );
1005
 
                echo '</td>';
1006
 
 
1007
 
                echo '</tr></table>';
1008
 
 
1009
 
                // End payload block:
1010
 
                $AdminUI->disp_payload_end();
1011
 
                break;
 
866
                break;
 
867
 
 
868
                case 'list':
 
869
                case 'pages':
 
870
                case 'intros':
 
871
                case 'podcasts':
 
872
                default:
 
873
                // Display VIEW
 
874
                $AdminUI->disp_view( 'items/views/_item_list_table.view.php' );
 
875
                break;
 
876
        }
 
877
 
 
878
        // @todo (0000) a field for the backoffice, at the bottom of the page would be used for moderation rules
 
879
        if( $Blog->get( 'notes' ) )
 
880
        {
 
881
                $block_item_Widget = new Widget( 'block_item' );
 
882
                $block_item_Widget->title = T_('Notes');
 
883
                // show a quicklink to edit if user has permission
 
884
                /* fp> TODO: use an action icon (will appear on the right)
 
885
                if( $current_User->check_perm( 'blog_properties', 'edit', false, $blog ) )
 
886
                {
 
887
                        $block_item_Widget->title .= ' <a href="?ctrl=blog_settings&amp;tab=advanced&amp;blog='.$Blog->ID.'#ffield_blog_notes">'.get_icon( 'edit' ).'</a>';
 
888
                }
 
889
                */
 
890
                $block_item_Widget->disp_template_replaced( 'block_start' );
 
891
                $Blog->disp( 'notes', 'htmlbody' );
 
892
                $block_item_Widget->disp_template_replaced( 'block_end' );
 
893
        }
 
894
        echo '</td>';
 
895
        echo '<td class="browse_right_col">';
 
896
        // Display VIEW
 
897
        $AdminUI->disp_view( 'items/views/_item_list_sidebar.view.php' );
 
898
        echo '</td>';
 
899
        echo '</tr></table>';
 
900
        // End payload block
 
901
        $AdminUI->disp_payload_end();
 
902
        break;
1012
903
}
1013
904
 
1014
 
// Display body bottom, debug info and close </html>:
 
905
// Display body bottom, debug info, close </html>
1015
906
$AdminUI->disp_global_footer();
1016
907
 
1017
908
?>