2
SOAP 웹 서비스를 사용하여 사용자 이름과 비밀번호를 확인하는 간단한 인증 플러그인을 작성했습니다. 그건 잘 작동합니다.Joomla 2.5 인증 플러그인 치명적 오류 : 비 객체에서 get() 멤버 함수 호출
joomla의 관리자는 SOAP 암호와 같은 매개 변수를 사용하고 싶었습니다. 그래서 xml에 params를 추가했습니다. 관리자가 잘 보여줍니다. 나는 그것의 가치에게 PHP를 얻을 때, 내가 얻을 :
치명적인 오류 : 비 객체() 멤버 함수를 얻기 위해 전화하는 것은
그래서 나는 다른 인증과 비교 나는 바로 그것을 할 같은 방법으로 ... 나는 그것이 왜 그렇게 이해가되지 않는다.public function __construct(& $subject, $params = array()) {
$nusoap = JPATH_SITE . '/plugins/authentication/ers/nusoap/lib/nusoap.php';
if (! file_exists ($nusoap)){
$response->error_message = "No such file";
return;
}
require_once ($nusoap);
// call the parent constructor
parent::__construct($subject, $params);
}
부모 : 당신은 당신의 자신의 생성자를 가지고 있기 때문에,이 같은 부모의 생성자를 호출 할 필요가
public function __construct() {
$nusoap = JPATH_SITE . '/plugins/authentication/ers/nusoap/lib/nusoap.php';
if (! file_exists ($nusoap)){
$response->error_message = "No such file";
return;
}
require_once ($nusoap);
}
function onUserAuthenticate($credentials, $options, &$response)
{
//Without defaults (the plugin crashes on the first get() bellow)
$webservice = $this->params->get('webservice', '');
$group = $this->params->get('group', '');
$whitepaw = $this->params->get('whitepaw', '');
JRequest::checkToken() or die('Invalid Token');
// For JLog
$response->type = 'ERS SOAP Webservice';
// MyCompany does not like blank passwords (So does Joomla ;))
if (empty($credentials['password'])) {
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('JGLOBAL_AUTH_EMPTY_PASS_NOT_ALLOWED');
return false;
}
if (empty($credentials['username'])) {
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('Please enter a username');
return false;
}
// Add a user to joomla
function addJoomlaUser($name, $username, $password, $email, $group) {
$data = array(
"name"=>$name,
"username"=>$username,
"password"=>$password,
"password2"=>$password,
"email"=>$email,
"block"=>0,
"groups"=>array("1","2", $group) // the uer is added into the group "public" and "registered" as well as a group of the user's choice.
);
$user = clone(JFactory::getUser());
//Write to database
if(!$user->bind($data)) {
throw new Exception("Could not bind data. Error: " . $user->getError());
}
if (!$user->save()) {
throw new Exception("Could not save user. Error: " . $user->getError());
}
return $user->id;
}
// Pour supprimer le cache du web-service
ini_set('soap.wsdl_cache_enabled', 0);
// Nouveau Client SOAP
try {
// Nouvelle instance de la classe soapClient
$client = new SoapClient($webservice, array('trace' => true));
$username = $credentials['username'];
$password = $credentials['password'];
$result = $client->CheckLogin(array('whitepaw'=>$whitepaw, 'username'=>$username, 'password'=>$password));
if($result->isInDB){
$name = $result->fname.' '.$result->lname;
$email = $result->email;
$response->error_message = $username.'<br>'.$password.'<br>'.$name.'<br>'.$email."<br><br>".
"<b>Request :</b><br>".htmlentities($client->__getLastRequest())."<br><br>".
"<b>RESPONSE :</b><br>".htmlentities($client->__getLastResponse())."<br><br>";
if(!$result->email == '' || empty ($result)) {
//Todo: check if the user is already in joomla db
$user_id = addJoomlaUser($name, $username, $password, $email,$group);
$response->status = JAuthentication::STATUS_SUCCESS;
//for testing purposes
$response->error_message = $user_id;
} else {
$response->error_message = "The webservice did not return data".$email.'did you see it?';
}
} else {
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = 'You do not have yet an account in <a href="http://my.ersnet.org">myers</a>. Please register.<br>';
$response->error_message .= $result->isInDB;
}
} catch (Exception $fault) {
$response->error_message = $fault->getMessage();
}
}
}
감사합니다. 당신의 대답 논리를 이해합니다. 나는 시도했다. 그러나 지금 그것은 놓치는 논증에 대해 묻는다. .. 왜 그렇게? 내 생성자에는 아무 것도 없습니다. – Samuel
무엇이 오류입니까? – MrCode
'경고 :/home/forum/public_html/libraries/joomla /에 정의 된 /home/forum/public_html/plugins/authentication/ers/ers.php의 30 번째 줄에있는 JPlugin :: __ construct()에 대한 인수 1이 누락되었습니다. plugin/plugin.php on line 55 치명적인 오류 : 39 번째 줄에있는 /home/forum/public_html/libraries/joomla/event/event.php에있는 객체가 아닌 객체의 attach() 함수를 호출하십시오. 생성자 및 플러그 앤 플레이 lib 메서드를 호출하는 모든 것은 괜찮습니다 ... @MrCode – Samuel