Exemple #1
0
 public function deleteComment(Comments $comment)
 {
     /** @var myModel $this */
     if (method_exists($this, 'decreaseCount')) {
         $this->decreaseCount('commentCount');
     }
     return $comment->delete();
 }
 function launch()
 {
     global $interface;
     global $user;
     global $configArray;
     // Process Delete Comment
     if (isset($_GET['delete']) && is_object($user)) {
         $comment = new Comments();
         $comment->id = $_GET['delete'];
         if ($comment->find(true)) {
             if ($user->id == $comment->user_id) {
                 $comment->delete();
             }
         }
     }
     $interface->assign('id', $_GET['id']);
     if (isset($_REQUEST['comment'])) {
         if (!$user) {
             $interface->assign('recordId', $_GET['id']);
             $interface->assign('comment', $_REQUEST['comment']);
             $interface->assign('followup', true);
             $interface->assign('followupModule', 'EContentRecord');
             $interface->assign('followupAction', 'UserComments');
             $interface->setPageTitle('You must be logged in first');
             $interface->assign('subTemplate', '../MyResearch/login.tpl');
             $interface->setTemplate('view-alt.tpl');
             $interface->display('layout.tpl', 'UserComments' . $_GET['id']);
             exit;
         }
         $result = $this->saveComment();
     }
     $interface->assign('user', $user);
     $eContentRecord = new EContentRecord();
     $eContentRecord->id = $_GET['id'];
     $eContentRecord->find(true);
     $recordDriver = new EcontentRecordDriver();
     $recordDriver->setDataObject($eContentRecord);
     $interface->setPageTitle(translate('Comments') . ': ' . $recordDriver->getBreadcrumb());
     $this->loadEContentComments();
     $interface->assign('subTemplate', 'view-comments.tpl');
     $interface->setTemplate('view.tpl');
     // Display Page
     $interface->display('layout.tpl');
 }
Exemple #3
0
 /**
  * Delete a comment
  *
  * @param int    $id   ID of comment to delete
  * @param object $user User whose comment is being deleted.
  *
  * @return bool        True for success, false for failure.
  * @access public
  */
 public static function deleteComment($id, $user)
 {
     $comment = new Comments();
     $comment->id = $id;
     if ($comment->find(true)) {
         if ($user->id == $comment->user_id) {
             $comment->delete();
             return true;
         }
     }
     return false;
 }
Exemple #4
0
     break;
 case validateRoute('POST', 'torrents/\\d+/comments'):
     $torrent = new Torrent($db);
     $comments = new Comments($db, $user, $torrent);
     $comments->add((int) $params[1], $postdata["data"]);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('PATCH', 'torrents/\\d+/comments/\\d+'):
     $comments = new Comments($db, $user);
     $comments->update((int) $params[1], (int) $params[3], $postdata["postData"]);
     httpResponse($result, $totalCount);
     break;
 case validateRoute('DELETE', 'torrents/\\d+/comments/\\d+'):
     $torrent = new Torrent($db, $user);
     $comments = new Comments($db, $user, $torrent);
     $comments->delete((int) $params[3]);
     httpResponse();
     break;
 case validateRoute('GET', 'torrents/toplists'):
     $cacheId = 'toplists-' . $_GET["limit"];
     if ($memcache && ($cached = $memcache->get($cacheId))) {
         httpResponse($cached);
     } else {
         $torrent = new Torrent($db);
         $toplists = $torrent->getToplists($_GET["limit"] ?: 15);
         $memcache && $memcache->set($cacheId, $toplists, MEMCACHE_COMPRESSED, 60 * 60);
         httpResponse($toplists);
     }
     break;
 case validateRoute('GET', 'torrents/download/\\d+'):
     $torrent = new Torrent($db, $user);
 /**
  * Drop comments by object
  *
  * @param ProjectDataObject
  * @return boolean
  */
 static function dropCommentsByObject(ProjectDataObject $object)
 {
     return Comments::delete(array('`rel_object_manager` = ? AND `rel_object_id` = ?', get_class($object->manager()), $object->getObjectId()));
 }
Exemple #6
0
<?php

