18 declare(strict_types=1);
    35         $this->db = $DIC->database();
    44         if (!isset(self::$instance)) {
    47         return self::$instance;
    58         $query = 
'SELECT * from ecs_import ' .
    59                 'WHERE server_id = ' . $this->db->quote($a_server_id, 
'integer') . 
' ' .
    60                 'AND mid = ' . $this->db->quote($a_mid, 
'integer') . 
' ' .
    61                 'AND econtent_id = ' . $this->db->quote($a_econtent_id, 
'text');
    62         $res = $this->db->query($query);
    64             return $row->content_id;
    74         $query = 
"SELECT obj_id FROM ecs_import " .
    75             "WHERE content_id = " . $this->db->quote($a_content_id, 
'integer') . 
" " .
    76             "&& mid = " . $this->db->quote($a_mid, 
'integer') . 
" " .
    77             '&& server_id = ' . $this->db->quote($a_server_id, 
'integer') . 
' ';
    79         if (!is_null($a_sub_id)) {
    80             $query .= 
'AND sub_id = ' . $this->db->quote($a_sub_id, 
'text');
    82             $query .= 
'AND sub_id IS NULL';
    84         $res = $this->db->query($query);
    87             return (
int) $row->obj_id;
    94         $query = 
"SELECT obj_id FROM ecs_import " .
    95             "WHERE content_id = " . $this->db->quote($a_content_id, 
'integer');
    97         $res = $this->db->query($query);
   101             $obj_ids[] = $row->obj_id;
   113         $query = 
'SELECT * from ecs_import ' .
   114                 'WHERE server_id = ' . $this->db->quote($a_server_id, 
'integer') . 
' ' .
   115                 'AND mid = ' . $this->db->quote($a_mid, 
'integer') . 
' ' .
   116                 'AND content_id = ' . $this->db->quote($a_content_id, 
'text');
   117         $res = $this->db->query($query);
   119             return (
int) $row->econtent_id;
   131         $query = 
"SELECT * FROM ecs_import ei JOIN object_data obd ON ei.obj_id = obd.obj_id " .
   132             'WHERE server_id = ' . $this->db->quote($a_server_id) . 
' ' .
   134         $res = $this->db->query($query);
   136             $all[$row->econtent_id] = $row->obj_id;
   150         $query = 
"SELECT * FROM ecs_import " .
   151             "WHERE mid = " . $this->db->quote($a_mid, 
'integer') . 
" " .
   152             'AND server_id = ' . $this->db->quote($a_server_id, 
'integer');
   154         $res = $this->db->query($query);
   157             $obj_ids[] = $row->obj_id;
   167         $query = 
"SELECT * FROM ecs_import WHERE obj_id = " . $this->db->quote($a_obj_id, 
'integer') . 
" ";
   168         $res = $this->db->query($query);
   170             return $row->econtent_id;
   180         $query = 
'SELECT * FROM ecs_import WHERE obj_id = ' . $this->db->quote($a_obj_id, 
'integer');
   181         $res = $this->db->query($query);
   183             return (
int) $row->server_id;
   194         $query = 
"SELECT obj_id FROM ecs_import WHERE econtent_id  = " . $this->db->quote($a_econtent_id, 
'text') . 
" " .
   195             'AND server_id = ' . $this->db->quote($a_server_id, 
'integer');
   196         $res = $this->db->query($query);
   199             $obj_ids[] = (
int) $row->obj_id;
   207     public function _lookupObjId(
int $a_server_id, 
string $a_econtent_id, 
int $a_mid, ?
string $a_sub_id = null): 
int   209         $query = 
"SELECT obj_id FROM ecs_import " .
   210             "WHERE econtent_id = " . $this->db->quote($a_econtent_id, 
'text') . 
" " .
   211             "AND mid = " . $this->db->quote($a_mid, 
'integer') . 
" " .
   212             'AND server_id = ' . $this->db->quote($a_server_id, 
'integer') . 
' ';
   214         if (!is_null($a_sub_id)) {
   215             $query .= 
'AND sub_id = ' . $this->db->quote($a_sub_id, 
'text');
   217             $query .= 
'AND sub_id IS NULL';
   219         $res = $this->db->query($query);
   222             return (
int) $row->obj_id;
   234         $query = 
"DELETE FROM ecs_import " .
   235             "WHERE obj_id = " . $this->db->quote($a_obj_id, 
'integer') . 
" ";
   236         $this->db->manipulate($query);
   245         $query = 
'DELETE FROM ecs_import ' .
   246             'WHERE server_id = ' . $this->db->quote($a_server_id, 
'integer');
   247         $this->db->manipulate($query);
   255     public function deleteRessources(
int $a_server_id, 
int $a_mid, array $a_econtent_ids): bool
   257         $query = 
'DELETE FROM ecs_import ' .
   258                 'WHERE server_id = ' . $this->db->quote($a_server_id, 
'integer') . 
' ' .
   259                 'AND mid = ' . $this->db->quote($a_mid, 
'integer') . 
' ' .
   260                 'AND ' . $this->db->in(
'econtent_id', $a_econtent_ids, 
false, 
'text');
   261         $this->db->manipulate($query);
   268     public function _isImported(
int $a_server_id, 
string $a_econtent_id, 
int $a_mid, ?
string $a_sub_id = null): 
int   270         return $this->
_lookupObjId($a_server_id, $a_econtent_id, $a_mid, $a_sub_id);
   275         $query = 
'UPDATE ecs_import SET server_id = ' . $this->db->quote(0, 
'integer') .
   276             ' WHERE server_id = ' . $this->db->quote($a_server_id, 
'integer');
   277         $this->db->manipulate($query);
 static ilECSImportManager $instance
 
_lookupObjId(int $a_server_id, string $a_econtent_id, int $a_mid, ?string $a_sub_id=null)
loogup obj_id by econtent and mid and server_id 
 
lookupServerId(int $a_obj_id)
Lookup server id of imported content. 
 
_isImported(int $a_server_id, string $a_econtent_id, int $a_mid, ?string $a_sub_id=null)
check if econtent is imported for a specific mid 
 
lookupObjIdByContentId(int $a_server_id, int $a_mid, int $a_content_id, ?string $a_sub_id=null)
Lookup obj_id by content id. 
 
_lookupObjIdsByMID($a_server_id, $a_mid)
lookup obj ids by mid 
 
Manage the ECS imported contents. 
 
static getPossibleRemoteTypes(bool $a_with_captions=false)
Get all possible remote object types. 
 
lookupObjIdsByContentId($a_content_id)
 
static getInstance()
Get the singleton instance of this ilECSImportManager. 
 
_lookupEContentId(int $a_obj_id)
get econent_id 
 
resetServerId($a_server_id)
 
deleteRessources(int $a_server_id, int $a_mid, array $a_econtent_ids)
Delete ressources. 
 
getAllImportedRemoteObjects($a_server_id)
get all imported links 
 
_lookupObjIds($a_server_id, $a_econtent_id)
Lookup obj_id. 
 
lookupContentId($a_server_id, $a_mid, $a_econtent_id)
Lookup content id The content is the - not necessarily unique - id provided by the econtent type...
 
lookupEContentIdByContentId($a_server_id, $a_mid, $a_content_id)
Lookup econtent id The econtent id is the unique id from ecs. 
 
deleteByServer(int $a_server_id)
Delete by server id. 
 
_deleteByObjId($a_obj_id)
Delete by obj_id.