/** * update whitelist * * @access protected * */ protected function updateCommunities() { global $ilLog; include_once './Services/WebServices/ECS/classes/class.ilECSCommunityReader.php'; include_once './Services/WebServices/ECS/classes/class.ilECSServerSettings.php'; // @TODO: Delete deprecated communities $invalidImportTypes = false; if (!$this->validateImportTypes($_POST['import_type'])) { $invalidImportTypes = true; } $servers = ilECSServerSettings::getInstance(); foreach ($servers->getServers() as $server) { try { // Read communities $cReader = ilECSCommunityReader::getInstanceByServerId($server->getServerId()); // Update community cache foreach ($cReader->getCommunities() as $community) { include_once './Services/WebServices/ECS/classes/class.ilECSCommunityCache.php'; $cCache = ilECSCommunityCache::getInstance($server->getServerId(), $community->getId()); $cCache->setCommunityName($community->getTitle()); $cCache->setMids($community->getMids()); $cCache->setOwnId($community->getOwnId()); $cCache->update(); } } catch (Exception $e) { $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot read ecs communities: ' . $e->getMessage()); } } include_once './Services/WebServices/ECS/classes/class.ilECSParticipantSetting.php'; foreach ((array) $_POST['sci_mid'] as $sid => $tmp) { foreach ((array) $_POST['sci_mid'][$sid] as $mid => $tmp) { $set = new ilECSParticipantSetting($sid, $mid); $set->enableExport(array_key_exists($mid, (array) $_POST['export'][$sid]) ? true : false); $set->enableImport(array_key_exists($mid, (array) $_POST['import'][$sid]) ? true : false); $set->setImportType($_POST['import_type'][$sid][$mid]); // update title/cname try { $part = ilECSCommunityReader::getInstanceByServerId($sid)->getParticipantByMID($mid); if ($part instanceof ilECSParticipant) { $set->setTitle($part->getParticipantName()); } $com = ilECSCommunityReader::getInstanceByServerId($sid)->getCommunityByMID($mid); if ($com instanceof ilECSCommunity) { $set->setCommunityName($com->getTitle()); } } catch (Exception $e) { $GLOBALS['ilLog']->write(__METHOD__ . ': Cannot read ecs communities: ' . $e->getMessage()); } $set->update(); } } if ($invalidImportTypes) { ilUtil::sendFailure($this->lng->txt('ecs_invalid_import_type_cms'), true); } else { ilUtil::sendSuccess($this->lng->txt('settings_saved'), true); } $GLOBALS['ilCtrl']->redirect($this, 'communities'); // TODO: Do update of remote courses and ... return true; }
/** * Read comunities */ private function read() { global $ilDB; $query = 'SELECT sid,cid FROM ecs_community '; $res = $ilDB->query($query); while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) { $this->communities[] = ilECSCommunityCache::getInstance($row->sid, $row->cid); } return true; }