<commit_before><?php
namespace Chamilo\Core\Repository;

use Chamilo\Core\Repository\Filter\FilterData;
use Chamilo\Core\Repository\Filter\Renderer\FormFilterRenderer;
use Chamilo\Core\Repository\Filter\Renderer\HtmlFilterRenderer;
use Chamilo\Core\Repository\Menu\ObjectTypeMenu;
use Chamilo\Core\Repository\Menu\RepositoryCategoryTreeMenu;
use Chamilo\Core\Repository\Menu\RepositoryMenu;
use Chamilo\Core\Repository\Selector\TypeSelector;
use Chamilo\Core\Repository\Storage\DataClass\ContentObject;
use Chamilo\Core\Repository\Storage\DataClass\RepositoryCategory;
use Chamilo\Core\Repository\Storage\DataManager;
use Chamilo\Core\Repository\UserView\Menu\UserViewMenu;
use Chamilo\Core\Repository\Workspace\PersonalWorkspace;
use Chamilo\Core\Repository\Workspace\Repository\WorkspaceRepository;
use Chamilo\Core\Repository\Workspace\Service\WorkspaceService;
use Chamilo\Core\Repository\Workspace\Storage\DataClass\Workspace;
use Chamilo\Libraries\Architecture\Application\Application;
use Chamilo\Libraries\Architecture\Application\ApplicationConfigurationInterface;
use Chamilo\Libraries\Architecture\ClassnameUtilities;
use Chamilo\Libraries\Architecture\Exceptions\ObjectNotExistException;
use Chamilo\Libraries\File\Redirect;
use Chamilo\Libraries\Format\Structure\BreadcrumbTrail;
use Chamilo\Libraries\Format\Tabs\DynamicContentTab;
use Chamilo\Libraries\Format\Tabs\DynamicTabsRenderer;
use Chamilo\Libraries\Format\Theme;
use Chamilo\Libraries\Platform\Session\Request;
use Chamilo\Libraries\Platform\Translation;
use Chamilo\Libraries\Storage\Parameters\DataClassCountParameters;
use Chamilo\Libraries\Storage\Query\Condition\AndCondition;
use Chamilo\Libraries\Storage\Query\Condition\EqualityCondition;
use Chamilo\Libraries\Storage\Query\Variable\PropertyConditionVariable;
use Chamilo\Libraries\Storage\Query\Variable\StaticConditionVariable;

