/** * Constructor. * @param $archiveId omit for a new archive */ function ArchiveForm($archiveId = null, $allowManagement = false) { parent::Form('admin/archiveForm.tpl'); $this->archiveId = isset($archiveId) ? (int) $archiveId : null; $this->allowManagement = $allowManagement; // Validation checks for this form $this->addCheck(new FormValidator($this, 'title', 'required', 'admin.archives.form.titleRequired')); $this->addCheck(new FormValidator($this, 'url', 'required', 'admin.archives.form.urlRequired')); $this->addCheck(new FormValidatorPost($this)); import('lib.pkp.classes.captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); $this->captchaEnabled = $captchaManager->isEnabled(); if ($this->captchaEnabled && !Validation::isSiteAdmin()) { $this->addCheck(new FormValidatorCaptcha($this, 'captcha', 'captchaId', 'common.captchaField.badCaptcha')); } $this->harvesterPluginName = Request::getUserVar('harvesterPluginName'); if ($archiveId) { $archiveDao =& DAORegistry::getDAO('ArchiveDAO'); $this->archive =& $archiveDao->getArchive($this->archiveId, false); if (empty($this->harvesterPluginName) && $this->archive) { $this->harvesterPluginName = $this->archive->getHarvesterPluginName(); } } if (empty($this->harvesterPluginName)) { $site =& Request::getSite(); $this->harvesterPluginName = $site->getSetting('defaultHarvesterPlugin'); } $this->harvesters =& PluginRegistry::loadCategory('harvesters'); HookRegistry::call('ArchiveForm::ArchiveForm', array(&$this, $this->harvesterPluginName)); }
/** * Constructor. */ function CommentForm($commentId, $articleId, $galleyId, $parentId = null) { parent::Form('comment/comment.tpl'); $this->articleId = $articleId; $commentDao =& DAORegistry::getDAO('CommentDAO'); $this->comment =& $commentDao->getById($commentId, $articleId); import('lib.pkp.classes.captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); $this->captchaEnabled = $captchaManager->isEnabled() && Config::getVar('captcha', 'captcha_on_comments') ? true : false; if ($this->captchaEnabled) { $this->reCaptchaEnabled = Config::getVar('captcha', 'recaptcha') ? true : false; } if (isset($this->comment)) { $this->commentId = $commentId; } $this->parentId = $parentId; $this->galleyId = $galleyId; $this->addCheck(new FormValidator($this, 'title', 'required', 'comments.titleRequired')); if ($this->captchaEnabled) { if ($this->reCaptchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } else { $this->addCheck(new FormValidatorCaptcha($this, 'captcha', 'captchaId', 'common.captchaField.badCaptcha')); } } $this->addCheck(new FormValidatorPost($this)); }
/** * Constructor * @param $typeId int Registration type to use */ function UserRegistrationForm($typeId) { $schedConf =& Request::getSchedConf(); $this->typeId = (int) $typeId; parent::Form('registration/userRegistrationForm.tpl'); $this->addCheck(new FormValidatorCustom($this, 'registrationTypeId', 'required', 'manager.registration.form.typeIdValid', create_function('$registrationTypeId, $schedConfId, $typeId', '$registrationTypeDao =& DAORegistry::getDAO(\'RegistrationTypeDAO\'); return $registrationTypeDao->openRegistrationTypeExistsByTypeId($typeId, $schedConfId);'), array($schedConf->getId(), $typeId))); import('captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); $this->captchaEnabled = $captchaManager->isEnabled() && Config::getVar('captcha', 'captcha_on_register') ? true : false; $user =& Request::getUser(); if (!$user) { $site =& Request::getSite(); $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired')); $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired')); $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.account.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true)); $this->addCheck(new FormValidatorAlphaNum($this, 'username', 'required', 'user.account.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.account.form.passwordLengthTooShort', '>=', $site->getMinPasswordLength())); $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.account.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this))); $this->addCheck(new FormValidator($this, 'firstName', 'required', 'user.profile.form.firstNameRequired')); $this->addCheck(new FormValidator($this, 'lastName', 'required', 'user.profile.form.lastNameRequired')); $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.account.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true)); if ($this->captchaEnabled) { $this->addCheck(new FormValidatorCaptcha($this, 'captcha', 'captchaId', 'common.captchaField.badCaptcha')); } $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $this->defaultAuth =& $authDao->getDefaultPlugin(); if (isset($this->defaultAuth)) { $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.account.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth))); } } $this->addCheck(new FormValidatorPost($this)); }
/** * Constructor. */ function RegistrationForm() { parent::Form('user/register.tpl'); import('lib.pkp.classes.captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); $this->captchaEnabled = $captchaManager->isEnabled() && Config::getVar('captcha', 'captcha_on_register') ? true : false; // Validation checks for this form $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired')); $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired')); $site =& Request::getSite(); $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true)); $this->addCheck(new FormValidatorAlphaNum($this, 'username', 'required', 'user.register.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.register.form.passwordLengthTooShort', '>=', $site->getMinPasswordLength())); $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.register.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this))); $this->addCheck(new FormValidator($this, 'firstName', 'required', 'user.profile.form.firstNameRequired')); $this->addCheck(new FormValidator($this, 'lastName', 'required', 'user.profile.form.lastNameRequired')); $this->addCheck(new FormValidatorUrl($this, 'userUrl', 'optional', 'user.profile.form.urlInvalid')); $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true)); if ($this->captchaEnabled) { $this->addCheck(new FormValidatorCaptcha($this, 'captcha', 'captchaId', 'common.captchaField.badCaptcha')); } $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $this->defaultAuth =& $authDao->getDefaultPlugin(); if (isset($this->defaultAuth)) { $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth))); } $this->addCheck(new FormValidatorPost($this)); }
/** * Constructor * @param $parentPluginName string Name of parent plugin * @param $thesisId int leave as default for new thesis */ function StudentThesisForm($parentPluginName, $thesisId = null) { $journal =& Request::getJournal(); $journalId = $journal->getId(); $this->parentPluginName = $parentPluginName; $thesisPlugin =& PluginRegistry::getPlugin('generic', $parentPluginName); $thesisPlugin->import('Thesis'); $this->validDegrees = array(THESIS_DEGREE_MASTERS => Locale::translate('plugins.generic.thesis.manager.degree.masters'), THESIS_DEGREE_DOCTORATE => Locale::translate('plugins.generic.thesis.manager.degree.doctorate')); import('lib.pkp.classes.captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); $this->captchaEnabled = $captchaManager->isEnabled() ? true : false; $this->uploadCodeEnabled = $thesisPlugin->getSetting($journalId, 'enableUploadCode'); parent::Form($thesisPlugin->getTemplatePath() . 'studentThesisForm.tpl'); // Captcha support if enabled if ($this->captchaEnabled) { $this->addCheck(new FormValidatorCaptcha($this, 'captcha', 'captchaId', 'common.captchaField.badCaptcha')); } // Degree is provided and is valid value $this->addCheck(new FormValidator($this, 'degree', 'required', 'plugins.generic.thesis.form.degreeRequired')); $this->addCheck(new FormValidatorInSet($this, 'degree', 'required', 'plugins.generic.thesis.form.degreeValid', array_keys($this->validDegrees))); // Degree Name is provided $this->addCheck(new FormValidator($this, 'degreeName', 'required', 'plugins.generic.thesis.form.degreeNameRequired')); // Department is provided $this->addCheck(new FormValidator($this, 'department', 'required', 'plugins.generic.thesis.form.departmentRequired')); // University is provided $this->addCheck(new FormValidator($this, 'university', 'required', 'plugins.generic.thesis.form.universityRequired')); // Approval date is provided and valid $this->addCheck(new FormValidator($this, 'dateApprovedYear', 'required', 'plugins.generic.thesis.form.dateApprovedRequired')); $this->addCheck(new FormValidatorCustom($this, 'dateApprovedYear', 'required', 'plugins.generic.thesis.form.dateApprovedValid', create_function('$dateApprovedYear', '$minYear = date(\'Y\') + THESIS_APPROVED_YEAR_OFFSET_PAST; $maxYear = date(\'Y\'); return ($dateApprovedYear >= $minYear && $dateApprovedYear <= $maxYear) ? true : false;'))); $this->addCheck(new FormValidator($this, 'dateApprovedMonth', 'required', 'plugins.generic.thesis.form.dateApprovedRequired')); $this->addCheck(new FormValidatorCustom($this, 'dateApprovedMonth', 'required', 'plugins.generic.thesis.form.dateApprovedValid', create_function('$dateApprovedMonth', 'return ($dateApprovedMonth >= 1 && $dateApprovedMonth <= 12) ? true : false;'))); $this->addCheck(new FormValidator($this, 'dateApprovedDay', 'required', 'plugins.generic.thesis.form.dateApprovedRequired')); $this->addCheck(new FormValidatorCustom($this, 'dateApprovedDay', 'required', 'plugins.generic.thesis.form.dateApprovedValid', create_function('$dateApprovedDay', 'return ($dateApprovedDay >= 1 && $dateApprovedDay <= 31) ? true : false;'))); // Title is provided $this->addCheck(new FormValidator($this, 'title', 'required', 'plugins.generic.thesis.form.titleRequired')); // Student first name is provided $this->addCheck(new FormValidator($this, 'studentFirstName', 'required', 'plugins.generic.thesis.form.studentFirstNameRequired')); // Student last name is provided $this->addCheck(new FormValidator($this, 'studentLastName', 'required', 'plugins.generic.thesis.form.studentLastNameRequired')); // Student email is provided and valid $this->addCheck(new FormValidatorEmail($this, 'studentEmail', 'required', 'plugins.generic.thesis.form.studentEmailValid')); // Supervisor first name is provided $this->addCheck(new FormValidator($this, 'supervisorFirstName', 'required', 'plugins.generic.thesis.form.supervisorFirstNameRequired')); // Supervisor last name is provided $this->addCheck(new FormValidator($this, 'supervisorLastName', 'required', 'plugins.generic.thesis.form.supervisorLastNameRequired')); // Supervisor email is provided $this->addCheck(new FormValidatorEmail($this, 'supervisorEmail', 'required', 'plugins.generic.thesis.form.supervisorEmailValid')); // Abstract is provided $this->addCheck(new FormValidator($this, 'abstract', 'required', 'plugins.generic.thesis.form.abstractRequired')); $this->addCheck(new FormValidatorPost($this)); }
/** * Constructor. */ function RegistrationForm() { parent::Form('user/register.tpl'); $this->implicitAuth = Config::getVar('security', 'implicit_auth'); if ($this->implicitAuth) { // If implicit auth - it is always an existing user $this->existingUser = 1; } else { $this->existingUser = Request::getUserVar('existingUser') ? 1 : 0; import('lib.pkp.classes.captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); $this->captchaEnabled = $captchaManager->isEnabled() && Config::getVar('captcha', 'captcha_on_register') ? true : false; if ($this->captchaEnabled) { $this->reCaptchaEnabled = Config::getVar('captcha', 'recaptcha') ? true : false; } // Validation checks for this form $this->addCheck(new FormValidator($this, 'username', 'required', 'user.profile.form.usernameRequired')); $this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.passwordRequired')); if ($this->existingUser) { // Existing user -- check login $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.login.loginError', create_function('$username,$form', 'return Validation::checkCredentials($form->getData(\'username\'), $form->getData(\'password\'));'), array(&$this))); } else { // New user -- check required profile fields $site =& Request::getSite(); $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByUsername'), array(), true)); $this->addCheck(new FormValidatorAlphaNum($this, 'username', 'required', 'user.register.form.usernameAlphaNumeric')); $this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.register.form.passwordLengthTooShort', '>=', $site->getMinPasswordLength())); $this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.register.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this))); $this->addCheck(new FormValidator($this, 'firstName', 'required', 'user.profile.form.firstNameRequired')); $this->addCheck(new FormValidator($this, 'lastName', 'required', 'user.profile.form.lastNameRequired')); $this->addCheck(new FormValidatorUrl($this, 'userUrl', 'optional', 'user.profile.form.urlInvalid')); $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'user.profile.form.emailRequired')); $this->addCheck(new FormValidatorORCID($this, 'orcid', 'optional', 'user.profile.form.orcidInvalid')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailsDoNotMatch', create_function('$email,$form', 'return $email == $form->getData(\'confirmEmail\');'), array(&$this))); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailExists', array(DAORegistry::getDAO('UserDAO'), 'userExistsByEmail'), array(), true)); if ($this->captchaEnabled) { if ($this->reCaptchaEnabled) { $this->addCheck(new FormValidatorReCaptcha($this, 'recaptcha_challenge_field', 'recaptcha_response_field', Request::getRemoteAddr(), 'common.captchaField.badCaptcha')); } else { $this->addCheck(new FormValidatorCaptcha($this, 'captcha', 'captchaId', 'common.captchaField.badCaptcha')); } } $authDao =& DAORegistry::getDAO('AuthSourceDAO'); $this->defaultAuth =& $authDao->getDefaultPlugin(); if (isset($this->defaultAuth)) { $this->addCheck(new FormValidatorCustom($this, 'username', 'required', 'user.register.form.usernameExists', create_function('$username,$form,$auth', 'return (!$auth->userExists($username) || $auth->authenticate($username, $form->getData(\'password\')));'), array(&$this, $this->defaultAuth))); } } } $this->addCheck(new FormValidatorPost($this)); }
/** * Constructor. */ function NotificationMailingListForm() { parent::Form('notification/maillist.tpl'); import('lib.pkp.classes.captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); $this->captchaEnabled = $captchaManager->isEnabled() && Config::getVar('captcha', 'captcha_on_mailinglist') ? true : false; // Validation checks for this form if ($this->captchaEnabled) { $this->addCheck(new FormValidatorCaptcha($this, 'captcha', 'captchaId', 'common.captchaField.badCaptcha')); } $this->addCheck(new FormValidatorPost($this)); $this->addCheck(new FormValidatorEmail($this, 'email', 'required', 'notification.mailList.emailInvalid')); $this->addCheck(new FormValidatorCustom($this, 'email', 'required', 'user.register.form.emailsDoNotMatch', create_function('$email,$form', 'return $email == $form->getData(\'confirmEmail\');'), array(&$this))); }
/** * Constructor. */ function CommentForm($commentId, $paperId, $galleyId, $parentId = null) { parent::Form('comment/comment.tpl'); $this->paperId = $paperId; $commentDao =& DAORegistry::getDAO('CommentDAO'); $this->comment =& $commentDao->getComment($commentId, $paperId); import('captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); $this->captchaEnabled = $captchaManager->isEnabled() && Config::getVar('captcha', 'captcha_on_comments') ? true : false; if (isset($this->comment)) { $this->commentId = $commentId; } $this->parentId = $parentId; $this->galleyId = $galleyId; $this->addCheck(new FormValidator($this, 'title', 'required', 'comments.titleRequired')); if ($this->captchaEnabled) { $this->addCheck(new FormValidatorCaptcha($this, 'captcha', 'captchaId', 'common.captchaField.badCaptcha')); } $this->addCheck(new FormValidatorPost($this)); }
function viewCaptcha($args) { $captchaId = (int) array_shift($args); import('captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); if ($captchaManager->isEnabled()) { $captchaDao =& DAORegistry::getDAO('CaptchaDAO'); $captcha =& $captchaDao->getCaptcha($captchaId); if ($captcha) { $captchaManager->generateImage($captcha); exit; } } Request::redirect(null, null, 'user'); }
/** * Captcha support. */ function viewCaptcha($args) { $this->validate(); $captchaId = (int) array_shift($args); import('lib.pkp.classes.captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); if ($captchaManager->isEnabled()) { $captchaDao =& DAORegistry::getDAO('CaptchaDAO'); $captcha =& $captchaDao->getCaptcha($captchaId); if ($captcha) { $captchaManager->generateImage($captcha); exit; } } Request::redirect(null, 'thesis'); }
<label for="chkThumbSize[]"> <span class="pad20"> <?php echo $l->m('in_020'); ?> </span> </label> <div id="fmtDiv"> <?php echo thumbSizes($cfg['thumbs']); ?> </div> </div> <?php if ($cfg['captcha']) { import('captcha.CaptchaManager'); $captchaManager = new CaptchaManager(); if ($captchaManager->isEnabled()) { $captcha = $captchaManager->createCaptcha(); ?> <div class="rowDiv"> <label for="captchaPic"> <span class="pad20"> Captcha </span> </label> <img src="<?php echo $init['captchaPath'] . $captcha->getId(); ?> "/><br /> </div><br /> <div class="rowDiv"> <label for="captchaInput"> <span class="pad20"> <?php echo $l->m('im_101'); ?> </span> </label> <input name="captcha" id="captcha" value="" size="20" maxlength="32" class="textField" />