/**
  * Show imported materials
  *
  * @access protected
  */
 protected function imported()
 {
     global $ilUser, $ilToolbar;
     $this->tabs_gui->setSubTabActive('ecs_import');
     include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php';
     if (ilECSServerSettings::getInstance()->activeServerExists()) {
         $ilToolbar->addButton($this->lng->txt('ecs_read_remote_links'), $this->ctrl->getLinkTarget($this, 'readAll'));
         $ilToolbar->addSeparator();
     }
     $sel_type = $_REQUEST["otype"];
     if (!$sel_type) {
         $sel_type = "rcrs";
     }
     include "Services/WebServices/ECS/classes/class.ilECSUtils.php";
     $options = ilECSUtils::getPossibleRemoteTypes(true);
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $sel = new ilSelectInputGUI("", "otype");
     $sel->setOptions($options);
     $sel->setValue($sel_type);
     $ilToolbar->addInputItem($sel);
     $ilToolbar->setFormAction($this->ctrl->getFormAction($this, "imported"));
     $ilToolbar->addFormButton($this->lng->txt("submit"), "imported");
     $robjs = ilUtil::_getObjectsByOperations($sel_type, 'visible', $ilUser->getId(), -1);
     if (count($robjs)) {
         $ilToolbar->addSeparator();
         $ilToolbar->addButton($this->lng->txt('csv_export'), $this->ctrl->getLinkTarget($this, 'exportImported'));
     }
     include_once 'Services/WebServices/ECS/classes/class.ilECSImportedContentTableGUI.php';
     $table_gui = new ilECSImportedContentTableGUI($this, 'imported');
     $table_gui->setTitle($this->lng->txt('ecs_imported_content'));
     $table_gui->parse($robjs);
     $this->tpl->setContent($table_gui->getHTML());
     return true;
 }
 /**
  * Init settings form
  */
 protected function initFormSettings()
 {
     include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
     $form = new ilPropertyFormGUI();
     $form->setFormAction($this->getCtrl()->getFormAction($this));
     $form->setTitle($this->getLang()->txt('ecs_part_settings') . ' ' . $this->getParticipant()->getTitle());
     $token = new ilCheckboxInputGUI($this->getLang()->txt('ecs_token_mechanism'), 'token');
     $token->setInfo($this->getLang()->txt('ecs_token_mechanism_info'));
     $token->setValue(1);
     $token->setChecked($this->getParticipant()->isTokenEnabled());
     $form->addItem($token);
     $dtoken = new ilCheckboxInputGUI($this->getLang()->txt('ecs_deprecated_token'), 'dtoken');
     $dtoken->setInfo($this->getLang()->txt('ecs_deprecated_token_info'));
     $dtoken->setValue(1);
     $dtoken->setChecked($this->getParticipant()->isDeprecatedTokenEnabled());
     $form->addItem($dtoken);
     // Export
     $export = new ilCheckboxInputGUI($this->getLang()->txt('ecs_tbl_export'), 'export');
     $export->setValue(1);
     $export->setChecked($this->getParticipant()->isExportEnabled());
     $form->addItem($export);
     // Export types
     $obj_types = new ilCheckboxGroupInputGUI($this->getLang()->txt('ecs_export_types'), 'export_types');
     $obj_types->setValue($this->getParticipant()->getExportTypes());
     include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
     foreach (ilECSUtils::getPossibleReleaseTypes(TRUE) as $type => $trans) {
         $obj_types->addOption(new ilCheckboxOption($trans, $type));
     }
     $export->addSubItem($obj_types);
     // Import
     $import = new ilCheckboxInputGUI($this->getLang()->txt('ecs_tbl_import'), 'import');
     $import->setValue(1);
     $import->setChecked($this->getParticipant()->isImportEnabled());
     $form->addItem($import);
     // Export types
     $imp_types = new ilCheckboxGroupInputGUI($this->getLang()->txt('ecs_import_types'), 'import_types');
     $imp_types->setValue($this->getParticipant()->getImportTypes());
     include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
     foreach (ilECSUtils::getPossibleRemoteTypes(TRUE) as $type => $trans) {
         $imp_types->addOption(new ilCheckboxOption($trans, $type));
     }
     $import->addSubItem($imp_types);
     $form->addCommandButton('saveSettings', $this->getLang()->txt('save'));
     $form->addCommandButton('abort', $this->getLang()->txt('cancel'));
     return $form;
 }
 /**
  * Reread all imported econtent.
  *
  * @return bool
  * @static
  * throws ilException, ilECSConnectorException
  */
 public static function handleImportReset(ilECSSetting $server)
 {
     global $ilLog;
     include_once 'Services/WebServices/ECS/classes/class.ilECSConnector.php';
     include_once 'Services/WebServices/ECS/classes/class.ilECSConnectorException.php';
     try {
         include_once './Services/WebServices/ECS/classes/class.ilECSEventQueueReader.php';
         include_once './Services/WebServices/ECS/classes/class.ilECSImport.php';
         include_once './Services/WebServices/ECS/classes/class.ilECSExport.php';
         $types = self::getAllEContentTypes();
         $event_queue = new ilECSEventQueueReader($server->getServerId());
         $event_queue->deleteAllEContentEvents($types);
         $list = self::getAllResourceIds($server, $types);
         $imported = ilECSImport::getAllImportedRemoteObjects($server->getServerId());
         $GLOBALS['ilLog']->write(__METHOD__ . ': Imported = ' . print_r($imported, true));
         $GLOBALS['ilLog']->write(__METHOD__ . ': List = ' . print_r($list, true));
         foreach ($list as $resource_type => $link_ids) {
             if (!in_array($resource_type, ilECSUtils::getPossibleRemoteTypes())) {
                 $GLOBALS['ilLog']->write(__METHOD__ . ': Ignoring resource type ' . $resource_type);
                 continue;
             }
             foreach ((array) $link_ids as $link_id) {
                 if (!isset($imported[$link_id])) {
                     // Add create event for not imported econtent
                     $event_queue->add($resource_type, $link_id, ilECSEvent::CREATED);
                 } else {
                     // Add update event for already existing events
                     $event_queue->add($resource_type, $link_id, ilECSEvent::UPDATED);
                 }
                 if (isset($imported[$link_id])) {
                     unset($imported[$link_id]);
                 }
             }
         }
         if (is_array($imported)) {
             // Delete event for deprecated econtent
             include_once 'Services/WebServices/ECS/classes/class.ilECSObjectSettings.php';
             foreach ($imported as $econtent_id => $obj_id) {
                 $type = self::getEventTypeFromObjectType(ilObject::_lookupType($obj_id));
                 if ($type) {
                     $event_queue->add($type, $econtent_id, ilECSEvent::DESTROYED);
                 }
             }
         }
     } catch (ilECSConnectorException $e1) {
         $ilLog->write('Cannot connect to ECS server: ' . $e1->getMessage());
         throw $e1;
     } catch (ilException $e2) {
         $ilLog->write('Update failed: ' . $e2->getMessage());
         throw $e2;
     }
     return true;
 }
Ejemplo n.º 4
0
 /**
  * get all imported links
  *
  * @access public
  * @static
  *
  */
 public static function getAllImportedRemoteObjects($a_server_id)
 {
     global $ilDB;
     include_once './Services/WebServices/ECS/classes/class.ilECSUtils.php';
     $query = "SELECT * FROM ecs_import ei JOIN object_data obd ON ei.obj_id = obd.obj_id " . 'WHERE server_id = ' . $ilDB->quote($a_server_id) . ' ' . 'AND ' . $ilDB->in('type', ilECSUtils::getPossibleRemoteTypes(), false, 'text');
     $res = $ilDB->query($query);
     while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
         $all[$row->econtent_id] = $row->obj_id;
     }
     return $all ? $all : array();
 }