Get session requirements for user not logged - refs BT#9889 #TMI

Conflicts:
	main/inc/ajax/sequence.ajax.php
	main/inc/lib/SecuenceResourceManager.php
1.10.x
Angel Fernando Quiroz Campos 10 years ago
parent ecde546555
commit 9129f129c5
  1. 4
      main/auth/courses.php
  2. 22
      main/inc/ajax/sequence.ajax.php
  3. 20
      main/inc/lib/SecuenceResourceManager.php

@ -223,8 +223,8 @@ switch ($action) {
if (count($sequences) > 0) {
$requirementsData = SequenceResourceManager::checkRequirementsForUser(
$sequences,
api_get_user_id(),
SequenceResource::SESSION_TYPE
SequenceResource::SESSION_TYPE,
api_get_user_id()
);
$continueWithSubscription = SequenceResourceManager::checkSequenceAreCompleted($requirementsData);

@ -13,9 +13,6 @@ use Fhaculty\Graph\Vertex;
require_once '../global.inc.php';
api_block_anonymous_users();
api_protect_admin_script();
$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
@ -25,6 +22,9 @@ $em = Database::getManager();
$repository = $em->getRepository('ChamiloCoreBundle:SequenceResource');
switch ($action) {
case 'graph':
api_block_anonymous_users();
api_protect_admin_script();
switch ($type) {
case 'session':
$type = SequenceResource::SESSION_TYPE;
@ -46,6 +46,9 @@ switch ($action) {
}
break;
case 'get_icon':
api_block_anonymous_users();
api_protect_admin_script();
$link = '';
switch ($type) {
case 'session':
@ -94,6 +97,9 @@ switch ($action) {
echo $link;
break;
case 'delete_vertex':
api_block_anonymous_users();
api_protect_admin_script();
$vertexId = isset($_REQUEST['vertex_id']) ? $_REQUEST['vertex_id'] : null;
$type = SequenceResource::SESSION_TYPE;
@ -137,6 +143,9 @@ switch ($action) {
}
break;
case 'load_resource':
api_block_anonymous_users();
api_protect_admin_script();
// children or parent
$loadResourceType = isset($_REQUEST['load_resource_type']) ? $_REQUEST['load_resource_type'] : null;
$sequenceId = isset($_REQUEST['sequence_id']) ? $_REQUEST['sequence_id'] : 0;
@ -192,6 +201,9 @@ switch ($action) {
}
break;
case 'save_resource':
api_block_anonymous_users();
api_protect_admin_script();
$parents = isset($_REQUEST['parents']) ? $_REQUEST['parents'] : '';
$sequenceId = isset($_REQUEST['sequence_id']) ? $_REQUEST['sequence_id'] : 0;
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : '';
@ -299,8 +311,8 @@ switch ($action) {
break;
}
$sequenceList = SequenceResourceManager::checkRequirementsForUser($sequences, $userId, $type);
$allowSubscription = SequenceResourceManager::checkSequenceAreCompleted($sequenceList);
$sequenceList = SecuenceResourceManager::checkRequirementsForUser($sequences, $type, $userId);
$allowSubscription = SecuenceResourceManager::checkSequenceAreCompleted($sequenceList);
$courseController = new CoursesController();

@ -14,12 +14,11 @@ class SequenceResourceManager
/**
* Check if the ser has completed the requirements for the sequences
* @param array $sequences The sequences
* @param int $userId The user ID
* @param int $type The type of sequence resource
*
* @param int $userId Optional. The user ID
* @return array
*/
public static function checkRequirementsForUser(array $sequences, $userId, $type)
public static function checkRequirementsForUser(array $sequences, $type, $userId = 0)
{
$sequenceList = [];
@ -35,11 +34,10 @@ class SequenceResourceManager
/**
* Check if the ser has completed the requirements for the session sequences
* @param array $sequences The sequences
* @param int $userId The user ID
*
* @param int $userId Optional. The user ID
* @return array
*/
private static function checkSessionRequirementsForUser(array $sequences, $userId)
private static function checkSessionRequirementsForUser(array $sequences, $userId = 0)
{
$sequenceList = [];
@ -77,10 +75,12 @@ class SequenceResourceManager
$gradebook
);
$itemSession['status'] = $itemSession['status'] && Category::userFinishedCourse(
$userId,
$category
);
if (!empty($userId)) {
$itemSession['status'] = $itemSession['status'] && Category::userFinishedCourse(
$userId,
$category
);
}
}
}

Loading…
Cancel
Save