403Webshell
Server IP : 185.252.147.100  /  Your IP : 216.73.216.43
Web Server : nginx/1.27.3
System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
User : mitr ( 1000)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/html/kanboard/app/Api/Procedure/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/html/kanboard/app/Api/Procedure/CommentProcedure.php
<?php

namespace Kanboard\Api\Procedure;

use Kanboard\Api\Authorization\CommentAuthorization;
use Kanboard\Api\Authorization\TaskAuthorization;
use Kanboard\Core\Security\Role;

/**
 * Comment API controller
 *
 * @package  Kanboard\Api\Procedure
 * @author   Frederic Guillot
 */
class CommentProcedure extends BaseProcedure
{
    public function getComment($comment_id)
    {
        CommentAuthorization::getInstance($this->container)->check($this->getClassName(), 'getComment', $comment_id);
        return $this->commentModel->getById($comment_id);
    }

    public function getAllComments($task_id)
    {
        TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'getAllComments', $task_id);
        $comments = $this->commentModel->getAll($task_id);
        $filteredComments = [];
        $userRole = $this->userSession->getRole();

        foreach ($comments as $comment) {
            if ($userRole === Role::APP_MANAGER && $comment['visibility'] === Role::APP_ADMIN) {
                continue;
            }

            if ($userRole === Role::APP_USER && $comment['visibility'] !== Role::APP_USER) {
                continue;
            }

            $filteredComments[] = $comment;
        }

        return $filteredComments;
    }

    public function removeComment($comment_id)
    {
        CommentAuthorization::getInstance($this->container)->check($this->getClassName(), 'removeComment', $comment_id);

        if ($this->userSession->isLogged()) {
            $loggedUserID = $this->userSession->getId();
            $comment = $this->commentModel->getById($comment_id);
            if ($comment['user_id'] != $loggedUserID) {
                return false;
            }
        }

        return $this->commentModel->remove($comment_id);
    }

    public function createComment($task_id, $user_id, $content, $reference = '', $visibility = Role::APP_USER)
    {
        TaskAuthorization::getInstance($this->container)->check($this->getClassName(), 'createComment', $task_id);

        if ($this->userSession->isLogged()) {
            $loggedUserID = $this->userSession->getId();
            if ($user_id != $loggedUserID) {
                return false;
            }

            $userRole = $this->userSession->getRole();
            if ($userRole === Role::APP_MANAGER && $visibility === Role::APP_ADMIN) {
                return false;
            }

            if ($userRole === Role::APP_USER && $visibility !== Role::APP_USER) {
                return false;
            }
        }

        $values = array(
            'task_id' => $task_id,
            'user_id' => $user_id,
            'comment' => $content,
            'reference' => $reference,
            'visibility' => $visibility,
        );

        list($valid, ) = $this->commentValidator->validateCreation($values);

        return $valid ? $this->commentModel->create($values) : false;
    }

    public function updateComment($id, $content)
    {
        CommentAuthorization::getInstance($this->container)->check($this->getClassName(), 'updateComment', $id);

        if ($this->userSession->isLogged()) {
            $loggedUserID = $this->userSession->getId();
            $comment = $this->commentModel->getById($id);
            if ($comment['user_id'] != $loggedUserID) {
                return false;
            }
        }

        $values = array(
            'id' => $id,
            'comment' => $content,
        );

        list($valid, ) = $this->commentValidator->validateModification($values);
        return $valid && $this->commentModel->update($values);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit