Example #1
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
*/
$trackPageToNavigationHistory = false;
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';
$GLOBALS['dh'] = AMALoginDataHandler::instance();
$retArray = array();
if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    if (!isset($_POST['option_id']) && !isset($_POST['provider_id'])) {
        $retArray = array("status" => "ERROR", "msg" => translateFN("Non so cosa cancellare"));
    } else {
        if (isset($_POST['option_id'])) {
            if (isset($key) && strlen($key) > 0) {
                $result = $GLOBALS['dh']->deleteOptionByKey(intval($_POST['option_id']), trim($key));
                $deletedElement = 'Chiave';
                // translateFN delayed when building msg
                $vowel = 'a';
            } else {
                $result = $GLOBALS['dh']->deleteOptionSet(intval($_POST['option_id']));
                $deletedElement = 'Fonte';
                // translateFN delayed when building msg
 /**
  * gets a list of the available login providers found in the DB
  * 
  * If in a multiprovider environment, common db is used
  * else first it's searched the provider db and if no
  * module_login_providers table is found there, use common
  * 
  * @param bool $enabled true if only enabled providers, false if only disabled, null for all providers
  * @param bool $getData true, to return all provider's data. defaults to false: return className only 
  * 
  * @return array with provider id as the key and implementing className as value
  * 
  * @access public
  */
 public static function getLoginProviders($enabled = true, $getData = false)
 {
     /**
      * If not multiprovider, the AMALoginDataHandler must check
      * if module's own tables are in the user_provider DB and use them
      * or the ones in the common db if they're not found in the provider DB
      */
     if (!MULTIPROVIDER && isset($GLOBALS['user_provider']) && !empty($GLOBALS['user_provider'])) {
         $dsn = MultiPort::getDSN($GLOBALS['user_provider']);
     } else {
         $dsn = null;
     }
     $res = AMALoginDataHandler::instance($dsn)->getLoginProviders($enabled, ' `displayOrder` ASC');
     if (!AMA_DB::isError($res) && is_array($res) && count($res) > 0) {
         foreach ($res as $provider) {
             if ($getData === false) {
                 $retArr[$provider[AMALoginDataHandler::$PREFIX . 'providers_id']] = $provider['className'];
             } else {
                 $id = $provider[AMALoginDataHandler::$PREFIX . 'providers_id'];
                 unset($provider[AMALoginDataHandler::$PREFIX . 'providers_id']);
                 $retArr[$id] = $provider;
             }
         }
         return $retArr;
     } else {
         return null;
     }
 }