Minor - format code

pull/3006/head
Julio Montoya 5 years ago
parent 2f567c8f99
commit 387d5b64d0
  1. 6
      main/document/document.php
  2. 5
      main/exercise/exercise.class.php
  3. 1
      main/inc/ajax/document.ajax.php
  4. 387
      main/inc/lib/document.lib.php
  5. 1
      main/inc/lib/exercise.lib.php
  6. 14
      src/CoreBundle/Component/Editor/Driver/CourseDriver.php
  7. 4
      src/CoreBundle/Controller/UserPortalController.php
  8. 6
      src/CourseBundle/Entity/CDocument.php
  9. 6
      src/CourseBundle/Repository/CDocumentRepository.php

@ -2,9 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Resource\ResourceLink;
use Chamilo\CoreBundle\Entity\Resource\ResourceRight;
use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Security\Authorization\Voter\ResourceNodeVoter;
use ChamiloSession as Session;
/**
@ -115,7 +113,6 @@ if ($capturePluginInstalled) {
';
}
$htmlHeadXtra[]
= '<script>
$(function () {
@ -2042,9 +2039,6 @@ $repo = $em->getRepository('ChamiloCourseBundle:CDocument');
$document = $repo->find(19);
if ($document->isVisible()) {
}
echo '

@ -2089,7 +2089,6 @@ class Exercise
]
);
$group = [
$form->createElement(
'checkbox',
@ -2108,11 +2107,10 @@ class Exercise
'hide_question_score',
null,
get_lang('HideQuestionScore')
)
),
];
$form->addGroup($group, null, get_lang('ResultsConfigurationPage'));
$displayMatrix = 'none';
$displayRandom = 'none';
$selectionType = $this->getQuestionSelectionType();
@ -2258,7 +2256,6 @@ class Exercise
get_lang('PropagateNegativeResults')
);
$options = [
'' => get_lang('SelectAnOption'),
1 => get_lang('SaveTheCorrectAnswersForTheNextAttempt'),

@ -6,7 +6,6 @@ use Chamilo\CoreBundle\Framework\Container;
/**
* Responses to AJAX calls for the document upload.
*/
require_once __DIR__.'/../global.inc.php';
$action = $_REQUEST['a'];

