00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00035 include_once "./classes/class.ilObject.php";
00036 include_once "./survey/classes/inc.SurveyConstants.php";
00037
00038 class ilObjSurveyQuestionPool extends ilObject
00039 {
00045 var $online;
00046
00053 function ilObjSurveyQuestionPool($a_id = 0,$a_call_by_reference = true)
00054 {
00055 $this->type = "spl";
00056 $this->ilObject($a_id,$a_call_by_reference);
00057 }
00058
00062 function create($a_upload = false)
00063 {
00064 parent::create();
00065 if(!$a_upload)
00066 {
00067 $this->createMetaData();
00068 }
00069 }
00070
00077 function update()
00078 {
00079 $this->updateMetaData();
00080 if (!parent::update())
00081 {
00082 return false;
00083 }
00084
00085
00086
00087 return true;
00088 }
00089
00095 function read($a_force_db = false)
00096 {
00097 parent::read($a_force_db);
00098 $this->loadFromDb();
00099 }
00100
00108 function loadFromDb()
00109 {
00110 global $ilDB;
00111
00112 $query = sprintf("SELECT * FROM survey_questionpool WHERE obj_fi = %s",
00113 $ilDB->quote($this->getId() . "")
00114 );
00115 $result = $ilDB->query($query);
00116 if ($result->numRows() == 1)
00117 {
00118 $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
00119 $this->setOnline($row["online"]);
00120 }
00121 }
00122
00130 function saveToDb()
00131 {
00132 global $ilDB;
00133
00134 $query = sprintf("SELECT * FROM survey_questionpool WHERE obj_fi = %s",
00135 $ilDB->quote($this->getId() . "")
00136 );
00137 $result = $ilDB->query($query);
00138 if ($result->numRows() == 1)
00139 {
00140 $query = sprintf("UPDATE survey_questionpool SET online = %s WHERE obj_fi = %s",
00141 $ilDB->quote($this->getOnline() . ""),
00142 $ilDB->quote($this->getId() . "")
00143 );
00144 $result = $ilDB->query($query);
00145 if ($result != DB_OK)
00146 {
00147 }
00148 }
00149 else
00150 {
00151 $query = sprintf("INSERT INTO survey_questionpool (online, obj_fi) VALUES (%s, %s)",
00152 $ilDB->quote($this->getOnline() . ""),
00153 $ilDB->quote($this->getId() . "")
00154 );
00155 $result = $ilDB->query($query);
00156 if ($result != DB_OK)
00157 {
00158 }
00159 }
00160 }
00161
00169 function ilClone($a_parent_ref)
00170 {
00171 global $rbacadmin;
00172
00173
00174 $new_ref_id = parent::ilClone($a_parent_ref);
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 return $new_ref_id;
00190 }
00191
00198 function delete()
00199 {
00200 $remove = parent::delete();
00201
00202 if (!$remove)
00203 {
00204 return false;
00205 }
00206
00207
00208 $this->deleteAllData();
00209
00210
00211 $this->deleteMetaData();
00212
00213 return true;
00214 }
00215
00216 function deleteAllData()
00217 {
00218 $query = sprintf("SELECT question_id FROM survey_question WHERE obj_fi = %s AND original_id IS NULL",
00219 $this->ilias->db->quote($this->getId())
00220 );
00221 $result = $this->ilias->db->query($query);
00222 $found_questions = array();
00223 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00224 {
00225 $this->removeQuestion($row["question_id"]);
00226 }
00227
00228
00229 include_once "./classes/class.ilUtil.php";
00230 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
00231 $directory = $spl_data_dir."/spl_".$this->getId();
00232 if (is_dir($directory))
00233 {
00234 include_once "./classes/class.ilUtil.php";
00235 ilUtil::delDir($directory);
00236 }
00237 }
00238
00252 function notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params = 0)
00253 {
00254 global $tree;
00255
00256 switch ($a_event)
00257 {
00258 case "link":
00259
00260
00261
00262
00263 break;
00264
00265 case "cut":
00266
00267
00268
00269 break;
00270
00271 case "copy":
00272
00273
00274
00275
00276 break;
00277
00278 case "paste":
00279
00280
00281
00282 break;
00283
00284 case "new":
00285
00286
00287
00288 break;
00289 }
00290
00291
00292 if ($a_node_id==$_GET["ref_id"])
00293 {
00294 $parent_obj =& $this->ilias->obj_factory->getInstanceByRefId($a_node_id);
00295 $parent_type = $parent_obj->getType();
00296 if($parent_type == $this->getType())
00297 {
00298 $a_node_id = (int) $tree->getParentId($a_node_id);
00299 }
00300 }
00301
00302 parent::notify($a_event,$a_ref_id,$a_parent_non_rbac_id,$a_node_id,$a_params);
00303 }
00304
00310 function getTitle()
00311 {
00312
00313 return parent::getTitle();
00314 }
00315
00319 function setTitle($a_title)
00320 {
00321 parent::setTitle($a_title);
00322 }
00323
00332 function removeQuestion($question_id)
00333 {
00334 if ($question_id < 1)
00335 return;
00336
00337 include_once "./survey/classes/class.SurveyQuestion.php";
00338 $question =& SurveyQuestion::_instanciateQuestion($question_id);
00339 $question->delete($question_id);
00340 }
00341
00351 function getQuestiontype($question_id)
00352 {
00353 if ($question_id < 1)
00354 return;
00355
00356 $query = sprintf("SELECT survey_questiontype.type_tag FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id AND survey_question.question_id = %s",
00357 $this->ilias->db->quote($question_id)
00358 );
00359 $result = $this->ilias->db->query($query);
00360 if ($result->numRows() == 1) {
00361 $data = $result->fetchRow(DB_FETCHMODE_OBJECT);
00362 return $data->type_tag;
00363 } else {
00364 return;
00365 }
00366 }
00367
00377 function isInUse($question_id)
00378 {
00379
00380 $query = sprintf("SELECT answer_id FROM survey_answer WHERE question_fi = %s",
00381 $this->ilias->db->quote($question_id)
00382 );
00383 $result = $this->ilias->db->query($query);
00384 $answered = $result->numRows();
00385
00386
00387 $query = sprintf("SELECT survey_survey.* FROM survey_survey, survey_survey_question WHERE survey_survey_question.survey_fi = survey_survey.survey_id AND survey_survey_question.question_fi = %s",
00388 $this->ilias->db->quote($question_id)
00389 );
00390 $result = $this->ilias->db->query($query);
00391 $inserted = $result->numRows();
00392 if (($inserted + $answered) == 0)
00393 {
00394 return false;
00395 }
00396 $result_array = array();
00397 while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
00398 {
00399 array_push($result_array, $row);
00400 }
00401 return $result_array;
00402 }
00403
00412 function paste($question_id)
00413 {
00414 $this->duplicateQuestion($question_id, $this->getId());
00415 }
00416
00426 function &getQuestionsInfo($question_array)
00427 {
00428 $result_array = array();
00429 $query = sprintf("SELECT survey_question.*, survey_questiontype.type_tag FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id AND survey_question.question_id IN (%s)",
00430 join($question_array, ",")
00431 );
00432 $result = $this->ilias->db->query($query);
00433 while ($row = $result->fetchRow(DB_FETCHMODE_OBJECT))
00434 {
00435 array_push($result_array, $row);
00436 }
00437 return $result_array;
00438 }
00439
00448 function duplicateQuestion($question_id, $obj_id = "")
00449 {
00450 global $ilUser;
00451
00452 $questiontype = $this->getQuestiontype($question_id);
00453 include_once "./survey/classes/class.$questiontype.php";
00454 $question = new $questiontype();
00455 $question->loadFromDb($question_id);
00456 $suffix = "";
00457 $counter = 1;
00458 while ($question->questionTitleExists($question->getTitle().$suffix, $obj_id))
00459 {
00460 $counter++;
00461 if ($counter > 1) $suffix = " ($counter)";
00462 }
00463 if ($obj_id)
00464 {
00465 $question->setObjId($obj_id);
00466 }
00467 $question->duplicate(false, $question->getTitle() . $suffix, $ilUser->fullname, $ilUser->id);
00468 }
00469
00478 function deletePhrases($phrase_array)
00479 {
00480 $query = "DELETE FROM survey_phrase WHERE phrase_id IN (" . join($phrase_array, ",") . ")";
00481 $result = $this->ilias->db->query($query);
00482 $query = "DELETE FROM survey_phrase_category WHERE phrase_fi IN (" . join($phrase_array, ",") . ")";
00483 $result = $this->ilias->db->query($query);
00484 }
00485
00493 function getQuestionsTable($sortoptions, $filter_text, $sel_filter_type, $startrow = 0)
00494 {
00495 global $ilUser;
00496 $where = "";
00497 if (strlen($filter_text) > 0) {
00498 switch($sel_filter_type) {
00499 case "title":
00500 $where = " AND survey_question.title LIKE " . $this->ilias->db->quote("%" . $filter_text . "%");
00501 break;
00502 case "description":
00503 $where = " AND survey_question.description LIKE " . $this->ilias->db->quote("%" . $filter_text . "%");
00504 break;
00505 case "author":
00506 $where = " AND survey_question.author LIKE " . $this->ilias->db->quote("%" . $filter_text . "%");
00507 break;
00508 }
00509 }
00510
00511
00512 $order = "";
00513 $images = array();
00514 include_once "./classes/class.ilUtil.php";
00515 if (count($sortoptions))
00516 {
00517 foreach ($sortoptions as $key => $value)
00518 {
00519 switch($key)
00520 {
00521 case "title":
00522 $order = " ORDER BY title $value";
00523 $images["title"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
00524 break;
00525 case "description":
00526 $order = " ORDER BY description $value";
00527 $images["description"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
00528 break;
00529 case "type":
00530 $order = " ORDER BY questiontype_id $value";
00531 $images["type"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
00532 break;
00533 case "author":
00534 $order = " ORDER BY author $value";
00535 $images["author"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
00536 break;
00537 case "created":
00538 $order = " ORDER BY created $value";
00539 $images["created"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
00540 break;
00541 case "updated":
00542 $order = " ORDER BY TIMESTAMP14 $value";
00543 $images["updated"] = " <img src=\"" . ilUtil::getImagePath(strtolower($value) . "_order.png", true) . "\" alt=\"" . strtolower($value) . "ending order\" />";
00544 break;
00545 }
00546 }
00547 }
00548 $maxentries = $ilUser->prefs["hits_per_page"];
00549 if ($maxentries < 1)
00550 {
00551 $maxentries = 9999;
00552 }
00553 $query = "SELECT survey_question.question_id, survey_question.TIMESTAMP + 0 AS TIMESTAMP14 FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id AND survey_question.obj_fi = " . $this->getId() . " AND ISNULL(survey_question.original_id) $where$order$limit";
00554 $query_result = $this->ilias->db->query($query);
00555 $max = $query_result->numRows();
00556 if ($startrow > $max -1)
00557 {
00558 $startrow = $max - ($max % $maxentries);
00559 }
00560 else if ($startrow < 0)
00561 {
00562 $startrow = 0;
00563 }
00564 $limit = " LIMIT $startrow, $maxentries";
00565 $query = "SELECT survey_question.*, survey_question.TIMESTAMP + 0 AS TIMESTAMP14, survey_questiontype.type_tag FROM survey_question, survey_questiontype WHERE survey_question.questiontype_fi = survey_questiontype.questiontype_id AND survey_question.obj_fi = " . $this->getId() . " AND ISNULL(survey_question.original_id) $where$order$limit";
00566 $query_result = $this->ilias->db->query($query);
00567 $rows = array();
00568 if ($query_result->numRows())
00569 {
00570 while ($row = $query_result->fetchRow(DB_FETCHMODE_ASSOC))
00571 {
00572 array_push($rows, $row);
00573 }
00574 }
00575 $nextrow = $startrow + $maxentries;
00576 if ($nextrow > $max - 1)
00577 {
00578 $nextrow = $startrow;
00579 }
00580 $prevrow = $startrow - $maxentries;
00581 if ($prevrow < 0)
00582 {
00583 $prevrow = 0;
00584 }
00585 return array(
00586 "rows" => $rows,
00587 "images" => $images,
00588 "startrow" => $startrow,
00589 "nextrow" => $nextrow,
00590 "prevrow" => $prevrow,
00591 "step" => $maxentries,
00592 "rowcount" => $max
00593 );
00594 }
00595
00601 function createExportDirectory()
00602 {
00603 include_once "./classes/class.ilUtil.php";
00604 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
00605 ilUtil::makeDir($spl_data_dir);
00606 if(!is_writable($spl_data_dir))
00607 {
00608 $this->ilias->raiseError("Survey Questionpool Data Directory (".$spl_data_dir
00609 .") not writeable.",$this->ilias->error_obj->FATAL);
00610 }
00611
00612
00613 $spl_dir = $spl_data_dir."/spl_".$this->getId();
00614 ilUtil::makeDir($spl_dir);
00615 if(!@is_dir($spl_dir))
00616 {
00617 $this->ilias->raiseError("Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
00618 }
00619
00620 $export_dir = $spl_dir."/export";
00621 ilUtil::makeDir($export_dir);
00622 if(!@is_dir($export_dir))
00623 {
00624 $this->ilias->raiseError("Creation of Export Directory failed.",$this->ilias->error_obj->FATAL);
00625 }
00626 }
00627
00631 function getExportDirectory()
00632 {
00633 include_once "./classes/class.ilUtil.php";
00634 $export_dir = ilUtil::getDataDir()."/spl_data"."/spl_".$this->getId()."/export";
00635 return $export_dir;
00636 }
00637
00641 function getExportFiles($dir)
00642 {
00643
00644 if (!@is_dir($dir) or
00645 !is_writeable($dir))
00646 {
00647 return array();
00648 }
00649
00650
00651 $dir = dir($dir);
00652
00653
00654 $file = array();
00655
00656
00657 while ($entry = $dir->read())
00658 {
00659 if ($entry != "." and
00660 $entry != ".." and
00661 substr($entry, -4) == ".xml" and
00662 ereg("^[0-9]{10}_{2}[0-9]+_{2}(spl__)*[0-9]+\.xml\$", $entry))
00663 {
00664 $file[] = $entry;
00665 }
00666 }
00667
00668
00669 $dir->close();
00670
00671 sort ($file);
00672 reset ($file);
00673
00674 return $file;
00675 }
00676
00682 function createImportDirectory()
00683 {
00684 include_once "./classes/class.ilUtil.php";
00685 $spl_data_dir = ilUtil::getDataDir()."/spl_data";
00686 ilUtil::makeDir($spl_data_dir);
00687
00688 if(!is_writable($spl_data_dir))
00689 {
00690 $this->ilias->raiseError("Survey Questionpool Data Directory (".$spl_data_dir
00691 .") not writeable.",$this->ilias->error_obj->FATAL);
00692 }
00693
00694
00695 $spl_dir = $spl_data_dir."/spl_".$this->getId();
00696 ilUtil::makeDir($spl_dir);
00697 if(!@is_dir($spl_dir))
00698 {
00699 $this->ilias->raiseError("Creation of Survey Questionpool Directory failed.",$this->ilias->error_obj->FATAL);
00700 }
00701
00702
00703 $import_dir = $spl_dir."/import";
00704 ilUtil::makeDir($import_dir);
00705 if(!@is_dir($import_dir))
00706 {
00707 $this->ilias->raiseError("Creation of Import Directory failed.",$this->ilias->error_obj->FATAL);
00708 }
00709 }
00710
00714 function getImportDirectory()
00715 {
00716 include_once "./classes/class.ilUtil.php";
00717 $import_dir = ilUtil::getDataDir()."/spl_data".
00718 "/spl_".$this->getId()."/import";
00719 if(@is_dir($import_dir))
00720 {
00721 return $import_dir;
00722 }
00723 else
00724 {
00725 return false;
00726 }
00727 }
00728
00732 function to_xml($questions)
00733 {
00734 if (!is_array($questions))
00735 {
00736 $questions =& $this->getQuestions();
00737 }
00738 if (count($questions) == 0)
00739 {
00740 $questions =& $this->getQuestions();
00741 }
00742 $xml = "";
00743
00744 foreach ($questions as $key => $value)
00745 {
00746 $questiontype = $this->getQuestiontype($value);
00747 include_once "./survey/classes/class.$questiontype.php";
00748 $question = new $questiontype();
00749 $question->loadFromDb($value);
00750 $xml .= $question->to_xml(false);
00751 }
00752 if (count($questions) > 1)
00753 {
00754 $xml = preg_replace("/<\/questestinterop>\s*<questestinterop>/", "", $xml);
00755 }
00756 $xml = str_replace("<questestinterop>", "", $xml);
00757 $xml = str_replace("</questestinterop>", "", $xml);
00758
00759 include_once("./classes/class.ilXmlWriter.php");
00760 $a_xml_writer = new ilXmlWriter;
00761
00762 $a_xml_writer->xmlHeader();
00763 $a_xml_writer->xmlStartTag("questestinterop");
00764 $attrs = array(
00765 "ident" => "qpl_" . $this->getId(),
00766 "title" => $this->getTitle()
00767 );
00768 $a_xml_writer->xmlStartTag("section", $attrs);
00769
00770 $a_xml_writer->xmlStartTag("qtimetadata");
00771 $a_xml_writer->xmlStartTag("qtimetadatafield");
00772 $a_xml_writer->xmlElement("fieldlabel", NULL, "SCORM");
00773
00774 include_once "./Services/MetaData/classes/class.ilMD.php";
00775 $md = new ilMD($this->getId(),0, $this->getType());
00776 $writer = new ilXmlWriter();
00777 $md->toXml($writer);
00778 $metadata = $writer->xmlDumpMem();
00779
00780 $a_xml_writer->xmlElement("fieldentry", NULL, $metadata);
00781 $a_xml_writer->xmlEndTag("qtimetadatafield");
00782 $a_xml_writer->xmlEndTag("qtimetadata");
00783 $a_xml_writer->xmlEndTag("section");
00784 $a_xml_writer->xmlEndTag("questestinterop");
00785
00786 $qtixml = $a_xml_writer->xmlDumpMem(FALSE);
00787 $qtixml = str_replace("</section>", $xml . "\n</section>", $qtixml);
00788 return $qtixml;
00789 }
00790
00791 function &getQuestions()
00792 {
00793 $questions = array();
00794 $query = sprintf("SELECT question_id FROM survey_question WHERE obj_fi = %s AND ISNULL(original_id)",
00795 $this->ilias->db->quote($this->getId() . "")
00796 );
00797 $result = $this->ilias->db->query($query);
00798 if ($result->numRows())
00799 {
00800 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00801 {
00802 array_push($questions, $row["question_id"]);
00803 }
00804 }
00805 return $questions;
00806 }
00807
00808 function importObject($source)
00809 {
00810 $metadata = "";
00811 if (is_file($source))
00812 {
00813 $fh = fopen($source, "r") or die("");
00814 $xml = fread($fh, filesize($source));
00815 fclose($fh) or die("");
00816
00817
00818 $xml = preg_replace("/>\s*?</", "><", $xml);
00819 $domxml = domxml_open_mem($xml);
00820 if (!empty($domxml))
00821 {
00822 $nodeList = $domxml->get_elements_by_tagname("fieldlabel");
00823 foreach ($nodeList as $node)
00824 {
00825 switch ($node->get_content())
00826 {
00827 case "SCORM":
00828 $metanode = $node->next_sibling();
00829 if (strcmp($metanode->node_name(), "fieldentry") == 0)
00830 {
00831 $metadata = $metanode->get_content();
00832 }
00833 }
00834 }
00835 $domxml->free();
00836 }
00837
00838
00839 if (preg_match_all("/(<item[^>]*>.*?<\/item>)/si", $xml, $matches))
00840 {
00841 foreach ($matches[1] as $index => $item)
00842 {
00843
00844 if (preg_match("/(<item[^>]*>)/is", $item, $start_tag))
00845 {
00846 if (preg_match("/(ident=\"([^\"]*)\")/is", $start_tag[1], $ident))
00847 {
00848 $ident = $ident[2];
00849 }
00850 }
00851 $question = "";
00852 if (preg_match("/<qticomment>Questiontype\=(.*?)<\/qticomment>/is", $item, $questiontype))
00853 {
00854 include_once "./survey/classes/class.SurveyNominalQuestion.php";
00855 include_once "./survey/classes/class.SurveyOrdinalQuestion.php";
00856 include_once "./survey/classes/class.SurveyMetricQuestion.php";
00857 include_once "./survey/classes/class.SurveyTextQuestion.php";
00858 switch ($questiontype[1])
00859 {
00860 case NOMINAL_QUESTION_IDENTIFIER:
00861 $question = new SurveyNominalQuestion();
00862 break;
00863 case ORDINAL_QUESTION_IDENTIFIER:
00864 $question = new SurveyOrdinalQuestion();
00865 break;
00866 case METRIC_QUESTION_IDENTIFIER:
00867 $question = new SurveyMetricQuestion();
00868 break;
00869 case TEXT_QUESTION_IDENTIFIER:
00870 $question = new SurveyTextQuestion();
00871 break;
00872 }
00873 if ($question)
00874 {
00875 $question->setObjId($this->getId());
00876 if ($question->from_xml("<questestinterop>$item</questestinterop>"))
00877 {
00878 $question->saveToDb();
00879 }
00880 else
00881 {
00882 $this->ilias->raiseError($this->lng->txt("error_importing_question"), $this->ilias->error_obj->MESSAGE);
00883 }
00884 }
00885 }
00886 }
00887 }
00888
00889 if ($metadata)
00890 {
00891 include_once "./Services/MetaData/classes/class.ilMDSaxParser.php";
00892 include_once "./Services/MetaData/classes/class.ilMD.php";
00893 $md_sax_parser = new ilMDSaxParser();
00894 $md_sax_parser->setXMLContent($metadata);
00895 $md_sax_parser->setMDObject($tmp = new ilMD($this->getId(),0,'spl'));
00896 $md_sax_parser->enableMDParsing(true);
00897 $md_sax_parser->startParsing();
00898
00899
00900
00901 $this->MDUpdateListener('General');
00902 }
00903
00904 }
00905 }
00906
00916 function setOnline($a_online_status)
00917 {
00918 switch ($a_online_status)
00919 {
00920 case 0:
00921 case 1:
00922 $this->online = $a_online_status;
00923 break;
00924 default:
00925 $this->online = 0;
00926 break;
00927 }
00928 }
00929
00930 function getOnline()
00931 {
00932 if (strcmp($this->online, "") == 0) $this->online = "0";
00933 return $this->online;
00934 }
00935
00936 function _lookupOnline($a_obj_id)
00937 {
00938 global $ilDB;
00939
00940 $query = sprintf("SELECT online FROM survey_questionpool WHERE obj_fi = %s",
00941 $ilDB->quote($a_obj_id . "")
00942 );
00943 $result = $ilDB->query($query);
00944 if ($result->numRows() == 1)
00945 {
00946 $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
00947 return $row["online"];
00948 }
00949 return 0;
00950 }
00951
00961 function _isWriteable($object_id, $user_id)
00962 {
00963 global $rbacsystem;
00964 global $ilDB;
00965
00966 $result_array = array();
00967 $query = sprintf("SELECT object_data.*, object_data.obj_id, object_reference.ref_id FROM object_data, object_reference WHERE object_data.obj_id = object_reference.obj_id AND object_data.obj_id = %s",
00968 $ilDB->quote($object_id . "")
00969 );
00970 $result = $ilDB->query($query);
00971 while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC))
00972 {
00973 include_once "./classes/class.ilObject.php";
00974 if ($rbacsystem->checkAccess("write", $row["ref_id"]) && (ilObject::_hasUntrashedReference($row["obj_id"])))
00975 {
00976 return true;
00977 }
00978 }
00979 return false;
00980 }
00981 }
00982 ?>