Open Journal Systems  3.3.0
OrcidProfileSettingsForm.inc.php
1 <?php
2 
18 import('lib.pkp.classes.form.Form');
19 
21 
22  const CONFIG_VARS = array(
23  'orcidProfileAPIPath' => 'string',
24  'orcidClientId' => 'string',
25  'orcidClientSecret' => 'string',
26  'sendMailToAuthorsOnPublication' => 'bool',
27  'logLevel' => 'string',
28  'isSandBox' => 'bool'
29  );
31  var $contextId;
32 
34  var $plugin;
35 
41  function __construct(&$plugin, $contextId) {
42  $this->contextId = $contextId;
43  $this->plugin =& $plugin;
44 
45  parent::__construct($plugin->getTemplateResource('settingsForm.tpl'));
46 
47  if(!$this->plugin->isGloballyConfigured()) {
48  $this->addCheck(new FormValidator($this, 'orcidProfileAPIPath', 'required',
49  'plugins.generic.orcidProfile.manager.settings.orcidAPIPathRequired'));
50  }
51  $this->addCheck(new FormValidatorPost($this));
52  $this->addCheck(new FormValidatorCSRF($this));
53  }
54 
58  function initData() {
61  $this->_data = array();
62  foreach (self::CONFIG_VARS as $configVar => $type) {
63  $this->_data[$configVar] = $plugin->getSetting($contextId, $configVar);
64  }
65  }
66 
70  function readInputData() {
71  $this->readUserVars(array_keys(self::CONFIG_VARS));
72  }
73 
78  function fetch($request, $template = null, $display = false) {
79  $templateMgr = TemplateManager::getManager($request);
80  $templateMgr->assign('globallyConfigured', $this->plugin->isGloballyConfigured());
81  $templateMgr->assign('pluginName', $this->plugin->getName());
82  return parent::fetch($request, $template, $display);
83  }
84 
88  function execute(...$functionArgs) {
91  foreach (self::CONFIG_VARS as $configVar => $type) {
92  if ($configVar === 'orcidProfileAPIPath') {
93  $plugin->updateSetting($contextId, $configVar, trim($this->getData($configVar), "\"\';"), $type);
94  }
95  else {
96  $plugin->updateSetting($contextId, $configVar, $this->getData($configVar), $type);
97  }
98  }
99  if (strpos($this->getData("orcidProfileAPIPath"), "sandbox.orcid.org") == true) {
100  $plugin->updateSetting($contextId, "isSandBox", true, "bool");
101  }
102 
103  parent::execute(...$functionArgs);
104  }
105 }
106 
OrcidProfileSettingsForm
Form for site admins to modify ORCID Profile plugin settings.
Definition: OrcidProfileSettingsForm.inc.php:20
Form\readUserVars
readUserVars($vars)
Definition: Form.inc.php:378
Form\getData
getData($key)
Definition: Form.inc.php:220
OrcidProfileSettingsForm\readInputData
readInputData()
Definition: OrcidProfileSettingsForm.inc.php:76
FormValidatorPost
Form validation check to make sure the form is POSTed.
Definition: FormValidatorPost.inc.php:18
OrcidProfileSettingsForm\CONFIG_VARS
const CONFIG_VARS
Definition: OrcidProfileSettingsForm.inc.php:22
OrcidProfileSettingsForm\$plugin
$plugin
Definition: OrcidProfileSettingsForm.inc.php:40
OrcidProfileSettingsForm\__construct
__construct(&$plugin, $contextId)
Definition: OrcidProfileSettingsForm.inc.php:47
OrcidProfileSettingsForm\$contextId
$contextId
Definition: OrcidProfileSettingsForm.inc.php:34
PKPTemplateManager\getManager
static & getManager($request=null)
Definition: PKPTemplateManager.inc.php:1239
FormValidator
Class to represent a form validation check.
Definition: FormValidator.inc.php:23
OrcidProfileSettingsForm\initData
initData()
Definition: OrcidProfileSettingsForm.inc.php:64
OrcidProfileSettingsForm\fetch
fetch($request, $template=null, $display=false)
Definition: OrcidProfileSettingsForm.inc.php:84
Form\addCheck
addCheck($formValidator)
Definition: Form.inc.php:395
FormValidatorCSRF
Form validation check to make sure the CSRF token is correct.
Definition: FormValidatorCSRF.inc.php:18
Form
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
OrcidProfileSettingsForm\execute
execute(... $functionArgs)
Definition: OrcidProfileSettingsForm.inc.php:94