コード例 #1
0
ファイル: auth.class.php プロジェクト: JULIO8/respaldo_glpi
 /**
  * Get name of an authentication method
  *
  * @param $authtype  Authentication method
  * @param $auths_id  Authentication method ID
  * @param $link      show links to config page ? (default 0)
  * @param $name      override the name if not empty (default '')
  *
  * @return string
  */
 static function getMethodName($authtype, $auths_id, $link = 0, $name = '')
 {
     switch ($authtype) {
         case self::LDAP:
             $auth = new AuthLdap();
             if ($auth->getFromDB($auths_id)) {
                 //TRANS: %1$s is the auth method type, %2$s the auth method name or link
                 return sprintf(__('%1$s: %2$s'), AuthLdap::getTypeName(1), $auth->getLink());
             }
             return sprintf(__('%1$s: %2$s'), __('LDAP directory'), $name);
         case self::MAIL:
             $auth = new AuthMail();
             if ($auth->getFromDB($auths_id)) {
                 //TRANS: %1$s is the auth method type, %2$s the auth method name or link
                 return sprintf(__('%1$s: %2$s'), AuthLdap::getTypeName(1), $auth->getLink());
             }
             return sprintf(__('%1$s: %2$s'), __('Email server'), $name);
         case self::CAS:
             if ($auths_id > 0) {
                 $auth = new AuthLdap();
                 if ($auth->getFromDB($auths_id)) {
                     return sprintf(__('%1$s: %2$s'), sprintf(__('%1$s + %2$s'), __('CAS'), AuthLdap::getTypeName(1)), $auth->getLink());
                 }
             }
             return __('CAS');
         case self::X509:
             if ($auths_id > 0) {
                 $auth = new AuthLdap();
                 if ($auth->getFromDB($auths_id)) {
                     return sprintf(__('%1$s: %2$s'), sprintf(__('%1$s + %2$s'), __('x509 certificate authentication'), AuthLdap::getTypeName(1)), $auth->getLink());
                 }
             }
             return __('x509 certificate authentication');
         case self::EXTERNAL:
             if ($auths_id > 0) {
                 $auth = new AuthLdap();
                 if ($auth->getFromDB($auths_id)) {
                     return sprintf(__('%1$s: %2$s'), sprintf(__('%1$s + %2$s'), __('Other'), AuthLdap::getTypeName(1)), $auth->getLink());
                 }
             }
             return __('Other');
         case self::DB_GLPI:
             return __('GLPI internal database');
         case self::NOT_YET_AUTHENTIFIED:
             return __('Not yet authenticated');
     }
     return '';
 }
コード例 #2
0
 /**
  * Get name of an authentication method
  *
  * @param $authtype Authentication method
  * @param $auths_id Authentication method ID
  * @param $link show links to config page ?
  * @param $name override the name if not empty
  *
  * @return string
  */
 static function getMethodName($authtype, $auths_id, $link = 0, $name = '')
 {
     global $LANG;
     switch ($authtype) {
         case self::LDAP:
             $auth = new AuthLdap();
             if ($auth->getFromDB($auths_id)) {
                 return $auth->getTypeName() . " " . $auth->getLink();
             }
             return $LANG['login'][2] . " {$name}";
         case self::MAIL:
             $auth = new AuthMail();
             if ($auth->getFromDB($auths_id)) {
                 return $auth->getTypeName() . " " . $auth->getLink();
             }
             return $LANG['login'][3] . " {$name}";
         case self::CAS:
             $out = $LANG['login'][4];
             if ($auths_id > 0) {
                 $auth = new AuthLdap();
                 if ($auth->getFromDB($auths_id)) {
                     $out .= " + " . $auth->getTypeName() . " " . $auth->getLink();
                 }
             }
             return $out;
         case self::X509:
             $out = $LANG['setup'][190];
             if ($auths_id > 0) {
                 $auth = new AuthLdap();
                 if ($auth->getFromDB($auths_id)) {
                     $out .= " + " . $auth->getTypeName() . " " . $auth->getLink();
                 }
             }
             return $out;
         case self::EXTERNAL:
             $out = $LANG['common'][62];
             if ($auths_id > 0) {
                 $auth = new AuthLdap();
                 if ($auth->getFromDB($auths_id)) {
                     $out .= " + " . $auth->getTypeName() . " " . $auth->getLink();
                 }
             }
             return $out;
         case self::DB_GLPI:
             return $LANG['login'][18];
         case self::NOT_YET_AUTHENTIFIED:
             return $LANG['login'][9];
     }
     return '';
 }