Skip to content

Commit

Permalink
pkp#3579: the easy changes...
Browse files Browse the repository at this point in the history
  • Loading branch information
crism committed May 18, 2018
1 parent 145f159 commit 72aeab0
Show file tree
Hide file tree
Showing 23 changed files with 63 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ function setSettings($settings) {
//
/**
* @copydoc Form::initData()
* @param $request Request
*/
function initData($request) {
function initData() {
$application = PKPApplication::getApplication();
$request = $application->getRequest();
$context = $request->getContext();
$this->_data = $context->getSettings();
}

/**
* @see Form::readInputData()
* @param $request PKPRequest
*/
function readInputData($request) {
function readInputData() {
$this->readUserVars(array_keys($this->getSettings()));
}

Expand All @@ -118,10 +118,11 @@ function fetch($request, $params = null) {

/**
* @see Form::execute()
* @param $request PKPRequest
*/
function execute($request) {
parent::execute($request);
function execute() {
parent::execute();
$application = PKPApplication::getApplication();
$request = $application->getRequest();
$context = $request->getContext();
$settingsDao = $context->getSettingsDao();
$settings = $this->getSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function __construct() {
/**
* @copydoc AnnouncementGridHandler::initialize()
*/
function initialize($request) {
parent::initialize($request);
function initialize($request, $args = null) {
parent::initialize($request, $args);

$this->setTitle('announcement.announcements');

Expand Down Expand Up @@ -85,10 +85,10 @@ protected function getRowInstance() {
/**
* @copydoc GridHandler::authorize()
*/
function authorize($request, &$args, $roleAssignments) {
function authorize($request, &$args, $roleAssignments, $requireAnnouncementsEnabled = false) {
import('lib.pkp.classes.security.authorization.ContextAccessPolicy');
$this->addPolicy(new ContextAccessPolicy($request, $roleAssignments));
return parent::authorize($request, $args, $roleAssignments, false);
return parent::authorize($request, $args, $roleAssignments, $requireAnnouncementsEnabled);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions controllers/grid/announcements/form/AnnouncementForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function getLocaleFieldNames() {
/**
* @copydoc Form::fetch()
*/
function fetch($request) {
function fetch($request, $template = null, $display = false) {
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('readOnly', $this->isReadOnly());
$templateMgr->assign('selectedTypeId', $this->getData('typeId'));
Expand Down Expand Up @@ -151,9 +151,8 @@ function readInputData() {

/**
* Save announcement.
* @param $request PKPRequest
*/
function execute($request) {
function execute() {
$announcementDao = DAORegistry::getDAO('AnnouncementDAO');

$announcement = $announcementDao->getById($this->announcementId);
Expand Down Expand Up @@ -199,6 +198,8 @@ function execute($request) {
import('classes.notification.NotificationManager');
$notificationManager = new NotificationManager();
$userGroupDao = DAORegistry::getDAO('UserGroupDAO');
$application = PKPApplication::getApplication();
$request = $application->getRequest();
$notificationUsers = array();
$allUsers = $userGroupDao->getUsersByContextId($contextId);
while ($user = $allUsers->next()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function getLocaleFieldNames() {
/**
* @copydoc Form::fetch()
*/
function fetch($request) {
function fetch($request, $template = null, $display = false) {
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('typeId', $this->typeId);
return parent::fetch($request, 'controllers/grid/announcements/form/announcementTypeForm.tpl');
Expand Down
4 changes: 2 additions & 2 deletions controllers/grid/files/LibraryFileGridCategoryRow.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ function getContext() {
/**
* @copydoc GridCategoryRow::initialize()
*/
function initialize($request) {
parent::initialize($request);
function initialize($request, $template = null) {
parent::initialize($request, $template);
$this->setId($this->getData());
}
}
Expand Down
4 changes: 2 additions & 2 deletions controllers/grid/files/LibraryFileGridHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ function setCanEdit($canEdit) {
* Configure the grid
* @param $request PKPRequest
*/
function initialize($request) {
parent::initialize($request);
function initialize($request, $args = null) {
parent::initialize($request, $args);

$router = $request->getRouter();
$this->_context = $router->getContext($request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function getTemplateVarsFromRowColumn($row, $column) {
/**
* @copydoc GridCellProvider::getCellActions()
*/
function getCellActions($request, $row, $column) {
function getCellActions($request, $row, $column, $position = GRID_ACTION_POSITION_DEFAULT) {
import('lib.pkp.classes.linkAction.request.RemoteActionConfirmationModal');
import('lib.pkp.classes.linkAction.request.AjaxAction');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function getLocaleFieldNames() {
/**
* @copydoc Form::fetch()
*/
function fetch($request) {
function fetch($request, $template = null, $display = false) {
$templateMgr = TemplateManager::getManager($request);

$themePlugins = PluginRegistry::getPlugins('themes');
Expand Down Expand Up @@ -198,7 +198,7 @@ function execute() {
* Perform additional validation checks
* @copydoc Form::validate
*/
function validate() {
function validate($callHooks = true) {
$navigationMenuDao = DAORegistry::getDAO('NavigationMenuDAO');

$navigationMenu = $navigationMenuDao->getByTitle($this->_contextId, $this->getData('title'));
Expand All @@ -213,7 +213,7 @@ function validate() {
}
}

return parent::validate();
return parent::validate($callHooks);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ function getContextId() {
/**
* @copydoc Form::fetch()
*/
function fetch($request) {
function fetch(
$request,
$template = 'controllers/grid/navigationMenus/form/navigationMenuItemsForm.tpl',
$display = false
) {
AppLocale::requireComponents(LOCALE_COMPONENT_APP_MANAGER);

$templateMgr = TemplateManager::getManager($request);
Expand Down Expand Up @@ -101,7 +105,7 @@ function fetch($request) {
'navigationMenuItemTypeConditionalWarnings' => json_encode($typeConditionalWarnings),
));

return parent::fetch($request, 'controllers/grid/navigationMenus/form/navigationMenuItemsForm.tpl');
return parent::fetch($request, $template, $display);
}

/**
Expand Down Expand Up @@ -131,9 +135,8 @@ function readInputData() {

/**
* Save NavigationMenuItem.
* @param $request PKPRequest
*/
function execute($request) {
function execute() {
$navigationMenuItemDao = DAORegistry::getDAO('NavigationMenuItemDAO');

$navigationMenuItem = $navigationMenuItemDao->getById($this->navigationMenuItemId);
Expand Down Expand Up @@ -162,7 +165,7 @@ function execute($request) {
* Perform additional validation checks
* @copydoc Form::validate
*/
function validate() {
function validate($callHooks = true) {
import('lib.pkp.classes.navigationMenu.NavigationMenuItem');
if ($this->getData('menuItemType') && $this->getData('menuItemType') != "") {
if ($this->getData('menuItemType') == NMI_TYPE_CUSTOM) {
Expand All @@ -185,7 +188,7 @@ function validate() {
$this->addError('path', __('manager.navigationMenus.form.typeMissing'));
}

return parent::validate();
return parent::validate($callHooks);
}

}
Expand Down
4 changes: 2 additions & 2 deletions controllers/grid/settings/genre/GenreGridHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ function __construct() {
* Configure the grid
* @param $request PKPRequest
*/
function initialize($request) {
parent::initialize($request);
function initialize($request, $args = null) {
parent::initialize($request, $args);

// Load language components
AppLocale::requireComponents(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ protected function loadData($request, $filter) {
/**
* @copydoc LanguageGridHandler::initialize()
*/
function initialize($request) {
parent::initialize($request);
function initialize($request, $args = null) {
parent::initialize($request, $args);
AppLocale::requireComponents(LOCALE_COMPONENT_APP_MANAGER);

$this->addNameColumn();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function __construct() {
/**
* @copydoc PKPHandler::authorize()
*/
function authorize($request, $args, $roleAssignments) {
function authorize($request, &$args, $roleAssignments) {
import('lib.pkp.classes.security.authorization.ContextAccessPolicy');
$this->addPolicy(new ContextAccessPolicy($request, $roleAssignments));
return parent::authorize($request, $args, $roleAssignments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,9 @@ protected function getRowInstance() {
}

/**
* @see GridHandler::loadData()
* @param $request PKPRequest
* @return array Grid data.
* @copydoc GridHandler::loadData()
*/
protected function loadData($request) {
protected function loadData($request, $filter = null) {
// Get all review forms.
$reviewFormDao = DAORegistry::getDAO('ReviewFormDAO');
$context = $request->getContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ function fetch($args, $request) {

/**
* Initialize form data from current settings.
* @param $reviewForm ReviewForm optional
*/
function initData($request) {
function initData() {
if ($this->reviewFormId) {
// Get review form
$application = PKPApplication::getApplication();
$request = $application->getRequest();
$context = $request->getContext();
$reviewFormDao = DAORegistry::getDAO('ReviewFormDAO');
$reviewForm = $reviewFormDao->getById($this->reviewFormId, Application::getContextAssocType(), $context->getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ function readInputData() {

/**
* Initialize form data from current settings.
* @param $request PKPRequest
*/
function initData($request) {
function initData() {
if ($this->reviewFormId) {
$application = PKPApplication::getApplication();
$request = $application->getRequest();
$context = $request->getContext();
$reviewFormDao = DAORegistry::getDAO('ReviewFormDAO');
$reviewForm = $reviewFormDao->getById($this->reviewFormId, Application::getContextAssocType(), $context->getId());
Expand All @@ -70,9 +71,10 @@ function fetch($args, $request) {

/**
* Save review form.
* @param $request PKPRequest
*/
function execute($request) {
function execute() {
$application = PKPApplication::getApplication();
$request = $application->getRequest();
$context = $request->getContext();
$reviewFormDao = DAORegistry::getDAO('ReviewFormDAO');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ protected function getRowInstance() {
/**
* @see GridHandler::renderFilter()
*/
function renderFilter($request) {
function renderFilter($request, $filterData = null) {
// Get filter data.
$roleDao = DAORegistry::getDAO('RoleDAO');
$roleOptions = array(0 => 'grid.user.allPermissionLevels') + Application::getRoleNames(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ function __construct() {
/**
* @copydoc SetupGridHandler::initialize()
*/
function initialize($request) {
parent::initialize($request);
function initialize($request, $args = null) {
parent::initialize($request, $args);

// Basic grid configuration
$this->setId('submissionChecklist');
Expand Down
2 changes: 1 addition & 1 deletion controllers/grid/settings/user/UserGridHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ protected function loadData($request, $filter) {
/**
* @copydoc GridHandler::renderFilter()
*/
function renderFilter($request) {
function renderFilter($request, $filterData = null) {
$context = $request->getContext();
$userGroupDao = DAORegistry::getDAO('UserGroupDAO');
$userGroups = $userGroupDao->getByContextId($context->getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ function authorize($request, &$args, $roleAssignments) {
/**
* @copydoc ListbuilderHandler::initialize()
*/
function initialize($request) {
parent::initialize($request);
function initialize($request, $args = null) {
parent::initialize($request, $args);
AppLocale::requireComponents(LOCALE_COMPONENT_PKP_MANAGER);

// Basic configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function getLocaleFieldNames() {
/**
* @copydoc ContextSettingsForm::fetch()
*/
function fetch($request) {
function fetch($request, $params = null) {
for($x = 1; $x < 11; $x++) {
$numAnnouncementsHomepageOptions[$x] = $x;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function getLocaleFieldNames() {
/**
* @copydoc ContextSettingsForm::fetch()
*/
function fetch($request) {
function fetch($request, $params = null) {
// Get all upload form image link actions.
$uploadImageLinkActions = array();
foreach ($this->getImagesSettingsName() as $settingName => $altText) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function __construct($wizardMode = false) {
/**
* @copydoc ContextSettingsForm::fetch()
*/
function fetch($request) {
function fetch($request, $params = null) {
$context = $request->getContext();
$dispatcher = $request->getDispatcher();
return parent::fetch($request, array(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ function initData($request) {
/**
* @copydoc ContextSettingsForm::fetch()
*/
function fetch($request) {
function fetch($request, $params = null) {
$templateMgr = TemplateManager::getManager($request);
$currencyDao = DAORegistry::getDAO('CurrencyDAO');
$currencies = array();
foreach ($currencyDao->getCurrencies() as $currency) {
$currencies[$currency->getCodeAlpha()] = $currency->getName();
}
$templateMgr->assign('currencies', $currencies);
return parent::fetch($request);
return parent::fetch($request, $params);
}

/**
Expand Down Expand Up @@ -106,13 +106,13 @@ function execute($request) {
* Validate the form.
* @copydoc Form::validate
*/
function validate() {
function validate($callHooks = true) {
if (!$this->settingsForm->validate()) {
foreach ($this->settingsForm->getErrorsArray() as $field => $message) {
$this->addError($field, $message);
}
}
return parent::validate();
return parent::validate($callHooks);
}
}

Expand Down

0 comments on commit 72aeab0

Please sign in to comment.