diff --git a/app/Migrations/Schema/V111/Version111.php b/app/Migrations/Schema/V111/Version111.php index c1f216f8ad..93a54e860e 100644 --- a/app/Migrations/Schema/V111/Version111.php +++ b/app/Migrations/Schema/V111/Version111.php @@ -272,6 +272,7 @@ class Version111 extends AbstractMigrationChamilo $this->addSql('ALTER TABLE ticket_message_attachments ENGINE=InnoDB'); $this->addSql('ALTER TABLE ticket_message_attachments DROP message_attch_id, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE message_id message_id INT DEFAULT NULL, CHANGE ticket_id ticket_id INT DEFAULT NULL, CHANGE filename filename LONGTEXT NOT NULL, CHANGE size size INT NOT NULL, CHANGE sys_insert_user_id sys_insert_user_id INT NOT NULL, CHANGE sys_insert_datetime sys_insert_datetime DATETIME NOT NULL, CHANGE sys_lastedit_user_id sys_lastedit_user_id INT DEFAULT NULL;'); $this->addSql('ALTER TABLE ticket_message_attachments ADD CONSTRAINT FK_70BF9E26700047D2 FOREIGN KEY (ticket_id) REFERENCES ticket_ticket (id);'); + $this->addSql('ALTER TABLE ticket_message_attachments ADD CONSTRAINT FK_70BF9E26537A1329 FOREIGN KEY (message_id) REFERENCES ticket_message (id);'); $this->addSql('CREATE INDEX IDX_70BF9E26700047D2 ON ticket_message_attachments (ticket_id);'); } else { $this->addSql('CREATE TABLE IF NOT EXISTS ticket_message_attachments (id INT AUTO_INCREMENT NOT NULL, ticket_id INT DEFAULT NULL, message_id INT DEFAULT NULL, path VARCHAR(255) NOT NULL, filename LONGTEXT NOT NULL, size INT NOT NULL, sys_insert_user_id INT NOT NULL, sys_insert_datetime DATETIME NOT NULL, sys_lastedit_user_id INT DEFAULT NULL, sys_lastedit_datetime DATETIME DEFAULT NULL, INDEX IDX_70BF9E26700047D2 (ticket_id), INDEX IDX_70BF9E26537A1329 (message_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); @@ -318,7 +319,6 @@ class Version111 extends AbstractMigrationChamilo $this->addSql('CREATE INDEX IDX_54B65868A76ED395 ON ticket_assigned_log (user_id);'); - $this->addSql('ALTER TABLE ticket_message DROP message_id, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE ticket_id ticket_id INT DEFAULT NULL, CHANGE subject subject VARCHAR(255) DEFAULT NULL, CHANGE message message LONGTEXT DEFAULT NULL, CHANGE status status VARCHAR(255) NOT NULL, CHANGE ip_address ip_address VARCHAR(255) NOT NULL, CHANGE sys_insert_user_id sys_insert_user_id INT NOT NULL, CHANGE sys_insert_datetime sys_insert_datetime DATETIME NOT NULL, CHANGE sys_lastedit_user_id sys_lastedit_user_id INT DEFAULT NULL;'); $this->addSql('ALTER TABLE ticket_message ADD CONSTRAINT FK_BA71692D700047D2 FOREIGN KEY (ticket_id) REFERENCES ticket_ticket (id);'); @@ -326,9 +326,6 @@ class Version111 extends AbstractMigrationChamilo $this->addSql('ALTER TABLE ticket_ticket CHANGE category_id category_id INT DEFAULT NULL;'); $this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C76812469DE2 FOREIGN KEY (category_id) REFERENCES ticket_category (id);'); $this->addSql('CREATE INDEX IDX_EDE2C76812469DE2 ON ticket_ticket (category_id);'); - if ($fixTableMessage) { - $this->addSql('ALTER TABLE ticket_message_attachments ADD CONSTRAINT FK_70BF9E26537A1329 FOREIGN KEY (message_id) REFERENCES ticket_message (id);'); - } $this->addSql('DELETE FROM settings_current WHERE title = "Ticket"'); } else { // Plugin was never installed. Create ticket tables @@ -403,7 +400,8 @@ class Version111 extends AbstractMigrationChamilo $this->addSql("ALTER TABLE session MODIFY COLUMN name VARCHAR(150) NOT NULL DEFAULT ''"); if (!$schema->hasTable('version')) { - $this->addSql('CREATE TABLE version (id int unsigned NOT NULL AUTO_INCREMENT, version varchar(255), PRIMARY KEY(id), UNIQUE(version));'); + $sql = getVersionTable(); + $this->addSql($sql); } if ($schema->hasTable('resource')) { diff --git a/app/Resources/public/css/base.css b/app/Resources/public/css/base.css index 2c7c895294..bb59955fc7 100644 --- a/app/Resources/public/css/base.css +++ b/app/Resources/public/css/base.css @@ -308,8 +308,16 @@ header{ text-align:center; vertical-align:middle; } +.radio input[type="radio"]{ + margin-left: -25px; +} input[type=checkbox], input[type=radio]{ - margin: 8px 0 0; + margin: 6px 0 0; +} +.prerequisites input[type=radio]{ + margin: 0 0 0 -25px; + vertical-align: middle; + height: 20px; } #gradebook_list .centered .badge-group { width: auto; diff --git a/composer.json b/composer.json index e82f9f3dec..8fc177a67f 100755 --- a/composer.json +++ b/composer.json @@ -43,7 +43,7 @@ } ], "require": { - "php": ">=5.4", + "php": ">=5.5", "ext-intl": "*", "ext-gd": "*", "ext-curl": "*", @@ -90,7 +90,6 @@ "ircmaxell/password-compat": "~1.0.4", "sylius/attribute": "0.13.0", "sylius/translation": "0.13.0", - "ramsey/array_column": "~1.1", "patchwork/utf8": "~1.2", "ddeboer/data-import": "@stable", "phpoffice/phpexcel": "~1.8", @@ -106,12 +105,13 @@ "knplabs/doctrine-behaviors": "~1.1", "jimmiw/php-time-ago": "^0.4.14", "phpoffice/phpword": "^0.12.1|dev-master", - "facebook/php-sdk-v4" : "~5.0", - "kigkonsult/icalcreator" : "0.1.0", + "facebook/php-sdk-v4": "~5.0", + "kigkonsult/icalcreator": "0.1.0", "essence/essence": "2.6.1", "pclzip/pclzip": "2.8.2", "chamilo/chash": "dev-master", - "ircmaxell/random-lib": "^1.2" + "ircmaxell/random-lib": "^1.2", + "ocramius/proxy-manager": "~1.0|2.0.*" }, "require-dev": { "behat/behat": "@stable", @@ -151,6 +151,6 @@ } }, "config": { - "component-dir": "web/assets" + "component-dir": "web/assets" } } diff --git a/main/course_description/index.php b/main/course_description/index.php index a938003be6..eafd2f1e2c 100755 --- a/main/course_description/index.php +++ b/main/course_description/index.php @@ -24,12 +24,12 @@ api_protect_course_script(true); $actions = array('listing', 'add', 'edit', 'delete', 'history'); $action = 'listing'; if (isset($_GET['action']) && in_array($_GET['action'], $actions)) { - $action = $_GET['action']; + $action = $_GET['action']; } $description_type = ''; if (isset($_GET['description_type'])) { - $description_type = intval($_GET['description_type']); + $description_type = intval($_GET['description_type']); } $id = null; diff --git a/main/course_description/layout.php b/main/course_description/layout.php index 44c484a293..3a40124c1b 100755 --- a/main/course_description/layout.php +++ b/main/course_description/layout.php @@ -11,7 +11,7 @@ api_protect_course_script(true); // Header -Display :: display_header(''); +Display::display_header(''); // Introduction section Display::display_introduction_section(TOOL_COURSE_DESCRIPTION); @@ -23,4 +23,4 @@ Event::event_access_tool(TOOL_COURSE_DESCRIPTION); echo $content; // Footer -Display :: display_footer(); +Display::display_footer(); diff --git a/main/course_description/listing.php b/main/course_description/listing.php index 07179cf60e..62146aeb79 100755 --- a/main/course_description/listing.php +++ b/main/course_description/listing.php @@ -18,27 +18,27 @@ if (api_is_allowed_to_edit(null, true)) { } $categories[ADD_BLOCK] = get_lang('NewBloc'); - $i = 1; - echo '
'.get_lang('ThematicAdvanceHistory').' |
@@ -49,7 +49,7 @@ if ($history) {
$user_info = api_get_user_info();
if (isset($descriptions) && count($descriptions) > 0) {
- foreach ($descriptions as $id => $description) {
+ foreach ($descriptions as $id => $description) {
if (!empty($description)) {
$actions = '';
if (api_is_allowed_to_edit(null, true) && !$history) {
diff --git a/main/document/document_quota.php b/main/document/document_quota.php
index 8087ab1645..39267aa45f 100755
--- a/main/document/document_quota.php
+++ b/main/document/document_quota.php
@@ -1,5 +1,6 @@
['status', 'studentfollowup']);
$result = api_get_settings_params_simple($params);
+ $plugin = StudentFollowUpPlugin::create();
if (!empty($result) && $result['selected_value'] === 'installed') {
$navigation['follow_up']['url'] = api_get_path(WEB_PLUGIN_PATH).'studentfollowup/posts.php';
- $navigation['follow_up']['title'] = get_lang('MyDossier');
+ $navigation['follow_up']['title'] = $plugin->get_lang('CareDetailView');
$navigation['follow_up']['key'] = 'homepage';
$navigation['follow_up']['icon'] = 'homepage.png';
}
@@ -363,8 +364,7 @@ function return_navigation_array()
// Reports
if (!empty($possible_tabs['reports'])) {
if (api_get_setting('show_tabs', 'reports') == 'true') {
- if (
- (api_is_platform_admin() || api_is_drh() || api_is_session_admin())
+ if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin())
&& Rights::hasRight('show_tabs:reports')
) {
$navigation['reports'] = $possible_tabs['reports'];
diff --git a/main/inc/lib/course_home.lib.php b/main/inc/lib/course_home.lib.php
index 8f986a4431..a4f06363f3 100755
--- a/main/inc/lib/course_home.lib.php
+++ b/main/inc/lib/course_home.lib.php
@@ -2,6 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CourseBundle\Entity\CTool;
+use Chamilo\CourseBundle\Entity\CLpCategory;
/**
* Class CourseHome
@@ -461,6 +462,8 @@ class CourseHome
// Condition for the session
$session_id = $sessionId ?: api_get_session_id();
$course_id = $courseId ?: api_get_course_int_id();
+ $userId = api_get_user_id();
+ $user = api_get_user_entity($userId);
$condition_session = api_get_session_condition(
$session_id,
true,
@@ -572,12 +575,12 @@ class CourseHome
$lp = new learnpath(
api_get_course_id(),
$lp_id,
- api_get_user_id()
+ $userId
);
$path = $lp->get_preview_image_path(ICON_SIZE_BIG);
$add = learnpath::is_lp_visible_for_student(
$lp_id,
- api_get_user_id(),
+ $userId,
api_get_course_id(),
api_get_session_id()
);
@@ -586,6 +589,16 @@ class CourseHome
}
}
+ if ($temp_row['image'] === 'lp_category.gif') {
+ $lpCategory = self::getPublishedLpCategoryFromLink(
+ $temp_row['link']
+ );
+ $add = learnpath::categoryIsVisibleForStudent(
+ $lpCategory,
+ $user
+ );
+ }
+
if ($add) {
$all_tools_list[] = $temp_row;
}
@@ -675,7 +688,7 @@ class CourseHome
WHERE blog_id =".$blog_id;
} else {
$sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
- WHERE blog_id =".$blog_id." AND user_id = ".api_get_user_id();
+ WHERE blog_id =".$blog_id." AND user_id = ".$userId;
}
$result_blogs = Database::query($sql_blogs);
@@ -1173,6 +1186,25 @@ class CourseHome
return $lp_id;
}
+ /**
+ * Get published learning path category from link inside course home
+ * @param string $link
+ * @return CLpCategory
+ */
+ public static function getPublishedLpCategoryFromLink($link)
+ {
+ $query = parse_url($link, PHP_URL_QUERY);
+ parse_str($query, $params);
+
+ $id = isset($params['id']) ? (int) $params['id'] : 0;
+
+ $em = Database::getManager();
+ /** @var CLpCategory $category */
+ $category = $em->find('ChamiloCourseBundle:CLpCategory', $id);
+
+ return $category;
+ }
+
/**
* @param bool $include_admin_tools
* @return array
diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php
index aea15044f0..f2c5ebca88 100755
--- a/main/inc/lib/template.lib.php
+++ b/main/inc/lib/template.lib.php
@@ -427,6 +427,7 @@ class Template
$show_course_navigation_menu = null;
if (!empty($this->course_id) && $this->user_is_logged_in) {
+
if (api_get_setting('show_toolshortcuts') != 'false') {
//Course toolbar
$show_course_shortcut = CourseHome::show_navigation_tool_shortcuts();
diff --git a/main/install/install.lib.php b/main/install/install.lib.php
index 3cbe625deb..d0b2815e67 100755
--- a/main/install/install.lib.php
+++ b/main/install/install.lib.php
@@ -2918,8 +2918,7 @@ function finishInstallation(
$files = $finder->files()->in($path);
// Needed for chash
- $sql = 'CREATE TABLE IF NOT EXISTS version (id int unsigned NOT NULL AUTO_INCREMENT, version varchar(255), PRIMARY KEY(id), UNIQUE(version));';
- Database::query($sql);
+ createVersionTable();
foreach ($files as $version) {
$version = str_replace(['Version', '.php'], '', $version->getFilename());
@@ -2928,6 +2927,24 @@ function finishInstallation(
}
}
+/**
+ * Creates 'version' table
+ */
+function createVersionTable()
+{
+ $sql = getVersionTable();
+ Database::query($sql);
+}
+
+/**
+ * Get version creation table query
+ * @return string
+ */
+function getVersionTable()
+{
+ return 'CREATE TABLE IF NOT EXISTS version (id int unsigned NOT NULL AUTO_INCREMENT, version varchar(20), PRIMARY KEY(id), UNIQUE(version));';
+}
+
/**
* Update settings based on installation profile defined in a JSON file
* @param string $installationProfile The name of the JSON file in main/install/profiles/ folder
diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php
index 32aeb01b08..b1e71271ef 100755
--- a/main/lp/learnpath.class.php
+++ b/main/lp/learnpath.class.php
@@ -9,6 +9,8 @@ use Gedmo\Sortable\Entity\Repository\SortableRepository;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder;
use Chamilo\CourseBundle\Entity\CLp;
+use Chamilo\CourseBundle\Entity\CTool;
+use Chamilo\UserBundle\Entity\User;
/**
* Class learnpath
@@ -4145,6 +4147,8 @@ class learnpath
foreach ($learPaths as $lp) {
learnpath::toggle_visibility($lp['iid'], 0);
}
+
+ learnpath::toggleCategoryPublish($id, 0);
}
return api_item_property_update(
@@ -4247,6 +4251,178 @@ class learnpath
}
}
+ /**
+ * Generate the link for a learnpath category as course tool
+ * @param int $categoryId
+ * @return string
+ */
+ private static function getCategoryLinkForTool($categoryId)
+ {
+ $link = 'lp/lp_controller.php?'.api_get_cidreq().'&'
+ .http_build_query(
+ [
+ 'action' => 'view_category',
+ 'id' => $categoryId
+ ]
+ );
+
+ return $link;
+ }
+
+ /**
+ * Publishes a learnpath.
+ * Show or hide the learnpath category on the course homepage
+ * @param int $id
+ * @param int $setVisibility
+ * @return bool
+ */
+ public static function toggleCategoryPublish($id, $setVisibility = 1)
+ {
+ $courseId = api_get_course_int_id();
+ $sessionId = api_get_session_id();
+ $sessionCondition = api_get_session_condition($sessionId, true, false, 't.sessionId');
+
+ $em = Database::getManager();
+
+ /** @var CLpCategory $category */
+ $category = $em->find('ChamiloCourseBundle:CLpCategory', $id);
+
+ if (!$category) {
+ return false;
+ }
+
+ $link = self::getCategoryLinkForTool($id);
+
+ /** @var CTool $tool */
+ $tool = $em
+ ->createQuery("
+ SELECT t FROM ChamiloCourseBundle:CTool t
+ WHERE
+ t.cId = :course AND
+ t.link = :link1 AND
+ t.image = 'lp_category.gif' AND
+ t.link LIKE :link2
+ $sessionCondition
+ ")
+ ->setParameters([
+ 'course' => (int) $courseId,
+ 'link1' => $link,
+ 'link2' => "$link%"
+ ])
+ ->getOneOrNullResult();
+
+ if ($setVisibility == 0 && $tool) {
+ $em->remove($tool);
+ $em->flush();
+
+ return true;
+ }
+
+ if ($setVisibility == 1 && !$tool) {
+ $tool = new CTool();
+ $tool
+ ->setCategory('authoring')
+ ->setCId($courseId)
+ ->setName(strip_tags($category->getName()))
+ ->setLink($link)
+ ->setImage('lp_category.gif')
+ ->setVisibility(1)
+ ->setAdmin(0)
+ ->setAddress('pastillegris.gif')
+ ->setAddedTool(0)
+ ->setSessionId($sessionId)
+ ->setTarget('_self');
+
+ $em->persist($tool);
+ $em->flush();
+
+ $tool->setId($tool->getIid());
+
+ $em->persist($tool);
+ $em->flush();
+
+ return true;
+ }
+
+ if ($setVisibility == 1 && $tool) {
+ $tool
+ ->setName(strip_tags($category->getName()))
+ ->setVisibility(1);
+
+ $em->persist($tool);
+ $em->flush();
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Check if the learnpath category is visible for a user
+ * @param CLpCategory $category
+ * @param User $user
+ * @return bool
+ */
+ public static function categoryIsVisibleForStudent(
+ CLpCategory $category,
+ User $user
+ )
+ {
+ $isAllowedToEdit = api_is_allowed_to_edit(null, true);
+
+ if ($isAllowedToEdit) {
+ return true;
+ }
+
+ $users = $category->getUsers();
+
+ if (empty($users) || !$users->count()) {
+ return true;
+ }
+
+ if ($category->hasUserAdded($user)) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Check if a learnpath category is published as course tool
+ * @param CLpCategory $category
+ * @param int $courseId
+ * @return bool
+ */
+ public static function categoryIsPusblished(
+ CLpCategory $category,
+ $courseId
+ )
+ {
+ $link = self::getCategoryLinkForTool($category->getId());
+ $em = Database::getManager();
+
+ $tools = $em
+ ->createQuery("
+ SELECT t FROM ChamiloCourseBundle:CTool t
+ WHERE t.cId = :course AND
+ t.name = :name AND
+ t.image = 'lp_category.gif' AND
+ t.link LIKE :link
+ ")
+ ->setParameters([
+ 'course' => $courseId,
+ 'name' => strip_tags($category->getName()),
+ 'link' => "$link%"
+ ])
+ ->getResult();
+
+ /** @var CTool $tool */
+ $tool = current($tools);
+
+ return $tool ? $tool->getVisibility() : false;
+ }
+
/**
* Restart the whole learnpath. Return the URL of the first element.
* Make sure the results are saved with anoter method. This method should probably be
diff --git a/main/lp/lp_add_category.php b/main/lp/lp_add_category.php
index ab72405203..d683a7ada9 100644
--- a/main/lp/lp_add_category.php
+++ b/main/lp/lp_add_category.php
@@ -31,8 +31,17 @@ $form = new FormValidator(
$form->addElement('header', null, get_lang('AddLPCategory'));
// Title
-$form->addElement('text', 'name', api_ucfirst(get_lang('Name')));
-$form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
+if (api_get_configuration_value('save_titles_as_html')) {
+ $form->addHtmlEditor(
+ 'name',
+ get_lang('Name'),
+ true,
+ false,
+ ['ToolbarSet' => 'Minimal']
+ );
+} else {
+ $form->addText('name', get_lang('Name'), true);
+}
$form->addElement('hidden', 'action', 'add_lp_category');
$form->addElement('hidden', 'c_id', api_get_course_int_id());
diff --git a/main/lp/lp_controller.php b/main/lp/lp_controller.php
index b99f5f7b53..8cd585b93c 100755
--- a/main/lp/lp_controller.php
+++ b/main/lp/lp_controller.php
@@ -334,9 +334,11 @@ if (isset($_SESSION['oLP'])) {
}
if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
- if (isset($_REQUEST['action']) && !in_array($_REQUEST['action'], ['list', 'view'])) {
+ if (isset($_REQUEST['action']) && !in_array($_REQUEST['action'], ['list', 'view', 'view_category'])) {
if (!empty($_REQUEST['lp_id'])) {
$_REQUEST['action'] = 'view';
+ } elseif($_REQUEST['action'] == 'view_category') {
+ $_REQUEST['action'] = 'view_category';
} else {
$_REQUEST['action'] = 'list';
}
@@ -873,6 +875,14 @@ switch ($action) {
require 'lp_list.php';
}
break;
+ case 'toggle_category_publish':
+ if (!$is_allowed_to_edit) {
+ api_not_allowed(true);
+ }
+
+ learnpath::toggleCategoryPublish($_REQUEST['id'], $_REQUEST['new_status']);
+ require 'lp_list.php';
+ break;
case 'toggle_publish':
// Change lp published status (visibility on homepage).
if (!$is_allowed_to_edit) {
diff --git a/main/lp/lp_edit_item_prereq.php b/main/lp/lp_edit_item_prereq.php
index 9c8ebd3f45..84475b65c8 100755
--- a/main/lp/lp_edit_item_prereq.php
+++ b/main/lp/lp_edit_item_prereq.php
@@ -91,6 +91,7 @@ echo '