issue #9 config option to disable media revisions, auth
This commit is contained in:
parent
6dd095f599
commit
e5d185e17e
|
@ -20,6 +20,7 @@ $conf['basedir'] = ''; //absolute dir from serveroot - blank
|
|||
$conf['baseurl'] = ''; //URL to server including protocol - blank for autodetect
|
||||
$conf['savedir'] = './data'; //where to store all the files
|
||||
$conf['allowdebug'] = 0; //allow debug output, enable if needed 0|1
|
||||
$conf['mediarevisions'] = 1; //enable/disable media revisions
|
||||
|
||||
/* Display Options */
|
||||
|
||||
|
|
5
feed.php
5
feed.php
|
@ -410,10 +410,11 @@ function rss_buildItems(&$rss,&$data,$opt){
|
|||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
function rssRecentChanges($opt){
|
||||
global $conf;
|
||||
$flags = RECENTS_SKIP_DELETED;
|
||||
if(!$opt['show_minor']) $flags += RECENTS_SKIP_MINORS;
|
||||
if($opt['content_type'] == 'media') $flags += RECENTS_MEDIA_CHANGES;
|
||||
if($opt['content_type'] == 'both') $flags += RECENTS_MEDIA_PAGES_MIXED;
|
||||
if($opt['content_type'] == 'media' && $conf['mediarevisions']) $flags += RECENTS_MEDIA_CHANGES;
|
||||
if($opt['content_type'] == 'both' && $conf['mediarevisions']) $flags += RECENTS_MEDIA_PAGES_MIXED;
|
||||
|
||||
$recents = getRecents(0,$opt['items'],$opt['namespace'],$flags);
|
||||
return $recents;
|
||||
|
|
29
inc/html.php
29
inc/html.php
|
@ -626,11 +626,12 @@ function html_recent($first=0, $show_changes='both'){
|
|||
* decide if this is the last page or is there another one.
|
||||
* This is the cheapest solution to get this information.
|
||||
*/
|
||||
if ($show_changes == 'mediafiles') {
|
||||
$flags = 0;
|
||||
if ($show_changes == 'mediafiles' && $conf['mediarevisions']) {
|
||||
$flags = RECENTS_MEDIA_CHANGES;
|
||||
} elseif ($show_changes == 'pages') {
|
||||
$flags = 0;
|
||||
} else {
|
||||
} elseif ($conf['mediarevisions']) {
|
||||
$show_changes = 'both';
|
||||
$flags = RECENTS_MEDIA_PAGES_MIXED;
|
||||
}
|
||||
|
@ -656,18 +657,20 @@ function html_recent($first=0, $show_changes='both'){
|
|||
$form->addHidden('do', 'recent');
|
||||
$form->addHidden('id', $ID);
|
||||
|
||||
$form->addElement(form_makeListboxField(
|
||||
'show_changes',
|
||||
array(
|
||||
'pages' => $lang['pages_changes'],
|
||||
'mediafiles' => $lang['media_changes'],
|
||||
'both' => $lang['both_changes']),
|
||||
$show_changes,
|
||||
$lang['changes_type'],
|
||||
'','',
|
||||
array('class'=>'quickselect')));
|
||||
if ($conf['mediarevisions']) {
|
||||
$form->addElement(form_makeListboxField(
|
||||
'show_changes',
|
||||
array(
|
||||
'pages' => $lang['pages_changes'],
|
||||
'mediafiles' => $lang['media_changes'],
|
||||
'both' => $lang['both_changes']),
|
||||
$show_changes,
|
||||
$lang['changes_type'],
|
||||
'','',
|
||||
array('class'=>'quickselect')));
|
||||
|
||||
$form->addElement(form_makeButton('submit', 'recent', $lang['btn_apply']));
|
||||
$form->addElement(form_makeButton('submit', 'recent', $lang['btn_apply']));
|
||||
}
|
||||
|
||||
$form->addElement(form_makeOpenTag('ul'));
|
||||
|
||||
|
|
|
@ -331,7 +331,8 @@ function media_save($file, $id, $ow, $auth, $move) {
|
|||
|
||||
//check for overwrite
|
||||
$overwrite = @file_exists($fn);
|
||||
if($overwrite && (!$ow || $auth < AUTH_DELETE)) {
|
||||
$auth_ow = (($conf['mediarevisions']) ? AUTH_UPLOAD : AUTH_DELETE);
|
||||
if($overwrite && (!$ow || $auth < $auth_ow)) {
|
||||
return array($lang['uploadexist'], 0);
|
||||
}
|
||||
// check for valid content
|
||||
|
@ -426,6 +427,8 @@ function media_saveOldRevision($id){
|
|||
$oldf = mediaFN($id);
|
||||
if(!@file_exists($oldf)) return '';
|
||||
$date = filemtime($oldf);
|
||||
if (!$conf['mediarevisions']) return $date;
|
||||
|
||||
$newf = mediaFN($id,$date);
|
||||
io_makeFileDir($newf);
|
||||
if(copy($oldf, $newf)) {
|
||||
|
@ -503,7 +506,7 @@ function media_notify($id,$file,$mime,$old_rev=false){
|
|||
$text = str_replace('@MIME@',$mime,$text);
|
||||
$text = str_replace('@MEDIA@',ml($id,'',true,'&',true),$text);
|
||||
$text = str_replace('@SIZE@',filesize_h(filesize($file)),$text);
|
||||
if ($old_rev) {
|
||||
if ($old_rev && $conf['mediarevisions']) {
|
||||
$text = str_replace('@OLD@', ml($id, "rev=$old_rev", true, '&', true), $text);
|
||||
} else {
|
||||
$text = str_replace('@OLD@', '', $text);
|
||||
|
@ -593,7 +596,7 @@ function media_tabs_files($selected=false){
|
|||
* @param string $selected - opened tab
|
||||
*/
|
||||
function media_tabs_details($image, $selected=false){
|
||||
global $lang;
|
||||
global $lang, $conf;
|
||||
|
||||
echo '<div class="mediamanager-tabs" id="mediamanager__tabs_details">';
|
||||
|
||||
|
@ -603,7 +606,9 @@ function media_tabs_details($image, $selected=false){
|
|||
if ($mime == 'image/jpeg') {
|
||||
media_tab(media_managerURL(array('tab_details' => 'edit')), 'edit', $lang['media_edittab'], $selected);
|
||||
}
|
||||
media_tab(media_managerURL(array('tab_details' => 'history')), 'history', $lang['media_historytab'], $selected);
|
||||
if ($conf['mediarevisions']) {
|
||||
media_tab(media_managerURL(array('tab_details' => 'history')), 'history', $lang['media_historytab'], $selected);
|
||||
}
|
||||
|
||||
echo '<div class="clearer"></div>';
|
||||
echo '</div>';
|
||||
|
@ -849,7 +854,7 @@ function media_preview($image, $auth, $rev=false, $meta=false) {
|
|||
* @author Kate Arzamastseva <pshns@ukr.net>
|
||||
*/
|
||||
function media_preview_buttons($image, $auth, $rev=false) {
|
||||
global $lang;
|
||||
global $lang, $conf;
|
||||
|
||||
echo '<div id="mediamanager__preview_buttons">';
|
||||
|
||||
|
@ -875,6 +880,11 @@ function media_preview_buttons($image, $auth, $rev=false) {
|
|||
$form->addElement(form_makeButton('submit','',$lang['btn_delete']));
|
||||
$form->printForm();
|
||||
|
||||
}
|
||||
|
||||
$auth_ow = (($conf['mediarevisions']) ? AUTH_UPLOAD : AUTH_DELETE);
|
||||
if($auth >= $auth_ow && !$rev){
|
||||
|
||||
// upload new version button
|
||||
$form = new Doku_Form(array('id' => 'mediamanager__btn_update',
|
||||
'action'=>media_managerURL(array('image' => $image, 'mediado' => 'update'), '&')));
|
||||
|
@ -882,7 +892,7 @@ function media_preview_buttons($image, $auth, $rev=false) {
|
|||
$form->printForm();
|
||||
}
|
||||
|
||||
if($auth >= AUTH_DELETE && $rev){
|
||||
if($auth >= AUTH_DELETE && $rev && $conf['mediarevisions']){
|
||||
|
||||
// restore button
|
||||
$form = new Doku_Form(array('id' => 'mediamanager__btn_restore',
|
||||
|
@ -1001,7 +1011,7 @@ function media_diff($image, $ns, $auth) {
|
|||
global $lang;
|
||||
global $conf;
|
||||
|
||||
if ($auth < AUTH_READ || !$image) return '';
|
||||
if ($auth < AUTH_READ || !$image || !$conf['mediarevisions']) return '';
|
||||
|
||||
$rev1 = (int) $_REQUEST['rev'];
|
||||
|
||||
|
@ -1035,7 +1045,11 @@ function media_diff($image, $ns, $auth) {
|
|||
}else{ // no revision was given, compare previous to current
|
||||
$r_rev = '';
|
||||
$revs = getRevisions($image, 0, 1, 8192, true);
|
||||
$l_rev = $revs[0];
|
||||
if (file_exists(mediaFN($image, $revs[0]))) {
|
||||
$l_rev = $revs[0];
|
||||
} else {
|
||||
$l_rev = '';
|
||||
}
|
||||
}
|
||||
|
||||
// prepare event data
|
||||
|
@ -1190,7 +1204,8 @@ function media_image_diff($image, $l_rev, $r_rev, $meta, $type) {
|
|||
* @author Kate Arzamastseva <pshns@ukr.net>
|
||||
*/
|
||||
function media_restore($image, $rev, $auth){
|
||||
if ($auth < AUTH_DELETE) return false;
|
||||
global $conf;
|
||||
if ($auth < AUTH_DELETE || !$conf['mediarevisions']) return false;
|
||||
if (!$image || !file_exists(mediaFN($image))) return false;
|
||||
if (!$rev || !file_exists(mediaFN($image, $rev))) return false;
|
||||
list($iext,$imime,$dl) = mimetype($image);
|
||||
|
|
|
@ -1140,7 +1140,7 @@ function tpl_fileList(){
|
|||
global $JUMPTO;
|
||||
|
||||
$opened_tab = $_REQUEST['tab_files'];
|
||||
if (!$opened_tab) $opened_tab = 'files';
|
||||
if (!$opened_tab || !in_array($opened_tab, array('files', 'upload', 'search'))) $opened_tab = 'files';
|
||||
if ($_REQUEST['mediado'] == 'update') $opened_tab = 'upload';
|
||||
|
||||
media_tabs_files($opened_tab);
|
||||
|
@ -1172,8 +1172,7 @@ function tpl_fileList(){
|
|||
* @author Kate Arzamastseva <pshns@ukr.net>
|
||||
*/
|
||||
function tpl_fileDetails($image, $rev){
|
||||
global $AUTH;
|
||||
global $NS;
|
||||
global $AUTH, $NS, $conf;
|
||||
|
||||
if (!$image || !file_exists(mediaFN($image))) return '';
|
||||
if ($rev && !file_exists(mediaFN($image, $rev))) $rev = false;
|
||||
|
@ -1181,7 +1180,17 @@ function tpl_fileDetails($image, $rev){
|
|||
$do = $_REQUEST['mediado'];
|
||||
|
||||
$opened_tab = $_REQUEST['tab_details'];
|
||||
if (!$opened_tab) $opened_tab = 'view';
|
||||
|
||||
$tab_array = array('view');
|
||||
list($ext, $mime) = mimetype($image);
|
||||
if ($mime == 'image/jpeg') {
|
||||
$tab_array[] = 'edit';
|
||||
}
|
||||
if ($conf['mediarevisions']) {
|
||||
$tab_array[] = 'history';
|
||||
}
|
||||
|
||||
if (!$opened_tab || !in_array($opened_tab, $tab_array)) $opened_tab = 'view';
|
||||
if ($_REQUEST['edit']) $opened_tab = 'edit';
|
||||
if ($do == 'restore') $opened_tab = 'view';
|
||||
|
||||
|
@ -1197,7 +1206,7 @@ function tpl_fileDetails($image, $rev){
|
|||
media_tab_edit($image, $NS, $AUTH);
|
||||
echo '</div>';
|
||||
|
||||
} elseif ($opened_tab == 'history') {
|
||||
} elseif ($opened_tab == 'history' && $conf['mediarevisions']) {
|
||||
echo '<div id="mediamanager__details">';
|
||||
media_tab_history($image,$NS,$AUTH);
|
||||
echo '</div>';
|
||||
|
@ -1446,7 +1455,7 @@ function tpl_getFavicon($abs=false) {
|
|||
*/
|
||||
function tpl_media() {
|
||||
//
|
||||
global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen;
|
||||
global $DEL, $NS, $IMG, $AUTH, $JUMPTO, $REV, $lang, $fullscreen, $conf;
|
||||
$fullscreen = true;
|
||||
require_once(DOKU_INC.'lib/exe/mediamanager.php');
|
||||
|
||||
|
|
|
@ -84,9 +84,9 @@
|
|||
$JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']);
|
||||
}
|
||||
|
||||
if ($_REQUEST['rev']) $REV = (int) $_REQUEST['rev'];
|
||||
if ($_REQUEST['rev'] && $conf['mediarevisions']) $REV = (int) $_REQUEST['rev'];
|
||||
|
||||
if($_REQUEST['mediado'] == 'restore'){
|
||||
if($_REQUEST['mediado'] == 'restore' && $conf['mediarevisions']){
|
||||
$JUMPTO = media_restore($_REQUEST['image'], $REV, $AUTH);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue