Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revise page_resume function #1170

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 11 additions & 24 deletions pinc/LPage.inc
Original file line number Diff line number Diff line change
Expand Up @@ -459,44 +459,31 @@ class LPage

// -----------------------------------------------------------------------------

public function resume_saved_page($pguser)
public function resume_page($pguser)
{
if ($this->page_state == $this->round->page_save_state) {
// Page comes from DONE.

// no need to update text, just record state change
$this->page_state = Page_reopen($this->projectid, $this->imagefile, $this->round, $pguser);

// When it was saved, the user's page-count was incremented.
// Now they are 'unsaving' it, so decrement their page-count.
// They'll get it back if/when they save-as-done again.
// (Plugs a former page-count cheat.)

page_tallies_add($this->round->id, $pguser, -1);
} else {
// Page comes from IN PROGRESS.

// Page comes from IN PROGRESS or OUT.
// Resuming such a page has no actual effect on the page,
// though it might in the future.

// For now, just confirm that the user is entitled to resume
// just confirm that the user is entitled to resume
// this page. (In the DONE case, Page_reopen performs this check.)

$res = DPDatabase::query("
SELECT {$this->round->user_column_name}
FROM $this->projectid
WHERE image='$this->imagefile'
");
[$current_round_user] = mysqli_fetch_row($res);

if ($pguser != $current_round_user) {
$err = sprintf(
_('You (%1$s) do not have the necessary access to page %2$s'),
$pguser,
$this->imagefile
);
throw new ProjectPageException($err);
}
_Page_require(
$this->projectid,
$this->imagefile,
[$this->round->page_out_state, $this->round->page_temp_state],
$this->round->user_column_name,
$pguser,
'resume'
);
}
}
} // end class
2 changes: 1 addition & 1 deletion tools/proofers/proof_frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

try {
$ppage = get_requested_PPage($_GET);
$ppage->lpage->resume_saved_page($pguser);
$ppage->lpage->resume_page($pguser);
} catch (ProjectException | ProjectPageException $exception) {
abort($exception->getMessage());
}
Expand Down