Beispiel #1
0
 /**
  * Метод удаления комментария
  * @param int $id ID комментария
  * @return null
  * @throws EngineException
  */
 protected function delete($id)
 {
     check_formkey();
     $id = (int) $id;
     lang::o()->get('comments');
     if (!$id) {
         throw new EngineException();
     }
     $this->comments->delete($id);
 }
Beispiel #2
0
 /**
  * Clear duplicate comments
  * 
  * There are times that the system may end up with duplicate comments, like when
  * copying content. This function is used to effectively eliminate duplicates.
  * <br/>Example:
  * <code>
  * comments :: clearDuplicates($currentLesson);
  * </code>
  * 
  * @param mixed $lesson a lesson id or an EfrontLesson object
  * @access public
  * @static
  * @since 3.6.0
  */
 public static function clearDuplicates($lesson)
 {
     if ($lesson instanceof EfrontLesson) {
         $lessonId = $lesson->lesson['id'];
     } elseif (eF_checkParameter($lesson, 'id')) {
         $lessonId = $lesson;
     } else {
         throw new EfrontLessonException(_INVALIDID . ": {$lesson}", EfrontLessonException::INVALID_ID);
     }
     $result = eF_getTableData("comments", "*", "lessons_ID=" . $lessonId, "id");
     foreach ($result as $value) {
         $commentsTerms[$value['id']] = $value;
         $id = $value['id'];
         unset($value['id']);
         $checksums[$id] = md5(serialize($value));
     }
     $uniques = array_unique($checksums);
     $duplicates = array_diff_key($checksums, $uniques);
     foreach ($duplicates as $key => $value) {
         $comments = new comments($commentsTerms[$key]);
         $comments->delete();
     }
 }
Beispiel #3
0
<?php

// +----------------------------------------------------------------------
// | Demila [ Beautiful Digital Content Trading System ]
// +----------------------------------------------------------------------
// | Copyright (c) 2015 http://demila.org All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Email author@demila.org
// +----------------------------------------------------------------------
define('USING_LANGUAGE', false);
require_once '../../../config.php';
require_once $config['root_path'] . '/core/functions.php';
include_once $config['system_core'] . "/initEngine.php";
admin_login();
if (isset($_POST['delete']) && isset($_POST['id']) && isset($_SESSION['user']['access']['items'])) {
    require_once ROOT_PATH . "/apps/items/models/items.class.php";
    $cms = new items();
    $cms->delete(intval($_POST['id']));
    die(json_encode(array_merge($_POST, array('status' => 'true'))));
} elseif (isset($_POST['deleteComment']) && isset($_POST['id']) && isset($_SESSION['user']['access']['items'])) {
    require_once ROOT_PATH . "/apps/items/models/comments.class.php";
    $cms = new comments();
    $cms->delete(intval($_POST['id']));
    die(json_encode(array_merge($_POST, array('status' => 'true'))));
}
echo json_encode(array_merge($_POST, array('status' => 'unknown error')));
die;