public static function loginForm($form_action = HTTP_ROOT_DIR, $supported_languages = array(), $login_page_language_code, $login_error_message = '')
 {
     $div = CDOMElement::create('div', 'id:login_div');
     $form = CDOMElement::create('form', "id:login_form, name:login_form, method:post, action:{$form_action}");
     $div_username = CDOMElement::create('div', 'id:username');
     $span_label_uname = CDOMElement::create('span', 'id:label_uname, class:page_text');
     $label_uname = CDOMElement::create('label', 'for:p_username');
     $label_uname->addChild(new CText(translateFN('Username')));
     $span_label_uname->addChild($label_uname);
     $span_username = CDOMElement::create('span', 'id:span_username, class:page_input');
     $username_input = CDOMElement::create('text', 'id:p_username, name:p_username');
     $span_username->addChild($username_input);
     $div_username->addChild($span_label_uname);
     $div_username->addChild($span_username);
     $div_password = CDOMElement::create('div', 'id:password');
     $span_label_pwd = CDOMElement::create('span', 'id:label_pwd, class:page_text');
     $label_pwd = CDOMElement::create('label', 'for:p_password');
     $label_pwd->addChild(new CText(translateFN('Password')));
     $span_label_pwd->addChild($label_pwd);
     $span_password = CDOMElement::create('span', 'id:span_password, class:page_input');
     $password_input = CDOMElement::create('password', 'id:p_password, name:p_password');
     $span_password->addChild($password_input);
     $div_password->addChild($span_label_pwd);
     $div_password->addChild($span_password);
     $div_remindme = CDOMElement::create('div', 'id:remindme');
     $span_label_remindme = CDOMElement::create('span', 'id:label_remindme, class:page_text');
     $label_remindme = CDOMElement::create('label', 'for:p_remindme');
     $label_remindme->addChild(new CText(translateFN('Resta collegato')));
     $span_label_remindme->addChild($label_remindme);
     $span_remindme = CDOMElement::create('span', 'id:span_remindme, class:page_input');
     $remindme_input = CDOMElement::create('checkbox', 'id:p_remindme,name:p_remindme,value:1');
     $span_remindme->addChild($remindme_input);
     $div_remindme->addChild($span_remindme);
     $div_remindme->addChild($span_label_remindme);
     $div_select = CDOMElement::create('div', 'id:language_selection');
     $select = CDOMElement::create('select', 'id:p_selected_language, name:p_selected_language');
     foreach ($supported_languages as $language) {
         $option = CDOMElement::create('option', "value:{$language['codice_lingua']}");
         if ($language['codice_lingua'] == $login_page_language_code) {
             $option->setAttribute('selected', 'selected');
         }
         $option->addChild(new CText($language['nome_lingua']));
         $select->addChild($option);
     }
     $div_select->addChild($select);
     $div_submit = CDOMElement::create('div', 'id:login_button');
     if (defined('MODULES_LOGIN') && MODULES_LOGIN) {
         // load login providers
         require_once MODULES_LOGIN_PATH . '/include/abstractLogin.class.inc.php';
         $loginProviders = abstractLogin::getLoginProviders();
     } else {
         $loginProviders = null;
     }
     if (!AMA_DB::isError($loginProviders) && is_array($loginProviders) && count($loginProviders) > 0) {
         $submit = CDOMElement::create('div', 'id:loginProviders');
         $form->addChild(CDOMElement::create('hidden', 'id:selectedLoginProvider, name:selectedLoginProvider'));
         $form->addChild(CDOMElement::create('hidden', 'id:selectedLoginProviderID, name:selectedLoginProviderID'));
         // add a DOM element (or html) foreach loginProvider
         foreach ($loginProviders as $providerID => $loginProvider) {
             include_once MODULES_LOGIN_PATH . '/include/' . $loginProvider . '.class.inc.php';
             if (class_exists($loginProvider)) {
                 $loginObject = new $loginProvider($providerID);
                 $CDOMElement = $loginObject->getCDOMElement();
                 if (!is_null($CDOMElement)) {
                     $submit->addChild($CDOMElement);
                 } else {
                     $htmlString = $loginObject->getHtml();
                     if (!is_null($htmlString)) {
                         $submit->addChild(new CText($htmlString));
                     }
                 }
             }
         }
     } else {
         // standard submit button if no MODULES_LOGIN
         $value = translateFN('Accedi');
         $submit = CDOMElement::create('submit', "id:p_login, name:p_login");
         $submit->setAttribute('value', $value);
     }
     $div_submit->addChild($submit);
     $form->addChild($div_username);
     $form->addChild($div_password);
     $form->addChild($div_remindme);
     $form->addChild($div_select);
     if ($login_error_message != '') {
         $div_error_message = CDOMElement::create('div', 'id:login_error_message, class:error');
         $div_error_message->addChild(new CText($login_error_message));
         $form->addChild($div_error_message);
     }
     $form->addChild($div_submit);
     $div->addChild($form);
     return $div;
 }
