Wrap Language->t to translate tag into the current language, with a fallback to english.
public t ( $tag, $replacements = [], $fallbackdefault = true, $oldreplacements = [], $striptags = false ) |
$config = SimpleSAML_Configuration::getInstance(); $janus_config = sspmod_janus_DiContainer::getInstance()->getConfig(); $authsource = $janus_config->getValue('auth', 'login-admin'); $useridattr = $janus_config->getValue('useridattr', 'eduPersonPrincipalName'); $et = new SimpleSAML_XHTML_Template($config, 'janus:editentity.php', 'janus:editentity'); $as = new SimpleSAML_Auth_Simple($authsource); // Validate user if ($as->isAuthenticated()) { $attributes = $as->getAttributes(); // Check if userid exists if (!isset($attributes[$useridattr])) { throw new Exception('User ID is missing'); } $userid = $attributes[$useridattr][0]; } else { echo $et->t('error_no_access'); exit; } // Get Entity controller $mcontroller = sspmod_janus_DiContainer::getInstance()->getEntityController(); // Get the user $user = new sspmod_janus_User(); $user->setUserid($userid); $user->load(sspmod_janus_User::USERID_LOAD); $eid = $_GET['eid']; $currentRevisionId = $_GET['currentRevisionId']; $historyTab = $_GET['historyTab']; if (!($entity = $mcontroller->setEntity($eid))) { throw new SimpleSAML_Error_Exception('Error in setEntity'); } $workflowstates = $janus_config->getValue('workflowstates');
/** * Recursiv attribute array listing function * * @param SimpleSAML_XHTML_Template $t Template object * @param array $attributes Attributes to be presented * @param string $nameParent Name of parent element * * @return string HTML representation of the attributes */ function present_attributes($t, $attributes, $nameParent) { $alternate = array('odd', 'even'); $i = 0; $summary = 'summary="' . $t->t('{consent:consent:table_summary}') . '"'; if (strlen($nameParent) > 0) { $parentStr = strtolower($nameParent) . '_'; $str = '<table class="attributes" ' . $summary . '>'; } else { $parentStr = ''; $str = '<table id="table_with_attributes" class="attributes" ' . $summary . '>'; $str .= "\n" . '<caption>' . $t->t('{consent:consent:table_caption}') . '</caption>'; } foreach ($attributes as $name => $value) { $nameraw = $name; $name = $t->getAttributeTranslation($parentStr . $nameraw); if (preg_match('/^child_/', $nameraw)) { // Insert child table $parentName = preg_replace('/^child_/', '', $nameraw); foreach ($value as $child) { $str .= "\n" . '<tr class="odd"><td style="padding: 2em">' . present_attributes($t, $child, $parentName) . '</td></tr>'; } } else { // Insert values directly $str .= "\n" . '<tr class="' . $alternate[$i++ % 2] . '"><td><span class="attrname">' . htmlspecialchars($name) . '</span>'; $isHidden = in_array($nameraw, $t->data['hiddenAttributes'], true); if ($isHidden) { $hiddenId = SimpleSAML_Utilities::generateID(); $str .= '<div class="attrvalue" style="display: none;" id="hidden_' . $hiddenId . '">'; } else { $str .= '<div class="attrvalue">'; } if (sizeof($value) > 1) { // We hawe several values $str .= '<ul>'; foreach ($value as $listitem) { if ($nameraw === 'jpegPhoto') { $str .= '<li><img src="data:image/jpeg;base64,' . htmlspecialchars($listitem) . '" alt="User photo" /></li>'; } else { $str .= '<li>' . htmlspecialchars($listitem) . '</li>'; } } $str .= '</ul>'; } elseif (isset($value[0])) { // We hawe only one value if ($nameraw === 'jpegPhoto') { $str .= '<img src="data:image/jpeg;base64,' . htmlspecialchars($value[0]) . '" alt="User photo" />'; } else { $str .= htmlspecialchars($value[0]); } } // end of if multivalue $str .= '</div>'; if ($isHidden) { $str .= '<div class="attrvalue consent_showattribute" id="visible_' . $hiddenId . '">'; $str .= '... '; $str .= '<a class="consent_showattributelink" href="javascript:SimpleSAML_show(\'hidden_' . $hiddenId . '\'); SimpleSAML_hide(\'visible_' . $hiddenId . '\');">'; $str .= $t->t('{consent:consent:show_attribute}'); $str .= '</a>'; $str .= '</div>'; } $str .= '</td></tr>'; } // end else: not child table } // end foreach $str .= isset($attributes) ? '</table>' : ''; return $str; }
if (in_array($country_name, $metaArray['tags'])) { $entry['flag'] = SimpleSAML_Module::getModuleURL('metalisting/flags/' . $code . '.png'); $entry['flag_name'] = $country_name; break; } } } // Store the data in the result array if (array_key_exists($entity_type, $metaentries)) { array_push($metaentries[$entity_type], $entry); } } if (!isset($_GET['output']) || $_GET['output'] !== 'json') { $config = SimpleSAML_Configuration::getInstance(); $t = new SimpleSAML_XHTML_Template($config, 'janus:metalisting.php', 'janus:editentity'); $t->data['header'] = $t->t('federation_entities_header'); $t->data['metaentries'] = $metaentries; $t->data['workflowstates'] = $workflowstates; $t->show(); } else { $json = array(); $type = null; if (isset($_GET['type'])) { $type = $_GET['type']; } header('Content-type: application/json'); header("Content-Disposition: attachment; filename=federation_metadata.json"); foreach ($metaentries as $entity_type => $entry_set) { if (!isset($type) || isset($type) && $type == $entity_type) { foreach ($entry_set as $entry) { $valid_status = 'bad';
$formGen = new sspmod_selfregister_XHTML_Form($formFields, 'newUser.php'); $showFields = sspmod_selfregister_Util::genFieldView($viewAttr); $formGen->fieldsToShow($showFields); $formGen->setReadOnly('mail'); $hidden = array('emailconfirmed' => $email, 'token' => $token); $formGen->addHiddenData($hidden); $formGen->setValues(array('mail' => $email)); $formGen->setSubmitter('submit_change'); $formHtml = $formGen->genFormHtml(); $html = new SimpleSAML_XHTML_Template($config, 'selfregister:step3_register.tpl.php', 'selfregister:selfregister'); $html->data['formHtml'] = $formHtml; $html->show(); } catch (sspmod_selfregister_Error_UserException $e) { // Invalid token $terr = new SimpleSAML_XHTML_Template($config, 'selfregister:step1_email.tpl.php', 'selfregister:selfregister'); $error = $terr->t($e->getMesgId(), $e->getTrVars()); $terr->data['error'] = htmlspecialchars($error); $terr->data['systemName'] = $systemName; $terr->show(); } } elseif (array_key_exists('sender', $_POST)) { try { // Add or update user object $listValidate = sspmod_selfregister_Util::genFieldView($viewAttr); $validator = new sspmod_selfregister_Registration_Validation($formFields, $listValidate); $validValues = $validator->validateInput(); $userInfo = sspmod_selfregister_Util::processInput($validValues, $viewAttr); $store = sspmod_selfregister_Storage_UserCatalogue::instantiateStorage(); $store->addUser($userInfo); $html = new SimpleSAML_XHTML_Template($config, 'selfregister:step4_complete.tpl.php', 'selfregister:selfregister'); $html->data['systemName'] = $systemName;
} $readOnlyFields = $showFields; $formGen = new sspmod_selfregister_XHTML_Form($formFields, 'delUser.php'); $formGen->fieldsToShow($showFields); $formGen->setReadOnly($readOnlyFields); $html = new SimpleSAML_XHTML_Template($config, 'selfregister:deluser.tpl.php', 'selfregister:selfregister'); if (array_key_exists('sender', $_POST)) { try { // Delete user object $store->delUser($attributes[$store->userIdAttr][0]); // Now when a User delete himself sucesfully, System log out him. // In the future when admin delete a user a msg will be showed // $html->data['userMessage'] = 'message_userdel'; $as->logout(SimpleSAML_Module::getModuleURL('selfregister/index.php?status=deleted')); } catch (sspmod_selfregister_Error_UserException $e) { // Some user error detected $error = $html->t($e->getMesgId(), $e->getTrVars()); $html->data['error'] = htmlspecialchars($error); } } elseif (array_key_exists('logout', $_GET)) { $as->logout(SimpleSAML_Module::getModuleURL('selfregister/index.php')); } else { // The GET access this endpoint $values = sspmod_selfregister_Util::filterAsAttributes($attributes, $reviewAttr); } $formGen->setValues($values); $formGen->setSubmitter('submit_delete'); $formHtml = $formGen->genFormHtml(); $html->data['formHtml'] = $formHtml; $html->data['uid'] = $attributes[$store->userIdAttr][0]; $html->show();
$t->data['todo'] = 'loginANSWER'; $t->data['useSMS'] = false; // get a random question $random_question = $qaLogin->getRandomQuestion($uid); $t->data['random_question'] = array("question_text" => $random_question["question_text"], "question_id" => $random_question["question_id"]); } else { $t->data['todo'] = 'loginCode'; if (!$qaLogin->hasMailCode($uid)) { $qaLogin->sendMailCode($uid, $email); } } if (isset($_POST['submit'])) { // if the form was submitted switch ($_POST['submit']) { // Next button pushed case $t->t('{auth2factor:login:next}'): // is this questions ? if (isset($_POST['answer'])) { //Ask the user for answer to a randomly selected question if ($prefs['challenge_type'] == 'question') { $loggedIn = $qaLogin->verifyAnswer($uid, $_POST['question_id'], $_POST['answer']); if ($loggedIn) { $state['saml:AuthnContextClassRef'] = $qaLogin->tfa_authencontextclassref; $qaLogin->resetFailedLoginAttempts($uid, 'answer_count'); SimpleSAML_Auth_Source::completeAuth($state); } else { $errorCode = 'WRONGANSWER'; // only increment if the account is not already locked if (!$qaLogin->isLocked($uid)) { $qaLogin->failedLoginAttempt($uid, 'answer_count', array('name' => $givenName, 'mail' => $email, 'uid' => $uid)); if ($failCount == $firstFailCount) {