• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

webservice/soap/classes/class.ilSoapAdministration.php

Go to the documentation of this file.
00001 <?php
00002   /*
00003    +-----------------------------------------------------------------------------+
00004    | ILIAS open source                                                           |
00005    +-----------------------------------------------------------------------------+
00006    | Copyright (c) 1998-2006 ILIAS open source, University of Cologne            |
00007    |                                                                             |
00008    | This program is free software; you can redistribute it and/or               |
00009    | modify it under the terms of the GNU General Public License                 |
00010    | as published by the Free Software Foundation; either version 2              |
00011    | of the License, or (at your option) any later version.                      |
00012    |                                                                             |
00013    | This program is distributed in the hope that it will be useful,             |
00014    | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016    | GNU General Public License for more details.                                |
00017    |                                                                             |
00018    | You should have received a copy of the GNU General Public License           |
00019    | along with this program; if not, write to the Free Software                 |
00020    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021    +-----------------------------------------------------------------------------+
00022   */
00023 
00024 
00035 include_once './webservice/soap/lib/nusoap.php';
00036 include_once ("./Services/Authentication/classes/class.ilAuthUtils.php");               // to get auth mode constants
00037 
00038 define ('SOAP_CLIENT_ERROR', 1);
00039 define ('SOAP_SERVER_ERROR', 2);
00040 
00041 class ilSoapAdministration
00042 {
00043         /*
00044          * object which handles php's authentication
00045          * @var object
00046          */
00047         var $sauth = null;
00048 
00049         /*
00050          * Defines type of error handling (PHP5 || NUSOAP)
00051          * @var object
00052          */
00053         var $error_method = null;
00054 
00055 
00056         function ilSoapAdministration($use_nusoap = true)
00057         {
00058                 define('USER_FOLDER_ID',7);
00059                 define('NUSOAP',1);
00060                 define('PHP5',2);
00061 
00062                 if(IL_SOAPMODE == IL_SOAPMODE_NUSOAP)
00063                 {
00064                         $this->error_method = NUSOAP;
00065                 } 
00066                 else
00067                 { 
00068                         $this->error_method = PHP5;
00069                 }
00070                 $this->__initAuthenticationObject();
00071 
00072         }
00073 
00074         // PROTECTED
00075         function __checkSession($sid)
00076         {
00077                 list($sid,$client) = $this->__explodeSid($sid);
00078 
00079                 $this->sauth->setClient($client);
00080                 $this->sauth->setSid($sid);
00081 
00082                 if(!$this->sauth->validateSession())
00083                 {
00084                         return false;
00085                 }
00086                 return true;
00087         }
00088 
00096         public function initErrorWriter()
00097         {
00098                 include_once('classes/class.ilErrorHandling.php');
00099 
00100                 set_error_handler(array('ilErrorHandling','_ilErrorWriter'),E_ALL);
00101         }
00102 
00103 
00104         function __explodeSid($sid)
00105         {
00106                 $exploded = explode('::',$sid);
00107 
00108                 return is_array($exploded) ? $exploded : array('sid' => '','client' => '');
00109         }
00110 
00111 
00112         function __setMessage($a_str)
00113         {
00114                 $this->message = $a_str;
00115         }
00116         function __getMessage()
00117         {
00118                 return $this->message;
00119         }
00120         function __appendMessage($a_str)
00121         {
00122                 $this->message .= isset($this->message) ? ' ' : '';
00123                 $this->message .= $a_str;
00124         }
00125 
00126 
00127         function __initAuthenticationObject($a_auth_mode = AUTH_LOCAL)
00128         {
00129                 switch($a_auth_mode)
00130                 {
00131                         case AUTH_CAS:
00132                                 include_once './webservice/soap/classes/class.ilSoapAuthenticationCAS.php';
00133                                 return $this->sauth = new ilSoapAuthenticationCAS();
00134                         case AUTH_LDAP:
00135                                 include_once './webservice/soap/classes/class.ilSoapAuthenticationLDAP.php';
00136                                 return $this->sauth = new ilSoapAuthenticationLDAP();
00137 
00138                         default:
00139                                 include_once './webservice/soap/classes/class.ilSoapAuthentication.php';
00140                                 return $this->sauth = new ilSoapAuthentication();
00141                 }
00142         }
00143 
00144 
00145         function __raiseError($a_message,$a_code)
00146         {
00147                 switch($this->error_method)
00148                 {
00149                         case NUSOAP:
00150                                 return new soap_fault($a_code,'',$a_message);
00151                         case PHP5:
00152                                 return new SoapFault($a_code, $a_message);
00153                 }
00154         }
00155 
00163         function getNIC($sid) {
00164             if(!$this->__checkSession($sid))
00165                 {
00166                         return $this->__raiseError($this->sauth->getMessage(),$this->sauth->getMessageCode());
00167                 }
00168 
00169                 // Include main header
00170                 include_once './include/inc.header.php';
00171                 global $rbacsystem, $rbacreview, $ilLog, $rbacadmin,$ilSetting, $ilClientIniFile;
00172 
00173                 if (!is_object($ilClientIniFile)) {
00174                     return $this->__raiseError("Client ini is not initialized","Server");
00175                 }
00176 
00177                 $auth_modes = ilAuthUtils::_getActiveAuthModes();
00178                 $auth_mode_default =  strtoupper(ilAuthUtils::_getAuthModeName(array_shift($auth_modes)));
00179                 $auth_mode_names = array();
00180                 foreach ($auth_modes as $mode) {
00181                         $auth_mode_names[] = strtoupper(ilAuthUtils::_getAuthModeName($mode));
00182                 }
00183 
00184         // todo: get information from client id, read from ini file specificied
00185         $client_details[] = array ("installation_id" => IL_INST_ID,
00186                                    "installation_version" => ILIAS_VERSION,
00187                                    "installation_url" => ILIAS_HTTP_PATH,
00188                                    "installation_description" => $ilClientIniFile->readVariable("client","description"),
00189                                                                         "installation_language_default" => $ilClientIniFile->readVariable("language","default"),
00190                                                                         "installation_session_expire" => $ilClientIniFile->readVariable("session","expire"),
00191                                                                         "installation_php_postmaxsize" => $this->return_bytes(ini_get("post_max_size")),
00192                                                                         "authentication_methods" => join(",", $auth_mode_names),
00193                                                                         "authentication_default_method" => $auth_mode_default
00194 
00195                                                                                                                                                 );
00196 
00197         // store into xml result set
00198                 include_once './webservice/soap/classes/class.ilXMLResultSet.php';
00199 
00200 
00201         $xmlResult = new ilXMLResultSet();
00202         $xmlResult->addArray($client_details, true);
00203 
00204         // create writer and return xml
00205                 include_once './webservice/soap/classes/class.ilXMLResultSetWriter.php';
00206         $xmlResultWriter = new ilXMLResultSetWriter($xmlResult);
00207         $xmlResultWriter->start();
00208         return $xmlResultWriter->getXML();
00209         }
00210 
00215         private function return_bytes($val) {
00216                 $val = trim($val);
00217                 $last = strtolower($val{strlen($val)-1});
00218                 switch($last) {
00219                 // The 'G' modifier is available since PHP 5.1.0
00220                 case 'g':
00221                         $val *= 1024;
00222                 case 'm':
00223                         $val *= 1024;
00224                 case 'k':
00225                         $val *= 1024;
00226                 }
00227                 return $val;
00228         }
00229 
00230 }
00231 ?>

Generated on Fri Dec 13 2013 17:57:03 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1