@ -6188,6 +6188,7 @@ class DocumentManager
*
* @param string $path
* @param bool $can_see_invisible
*
* @deprecated use CDocumentRepository::getFolderSize
*
* @return int Total size
@ -6718,6 +6719,199 @@ class DocumentManager
return false;
}
/**
* @param array $documentAndFolders
* @param array $courseInfo
* @param bool $is_certificate_mode
* @param array $groupMemberWithUploadRights
* @param string $path
* @param bool $addToEditor
* @param string $editorUrl
*
* @return array
*/
public static function processDocumentAndFolders(
$documentAndFolders,
$courseInfo,
$is_certificate_mode,
$groupMemberWithUploadRights,
$path,
$addToEditor = false,
$editorUrl = ''
) {
if (empty($documentAndFolders) || empty($courseInfo)) {
return [];
}
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
$userId = api_get_user_id();
$currentUserInfo = api_get_user_info();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();
$userIsSubscribed = CourseManager::is_user_subscribed_in_course($userId, $courseInfo['code']);
$url = api_get_path(WEB_COURSE_PATH).$courseInfo['directory'].'/document';
$courseId = $courseInfo['real_id'];
$group_properties = GroupManager::get_group_properties($groupId);
$sortable_data = [];
foreach ($documentAndFolders as $key => $document_data) {
$row = [];
$row['id'] = $document_data['id'];
$row['type'] = $document_data['filetype'];
// If the item is invisible, wrap it in a span with class invisible.
$is_visible = self::is_visible_by_id(
$document_data['id'],
$courseInfo,
$sessionId,
$userId,
false,
$userIsSubscribed
);
$invisibility_span_open = $is_visible == 0 ? '<span class="muted">' : '';
$invisibility_span_close = $is_visible == 0 ? '</span>' : '';
$size = 1;
// Get the title or the basename depending on what we're using
if ($document_data['title'] != '') {
$document_name = $document_data['title'];
} else {
$document_name = basename($document_data['path']);
}
$row['name'] = $document_name;
// Data for checkbox
if (($isAllowedToEdit || $groupMemberWithUploadRights) && count($documentAndFolders) > 1) {
$row[] = $document_data['id'];
}
if (self::is_folder_to_avoid($document_data['path'], $is_certificate_mode)) {
continue;
}
// Show the owner of the file only in groups
$user_link = '';
if (!empty($groupId)) {
if (!empty($document_data['insert_user_id'])) {
$userInfo = api_get_user_info(
$document_data['insert_user_id'],
false,
false,
false,
false,
false
);
$user_link = '<div class="document_owner">'
.get_lang('Owner').': '.UserManager::getUserProfileLink($userInfo)
.'</div>';
}
}
// Hack in order to avoid the download icon appearing on cloud links
if ($document_data['filetype'] == 'link') {
$size = 0;
}
// Icons (clickable)
$row[] = self::create_document_link(
$url,
$document_data,
true,
$is_visible,
$size,
$isAllowedToEdit,
$is_certificate_mode,
$addToEditor,
$editorUrl
);
// Validation when belongs to a session
$session_img = api_get_session_image($document_data['session_id'], $currentUserInfo['status']);
$link = self::create_document_link(
$url,
$document_data,
false,
$is_visible,
$size,
$isAllowedToEdit,
$is_certificate_mode,
$addToEditor,
$editorUrl
);
// Document title with link
$row[] = $link.$session_img.'<br />'.$invisibility_span_open.'<i>'
.nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, 'utf-8'))
.'</i>'.$invisibility_span_close.$user_link;
if ($document_data['filetype'] == 'folder') {
$displaySize = '<span id="document_size_'.$document_data['id']
.'" data-path= "'.$document_data['path']
.'" class="document_size"></span>';
} else {
$displaySize = format_file_size($document_data['size']);
}
$row[] = '<span style="display:none;">'.$size.'</span>'.
$invisibility_span_open.
$displaySize.
$invisibility_span_close;
// Last edit date
$last_edit_date = api_get_local_time($document_data['updated_at']);
$display_date = date_to_str_ago($document_data['updated_at']).
' <div class="muted"><small>'.$last_edit_date."</small></div>";
$row[] = $invisibility_span_open.$display_date.$invisibility_span_close;
$groupMemberWithEditRightsCheckDocument = GroupManager::allowUploadEditDocument(
$userId,
$courseId,
$group_properties,
$document_data
);
// Admins get an edit column
if ($isAllowedToEdit ||
$groupMemberWithEditRightsCheckDocument ||
self::is_my_shared_folder(api_get_user_id(), $path, $sessionId)
) {
$is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false;
// If readonly, check if it the owner of the file or if the user is an admin
if ($document_data['creator_id'] == api_get_user_id() || api_is_platform_admin()) {
$edit_icons = self::build_edit_icons(
$document_data,
$key,
$is_template,
$is_visible
);
} else {
$edit_icons = self::build_edit_icons(
$document_data,
$key,
$is_template,
$is_visible
);
}
$row[] = $edit_icons;
} else {
$row[] = '';
}
$row[] = $last_edit_date;
$row[] = $size;
$row[] = $document_name;
if ((isset($_GET['keyword']) && self::search_keyword($document_name, $_GET['keyword'])) ||
!isset($_GET['keyword']) ||
empty($_GET['keyword'])
) {
$sortable_data[] = $row;
}
}
return $sortable_data;
}
/**
* Parse file information into a link.
*
@ -7141,197 +7335,4 @@ class DocumentManager
return $btn;
}
/**
* @param array $documentAndFolders
* @param array $courseInfo
* @param bool $is_certificate_mode
* @param array $groupMemberWithUploadRights
* @param string $path
* @param bool $addToEditor
* @param string $editorUrl
*
* @return array
*/
public static function processDocumentAndFolders(
$documentAndFolders,
$courseInfo,
$is_certificate_mode,
$groupMemberWithUploadRights,
$path,
$addToEditor = false,
$editorUrl = ''
) {
if (empty($documentAndFolders) || empty($courseInfo)) {
return [];
}
$isAllowedToEdit = api_is_allowed_to_edit(null, true);
$userId = api_get_user_id();
$currentUserInfo = api_get_user_info();
$sessionId = api_get_session_id();
$groupId = api_get_group_id();
$userIsSubscribed = CourseManager::is_user_subscribed_in_course($userId, $courseInfo['code']);
$url = api_get_path(WEB_COURSE_PATH).$courseInfo['directory'].'/document';
$courseId = $courseInfo['real_id'];
$group_properties = GroupManager::get_group_properties($groupId);
$sortable_data = [];
foreach ($documentAndFolders as $key => $document_data) {
$row = [];
$row['id'] = $document_data['id'];
$row['type'] = $document_data['filetype'];
// If the item is invisible, wrap it in a span with class invisible.
$is_visible = self::is_visible_by_id(
$document_data['id'],
$courseInfo,
$sessionId,
$userId,
false,
$userIsSubscribed
);
$invisibility_span_open = $is_visible == 0 ? '<span class="muted">' : '';
$invisibility_span_close = $is_visible == 0 ? '</span>' : '';
$size = 1;
// Get the title or the basename depending on what we're using
if ($document_data['title'] != '') {
$document_name = $document_data['title'];
} else {
$document_name = basename($document_data['path']);
}
$row['name'] = $document_name;
// Data for checkbox
if (($isAllowedToEdit || $groupMemberWithUploadRights) && count($documentAndFolders) > 1) {
$row[] = $document_data['id'];
}
if (self::is_folder_to_avoid($document_data['path'], $is_certificate_mode)) {
continue;
}
// Show the owner of the file only in groups
$user_link = '';
if (!empty($groupId)) {
if (!empty($document_data['insert_user_id'])) {
$userInfo = api_get_user_info(
$document_data['insert_user_id'],
false,
false,
false,
false,
false
);
$user_link = '<div class="document_owner">'
.get_lang('Owner').': '.UserManager::getUserProfileLink($userInfo)
.'</div>';
}
}
// Hack in order to avoid the download icon appearing on cloud links
if ($document_data['filetype'] == 'link') {
$size = 0;
}
// Icons (clickable)
$row[] = self::create_document_link(
$url,
$document_data,
true,
$is_visible,
$size,
$isAllowedToEdit,
$is_certificate_mode,
$addToEditor,
$editorUrl
);
// Validation when belongs to a session
$session_img = api_get_session_image($document_data['session_id'], $currentUserInfo['status']);
$link = self::create_document_link(
$url,
$document_data,
false,
$is_visible,
$size,
$isAllowedToEdit,
$is_certificate_mode,
$addToEditor,
$editorUrl
);
// Document title with link
$row[] = $link.$session_img.'<br />'.$invisibility_span_open.'<i>'
.nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, 'utf-8'))
.'</i>'.$invisibility_span_close.$user_link;
if ($document_data['filetype'] == 'folder') {
$displaySize = '<span id="document_size_'.$document_data['id']
.'" data-path= "'.$document_data['path']
.'" class="document_size"></span>';
} else {
$displaySize = format_file_size($document_data['size']);
}
$row[] = '<span style="display:none;">'.$size.'</span>'.
$invisibility_span_open.
$displaySize.
$invisibility_span_close;
// Last edit date
$last_edit_date = api_get_local_time($document_data['updated_at']);
$display_date = date_to_str_ago($document_data['updated_at']).
' <div class="muted"><small>'.$last_edit_date."</small></div>";
$row[] = $invisibility_span_open.$display_date.$invisibility_span_close;
$groupMemberWithEditRightsCheckDocument = GroupManager::allowUploadEditDocument(
$userId,
$courseId,
$group_properties,
$document_data
);
// Admins get an edit column
if ($isAllowedToEdit ||
$groupMemberWithEditRightsCheckDocument ||
self::is_my_shared_folder(api_get_user_id(), $path, $sessionId)
) {
$is_template = isset($document_data['is_template']) ? $document_data['is_template'] : false;
// If readonly, check if it the owner of the file or if the user is an admin
if ($document_data['creator_id'] == api_get_user_id() || api_is_platform_admin()) {
$edit_icons = self::build_edit_icons(
$document_data,
$key,
$is_template,
$is_visible
);
} else {
$edit_icons = self::build_edit_icons(
$document_data,
$key,
$is_template,
$is_visible
);
}
$row[] = $edit_icons;
} else {
$row[] = '';
}
$row[] = $last_edit_date;
$row[] = $size;
$row[] = $document_name;
if ((isset($_GET['keyword']) && self::search_keyword($document_name, $_GET['keyword'])) ||
!isset($_GET['keyword']) ||
empty($_GET['keyword'])
) {
$sortable_data[] = $row;
}
}
return $sortable_data;
}
}

