31 $this->obj_id = $a_obj_id;
35 public static function treeExists($a_server_id, $a_mid, $a_tree_id)
39 $query =
'SELECT COUNT(*) num FROM ecs_cms_data '.
40 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
41 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
42 'AND tree_id = '.$ilDB->quote($a_tree_id,
'integer');
47 return $row->num > 0 ?
true :
false;
66 $query =
'SELECT ed.obj_id obj_id FROM ecs_cms_data ed '.
67 'LEFT JOIN ecs_cms_tree et ON ed.obj_id = et.child '.
68 'WHERE et.child IS NULL '.
69 'AND server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
70 'AND mid = '.$ilDB->quote($a_mid).
' '.
71 'AND tree_id = '.$ilDB->quote($a_tree_id);
86 $query =
'SELECT obj_id FROM ecs_cms_data '.
87 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
88 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
89 'AND tree_id = '.$ilDB->quote($a_tree_id,
'integer').
' '.
90 'AND cms_id = '.$ilDB->quote(
$cms_id,
'integer');
93 #$GLOBALS['ilLog']->write(__METHOD__.': '.$query);
114 $query =
'SELECT tree_id FROM ecs_cms_data '.
115 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
116 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
117 'AND cms_id = '.$ilDB->quote(
$cms_id,
'integer').
' '.
123 return $row->tree_id;
132 public static function lookupTitle($a_server_id, $a_mid, $a_tree_id)
136 $query =
'SELECT * FROM ecs_cms_data '.
137 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
138 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
139 'AND tree_id = '.$ilDB->quote($a_tree_id,
'integer');
159 $query =
'SELECT term FROM ecs_cms_data '.
160 'JOIN ecs_cms_tree ON obj_id = child '.
161 'WHERE tree = '.$ilDB->quote($a_tree_id,
'integer').
' '.
162 'AND server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
163 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
164 'AND tree_id = '.$ilDB->quote($a_tree_id,
'integer').
' '.
182 $query =
'SELECT status,deleted FROM ecs_cms_data '.
183 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
184 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
185 'AND tree_id = '.$ilDB->quote($a_tree_id,
'integer').
' '.
186 'AND obj_id = '.$ilDB->quote(
$obj_id,
'integer');
207 $query =
'SELECT status FROM ecs_cms_data '.
208 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
209 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
210 'AND tree_id = '.$ilDB->quote($a_tree_id,
'integer').
' '.
211 'AND cms_id = '.$ilDB->quote(
$cms_id,
'integer');
226 include_once
'./Services/WebServices/ECS/classes/Mapping/class.ilECSNodeMappingAssignments.php';
227 include_once
'./Services/WebServices/ECS/classes/Tree/class.ilECSCmsTree.php';
231 $subIds =
self::lookupCmsIds(array_merge($cmsTree->getSubTreeIds($assignment),array($assignment)));
238 self::MAPPING_MAPPED);
249 return (
int) $cms_ids[0];
257 $query =
'SELECT cms_id FROM ecs_cms_data '.
258 'WHERE '.$ilDB->in(
'obj_id',$a_obj_ids,
false,
'integer');
264 $cms_ids[] =
$row->cms_id;
280 $query =
'SELECT cms_id FROM ecs_cms_data '.
281 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
282 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
283 'AND tree_id = '.$ilDB->quote($a_tree_id,
'integer');
288 $cms_ids[] =
$row->cms_id;
307 $query =
'UPDATE ecs_cms_data '.
308 'SET status = '.$ilDB->quote(
$status,
'integer').
' '.
309 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
310 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
311 'AND tree_id = '.$ilDB->quote($a_tree_id,
'integer').
' '.
312 'AND '. $ilDB->in(
'cms_id',$cms_ids,
false,
'integer');
313 $ilDB->manipulate(
$query);
331 $query =
'UPDATE ecs_cms_data '.
332 'SET status = '.$ilDB->quote(
$status,
'integer').
' '.
333 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
334 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
335 'AND tree_id = '.$ilDB->quote($a_tree_id,
'integer').
' ';
336 $ilDB->manipulate(
$query);
347 public static function writeAllDeleted($a_server_id, $a_mid, $a_tree_id, $a_deleted_flag)
351 $query =
'UPDATE ecs_cms_data '.
352 'SET deleted = '.$ilDB->quote($a_deleted_flag,
'integer').
' '.
353 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
354 'AND mid = '.$ilDB->quote($a_mid,
'integer').
' '.
355 'AND tree_id = '.$ilDB->quote($a_tree_id,
'integer').
' ';
356 $ilDB->manipulate(
$query);
364 $query =
'SELECT DISTINCT(tree_id) tid FROM ecs_cms_data '.
365 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer').
' '.
366 'AND mid = '.$ilDB->quote($a_mid,
'integer');
372 $tree_ids[] =
$row->tid;
374 return (array) $tree_ids;
380 $this->title = $a_title;
390 $this->term = $a_term;
400 $this->obj_id = $a_id;
410 $this->cms_id = $a_id;
420 $this->server_id = $a_id;
430 $this->tree_id = $a_id;
450 $this->status = $a_status;
460 $this->deleted = $a_is_deleted;
473 $this->obj_id = $ilDB->nextId(
'ecs_cms_data');
475 $query =
'INSERT INTO ecs_cms_data (obj_id,server_id,mid,tree_id,cms_id,title,term,status,deleted) '.
477 $ilDB->quote($this->obj_id,
'integer').
', '.
478 $ilDB->quote($this->server_id,
'integer') .
', ' .
479 $ilDB->quote($this->mid,
'integer').
', '.
480 $ilDB->quote($this->tree_id,
'integer').
', '.
481 $ilDB->quote($this->cms_id,
'integer').
', '.
482 $ilDB->quote($this->title,
'text').
', '.
483 $ilDB->quote($this->term,
'text').
', '.
484 $ilDB->quote($this->status,
'integer').
', '.
485 $ilDB->quote($this->deleted,
'integer').
' '.
487 $ilDB->manipulate(
$query);
495 $query =
"UPDATE ecs_cms_data SET ".
496 'title = '.$ilDB->quote($this->title,
'text').
', '.
497 'term = '.$ilDB->quote($this->term,
'text').
', '.
498 'status = '.$ilDB->quote($this->status,
'text').
', '.
499 'deleted = '.$ilDB->quote($this->
isDeleted(),
'integer').
' '.
500 'WHERE obj_id = '.$ilDB->quote($this->obj_id,
'integer');
501 $ilDB->manipulate(
$query);
504 public function delete()
508 $query =
"DELETE FROM ecs_cms_data ".
509 'WHERE obj_id = '.$ilDB->quote($this->obj_id,
'integer');
510 $ilDB->manipulate(
$query);
517 $query =
"DELETE FROM ecs_cms_data ".
518 'WHERE server_id = '.$ilDB->quote($this->server_id,
'integer').
' '.
519 'AND mid = '.$ilDB->quote($this->mid,
'integer').
' '.
520 'AND tree_id = '.$ilDB->quote($this->tree_id,
'integer').
' ';
521 $ilDB->manipulate(
$query);
528 $query =
"DELETE FROM ecs_cms_data ".
529 'WHERE server_id = '.$ilDB->quote($a_server_id,
'integer');
530 $ilDB->manipulate(
$query);
537 $query =
'SELECT * FROM ecs_cms_data '.
538 'WHERE obj_id = '.$ilDB->quote($this->obj_id,
'integer');
542 $this->title =
$row->title;
543 $this->term =
$row->term;
544 $this->server_id =
$row->server_id;
545 $this->mid =
$row->mid;
546 $this->tree_id =
$row->tree_id;
547 $this->cms_id =
$row->cms_id;
548 $this->status =
$row->status;
549 $this->deleted =
$row->deleted;