00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00035 define('IL_CRS_TIMINGS_ACTIVATION',0);
00036 define('IL_CRS_TIMINGS_DEACTIVATED',1);
00037 define('IL_CRS_TIMINGS_PRESETTING',2);
00038
00039 class ilCourseItems
00040 {
00041 var $course_obj;
00042 var $ilErr;
00043 var $ilDB;
00044 var $tree;
00045 var $lng;
00046
00047 var $items;
00048 var $parent;
00049
00050 var $timing_type;
00051 var $timing_start;
00052 var $timing_end;
00053
00054
00055 function ilCourseItems(&$course_obj,$a_parent = 0,$user_id = 0)
00056 {
00057 global $ilErr,$ilDB,$lng,$tree;
00058
00059 $this->ilErr =& $ilErr;
00060 $this->ilDB =& $ilDB;
00061 $this->lng =& $lng;
00062 $this->tree =& $tree;
00063
00064 $this->course_obj =& $course_obj;
00065 $this->setParentId($a_parent);
00066 $this->user_id = $user_id;
00067
00068 $this->__read();
00069 }
00070
00071 function getUserId()
00072 {
00073 global $ilUser;
00074
00075 return $this->user_id ? $this->user_id : $ilUser->getId();
00076 }
00077
00078 function _hasCollectionTimings($a_ref_id)
00079 {
00080 global $tree,$ilDB,$ilObjDataCache;
00081
00082
00083 include_once 'Services/Tracking/classes/class.ilLPObjSettings.php';
00084
00085 $obj_id = $ilObjDataCache->lookupObjId($a_ref_id);
00086 switch(ilLPObjSettings::_lookupMode($obj_id))
00087 {
00088 case LP_MODE_COLLECTION:
00089 include_once 'Services/Tracking/classes/class.ilLPCollectionCache.php';
00090 $ids = ilLPCollectionCache::_getItems($obj_id);
00091 break;
00092 default:
00093 $ids = array($a_ref_id);
00094 break;
00095 }
00096 if(!$ids)
00097 {
00098 return false;
00099 }
00100
00101 $query = "SELECT * FROM crs_items ".
00102 "WHERE timing_type = '".IL_CRS_TIMINGS_PRESETTING."' ".
00103 "AND obj_id IN('".implode("','",$ids)."')";
00104
00105 $res = $ilDB->query($query);
00106 return $res->numRows() ? true :false;
00107 }
00108
00109 function _hasChangeableTimings($a_ref_id)
00110 {
00111 global $tree,$ilDB;
00112
00113 $subtree = $tree->getSubTree($tree->getNodeData($a_ref_id));
00114
00115 foreach($subtree as $node)
00116 {
00117 $ref_ids[] = $node['ref_id'];
00118 }
00119
00120 $query = "SELECT * FROM crs_items ".
00121 "WHERE timing_type = '".IL_CRS_TIMINGS_PRESETTING."' ".
00122 "AND changeable = '1' ".
00123 "AND obj_id IN('".implode("','",$ref_ids)."') ".
00124 "AND parent_id IN('".implode("','",$ref_ids)."')";
00125
00126 $res = $ilDB->query($query);
00127 return $res->numRows() ? true :false;
00128 }
00129
00130 function setParentId($a_parent = 0)
00131 {
00132 $this->parent = $a_parent ? $a_parent : $this->course_obj->getRefId();
00133
00134 $this->__read();
00135
00136 return true;
00137 }
00138 function getParentId()
00139 {
00140 return $this->parent;
00141 }
00142
00143 function setTimingType($a_type)
00144 {
00145 $this->timing_type = $a_type;
00146 }
00147 function getTimingType()
00148 {
00149 return $this->timing_type;
00150 }
00151
00152 function setTimingStart($a_start)
00153 {
00154 $this->timing_start = $a_start;
00155 }
00156 function getTimingStart()
00157 {
00158 return $this->timing_start;
00159 }
00160 function setTimingEnd($a_end)
00161 {
00162 $this->timing_end = $a_end;
00163 }
00164 function getTimingEnd()
00165 {
00166 return $this->timing_end;
00167 }
00168 function setSuggestionStart($a_start)
00169 {
00170 $this->suggestion_start = $a_start;
00171 }
00172 function getSuggestionStart()
00173 {
00174 return $this->suggestion_start ? $this->suggestion_start : mktime(0,0,1,date('n',time()),date('j',time()),date('Y',time()));
00175 }
00176 function setSuggestionEnd($a_end)
00177 {
00178 $this->suggestion_end = $a_end;
00179 }
00180 function getSuggestionEnd()
00181 {
00182 return $this->suggestion_end ? $this->suggestion_end : mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
00183 }
00184 function setEarliestStart($a_start)
00185 {
00186 $this->earliest_start = $a_start;
00187 }
00188 function getEarliestStart()
00189 {
00190 return $this->earliest_start ? $this->earliest_start : mktime(0,0,1,date('n',time()),date('j',time()),date('Y',time()));
00191 }
00192 function setLatestEnd($a_end)
00193 {
00194 $this->latest_end = $a_end;
00195 }
00196 function getLatestEnd()
00197 {
00198 return $this->latest_end ? $this->latest_end : mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
00199 }
00200 function toggleVisible($a_status)
00201 {
00202 $this->visible = (int) $a_status;
00203 }
00204 function enabledVisible()
00205 {
00206 return (bool) $this->visible;
00207 }
00208 function toggleChangeable($a_status)
00209 {
00210 $this->changeable = (int) $a_status;
00211 }
00212 function enabledChangeable()
00213 {
00214 return (bool) $this->changeable;
00215 }
00216
00217 function getAllItems()
00218 {
00219 return $this->items ? $this->items : array();
00220 }
00221
00222 function getFilteredItems($a_container_id)
00223 {
00224 include_once 'course/classes/Event/class.ilEventItems.php';
00225
00226 $event_items = ilEventItems::_getItemsOfContainer($a_container_id);
00227
00228 foreach($this->items as $item)
00229 {
00230 if(!in_array($item['ref_id'],$event_items))
00231 {
00232 $filtered[] = $item;
00233 }
00234 }
00235 return $filtered ? $filtered : array();
00236 }
00237
00238 function getItemsByEvent($a_event_id)
00239 {
00240 include_once 'course/classes/Event/class.ilEventItems.php';
00241
00242 $event_items_obj = new ilEventItems($a_event_id);
00243 $event_items = $event_items_obj->getItems();
00244 foreach($event_items as $item)
00245 {
00246 if($this->tree->isDeleted($item))
00247 {
00248 continue;
00249 }
00250 $node = $this->tree->getNodeData($item);
00251 $items[] = $this->__getItemData($node);
00252 }
00253 return $items ? $items : array();
00254 }
00255
00256
00257 function getItems()
00258 {
00259 global $rbacsystem;
00260
00261 foreach($this->items as $item)
00262 {
00263 if($item["type"] != "rolf" and
00264 ($item["timing_type"] or
00265 ($item["timing_start"] <= time() and $item["timing_end"] >= time())))
00266 {
00267 if($rbacsystem->checkAccess('visible',$item['ref_id']))
00268 {
00269 $filtered[] = $item;
00270 }
00271 }
00272 }
00273 return $filtered ? $filtered : array();
00274 }
00275 function getItem($a_item_id)
00276 {
00277 foreach($this->items as $item)
00278 {
00279 if($item["child"] == $a_item_id)
00280 {
00281 return $item;
00282 }
00283 }
00284 return array();
00285 }
00286
00287 function validateActivation()
00288 {
00289 global $ilErr;
00290
00291 $ilErr->setMessage('');
00292
00293 if($this->getTimingType() == IL_CRS_TIMINGS_ACTIVATION)
00294 {
00295 if($this->getTimingStart() > $this->getTimingEnd())
00296 {
00297 $ilErr->appendMessage($this->lng->txt("crs_activation_start_invalid"));
00298 }
00299 }
00300 if($this->getTimingType() == IL_CRS_TIMINGS_PRESETTING)
00301 {
00302 if($this->getSuggestionEnd() > $this->getLatestEnd())
00303 {
00304 $ilErr->appendMessage($this->lng->txt('crs_latest_end_not_valid'));
00305 }
00306 }
00307
00308 #if($this->getTimingType() == IL_CRS_TIMINGS_PRESETTING and
00309 # $this->enabledChangeable())
00310 #{
00311 # if($this->getSuggestionStart() < $this->getEarliestStart() or
00312 # $this->getSuggestionEnd() > $this->getLatestEnd() or
00313 # $this->getSuggestionStart() > $this->getLatestEnd() or
00314 # $this->getSuggestionEnd() < $this->getEarliestStart())
00315 # {
00316 # $ilErr->appendMessage($this->lng->txt("crs_suggestion_not_within_activation"));
00317 # }
00318 #}
00319
00320 if($ilErr->getMessage())
00321 {
00322 return false;
00323 }
00324 return true;
00325 }
00326
00327 function update($a_item_id)
00328 {
00329 $query = "UPDATE crs_items SET ".
00330 "timing_type = '".(int) $this->getTimingType()."', ".
00331 "timing_start = '".(int) $this->getTimingStart()."', ".
00332 "timing_end = '".(int) $this->getTimingEnd()."', ".
00333 "suggestion_start = '".(int) $this->getSuggestionStart()."', ".
00334 "suggestion_end = '".(int) $this->getSuggestionEnd()."', ".
00335 "changeable = '".(int) $this->enabledChangeable()."', ".
00336 "earliest_start = '".(int) $this->getEarliestStart()."', ".
00337 "latest_end = '".(int) $this->getLatestEnd()."', ".
00338 "visible = '".(int) $this->enabledVisible()."' ".
00339 "WHERE parent_id = '".$this->getParentId()."' ".
00340 "AND obj_id = '".$a_item_id."'";
00341
00342 $res = $this->ilDB->query($query);
00343 $this->__read();
00344
00345 return true;
00346 }
00347
00348
00349 function moveUp($item_id)
00350 {
00351 $this->__updateTop($item_id);
00352 $this->__read();
00353
00354 return true;
00355 }
00356 function moveDown($item_id)
00357 {
00358 $this->__updateBottom($item_id);
00359 $this->__read();
00360
00361 return true;
00362 }
00363
00364 function deleteAllEntries()
00365 {
00366 $all_items = $this->tree->getChilds($this->parent);
00367
00368 foreach($all_items as $item)
00369 {
00370 $query = "DELETE FROM crs_items ".
00371 "WHERE parent_id = '".$item["child"]."'";
00372
00373 $this->ilDB->query($query);
00374 }
00375 $query = "DELETE FROM crs_items ".
00376 "WHERE parent_id = '".$this->course_obj->getRefId()."'";
00377
00378 $this->ilDB->query($query);
00379
00380 return true;
00381 }
00382
00383
00384 function __read()
00385 {
00386 $this->items = array();
00387 $all_items = $this->tree->getChilds($this->parent);
00388
00389 foreach($all_items as $item)
00390 {
00391 if($item["type"] != 'rolf')
00392 {
00393 $this->items[] = $item;
00394 }
00395 }
00396
00397 for($i = 0;$i < count($this->items); ++$i)
00398 {
00399 if($this->items[$i]["type"] == 'rolf')
00400 {
00401 unset($this->items[$i]);
00402 continue;
00403 }
00404 $this->items[$i] = $this->__getItemData($this->items[$i]);
00405 }
00406 $this->__purgeDeleted();
00407 $this->__sort();
00408
00409 return true;
00410 }
00411
00412 function __purgeDeleted()
00413 {
00414 global $tree;
00415
00416 $all = array();
00417
00418 $query = "SELECT obj_id FROM crs_items ".
00419 "WHERE parent_id = '".$this->getParentId()."'";
00420
00421 $res = $this->ilDB->query($query);
00422 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00423 {
00424 if($tree->getParentId($row->obj_id) != $this->getParentId())
00425 {
00426 $this->__delete($row->obj_id);
00427 }
00428 }
00429 }
00430
00431 function __delete($a_obj_id)
00432 {
00433
00434 $query = "SELECT position FROM crs_items ".
00435 "WHERE obj_id = '".$a_obj_id."' ".
00436 "AND parent_id = '".$this->getParentId()."'";
00437
00438 $res = $this->ilDB->query($query);
00439 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00440 {
00441 $position = $row->position;
00442 }
00443
00444
00445 $query = "UPDATE crs_items SET ".
00446 "position = CASE ".
00447 "WHEN position > '".$position."' ".
00448 "THEN position - 1 ".
00449 "ELSE position ".
00450 "END ".
00451 "WHERE parent_id = '".$this->getParentId()."'";
00452
00453 $res = $this->ilDB->query($query);
00454
00455
00456 $query = "DELETE FROM crs_items ".
00457 "WHERE parent_id = '".$this->getParentId()."' ".
00458 "AND obj_id = '".$a_obj_id."'";
00459
00460 $res = $this->ilDB->query($query);
00461
00462 return true;
00463 }
00464
00465 function __getItemData($a_item)
00466 {
00467 global $ilDB,$ilUser,$ilObjDataCache;
00468
00469 $query = "SELECT * FROM crs_items ".
00470 "WHERE obj_id = '".$a_item['child']."' ".
00471 "AND parent_id = '".$a_item['parent']."'";
00472
00473 $res = $this->ilDB->query($query);
00474 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00475 {
00476 $a_item["timing_type"] = $row->timing_type;
00477 $a_item["timing_start"] = $row->timing_start;
00478 $a_item["timing_end"] = $row->timing_end;
00479 $a_item["suggestion_start"] = $row->suggestion_start ? $row->suggestion_start :
00480 mktime(0,0,1,date('n',time()),date('j',time()),date('Y',time()));
00481 $a_item["suggestion_end"] = $row->suggestion_end ? $row->suggestion_end :
00482 mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
00483 $a_item['changeable'] = $row->changeable;
00484 $a_item['earliest_start'] = $row->earliest_start ? $row->earliest_start :
00485 mktime(0,0,1,date('n',time()),date('j',time()),date('Y',time()));
00486 $a_item['latest_end'] = $row->latest_end ? $row->latest_end :
00487 mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
00488 $a_item['visible'] = $row->visible;
00489 $a_item["position"] = $row->position;
00490
00491 include_once 'course/classes/Timings/class.ilTimingPlaned.php';
00492 $data = ilTimingPlaned::_getPlanedTimings($this->getUserId(),$a_item['child']);
00493
00494
00495 if($a_item['changeable'] and
00496 $a_item['timing_type'] == IL_CRS_TIMINGS_PRESETTING)
00497 {
00498 if($data['planed_start'])
00499 {
00500 $a_item['start'] = $data['planed_start'];
00501 $a_item['end'] = $data['planed_end'];
00502 $a_item['activation_info'] = 'crs_timings_planed_info';
00503 }
00504 else
00505 {
00506 $a_item['start'] = $row->suggestion_start;
00507 $a_item['end'] = $row->suggestion_end;
00508 $a_item['activation_info'] = 'crs_timings_suggested_info';
00509 }
00510 }
00511 elseif($a_item['timing_type'] == IL_CRS_TIMINGS_PRESETTING)
00512 {
00513 $a_item['start'] = $row->suggestion_start;
00514 $a_item['end'] = $row->suggestion_end;
00515 $a_item['activation_info'] = 'crs_timings_suggested_info';
00516 }
00517 elseif($a_item['timing_type'] == IL_CRS_TIMINGS_ACTIVATION)
00518 {
00519 $a_item['start'] = $row->timing_start;
00520 $a_item['end'] = $row->timing_end;
00521 $a_item['activation_info'] = 'activation';
00522 }
00523 else
00524 {
00525 $a_item['start'] = 999999999;
00526 }
00527 }
00528
00529 if(!isset($a_item["position"]))
00530 {
00531 $a_item = $this->createDefaultEntry($a_item);
00532 }
00533 return $a_item;
00534 }
00535
00536 function createDefaultEntry($a_item)
00537 {
00538 $a_item["timing_type"] = IL_CRS_TIMINGS_DEACTIVATED;
00539 $a_item["timing_start"] = time();
00540 $a_item["timing_end"] = time();
00541 $a_item["suggestion_start"] = time();
00542 $a_item["suggestion_end"] = time();
00543 $a_item["position"] = $this->__getLastPosition() + 1;
00544 $a_item['visible'] = 0;
00545 $a_item['changeable'] = 0;
00546 $a_item['earliest_start'] = time();
00547 $a_item['latest_end'] = mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
00548 $a_item['visible'] = 0;
00549 $a_item['changeable'] = 0;
00550
00551
00552 $query = "INSERT INTO crs_items ".
00553 "VALUES('".$a_item['parent']."','".
00554 $a_item["child"]."','".
00555 $a_item["timing_type"]."','".
00556 $a_item["timing_start"]."','".
00557 $a_item["timing_end"]."','".
00558 $a_item["suggestion_start"]."','".
00559 $a_item["suggestion_end"]."','".
00560 $a_item["changeable"]."','".
00561 $a_item['earliest_start']."',' ".
00562 $a_item['latest_end']."',' ".
00563 $a_item["visible"]."','".
00564 $a_item["position"]."')";
00565
00566 $res = $this->ilDB->query($query);
00567
00568 return $a_item;
00569 }
00570
00571
00572 function __getLastPosition()
00573 {
00574 $query = "SELECT MAX(position) as last_position FROM crs_items ".
00575 "WHERE parent_id = '".$this->getParentId()."'";
00576
00577 $res = $this->ilDB->query($query);
00578 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00579 {
00580 $max = $row->last_position;
00581 }
00582 return $max ? $max : 0;
00583 }
00584
00585 function __updateTop($item_id)
00586 {
00587 $query = "SELECT position,obj_id FROM crs_items ".
00588 "WHERE obj_id = '".$item_id."' ".
00589 "AND parent_id = '".$this->getParentId()."'";
00590
00591 $res = $this->ilDB->query($query);
00592 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00593 {
00594 $node_a["position"] = $row->position;
00595 $node_a["obj_id"] = $row->obj_id;
00596 }
00597
00598 $query = "SELECT position, obj_id FROM crs_items ".
00599 "WHERE position < '".$node_a["position"]."' ".
00600 "AND parent_id = '".$this->getParentId()."' ".
00601 "ORDER BY position DESC";
00602
00603 $res = $this->ilDB->query($query);
00604 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00605 {
00606 if(!$this->__isMovable($row->obj_id))
00607 {
00608 continue;
00609 }
00610 $node_b["position"] = $row->position;
00611 $node_b["obj_id"] = $row->obj_id;
00612 break;
00613 }
00614 $this->__switchNodes($node_a,$node_b);
00615
00616 }
00617
00618 function __updateBottom($item_id)
00619 {
00620 $query = "SELECT position,obj_id FROM crs_items ".
00621 "WHERE obj_id = '".$item_id."' ".
00622 "AND parent_id = '".$this->getParentId()."'";
00623
00624 $res = $this->ilDB->query($query);
00625 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00626 {
00627 $node_a["position"] = $row->position;
00628 $node_a["obj_id"] = $row->obj_id;
00629 break;
00630 }
00631 $query = "SELECT position ,obj_id FROM crs_items ".
00632 "WHERE position > '".$node_a["position"]."' ".
00633 "AND parent_id = '".$this->getParentId()."' ".
00634 "ORDER BY position ASC";
00635
00636 $res = $this->ilDB->query($query);
00637 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00638 {
00639 if(!$this->__isMovable($row->obj_id))
00640 {
00641 continue;
00642 }
00643 $node_b["position"] = $row->position;
00644 $node_b["obj_id"] = $row->obj_id;
00645 break;
00646 }
00647 $this->__switchNodes($node_a,$node_b);
00648
00649 return true;
00650 }
00651
00652 function __isMovable($a_ref_id)
00653 {
00654 include_once 'course/classes/Event/class.ilEventItems.php';
00655
00656 global $ilObjDataCache;
00657
00658 if($ilObjDataCache->lookupType($ilObjDataCache->lookupObjId($a_ref_id)) != 'crs')
00659 {
00660 return true;
00661 }
00662 if(ilEventItems::_isAssigned($a_ref_id))
00663 {
00664 return false;
00665 }
00666 return true;
00667 }
00668
00669 function __switchNodes($node_a,$node_b)
00670 {
00671 if(!$node_b["obj_id"])
00672 {
00673 return false;
00674 }
00675
00676 $query = "UPDATE crs_items SET ".
00677 "position = '".$node_a["position"]."' ".
00678 "WHERE obj_id = '".$node_b["obj_id"]."' ".
00679 "AND parent_id = '".$this->getParentId()."'";
00680
00681 $res = $this->ilDB->query($query);
00682
00683 $query = "UPDATE crs_items SET ".
00684 "position = '".$node_b["position"]."' ".
00685 "WHERE obj_id = '".$node_a["obj_id"]."' ".
00686 "AND parent_id = '".$this->getParentId()."'";
00687
00688 $res = $this->ilDB->query($query);
00689
00690 return true;
00691 }
00692
00693
00694 function __sort()
00695 {
00696 switch($this->course_obj->getOrderType())
00697 {
00698 case IL_CRS_SORT_MANUAL:
00699 $this->items = ilUtil::sortArray($this->items,"position","asc",true);
00700 break;
00701
00702 case IL_CRS_SORT_TITLE:
00703 $this->items = ilUtil::sortArray($this->items,"title","asc");
00704 break;
00705
00706 case IL_CRS_SORT_ACTIVATION:
00707
00708
00709 list($active,$inactive) = $this->__splitByActivation();
00710
00711 $sorted_active = ilUtil::sortArray($active,"start","asc");
00712 $sorted_inactive = ilUtil::sortArray($inactive,'title','asc');
00713
00714 $this->items = array_merge($sorted_active,$sorted_inactive);
00715 break;
00716 }
00717 return true;
00718 }
00719
00720 function __splitByActivation()
00721 {
00722 $inactive = $active = array();
00723 foreach($this->items as $item)
00724 {
00725 if($item['timing_type'] == IL_CRS_TIMINGS_DEACTIVATED)
00726 {
00727 $inactive[] = $item;
00728 }
00729 else
00730 {
00731 $active[] = $item;
00732 }
00733 }
00734 return array($active,$inactive);
00735 }
00736
00737 function _getItem($a_item_id)
00738 {
00739 include_once 'course/classes/class.ilObjCourse.php';
00740
00741 global $ilDB,$ilUser;
00742
00743 $query = "SELECT * FROM crs_items ".
00744 "WHERE obj_id = '".$a_item_id."'";
00745 $res = $ilDB->query($query);
00746 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00747 {
00748 $data['parent_id'] = $row->parent_id;
00749 $data['obj_id'] = $row->obj_id;
00750 $data['timing_type'] = $row->timing_type;
00751 $data['timing_start'] = $row->timing_start;
00752 $data['timing_end'] = $row->timing_end;
00753 $data["suggestion_start"] = $row->suggestion_start ? $row->suggestion_start :
00754 mktime(0,0,1,date('n',time()),date('j',time()),date('Y',time()));
00755 $data["suggestion_end"] = $row->suggestion_end ? $row->suggestion_end :
00756 mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
00757 $data['changeable'] = $row->changeable;
00758 $data['earliest_start'] = $row->earliest_start ? $row->earliest_start :
00759 mktime(0,0,1,date('n',time()),date('j',time()),date('Y',time()));
00760 $data['latest_end'] = $row->latest_end ? $row->latest_end :
00761 mktime(23,55,00,date('n',time()),date('j',time()),date('Y',time()));
00762 $data['visible'] = $row->visible;
00763 $data['position'] = $row->position;
00764
00765
00766 include_once 'course/classes/Timings/class.ilTimingPlaned.php';
00767 $user_data = ilTimingPlaned::_getPlanedTimings($ilUser->getId(),$a_item['child']);
00768
00769
00770 if($data['changeable'] and
00771 $data['timing_type'] == IL_CRS_TIMINGS_PRESETTING)
00772 {
00773 if($user_data['planed_start'])
00774 {
00775 $data['start'] = $user_data['planed_start'];
00776 $data['end'] = $user_data['planed_end'];
00777 $data['activation_info'] = 'crs_timings_planed_info';
00778 }
00779 else
00780 {
00781 $data['start'] = $row->suggestion_start;
00782 $data['end'] = $row->suggestion_end;
00783 $data['activation_info'] = 'crs_timings_suggested_info';
00784 }
00785 }
00786 elseif($data['timing_type'] == IL_CRS_TIMINGS_PRESETTING)
00787 {
00788 $data['start'] = $row->suggestion_start;
00789 $data['end'] = $row->suggestion_end;
00790 $data['activation_info'] = 'crs_timings_suggested_info';
00791 }
00792 elseif($data['timing_type'] == IL_CRS_TIMINGS_ACTIVATION)
00793 {
00794 $data['start'] = $row->timing_start;
00795 $data['end'] = $row->timing_end;
00796 $data['activation_info'] = 'activation';
00797 }
00798 else
00799 {
00800 $data['start'] = 999999999;
00801 }
00802 }
00803 return $data ? $data : array();
00804 }
00805
00806 function _isActivated($a_item_id)
00807 {
00808 global $ilDB;
00809
00810 $query = "SELECT * FROM crs_items ".
00811 "WHERE obj_id = '".$a_item_id."'";
00812
00813 $res = $ilDB->query($query);
00814 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
00815 {
00816 if($row->activation_unlimited)
00817 {
00818 return true;
00819 }
00820 if(time() > $row->activation_start and time() < $row->activation_end)
00821 {
00822 return true;
00823 }
00824 }
00825 return false;
00826 }
00827
00828
00829 }
00830 ?>