本文整理汇总了PHP中ilObjMediaObject::_removeUsage方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjMediaObject::_removeUsage方法的具体用法?PHP ilObjMediaObject::_removeUsage怎么用?PHP ilObjMediaObject::_removeUsage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ilObjMediaObject
的用法示例。
在下文中一共展示了ilObjMediaObject::_removeUsage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateAssignmentTextObject
function updateAssignmentTextObject($a_return = false)
{
global $ilCtrl, $ilUser;
$times_up = $this->ass->getDeadline() && $this->ass->getDeadline() - time() < 0;
if (!$this->ass || $this->ass->getType() != ilExAssignment::TYPE_TEXT || $times_up) {
if ($times_up) {
ilUtil::sendFailure($this->lng->txt("exercise_time_over"), true);
}
$ilCtrl->redirect($this, "showOverview");
}
$this->checkPermission("read");
$form = $this->initAssignmentTextForm($this->ass);
// we are not using a purifier, so we have to set the valid RTE tags
// :TODO:
include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
$rte = $form->getItemByPostVar("atxt");
$rte->setRteTags(ilObjAdvancedEditing::_getUsedHTMLTags("exc_ass"));
if ($form->checkInput()) {
$text = trim($form->getInput("atxt"));
$existing = (bool) ilExAssignment::getDeliveredFiles($this->ass->getExerciseId(), $this->ass->getId(), $ilUser->getId());
$returned_id = $this->object->updateTextSubmission($this->ass->getExerciseId(), $this->ass->getId(), $ilUser->getId(), ilRTE::_replaceMediaObjectImageSrc($text, 0));
// no empty text
if ($returned_id) {
if (!$existing) {
// #14332 - new text
$this->sendNotifications($this->ass->getId());
$this->object->handleSubmission($this->ass->getId());
}
// mob usage
include_once "Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mobs = ilRTE::_getMediaObjects($text, 0);
foreach ($mobs as $mob) {
if (ilObjMediaObject::_exists($mob)) {
ilObjMediaObject::_removeUsage($mob, 'exca~:html', $ilUser->getId());
ilObjMediaObject::_saveUsage($mob, 'exca:html', $returned_id);
}
}
}
ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
if ($a_return) {
$ilCtrl->redirect($this, "showOverview");
} else {
$ilCtrl->redirect($this, "editAssignmentText");
}
}
$form->setValuesByPost();
$this->editAssignmentTextObject($form);
}
示例2: deleteTest
/**
* Deletes the test and all related objects, files and database entries
*
* @access public
*/
function deleteTest()
{
global $tree, $ilDB, $ilPluginAdmin;
// first of all remove all test editings, because the delete statements used for this
// contain a subquery for active ids, that are deleted in the next steps
$this->removeAllTestEditings();
$result = $ilDB->queryF("SELECT active_id FROM tst_active WHERE test_fi = %s", array('integer'), array($this->getTestId()));
$active_array = array();
while ($row = $ilDB->fetchAssoc($result)) {
array_push($active_array, $row["active_id"]);
}
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_active WHERE test_fi = %s", array('integer'), array($this->getTestId()));
if (count($active_array)) {
foreach ($active_array as $active_id) {
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_times WHERE active_fi = %s", array('integer'), array($active_id));
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_sequence WHERE active_fi = %s", array('integer'), array($active_id));
}
}
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_mark WHERE test_fi = %s", array('integer'), array($this->getTestId()));
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_tests WHERE test_id = %s", array('integer'), array($this->getTestId()));
require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
$testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this);
$testQuestionSetConfigFactory->getQuestionSetConfig()->removeQuestionSetRelatedData();
// delete export files
include_once "./Services/Utilities/classes/class.ilUtil.php";
$tst_data_dir = ilUtil::getDataDir() . "/tst_data";
$directory = $tst_data_dir . "/tst_" . $this->getId();
if (is_dir($directory)) {
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::delDir($directory);
}
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mobs = ilObjMediaObject::_getMobsOfObject("tst:html", $this->getId());
// remaining usages are not in text anymore -> delete them
// and media objects (note: delete method of ilObjMediaObject
// checks whether object is used in another context; if yes,
// the object is not deleted!)
foreach ($mobs as $mob) {
ilObjMediaObject::_removeUsage($mob, "tst:html", $this->getId());
if (ilObjMediaObject::_exists($mob)) {
$mob_obj =& new ilObjMediaObject($mob);
$mob_obj->delete();
}
}
}
示例3: saveStatutoryRegulationsObject
public function saveStatutoryRegulationsObject()
{
require_once 'Services/RTE/classes/class.ilRTE.php';
if (isset($_POST['statutory_regulations']) && $_POST['statutory_regulations'] != NULL) {
$this->genSetData->set('statutory_regulations', ilRTE::_replaceMediaObjectImageSrc($_POST['statutory_regulations'], 0), 'regulations');
// copy temporary media objects (frm~)
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
$mediaObjects = ilRTE::_getMediaObjects($_POST['statutory_regulations'], 0);
$myMediaObjects = ilObjMediaObject::_getMobsOfObject('pays~:html', ilObject::_lookupObjId($this->ref_id));
foreach ($mediaObjects as $mob) {
foreach ($myMediaObjects as $myMob) {
if ($mob == $myMob) {
// change usage
ilObjMediaObject::_removeUsage($mob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
break;
}
}
ilObjMediaObject::_saveUsage($mob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
}
} else {
$this->genSetData->set('statutory_regulations', NULL, 'regulations');
}
// remove usage of deleted media objects
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
$oldMediaObjects = ilObjMediaObject::_getMobsOfObject('pays~:html', ilObject::_lookupObjId($this->ref_id));
$curMediaObjects = ilRTE::_getMediaObjects($_POST['statutory_regulations'], 0);
foreach ($oldMediaObjects as $oldMob) {
$found = false;
foreach ($curMediaObjects as $curMob) {
if ($oldMob == $curMob) {
$found = true;
break;
}
}
if (!$found) {
if (ilObjMediaObject::_exists($oldMob)) {
ilObjMediaObject::_removeUsage($oldMob, 'pays~:html', ilObject::_lookupObjId($this->ref_id));
$mob_obj = new ilObjMediaObject($oldMob);
$mob_obj->delete();
}
}
}
$this->genSetData->set('show_sr_shoppingcart', isset($_POST['show_sr_shoppingcart']) ? 1 : 0, 'regulations');
$this->genSetData->set('attach_sr_invoice', isset($_POST['attach_sr_invoice']) ? 1 : 0, 'regulations');
$this->StatutoryRegulationsObject();
ilUtil::sendSuccess($this->lng->txt('pays_updated_general_settings'));
return true;
}
示例4: _cleanupMediaObjectUsage
/**
* synchronises appearances of media objects in $a_text with media
* object usage table
*
* @param string $a_text text, including media object tags
* @param string $a_usage_type type of context of usage, e.g. cat:html
* @param int $a_usage_id if of context of usage, e.g. category id
*/
function _cleanupMediaObjectUsage($a_text, $a_usage_type, $a_usage_id)
{
// get current stored mobs
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mobs = ilObjMediaObject::_getMobsOfObject($a_usage_type, $a_usage_id);
while (eregi("data\\/" . CLIENT_ID . "\\/mobs\\/mm_([0-9]+)", $a_text, $found)) {
$a_text = str_replace($found[0], "", $a_text);
if (!in_array($found[1], $mobs)) {
// save usage if missing
ilObjMediaObject::_saveUsage($found[1], $a_usage_type, $a_usage_id);
} else {
// if already saved everything ok -> take mob out of mobs array
unset($mobs[$found[1]]);
}
}
// remaining usages are not in text anymore -> delete them
// and media objects (note: delete method of ilObjMediaObject
// checks whether object is used in another context; if yes,
// the object is not deleted!)
foreach ($mobs as $mob) {
ilObjMediaObject::_removeUsage($mob, $a_usage_type, $a_usage_id);
$mob_obj =& new ilObjMediaObject($mob);
$mob_obj->delete();
}
}
示例5: deleteSurveyRecord
/**
* Deletes the survey from the database
*
* @access public
*/
function deleteSurveyRecord()
{
global $ilDB;
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_svy WHERE survey_id = %s", array('integer'), array($this->getSurveyId()));
$result = $ilDB->queryF("SELECT questionblock_fi FROM svy_qblk_qst WHERE survey_fi = %s", array('integer'), array($this->getSurveyId()));
$questionblocks = array();
while ($row = $ilDB->fetchAssoc($result)) {
array_push($questionblocks, $row["questionblock_fi"]);
}
if (count($questionblocks)) {
$affectedRows = $ilDB->manipulate("DELETE FROM svy_qblk WHERE " . $ilDB->in('questionblock_id', $questionblocks, false, 'integer'));
}
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qblk_qst WHERE survey_fi = %s", array('integer'), array($this->getSurveyId()));
$this->deleteAllUserData();
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_anonymous WHERE survey_fi = %s", array('integer'), array($this->getSurveyId()));
// delete export files
include_once "./Services/Utilities/classes/class.ilUtil.php";
$svy_data_dir = ilUtil::getDataDir() . "/svy_data";
$directory = $svy_data_dir . "/svy_" . $this->getId();
if (is_dir($directory)) {
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::delDir($directory);
}
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mobs = ilObjMediaObject::_getMobsOfObject("svy:html", $this->getId());
// remaining usages are not in text anymore -> delete them
// and media objects (note: delete method of ilObjMediaObject
// checks whether object is used in another context; if yes,
// the object is not deleted!)
foreach ($mobs as $mob) {
ilObjMediaObject::_removeUsage($mob, "svy:html", $this->getId());
$mob_obj =& new ilObjMediaObject($mob);
$mob_obj->delete();
}
}
示例6: delete
/**
* Deletes a question and all materials from the database
*
* @param integer $question_id The database id of the question
* @access private
*/
function delete($question_id)
{
global $ilDB;
if ($question_id < 1) {
return;
}
$result = $ilDB->queryF("SELECT obj_fi FROM svy_question WHERE question_id = %s", array('integer'), array($question_id));
if ($result->numRows() == 1) {
$row = $ilDB->fetchAssoc($result);
$obj_id = $row["obj_fi"];
} else {
return;
}
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_answer WHERE question_fi = %s", array('integer'), array($question_id));
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_constraint WHERE question_fi = %s", array('integer'), array($question_id));
$result = $ilDB->queryF("SELECT constraint_fi FROM svy_qst_constraint WHERE question_fi = %s", array('integer'), array($question_id));
while ($row = $ilDB->fetchObject($result)) {
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_constraint WHERE constraint_id = %s", array('integer'), array($row->constraint_fi));
}
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_constraint WHERE question_fi = %s", array('integer'), array($question_id));
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qblk_qst WHERE question_fi = %s", array('integer'), array($question_id));
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_qst_oblig WHERE question_fi = %s", array('integer'), array($question_id));
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_svy_qst WHERE question_fi = %s", array('integer'), array($question_id));
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_variable WHERE question_fi = %s", array('integer'), array($question_id));
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_question WHERE question_id = %s", array('integer'), array($question_id));
$this->deleteAdditionalTableData($question_id);
$affectedRows = $ilDB->manipulateF("DELETE FROM svy_material WHERE question_fi = %s", array('integer'), array($question_id));
include_once "./Services/Link/classes/class.ilInternalLink.php";
ilInternalLink::_deleteAllLinksOfSource("sqst", $question_id);
$directory = CLIENT_WEB_DIR . "/survey/" . $obj_id . "/{$question_id}";
if (preg_match("/\\d+/", $obj_id) and preg_match("/\\d+/", $question_id) and is_dir($directory)) {
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::delDir($directory);
}
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mobs = ilObjMediaObject::_getMobsOfObject("spl:html", $question_id);
// remaining usages are not in text anymore -> delete them
// and media objects (note: delete method of ilObjMediaObject
// checks whether object is used in another context; if yes,
// the object is not deleted!)
foreach ($mobs as $mob) {
ilObjMediaObject::_removeUsage($mob, "spl:html", $question_id);
$mob_obj =& new ilObjMediaObject($mob);
$mob_obj->delete();
}
include_once "./Modules/Survey/classes/class.ilSurveySkill.php";
ilSurveySkill::handleQuestionDeletion($question_id, $obj_id);
// #12772 - untie question copies from pool question
$ilDB->manipulate("UPDATE svy_question" . " SET original_id = NULL" . " WHERE original_id = " . $ilDB->quote($question_id, "integer"));
}
示例7: addThreadObject
public function addThreadObject($a_prevent_redirect = false)
{
/**
* @var $ilUser ilObjUser
* @var $ilAccess ilAccessHandler
* @var $lng ilLanguage
*/
global $ilUser, $ilAccess, $lng;
$frm = $this->object->Forum;
$frm->setForumId($this->object->getId());
$frm->setForumRefId($this->object->getRefId());
if (!$ilAccess->checkAccess('add_thread', '', $this->object->getRefId())) {
$this->ilias->raiseError($lng->txt('permission_denied'), $this->ilias->error_obj->MESSAGE);
}
$frm->setMDB2WhereCondition('top_frm_fk = %s ', array('integer'), array($frm->getForumId()));
$topicData = $frm->getOneTopic();
$this->initTopicCreateForm();
if ($this->create_topic_form_gui->checkInput()) {
require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
if ($ilUser->isAnonymous() && !$ilUser->isCaptchaVerified() && ilCaptchaUtil::isActiveForForum()) {
$ilUser->setCaptchaVerified(true);
}
if ($this->objProperties->isAnonymized()) {
if (!strlen($this->create_topic_form_gui->getInput('alias'))) {
$user_alias = $this->lng->txt('forums_anonymous');
} else {
$user_alias = $this->create_topic_form_gui->getInput('alias');
}
} else {
$user_alias = $ilUser->getLogin();
}
$status = 1;
if ($this->objProperties->isPostActivationEnabled() && !$this->is_moderator || $this->objCurrentPost->isAnyParentDeactivated()) {
$status = 0;
}
// build new thread
$newPost = $frm->generateThread($topicData['top_pk'], $ilUser->getId(), $this->objProperties->isAnonymized() ? 0 : $ilUser->getId(), $this->handleFormInput($this->create_topic_form_gui->getInput('subject'), false), ilRTE::_replaceMediaObjectImageSrc($this->create_topic_form_gui->getInput('message'), 0), $this->create_topic_form_gui->getItemByPostVar('notify') ? (int) $this->create_topic_form_gui->getInput('notify') : 0, $this->create_topic_form_gui->getItemByPostVar('notify_posts') ? (int) $this->create_topic_form_gui->getInput('notify_posts') : 0, $user_alias, '', $status);
$file = $_FILES['userfile'];
// file upload
if (is_array($file) && !empty($file)) {
$tmp_file_obj = new ilFileDataForum($this->object->getId(), $newPost);
$tmp_file_obj->storeUploadedFile($file);
}
// Visit-Counter
$frm->setDbTable('frm_data');
$frm->setMDB2WhereCondition('top_pk = %s ', array('integer'), array($topicData['top_pk']));
$frm->updateVisits($topicData['top_pk']);
$frm->setMDB2WhereCondition('thr_top_fk = %s AND thr_subject = %s AND thr_num_posts = 1 ', array('integer', 'text'), array($topicData['top_pk'], $this->create_topic_form_gui->getInput('subject')));
// copy temporary media objects (frm~)
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
$mediaObjects = ilRTE::_getMediaObjects($this->create_topic_form_gui->getInput('message'), 0);
foreach ($mediaObjects as $mob) {
if (ilObjMediaObject::_exists($mob)) {
ilObjMediaObject::_removeUsage($mob, 'frm~:html', $ilUser->getId());
ilObjMediaObject::_saveUsage($mob, 'frm:html', $newPost);
}
}
if ($this->ilias->getSetting('forum_notification') == 1) {
// send notification about new topic
$objPost = new ilForumPost((int) $newPost, $this->is_moderator);
$post_data = array();
$post_data = $objPost->getDataAsArray();
$titles = $this->getTitlesByRefId(array($this->object->getRefId()));
$post_data["top_name"] = $titles[0];
$post_data["ref_id"] = $this->object->getRefId();
$frm->sendForumNotifications($post_data);
}
if (!$a_prevent_redirect) {
ilUtil::sendSuccess($this->lng->txt('forums_thread_new_entry'), true);
$this->ctrl->redirect($this);
} else {
return $newPost;
}
} else {
$this->create_topic_form_gui->setValuesByPost();
if (!$this->objProperties->isAnonymized()) {
$this->create_topic_form_gui->getItemByPostVar('alias')->setValue($ilUser->getLogin());
}
return $this->tpl->setContent($this->create_topic_form_gui->getHTML());
}
}
示例8: deleteTest
/**
* Deletes the test and all related objects, files and database entries
*
* @access public
*/
function deleteTest()
{
global $ilDB;
// first of all remove all test editings, because the delete statements used for this
// contain a subquery for active ids, that are deleted in the next steps
$this->removeAllTestEditings();
$result = $ilDB->queryF("SELECT active_id FROM tst_active WHERE test_fi = %s", array('integer'), array($this->getTestId()));
$active_array = array();
while ($row = $ilDB->fetchAssoc($result)) {
array_push($active_array, $row["active_id"]);
}
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_active WHERE test_fi = %s", array('integer'), array($this->getTestId()));
if (count($active_array)) {
foreach ($active_array as $active_id) {
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_times WHERE active_fi = %s", array('integer'), array($active_id));
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_sequence WHERE active_fi = %s", array('integer'), array($active_id));
}
}
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_mark WHERE test_fi = %s", array('integer'), array($this->getTestId()));
$result = $ilDB->queryF("SELECT question_fi FROM tst_test_question WHERE test_fi = %s", array('integer'), array($this->getTestId()));
while ($row = $ilDB->fetchAssoc($result)) {
$this->removeQuestion($row["question_fi"]);
}
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_tests WHERE test_id = %s", array('integer'), array($this->getTestId()));
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_test_random WHERE test_fi = %s", array('integer'), array($this->getTestId()));
// this delete is allready done by call to removeAllTestEditings some lines above
/*$affectedRows = $ilDB->manipulateF("DELETE FROM tst_test_rnd_qst WHERE tst_test_rnd_qst.active_fi IN (SELECT active_id FROM tst_active WHERE test_fi = %s)",
array('integer'),
array($this->getTestId())
);*/
// moved to top of this method because this method performs delete statements,
// that use a subquery for active ids, that are allready deleted some lines above
//$this->removeAllTestEditings();
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_test_question WHERE test_fi = %s", array('integer'), array($this->getTestId()));
if ($this->isRandomTest()) {
$this->removeDuplicatedQuestionpools();
}
// delete export files
include_once "./Services/Utilities/classes/class.ilUtil.php";
$tst_data_dir = ilUtil::getDataDir() . "/tst_data";
$directory = $tst_data_dir . "/tst_" . $this->getId();
if (is_dir($directory)) {
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::delDir($directory);
}
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mobs = ilObjMediaObject::_getMobsOfObject("tst:html", $this->getId());
// remaining usages are not in text anymore -> delete them
// and media objects (note: delete method of ilObjMediaObject
// checks whether object is used in another context; if yes,
// the object is not deleted!)
foreach ($mobs as $mob) {
ilObjMediaObject::_removeUsage($mob, "tst:html", $this->getId());
if (ilObjMediaObject::_exists($mob)) {
$mob_obj =& new ilObjMediaObject($mob);
$mob_obj->delete();
}
}
}
示例9: delete
/**
* Deletes a question and all materials from the database
*
* @param integer $question_id The database id of the question
* @access private
*/
public function delete($question_id)
{
global $ilDB, $ilLog;
if ($question_id < 1) {
return true;
}
// nothing to do
$result = $ilDB->queryF("SELECT obj_fi FROM qpl_questions WHERE question_id = %s", array('integer'), array($question_id));
if ($result->numRows() == 1) {
$row = $ilDB->fetchAssoc($result);
$obj_id = $row["obj_fi"];
} else {
return true;
// nothing to do
}
try {
$this->deletePageOfQuestion($question_id);
} catch (Exception $e) {
$ilLog->write("EXCEPTION: Could not delete page of question {$question_id}: {$e}");
return false;
}
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_questions WHERE question_id = %s", array('integer'), array($question_id));
if ($affectedRows == 0) {
return false;
}
try {
$this->deleteAdditionalTableData($question_id);
$this->deleteAnswers($question_id);
$this->feedbackOBJ->deleteGenericFeedbacks($question_id, $this->isAdditionalContentEditingModePageObject());
$this->feedbackOBJ->deleteSpecificAnswerFeedbacks($question_id, $this->isAdditionalContentEditingModePageObject());
} catch (Exception $e) {
$ilLog->write("EXCEPTION: Could not delete additional table data of question {$question_id}: {$e}");
return false;
}
try {
// delete the question in the tst_test_question table (list of test questions)
$affectedRows = $ilDB->manipulateF("DELETE FROM tst_test_question WHERE question_fi = %s", array('integer'), array($question_id));
} catch (Exception $e) {
$ilLog->write("EXCEPTION: Could not delete delete question {$question_id} from a test: {$e}");
return false;
}
try {
// delete suggested solutions contained in the question
$affectedRows = $ilDB->manipulateF("DELETE FROM qpl_sol_sug WHERE question_fi = %s", array('integer'), array($question_id));
} catch (Exception $e) {
$ilLog->write("EXCEPTION: Could not delete suggested solutions of question {$question_id}: {$e}");
return false;
}
try {
$directory = CLIENT_WEB_DIR . "/assessment/" . $obj_id . "/{$question_id}";
if (preg_match("/\\d+/", $obj_id) and preg_match("/\\d+/", $question_id) and is_dir($directory)) {
include_once "./Services/Utilities/classes/class.ilUtil.php";
ilUtil::delDir($directory);
}
} catch (Exception $e) {
$ilLog->write("EXCEPTION: Could not delete question file directory {$directory} of question {$question_id}: {$e}");
return false;
}
try {
include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
$mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
// remaining usages are not in text anymore -> delete them
// and media objects (note: delete method of ilObjMediaObject
// checks whether object is used in another context; if yes,
// the object is not deleted!)
foreach ($mobs as $mob) {
ilObjMediaObject::_removeUsage($mob, "qpl:html", $question_id);
if (ilObjMediaObject::_exists($mob)) {
$mob_obj =& new ilObjMediaObject($mob);
$mob_obj->delete();
}
}
} catch (Exception $e) {
$ilLog->write("EXCEPTION: Error deleting the media objects of question {$question_id}: {$e}");
return false;
}
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintTracking.php';
ilAssQuestionHintTracking::deleteRequestsByQuestionIds(array($question_id));
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintList.php';
ilAssQuestionHintList::deleteHintsByQuestionIds(array($question_id));
require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentList.php';
$assignmentList = new ilAssQuestionSkillAssignmentList($ilDB);
$assignmentList->setParentObjId($obj_id);
$assignmentList->setQuestionIdFilter($question_id);
$assignmentList->loadFromDb();
foreach ($assignmentList->getAssignmentsByQuestionId($question_id) as $assignment) {
/* @var ilAssQuestionSkillAssignment $assignment */
$assignment->deleteFromDb();
}
try {
// update question count of question pool
include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
ilObjQuestionPool::_updateQuestionCount($this->getObjId());
} catch (Exception $e) {
//.........这里部分代码省略.........
示例10: deletePost
/**
* delete post and sub-posts
* @param integer $post: ID
* @access public
* @return integer 0 or thread-ID
*/
public function deletePost($post)
{
global $ilDB;
include_once "./Modules/Forum/classes/class.ilObjForum.php";
// delete tree and get id's of all posts to delete
$p_node = $this->getPostNode($post);
$del_id = $this->deletePostTree($p_node);
// Delete User read entries
foreach ($del_id as $post_id) {
ilObjForum::_deleteReadEntries($post_id);
}
// DELETE ATTACHMENTS ASSIGNED TO POST
$this->__deletePostFiles($del_id);
$dead_pos = count($del_id);
$dead_thr = 0;
// if deletePost is thread opener ...
if ($p_node["parent"] == 0) {
// delete thread access data
include_once './Modules/Forum/classes/class.ilObjForum.php';
ilObjForum::_deleteAccessEntries($p_node['tree']);
// delete thread
$dead_thr = $p_node["tree"];
$statement = $ilDB->manipulateF('
DELETE FROM frm_threads
WHERE thr_pk = %s', array('integer'), array($p_node['tree']));
// update num_threads
$statement = $ilDB->manipulateF('
UPDATE frm_data
SET top_num_threads = top_num_threads - 1
WHERE top_frm_fk = %s', array('integer'), array($this->id));
// delete all related news
$posset = $ilDB->queryf('
SELECT * FROM frm_posts
WHERE pos_thr_fk = %s', array('integer'), array($p_node['tree']));
while ($posrec = $ilDB->fetchAssoc($posset)) {
include_once "./Services/News/classes/class.ilNewsItem.php";
$news_id = ilNewsItem::getFirstNewsIdForContext($this->id, "frm", $posrec["pos_pk"], "pos");
if ($news_id > 0) {
$news_item = new ilNewsItem($news_id);
$news_item->delete();
}
try {
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
$mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $posrec['pos_pk']);
foreach ($mobs as $mob) {
if (ilObjMediaObject::_exists($mob)) {
ilObjMediaObject::_removeUsage($mob, 'frm:html', $posrec['pos_pk']);
$mob_obj = new ilObjMediaObject($mob);
$mob_obj->delete();
}
}
} catch (Exception $e) {
}
}
// delete all posts of this thread
$statement = $ilDB->manipulateF('
DELETE FROM frm_posts
WHERE pos_thr_fk = %s', array('integer'), array($p_node['tree']));
} else {
// delete this post and its sub-posts
for ($i = 0; $i < $dead_pos; $i++) {
$statement = $ilDB->manipulateF('
DELETE FROM frm_posts
WHERE pos_pk = %s', array('integer'), array($del_id[$i]));
// delete related news item
include_once "./Services/News/classes/class.ilNewsItem.php";
$news_id = ilNewsItem::getFirstNewsIdForContext($this->id, "frm", $del_id[$i], "pos");
if ($news_id > 0) {
$news_item = new ilNewsItem($news_id);
$news_item->delete();
}
try {
include_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
$mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $del_id[$i]);
foreach ($mobs as $mob) {
if (ilObjMediaObject::_exists($mob)) {
ilObjMediaObject::_removeUsage($mob, 'frm:html', $del_id[$i]);
$mob_obj = new ilObjMediaObject($mob);
$mob_obj->delete();
}
}
} catch (Exception $e) {
}
}
// update num_posts in frm_threads
$statement = $ilDB->manipulateF('
UPDATE frm_threads
SET thr_num_posts = thr_num_posts - %s
WHERE thr_pk = %s', array('integer', 'integer'), array($dead_pos, $p_node['tree']));
// get latest post of thread and update last_post
$res1 = $ilDB->queryf('
SELECT * FROM frm_posts
WHERE pos_thr_fk = %s
ORDER BY pos_date DESC', array('integer'), array($p_node['tree']));
//.........这里部分代码省略.........