MISAuth.class.inc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <?php
  2. /*
  3. * DON'T REMOVE THE FOLLOWING LICENSE
  4. * INFORMATION!
  5. * ----------------------------------
  6. * Copyright by
  7. * Global Cube Business Solutions
  8. * Author: Dennis Ritz
  9. * info@global-cube.de
  10. * 2007-2008
  11. * ----------------------------------
  12. */
  13. class MISAuth extends App {
  14. public function __construct() {
  15. parent::__construct(__file__);
  16. }
  17. /*
  18. * init
  19. * ----
  20. * This function sets the main workaround for this class.
  21. */
  22. public function __init() {
  23. return $this->__AUTH();
  24. }
  25. public function login($p_username,$p_password) {
  26. //$confirmLogin = $this->confirmLogin($p_username,$p_password);
  27. //if(!$confirmLogin) {
  28. $status = parent::login($p_username,$p_password);
  29. //}
  30. if($status == AUTH_LOGGED_IN) {
  31. return array("CMgr.getMODEL().setUser('".utf8_encode($this->getUsername())." ".$this->_getI18N("logout")."');CMgr.getMODEL().__construct();");
  32. } elseif($status == AUTH_CONFIRM_LOGIN){
  33. return array("Browser.getElementById('inp_password').value='';CMgr.getAUTH().setInfoMsg('".$this->_getI18N("authConfirmLoginMsg")."');");
  34. } else {
  35. return array("CMgr.getAUTH().setInfoMsg('".$this->_getI18N("authFailedMsg")."');");
  36. }
  37. }
  38. public function logout() {
  39. $MISConfig = new MISConfig();
  40. $status = parent::logout();
  41. $MISConfig->setConfigFile($MISConfig->getDefaultConfigFile());
  42. $projectDOM = new DOMDocument('1.0', 'utf-8');
  43. $projectDOM->load($MISConfig->getConfigFile());
  44. $projectXpath = new DOMXpath($projectDOM);
  45. $configName = $projectXpath->query("/Configuration")->item(0)->getAttribute("Name");
  46. return array('CMgr.getMODEL().__construct();CMgr.getMODEL().setConfig("'.$configName.'");CMgr.getMODEL().setUser("'.$this->_getI18N("login").'");');
  47. }
  48. public function getMain() {
  49. $eval = "Browser.getElementById('inp_username').focus();CMgr.getMODEL().setLocationName('');CMgr.getMODEL().setLeftToolbar('');CMgr.getMODEL().setLeftFootbar('');CMgr.getMODEL().setMainToolbar('');CMgr.getMODEL().setMainFootbar('');CMgr.getMODEL().setMainHead('');CMgr.getMODEL().setUser('".$this->_getI18N("login")."');";
  50. switch($this->getAuthStatus()) {
  51. case AUTH_FAILED: $logonInfoMsg = $this->_getI18N("authFailedMsg");
  52. break;
  53. case AUTH_LOGGED_IN: $logonInfoMsg = $this->_getI18N("authLoggedInMsg");
  54. break;
  55. case AUTH_NOT_LOGGED: $logonInfoMsg = $this->_getI18N("authNotLoggedMsg");
  56. break;
  57. case AUTH_LOGGED_OUT: $logonInfoMsg = $this->_getI18N("authLoggedOutMsg");
  58. break;
  59. case AUTH_TIMEOUT: $logonInfoMsg = $this->_getI18N("authTimeoutMsg");
  60. break;
  61. case AUTH_EXPIRED: $logonInfoMsg = $this->_getI18N("authExpiredMsg");
  62. break;
  63. case AUTH_ERROR: $logonInfoMsg = $this->_getI18N("authErrorMsg");
  64. break;
  65. case AUTH_SECURITY: $logonInfoMsg = $this->_getI18N("authSecurityMsg");
  66. break;
  67. case AUTH_CONFIRM_LOGIN:$logonInfoMsg = $this->_getI18N("authConfirmLoginMsg");
  68. break;
  69. }
  70. if($this->getAuthStatus() == AUTH_LOGGED_OUT || $this->getAuthStatus() == AUTH_EXPIRED || $this->getAuthStatus() == AUTH_SECURITY) {
  71. $eval .= "Cookie.eraseAll();";
  72. }
  73. $eval .= "Browser.getElementById('inp_username').focus();";
  74. return array('<div id="logon" style="margin:auto;"><img style="position:relative;left:200px;top:0px;" src="img/MISView/company.png">
  75. <div class="title">'.$this->_getI18N("welcome").'</div>
  76. <div class="content"><div id="logonInfoMsg">'.$logonInfoMsg.'</div>
  77. <form name="loginForm" encoding="utf-8" action="" target="_self" method="post" class="" onsubmit="return Form.submit(this,\'MISAuth\',\'login\',\'username\',\'password\');">
  78. <fieldset>
  79. <legend>'.$this->_getI18N("auth").'</legend>
  80. <table>
  81. <tr>
  82. <td><label for="inp_username">'.$this->_getI18N("username").'</label>:</td>
  83. <td><input type="text" id="inp_username" name="username"></td>
  84. </tr>
  85. <tr>
  86. <td><label for="inp_password">'.$this->_getI18N("password").'</label>:</td>
  87. <td><input type="password" id="inp_password" name="password"></td>
  88. </tr>
  89. <tr>
  90. <td>&nbsp;</td>
  91. <td><input type="submit" value="'.$this->_getI18N("loginBtn").'"></td>
  92. </tr>
  93. </table>
  94. </fieldset>
  95. </form>
  96. </div>
  97. </div>',
  98. $eval);
  99. }
  100. }
  101. ?>