thrownewException('Cannot connect to mysql database ('.$this->db->connect_errno.') '.$this->db->connect_error);
}
$this->db->set_charset($d['charset']);
}
/**
*@seeIdentityProvider_Driver::guest.
*/
publicfunctionguest(){
if(empty($this->_guest_user)){
$this->_guest_user=newWordpress_User();
$this->_guest_user->id=0;
$this->_guest_user->name="Guest";
$this->_guest_user->full_name="Guest";
$this->_guest_user->guest=true;
$this->_guest_user->admin=false;
$this->_guest_user->locale=null;
$this->_guest_user->email=null;
$this->_guest_user->url=null;
}
return$this->_guest_user;
}
/**
*@seeIdentityProvider_Driver::admin_user.
*/
publicfunctionadmin_user(){
$tp=$this->config['wp_database']['table_prefix'];
$query='SELECT user_id FROM '.$tp.'usermeta WHERE meta_key = "'.$tp.'capabilities" AND meta_value = "a:1:{s:13:\"administrator\";b:1;}" ORDER BY user_id ASC LIMIT 1';
$query='SELECT u.*, m.meta_value AS roles FROM '.$tp.'users u LEFT OUTER JOIN '.$tp.'usermeta m ON (u.ID = m.user_id) WHERE u.ID = '.$id.' AND meta_key = "'.$tp.'capabilities"';
$query='SELECT u.*, m.meta_value AS roles FROM '.$tp.'users u LEFT OUTER JOIN '.$tp.'usermeta m ON (u.ID = m.user_id) WHERE u.user_login = "'.$name.'" AND meta_key = "'.$tp.'capabilities"';
$result=$this->db->query($query);
$user=$result->fetch_array(MYSQLI_ASSOC);
$result->free();
if(isset($user)){
returnnewWordpress_User($user);
}else{
returnnull;
}
}
/**
*@seeIdentityProvider_Driver::create_group.
*/
publicfunctioncreate_group($name){
thrownewException("@todo INVALID OPERATION");
}
/**
*@seeIdentityProvider_Driver::everybody.
*/
publicfunctioneverybody(){
returnnewWordpress_Group('everybody');
}
/**
*@seeIdentityProvider_Driver::registered_users.
*/
publicfunctionregistered_users(){
returnnewWordpress_Group('registered_users');
}
/**
*@seeIdentityProvider_Driver::get_user_list.
*/
publicfunctionget_user_list($ids){
$users=array();
foreach($idsas$id){
$users[]=$this->lookup_user($id);
}
return$users;
}
/**
*@seeIdentityProvider_Driver::lookup_group.
*/
publicfunctionlookup_group($name){
$groups=$this->groups();
foreach($groupsas$group){
if($group->id==$name){
return$group;
}
}
returnnull;
}
/**
*Lookupthegroupbyname.
*@paramstring$namethenameofthegrouptolocate
*@returnGroup_Definition
*/
publicfunctionlookup_group_by_name($name){
return$this->lookup_group(strtolower($name));
}
/**
*@seeIdentityProvider_Driver::groups.
*/
publicfunctiongroups(){
if(!isset($this->wp_roles)){
$tp=$this->config['wp_database']['table_prefix'];
$query='SELECT option_value FROM '.$tp.'options WHERE option_name = "'.$tp.'user_roles" LIMIT 1';