Merge lp:~edb/quam-plures/navbar_workflow_fix into lp:quam-plures

Proposed by EdB
Status: Merged
Merged at revision: 7594
Proposed branch: lp:~edb/quam-plures/navbar_workflow_fix
Merge into: lp:quam-plures
Diff against target: 53 lines (+24/-11)
1 file modified
qp_inc/_core/__core.init.php (+24/-11)
To merge this branch: bzr merge lp:~edb/quam-plures/navbar_workflow_fix
Reviewer Review Type Date Requested Status
Yabs (community) Approve
Review via email: mp+45617@code.launchpad.net

Description of the change

Removes a tiny little "bug": when workflow is not enabled we still get a navbar option for "post statuses", but that feature only comes into play when workflow is enabled. This branch does a check before adding that option to the navbar.

To post a comment you must log in.
Revision history for this message
Yabs (yabs) wrote :

if( $Blog

Needs to be :

if( !empty( $Blog )

Although, ideally, we'd actually check if it was an instance of the blog class, which we don't do anywhere in the core AFAIK.

¥

review: Needs Fixing
Revision history for this message
EdB (edb) wrote :

if( $Blog ) { die() }
produces the same exact results as
if( ! empty( $Blog ) { die() }

In both cases it doesn't die until a blog has been selected or identified ... even if it seems to be blog-0 in the URL. For example when first hitting the Items or Blog settings tab. The URL in those cases says blog 0 but it actually goes to the first blog or blog 1.

So why would the latter be more correct than the former?

Revision history for this message
Yabs (yabs) wrote :

If $Blog isn't defined and you check with "if( $Blog )" it'll throw a php warning about an undefined variable, whereas !empty( $Blog ) won't.

¥

7581. By EdB

updated from core

7582. By EdB

update from core

Revision history for this message
EdB (edb) wrote :

Okay got it figured out. It isn't empty, but it is "defined" compliments of the global line declaring it's existence.
if( $Blog ) { pre_dump( $Blog ); } before the block of globals at function build_navbar_menu() throws an error for undefined variable. Anywhere after those globals it doesn't. Same with little-b $blog - error above, no error below.

It works as-is is the thing.

7583. By EdB

update from core

7584. By EdB

adding core changes

Revision history for this message
Yabs (yabs) wrote :

Fair enough ;)

¥

review: Approve
7585. By EdB

new stuff in core now here - woohoo!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qp_inc/_core/__core.init.php'
2--- qp_inc/_core/__core.init.php 2011-01-01 12:53:50 +0000
3+++ qp_inc/_core/__core.init.php 2011-03-08 04:37:11 +0000
4@@ -408,11 +408,18 @@
5 'text' => T_('Post types').'…',
6 'href' => $admin_url.'?ctrl=itemtypes',
7 ),
8- 'itemstatuses' => array(
9- 'text' => T_('Post statuses').'…',
10- 'href' => $admin_url.'?ctrl=itemstatuses',
11- ),
12 );
13+
14+ if( $Blog && $Blog->get_setting( 'use_workflow' ) )
15+ { // workflow is enabled for this blog
16+ $entries['global_sets']['entries'] += array(
17+ 'itemstatuses' => array(
18+ 'text' => T_('Post statuses').'…',
19+ 'href' => $admin_url.'?ctrl=itemstatuses',
20+ ),
21+ );
22+ }
23+
24 }
25
26 // FILES LINK :: main item update and dropdown menu items...
27@@ -989,13 +996,19 @@
28 'text' => T_('Post types'),
29 'title' => T_('Post types management'),
30 'href' => $dispatcher.'?ctrl=itemtypes'),
31- 'statuses' => array(
32- 'text' => T_('Post statuses'),
33- 'title' => T_('Post statuses management'),
34- 'href' => $dispatcher.'?ctrl=itemstatuses'),
35- )
36- ),
37- ) );
38+ )
39+ ),
40+ ) );
41+
42+ if( $Blog && $Blog->get_setting( 'use_workflow' ) )
43+ {
44+ $AdminUI->add_menu_entries( 'options', array(
45+ 'statuses' => array(
46+ 'text' => T_('Post statuses'),
47+ 'title' => T_('Post statuses management'),
48+ 'href' => $dispatcher.'?ctrl=itemstatuses' ),
49+ ) );
50+ }
51 }
52
53 if( $current_User->check_perm( 'users', 'view' ) )

Subscribers

People subscribed via source and target branches