54        $this->server_id = $a_server_id;
 
   67        if (array_key_exists($a_server_id, self::$instances) and is_object(self::$instances[$a_server_id])) {
 
   68            return self::$instances[$a_server_id];
 
   77        $query = 
"DELETE FROM ldap_rg_mapping " .
 
   78            "WHERE role = " . 
$ilDB->quote($a_role_id, 
'integer');
 
   88        $query = 
"DELETE FROM ldap_rg_mapping " .
 
   89            "WHERE server_id = " . 
$ilDB->quote($a_server_id, 
'integer');
 
   97        global 
$ilDB,$rbacreview;
 
   99        $query = 
"SELECT rgm.* FROM ldap_rg_mapping rgm JOIN ldap_server_settings lss " .
 
  100            "ON rgm.server_id = lss.server_id " .
 
  101            "WHERE lss.active = 1 " .
 
  102            "AND lss.role_sync_active = 1 ";
 
  109            $data[
'member']                     = 
$row->member_attribute;
 
  112            $data[
'info_type']          = 
$row->mapping_info_type;
 
  114            $data[
'object_id']          = $rbacreview->getObjectOfRole(
$row->role);
 
  119        return $active ? $active : array();
 
  135        return $this->mappings ? $this->mappings : array();
 
  146        $this->mappings = array();
 
  147        foreach ($a_mappings as $mapping_id => 
$data) {
 
  148            if ($mapping_id == 0) {
 
  172        global 
$ilErr,$rbacreview;
 
  175        $found_missing = 
false;
 
  176        foreach ($this->mappings as $mapping_id => 
$data) {
 
  178            if (!strlen(
$data[
'dn']) || !strlen(
$data[
'member_attribute']) || !strlen(
$data[
'role_name'])) {
 
  179                if (!$found_missing) {
 
  180                    $found_missing = 
true;
 
  181                    $ilErr->appendMessage($this->lng->txt(
'fill_out_all_required_fields'));
 
  185            if (strlen(
$data[
'role_name']) and !$rbacreview->roleExists(
$data[
'role_name'])) {
 
  186                $ilErr->appendMessage($this->lng->txt(
'ldap_role_not_exists') . 
' ' . 
$data[
'role_name']);
 
  189        return strlen(
$ilErr->getMessage()) ? false : 
true;
 
  203        foreach ($this->mappings as $mapping_id => 
$data) {
 
  205                $next_id = 
$ilDB->nextId(
'ldap_rg_mapping');
 
  206                $query = 
"INSERT INTO ldap_rg_mapping (mapping_id,server_id,url,dn,member_attribute,member_isdn,role,mapping_info,mapping_info_type) " .
 
  208                    $ilDB->quote($next_id, 
'integer') . 
", " .
 
  209                    $this->db->quote($this->
getServerId(), 
'integer') . 
", " .
 
  210                    $this->db->quote(
$data[
'url'], 
'text') . 
", " .
 
  211                    $this->db->quote(
$data[
'dn'], 
'text') . 
", " .
 
  212                    $this->db->quote(
$data[
'member_attribute'], 
'text') . 
", " .
 
  213                    $this->db->quote(
$data[
'member_isdn'], 
'integer') . 
", " .
 
  214                    $this->db->quote(
$data[
'role'], 
'integer') . 
", " .
 
  215                    $this->db->quote(
$data[
'info'], 
'text') . 
", " .
 
  216                    $this->db->quote(
$data[
'info_type'], 
'integer') .
 
  220                $query = 
"UPDATE ldap_rg_mapping " .
 
  221                    "SET server_id = " . $this->db->quote($this->
getServerId(), 
'integer') . 
", " .
 
  222                    "url = " . $this->db->quote(
$data[
'url'], 
'text') . 
", " .
 
  223                    "dn =" . $this->db->quote(
$data[
'dn'], 
'text') . 
", " .
 
  224                    "member_attribute = " . $this->db->quote(
$data[
'member_attribute'], 
'text') . 
", " .
 
  225                    "member_isdn = " . $this->db->quote(
$data[
'member_isdn'], 
'integer') . 
", " .
 
  226                    "role = " . $this->db->quote(
$data[
'role'], 
'integer') . 
", " .
 
  227                    "mapping_info = " . $this->db->quote(
$data[
'info'], 
'text') . 
", " .
 
  228                    "mapping_info_type = " . $this->db->quote(
$data[
'info_type'], 
'integer') . 
" " .
 
  229                    "WHERE mapping_id = " . $this->db->quote($mapping_id, 
'integer');
 
  244    public function delete($a_mapping_id)
 
  248        $query = 
"DELETE FROM ldap_rg_mapping " .
 
  249            "WHERE server_id = " . $this->db->quote($this->
getServerId(), 
'integer') . 
" " .
 
  250            "AND mapping_id = " . $this->db->quote($a_mapping_id, 
'integer');
 
  264        $role = $this->mappings[$a_mapping_id][
'role_name'];
 
  265        $dn_parts = explode(
',', $this->mappings[$a_mapping_id][
'dn']);
 
  267        return (array_key_exists(0, $dn_parts) ? $dn_parts[0] : 
"''");
 
  279        global $ilObjDataCache,$rbacreview,$tree;
 
  281        $this->mappings = array();
 
  282        $query = 
"SELECT * FROM ldap_rg_mapping LEFT JOIN object_data " .
 
  283            "ON role = obj_id " .
 
  284            "WHERE server_id =" . $this->db->quote($this->
getServerId(), 
'integer') . 
' ' .
 
  289            $this->mappings[
$row->mapping_id][
'mapping_id']                     = 
$row->mapping_id;
 
  290            $this->mappings[
$row->mapping_id][
'dn']                                     = 
$row->dn;
 
  291            $this->mappings[
$row->mapping_id][
'url']                                    = 
$row->url;
 
  292            $this->mappings[
$row->mapping_id][
'member_attribute']               = 
$row->member_attribute;
 
  293            $this->mappings[
$row->mapping_id][
'member_isdn']                    = 
$row->member_isdn;
 
  294            $this->mappings[
$row->mapping_id][
'role']                                   = 
$row->role;
 
  295            $this->mappings[
$row->mapping_id][
'info']                                   = 
$row->mapping_info;
 
  296            $this->mappings[
$row->mapping_id][
'info_type']                              = 
$row->mapping_info_type;
 
  297            if ($ilObjDataCache->lookupType(
$row->role) == 
'role') {
 
  298                $this->mappings[
$row->mapping_id][
'role_name']                  = $ilObjDataCache->lookupTitle(
$row->role);
 
  300                $this->mappings[
$row->mapping_id][
'role_name']                  = 
$row->role;
 
An exception for terminatinating execution or to throw for unit testing.
getMappingInfoString($a_mapping_id)
Create an info string for a role group mapping.
__construct($a_server_id)
Private constructor (Singleton for each server_id)
static _deleteByRole($a_role_id)
const MAPPING_INFO_INFO_ONLY
validate()
Validate mappings.
getMappings()
Get already configured mappings.
static _getInstanceByServerId($a_server_id)
Get instance of class.
static _getAllActiveMappings()
loadFromPost($a_mappings)
static _deleteByServerId($a_server_id)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
foreach($_POST as $key=> $value) $res