Skip to content

Commit

Permalink
cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
janul committed Mar 26, 2015
1 parent 490e164 commit f362c84
Showing 1 changed file with 13 additions and 30 deletions.
43 changes: 13 additions & 30 deletions application/libraries/Providerupdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,33 +643,18 @@ public function updateProvider(models\Provider $ent, array $ch)
* set scopes
*/
if (array_key_exists('scopes', $ch) && (!in_array('scope', $dissalowedparts) || empty($entid))) {
$origscopesso = implode(',', $ent->getScope('idpsso'));
$origscopeaa = implode(',', $ent->getScope('aa'));
if (array_key_exists('idpsso', $ch['scopes']) && !empty($ch['scopes']['idpsso'])) {
$idpssoscopes = array_filter(preg_split("/[\s,]+/", $ch['scopes']['idpsso']));
$ent->setScope('idpsso', array_unique($idpssoscopes));
if ($origscopesso != implode(',', $idpssoscopes)) {
$m['Scope IDPSSO'] = array('before' => $origscopesso, 'after' => implode(',', $idpssoscopes));
}
} else {
$ent->setScope('idpsso', array());
if (!empty($origscopesso)) {
$m['Scope IDPSSO'] = array('before' => $origscopesso, 'after' => '');
}
}
if (array_key_exists('aa', $ch['scopes']) && !empty($ch['scopes']['aa'])) {
$aascopes = array_filter(preg_split("/[\s,]+/", $ch['scopes']['aa']));
$ent->setScope('aa', array_unique($aascopes));
if ($origscopeaa != implode(',', $aascopes)) {
$m['Scope AA'] = array('before' => $origscopeaa, 'after' => implode(',', $aascopes));
}
} else {
$ent->setScope('aa', array());
if (!empty($origscopeaa)) {
$m['Scope AA'] = array('before' => $origscopeaa, 'after' => '');

$scopeTypes = array('idpsso', 'aa');
foreach ($scopeTypes as $scopeType) {
$origScopes = implode(',', $ent->getScope($scopeType));
if (array_key_exists($scopeType, $ch['scopes']) && !empty($ch['scopes'][$scopeType])) {
$newScopes = array_filter(preg_split("/[\s,]+/", $ch['scopes'][$scopeType]));
$ent->setScope($scopeType, array_unique($newScopes));
if ($origScopes != implode(',', $newScopes)) {
$m['Scope ' . $scopeType . ''] = array('before' => $origScopes, 'after' => implode(',', $newScopes));
}
}
}
$origscopesso = null;
}
}
if (array_key_exists('entityid', $ch) && !empty($ch['entityid'])) {
Expand All @@ -684,7 +669,7 @@ public function updateProvider(models\Provider $ent, array $ch)
}
}

$fields = array('lname', 'ldisplayname','lhelpdesk');
$fields = array('lname', 'ldisplayname', 'lhelpdesk');
$fieldsLongName = array(
'lname' => 'OrganizationName',
'ldisplayname' => 'OrganizationDisplayName',
Expand All @@ -703,7 +688,7 @@ public function updateProvider(models\Provider $ent, array $ch)
$trackorigs = $ent->getMergedLocalName();
} elseif ($fieldName === 'ldisplayname') {
$trackorigs = $ent->getMergedLocalDisplayName();
}elseif($fieldName === 'lhelpdesk'){
} elseif ($fieldName === 'lhelpdesk') {
$trackorigs = $ent->getHelpdeskUrlLocalized();
}
$isDiff = false;
Expand Down Expand Up @@ -737,8 +722,7 @@ public function updateProvider(models\Provider $ent, array $ch)
$ent->setLocalDisplayName($ch['ldisplayname']);
$trackAfter = $ent->getMergedLocalDisplayName();

}elseif($fieldName === 'lhelpdesk')
{
} elseif ($fieldName === 'lhelpdesk') {
if (isset($ch['lhelpdesk']['en'])) {
$ent->setHelpdeskUrl($ch['lhelpdesk']['en']);
unset($ch['lhelpdesk']['en']);
Expand All @@ -756,7 +740,6 @@ public function updateProvider(models\Provider $ent, array $ch)
}



if ($isAdmin) {
if (array_key_exists('regauthority', $ch)) {
if ($ent->getRegistrationAuthority() !== $ch['regauthority']) {
Expand Down

0 comments on commit f362c84

Please sign in to comment.