Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Jun 7, 2013
1 parent 30ebd19 commit cefdace
Show file tree
Hide file tree
Showing 40 changed files with 42 additions and 85 deletions.
2 changes: 1 addition & 1 deletion classes/admin/form/PKPSiteSettingsForm.inc.php
Expand Up @@ -109,7 +109,7 @@ function execute() {
$site->setRedirect($this->getData('redirect'));
$site->setMinPasswordLength($this->getData('minPasswordLength'));

$siteSettingsDao =& $this->siteSettingsDao;
$siteSettingsDao = $this->siteSettingsDao;
foreach ($this->getLocaleFieldNames() as $setting) {
$siteSettingsDao->updateSetting($setting, $this->getData($setting), null, true);
}
Expand Down
2 changes: 1 addition & 1 deletion classes/comment/CommentDAO.inc.php
Expand Up @@ -233,7 +233,7 @@ function decrementChildCount($commentId) {
* @param Comment object
*/
function deleteObject($comment, $isRecursing = false) {
$result = $this->update('DELETE FROM comments WHERE comment_id = ?', $comment->getId());
$this->update('DELETE FROM comments WHERE comment_id = ?', $comment->getId());
if (!$isRecursing) $this->decrementChildCount($comment->getParentCommentId());
foreach ($comment->getChildren() as $child) {
$this->deleteObject($child, true);
Expand Down
2 changes: 1 addition & 1 deletion classes/controlledVocab/ControlledVocabEntryDAO.inc.php
Expand Up @@ -195,7 +195,7 @@ function getByControlledVocabId($controlledVocabId, $rangeInfo = null, $filter =
* @param $controlledVocabEntry ControlledVocabEntry
*/
function updateObject(&$controlledVocabEntry) {
$returner = $this->update(
$this->update(
'UPDATE controlled_vocab_entries
SET controlled_vocab_id = ?,
seq = ?
Expand Down
Expand Up @@ -192,7 +192,6 @@ function getIsSubcomponent() {
*/
function exportCitations(&$args, $request, $noCitationsFoundMessage) {
$router = $request->getRouter();
$context = $router->getContext($request);
$templateMgr = TemplateManager::getManager($request);

$errorMessage = null;
Expand Down
4 changes: 1 addition & 3 deletions classes/controllers/grid/plugins/PluginGridHandler.inc.php
Expand Up @@ -179,7 +179,7 @@ function getCategoryRowIdParameterName() {
*/
function loadData($request, $filter) {
$categories = PluginRegistry::getCategories();
if (is_array($filter) && isset($filter['category']) && ($i = array_search($filter['category'], $categories)) !== false) {
if (is_array($filter) && isset($filter['category']) && array_search($filter['category'], $categories) !== false) {
return array($filter['category'] => $filter['category']);
} else {
return array_combine($categories, $categories);
Expand Down Expand Up @@ -245,8 +245,6 @@ function upgradePlugin($args, $request) {
* @param $request PKPRequest
*/
function uploadPlugin($args, $request) {
$errorMsg = '';

import('lib.pkp.classes.file.TemporaryFileManager');
$temporaryFileManager = new TemporaryFileManager();
$user = $request->getUser();
Expand Down
Expand Up @@ -312,9 +312,7 @@ function updateLimitFiles($args, $request) {
function getReviewersNotAssignedToSubmission($args, $request) {
$context = $request->getContext();
$submission = $this->getSubmission();
$stageId = $this->getAuthorizedContextObject(ASSOC_TYPE_WORKFLOW_STAGE);
$reviewRound = $this->getReviewRound();
$round = $reviewRound->getRound();
$term = $request->getUserVar('term');

$userDao = DAORegistry::getDAO('UserDAO'); /* @var $userDao UserDAO */
Expand Down Expand Up @@ -344,8 +342,6 @@ function getUsersNotAssignedAsReviewers($args, $request) {
$term = $request->getUserVar('term');

$userGroupDao = DAORegistry::getDAO('UserGroupDAO'); /* @var $userGroupDao UserGroupDAO */
$submission = $this->getSubmission();

$users = $userGroupDao->getUsersNotInRole(ROLE_ID_REVIEWER, $context->getId(), $term);

$userList = array();
Expand Down Expand Up @@ -592,7 +588,6 @@ function sendReminder($args, $request) {
* @return string Serialized JSON object
*/
function sendEmail($args, $request) {
$user = $request->getUser();
$reviewAssignment = $this->getAuthorizedContextObject(ASSOC_TYPE_REVIEW_ASSIGNMENT);

// Form handling.
Expand All @@ -612,8 +607,6 @@ function sendEmail($args, $request) {
* @return string Serialized JSON object
*/
function reviewHistory($args, $request) {
$user = $request->getUser();

$reviewAssignment = $this->getAuthorizedContextObject(ASSOC_TYPE_REVIEW_ASSIGNMENT);

$templateMgr = TemplateManager::getManager($request);
Expand Down
Expand Up @@ -83,8 +83,6 @@ protected function _reviewRound($args, $request) {

// Assign editor decision actions to the template, only if
// user is accessing the last review round for this stage.
$reviewRoundDao = DAORegistry::getDAO('ReviewRoundDAO');

$notificationRequestOptions = array(
NOTIFICATION_LEVEL_NORMAL => array(
NOTIFICATION_TYPE_REVIEW_ROUND_STATUS => array(ASSOC_TYPE_REVIEW_ROUND, $reviewRound->getId())),
Expand Down
4 changes: 2 additions & 2 deletions classes/file/wrappers/FTPFileWrapper.inc.php
Expand Up @@ -27,7 +27,7 @@ function open($mode = 'r') {
$port = isset($this->info['port']) ? (int)$this->info['port'] : 21;
$path = isset($this->info['path']) ? $this->info['path'] : '/';

if (!($this->ctrl = fsockopen($host, $port, $errno, $errstr)))
if (!($this->ctrl = fsockopen($host, $port)))
return false;

if ($this->_open($user, $pass, $path))
Expand Down Expand Up @@ -82,7 +82,7 @@ function _open($user, $pass, $path) {
$host = "$h1.$h2.$h3.$h4";
$port = ($p1 << 8) + $p2;

if (!($this->fp = fsockopen($host, $port, $errno, $errstr)))
if (!($this->fp = fsockopen($host, $port)))
return false;

// Retrieve file
Expand Down
2 changes: 1 addition & 1 deletion classes/file/wrappers/HTTPFileWrapper.inc.php
Expand Up @@ -73,7 +73,7 @@ function open($mode = 'r') {
}
}

if (!($this->fp = fsockopen($host, $port, $errno, $errstr)))
if (!($this->fp = fsockopen($host, $port)))
return false;

$additionalHeadersString = '';
Expand Down
2 changes: 1 addition & 1 deletion classes/filter/FilterDAO.inc.php
Expand Up @@ -339,7 +339,7 @@ function updateObject(&$filter) {
$filterGroup =& $filter->getFilterGroup();
assert($filterGroup->getSymbolic() != FILTER_GROUP_TEMPORARY_ONLY);

$returner = $this->update(
$this->update(
'UPDATE filters
SET filter_group_id = ?,
display_name = ?,
Expand Down
2 changes: 1 addition & 1 deletion classes/filter/FilterGroupDAO.inc.php
Expand Up @@ -98,7 +98,7 @@ function &getObjectBySymbolic($filterGroupSymbolic) {
* @param $filterGroup FilterGroup
*/
function updateObject(&$filterGroup) {
$returner = $this->update(
$this->update(
'UPDATE filter_groups
SET symbolic = ?,
display_name = ?,
Expand Down
3 changes: 1 addition & 2 deletions classes/form/Form.inc.php
Expand Up @@ -179,7 +179,6 @@ function fetch($request, $template = null, $display = false) {
$templateMgr->assign('formLocales', $this->supportedLocales);

// Determine the current locale to display fields with
$formLocale = $this->getFormLocale();
$templateMgr->assign('formLocale', $this->getFormLocale());

// N.B: We have to call $templateMgr->display instead of ->fetch($display)
Expand Down Expand Up @@ -331,7 +330,7 @@ function isLocaleResubmit() {
* @return string
*/
function getDefaultFormLocale() {
if (empty($formLocale)) $formLocale = AppLocale::getLocale();
$formLocale = AppLocale::getLocale();
if (!isset($this->supportedLocales[$formLocale])) $formLocale = $this->requiredLocale;
return $formLocale;
}
Expand Down
1 change: 0 additions & 1 deletion classes/form/validation/FormValidatorLocale.inc.php
Expand Up @@ -50,7 +50,6 @@ function FormValidatorLocale(&$form, $field, $type, $message, $requiredLocale =
* @return string
*/
function getMessage() {
$primaryLocale = AppLocale::getPrimaryLocale();
$allLocales = AppLocale::getAllLocales();
return parent::getMessage() . ' (' . $allLocales[$this->_requiredLocale] . ')';
}
Expand Down
2 changes: 1 addition & 1 deletion classes/language/LanguageDAO.inc.php
Expand Up @@ -129,7 +129,7 @@ function getLanguageNames($locale = null) {
$returner = array();
$cacheContents = $cache->getContents();
if (is_array($cacheContents)) {
foreach ($cache->getContents() as $code => $entry) {
foreach ($cache->getContents() as $entry) {
$returner[] = $entry[0];
}
}
Expand Down
2 changes: 1 addition & 1 deletion classes/mail/Mail.inc.php
Expand Up @@ -212,7 +212,7 @@ function addHeader($name, $content) {
}

foreach ($headers as $key => $value) {
if ($headers[$key]['name'] == $name) {
if ($value['name'] == $name) {
$headers[$key]['content'] = $content;
$updated = true;
}
Expand Down
13 changes: 6 additions & 7 deletions classes/mail/PKPEmailTemplateDAO.inc.php
Expand Up @@ -48,7 +48,7 @@ function &getBaseEmailTemplate($emailKey, $assocType, $assocId) {

$returner = null;
if ($result->RecordCount() != 0) {
$returner =& $this->_returnBaseEmailTemplateFromRow($result->GetRowAssoc(false));
$returner = $this->_returnBaseEmailTemplateFromRow($result->GetRowAssoc(false));
}

$result->Close();
Expand Down Expand Up @@ -81,7 +81,7 @@ function &getLocaleEmailTemplate($emailKey, $assocType, $assocId) {

$returner = null;
if ($result->RecordCount() != 0) {
$returner =& $this->_returnLocaleEmailTemplateFromRow($result->GetRowAssoc(false));
$returner = $this->_returnLocaleEmailTemplateFromRow($result->GetRowAssoc(false));
} else {
$result->Close();

Expand All @@ -106,7 +106,7 @@ function &getLocaleEmailTemplate($emailKey, $assocType, $assocId) {
array($assocType, $assocId, $emailKey)
);
if ($result->RecordCount() != 0) {
$returner =& $this->_returnLocaleEmailTemplateFromRow($result->GetRowAssoc(false));
$returner = $this->_returnLocaleEmailTemplateFromRow($result->GetRowAssoc(false));
}
}

Expand Down Expand Up @@ -145,7 +145,7 @@ function &getEmailTemplate($emailKey, $locale, $assocType, $assocId) {

$returner = null;
if ($result->RecordCount() != 0) {
$returner =& $this->_returnEmailTemplateFromRow($result->GetRowAssoc(false));
$returner = $this->_returnEmailTemplateFromRow($result->GetRowAssoc(false));
$returner->setCustomTemplate(false);
} else {
$result->Close();
Expand Down Expand Up @@ -176,7 +176,7 @@ function &getEmailTemplate($emailKey, $locale, $assocType, $assocId) {
array($assocType, $assocId, $emailKey, $locale)
);
if ($result->RecordCount() != 0) {
$returner =& $this->_returnEmailTemplateFromRow($result->GetRowAssoc(false));
$returner = $this->_returnEmailTemplateFromRow($result->GetRowAssoc(false));
$returner->setCustomTemplate(true);
}
}
Expand Down Expand Up @@ -466,7 +466,7 @@ function &getEmailTemplates($locale, $assocType, $assocId, $rangeInfo = null) {
);

while (!$result->EOF) {
$emailTemplates[] =& $this->_returnEmailTemplateFromRow($result->GetRowAssoc(false), false);
$emailTemplates[] = $this->_returnEmailTemplateFromRow($result->GetRowAssoc(false), false);
$result->MoveNext();
}
$result->Close();
Expand Down Expand Up @@ -496,7 +496,6 @@ function &getEmailTemplates($locale, $assocType, $assocId, $rangeInfo = null) {
);

while (!$result->EOF) {
$row = $result->getRowAssoc(false);
$emailTemplates[] = $this->_returnEmailTemplateFromRow($result->GetRowAssoc(false), true);
$result->MoveNext();
}
Expand Down
1 change: 0 additions & 1 deletion classes/mail/SubmissionMailTemplate.inc.php
Expand Up @@ -47,7 +47,6 @@ function assignParams($paramArray = array()) {

$application = PKPApplication::getApplication();
$request = $application->getRequest();
$context = isset($this->context)?$this->context:$request->getContext();

$paramArray['submissionTitle'] = strip_tags($submission->getLocalizedTitle());
$paramArray['submissionId'] = $submission->getId();
Expand Down
2 changes: 1 addition & 1 deletion classes/metadata/MetadataDescriptionDAO.inc.php
Expand Up @@ -96,7 +96,7 @@ function &getObjectsByAssocId($assocType, $assocId, $rangeInfo = null) {
*/
function updateObject(&$metadataDescription) {
$metadataSchema =& $metadataDescription->getMetadataSchema();
$returner = $this->update(
$this->update(
'UPDATE metadata_descriptions
SET assoc_type = ?,
assoc_id = ?,
Expand Down
Expand Up @@ -131,9 +131,6 @@ public function updateNotification($request, $userIds, $assocType, $assocId) {
private function _getSignoffNotificationContents($request, $notification, $symbolic, $message) {
$submissionId = $notification->getAssocId();

$submissionDao = Application::getSubmissionDAO();
$submission = $submissionDao->getById($submissionId);

// Get the stage id, based on symbolic.
$signoffDao = DAORegistry::getDAO('SignoffDAO');
$stageId = $signoffDao->getStageIdBySymbolic($symbolic);
Expand Down
2 changes: 1 addition & 1 deletion classes/oai/OAI.inc.php
Expand Up @@ -447,7 +447,7 @@ function ListMetadataFormats() {
$response = "\t<ListMetadataFormats>\n";

// output metadata formats
foreach ($formats as $prefix => $format) {
foreach ($formats as $format) {
$response .= "\t\t<metadataFormat>\n" .
"\t\t\t<metadataPrefix>" . $format->prefix . "</metadataPrefix>\n" .
"\t\t\t<schema>" . $format->schema . "</schema>\n" .
Expand Down
3 changes: 0 additions & 3 deletions classes/plugins/PKPPlugin.inc.php
Expand Up @@ -519,9 +519,6 @@ function installData($hookName, $args) {
* @return boolean
*/
function installSiteSettings($hookName, $args) {
$installer =& $args[0];
$result =& $args[1];

// All contexts are set to zero for site-wide plug-in settings
$application = PKPApplication::getApplication();
$contextDepth = $application->getContextDepth();
Expand Down
2 changes: 1 addition & 1 deletion classes/plugins/PluginRegistry.inc.php
Expand Up @@ -38,7 +38,7 @@ static function &getPlugins($category = null) {
static function &getAllPlugins() {
$plugins =& PluginRegistry::getPlugins();
$allPlugins = array();
if (is_array($plugins)) foreach ($plugins as $category => $list) {
if (is_array($plugins)) foreach ($plugins as $list) {
if (is_array($list)) $allPlugins += $list;
}
return $allPlugins;
Expand Down
2 changes: 1 addition & 1 deletion classes/reviewForm/ReviewFormElementDAO.inc.php
Expand Up @@ -167,7 +167,7 @@ function deleteById($reviewFormElementId) {
* @param $reviewFormId int
*/
function deleteByReviewFormId($reviewFormId) {
$reviewFormElements =& $this->getReviewFormElements($reviewFormId);
$reviewFormElements = $this->getReviewFormElements($reviewFormId);
foreach ($reviewFormElements as $reviewFormElementId => $reviewFormElement) {
$this->deleteById($reviewFormElementId);
}
Expand Down
2 changes: 0 additions & 2 deletions classes/security/PKPRoleDAO.inc.php
Expand Up @@ -48,8 +48,6 @@ function newDataObject() {
* @return array matching Users
*/
function &getUsersByRoleId($roleId = null, $contextId = null, $searchType = null, $search = null, $searchMatch = null, $dbResultRange = null) {
$users = array();

$paramArray = array(ASSOC_TYPE_USER, 'interest');
if (isset($roleId)) $paramArray[] = (int) $roleId;
if (isset($contextId)) $paramArray[] = (int) $contextId;
Expand Down
Expand Up @@ -75,9 +75,7 @@ function effect() {
* @return array
*/
function _getAccessibleStageRoles($userId, $contextId, &$submission, $stageId) {
$stageAssignmentDao = & DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */
$userGroupDao = DAORegistry::getDAO('UserGroupDAO');

$stageAssignmentDao = DAORegistry::getDAO('StageAssignmentDAO'); /* @var $stageAssignmentDao StageAssignmentDAO */
$userRoles = $this->getAuthorizedContextObject(ASSOC_TYPE_USER_ROLES);

$accessibleStageRoles = array();
Expand Down
3 changes: 0 additions & 3 deletions classes/submission/PKPSubmissionFileDAO.inc.php
Expand Up @@ -807,9 +807,6 @@ function _deleteInternally($submissionId = null, $fileStage = null, $fileId = nu
$assocType, $assocId, $stageId, $uploaderUserId, $uploaderUserGroupId, $round, null, $latestOnly);
if (empty($deletedFiles)) return 0;

$filterClause = '';
$conjunction = '';
$params = array();
foreach($deletedFiles as $deletedFile) { /* @var $deletedFile SubmissionFile */
// Delete file in the database.
// NB: We cannot safely bulk-delete because MySQL 3.23
Expand Down
3 changes: 1 addition & 2 deletions classes/submission/ReviewFilesDAO.inc.php
Expand Up @@ -50,8 +50,7 @@ function revoke($reviewId, $fileId) {
'DELETE FROM review_files WHERE review_id = ? AND file_id = ?',
array(
(int) $reviewId,
(int) $fileId,
(int) $revision
(int) $fileId
)
);
}
Expand Down
4 changes: 2 additions & 2 deletions classes/submission/SubmissionAgencyDAO.inc.php
Expand Up @@ -143,8 +143,8 @@ function insertAgencies($agencies, $submissionId, $deleteFirst = true) {
$agencyEntry->setControlledVocabId($currentAgencies->getID());
$agencyEntry->setAgency(urldecode($agency), $locale);
$agencyEntry->setSequence($i);
$i ++;
$agencyEntryId = $submissionAgencyEntryDao->insertObject($agencyEntry);
$i++;
$submissionAgencyEntryDao->insertObject($agencyEntry);
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions classes/submission/SubmissionDAO.inc.php
Expand Up @@ -327,11 +327,9 @@ function getByContextId($contextId) {
* @return array Submissions
*/
function getByUserId($userId, $contextId = null) {
$primaryLocale = AppLocale::getPrimaryLocale();
$locale = AppLocale::getLocale();
$params = $this->_getFetchParameters();
$params[] = (int) $userId;
if ($pressId) $params[] = (int) $contextId;
if ($contextId) $params[] = (int) $contextId;

$result = $this->retrieve(
'SELECT s.*, ps.date_published,
Expand Down
4 changes: 2 additions & 2 deletions classes/submission/SubmissionDisciplineDAO.inc.php
Expand Up @@ -146,8 +146,8 @@ function insertDisciplines($disciplines, $submissionId, $deleteFirst = true) {
$disciplineEntry->setControlledVocabId($currentDisciplines->getID());
$disciplineEntry->setDiscipline(urldecode($discipline), $locale);
$disciplineEntry->setSequence($i);
$i ++;
$disciplineEntryId = $submissionDisciplineEntryDao->insertObject($disciplineEntry);
$i++;
$submissionDisciplineEntryDao->insertObject($disciplineEntry);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions classes/submission/SubmissionKeywordDAO.inc.php
Expand Up @@ -144,8 +144,8 @@ function insertKeywords($keywords, $submissionId, $deleteFirst = true) {
$keywordEntry->setControlledVocabId($currentKeywords->getID());
$keywordEntry->setKeyword(urldecode($keyword), $locale);
$keywordEntry->setSequence($i);
$i ++;
$keywordEntryId = $submissionKeywordEntryDao->insertObject($keywordEntry);
$i++;
$submissionKeywordEntryDao->insertObject($keywordEntry);
}
}
}
Expand Down

0 comments on commit cefdace

Please sign in to comment.