Skip to content

Commit

Permalink
lists_default_configuration is not set #872
Browse files Browse the repository at this point in the history
  • Loading branch information
Fasse committed Jul 24, 2019
1 parent 5182e2a commit ed007b8
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions adm_program/system/classes/TableRoles.php
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ public static function getCostPeriods($costPeriod = null)
*/
public function getDefaultList()
{
global $gSettingsManager;
global $gSettingsManager, $gCurrentOrganization;

$defaultListId = (int) $this->getValue('rol_lst_id');

Expand All @@ -317,8 +317,24 @@ public function getDefaultList()
}
else
{
// read system default list configuration
return $gSettingsManager->getInt('lists_default_configuration');
try
{
// read system default list configuration
$defaultListConfiguration = $gSettingsManager->getInt('lists_default_configuration');
}
catch (\InvalidArgumentException $exception)
{
// if no default list was set than load another global list of this organization
$sql = 'SELECT MIN(lst_id) as lst_id
FROM '.TBL_LISTS.'
WHERE lst_org_id = ? -- $gCurrentOrganization->getValue(\'org_id\')
AND lst_global = 1 ';
$statement = $this->db->queryPrepared($sql, array($gCurrentOrganization->getValue('org_id')));
$row = $statement->fetch();
$defaultListConfiguration = $row['lst_id'];
}

return $defaultListConfiguration;
}
}

Expand Down Expand Up @@ -462,14 +478,14 @@ public function setValue($columnName, $newValue, $checkValue = true)
if($columnName === 'rol_cat_id' && isset($gCurrentUser) && $gCurrentUser instanceof User)
{
$category = new TableCategory($this->db, $newValue);

if(!$category->isVisible() || $category->getValue('cat_type') !== 'ROL')
{
throw new AdmException('Category of the role '. $this->getValue('dat_name'). ' could not be set
because the category is not visible to the current user and current organization.');
}
}

if ($columnName === 'rol_default_registration' && $newValue == '0' && $this->dbColumns[$columnName] == '1')
{
// checks if at least one other role has this flag
Expand All @@ -481,7 +497,7 @@ public function setValue($columnName, $newValue, $checkValue = true)
AND rol_id <> ? -- $this->getValue(\'rol_id\')
AND cat_org_id = ? -- $gCurrentOrganization->getValue(\'org_id\')';
$pdoStatement = $this->db->queryPrepared($sql, array((int) $this->getValue('rol_id'), (int) $gCurrentOrganization->getValue('org_id')));

if ((int) $pdoStatement->fetchColumn() === 0)
{
throw new AdmException('ROL_NO_DEFAULT_ROLE', array($gL10n->get('ROL_DEFAULT_REGISTRATION')));
Expand Down

0 comments on commit ed007b8

Please sign in to comment.