本文整理汇总了PHP中CEventLog::add方法的典型用法代码示例。如果您正苦于以下问题:PHP CEventLog::add方法的具体用法?PHP CEventLog::add怎么用?PHP CEventLog::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEventLog
的用法示例。
在下文中一共展示了CEventLog::add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Delete
public static final function Delete($lesson_id)
{
global $USER_FIELD_MANAGER;
list($lesson_id, $simulate, $check_permissions, $user_id) = self::_funcDelete_ParseOptions($lesson_id);
if ($check_permissions) {
$oAccess = CLearnAccess::GetInstance($user_id);
if (!$oAccess->IsLessonAccessible($lesson_id, CLearnAccess::OP_LESSON_REMOVE)) {
throw new LearnException('EA_ACCESS_DENIED', LearnException::EXC_ERR_ALL_ACCESS_DENIED);
}
}
// Parents and childs of the lesson
$arNeighboursEdges = self::ListImmediateNeighbours($lesson_id);
// precache rights for lesson
if ($check_permissions) {
$IsLessonAccessibleFor_OP_LESSON_UNLINK_DESCENDANTS = $oAccess->IsLessonAccessible($lesson_id, CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS);
$IsLessonAccessibleFor_OP_LESSON_UNLINK_FROM_PARENTS = $oAccess->IsLessonAccessible($lesson_id, CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS);
}
foreach (GetModuleEvents('learning', 'OnBeforeLessonDelete', true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($lesson_id));
}
foreach ($arNeighboursEdges as $arEdge) {
$child_lesson_id = (int) $arEdge['CHILD_LESSON'];
$parent_lesson_id = (int) $arEdge['PARENT_LESSON'];
if ($check_permissions) {
$IsLessonAccessible = false;
if ($child_lesson_id === $lesson_id) {
// if we will be remove edge to parent - use precached rights for OP_LESSON_UNLINK_FROM_PARENTS
$IsLessonAccessible = $IsLessonAccessibleFor_OP_LESSON_UNLINK_FROM_PARENTS && $oAccess->IsLessonAccessible($parent_lesson_id, CLearnAccess::OP_LESSON_UNLINK_DESCENDANTS);
} elseif ($parent_lesson_id === $lesson_id) {
// if we will be remove edge to child - use precached rights for OP_LESSON_UNLINK_DESCENDANTS
$IsLessonAccessible = $IsLessonAccessibleFor_OP_LESSON_UNLINK_DESCENDANTS && $oAccess->IsLessonAccessible($child_lesson_id, CLearnAccess::OP_LESSON_UNLINK_FROM_PARENTS);
} else {
throw new LearnException('EA_FATAL: $lesson_id (' . $lesson_id . ') not equal to one of: $child_lesson_id (' . $child_lesson_id . '), $parent_lesson_id (' . $parent_lesson_id . ')', LearnException::EXC_ERR_ALL_LOGIC | LearnException::EXC_ERR_ALL_GIVEUP);
}
if (!$IsLessonAccessible) {
throw new LearnException('EA_ACCESS_DENIED', LearnException::EXC_ERR_ALL_ACCESS_DENIED);
}
if ($simulate === false) {
self::RelationRemove($parent_lesson_id, $child_lesson_id);
}
}
}
$linkedCourseId = self::GetLinkedCourse($lesson_id);
// If lesson is course, remove course
if ($linkedCourseId !== false) {
global $DB;
if ($simulate === false) {
if (!$DB->Query("DELETE FROM b_learn_course_site WHERE COURSE_ID = " . (int) $linkedCourseId, true)) {
throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_ALL_GIVEUP);
}
$rc = self::CourseBecomeLesson($linkedCourseId);
// if course cannot be converted to lesson - don't remove lesson
if ($rc === false) {
throw new LearnException('EA_OTHER: lesson is unremovable because linked course is in use.', LearnException::EXC_ERR_LL_UNREMOVABLE_CL);
}
// reload cache of LINKED_LESSON_ID -> COURSE_ID
self::GetCourseToLessonMap_ReloadCache();
if (CModule::IncludeModule("search")) {
CSearch::DeleteIndex("learning", false, "C" . $linkedCourseId);
CSearch::DeleteIndex("learning", "C" . $linkedCourseId);
}
}
}
// And remove lesson
if ($simulate === false) {
global $DB;
$r = $DB->Query("SELECT PREVIEW_PICTURE, DETAIL_PICTURE \n\t\t\t\tFROM b_learn_lesson \n\t\t\t\tWHERE ID = " . (int) $lesson_id, true);
if ($r === false) {
throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_ALL_GIVEUP);
}
$arRes = $r->Fetch();
if (!$arRes) {
throw new LearnException('EA_SQLERROR', LearnException::EXC_ERR_ALL_GIVEUP);
}
CFile::Delete($arRes['PREVIEW_PICTURE']);
CFile::Delete($arRes['DETAIL_PICTURE']);
// Remove questions
$q = CLQuestion::GetList(array(), array('LESSON_ID' => $lesson_id));
while ($arQ = $q->Fetch()) {
if (!CLQuestion::Delete($arQ['ID'])) {
throw new LearnException('EA_QUESTION_NOT_REMOVED', LearnException::EXC_ERR_ALL_GIVEUP);
}
}
CLearnGraphNode::Remove($lesson_id);
$USER_FIELD_MANAGER->delete('LEARNING_LESSONS', $lesson_id);
CLearnCacheOfLessonTreeComponent::MarkAsDirty();
CEventLog::add(array('AUDIT_TYPE_ID' => 'LEARNING_REMOVE_ITEM', 'MODULE_ID' => 'learning', 'ITEM_ID' => 'L #' . $lesson_id, 'DESCRIPTION' => 'lesson removed'));
if (CModule::IncludeModule('search')) {
CSearch::DeleteIndex('learning', false, 'L' . $lesson_id);
CSearch::DeleteIndex('learning', 'L' . $lesson_id);
}
}
if ($simulate === false) {
foreach (GetModuleEvents('learning', 'OnAfterLessonDelete', true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($lesson_id));
}
}
}
示例2: delete
/**
* Removes existing learning group
*
* @param int $groupId
*
* @return bool false on error, or true - if no errors detected
*/
public static function delete($groupId)
{
global $DB, $APPLICATION, $USER_FIELD_MANAGER;
foreach (GetModuleEvents('learning', 'OnBeforeLearningGroupDelete', true) as $arEvent) {
if (ExecuteModuleEventEx($arEvent, array($groupId)) === false) {
IncludeModuleLangFile(__FILE__);
$errmsg = GetMessage("LEARNING_GROUP_DELETE_UNKNOWN_ERROR");
$errno = 'LEARNING_GROUP_DELETE_UNKNOWN_ERROR';
if ($ex = $APPLICATION->getException()) {
$errmsg = $ex->getString();
$errno = $ex->getId();
}
$e = new CAdminException(array('text' => $errmsg, 'id' => $errno));
$APPLICATION->ThrowException($e);
return false;
}
}
$rc = $DB->Query("DELETE FROM b_learn_groups WHERE ID = " . (int) $groupId, $bIgnoreErrors = true);
if (defined("BX_COMP_MANAGED_CACHE")) {
global $CACHE_MANAGER;
$CACHE_MANAGER->ClearByTag('LEARNING_GROUP_' . (int) ($groupId / 100));
$CACHE_MANAGER->ClearByTag('LEARNING_GROUP');
}
$USER_FIELD_MANAGER->delete('LEARNING_LGROUPS', $groupId);
CEventLog::add(array('AUDIT_TYPE_ID' => 'LEARNING_REMOVE_ITEM', 'MODULE_ID' => 'learning', 'ITEM_ID' => 'LG #' . $groupId, 'DESCRIPTION' => 'learning group removed'));
foreach (GetModuleEvents('learning', 'OnAfterLearningGroupDelete', true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($groupId));
}
return $rc !== false;
}
示例3: Delete
/**
* <p>Метод удаляет вопрос с идентификатором ID.</p>
*
*
* @param int $ID Идентификатор вопроса.
*
* @return bool <p>Метод возвращает <i>true</i> в случае успешного удаления вопроса, в
* противном случае возвращает <i>false</i>.</p>
*
* <h4>Example</h4>
* <pre>
* <?
* if (CModule::IncludeModule("learning"))
* {
* $COURSE_ID = 97;
* $QUESTION_ID = 600;
*
* if (CCourse::GetPermission($COURSE_ID) >= 'W')
* {
* @set_time_limit(0);
* $DB->StartTransaction();
* if (!CLQuestion::Delete($QUESTION_ID))
* {
* echo "Error!";
* $DB->Rollback();
* }
* else
* $DB->Commit();
* }
* }
* ?>
* </pre>
*
*
* <h4>See Also</h4>
* <ul><li> <a href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/index.php">CLQuestion</a>::<a
* href="http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/add.php">Add</a> </li></ul><a name="examples"></a>
*
*
* @static
* @link http://dev.1c-bitrix.ru/api_help/learning/classes/clquestion/delete.php
* @author Bitrix
*/
public static function Delete($ID)
{
global $DB, $USER_FIELD_MANAGER;
$ID = intval($ID);
if ($ID < 1) {
return false;
}
$strSql = "SELECT FILE_ID FROM b_learn_question WHERE ID = " . $ID;
$r = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if (!($arQuestion = $r->Fetch())) {
return false;
}
$answers = CLAnswer::GetList(array(), array("QUESTION_ID" => $ID));
while ($arAnswer = $answers->Fetch()) {
if (!CLAnswer::Delete($arAnswer["ID"])) {
return false;
}
}
$arAttempts = array();
$strSql = "SELECT ATTEMPT_ID FROM b_learn_test_result WHERE QUESTION_ID = " . $ID;
$res = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
while ($ar = $res->Fetch()) {
$arAttempts[] = $ar["ATTEMPT_ID"];
}
//Attempts to recount
//Results
$strSql = "DELETE FROM b_learn_test_result WHERE QUESTION_ID = " . $ID;
if (!$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) {
return false;
}
foreach ($arAttempts as $ATTEMPT_ID) {
CTestAttempt::RecountQuestions($ATTEMPT_ID);
CTestAttempt::OnAttemptChange($ATTEMPT_ID);
}
$strSql = "DELETE FROM b_learn_question WHERE ID = " . $ID;
if (!$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) {
return false;
}
$USER_FIELD_MANAGER->delete('LEARNING_QUESTIONS', $ID);
CFile::Delete($arQuestion["FILE_ID"]);
CEventLog::add(array('AUDIT_TYPE_ID' => 'LEARNING_REMOVE_ITEM', 'MODULE_ID' => 'learning', 'ITEM_ID' => 'Q #' . $ID, 'DESCRIPTION' => 'question removed'));
foreach (GetModuleEvents('learning', 'OnAfterQuestionDelete', true) as $arEvent) {
ExecuteModuleEventEx($arEvent, array($ID, $arQuestion));
}
return true;
}
示例4: Delete
function Delete($ID)
{
global $DB;
$ID = intval($ID);
if ($ID < 1) {
return false;
}
CLearnHelper::FireEvent('OnBeforeTestDelete', $ID);
//Gradebook
$records = CGradeBook::GetList(array(), array("TEST_ID" => $ID));
while ($arRecord = $records->Fetch()) {
if (!CGradeBook::Delete($arRecord["ID"])) {
return false;
}
}
//Attempts
$attempts = CTestAttempt::GetList(array(), array("TEST_ID" => $ID));
while ($arAttempt = $attempts->Fetch()) {
if (!CTestAttempt::Delete($arAttempt["ID"])) {
return false;
}
}
//Marks
$marks = CLTestMark::GetList(array(), array("TEST_ID" => $ID));
while ($arMark = $marks->Fetch()) {
if (!CLTestMark::Delete($arMark["ID"])) {
return false;
}
}
$strSql = "DELETE FROM b_learn_test WHERE ID = " . $ID;
if (!$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__)) {
return false;
}
CEventLog::add(array('AUDIT_TYPE_ID' => 'LEARNING_REMOVE_ITEM', 'MODULE_ID' => 'learning', 'ITEM_ID' => 'T #' . $ID, 'DESCRIPTION' => 'test removed'));
CLearnHelper::FireEvent('OnAfterTestDelete', $ID);
return true;
}