require_once "../bd.php";
// Include connect to BD
require_once '../classes/base.php';
// Include main classes
//If DELETE comment
if (isset($_GET['name']) == 'comment') {
    $id = $_GET['id'];
    $deleteObject = new Comments();
    if ($deleteObject->delete($id)) {
        echo '<script>window.location.href="../index.php"</script>';
    } else {
        echo 'False';
    }
}
//If DELETE etries
if (isset($_GET['name']) == 'entries') {
    $id = $_GET['id'];
    $deleteObject = new Content();
    if ($deleteObject->delete($id)) {
        echo '<script>window.location.href="../index.php"</script>';
    } else {
        echo 'False';
    }
}
Exemple #7
0
Route::post('comments/store', ['as' => 'comments.store', 'middleware' => 'csrf', 'uses' => function () {
    $foreignType = Input::get('foreigntype');
    $foreignId = Input::get('foreignid');
    return Comments::store($foreignType, $foreignId);
}]);
Route::get('comments/{id}', function ($id) {
    return Comments::get($id);
});
Route::get('comments/{id}/edit', ['as' => 'comments.edit', 'uses' => function ($id) {
    return Comments::edit($id);
}]);
Route::put('comments/{id}/update', ['as' => 'comments.update', 'middleware' => 'csrf', 'uses' => function ($id) {
    return Comments::update($id);
}]);
Route::delete('comments/{id}/delete', ['as' => 'comments.delete', 'middleware' => 'csrf', 'uses' => function ($id) {
    return Comments::delete($id);
}]);
/*
 * Ratings
 */
Route::post('ratings/store', ['as' => 'ratings.store', 'middleware' => 'csrf', 'uses' => function () {
    $foreignType = Input::get('foreigntype');
    $foreignId = Input::get('foreignid');
    return Ratings::store($foreignType, $foreignId);
}]);
/*
 * Captcha
 */
