Commit 854937a7 authored by lphuberdeau's avatar lphuberdeau

[KIL] Staging & Approval

parent c085057f
......@@ -2661,7 +2661,6 @@ lib/prefs/warn.php -text
lib/prefs/watershed.php -text
lib/prefs/webmail.php -text
lib/prefs/wiki.php -text
lib/prefs/wikiapproval.php -text
lib/prefs/wikiplugin.php -text
lib/prefs/wikiplugininline.php -text
lib/prefs/wikipluginprefs.php -text
......@@ -4991,7 +4990,6 @@ templates/tiki-admingroups.tpl -text
templates/tiki-adminusers.tpl -text
templates/tiki-ajax_header.tpl -text
templates/tiki-all_languages.tpl -text
templates/tiki-approve_staging_page.tpl -text
templates/tiki-article_types.tpl -text
templates/tiki-articles-js.tpl -text
templates/tiki-assignuser.tpl -text
......@@ -5277,7 +5275,6 @@ templates/tiki-webdav.tpl -text
templates/tiki-webmail.tpl -text
templates/tiki-webmail_contacts.tpl -text
templates/tiki-wiki3d.tpl -text
templates/tiki-wiki_staging.tpl -text
templates/tiki-wiki_structure_bar.tpl -text
templates/tiki-wiki_topline.tpl -text
templates/tiki.tpl -text
......@@ -5496,7 +5493,6 @@ tests/testfile.txt -text
/tiki-adminusers.php -text
/tiki-ajax_services.php -text
/tiki-all_languages.php -text
/tiki-approve_staging_page.php -text
/tiki-article_types.php -text
/tiki-articles_rss.php -text
/tiki-assignuser.php -text
......
......@@ -27,21 +27,6 @@ if ($prefs['feature_categories'] == 'y' && $catobjperms->modify_object_categorie
if ( !isset($_REQUEST["cat_categorize"]) || $_REQUEST["cat_categorize"] != 'on' || (isset($_REQUEST["cat_clearall"]) && $_REQUEST["cat_clearall"] == 'on') ) {
$_REQUEST['cat_categories'] = NULL;
}
if ( $cat_type == 'wiki page' && $tikilib->get_approved_page($cat_objid) ) {
if ($prefs['wikiapproval_approved_category'] > 0 && in_array($prefs['wikiapproval_approved_category'], $_REQUEST['cat_categories'])) {
$_REQUEST['cat_categories'] = array_diff($_REQUEST['cat_categories'],Array($prefs['wikiapproval_approved_category']));
}
if ($prefs['wikiapproval_staging_category'] > 0 && !in_array($prefs['wikiapproval_staging_category'], $_REQUEST['cat_categories'])) {
$_REQUEST['cat_categories'][] = $prefs['wikiapproval_staging_category'];
}
if ($prefs['wikiapproval_outofsync_category'] > 0 && !in_array($prefs['wikiapproval_outofsync_category'], $_REQUEST['cat_categories'])) {
$_REQUEST['cat_categories'][] = $prefs['wikiapproval_outofsync_category'];
}
}
if ($cat_type == 'wiki page' && $tikilib->get_staging_page($cat_objid) && in_array($prefs['wikiapproval_staging_category'], $_REQUEST['cat_categories']) && in_array($prefs['wikiapproval_approved_category'], $_REQUEST['cat_categories'])) {
// Drop the staging category if page without staging prefix is attempted to be categorized in both staging category and approved category
$_REQUEST['cat_categories'] = array_diff($_REQUEST['cat_categories'],Array($prefs['wikiapproval_staging_category']));
}
$categlib->update_object_categories(isset($_REQUEST['cat_categories'])?$_REQUEST['cat_categories']:'', $cat_objid, $cat_type, $cat_desc, $cat_name, $cat_href, $_REQUEST['cat_managed']);
$cats = $categlib->get_object_categories($cat_type, $cat_objid);
......
......@@ -29,15 +29,6 @@ if ($prefs['feature_categories'] == 'y' && isset($cat_type) && isset($cat_objid)
$cats = $categlib->get_default_categories();
}
if ($prefs['wikiapproval_sync_categories'] == 'y' && !$cats
&& $cat_type == 'wiki page' && ( $approved = $tikilib->get_approved_page($cat_objid) )
&& !$tikilib->page_exists($cat_objid) ) {
// to pre-populate categories of original page if this is the first creation of a staging page
$approvedPageName = $approved;
$cats = $categlib->get_object_categories($cat_type, $approvedPageName);
$cats = array_diff($cats,Array($prefs['wikiapproval_approved_category']));
}
if ($cat_type == 'wiki page' || $cat_type == 'blog' || $cat_type == 'image gallery' || $cat_type == 'mypage') {
$ext = ($cat_type == 'wiki page')? 'wiki':str_replace(' ', '_', $cat_type);
$pref = 'feature_'.$ext.'_mandatory_category';
......
......@@ -15,40 +15,24 @@ global $tiki_p_view_freetags;
if ($prefs['feature_freetags'] == 'y' and $tiki_p_view_freetags == 'y') {
global $freetaglib;
if (!is_object($freetaglib)) {
include_once('lib/freetag/freetaglib.php');
}
$freetaglib = TikiLib::lib('freetag');
if (isset($cat_objid)) {
$tags = $freetaglib->get_tags_on_object($cat_objid, $cat_type);
$tagarray = array();
$taglist = '';
if (!empty($tags['data'])) {
foreach ($tags['data'] as $tag) {
if (strstr($tag['tag'], ' ')) {
$taglist .= '"'.$tag['tag'] . '" ';
} else {
$taglist .= $tag['tag'] . ' ';
$tags = $freetaglib->get_tags_on_object($cat_objid, $cat_type);
$tagarray = array();
$taglist = '';
if (!empty($tags['data'])) {
foreach ($tags['data'] as $tag) {
if (strstr($tag['tag'], ' ')) {
$taglist .= '"'.$tag['tag'] . '" ';
} else {
$taglist .= $tag['tag'] . ' ';
}
$tagarray[] = $tag['tag'];
}
$tagarray[] = $tag['tag'];
}
}
if ($prefs['feature_wikiapproval'] == 'y' && $prefs['wikiapproval_combine_freetags'] == 'y'
&& $cat_type == 'wiki page' && $approved = $tikilib->get_approved_page($cat_objid)) {
// to combine tags from approved page
$approvedPageName = $approved;
$approvedTags = $freetaglib->get_tags_on_object($approvedPageName, $cat_type);
foreach($approvedTags['data'] as $approvedTag) {
if (!in_array($approvedTag['tag'],$tagarray)) {
$taglist .= $approvedTag['tag'] . ' ';
}
}
}
$smarty->assign('taglist',$taglist);
$smarty->assign('taglist',$taglist);
} else {
$taglist = '';
}
......
......@@ -236,7 +236,7 @@ function _breadcrumb_getTitle($crumbs, $loc) {
require_once 'lib/smarty_tiki/modifier.escape.php';
}
$class = "pagetitle";
$class = "pagetitle";
$metadata = '';
$current = current_object();
......@@ -251,10 +251,10 @@ function _breadcrumb_getTitle($crumbs, $loc) {
}
}
$ret = '<strong><a class="'.$class.'"' . $metadata . ' title="'.tra("refresh").'" href="' . $escapedHref . '">';
$ret = '<strong><a class="'.$class.'"' . $metadata . ' title="'.tra("refresh").'" href="' . $escapedHref . '">';
} else {
$class = "crumblink";
$ret = '<a class="'.$class.'" title="';
$class = "crumblink";
$ret = '<a class="'.$class.'" title="';
if ( ($structure == 'y') && $info ) {
$cnt = count($structure_path);
} else {
......@@ -265,25 +265,22 @@ function _breadcrumb_getTitle($crumbs, $loc) {
include_once('tiki-sefurl.php');
$ret .= '" href="'.filter_out_sefurl($crumbs[$len-1]->url, $smarty).'">';
}
if ($prefs['feature_breadcrumbs'] == 'n' && $loc == "admin")
$ret .= tra("Administration:")." ";
if ($prefs['wikiapproval_hideprefix'] == 'y' && $approved = $tikilib->get_approved_page( $crumbs[$len-1]->title ) ) {
$crumbs[$len-1]->title = $approved;
if ($prefs['feature_breadcrumbs'] == 'n' && $loc == "admin")
$ret .= tra("Administration:")." ";
if (!empty($prefs['wiki_pagename_strip'])) {
include_once('lib/smarty_tiki/modifier.pagename.php');
$ret .= tra(smarty_modifier_pagename($crumbs[$len-1]->title)).'</a>';
} else {
$ret .= htmlentities(tra($crumbs[$len-1]->title), ENT_QUOTES, 'UTF-8').'</a>';
}
if (!empty($prefs['wiki_pagename_strip'])) {
include_once('lib/smarty_tiki/modifier.pagename.php');
$ret .= tra(smarty_modifier_pagename($crumbs[$len-1]->title)).'</a>';
} else {
$ret .= htmlentities(tra($crumbs[$len-1]->title), ENT_QUOTES, 'UTF-8').'</a>';
}
$ret .= help_doclink(array('crumb'=>$crumbs[$len-1]));
if( isset($info['flag']) && $info['flag'] == 'L' && $print_page != 'y' ) {
$ret .= ' <img src="pics/icons/lock.png" height="16" width="16" alt="'.tra('locked').'" title="'.tra('locked by').' '.$info['user'].'" />';
}
if( $prefs['feature_breadcrumbs'] == 'n' || $prefs['feature_sitetitle'] == 'title' ) {
$ret .= '</strong>';
}
return $ret;
$ret .= help_doclink(array('crumb'=>$crumbs[$len-1]));
if( isset($info['flag']) && $info['flag'] == 'L' && $print_page != 'y' ) {
$ret .= ' <img src="pics/icons/lock.png" height="16" width="16" alt="'.tra('locked').'" title="'.tra('locked by').' '.$info['user'].'" />';
}
if( $prefs['feature_breadcrumbs'] == 'n' || $prefs['feature_sitetitle'] == 'title' ) {
$ret .= '</strong>';
}
return $ret;
}
/**
......@@ -293,23 +290,23 @@ function _breadcrumb_getTitle($crumbs, $loc) {
*/
/* static */
function breadcrumb_getDescription($crumbs, $loc) {
global $prefs, $info;
$len = count($crumbs);
if ($prefs['feature_breadcrumbs'] == 'y') {
if ($loc == 'page' && ($prefs['feature_sitedesc'] == 'page' || ($prefs['feature_wiki_description'] == 'y' && $info) )) {
return '<span id="description">'.tra($crumbs[$len-1]->description).'</span>';
} else if ($loc == 'site' && $prefs['feature_sitedesc'] == 'y' ) {
return '<span id="description">'.tra($crumbs[$len-1]->description).'</span>';
} else if ($loc == 'head') {
global $prefs, $info;
$len = count($crumbs);
if ($prefs['feature_breadcrumbs'] == 'y') {
if ($loc == 'page' && ($prefs['feature_sitedesc'] == 'page' || ($prefs['feature_wiki_description'] == 'y' && $info) )) {
return '<span id="description">'.tra($crumbs[$len-1]->description).'</span>';
} else if ($loc == 'site' && $prefs['feature_sitedesc'] == 'y' ) {
return '<span id="description">'.tra($crumbs[$len-1]->description).'</span>';
} else if ($loc == 'head') {
return tra($crumbs[$len-1]->description);
}
} else if ( !($prefs['feature_wiki_description'] == 'n' && $info)) {
return tra($crumbs[$len-1]->description);
}
} else if ( !($prefs['feature_wiki_description'] == 'n' && $info)) {
return tra($crumbs[$len-1]->description);
}
}
/* private */
function _is_assoc($var) {
return is_array($var) && array_keys($var)!==range(0,count($var)-1);
}
......@@ -222,8 +222,6 @@ class Services_Language_TranslationController
return $info['author'] == $user && $info['creator_edit'] == 'y';
}
// FIXME : Include staging & approval if we decide to keep it
return $perms->admin;
}
......
......@@ -295,11 +295,6 @@ class FreetagLib extends ObjectLib
$bindvals = array_merge($bindvals, array($findesc, $findesc));
}
global $prefs;
if ($prefs['feature_wikiapproval'] == 'y') {
$mid .= ' AND o.`itemId` not like ?';
$bindvals[] = $prefs['wikiapproval_prefix'] . '%';
}
// We must adjust for duplicate normalized tags appearing multiple times in the join by
// counting only the distinct tags. It should also work for an individual user.
......@@ -328,7 +323,7 @@ class FreetagLib extends ObjectLib
if ($tiki_p_admin == 'y') {
$ok = true;
} elseif ($row['type'] == 'blog post') {
global $bloglib; include_once('lib/blogs/bloglib.php');
$bloglib = TikiLib::lib('blog');
$post_info = $bloglib->get_post($row['itemId']);
if ($this->user_has_perm_on_object($user, $post_info['blogId'], 'blog', 'tiki_p_read_blog')) {
$ok = true;
......@@ -1207,12 +1202,6 @@ class FreetagLib extends ObjectLib
$mid = ' oa.objectId <> ob.objectId AND ob.type = ? AND oa.type = ? AND oa.itemId = ?';
$bindvals = array($targetType, $type, $objectId);
global $prefs;
if ($prefs['feature_wikiapproval'] == 'y') {
$mid .= ' AND ob.`itemId` not like ?';
$bindvals[] = $prefs['wikiapproval_prefix'] . '%';
}
if ($prefs['feature_multilingual'] == 'y' && $type == 'wiki page' && $targetType == 'wiki page') {
// make sure only same lang pages are selected
$mid .= ' AND (pb.`lang` = pa.`lang` OR pa.`lang` IS NULL OR pb.`lang` IS NULL) ';
......
......@@ -29,23 +29,6 @@ class MultilingualLib extends TikiLib
function insertTranslation($type, $srcId, $srcLang, $objId, $objLang) {
global $prefs;
if ($type == 'wiki page' && $prefs['feature_wikiapproval'] == 'y') {
$srcPageName = $this->get_page_name_from_id($srcId);
$objPageName = $this->get_page_name_from_id($objId);
if ( ($stagingSrc = $this->get_staging_page( $srcPageName )) && ($stagingObj = $this->get_staging_page( $objPageName )) ) {
$srcStagingPageName = $stagingSrc;
$objStagingPageName = $stagingObj;
if ($this->page_exists($srcStagingPageName) && $this->page_exists($objStagingPageName)) {
$this->insertTranslation($type,
$this->get_page_id_from_name($srcStagingPageName),
$srcLang,
$this->get_page_id_from_name($objStagingPageName),
$objLang
);
}
}
}
$srcTrads = $this->getTrads($type, $srcId);
$objTrads = $this->getTrads($type, $objId);
......@@ -91,22 +74,6 @@ class MultilingualLib extends TikiLib
*/
function updateTranslation($type, $srcId, $objId, $objLang)
{
global $prefs;
if ($type == 'wiki page' && $prefs['feature_wikiapproval'] == 'y') {
$srcPageName = $this->get_page_name_from_id($srcId);
$objPageName = $this->get_page_name_from_id($objId);
if ( ($stagingSrc = $this->get_staging_page( $srcPageName )) && ($stagingObj = $this->get_staging_page( $objPageName )) ) {
$srcStagingPageName = $stagingSrc;
$objStagingPageName = $stagingObj;
if ($this->page_exists($srcStagingPageName) && $this->page_exists($objStagingPageName)) {
$this->updateTranslation($type,
$this->get_page_id_from_name($srcStagingPageName),
$this->get_page_id_from_name($objStagingPageName),
$objLang
);
}
}
}
$query = "update `tiki_translated_objects` set `objId`=? where `type`=? and `srcId`=? and `lang`=?";
$this->query($query, array($objId, $type, $srcId, $objLang));
}
......@@ -209,16 +176,6 @@ class MultilingualLib extends TikiLib
*/
function detachTranslation($type, $objId)
{
global $prefs;
if ($type == 'wiki page' && $prefs['feature_wikiapproval'] == 'y') {
$objPageName = $this->get_page_name_from_id($objId);
if ( $stagingObj = $this->get_staging_page( $objPageName ) ) {
$objStagingPageName = $stagingObj;
if ($this->page_exists($objStagingPageName)) {
$this->detachTranslation($type, $this->get_page_id_from_name($objStagingPageName));
}
}
}
$query = "delete from `tiki_translated_objects` where `type`= ? and `objId`=?";
$this->query($query,array($type, $objId));
//@@TODO: delete the set if only one remaining object - not necesary but will clean the table
......@@ -671,12 +628,7 @@ class MultilingualLib extends TikiLib
$pages = array();
global $prefs;
while ( $row = $result->fetchRow() ) {
// add pagename of approved page if it is a staging page
if ( $approved = $this->get_approved_page( $row['page'] ) ) {
$row['approvedPage'] = $approved;
}
if ( $prefs['feature_urgent_translation_master_only'] != 'y' || $row['lang'] == $prefs['site_language'] ) {
if ( $row['lang'] == $prefs['site_language'] ) {
$pages[] = $row;
}
}
......
......@@ -771,12 +771,6 @@ function prefs_feature_list($partial = false) {
'type' => 'flag',
'default' => 'n',
),
'feature_urgent_translation_master_only' => array(
'name' => tra('Only allow urgent translation from site language'),
'description' => tra('Use the site language as a master language and prevent translations from sending critical updates.'),
'type' => 'flag',
'default' => 'n',
),
'feature_translation_incomplete_notice' => array(
'name' => tra('Incomplete translation notice'),
'description' => tra('When a page is translated to a new language, a notice will be automatically inserted into the page to indicate that the translation is not yet complete.'),
......@@ -1824,19 +1818,6 @@ function prefs_feature_list($partial = false) {
'type' => 'flag',
'default' => 'n',
),
'feature_wikiapproval' => array(
'name' => tra('Use wiki page staging and approval'),
'type' => 'flag',
'help' => 'Wiki+Page+Staging+and+Approval',
'perspective' => false,
'dependencies' => array (
'feature_categories'
),
'warning' => tra('This feature is experimental'),
'tags' => array('experimental'),
'description' => tra('Allows wiki pages to be staged (drafted) before they are approved (published)'),
'default' => 'n',
),
'feature_listorphanStructure' => array(
'name' => tra('Pages not in structure'),
'type' => 'flag',
......
<?php
// (c) Copyright 2002-2011 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$
function prefs_wikiapproval_list($partial = false) {
global $prefs;
$staging_catree = array();
if (! $partial && $prefs['feature_categories'] == 'y') {
global $categlib;
include_once ('lib/categories/categlib.php');
$all_categs = $categlib->get_all_categories();
$staging_catree['0'] = tra('None');
foreach ($all_categs as $categ)
{
$staging_catree[$categ['categId']] = $categ['categpath'];
}
}
global $userlib;
$all_groups = $partial ? array() : $userlib->list_all_groups();
$staging_groups = array();
$staging_groups['-1'] = tra('None');
foreach ($all_groups as $group) {
$staging_groups[$group] = $group;
}
return array(
'wikiapproval_block_editapproved' => array(
'name' => tra('Force bounce of editing of approved pages to staging'),
'type' => 'flag',
'default' => 'n',
),
'wikiapproval_delete_staging' => array(
'name' => tra('Delete staging pages at approval'),
'type' => 'flag',
'default' => 'n',
),
'wikiapproval_prefix' => array(
'name' => tra('Unique page name prefix to indicate staging copy'),
'type' => 'text',
'size' => '15',
'default' => '*',
),
'wikiapproval_hideprefix' => array(
'name' => tra('Hide page name prefix'),
'type' => 'flag',
'default' => 'n',
),
'wikiapproval_sync_categories' => array(
'name' => tra('Categorize approved pages with categories of staging copy on approval'),
'type' => 'flag',
'default' => 'n',
),
'wikiapproval_update_freetags' => array(
'name' => tra('Replace freetags with that of staging pages, on approval'),
'type' => 'flag',
'dependencies' => array(
'feature_freetags',
),
'default' => 'n',
),
'wikiapproval_combine_freetags' => array(
'name' => tra('Add new freetags of approved copy (into tags field) when editing staging pages'),
'type' => 'flag',
'dependencies' => array(
'feature_freetags',
),
'default' => 'n',
),
'wikiapproval_staging_category' => array(
'name' => tra('Staging'),
'type' => 'list',
'options' => $staging_catree,
'dependencies' => array(
'feature_categories',
),
'default' => '0',
),
'wikiapproval_approved_category' => array(
'name' => tra('Approved') . ' ' . tra('(mandatory for feature to work)'),
'type' => 'list',
'options' => $staging_catree,
'dependencies' => array(
'feature_categories',
),
'default' => '0',
),
'wikiapproval_outofsync_category' => array(
'name' => tra('Out-of-sync'),
'type' => 'list',
'options' => $staging_catree,
'dependencies' => array(
'feature_categories',
),
'default' => '0',
),
'wikiapproval_master_group' => array(
'name' => tra('If not in the group, edit is always redirected to the staging page edit'),
'type' => 'list',
'options' => $staging_groups,
'default' => '-1',
),
);
}
......@@ -30,15 +30,6 @@ class RankLib extends TikiLib
$mid .= ")";
}
if ($prefs['feature_wikiapproval'] == 'y') {
if ($mid) {
$mid .= " AND tp.`pageName` not like ?";
} else {
$mid .= " WHERE tp.`pageName` not like ?";
}
$bindvals[] = $prefs['wikiapproval_prefix'] . '%';
}
$query = "select distinct tp.`pageName`, tp.`hits`, tp.`lang`, tp.`page_id` from `tiki_pages` tp $mid order by `hits` desc";
$result = $this->query($query, $bindvals);
......@@ -98,14 +89,6 @@ class RankLib extends TikiLib
}
$mid .= ")";
}
if ($prefs['feature_wikiapproval'] == 'y') {
if ($mid) {
$mid .= " AND tp.`pageName` not like ?";
} else {
$mid .= " WHERE tp.`pageName` not like ?";
}
$bindvals[] = $prefs['wikiapproval_prefix'] . '%';
}
$query = "select tp.`pageName`, tp.`pageRank` from `tiki_pages` tp $mid order by `pageRank` desc";
......@@ -144,14 +127,6 @@ class RankLib extends TikiLib
}
$mid .= ")";
}
if ($prefs['feature_wikiapproval'] == 'y') {
if ($mid) {
$mid .= " AND tp.`pageName` not like ?";
} else {
$mid .= " WHERE tp.`pageName` not like ?";
}
$bindvals[] = $prefs['wikiapproval_prefix'] . '%';
}
$query = "select tp.`pageName`, tp.`lastModif`, tp.`hits` from `tiki_pages` tp $mid order by `lastModif` desc";
......@@ -183,10 +158,8 @@ class RankLib extends TikiLib
function forums_ranking_last_posts($limit, $toponly=false, $forumId='')
{
global $user, $commentslib; require_once 'lib/comments/commentslib.php';
if (! $commentslib) {
$commentslib = new Comments;
}
global $user;
$commentslib = TikiLib::lib('comments');
$offset=0;
$count = 0;
$ret = array();
......
......@@ -8198,37 +8198,6 @@ JS;
return $result;
}
/**
* Returns the approved page name or null if not a staging page or staging is disabled.
*/
function get_approved_page( $page ) {
global $prefs;
$prefixLen = strlen( $prefs['wikiapproval_prefix'] );
$prefix = substr( $page, 0, $prefixLen );
if( $prefs['feature_wikiapproval'] == 'y' && $prefix == $prefs['wikiapproval_prefix'] ) {
return substr($page, $prefixLen );
}
}
function get_staging_page( $page ) {
global $prefs;
$prefixLen = strlen( $prefs['wikiapproval_prefix'] );
$prefix = substr( $page, 0, $prefixLen );
if( $prefs['feature_wikiapproval'] == 'y' && $prefix != $prefs['wikiapproval_prefix'] ) {
return $prefs['wikiapproval_prefix'] . $page;
}
}
function get_approved_page_or_self( $page ) {
if( $app = $this->get_approved_page( $page ) ) {
return $app;
} else {
return $page;
}
}
protected function rename_object( $type, $old, $new ) {
global $prefs;
......
......@@ -45,9 +45,6 @@ class EditLib
function user_needs_to_specify_language_of_page_to_be_created($page, $page_info, $new_page_inherited_attributes = null) {
global $_REQUEST, $multilinguallib, $prefs, $tikilib;
if ($prefs['feature_wikiapproval'] == 'y' && substr($page, 0, strlen($prefs['wikiapproval_prefix'])) == $prefs['wikiapproval_prefix'] && $tikilib->page_exists($tikilib->get_approved_page($page))) {
return false;
}
if (isset($_REQUEST['need_lang']) && $_REQUEST['need_lang'] == 'n') {
return false;
}
......
......@@ -62,11 +62,6 @@ class HistLib extends TikiLib
$res = $result->fetchRow();
global $prefs;
if ($prefs['feature_wikiapproval'] == 'y') {
// for approval and staging feature to work properly, one has to use real commit time of rollbacks
//TODO: make this feature to set rollback time as current time as more general optional feature
$res["lastModif"] = time();
}
// add rollback comment to existing one (after truncating if needed)
$ver_comment = " [" . tra("rollback version ") . $version . "]";
$too_long = 200 - strlen($res["comment"] . $ver_comment);
......@@ -1204,31 +1199,5 @@ function rollback_page_to_version($page, $version, $check_key = true, $keep_last
}
$histlib->use_version($page, $version, '', $keep_lastModif);
if ( ($approved = $tikilib->get_approved_page($page)) && $prefs['wikiapproval_outofsync_category'] > 0) {
$approved_page = $histlib->get_page_from_history($approved, 0, true);
$staging_page = $histlib->get_page_from_history($page, $version, true);
$cat_type='wiki page';
$staging_cats = $categlib->get_object_categories($cat_type, $page);
$s_cat_desc = ($prefs['feature_wiki_description'] == 'y') ? substr($staging_info["description"],0,200) : '';
$s_cat_objid = $page;
$s_cat_name = $page;
$s_cat_href="tiki-index.php?page=".urlencode($s_cat_objid);
//Instead of firing up diff, just check if the pages share the same exact data, drop the staging
//copy out of the review category if so
if ( $approved_page["data"] != $staging_page["data"] ) //compare these only once
$pages_diff = true;
if ( in_array($prefs['wikiapproval_outofsync_category'], $staging_cats) )
$in_staging_cat = true;
if ( !$pages_diff && $in_staging_cat ) {
$staging_cats = array_diff($staging_cats,Array($prefs['wikiapproval_outofsync_category']));
$categlib->update_object_categories($staging_cats, $s_cat_objid, $cat_type, $s_cat_desc, $s_cat_name, $s_cat_href);
} elseif ( $pages_diff && !$in_staging_cat ) {
$staging_cats[] = $prefs['wikiapproval_outofsync_category'];
$categlib->update_object_categories($staging_cats, $s_cat_objid, $cat_type, $s_cat_desc, $s_cat_name, $s_cat_href);
}
}
$tikilib->invalidate_cache( $page );
}
......@@ -37,7 +37,6 @@ class WikiRenderer
'setupCategories',
'setupPoll',
'setupBreadcrumbs',
'setupStaging',
);
private $toRestore = array();
......@@ -185,13 +184,13 @@ class WikiRenderer
private function setupMultilingual() // {{{
{
global $multilinguallib, $tikilib, $prefs;
global $prefs;
if ($prefs['feature_multilingual'] != 'y')
return;
include_once('lib/multilingual/multilinguallib.php');
require_once('lib/core/Multilingual/MachineTranslation/GoogleTranslateWrapper.php');
$tikilib = TikiLib::lib('tiki');
$multilinguallib = TikiLib::lib('multilingual');
if( !empty($this->info['lang'])) {
$this->trads = $multilinguallib->getTranslations('wiki page', $this->info['page_id'], $this->page, $this->info['lang']);
......@@ -207,26 +206,11 @@ class WikiRenderer
$this->smartyassign('langsCandidatesForMachineTranslation', $langsCandidatesForMachineTranslation);
}
$stagingEnabled = (
$prefs['feature_wikiapproval'] == 'y'
&& $tikilib->page_exists($prefs['wikiapproval_prefix'] . $this->page) );
if ( $stagingEnabled ) {
// temporary fix: simply use info of staging page to determine critical translation bits
// TODO: better system of dealing with translation bits with approval
$stagingPageId = $tikilib->get_page_id_from_name($prefs['wikiapproval_prefix'] . $this->page);
$bits = $multilinguallib->getMissingTranslationBits( 'wiki page', $stagingPageId, 'critical', true );
} else {
$bits = $multilinguallib->getMissingTranslationBits( 'wiki page', $this->info['page_id'], 'critical', true );
}
$bits = $multilinguallib->getMissingTranslationBits( 'wiki page', $this->info['page_id'], 'critical', true );
$alertData = array();
foreach( $bits as $translationBit ) {
if ( $stagingEnabled ) {
$alertData[] = $multilinguallib->getTranslationsWithBit( $translationBit, $stagingPageId );
} else {
$alertData[] = $multilinguallib->getTranslationsWithBit( $translationBit, $this->info['page_id'] );
}
$alertData[] = $multilinguallib->getTranslationsWithBit( $translationBit, $this->info['page_id'] );
}
$this->smartyassign( 'translation_alert', $alertData );
......@@ -522,54 +506,6 @@ class WikiRenderer
$this->smartyassign('trail', $crumbs);