@ -14,7 +14,6 @@ use ChamiloSession as Session;
* @author Hubert Borderiou 2011-10-21
* @author ivantcholakov2009-07-20
* @author Julio Montoya
*
*/
class ExerciseLib
{

@ -435,9 +435,13 @@ class CourseDriver extends Driver implements DriverInterface
return false;
}
public function mount(array $opts)
{
}
protected function getParents($path)
{
$parents = array();
$parents = [];
while ($path) {
if ($file = $this->stat($path)) {
@ -449,6 +453,7 @@ class CourseDriver extends Driver implements DriverInterface
if (count($parents)) {
array_pop($parents);
}
return $parents;
}
@ -464,13 +469,8 @@ class CourseDriver extends Driver implements DriverInterface
$dir = $this->stat($id);
$path .= $dir['name'].$this->separator;
}
return $path . $file['name'];
}
public function mount(array $opts)
{
return $path.$file['name'];
}
/**

@ -461,7 +461,7 @@ class UserPortalController extends BaseController
}
/** @var \Chamilo\SettingsBundle\Manager\SettingsManager $settingManager */
$settingManager = $this->get('chamilo.settings.manager');
//$settingManager = $this->get('chamilo.settings.manager');
/*var_dump($settingManager->getSetting('platform.institution'));
$settings = $settingManager->loadSettings('platform');
var_dump($settings->get('institution'));
@ -475,7 +475,7 @@ class UserPortalController extends BaseController
$countCourses = \CourseManager::count_courses();
return $this->render(
'ChamiloCoreBundle:Index:userportal.html.twig',
'ChamiloThemeBundle:Index:userportal.html.twig',
[
'content' => $items,
'count_courses' => $countCourses,

@ -8,10 +8,7 @@ use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Resource\AbstractResource;
use Chamilo\CoreBundle\Entity\Resource\ResourceInterface;
use Chamilo\CoreBundle\Entity\Resource\ResourceLink;
use Chamilo\CoreBundle\Entity\Resource\ResourceNode;
use Chamilo\CoreBundle\Entity\Resource\ResourceRight;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Security\Authorization\Voter\ResourceNodeVoter;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Mapping as ORM;
@ -356,7 +353,7 @@ class CDocument extends AbstractResource implements ResourceInterface
}
/**
* Visiblity types ResourceLink::VISIBILITY_DELETED
* Visiblity types ResourceLink::VISIBILITY_DELETED.
*
* @return int
*/
@ -365,7 +362,6 @@ class CDocument extends AbstractResource implements ResourceInterface
return $this->getCourseSessionResourceLink()->getVisibility();
}
public function isVisible()
{
return $this->getVisibility() === ResourceLink::VISIBILITY_PUBLISHED;

@ -116,8 +116,9 @@ class CDocumentRepository extends ResourceRepository
* @param int $courseId
* @param string $path
*
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*
* @return mixed
*/
public function getFolderSize($courseId, $path)
{
@ -152,8 +153,9 @@ class CDocumentRepository extends ResourceRepository
* @param int $groupId
* @param int $sessionId
*
* @return mixed
* @throws \Doctrine\ORM\NonUniqueResultException
*
* @return mixed
*/
public function getTotalSpace($courseId, $groupId = null, $sessionId = null)
{

Loading…
Cancel
Save