function deleteConnectedModules($object_id)
 {
     global $connected_cms;
     $connected_cms[$this->cms_type]->soap_client->setCachingStatus(false);
     $connected_cms[$this->cms_type]->soap_client->clearCache();
     $connected_cms[$this->cms_type]->soap_client->user_type == "admin";
     $crs_id = ObjectConnections::getConnectionModuleId($object_id, "crs", $this->cms_type);
     if ($crs_id && $connected_cms[$this->cms_type]->soap_client->checkReferenceById($crs_id)) {
         $connected_cms[$this->cms_type]->soap_client->deleteObject($crs_id);
     }
     return parent::deleteConnectedModules($object_id);
 }
 function init($cms)
 {
     parent::init($cms);
     $this->field_script = $GLOBALS['ELEARNING_INTERFACE_MODULES'][$cms]["field_script"];
 }
 /**
  * get preferences
  *
  * shows additional settings.
  * @access public
  */
 function getPreferences()
 {
     global $connected_cms;
     $role_template_name = Request::get('role_template_name');
     $cat_name = Request::get('cat_name');
     $this->soap_client->setCachingStatus(false);
     if ($cat_name != "") {
         $cat = $this->soap_client->getReferenceByTitle(trim($cat_name), "cat");
         if ($cat == false) {
             $messages["error"] .= sprintf(_("Das Objekt mit dem Namen \"%s\" wurde im System %s nicht gefunden."), htmlReady($cat_name), htmlReady($this->getName())) . "<br>\n";
         } elseif ($cat != "") {
             ELearningUtils::setConfigValue("category_id", $cat, $this->cms_type);
             $this->main_category_node_id = $cat;
         }
     }
     if ($this->main_category_node_id != false and ELearningUtils::getConfigValue("user_category_id", $this->cms_type) == "") {
         $object_data["title"] = sprintf(_("User-Daten"));
         $object_data["description"] = _("Hier befinden sich die persönlichen Ordner der Stud.IP-User.");
         $object_data["type"] = "cat";
         $object_data["owner"] = $this->user->getId();
         $user_cat = $connected_cms[$this->cms_type]->soap_client->addObject($object_data, $connected_cms[$this->cms_type]->main_category_node_id);
         if ($user_cat != false) {
             $this->user_category_node_id = $user_cat;
             ELearningUtils::setConfigValue("user_category_id", $user_cat, $this->cms_type);
         } else {
             $messages["error"] .= _("Die Kategorie für User-Daten konnte nicht angelegt werden.") . "<br>\n";
         }
     }
     if ($role_template_name != "") {
         $role_template = $this->soap_client->getObjectByTitle(trim($role_template_name), "rolt");
         if ($role_template == false) {
             $messages["error"] .= sprintf(_("Das Rollen-Template mit dem Namen \"%s\" wurde im System %s nicht gefunden."), htmlReady($role_template_name), htmlReady($this->getName())) . "<br>\n";
         }
         if (is_array($role_template)) {
             ELearningUtils::setConfigValue("user_role_template_id", $role_template["obj_id"], $this->cms_type);
             ELearningUtils::setConfigValue("user_role_template_name", $role_template["title"], $this->cms_type);
             $this->user_role_template_id = $role_template["obj_id"];
         }
     }
     if (Request::submitted('submit')) {
         ELearningUtils::setConfigValue("encrypt_passwords", Request::option("encrypt_passwords"), $this->cms_type);
         $encrypt_passwords = Request::option("encrypt_passwords");
         ELearningUtils::setConfigValue("ldap_enable", Request::option("ldap_enable"), $this->cms_type);
         $this->ldap_enable = Request::option("ldap_enable");
     } else {
         if (ELearningUtils::getConfigValue("encrypt_passwords", $this->cms_type) != "") {
             $encrypt_passwords = ELearningUtils::getConfigValue("encrypt_passwords", $this->cms_type);
         }
     }
     $cat = $this->soap_client->getObjectByReference($this->main_category_node_id);
     $user_cat = $this->soap_client->getObjectByReference($this->user_category_node_id);
     $title = $this->link->getModuleLink($user_cat["title"], $this->user_category_node_id, "cat");
     $ldap_options = array();
     foreach (StudipAuthAbstract::GetInstance() as $plugin) {
         if ($plugin instanceof StudipAuthLdap) {
             $ldap_options[] = '<option ' . ($plugin->plugin_name == $this->ldap_enable ? 'selected' : '') . '>' . $plugin->plugin_name . '</option>';
         }
     }
     ob_start();
     ConnectedCMS::getPreferences();
     $module_types = ob_get_clean();
     $template = $GLOBALS['template_factory']->open('elearning/ilias4_connected_cms_preferences.php');
     $template->set_attribute('messages', $messages);
     $template->set_attribute('soap_error', $this->soap_client->getError());
     $template->set_attribute('soap_data', $this->soap_data);
     $template->set_attribute('main_category_node_id', $this->main_category_node_id);
     $template->set_attribute('main_category_node_id_title', $cat['title']);
     $template->set_attribute('user_category_node_id', $this->user_category_node_id);
     $template->set_attribute('user_category_node_id_title', $title);
     $template->set_attribute('user_role_template_name', ELearningUtils::getConfigValue("user_role_template_name", $this->cms_type));
     $template->set_attribute('user_role_template_id', $this->user_role_template_id);
     $template->set_attribute('encrypt_passwords', $encrypt_passwords);
     $template->set_attribute('ldap_options', count($ldap_options) ? join("\n", array_merge(array('<option></option>'), $ldap_options)) : '');
     $template->set_attribute('module_types', $module_types);
     echo $template->render();
 }