/** * Constructor. */ function MetadataForm($paper) { $roleDao =& DAORegistry::getDAO('RoleDAO'); $schedConf =& Request::getSchedConf(); $user =& Request::getUser(); $roleId = $roleDao->getRoleIdFromPath(Request::getRequestedPage()); // If the user is a director of this paper, make the form editable. $this->canEdit = false; if ($roleId != null && ($roleId == ROLE_ID_DIRECTOR || $roleId == ROLE_ID_TRACK_DIRECTOR)) { $this->canEdit = true; } // Check if the author can modify metadata. if ($roleId == ROLE_ID_AUTHOR) { if (AuthorAction::mayEditPaper($paper)) { $this->canEdit = true; } } if ($this->canEdit) { parent::Form('submission/metadata/metadataEdit.tpl'); $this->addCheck(new FormValidatorLocale($this, 'title', 'required', 'author.submit.form.titleRequired')); $this->addCheck(new FormValidatorArray($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', array('firstName', 'lastName'))); $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'author.submit.form.authorRequiredFields', create_function('$email, $regExp', 'return String::regexp_match($regExp, $email);'), array(ValidatorEmail::getRegexp()), false, array('email'))); $this->addCheck(new FormValidatorArrayCustom($this, 'authors', 'required', 'user.profile.form.urlInvalid', create_function('$url, $regExp', 'return empty($url) ? true : String::regexp_match($regExp, $url);'), array(ValidatorUrl::getRegexp()), false, array('url'))); } else { parent::Form('submission/metadata/metadataView.tpl'); } // If the user is a reviewer of this paper, do not show authors. $this->canViewAuthors = true; if ($roleId != null && $roleId == ROLE_ID_REVIEWER) { $this->canViewAuthors = false; } $this->paper = $paper; $this->addCheck(new FormValidatorPost($this)); }
/** * Validate that the user is the author for the paper. * Redirects to author index page if validation fails. * @param $paperId int * @param $requiresEditAccess boolean True means that the author must * have edit access over the specified paper in order for * validation to be successful. * @param $isDeleting boolean True iff user is deleting a paper */ function validate($paperId, $requiresEditAccess = false, $isDeleting = false) { parent::validate(); $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $roleDao =& DAORegistry::getDAO('RoleDAO'); $conference =& Request::getConference(); $schedConf =& Request::getSchedConf(); $user =& Request::getUser(); $isValid = true; $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($paperId); if ($authorSubmission == null) { $isValid = false; } else { if ($authorSubmission->getSchedConfId() != $schedConf->getId()) { $isValid = false; } else { if ($authorSubmission->getUserId() != $user->getId()) { $isValid = false; } } } if ($isValid && $requiresEditAccess) { if (!AuthorAction::mayEditPaper($authorSubmission)) { $isValid = false; } } if (!$isValid) { Request::redirect(null, null, Request::getRequestedPage()); } $this->submission =& $authorSubmission; return true; }
/** * Validate that the user is the author for the paper. * Redirects to author index page if validation fails. * @param $paperId int * @param $requiresEditAccess boolean True means that the author must * have edit access over the specified paper in order for * validation to be successful. * @param $isDeleting boolean True iff user is deleting a paper, and is not * coming from an old URL (e.g. submission ack email) */ function validate($request, $paperId, $requiresEditAccess = false, $isDeleting = false) { parent::validate(); $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $roleDao =& DAORegistry::getDAO('RoleDAO'); $conference =& $request->getConference(); $schedConf =& $request->getSchedConf(); $user =& $request->getUser(); $isValid = true; $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($paperId); if ($authorSubmission == null) { $isValid = false; } else { if ($authorSubmission->getSchedConfId() != $schedConf->getId()) { $isValid = false; } else { if ($authorSubmission->getUserId() != $user->getId()) { $isValid = false; } } } if ($isValid && !$isDeleting) { // The user may be coming in on an old URL e.g. from the submission // ack email. If OCS is awaiting the completion of the submission, // send them to the submit page. if ($authorSubmission->getSubmissionProgress() != 0) { $request->redirect(null, null, null, 'submit', array($authorSubmission->getSubmissionProgress()), array('paperId' => $authorSubmission->getId())); } } if ($isValid && $requiresEditAccess) { if (!AuthorAction::mayEditPaper($authorSubmission)) { $isValid = false; } } if (!$isValid) { $request->redirect(null, null, $request->getRequestedPage()); } $this->submission =& $authorSubmission; return true; }