当前位置: 首页>>代码示例>>PHP>>正文


PHP ilObjMediaObject::_exists方法代码示例

本文整理汇总了PHP中ilObjMediaObject::_exists方法的典型用法代码示例。如果您正苦于以下问题:PHP ilObjMediaObject::_exists方法的具体用法?PHP ilObjMediaObject::_exists怎么用?PHP ilObjMediaObject::_exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ilObjMediaObject的用法示例。


在下文中一共展示了ilObjMediaObject::_exists方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: exportXHTMLMediaObjects

 function exportXHTMLMediaObjects($a_export_dir)
 {
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $mobs = ilObjMediaObject::_getMobsOfObject("tst:html", $this->test_obj->getId());
     foreach ($mobs as $mob) {
         if (ilObjMediaObject::_exists($mob)) {
             $mob_obj =& new ilObjMediaObject($mob);
             $mob_obj->exportFiles($a_export_dir);
             unset($mob_obj);
         }
     }
     foreach ($this->test_obj->questions as $question_id) {
         $mobs = ilObjMediaObject::_getMobsOfObject("qpl:html", $question_id);
         foreach ($mobs as $mob) {
             if (ilObjMediaObject::_exists($mob)) {
                 $mob_obj =& new ilObjMediaObject($mob);
                 $mob_obj->exportFiles($a_export_dir);
                 unset($mob_obj);
             }
         }
     }
 }
开发者ID:bheyser,项目名称:qplskl,代码行数:22,代码来源:class.ilTestExport.php

示例2: 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);
 }
开发者ID:bheyser,项目名称:qplskl,代码行数:48,代码来源:class.ilObjExerciseGUI.php

示例3: exportXMLMediaObjects

 /**
  * export media objects to xml (see ilias_co.dtd)
  *
  * @param	object		$a_xml_writer	ilXmlWriter object that receives the
  *										xml data
  */
 function exportXMLMediaObjects(&$a_xml_writer, $a_inst, $a_target_dir, &$expLog)
 {
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     foreach ($this->mob_ids as $mob_id) {
         $expLog->write(date("[y-m-d H:i:s] ") . "Media Object " . $mob_id);
         if (ilObjMediaObject::_exists($mob_id)) {
             $media_obj = new ilObjMediaObject($mob_id);
             $media_obj->exportXML($a_xml_writer, $a_inst);
             $media_obj->exportFiles($a_target_dir);
             unset($media_obj);
         }
     }
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:19,代码来源:class.ilObjQuestionPool.php

示例4: 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;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:48,代码来源:class.ilObjPaymentSettingsGUI.php

示例5: _exists

 /**
  * Check if internal link refers to a valid target
  *
  * @param	string		$a_type			target type ("PageObject" | "StructureObject" |
  *										"GlossaryItem" | "MediaObject")
  * @param	string		$a_target		target id, e.g. "il__pg_244")
  *
  * @return	boolean		true/false
  */
 function _exists($a_type, $a_target)
 {
     global $tree;
     switch ($a_type) {
         case "PageObject":
         case "StructureObject":
             return ilLMObject::_exists($a_target);
             break;
         case "GlossaryItem":
             return ilGlossaryTerm::_exists($a_target);
             break;
         case "MediaObject":
             return ilObjMediaObject::_exists($a_target);
             break;
         case "WikiPage":
             include_once "./Modules/Wiki/classes/class.ilWikiPage.php";
             return ilWikiPage::_exists("wiki", (int) $a_target);
             break;
         case "RepositoryItem":
             if (is_int(strpos($a_target, "_"))) {
                 $ref_id = ilInternalLink::_extractObjIdOfTarget($a_target);
                 return $tree->isInTree($ref_id);
             }
             break;
     }
     return false;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:36,代码来源:class.ilInternalLink.php

示例6: addQTIMaterial

 /**
  * Creates a QTI material tag from a plain text or xhtml text
  *
  * @param object $a_xml_writer Reference to the ILIAS XML writer
  * @param string $a_material plain text or html text containing the material
  * @return string QTI material tag
  * @access public
  */
 function addQTIMaterial(&$a_xml_writer, $a_material)
 {
     include_once "./Services/RTE/classes/class.ilRTE.php";
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $a_xml_writer->xmlStartTag("material");
     $attrs = array("texttype" => "text/plain");
     if ($this->isHTML($a_material)) {
         $attrs["texttype"] = "text/xhtml";
     }
     $a_xml_writer->xmlElement("mattext", $attrs, ilRTE::_replaceMediaObjectImageSrc($a_material, 0));
     $mobs = ilObjMediaObject::_getMobsOfObject("tst:html", $this->getId());
     foreach ($mobs as $mob) {
         $moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
         if (strpos($a_material, "mm_{$mob}") !== FALSE) {
             if (ilObjMediaObject::_exists($mob)) {
                 $mob_obj =& new ilObjMediaObject($mob);
                 $imgattrs = array("label" => $moblabel, "uri" => "objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle());
             }
             $a_xml_writer->xmlElement("matimage", $imgattrs, NULL);
         }
     }
     $a_xml_writer->xmlEndTag("material");
 }
开发者ID:bheyser,项目名称:qplskl,代码行数:31,代码来源:class.ilObjTest.php

示例7: _getMediaObjects

 /**
  * Returns all media objects found in the passed string
  * @static
  * @param	string	$a_text			text, including media object tags
  * @param  integer $a_direction 0 to find image src, 1 to find mob id
  * @return array array of media objects
  */
 public static function _getMediaObjects($a_text, $a_direction = 0)
 {
     if (!strlen($a_text)) {
         return array();
     }
     include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php";
     $mediaObjects = array();
     switch ($a_direction) {
         case 0:
             if (preg_match_all("/src\\=\"(.*?\\/mobs\\/mm_([0-9]+)\\/.*?)\"/", $a_text, $matches)) {
                 foreach ($matches[2] as $idx => $mob) {
                     if (ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects)) {
                         $mediaObjects[] = $mob;
                     }
                 }
             }
             break;
         default:
             if (preg_match_all("/src\\=\"il_([0-9]+)_mob_([0-9]+)\"/", $a_text, $matches)) {
                 foreach ($matches[2] as $idx => $mob) {
                     if (ilObjMediaObject::_exists($mob) && !in_array($mob, $mediaObjects)) {
                         $mediaObjects[] = $mob;
                     }
                 }
             }
             break;
     }
     return $mediaObjects;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:36,代码来源:class.ilRTE.php

示例8: _exists

 /**
  * Check if internal link refers to a valid target
  *
  * @param	string		$a_type			target type ("PageObject" | "StructureObject" |
  *										"GlossaryItem" | "MediaObject")
  * @param	string		$a_target		target id, e.g. "il__pg_244")
  *
  * @return	boolean		true/false
  */
 function _exists($a_type, $a_target)
 {
     global $tree;
     switch ($a_type) {
         case "PageObject":
         case "StructureObject":
             return ilLMObject::_exists($a_target);
             break;
         case "GlossaryItem":
             return ilGlossaryTerm::_exists($a_target);
             break;
         case "MediaObject":
             return ilObjMediaObject::_exists($a_target);
             break;
         case "RepositoryItem":
             if (is_int(strpos($a_target, "_"))) {
                 $ref_id = ilInternalLink::_extractObjIdOfTarget($a_target);
                 return $tree->isInTree($ref_id);
             }
             break;
     }
     return false;
 }
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:32,代码来源:class.ilInternalLink.php

示例9: 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());
     }
 }