Route::get('captcha', ['as' => 'captcha', 'uses' => function () {
    Captcha::make();
    $response = Response::make('', 200);
Exemple #8
0
 function DeleteComment()
 {
     require_once ROOT_DIR . '/services/MyResearch/lib/Comments.php';
     global $user;
     global $configArray;
     // Process Delete Comment
     if (is_object($user)) {
         $comment = new Comments();
         $comment->id = $_GET['commentId'];
         $comment->source = 'eContent';
         if ($comment->find(true)) {
             if ($user->id == $comment->user_id) {
                 $comment->delete();
             }
         }
     }
     return '<result>true</result>';
 }
Exemple #9
0
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // not found
} elseif (!isset($item['id'])) {
    include '../error.php';
    // permission denied
} elseif (!Comments::allow_modification($anchor, $item)) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // deletion is confirmed
} elseif (isset($_REQUEST['confirm']) && $_REQUEST['confirm'] == 'yes') {
    // touch the related anchor before actual deletion, since the item has to be accessible at that time
    if (is_object($anchor)) {
        $anchor->touch('comment:delete', $item['id']);
    }
    // if no error, back to the anchor or to the index page
    if (Comments::delete($item['id'])) {
        Comments::clear($item);
        if ($render_overlaid && isset($_REQUEST['follow_up']) && $_REQUEST['follow_up'] == 'close') {
            echo "deleting done";
            finalize_page(true);
        } elseif (is_object($anchor)) {
            Safe::redirect($anchor->get_url('comments'));
        } else {
            Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'comments/');
        }
    }
    // deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
    Logger::error(i18n::s('The action has not been confirmed.'));
} else {
    // commands
Exemple #10
0
<?php

authorize();
// Quick SQL injection check
if (!$_GET['postid'] || !is_number($_GET['postid'])) {
    error(0);
}
// Make sure they are moderators
if (!check_perms('site_moderate_forums')) {
    error(403);
}
Comments::delete((int) $_GET['postid']);
Exemple #11
0
 /**
 * Drop comments by object
 *
 * @param ContentDataObject
 * @return boolean
 */
 static function dropCommentsByObject(ContentDataObject $object) {
   return Comments::delete(array('`rel_object_id` = ?', $object->getObjectId()));
 } // dropCommentsByObject
Exemple #12
0
 /**
  * Create admin page
  * 
  * @author Thibaud Rohmer
  */
 public function __construct()
 {
     /// Check that current user is an admin or an uploader
     if (!(CurrentUser::$admin || CurrentUser::$uploader)) {
         return;
     }
     /// Get actions available for Uploaders too
     if (isset($_GET['a'])) {
         switch ($_GET['a']) {
             case "Abo":
                 $this->page = new AdminAbout();
                 break;
             case "Upl":
                 if (isset($_POST['path'])) {
                     AdminUpload::upload();
                     CurrentUser::$path = File::r2a(stripslashes($_POST['path']));
                 }
                 break;
             case "Mov":
                 if (isset($_POST['pathFrom'])) {
                     try {
                         CurrentUser::$path = File::r2a(dirname(stripslashes($_POST['pathFrom'])));
                     } catch (Exception $e) {
                         CurrentUser::$path = Settings::$photos_dir;
                     }
                 }
                 Admin::move();
                 if (isset($_POST['move']) && $_POST['move'] == "rename") {
                     try {
                         if (is_dir(File::r2a(stripslashes($_POST['pathFrom'])))) {
                             CurrentUser::$path = dirname(File::r2a(stripslashes($_POST['pathFrom']))) . "/" . stripslashes($_POST['pathTo']);
                         }
                     } catch (Exception $e) {
                         CurrentUser::$path = Settings::$photos_dir;
                     }
                 }
                 break;
             case "Del":
                 if (isset($_POST['del'])) {
                     if (!is_array($_POST['del'])) {
                         CurrentUser::$path = dirname(File::r2a(stripslashes($_POST['del'])));
                     } else {
                         CurrentUser::$path = dirname(File::r2a(stripslashes($_POST['del'][0])));
                     }
                     Admin::delete();
                 }
                 break;
         }
     }
     /// Check that current user is an admin
     if (!CurrentUser::$admin) {
         return;
     }
     /// Get action
     if (isset($_GET['a'])) {
         switch ($_GET['a']) {
             case "Sta":
                 $this->page = new AdminStats();
                 break;
             case "VTk":
                 $this->page = new GuestToken();
                 break;
             case "DTk":
                 if (isset($_POST['tokenkey'])) {
                     GuestToken::delete($_POST['tokenkey']);
                 }
                 $this->page = new GuestToken();
                 break;
             case "Acc":
                 if (isset($_POST['edit'])) {
                     Account::edit($_POST['login'], $_POST['old_password'], $_POST['password'], $_POST['name'], $_POST['email'], NULL, $_POST['language']);
                 }
                 if (isset($_POST['login'])) {
                     $this->page = new Account($_POST['login']);
                 } else {
                     $this->page = CurrentUser::$account;
                 }
                 break;
             case "GC":
                 Group::create($_POST['group']);
                 $this->page = new Group();
                 break;
             case "AAc":
                 Account::create($_POST['login'], $_POST['password'], $_POST['verif']);
                 $this->page = new Group();
                 break;
             case "AGA":
                 $a = new Account($_POST['acc']);
                 $a->add_group($_POST['group']);
                 $a->save();
                 $this->page = CurrentUser::$account;
                 break;
             case "AGR":
                 $a = new Account($_POST['acc']);
                 $a->remove_group($_POST['group']);
                 $a->save();
                 $this->page = CurrentUser::$account;
                 break;
             case "ADe":
                 Account::delete($_POST['name']);
                 $this->page = new Group();
                 break;
             case "GEd":
                 Group::edit($_POST);
                 $this->page = new Group();
                 break;
             case "GDe":
                 Group::delete($_GET['g']);
                 $this->page = new Group();
                 break;
             case "CDe":
                 CurrentUser::$path = File::r2a($_POST['image']);
                 Comments::delete($_POST['id']);
                 $this->page = new MainPage();
                 break;
             case "JS":
                 break;
             case "EdA":
                 $this->page = new Group();
                 break;
             case "GAl":
                 if (isset($_POST['path'])) {
                     Settings::gener_all(File::r2a(stripslashes($_POST['path'])));
                 }
             case "Set":
                 if (isset($_POST['name'])) {
                     Settings::set();
                 }
                 $this->page = new Settings();
                 break;
         }
     }
     if (!isset($this->page)) {
         $this->page = new AdminAbout();
     }
     /// Create menu
     $this->menu = new AdminMenu();
 }
 public function deletecommentAction()
 {
     if ($this->_getParam('id', false)) {
         $comments = new Comments();
         $where = $comments->getAdapter()->quoteInto('comment_id = ?', (int) $this->_getParam('id'));
         $comments->delete($where);
     } else {
         throw new Exception('No comment ID has been specified', 500);
     }
 }
<?php

if (isset($_POST['task']) && $_POST['task'] == 'comment_delete') {
    require_once '../sql/models/comments.php';
    if (class_exists('Comments')) {
        if (Comments::delete($_POST['comment_id'])) {
            echo 'true';
        } else {
            echo 'false';
        }
    }
}
 /** Delete a comment ajax action
  * @access public
  * @return mixed
  * @throws Pas_Exception_Param
  */
 public function deletecommentAction()
 {
     if ($this->getParam('id', false)) {
         $comments = new Comments();
         $where = $comments->getAdapter()->quoteInto('id = ?', (int) $this->getParam('id'));
         $comments->delete($where);
     } else {
         throw new Pas_Exception_Param($this->_missingParameter, 500);
     }
 }
Exemple #16
0
 function DeleteComment()
 {
     require_once ROOT_DIR . '/services/MyResearch/lib/Comments.php';
     global $user;
     // Process Delete Comment
     if (is_object($user)) {
         $comment = new Comments();
         $comment->id = $_GET['commentId'];
         if ($comment->find(true)) {
             if ($user->id == $comment->user_id || $user->hasRole('opacAdmin')) {
                 $comment->delete();
             }
         }
     }
     return '<result>true</result>';
 }