Beispiel #2
0
 * Users (types) allowed to access this module.
*/
$allowedUsersAr = array(AMA_TYPE_SWITCHER);
/**
 * Get needed objects
*/
$neededObjAr = array(AMA_TYPE_SWITCHER => array('layout'));
/**
 * Performs basic controls before entering this module
*/
require_once ROOT_DIR . '/include/module_init.inc.php';
require_once ROOT_DIR . '/browsing/include/browsing_functions.inc.php';
// MODULE's OWN IMPORTS
require_once MODULES_LOGIN_PATH . '/config/config.inc.php';
$self = whoami();
$loginProviders = abstractLogin::getLoginProviders(null, true);
if (!is_null($loginProviders) && is_array($loginProviders)) {
    /**
     * generate HTML for 'New Provider' button and the table
     */
    $configIndexDIV = CDOMElement::create('div', 'id:configindex');
    $newButton = CDOMElement::create('button');
    $newButton->setAttribute('class', 'newButton top tooltip');
    $newButton->setAttribute('title', translateFN('Clicca per creare un nuovo login provider'));
    $newButton->setAttribute('onclick', 'javascript:editProvider(null);');
    $newButton->addChild(new CText(translateFN('Nuovo Provider')));
    $configIndexDIV->addChild($newButton);
    $tableOutData = array();
    if (!AMA_DB::isError($loginProviders)) {
        $labels = array(translateFN('id'), translateFN('ordine'), translateFN('className'), translateFN('Nome'), translateFN('Abilitato'), translateFN('Bottone'), translateFN('azioni'));
        $hasDefault = false;
Beispiel #3
0
$neededObjAr = array(AMA_TYPE_SWITCHER => array('layout'));
/**
 * Performs basic controls before entering this module
*/
require_once ROOT_DIR . '/include/module_init.inc.php';
// MODULE's OWN IMPORTS
require_once MODULES_LOGIN_PATH . '/config/config.inc.php';
$GLOBALS['dh'] = AMALoginDataHandler::instance();
$retArray = array('status' => 'ERROR');
/**
 * guess which management class is needed by inspecting the passed providerClassName
 */
$optionsClassName = null;
if (isset($_REQUEST['providerClassName']) && strlen($_REQUEST['providerClassName']) > 0) {
    $type = trim($_REQUEST['providerClassName']);
    if (in_array($type, abstractLogin::getLoginProviders(null))) {
        require_once MODULES_LOGIN_PATH . '/include/' . $type . '.class.inc.php';
        $optionsClassName = $type::MANAGEMENT_CLASS;
    }
}
if (!is_null($optionsClassName)) {
    require_once MODULES_LOGIN_PATH . '/include/management/' . $optionsClassName . '.inc.php';
    if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
        /**
         * it's a POST, save the passed options config data
         */
        // build an optionManager with passed POST data
        $optionsManager = new $optionsClassName($_POST);
        // try to save it
        if (is_a($optionsManager, 'ldapManagement')) {
            $res = $GLOBALS['dh']->saveOptionSet($optionsManager->toArray());