开发者ID:bheyser,项目名称:qplskl,代码行数:81,代码来源:class.ilObjForumGUI.php

示例10: start

    function start()
    {
        global $ilDB;
        ilUtil::makeDir($this->target_dir_absolute . "/objects");
        $query_frm = 'SELECT * FROM frm_settings fs ' . 'JOIN object_data od ON fs.obj_id = od.obj_id ' . 'JOIN frm_data ON top_frm_fk  = od.obj_id ' . 'WHERE fs.obj_id = ' . $ilDB->quote($this->forum_id, 'integer');
        $res = $ilDB->query($query_frm);
        while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
            break;
        }
        $this->xmlStartTag("Forum", null);
        $this->xmlElement("Id", null, (int) $row->top_pk);
        $this->xmlElement("ObjId", null, (int) $row->obj_id);
        $this->xmlElement("Title", null, $row->title);
        $this->xmlElement("Description", null, $row->description);
        $this->xmlElement("DefaultView", null, (int) $row->default_view);
        $this->xmlElement("Pseudonyms", null, (int) $row->anonymized);
        $this->xmlElement("Statistics", null, (int) $row->statistics_enabled);
        $this->xmlElement("PostingActivation", null, (int) $row->post_activation);
        $this->xmlElement("PresetSubject", null, (int) $row->preset_subject);
        $this->xmlElement("PresetRe", null, (int) $row->add_re_subject);
        $this->xmlElement("NotificationType", null, $row->notification_type);
        $this->xmlElement("ForceNotification", null, (int) $row->admin_force_noti);
        $this->xmlElement("ToggleNotification", null, (int) $row->user_toggle_noti);
        $this->xmlElement("LastPost", null, $row->top_last_post);
        $this->xmlElement("Moderator", null, (int) $row->top_mods);
        $this->xmlElement("CreateDate", null, $row->top_date);
        $this->xmlElement("UpdateDate", null, $row->top_update);
        $this->xmlElement("UpdateUserId", null, $row->update_user);
        $this->xmlElement("UserId", null, (int) $row->top_usr_id);
        $query_thr = "SELECT frm_threads.* " . " FROM frm_threads " . " INNER JOIN frm_data ON top_pk = thr_top_fk " . 'WHERE top_frm_fk = ' . $ilDB->quote($this->forum_id, 'integer');
        $res = $ilDB->query($query_thr);
        while ($row = $ilDB->fetchObject($res)) {
            $this->xmlStartTag("Thread");
            $this->xmlElement("Id", null, (int) $row->thr_pk);
            $this->xmlElement("Subject", null, $row->thr_subject);
            $this->xmlElement("UserId", null, (int) $row->thr_usr_id);
            $this->xmlElement("Alias", null, $row->thr_usr_alias);
            $this->xmlElement("LastPost", null, $row->thr_last_post);
            $this->xmlElement("CreateDate", null, $row->thr_date);
            $this->xmlElement("UpdateDate", null, $row->thr_date);
            $this->xmlElement("ImportName", null, $row->import_name);
            $this->xmlElement("Sticky", null, (int) $row->is_sticky);
            $this->xmlElement("Closed", null, (int) $row->is_closed);
            $query = 'SELECT frm_posts.*, frm_posts_tree.*
						FROM frm_posts
							INNER JOIN frm_data
								ON top_pk = pos_top_fk
							INNER JOIN frm_posts_tree
								ON pos_fk = pos_pk
						WHERE pos_thr_fk = ' . $ilDB->quote($row->thr_pk, 'integer') . ' ';
            $query .= " ORDER BY frm_posts_tree.lft ASC";
            $resPosts = $ilDB->query($query);
            $lastDepth = null;
            while ($rowPost = $ilDB->fetchObject($resPosts)) {
                /*
                				// Used for nested postings
                				if( $rowPost->depth < $lastDepth )
                				{
                					for( $i = $rowPost->depth; $i <= $lastDepth; $i++ )
                					{
                						$this->xmlEndTag("Post");
                					}
                				}*/
                $this->xmlStartTag("Post");
                $this->xmlElement("Id", null, (int) $rowPost->pos_pk);
                $this->xmlElement("UserId", null, (int) $rowPost->pos_usr_id);
                $this->xmlElement("Alias", null, $rowPost->pos_usr_alias);
                $this->xmlElement("Subject", null, $rowPost->pos_subject);
                $this->xmlElement("CreateDate", null, $rowPost->pos_date);
                $this->xmlElement("UpdateDate", null, $rowPost->pos_update);
                $this->xmlElement("UpdateUserId", null, (int) $rowPost->update_user);
                $this->xmlElement("Censorship", null, (int) $rowPost->pos_cens);
                $this->xmlElement("CensorshipMessage", null, $rowPost->pos_cens_com);
                $this->xmlElement("Notification", null, $rowPost->notify);
                $this->xmlElement("ImportName", null, $rowPost->import_name);
                $this->xmlElement("Status", null, (int) $rowPost->pos_status);
                $this->xmlElement("Message", null, ilRTE::_replaceMediaObjectImageSrc($rowPost->pos_message, 0));
                $media_exists = false;
                $mobs = ilObjMediaObject::_getMobsOfObject('frm:html', $rowPost->pos_pk);
                foreach ($mobs as $mob) {
                    $moblabel = "il_" . IL_INST_ID . "_mob_" . $mob;
                    if (ilObjMediaObject::_exists($mob)) {
                        if (!$media_exists) {
                            $this->xmlStartTag("MessageMediaObjects");
                            $media_exists = true;
                        }
                        $mob_obj = new ilObjMediaObject($mob);
                        $imgattrs = array("label" => $moblabel, "uri" => $this->target_dir_relative . "/objects/" . "il_" . IL_INST_ID . "_mob_" . $mob . "/" . $mob_obj->getTitle());
                        $this->xmlElement("MediaObject", $imgattrs, NULL);
                        $mob_obj->exportFiles($this->target_dir_absolute);
                    }
                }
                if ($media_exists) {
                    $this->xmlEndTag("MessageMediaObjects");
                }
                $this->xmlElement("Lft", null, (int) $rowPost->lft);
                $this->xmlElement("Rgt", null, (int) $rowPost->rgt);
                $this->xmlElement("Depth", null, (int) $rowPost->depth);
                $this->xmlElement("ParentId", null, (int) $rowPost->parent_pos);
                $tmp_file_obj = new ilFileDataForum($this->forum_id, $rowPost->pos_pk);
//.........这里部分代码省略.........
开发者ID:Walid-Synakene,项目名称:ilias,代码行数:101,代码来源:class.ilForumXMLWriter.php

示例11: 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']));
//.........这里部分代码省略.........
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:101,代码来源:class.ilForum.php


注:本文中的ilObjMediaObject::_exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。