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