function echo_project_state_changer($project) { global $pguser, $code_url; $transitions = get_valid_transitions($project, $pguser); if (count($transitions) > 0) { $here = $_SERVER['REQUEST_URI']; echo "\n <form\n name='{$project->projectid}'\n method='POST'\n action='{$code_url}/tools/changestate.php'>\n <input\n type='hidden'\n name='projectid'\n value='{$project->projectid}'>\n <input\n type='hidden'\n name='curr_state'\n value='{$project->state}'>\n <input\n type='hidden'\n name='return_uri'\n value='{$here}'>\n <select\n name='next_state'\n onchange='this.form.submit()'>\n "; echo_project_state_option($project->state, 1); foreach ($transitions as $transition) { echo_project_state_option($transition->to_state, 0); } echo "\n </select>\n </form>\n "; } else { echo get_medium_label_for_project_state($project->state), "\n"; } }
function do_change_state() { global $project, $pguser, $code_url, $charset; $valid_transitions = get_valid_transitions($project, $pguser); if (count($valid_transitions) == 0) { return; } echo "<h4>"; echo _("Change Project State"); echo "</h4>\n"; if ($project->state == PROJ_NEW) { echo "<p>\n"; echo _("Check for missing pages and make sure that all illustration files have been uploaded <b>before</b> moving this project into the rounds."); echo "</p>\n"; } // print out a message if PM has project loads disabled, // as they can't move a project out of the unavailable state if ($project->can_be_managed_by_current_user) { check_user_can_load_projects(false); } $here = $_SERVER['REQUEST_URI']; // If the request URI included an 'expected_state' parameter, there's a wrinkle: // If the user clicks on this button, the project's state will (normally) change. // So if we then returned the user to exactly this URI, they'd get a warning: // "The project is no longer in 'this state'. It is now in 'that state'. // So we suppress the 'expected_state' parameter from the request URI. $here = preg_replace('/expected_state=[A-Za-z._0-9]+/', '', $here); // This can leave an extra &, but I suspect browsers can handle it. foreach ($valid_transitions as $transition) { echo "<form method='POST' action='{$code_url}/tools/changestate.php'>"; echo "<input type='hidden' name='projectid' value='{$project->projectid}'>\n"; echo "<input type='hidden' name='curr_state' value='{$project->state}'>\n"; echo "<input type='hidden' name='next_state' value='{$transition->to_state}'>\n"; echo "<input type='hidden' name='confirmed' value='yes'>\n"; echo "<input type='hidden' name='return_uri' value='{$here}'>\n"; $question = $transition->confirmation_question; if (is_null($question)) { $onClick_condition = "return true;"; } else { $onClick_condition = "return confirm(\"" . javascript_safe($question, $charset) . "\");"; } $onclick_attr = "onClick='{$onClick_condition}'"; echo "<input type='submit' value='", attr_safe($transition->action_name), "' {$onclick_attr}>"; if (1) { // Say who is allowed to do this transition. echo " [{$transition->who_restriction}]"; } echo "</form>\n"; } }