/**
 *
 * @package Chamilo\Core\Repository
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
abstract class Manager extends Application
{
    /**
     * #@+ Constant defining a parameter of the repository manager.
     */
    // SortableTable hogs 'action' so we'll use something else.
    const PARAM_CATEGORY_ID = 'category';
    const PARAM_SHARED_CATEGORY_ID = 'shared_category_id';
    const PARAM_CONTENT_OBJECT_ID = 'object';
    const PARAM_ATTACHMENT_ID = 'attachment';
    const PARAM_DESTINATION_CONTENT_OBJECT_ID = 'destination';
    const PARAM_CONTENT_OBJECT_TYPE = 'content_object_type';
    const PARAM_CONTENT_OBJECT_TEMPLATE_REGISTRATION_ID = 'template_id';
    const PARAM_DELETE_PERMANENTLY = 'delete_permanently';
    const PARAM_DELETE_VERSION = 'delete_version';
    const PARAM_DELETE_RECYCLED = 'delete_recycle';
    const PARAM_EXPORT_SELECTED = 'export_selected';
    const PARAM_EXPORT_CP_SELECTED = 'export_cp_selected';
    const PARAM_EMPTY_RECYCLE_BIN = 'empty';
    const PARAM_RECYCLE_SELECTED = 'recycle_selected';
    const PARAM_MOVE_SELECTED = 'move_selected';
    const PARAM_RESTORE_SELECTED = 'restore_selected';
    const PARAM_DELETE_SELECTED = 'delete_selected';
    const PARAM_EDIT_SELECTED_RIGHTS = 'rights_selected';
    const PARAM_PUBLISH_SELECTED = 'publish_selected';
    const PARAM_COMPARE_OBJECT = 'object';
    const PARAM_COMPARE_VERSION = 'compare';
    const PARAM_CLOI_REF = 'cloi_ref';
    const PARAM_CLOI_ID = 'cloi_id';
    const PARAM_CLOI_ROOT_ID = 'cloi_root_id';
    const PARAM_CLOI_COMPLEX_REF = 'cloi_complex_ref';
    const PARAM_DISPLAY_ORDER = 'display_order';
    const PARAM_REMOVE_SELECTED_CLOI = 'cloi_delete_selected';
    const PARAM_MOVE_DIRECTION = 'move_direction';
    const PARAM_DIRECTION_UP = 'up';
    const PARAM_DIRECTION_DOWN = 'down';
    const PARAM_ADD_OBJECTS = 'add_objects';
    const PARAM_TARGET_USER = 'target_user';
    const PARAM_TARGET_GROUP = 'target_group';
    const PARAM_COPY_TO_TEMPLATES = 'copy_to_template';
    const PARAM_EXTERNAL_OBJECT_ID = 'external_object_id';
    const PARAM_EXTERNAL_REPOSITORY_ID = 'ext_rep_id';
    const PARAM_EXTERNAL_INSTANCE = 'external_instance';
    const PARAM_LINK_TYPE = 'link_type';
    const PARAM_LINK_ID = 'link_id';
    const PARAM_CONTENT_OBJECT_MANAGER_TYPE = 'manage';
    const PARAM_SHARED_VIEW = 'shared_view';
    const PARAM_SHOW_OBJECTS_SHARED_BY_ME = 'show_my_objects';
    const PARAM_RENAME = 'rename_co';
    const PARAM_EXPORT_TYPE = 'export_type';
    const PARAM_IMPORT_TYPE = 'import_type';
    const PARAM_CATEGORY_TYPE = 'category_type';
    const PARAM_TYPE = 'type';
    const PARAM_IDENTIFIER = 'identifier';
    const PARAM_WORKSPACE_ID = 'workspace_id';
    const SHARED_VIEW_OTHERS_OBJECTS = 0;
    const SHARED_VIEW_OWN_OBJECTS = 1;
    const SHARED_VIEW_ALL_OBJECTS = 2;
    const PARAM_RENDERER = 'renderer';
    
    /**
     * Constant defining an action of the repository manager.
     */
    const ACTION_BROWSE_CONTENT_OBJECTS = 'Browser';
    const ACTION_BROWSE_SHARED_CONTENT_OBJECTS = 'SharedContentObjectsBrowser';
    const ACTION_BROWSE_RECYCLED_CONTENT_OBJECTS = 'RecycleBinBrowser';
    const ACTION_VIEW_CONTENT_OBJECTS = 'Viewer';
    const ACTION_CREATE_CONTENT_OBJECTS = 'Creator';
    const ACTION_EDIT_CONTENT_OBJECTS = 'Editor';
    const ACTION_REVERT_CONTENT_OBJECTS = 'Reverter';
    const ACTION_DELETE_CONTENT_OBJECTS = 'Deleter';
    const ACTION_DELETE_SHARED_CONTENT_OBJECTS = 'SharedContentObjectsDeleter';
    const ACTION_UNLINK_CONTENT_OBJECTS = 'Unlinker';
    const ACTION_RESTORE_CONTENT_OBJECTS = 'Restorer';
    const ACTION_MOVE_CONTENT_OBJECTS = 'Mover';
    const ACTION_MOVE_SHARED_CONTENT_OBJECTS = 'SharedContentObjectsMover';
    const ACTION_QUOTA = 'Quota';
    const ACTION_COMPARE_CONTENT_OBJECTS = 'Comparer';
    const ACTION_EXPORT_CONTENT_OBJECTS = 'Exporter';
    const ACTION_IMPORT_CONTENT_OBJECTS = 'Importer';
    const ACTION_MANAGE_CATEGORIES = 'CategoryManager';
    const ACTION_BUILD_COMPLEX_CONTENT_OBJECT = 'Builder';
    const ACTION_VIEW_REPO = 'AttachmentViewer';
    const ACTION_DOWNLOAD_DOCUMENT = 'DocumentDownloader';
    const ACTION_COPY_CONTENT_OBJECT = 'Copier';
    const ACTION_VIEW_ATTACHMENT = 'AttachmentViewer';
    const ACTION_DELETE_LINK = 'LinkDeleter';
    const ACTION_VIEW_DOUBLES = 'DoublesViewer';
    const ACTION_HTML_EDITOR_FILE = 'HtmlEditorFile';
    const ACTION_REPOSITORY_VIEWER = 'RepositoryViewer';
    const ACTION_USER_VIEW = 'UserView';
    const ACTION_PREVIEW = 'Previewer';
    const ACTION_WORKSPACE = 'Workspace';
    const ACTION_PUBLICATION = 'Publication';
    const ACTION_LINK_CONTENT_OBJECT_PROPERTY_METADATA = 'PropertyMetadataLinker';
    const ACTION_LINK_CONTENT_OBJECT_METADATA_ELEMENT = 'MetadataElementLinker';
    const ACTION_LINK_CONTENT_OBJECT_ALTERNATIVE = 'AlternativeLinker';
    const ACTION_BATCH_EDIT_CONTENT_OBJECT_METADATA = 'MetadataBatchEditor';
    const ACTION_LINK_SCHEMAS = 'SchemaLinker';
    const ACTION_LINK_PROVIDERS = 'ProviderLinker';
    const ACTION_IMPACT_VIEW_RECYCLE = 'ImpactViewRecycler';
    
    // Tabs
    const TABS_FILTER = 'advanced_filter';
    const TABS_CONTENT_OBJECT = 'content_object';
    const TAB_CATEGORY = 'Category';
    const TAB_OBJECT_TYPE = 'ObjectType';
    const TAB_SEARCH = 'Search';
    const TAB_USERVIEW = 'Userview';
    
    // Default action
    const DEFAULT_ACTION = self::ACTION_BROWSE_CONTENT_OBJECTS;

    /**
     * Property of this repository manager.
     */
    private $search_parameters;

    private $search_form;

    private $category_menu;

    /**
     *
     * @var \Chamilo\Core\Repository\Workspace\Architecture\WorkspaceInterface
     */
    private $currentWorkspace;

    /**
     * Constructor
     * 
     * @param $user_id int The user id of current user
     */
    public function __construct(ApplicationConfigurationInterface $applicationConfiguration)
    {
        parent::__construct($applicationConfiguration);
        
        $this->checkAuthorization(Manager::context());
        <commit_msg>[Repository] Bugfix for document downloader - authorization checker<commit_after><?php
namespace Chamilo\Core\Repository;

use Chamilo\Core\Repository\Filter\FilterData;
use Chamilo\Core\Repository\Filter\Renderer\FormFilterRenderer;
use Chamilo\Core\Repository\Filter\Renderer\HtmlFilterRenderer;
use Chamilo\Core\Repository\Menu\ObjectTypeMenu;
use Chamilo\Core\Repository\Menu\RepositoryCategoryTreeMenu;
use Chamilo\Core\Repository\Menu\RepositoryMenu;
use Chamilo\Core\Repository\Selector\TypeSelector;
use Chamilo\Core\Repository\Storage\DataClass\ContentObject;
use Chamilo\Core\Repository\Storage\DataClass\RepositoryCategory;
use Chamilo\Core\Repository\Storage\DataManager;
use Chamilo\Core\Repository\UserView\Menu\UserViewMenu;
use Chamilo\Core\Repository\Workspace\PersonalWorkspace;
use Chamilo\Core\Repository\Workspace\Repository\WorkspaceRepository;
use Chamilo\Core\Repository\Workspace\Service\WorkspaceService;
use Chamilo\Core\Repository\Workspace\Storage\DataClass\Workspace;
use Chamilo\Libraries\Architecture\Application\Application;
use Chamilo\Libraries\Architecture\Application\ApplicationConfigurationInterface;
use Chamilo\Libraries\Architecture\ClassnameUtilities;
use Chamilo\Libraries\Architecture\Exceptions\ObjectNotExistException;
use Chamilo\Libraries\Architecture\Interfaces\NoAuthenticationSupport;
use Chamilo\Libraries\File\Redirect;
use Chamilo\Libraries\Format\Structure\BreadcrumbTrail;
use Chamilo\Libraries\Format\Tabs\DynamicContentTab;
use Chamilo\Libraries\Format\Tabs\DynamicTabsRenderer;
use Chamilo\Libraries\Format\Theme;
use Chamilo\Libraries\Platform\Session\Request;
use Chamilo\Libraries\Platform\Translation;
use Chamilo\Libraries\Storage\Parameters\DataClassCountParameters;
use Chamilo\Libraries\Storage\Query\Condition\AndCondition;
use Chamilo\Libraries\Storage\Query\Condition\EqualityCondition;
use Chamilo\Libraries\Storage\Query\Variable\PropertyConditionVariable;
use Chamilo\Libraries\Storage\Query\Variable\StaticConditionVariable;

/**
 *
 * @package Chamilo\Core\Repository
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
abstract class Manager extends Application
{
    /**
     * #@+ Constant defining a parameter of the repository manager.
     */
    // SortableTable hogs 'action' so we'll use something else.
    const PARAM_CATEGORY_ID = 'category';
    const PARAM_SHARED_CATEGORY_ID = 'shared_category_id';
    const PARAM_CONTENT_OBJECT_ID = 'object';
    const PARAM_ATTACHMENT_ID = 'attachment';
    const PARAM_DESTINATION_CONTENT_OBJECT_ID = 'destination';
    const PARAM_CONTENT_OBJECT_TYPE = 'content_object_type';
    const PARAM_CONTENT_OBJECT_TEMPLATE_REGISTRATION_ID = 'template_id';
    const PARAM_DELETE_PERMANENTLY = 'delete_permanently';
    const PARAM_DELETE_VERSION = 'delete_version';
    const PARAM_DELETE_RECYCLED = 'delete_recycle';
    const PARAM_EXPORT_SELECTED = 'export_selected';
    const PARAM_EXPORT_CP_SELECTED = 'export_cp_selected';
    const PARAM_EMPTY_RECYCLE_BIN = 'empty';
    const PARAM_RECYCLE_SELECTED = 'recycle_selected';
    const PARAM_MOVE_SELECTED = 'move_selected';
    const PARAM_RESTORE_SELECTED = 'restore_selected';
    const PARAM_DELETE_SELECTED = 'delete_selected';
    const PARAM_EDIT_SELECTED_RIGHTS = 'rights_selected';
    const PARAM_PUBLISH_SELECTED = 'publish_selected';
    const PARAM_COMPARE_OBJECT = 'object';
    const PARAM_COMPARE_VERSION = 'compare';
    const PARAM_CLOI_REF = 'cloi_ref';
    const PARAM_CLOI_ID = 'cloi_id';
    const PARAM_CLOI_ROOT_ID = 'cloi_root_id';
    const PARAM_CLOI_COMPLEX_REF = 'cloi_complex_ref';
    const PARAM_DISPLAY_ORDER = 'display_order';
    const PARAM_REMOVE_SELECTED_CLOI = 'cloi_delete_selected';
    const PARAM_MOVE_DIRECTION = 'move_direction';
    const PARAM_DIRECTION_UP = 'up';
    const PARAM_DIRECTION_DOWN = 'down';
    const PARAM_ADD_OBJECTS = 'add_objects';
    const PARAM_TARGET_USER = 'target_user';
    const PARAM_TARGET_GROUP = 'target_group';
    const PARAM_COPY_TO_TEMPLATES = 'copy_to_template';
    const PARAM_EXTERNAL_OBJECT_ID = 'external_object_id';
    const PARAM_EXTERNAL_REPOSITORY_ID = 'ext_rep_id';
    const PARAM_EXTERNAL_INSTANCE = 'external_instance';
    const PARAM_LINK_TYPE = 'link_type';
    const PARAM_LINK_ID = 'link_id';
    const PARAM_CONTENT_OBJECT_MANAGER_TYPE = 'manage';
    const PARAM_SHARED_VIEW = 'shared_view';
    const PARAM_SHOW_OBJECTS_SHARED_BY_ME = 'show_my_objects';
    const PARAM_RENAME = 'rename_co';
    const PARAM_EXPORT_TYPE = 'export_type';
    const PARAM_IMPORT_TYPE = 'import_type';
    const PARAM_CATEGORY_TYPE = 'category_type';
    const PARAM_TYPE = 'type';
    const PARAM_IDENTIFIER = 'identifier';
    const PARAM_WORKSPACE_ID = 'workspace_id';
    const SHARED_VIEW_OTHERS_OBJECTS = 0;
    const SHARED_VIEW_OWN_OBJECTS = 1;
    const SHARED_VIEW_ALL_OBJECTS = 2;
    const PARAM_RENDERER = 'renderer';
    
    /**
     * Constant defining an action of the repository manager.
     */
    const ACTION_BROWSE_CONTENT_OBJECTS = 'Browser';
    const ACTION_BROWSE_SHARED_CONTENT_OBJECTS = 'SharedContentObjectsBrowser';
    const ACTION_BROWSE_RECYCLED_CONTENT_OBJECTS = 'RecycleBinBrowser';
    const ACTION_VIEW_CONTENT_OBJECTS = 'Viewer';
    const ACTION_CREATE_CONTENT_OBJECTS = 'Creator';
    const ACTION_EDIT_CONTENT_OBJECTS = 'Editor';
    const ACTION_REVERT_CONTENT_OBJECTS = 'Reverter';
    const ACTION_DELETE_CONTENT_OBJECTS = 'Deleter';
    const ACTION_DELETE_SHARED_CONTENT_OBJECTS = 'SharedContentObjectsDeleter';
    const ACTION_UNLINK_CONTENT_OBJECTS = 'Unlinker';
    const ACTION_RESTORE_CONTENT_OBJECTS = 'Restorer';
    const ACTION_MOVE_CONTENT_OBJECTS = 'Mover';
    const ACTION_MOVE_SHARED_CONTENT_OBJECTS = 'SharedContentObjectsMover';
    const ACTION_QUOTA = 'Quota';
    const ACTION_COMPARE_CONTENT_OBJECTS = 'Comparer';
    const ACTION_EXPORT_CONTENT_OBJECTS = 'Exporter';
    const ACTION_IMPORT_CONTENT_OBJECTS = 'Importer';
    const ACTION_MANAGE_CATEGORIES = 'CategoryManager';
    const ACTION_BUILD_COMPLEX_CONTENT_OBJECT = 'Builder';
    const ACTION_VIEW_REPO = 'AttachmentViewer';
    const ACTION_DOWNLOAD_DOCUMENT = 'DocumentDownloader';
    const ACTION_COPY_CONTENT_OBJECT = 'Copier';
    const ACTION_VIEW_ATTACHMENT = 'AttachmentViewer';
    const ACTION_DELETE_LINK = 'LinkDeleter';
    const ACTION_VIEW_DOUBLES = 'DoublesViewer';
    const ACTION_HTML_EDITOR_FILE = 'HtmlEditorFile';
    const ACTION_REPOSITORY_VIEWER = 'RepositoryViewer';
    const ACTION_USER_VIEW = 'UserView';
    const ACTION_PREVIEW = 'Previewer';
    const ACTION_WORKSPACE = 'Workspace';
    const ACTION_PUBLICATION = 'Publication';
    const ACTION_LINK_CONTENT_OBJECT_PROPERTY_METADATA = 'PropertyMetadataLinker';
    const ACTION_LINK_CONTENT_OBJECT_METADATA_ELEMENT = 'MetadataElementLinker';
    const ACTION_LINK_CONTENT_OBJECT_ALTERNATIVE = 'AlternativeLinker';
    const ACTION_BATCH_EDIT_CONTENT_OBJECT_METADATA = 'MetadataBatchEditor';
    const ACTION_LINK_SCHEMAS = 'SchemaLinker';
    const ACTION_LINK_PROVIDERS = 'ProviderLinker';
    const ACTION_IMPACT_VIEW_RECYCLE = 'ImpactViewRecycler';
    
    // Tabs
    const TABS_FILTER = 'advanced_filter';
    const TABS_CONTENT_OBJECT = 'content_object';
    const TAB_CATEGORY = 'Category';
    const TAB_OBJECT_TYPE = 'ObjectType';
    const TAB_SEARCH = 'Search';
    const TAB_USERVIEW = 'Userview';
    
    // Default action
    const DEFAULT_ACTION = self::ACTION_BROWSE_CONTENT_OBJECTS;

    /**
     * Property of this repository manager.
     */
    private $search_parameters;

    private $search_form;

    private $category_menu;

    /**
     *
     * @var \Chamilo\Core\Repository\Workspace\Architecture\WorkspaceInterface
     */
    private $currentWorkspace;

    /**
     * Constructor
     * 
     * @param $user_id int The user id of current user
     */
    public function __construct(ApplicationConfigurationInterface $applicationConfiguration)
    {
        parent::__construct($applicationConfiguration);

        if($this->getUser())
        {
            $this->checkAuthorization(Manager::context());
        }

{'fraction_non_alphanumeric': 0.0860076232632485, 'fraction_numerical': 0.00036886757654002215, 'mean_word_length': 5.1131153701615935, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2352075', 'n_tokens_mistral': 5267, 'n_tokens_neox': 5258, 'n_words': 887}