The modules included with Polyphony are ones that are common to most of the applications that we develope. Instead of adding them to each application individually, the Polyphony modules directory can be added as a modules-location to be searched by the Harmoni ActionHandler.
11.4.1 Authentication
These are some simple actions for login, failed-login, and logout.
Below is one example of some code that could be put on a page to access the login actions.
Example
// Login links
print _("Current User: ");
// If they are logged in, print their name and a logout link
if ($harmoni->LoginState->isValid()) {
print $harmoni->LoginState->getAgentName();
print " - <a href='".MYURL."/auth/logout/".
implode("/", $harmoni->pathInfoParts)."'>";
print _("Log Out");
// Otherwise, print a login link
} else {
print _("anonymous");
print " - <a href='".MYURL."/auth/login/".
implode("/", $harmoni->pathInfoParts)."'>";
print _("Log In");
}
print "</a>";
11.4.2 Language
The language.change action changes the current action and returns the user to their previous action.
Put the following on your pages to submit the language change:
// Define the form and language-selection field
print "\n<form action='".MYURL."/language/change/"
.implode("/", $harmoni->pathInfoParts)."' method='post'>";
print "\n\t<select name='language'>";
// Get a list of the availible languages.
$langLoc =& Services::getService('Lang');
$currentCode = $langLoc->getLanguage();
$languages = $langLoc->getLanguages();
ksort($languages);
// Print out an option for each language.
foreach($languages as $code => $language) {
print "\n\t\t<option value='".$code."'"
.(($code == $currentCode)?" selected='selected'":"").">";
print $language."</option>";
}
// Close up the form.
print "\n\t</select>";
print "\n\t<input type='submit'>";
print "\n</form>";