Status as of 2012: this is all mostly done and kept for historical perspectives. If you notice an issue with Category Jail for a specific feature, please file a bug report, or fix the code and commit if you can 😊



As explained in the Workspace, the category jail is a way to restrict the visible categories and listed objects. At this time, the preference has been partially deployed as a few examples, but to be an effective feature, it must be deployed on all features and all listings.

Once this task is completed, WYSIWTSN will be achieved through Perspectives.

Tools

  • $categlib->get_jail() provides the list of categories available in the jail
  • $categlib->get_jailed( $categories ) returns the list of filtered categories for the jail if activated, or the provided categories if not
  • $categlib->get_default_categories() provides the list of categories to be applied as default

Tasks

These tasks must be performed for all features (ex: file galleries, image galleries, articles, ...). They should be performed one by one.

  1. Update the Jailroot Demonstration profile to create test data for the data type.
  2. Verify that object creation uses the root categories as default values on object creation (by setting the $cat_object_exists variable before inclusion of categorize.php and categorize_list.php)
  3. Update the primary listings to respect the category jail. This usually implies setting a default category filter (get_jail) if none is applied and filtering the category filter (get_jailed). List filtering should be done in the libraries as much as possible.
  4. Update all the modules and plugins related to the feature. These might work out of the box if they used the primary listing functions. However, this is not common. If possible, the code should be converted to use the primary listing function and set the appropriate filters and orderings. Otherwise, the code will need to be updated to respect the filtering.

Progress

FeatureAssigned toStatus
Categorylphuberdeaucompleted
WikichealerDone
ArticlebenEdit and primary listing done
Image galleries
Blogsaldo
File galleriesjonny/lphcompleted
Trackersluci & SylvieDeployment of Category Jail for Trackers
CalendarbenListing done, problems with events edition
Forumslphuberdeaucompleted
Polls


Other features?

  • Multiple modules also do not respect WYSIWYCA and WYSIWTSN
    • Most critical would be "since your last visit", which can be updated by simply calling the functions instead of duplicating SQL.
  • Search -> not working as of 2009-01-09

Examples

Apply default categories on object creation
Copy to clipboard
Index: tiki-editpage.php =================================================================== --- tiki-editpage.php (revision 20514) +++ tiki-editpage.php (revision 20521) @@ -1010,6 +1010,7 @@ $cat_name = $_REQUEST["page"]; $cat_href="tiki-index.php?page=".urlencode($cat_objid); $cat_lang = $_REQUEST['lang']; + $cat_object_exists = $tikilib->page_exists( $_REQUEST['page'] ); include_once("categorize.php"); include_once("poll_categorize.php"); include_once("freetag_apply.php"); @@ -1286,6 +1287,7 @@ $cat_type = 'wiki page'; $cat_objid = $_REQUEST["page"]; $cat_lang = $pageLang; +$cat_object_exists = $tikilib->page_exists( $_REQUEST['page'] ); $smarty->assign('section',$section); include_once ('tiki-section_options.php'); if ($prefs['feature_freetags'] == 'y') { Index: tiki-edit_article.php =================================================================== --- tiki-edit_article.php (revision 20514) +++ tiki-edit_article.php (revision 20521) @@ -434,6 +434,7 @@ $cat_objid = $artid; $cat_desc = substr($_REQUEST["heading"], 0, 200); $cat_name = $_REQUEST["title"]; + $cat_object_exists = (bool) $artid; $cat_href = "tiki-read_article.php?articleId=" . $cat_objid; include_once("categorize.php"); include_once ("freetag_apply.php"); @@ -472,6 +473,7 @@ $cat_type = 'article'; $cat_objid = $articleId; +$cat_object_exists = (bool) $artid; include_once ("categorize_list.php"); if ($prefs['feature_freetags'] == 'y') {

Apply default filters and jail
Copy to clipboard
Index: lib/tikilib.php =================================================================== --- lib/tikilib.php (revision 20514) +++ lib/tikilib.php (revision 20521) @@ -3066,8 +3066,12 @@ $bindvars[] = $max_rating; } + global $categlib; require_once('lib/categories/categlib.php'); + if( empty( $categId ) ) { + $categId = $categlib->get_jail(); + } + if ($categId) { - global $categlib; require_once('lib/categories/categlib.php'); $categlib->getSqlJoin($categId, 'article', '`tiki_articles`.`articleId`', $fromSql, $mid2, $bindvars); } @@ -3952,19 +3956,28 @@ $mid = ''; } + global $categlib; require_once( 'lib/categories/categlib.php' ); + $category_jails = $categlib->get_jail(); + + if( ! isset( $filter['categId'] ) && ! empty( $category_jails ) ) { + $filter['categId'] = $category_jails; + } + $distinct = ''; if (!empty($filter)) { $tmp_mid = array(); foreach ($filter as $type=>$val) { if ($type == 'categId') { - $cat_count = count( (array) $val ); + $categories = $categlib->get_jailed( (array) $val ); + + $cat_count = count( $categories ); $join_tables .= " inner join `tiki_objects` as tob on (tob.`itemId`= tp.`pageName` and tob.`type`= ?) inner join `tiki_category_objects` as tc on (tc.`catObjectId`=tob.`objectId` and tc.`categId` IN(" . implode(', ', array_fill(0, $cat_count, '?')) . ")) "; if( $cat_count > 1 ) { $distinct = ' DISTINCT '; } - $join_bindvars = array_merge(array('wiki page'), (array) $val); + $join_bindvars = array_merge(array('wiki page'), $categories); } elseif ($type == 'lang') { $tmp_mid[] = 'tp.`lang`=?'; $bindvars[] = $val;
Show PHP error messages
 
ERROR (E_WARNING): Trying to access array offset on null
At line 298 in temp/templates_c/en_social^51ed9d5e273be5e76d0e990a7170327cc292754c_0.file_tiki-show_page.tpl.php