/**
  * @param $a_usr_id
  * @param $a_data
  *
  * @return bool
  */
 public static function doAssignments($a_usr_id, $a_data)
 {
     global $ilDB, $rbacadmin, $ilLog;
     $query = "SELECT rule_id FROM shib_role_assignment ";
     $num_matches = 0;
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $rule = new ilShibbolethRoleAssignmentRule($row->rule_id);
         if ($rule->doesMatch($a_data)) {
             $num_matches++;
             $ilLog->write(__METHOD__ . ': Assigned to role ' . ilObject::_lookupTitle($rule->getRoleId()));
             $rbacadmin->assignUser($rule->getRoleId(), $a_usr_id);
         }
     }
     // Assign to default if no matching found
     if (!$num_matches) {
         $default_role = shibConfig::getInstance()->getUserDefaultRole();
         $ilLog->write(__METHOD__ . ': Assigned to default role ' . ilObject::_lookupTitle($default_role));
         $rbacadmin->assignUser($default_role, $a_usr_id);
     }
     return true;
 }
 protected function saveRoleSelection()
 {
     $rule = new ilShibbolethRoleAssignmentRule($_SESSION['shib_role_ass']['rule_id']);
     $rule->setRoleId((int) $_POST['role_id']);
     $rule->setName($_SESSION['shib_role_ass']['name']);
     $rule->setValue($_SESSION['shib_role_ass']['value']);
     $rule->enablePlugin($_SESSION['shib_role_ass']['plugin']);
     $rule->setPluginId($_SESSION['shib_role_ass']['plugin_id']);
     $rule->enableAddOnUpdate($_SESSION['shib_role_ass']['add_on_update']);
     $rule->enableRemoveOnUpdate($_SESSION['shib_role_ass']['remove_on_update']);
     if ($rule->getRuleId()) {
         $rule->update();
     } else {
         $rule->add();
     }
     ilUtil::sendSuccess($this->lng->txt('settings_saved'));
     unset($_SESSION['shib_role_ass']);
     $this->roleAssignment();
 }