1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70:
<?php
$plugin_is_filter = 5 | ADMIN_PLUGIN;
$plugin_description = gettext('Mark installation as “released”.');
$plugin_author = "Stephen Billard (sbillard)";
$plugin_category = gettext('Development');
zp_register_filter('admin_utilities_buttons', 'markRelease_button');
if (isset($_REQUEST['markRelease'])) {
XSRFdefender('markRelease');
$v = file_get_contents(SERVERPATH . '/' . ZENFOLDER . '/version.php');
preg_match_all("~(define\('ZENPHOTO_VERSION',\s*'([^']*)'\))~", $v, $matches);
$currentVersion = $matches[2][0];
if (isset($matches[2][1])) {
$originalVersion = $matches[2][1];
} else {
$originalVersion = preg_replace("~-[^RC]~i", '', $currentVersion);
}
if ($_REQUEST['markRelease'] == 'released') {
if (preg_match('~-[^RC]~i', $originalVersion)) {
$originalVersion = preg_replace('~-.*~', '', $originalVersion);
}
$version = "define('ZENPHOTO_VERSION', '$originalVersion');";
} else {
preg_match_all('~([^-]*)~', $currentVersion, $matches);
$mark = $matches[0][0] . '-DEBUG';
$version = "define('ZENPHOTO_VERSION', '$mark'); //original: define('ZENPHOTO_VERSION', '$originalVersion');";
}
$v = preg_replace("~define\('ZENPHOTO_VERSION.*\n~", $version . "\n", $v);
file_put_contents(SERVERPATH . '/' . ZENFOLDER . '/version.php', $v);
redirectURL(FULLWEBPATH . '/' . ZENFOLDER . '/admin.php');
}
function markRelease_button($buttons) {
$text = array('released' => gettext('released'), 'debug' => gettext('debug'));
if (TEST_RELEASE) {
$mark = '-DEBUG';
$action = 'released';
} else {
$mark = '';
$action = 'debug';
}
$buttons[] = array(
'category' => gettext('Development'),
'enable' => true,
'button_text' => gettext('Mark release'),
'formname' => 'markRelease_button',
'action' => FULLWEBPATH . '/' . ZENFOLDER . '/admin.php?markRelease=' . $action,
'icon' => $mark ? FULLWEBPATH . '/' . ZENFOLDER . '/images/comments-on.png' : FULLWEBPATH . '/' . ZENFOLDER . '/images/comments-off.png',
'title' => sprintf(gettext('Edits the version.php file making a “%s” install.'), $text[$action]),
'alt' => '',
'hidden' => '<input type="hidden" name="markRelease" value="' . $action . '" />',
'rights' => ADMIN_RIGHTS,
'XSRFTag' => 'markRelease'
);
return $buttons;
}
?>