Minor - format code, update php docs, rename function name

pull/2487/head
jmontoyaa 7 years ago
parent c1c35419a0
commit 762a613257
  1. 271
      main/admin/ldap_import_students_to_session.php
  2. 5
      main/inc/global.inc.php
  3. 25
      main/inc/lib/MoodleImport.php
  4. 105
      main/inc/lib/agenda.lib.php
  5. 39
      main/inc/lib/message.lib.php
  6. 189
      main/inc/lib/myspace.lib.php
  7. 108
      main/inc/lib/usergroup.lib.php
  8. 149
      main/lp/aicc.class.php
  9. 12
      main/lp/aicc_hacp.php
  10. 23
      main/lp/learnpathItem.class.php
  11. 2
      main/lp/lp_add.php
  12. 157
      main/lp/scorm.class.php
  13. 4
      main/social/group_members.php
  14. 4
      main/social/group_waiting_list.php

@ -5,9 +5,7 @@
* @package chamilo.admin
* Copyright (c) 2007 Mustapha Alouani (supervised by Michel Moreau-Belliard)
*/
/**
* Code
*/
// resetting the course id
$cidReset = true;
require_once('../inc/global.inc.php');
@ -51,166 +49,131 @@ $id_session = $_POST['id_session'];
// form1 annee = 0; composante= 0 etape = 0
//if ($annee == "" && $composante == "" && $etape == "") {
if (empty($annee) && empty($id_session))
{
Display::display_header($tool_name);
echo '<div style="align:center">';
echo Display::return_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')).' '.get_lang('LDAPSelectFilterOnUsersOU');
echo '<form method="get" action="'.api_get_self().'"><br />';
echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> ';
echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"> ';
echo '<input type="submit" value="'.get_lang('Submit').'">';
echo '</form>';
echo '</div>';
}
elseif (!empty($annee) && empty($id_session))
{
Display::display_header($tool_name);
echo '<div style="align:center">';
echo Display::return_icon(
'course.png',
get_lang('SelectSessionToImportUsersTo')).' '.get_lang('SelectSessionToImportUsersTo').'<br />';
echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
echo '<select name="id_session">';
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$sql = "SELECT id,name,nbr_courses,access_start_date,access_end_date ".
" FROM $tbl_session ".
" ORDER BY name";
$result = Database::query($sql);
if (empty($annee) && empty($id_session)) {
Display::display_header($tool_name);
echo '<div style="align:center">';
echo Display::return_icon('group.gif', get_lang('LDAPSelectFilterOnUsersOU')).' '.get_lang('LDAPSelectFilterOnUsersOU');
echo '<form method="get" action="'.api_get_self().'"><br />';
echo '<em>'.get_lang('LDAPOUAttributeFilter').' :</em> ';
echo '<input type="text" name="annee" size="4" maxlength="30" value="'.$annee_base.'"> ';
echo '<input type="submit" value="'.get_lang('Submit').'">';
echo '</form>';
echo '</div>';
$sessions = Database::store_result($result);
$nbr_results = count($sessions);
foreach ($sessions as $row) {
echo '<option value="'.$row['id'].'">'.api_htmlentities($row['name']).' ('.$row['access_start_date'].' - '.$row['access_end_date'].')</option>';
}
echo '</select>';
echo '<input type="submit" value="'.get_lang('Submit').'">';
echo '</form>';
echo '</div>';
} elseif (!empty($annee) && empty($id_session)) {
Display::display_header($tool_name);
echo '<div style="align:center">';
echo Display::return_icon(
'course.png',
get_lang('SelectSessionToImportUsersTo')
).' '.get_lang('SelectSessionToImportUsersTo').'<br />';
echo '<form method="post" action="'.api_get_self().'?annee='.Security::remove_XSS($annee).'"><br />';
echo '<select name="id_session">';
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$sql = "SELECT id,name,nbr_courses,access_start_date,access_end_date ".
" FROM $tbl_session ".
" ORDER BY name";
$result = Database::query($sql);
$sessions = Database::store_result($result);
$nbr_results = count($sessions);
foreach ($sessions as $row) {
echo '<option value="'.$row['id'].'">'.api_htmlentities($row['name']).' ('.$row['access_start_date'].' - '.$row['access_end_date'].')</option>';
}
echo '</select>';
echo '<input type="submit" value="'.get_lang('Submit').'">';
echo '</form>';
echo '</div>';
}
// form4 annee != 0; composante != 0 etape != 0
//elseif ($annee <> "" && $composante <> "" && $etape <> "" && $listeok != 'yes') {
elseif (!empty($annee) && !empty($id_session) && empty($_POST['confirmed']))
{
Display::display_header($tool_name);
echo '<div style="align: center;">';
echo '<br />';
echo '<br />';
echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>';
//echo "Connection ...";
$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
ldap_set_version($ds);
if ($ds) {
$r = false;
$res = ldap_handle_bind($ds, $r);
//$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))");
//echo "(ou=*$annee,ou=$composante)";
$sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)");
$info = ldap_get_entries($ds, $sr);
for ($key = 0; $key < $info["count"]; $key++) {
$nom_form[] = $info[$key]["sn"][0];
$prenom_form[] = $info[$key]["givenname"][0];
$email_form[] = $info[$key]["mail"][0];
// Get uid from dn
//$dn_array=ldap_explode_dn($info[$key]["dn"],1);
//$username_form[] = $dn_array[0]; // uid is first key
$username_form[] = $info[$key]['uid'][0];
$outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student"
//$val = ldap_get_values_len($ds, $entry, "userPassword");
//$password_form[] = $val[0];
$password_form[] = $info[$key]['userPassword'][0];
}
ldap_unbind($ds);
/*-----------------------------------------------*/
asort($nom_form);
reset($nom_form);
$statut = 5;
include ('ldap_form_add_users_group.php');
} else {
echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
}
echo '<br /><br />';
elseif (!empty($annee) && !empty($id_session) && empty($_POST['confirmed'])) {
Display::display_header($tool_name);
echo '<div style="align: center;">';
echo '<br />';
echo '<br />';
echo '<h3>'.Display::return_icon('group.gif', get_lang('SelectStudents')).' '.get_lang('SelectStudents').'</h3>';
//echo "Connection ...";
$ds = ldap_connect($ldap_host, $ldap_port) or die(get_lang('LDAPConnectionError'));
ldap_set_version($ds);
if ($ds) {
$r = false;
$res = ldap_handle_bind($ds, $r);
//$sr = @ ldap_search($ds, "ou=people,$LDAPbasedn", "(|(edupersonprimaryorgunitdn=ou=$etape,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn)(edupersonprimaryorgunitdn=ou=02PEL,ou=$annee,ou=diploma,o=Paris1,$LDAPbasedn))");
//echo "(ou=*$annee,ou=$composante)";
$sr = @ ldap_search($ds, $ldap_basedn, "(ou=*$annee)");
$info = ldap_get_entries($ds, $sr);
for ($key = 0; $key < $info["count"]; $key++) {
$nom_form[] = $info[$key]["sn"][0];
$prenom_form[] = $info[$key]["givenname"][0];
$email_form[] = $info[$key]["mail"][0];
// Get uid from dn
//$dn_array=ldap_explode_dn($info[$key]["dn"],1);
//$username_form[] = $dn_array[0]; // uid is first key
$username_form[] = $info[$key]['uid'][0];
$outab[] = $info[$key]["eduPersonPrimaryAffiliation"][0]; // Ici "student"
//$val = ldap_get_values_len($ds, $entry, "userPassword");
//$password_form[] = $val[0];
$password_form[] = $info[$key]['userPassword'][0];
}
ldap_unbind($ds);
asort($nom_form);
reset($nom_form);
$statut = 5;
include('ldap_form_add_users_group.php');
} else {
echo '<h4>'.get_lang('UnableToConnectTo').' '.$host.'</h4>';
}
echo '<br /><br />';
echo '<a href="ldap_import_students.php?annee=">'.get_lang('BackToNewSearch').'</a>';
echo '<br /><br />';
echo '</div>';
}
elseif (!empty($annee) && !empty($id_session) && ($_POST['confirmed'] == 'yes'))
{
$id = $_POST['username_form'];
$UserList = array();
$userid_match_login = array();
foreach ($id as $form_index=>$user_id)
{
if (is_array($_POST['checkboxes']) && in_array($form_index, array_values($_POST['checkboxes'])))
{
$tmp = ldap_add_user($user_id);
$UserList[] = $tmp;
$userid_match_login[$tmp] = $user_id;
}
}
if (!empty($_POST['id_session'])) {
$num = 0;
$tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
foreach ($UserList as $user_id) {
$res_user = Database::insert(
$tbl_session_user,
[
'session_id' => intval($id_session),
'user_id' => intval($user_id),
'registered_at' => api_get_utc_datetime()
]
);
if ($res_user !== false) {
$num++;
}
}
if ($num > 0) {
$sql = 'UPDATE '.$tbl_session.' SET nbr_users = (nbr_users + '.$num.') WHERE id = '.intval($id_session);
$res = Database::query($sql);
}
header('Location: resume_session.php?id_session='.Security::remove_XSS($_POST['id_session']));
}
/*
else
{
Display :: display_header($tool_name);
if(count($userid_match_login)>0)
{
$message=get_lang('LDAPUsersAddedOrUpdated').':<br />';
foreach($userid_match_login as $user_id => $login)
{
$message .= '- '.$login.'<br />';
}
}
else
{
$message=get_lang('NoUserAdded');
}
Display::addFlash(Display::return_message($message, 'normal', false));
}
*/
else
{
$message = get_lang('NoUserAdded');
Display::addFlash(Display::return_message($message, 'normal', false));
} elseif (!empty($annee) && !empty($id_session) && ($_POST['confirmed'] == 'yes')) {
$id = $_POST['username_form'];
$UserList = array();
$userid_match_login = array();
foreach ($id as $form_index => $user_id) {
if (is_array($_POST['checkboxes']) && in_array($form_index, array_values($_POST['checkboxes']))) {
$tmp = ldap_add_user($user_id);
$UserList[] = $tmp;
$userid_match_login[$tmp] = $user_id;
}
}
if (!empty($_POST['id_session'])) {
$num = 0;
$tbl_session_user = Database::get_main_table(TABLE_MAIN_SESSION_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
foreach ($UserList as $user_id) {
$res_user = Database::insert(
$tbl_session_user,
[
'session_id' => intval($id_session),
'user_id' => intval($user_id),
'registered_at' => api_get_utc_datetime(),
]
);
if ($res_user !== false) {
$num++;
}
}
if ($num > 0) {
$sql = 'UPDATE '.$tbl_session.' SET nbr_users = (nbr_users + '.$num.') WHERE id = '.intval($id_session);
$res = Database::query($sql);
}
header('Location: resume_session.php?id_session='.Security::remove_XSS($_POST['id_session']));
exit;
} else {
$message = get_lang('NoUserAdded');
Display::addFlash(Display::return_message($message, 'normal', false));
Display::display_header($tool_name);
}
echo '<br /><br />';
}
echo '<br /><br />';
echo '<a href="ldap_import_students.php?annee=&composante=&etape=">'.get_lang('BackToNewSearch').'</a>';
echo '<br /><br />';
}
Display::display_footer();
?>

@ -11,7 +11,7 @@
*
* @package chamilo.include
* @todo remove the code that displays the button that links to the install page
* but use a redirect immediately. By doing so the $alreadyInstalled variable can be removed.
* but use a redirect immediately. By doing so the $alreadyInstalled variable can be removed.
*
*/
@ -569,7 +569,7 @@ if (!$x = strpos($_SERVER['PHP_SELF'], 'whoisonline.php')) {
// ===== end "who is logged in?" module section =====
//Update of the logout_date field in the table track_e_login
// Update of the logout_date field in the table track_e_login
// (needed for the calculation of the total connection time)
if (!isset($_SESSION['login_as']) && isset($_user)) {
// if $_SESSION['login_as'] is set, then the user is an admin logged as the user
@ -632,4 +632,3 @@ if (empty($default_quota)) {
define('DEFAULT_DOCUMENT_QUOTA', $default_quota);
// Forcing PclZip library to use a custom temporary folder.
define('PCLZIP_TEMPORARY_DIR', api_get_path(SYS_ARCHIVE_PATH));

@ -202,15 +202,22 @@ class MoodleImport
// Ok, we got the Quiz and create it, now its time to add the Questions
foreach ($moduleValues['question_instances'] as $index => $question) {
$questionsValues = $this->readMainQuestionsXml($questionsXml, $question['questionid']);
$questionsValues = $this->readMainQuestionsXml(
$questionsXml,
$question['questionid']
);
$moduleValues['question_instances'][$index] = $questionsValues;
// Set Question Type from Moodle XML element <qtype>
$qType = $moduleValues['question_instances'][$index]['qtype'];
// Add the matched chamilo question type to the array
$moduleValues['question_instances'][$index]['chamilo_qtype'] = $this->matchMoodleChamiloQuestionTypes($qType);
$questionInstance = Question::getInstance($moduleValues['question_instances'][$index]['chamilo_qtype']);
$questionInstance = Question::getInstance(
$moduleValues['question_instances'][$index]['chamilo_qtype']
);
if ($questionInstance) {
$questionInstance->updateTitle($moduleValues['question_instances'][$index]['name']);
$questionInstance->updateTitle(
$moduleValues['question_instances'][$index]['name']
);
$questionText = $moduleValues['question_instances'][$index]['questiontext'];
// Replace the path from @@PLUGINFILE@@ to a correct chamilo path
@ -466,7 +473,9 @@ class MoodleImport
if (!$isThisItemThatIWant && $item->nodeName == 'contenthash') {
$currentItem['contenthash'] = $item->nodeValue;
}
if ($item->nodeName == 'contextid' && intval($item->nodeValue) == intval($contextId) && !$isThisItemThatIWant) {
if ($item->nodeName == 'contextid' &&
intval($item->nodeValue) == intval($contextId) && !$isThisItemThatIWant
) {
$isThisItemThatIWant = true;
continue;
}
@ -479,11 +488,15 @@ class MoodleImport
$currentItem['filesize'] = $item->nodeValue;
}
if ($isThisItemThatIWant && $item->nodeName == 'mimetype' && $item->nodeValue == 'document/unknown') {
if ($isThisItemThatIWant && $item->nodeName == 'mimetype' &&
$item->nodeValue == 'document/unknown'
) {
break;
}
if ($isThisItemThatIWant && $item->nodeName == 'mimetype' && $item->nodeValue !== 'document/unknown') {
if ($isThisItemThatIWant && $item->nodeName == 'mimetype' &&
$item->nodeValue !== 'document/unknown'
) {
$currentItem['mimetype'] = $item->nodeValue;
break 2;
}

@ -8,7 +8,7 @@
*/
class Agenda
{
public $events = array();
public $events = [];
/** @var string Current type */
public $type = 'personal';
public $types = array('personal', 'admin', 'course');
@ -224,11 +224,11 @@ class Agenda
$allDay,
$title,
$content,
$usersToSend = array(),
$usersToSend = [],
$addAsAnnouncement = false,
$parentEventId = null,
$attachmentArray = array(),
$attachmentCommentList = array(),
$attachmentArray = [],
$attachmentCommentList = [],
$eventComment = null,
$color = ''
) {
@ -450,7 +450,7 @@ class Agenda
$sql = "SELECT * FROM $repeatTable
WHERE c_id = $courseId AND cal_id = $eventId";
$res = Database::query($sql);
$repeatInfo = array();
$repeatInfo = [];
if (Database::num_rows($res) > 0) {
$repeatInfo = Database::fetch_array($res, 'ASSOC');
}
@ -466,7 +466,7 @@ class Agenda
*
* @return bool
*/
public function addRepeatedItem($eventId, $type, $end, $sentTo = array())
public function addRepeatedItem($eventId, $type, $end, $sentTo = [])
{
$t_agenda = Database::get_course_table(TABLE_AGENDA);
$t_agenda_r = Database::get_course_table(TABLE_AGENDA_REPEAT);
@ -628,7 +628,7 @@ class Agenda
* @param array $sentTo
* @return int
*/
public function storeAgendaEventAsAnnouncement($item_id, $sentTo = array())
public function storeAgendaEventAsAnnouncement($item_id, $sentTo = [])
{
$table_agenda = Database::get_course_table(TABLE_AGENDA);
$course_id = api_get_course_int_id();
@ -700,9 +700,9 @@ class Agenda
$allDay,
$title,
$content,
$usersToSend = array(),
$attachmentArray = array(),
$attachmentCommentList = array(),
$usersToSend = [],
$attachmentArray = [],
$attachmentCommentList = [],
$comment = null,
$color = '',
$addAnnouncement = false,
@ -1201,7 +1201,7 @@ class Agenda
$ignoreVisibility = api_get_configuration_value('personal_agenda_show_all_session_events');
// Getting course events
$my_course_list = array();
$my_course_list = [];
if (!api_is_anonymous()) {
$session_list = SessionManager::get_sessions_by_user(
api_get_user_id(),
@ -1216,7 +1216,7 @@ class Agenda
if (api_is_drh()) {
if (api_drh_can_access_all_session_content()) {
$session_list = array();
$session_list = [];
$sessionList = SessionManager::get_sessions_followed_by_drh(
api_get_user_id(),
null,
@ -1511,10 +1511,10 @@ class Agenda
WHERE user = $user_id $startCondition $endCondition";
$result = Database::query($sql);
$my_events = array();
$my_events = [];
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$event = array();
$event = [];
$event['id'] = 'personal_'.$row['id'];
$event['title'] = $row['title'];
$event['className'] = 'personal';
@ -1594,8 +1594,8 @@ class Agenda
";
$result = Database::query($sql);
$users = array();
$groups = array();
$users = [];
$groups = [];
$everyone = false;
while ($row = Database::fetch_array($result, 'ASSOC')) {
@ -1677,12 +1677,12 @@ class Agenda
$end = isset($end) && !empty($end) ? api_get_utc_datetime(intval($end)) : null;
if (empty($courseInfo)) {
return array();
return [];
}
$courseId = $courseInfo['real_id'];
if (empty($courseId)) {
return array();
return [];
}
$sessionId = intval($sessionId);
@ -1695,7 +1695,7 @@ class Agenda
$sessionId
);
$groupNameList = array();
$groupNameList = [];
if (!empty($groupList)) {
foreach ($groupList as $group) {
$groupNameList[$group['iid']] = $group['name'];
@ -1868,7 +1868,7 @@ class Agenda
if (Database::num_rows($result)) {
$eventsAdded = array_column($this->events, 'unique_id');
while ($row = Database::fetch_array($result, 'ASSOC')) {
$event = array();
$event = [];
$event['id'] = 'course_'.$row['id'];
$event['unique_id'] = $row['iid'];
// To avoid doubles
@ -1973,7 +1973,7 @@ class Agenda
// Event Sent to a group?
if (isset($row['to_group_id']) && !empty($row['to_group_id'])) {
$sent_to = array();
$sent_to = [];
if (!empty($group_to_array)) {
foreach ($group_to_array as $group_item) {
$sent_to[] = $groupNameList[$group_item];
@ -1991,7 +1991,7 @@ class Agenda
// Event sent to a user?
if (isset($row['to_user_id'])) {
$sent_to = array();
$sent_to = [];
if (!empty($user_to_array)) {
foreach ($user_to_array as $item) {
$user_info = api_get_user_info($item);
@ -2064,10 +2064,10 @@ class Agenda
WHERE access_url_id = $access_url_id
$dateCondition";
$result = Database::query($sql);
$my_events = array();
$my_events = [];
if (Database::num_rows($result)) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$event = array();
$event = [];
$event['id'] = 'platform_'.$row['id'];
$event['title'] = $row['title'];
$event['className'] = 'platform';
@ -2151,8 +2151,8 @@ class Agenda
}
}
$sendToGroups = isset($sendTo['groups']) ? $sendTo['groups'] : array();
$sendToUsers = isset($sendTo['users']) ? $sendTo['users'] : array();
$sendToGroups = isset($sendTo['groups']) ? $sendTo['groups'] : [];
$sendToUsers = isset($sendTo['users']) ? $sendTo['users'] : [];
/** @var HTML_QuickForm_select $select */
$select = $form->addSelect(
@ -2166,10 +2166,10 @@ class Agenda
$form->setRequired($select);
}
$selectedEveryoneOptions = array();
$selectedEveryoneOptions = [];
if (isset($sendTo['everyone']) && $sendTo['everyone']) {
$selectedEveryoneOptions = array('selected');
$sendToUsers = array();
$sendToUsers = [];
}
$select->addOption(
@ -2178,7 +2178,7 @@ class Agenda
$selectedEveryoneOptions
);
$options = array();
$options = [];
if (is_array($groupList)) {
foreach ($groupList as $group) {
$count_users = isset($group['count_users']) ? $group['count_users'] : $group['userNb'];
@ -2208,7 +2208,7 @@ class Agenda
// adding the individual users to the select form
if (is_array($userList)) {
$options = array();
$options = [];
foreach ($userList as $user) {
if ($user['status'] == ANONYMOUS) {
continue;
@ -2254,8 +2254,8 @@ class Agenda
*/
public function parseSendToArray($to)
{
$groupList = array();
$userList = array();
$groupList = [];
$userList = [];
$sendTo = null;
$sendTo['everyone'] = false;
@ -2361,7 +2361,7 @@ class Agenda
} else {
$sendTo = isset($params['send_to']) ? $params['send_to'] : ['everyone' => true];
if ($this->type == 'course') {
$this->showToForm($form, $sendTo, array(), false, true);
$this->showToForm($form, $sendTo, [], false, true);
}
}
@ -2533,8 +2533,8 @@ class Agenda
*/
public function showToForm(
$form,
$sendTo = array(),
$attributes = array(),
$sendTo = [],
$attributes = [],
$addOnlyItemsInSendTo = false,
$required = false
) {
@ -2644,7 +2644,7 @@ class Agenda
c_id = $courseId AND
agenda_id = $eventId";
$result = Database::query($sql);
$list = array();
$list = [];
if (Database::num_rows($result) != 0) {
$list = Database::store_result($result, 'ASSOC');
}
@ -2666,7 +2666,7 @@ class Agenda
$eventId = intval($eventId);
$attachmentId = intval($attachmentId);
$row = array();
$row = [];
$sql = "SELECT id, path, filename, comment
FROM $tableAttachment
WHERE
@ -2886,7 +2886,7 @@ class Agenda
*/
public function getAllRepeatEvents($eventId)
{
$events = array();
$events = [];
switch ($this->type) {
case 'personal':
break;
@ -3007,7 +3007,7 @@ class Agenda
'post',
'',
'',
array(),
[],
FormValidator::LAYOUT_INLINE
);
$attributes = array(
@ -3036,7 +3036,7 @@ class Agenda
'get',
api_get_self().'?type=personal&',
'',
array(),
[],
FormValidator::LAYOUT_INLINE
);
@ -3121,7 +3121,7 @@ class Agenda
{
$charset = api_get_system_encoding();
$filepath = api_get_path(SYS_ARCHIVE_PATH).$file['name'];
$messages = array();
$messages = [];
if (!@move_uploaded_file($file['tmp_name'], $filepath)) {
error_log(
@ -3289,8 +3289,8 @@ class Agenda
) {
$user_id = intval($user_id);
$items = array();
$my_list = array();
$items = [];
$my_list = [];
// get agenda-items for every course
foreach ($courses_dbs as $key => $array_course_info) {
@ -3386,7 +3386,7 @@ class Agenda
}
// sorting by hour for every day
$agendaitems = array();
$agendaitems = [];
while (list ($agendaday, $tmpitems) = each($items)) {
if (!isset($agendaitems[$agendaday])) {
$agendaitems[$agendaday] = '';
@ -3681,7 +3681,7 @@ class Agenda
$agendaitems,
$month,
$year,
$weekdaynames = array(),
$weekdaynames = [],
$monthName,
$show_content = true
) {
@ -3819,7 +3819,7 @@ class Agenda
$icon = Display::return_icon(
'user.png',
get_lang('MyAgenda'),
array(),
[],
ICON_SIZE_SMALL
);
break;
@ -3828,7 +3828,7 @@ class Agenda
$icon = Display::return_icon(
'view_remove.png',
get_lang('GlobalEvent'),
array(),
[],
ICON_SIZE_SMALL
);
break;
@ -3845,7 +3845,7 @@ class Agenda
$value['course_name'].' '.get_lang(
'Course'
),
array(),
[],
ICON_SIZE_SMALL
),
$value['url']
@ -3856,7 +3856,7 @@ class Agenda
$value['course_name'].' '.get_lang(
'Course'
),
array(),
[],
ICON_SIZE_SMALL
);
}
@ -3931,10 +3931,9 @@ class Agenda
/**
* Get personal agenda items between two dates (=all events from all registered courses)
* @param int user ID of the user
* @param int $user_id user ID of the user
* @param string Optional start date in datetime format (if no start date is given, uses today)
* @param string Optional end date in datetime format (if no date is given, uses one year from now)
* @param integer $user_id
* @return array Array of events ordered by start date, in
* [0]('datestart','dateend','title'),[1]('datestart','dateend','title','link','coursetitle') format,
* where datestart and dateend are in yyyyMMddhhmmss format.
@ -3945,7 +3944,7 @@ class Agenda
$date_start = '',
$date_end = ''
) {
$items = array();
$items = [];
if ($user_id != strval(intval($user_id))) {
return $items;
}
@ -4158,8 +4157,6 @@ class Agenda
$courseTitle = $this->course['name'];
}
api_mail_html(
$userInfo['complete_name'],
$userInfo['mail'],

@ -165,7 +165,8 @@ class MessageManager
}
$userInfo = api_get_user_info($result[1]);
$message[1] = '<a '.$class.' href="view_message.php?id='.$result[0].'">'.$result[2].'</a><br />'.$userInfo['complete_name_with_username'];
$message[1] = '<a '.$class.' href="view_message.php?id='.$result[0].'">'.
$result[2].'</a><br />'.$userInfo['complete_name_with_username'];
$message[3] =
Display::url(
@ -495,7 +496,7 @@ class MessageManager
* @param int $sender_id
* @param bool $sendCopyToDrhUsers send copy to related DRH users
* @param bool $directMessage
* @param bool $smsParameters
* @param array $smsParameters
* @param bool $uploadFiles Do not upload files using the MessageManager class
*
* @return bool
@ -573,8 +574,8 @@ class MessageManager
$receiver_user_id = intval($receiver_user_id);
$message_id = intval($message_id);
// first get data from message id (parent)
$sql_message = "SELECT * FROM $table_message WHERE id = '$parent_id'";
$rs_message = Database::query($sql_message);
$sql = "SELECT * FROM $table_message WHERE id = '$parent_id'";
$rs_message = Database::query($sql);
$row_message = Database::fetch_array($rs_message);
// get message id from data found early for other receiver user
@ -785,7 +786,7 @@ class MessageManager
* update messages by user id and message id
* @param int $user_id
* @param int $message_id
* @return resource
* @return bool
*/
public static function update_message($user_id, $message_id)
{
@ -793,14 +794,15 @@ class MessageManager
return false;
}
$table_message = Database::get_main_table(TABLE_MESSAGE);
$sql = "UPDATE $table_message SET
$table = Database::get_main_table(TABLE_MESSAGE);
$sql = "UPDATE $table SET
msg_status = '".MESSAGE_STATUS_NEW."'
WHERE
msg_status <> ".MESSAGE_STATUS_OUTBOX." AND
user_receiver_id=".intval($user_id)." AND
id='" . intval($message_id)."'";
Database::query($sql);
return true;
}
/**
@ -906,14 +908,14 @@ class MessageManager
}
/**
* get messages by parent id optionally with limit
* Get messages by parent id optionally with limit
* @param int parent id
* @param int group id (optional)
* @param int offset (optional)
* @param int limit (optional)
* @return array
*/
public static function get_messages_by_parent($parent_id, $group_id = '', $offset = 0, $limit = 0)
public static function get_messages_by_parent($parent_id, $group_id = 0, $offset = 0, $limit = 0)
{
if ($parent_id != strval(intval($parent_id))) {
return false;
@ -921,12 +923,12 @@ class MessageManager
$table_message = Database::get_main_table(TABLE_MESSAGE);
$parent_id = intval($parent_id);
$condition_group_id = '';
if ($group_id !== '') {
if (!empty($group_id)) {
$group_id = intval($group_id);
$condition_group_id = " AND group_id = '$group_id' ";
}
$condition_limit = "";
$condition_limit = '';
if ($offset && $limit) {
$offset = ($offset - 1) * $limit;
$condition_limit = " LIMIT $offset,$limit ";
@ -1037,7 +1039,8 @@ class MessageManager
if ($request === true) {
$message[1] = '<a onclick="show_sent_message('.$result[0].')" href="javascript:void(0)">'.$userInfo['complete_name_with_username'].'</a>';
$message[2] = '<a onclick="show_sent_message('.$result[0].')" href="javascript:void(0)">'.str_replace("\\", "", $result[2]).'</a>';
$message[3] = api_convert_and_format_date($result[3], DATE_TIME_FORMAT_LONG); //date stays the same
//date stays the same
$message[3] = api_convert_and_format_date($result[3], DATE_TIME_FORMAT_LONG);
$message[4] = '&nbsp;&nbsp;<a title="'.addslashes(get_lang('DeleteMessage')).'" onclick="delete_one_message_outbox('.$result[0].')" href="javascript:void(0)" >'.
Display::returnFontAwesomeIcon('trash', 2).'</a>';
} else {
@ -1174,9 +1177,11 @@ class MessageManager
$message_content .= '</div>';
} else {
if ($source == 'outbox') {
$message_content .= get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.$receiverUserInfo['complete_name'].'</b>';
$message_content .= get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.
$receiverUserInfo['complete_name'].'</b>';
} else {
$message_content .= get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.get_lang('Me').'</b>';
$message_content .= get_lang('From').':&nbsp;'.$name.'</b> '.api_strtolower(get_lang('To')).' <b>'.
get_lang('Me').'</b>';
}
}
@ -1679,7 +1684,8 @@ class MessageManager
$filesize = format_file_size($row_file['size']);
$filecomment = Security::remove_XSS($row_file['comment']);
$filename = Security::remove_XSS($filename);
$links_attach_file[] = $attach_icon.'&nbsp;<a href="'.$archiveURL.$archiveFile.'">'.$filename.'</a>&nbsp;('.$filesize.')'.(!empty($filecomment) ? '&nbsp;-&nbsp;<i>'.$filecomment.'</i>' : '');
$links_attach_file[] = $attach_icon.'&nbsp;<a href="'.$archiveURL.$archiveFile.'">'.$filename.'</a>
&nbsp;('.$filesize.')'.(!empty($filecomment) ? '&nbsp;-&nbsp;<i>'.$filecomment.'</i>' : '');
}
}
}
@ -1853,7 +1859,8 @@ class MessageManager
public static function outbox_display($keyword = '')
{
Session::write('message_sent_search_keyword', $keyword);
$success = get_lang('SelectedMessagesDeleted').'&nbsp</b><br /><a href="outbox.php">'.get_lang('BackToOutbox').'</a>';
$success = get_lang('SelectedMessagesDeleted').'&nbsp</b><br />
<a href="outbox.php">'.get_lang('BackToOutbox').'</a>';
$html = '';
if (isset($_REQUEST['action'])) {

@ -133,6 +133,7 @@ class MySpace
@chmod($file_name, api_get_permissions_for_new_files());
header("Location:".$archive_url.$file_name);
exit;
}
return $message;
}
@ -266,9 +267,9 @@ class MySpace
// course code
$return .= ' <td width="157px" >'.cut($courseCode, 20, true).'</td>';
// time spent in the course
$return .= ' <td><div>'.api_time_to_hms(Tracking::get_time_spent_on_the_course($user_id, $courseId)).'</div></td>';
$return .= '<td><div>'.api_time_to_hms(Tracking::get_time_spent_on_the_course($user_id, $courseId)).'</div></td>';
// student progress in course
$return .= ' <td><div>'.round(Tracking::get_avg_student_progress($user_id, $courseCode), 2).'</div></td>';
$return .= '<td><div>'.round(Tracking::get_avg_student_progress($user_id, $courseCode), 2).'</div></td>';
// student score
$avg_score = Tracking::get_avg_student_score($user_id, $courseCode);
if (is_numeric($avg_score)) {
@ -325,16 +326,58 @@ class MySpace
0
);
$table->additional_parameters = $addparams;
$table->set_header(0, get_lang('OfficialCode'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
$table->set_header(
0,
get_lang('OfficialCode'),
true,
array('style' => 'font-size:8pt'),
array('style' => 'font-size:8pt')
);
if (api_is_western_name_order()) {
$table->set_header(1, get_lang('FirstName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
$table->set_header(2, get_lang('LastName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
$table->set_header(
1,
get_lang('FirstName'),
true,
array('style' => 'font-size:8pt'),
array('style' => 'font-size:8pt')
);
$table->set_header(
2,
get_lang('LastName'),
true,
array('style' => 'font-size:8pt'),
array('style' => 'font-size:8pt')
);
} else {
$table->set_header(1, get_lang('LastName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
$table->set_header(2, get_lang('FirstName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
$table->set_header(
1,
get_lang('LastName'),
true,
array('style' => 'font-size:8pt'),
array('style' => 'font-size:8pt')
);
$table->set_header(
2,
get_lang('FirstName'),
true,
array('style' => 'font-size:8pt'),
array('style' => 'font-size:8pt')
);
}
$table->set_header(3, get_lang('LoginName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
$table->set_header(4, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
$table->set_header(
3,
get_lang('LoginName'),
true,
array('style' => 'font-size:8pt'),
array('style' => 'font-size:8pt')
);
$table->set_header(
4,
$t_head,
false,
array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'),
array('style' => 'width:90%;padding:0;font-size:7.5pt;')
);
$table->set_column_filter(4, array('MySpace', 'course_info_tracking_filter'));
$table->display();
}
@ -676,13 +719,13 @@ class MySpace
// jqgrid will use this URL to do the selects
$url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_lp_progress&session_id='.$sessionId.'&course_id='.$courseId.'&date_to='.$date_to.'&date_from='.$date_from;
//Table Id
// Table Id
$tableId = 'lpProgress';
//Autowidth
// Autowidth
$extra_params['autowidth'] = 'true';
//height auto
// height auto
$extra_params['height'] = 'auto';
$table = Display::grid_js(
@ -879,7 +922,11 @@ class MySpace
// Displaying a feedback message
if (!empty($additionalExportFields)) {
echo Display::return_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', 'confirm', false);
echo Display::return_message(
get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>',
'confirm',
false
);
} else {
echo Display::return_message(
get_lang('NoAdditionalFieldsWillBeExported'),
@ -901,7 +948,11 @@ class MySpace
$message .= '<li>'.$extrafields[$extra_field_export][3].'</li>';
}
echo Display::return_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', 'normal', false);
echo Display::return_message(
get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>',
'normal',
false
);
}
}
}
@ -1254,9 +1305,11 @@ class MySpace
null,
false
);
if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
if ($last_login_date_tmp != false && $last_login_date == false) {
// TODO: To be cleaned.
$last_login_date = $last_login_date_tmp;
} elseif ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
} elseif ($last_login_date_tmp != false && $last_login_date == false) {
// TODO: Repeated previous condition. To be cleaned.
// Find the max and assign it to first_login_date
if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
$last_login_date = $last_login_date_tmp;
@ -1322,18 +1375,18 @@ class MySpace
*/
public static function display_tracking_session_overview()
{
$t_head = '<table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
$t_head .= '<tr>';
$t_head .= '<th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>';
$t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
$t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>';
$t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgCourseScore'), 6, true).'</span></th>';
$t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('TotalNumberOfMessages'), 6, true).'</span></th>';
$t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('TotalNumberOfAssignments'), 6, true).'</span></th>';
$t_head .= '<th width="105px" style="border-bottom:0"><span>'.get_lang('TotalExercisesScoreObtained').'</span></th>';
$t_head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('TotalExercisesAnswered'), 6, true).'</span></th>';
$t_head .= '<th style="padding:0;border-bottom:0;border-right:0;"><span>'.get_lang('LatestLogin').'</span></th>';
$t_head .= '</tr></table>';
$head = '<table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
$head .= '<tr>';
$head .= '<th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>';
$head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
$head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>';
$head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgCourseScore'), 6, true).'</span></th>';
$head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('TotalNumberOfMessages'), 6, true).'</span></th>';
$head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('TotalNumberOfAssignments'), 6, true).'</span></th>';
$head .= '<th width="105px" style="border-bottom:0"><span>'.get_lang('TotalExercisesScoreObtained').'</span></th>';
$head .= '<th style="padding:0;border-bottom:0"><span>'.cut(get_lang('TotalExercisesAnswered'), 6, true).'</span></th>';
$head .= '<th style="padding:0;border-bottom:0;border-right:0;"><span>'.get_lang('LatestLogin').'</span></th>';
$head .= '</tr></table>';
$addparams = array('view' => 'admin', 'display' => 'sessionoverview');
$table = new SortableTable(
@ -1345,8 +1398,20 @@ class MySpace
$table->additional_parameters = $addparams;
$table->set_header(0, '', false, null, array('style' => 'display: none'));
$table->set_header(1, get_lang('Session'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
$table->set_header(2, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
$table->set_header(
1,
get_lang('Session'),
true,
array('style' => 'font-size:8pt'),
array('style' => 'font-size:8pt')
);
$table->set_header(
2,
$head,
false,
array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'),
array('style' => 'width:90%;padding:0;font-size:7.5pt;')
);
$table->set_column_filter(2, array('MySpace', 'session_tracking_filter'));
$table->display();
}
@ -1465,7 +1530,12 @@ class MySpace
}
$nb_messages += Tracking::count_student_messages($row_user->user_id, $row->code, $session_id);
$nb_assignments += Tracking::count_student_assignments($row_user->user_id, $row->code, $session_id);
$last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row_user->user_id, $courseInfo, $session_id, false);
$last_login_date_tmp = Tracking::get_last_connection_date_on_the_course(
$row_user->user_id,
$courseInfo,
$session_id,
false
);
if ($last_login_date_tmp != false && $last_login_date == false) {
// TODO: To be cleaned.
$last_login_date = $last_login_date_tmp;
@ -1493,7 +1563,11 @@ class MySpace
$avg_score = '-';
}
if ($last_login_date) {
$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
$last_login_date = api_convert_and_format_date(
$last_login_date,
DATE_FORMAT_SHORT,
date_default_timezone_get()
);
} else {
$last_login_date = '-';
}
@ -1616,10 +1690,22 @@ class MySpace
while ($row_user = Database::fetch_object($result_users)) {
// get time spent in the course and session
$time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id);
$progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true);
$progress_tmp = Tracking::get_avg_student_progress(
$row_user->user_id,
$row->code,
array(),
$session_id,
true
);
$progress += $progress_tmp[0];
$nb_progress_lp += $progress_tmp[1];
$score_tmp = Tracking::get_avg_student_score($row_user->user_id, $row->code, array(), $session_id, true);
$score_tmp = Tracking::get_avg_student_score(
$row_user->user_id,
$row->code,
array(),
$session_id,
true
);
if (is_array($score_tmp)) {
$score += $score_tmp[0];
$nb_score_lp += $score_tmp[1];
@ -1642,9 +1728,11 @@ class MySpace
$session_id,
false
);
if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
if ($last_login_date_tmp != false && $last_login_date == false) {
// TODO: To be cleaned.
$last_login_date = $last_login_date_tmp;
} else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
} else if ($last_login_date_tmp != false && $last_login_date == false) {
// TODO: Repeated previous condition. To be cleaned.
// Find the max and assign it to first_login_date
if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
$last_login_date = $last_login_date_tmp;
@ -1667,7 +1755,11 @@ class MySpace
$avg_score = '-';
}
if ($last_login_date) {
$last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
$last_login_date = api_convert_and_format_date(
$last_login_date,
DATE_FORMAT_SHORT,
date_default_timezone_get()
);
} else {
$last_login_date = '-';
}
@ -1958,7 +2050,11 @@ class MySpace
$avg_progress_in_course = Tracking::get_avg_student_progress($users, $course_code, array(), $session_id);
$avg_score_in_course = Tracking::get_avg_student_score($users, $course_code, array(), $session_id);
$avg_score_in_exercise = Tracking::get_avg_student_exercise_score($users, $course_code, 0, $session_id);
$avg_time_spent_in_course = Tracking::get_time_spent_on_the_course($users, $courseInfo['real_id'], $session_id);
$avg_time_spent_in_course = Tracking::get_time_spent_on_the_course(
$users,
$courseInfo['real_id'],
$session_id
);
$avg_progress_in_course = round($avg_progress_in_course / $nb_students_in_course, 2);
if (is_numeric($avg_score_in_course)) {
@ -2134,7 +2230,8 @@ class MySpace
/**
* Checks if there are repeted users in a given array
* @param array $usernames list of the usernames in the uploaded file
* @param array $user_array $user_array['username'] and $user_array['sufix'] where sufix is the number part in a login i.e -> jmontoya2
* @param array $user_array $user_array['username'] and $user_array['sufix']
* where suffix is the number part in a login i.e -> jmontoya2
* @return array with the $usernames array and the $user_array array
* @author Julio Montoya
*/
@ -2223,7 +2320,8 @@ class MySpace
$user_name = $user['UserName'];
$sql_select = "SELECT user_id FROM $table_user WHERE username ='$user_name' ";
$rs = Database::query($sql_select);
$user['create'] = Database::result($rs, 0, 0); // This should be the ID because the user exists.
$user['create'] = Database::result($rs, 0, 0);
// This should be the ID because the user exists.
} else {
$user['create'] = $is_session_avail;
}
@ -2242,8 +2340,7 @@ class MySpace
/**
* This functions checks whether there are users that are already
* registered in the DB by different creator than the current coach.
* @param string a given username
* @param array $users the array with the course list ids
* @param array $users
* @return array
* @author Julio Montoya Armas
*/
@ -2272,7 +2369,7 @@ class MySpace
/**
* Validates imported data.
* @param $users list of users
* @param array $users list of users
*/
function validate_data($users, $id_session = null)
{
@ -2467,7 +2564,8 @@ class MySpace
} else {
$addedto = get_lang('UserNotAdded');
}
$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
$registered_users .= "<a href=\"../user/userInfo.php?uInfo=".$user['id']."\">".
api_get_person_name($user['FirstName'], $user['LastName'])."</a> - ".$addedto.'<br />';
}
}
Display::addFlash(Display::return_message($registered_users));
@ -2932,7 +3030,8 @@ function convert_to_array($sql_result)
{
$result_to_print = '<table>';
foreach ($sql_result as $key => $data) {
$result_to_print .= '<tr><td>'.date('d-m-Y (H:i:s)', $data['login']).'</td><td>'.api_time_to_hms($data['logout'] - $data['login']).'</tr></td>'."\n";
$result_to_print .= '<tr><td>'.date('d-m-Y (H:i:s)', $data['login']).'</td><td>'.
api_time_to_hms($data['logout'] - $data['login']).'</tr></td>'."\n";
}
$result_to_print .= '</table>';
$result_to_print = array("result"=>$result_to_print);

@ -59,7 +59,7 @@ class UserGroup extends Model
*/
public function getTotalCount()
{
$row = Database::select('count(*) as count', $this->table, array(), 'first');
$row = Database::select('count(*) as count', $this->table, [], 'first');
return $row['count'];
}
@ -177,10 +177,20 @@ class UserGroup extends Model
{
// action links
echo '<div class="actions">';
echo '<a href="../admin/index.php">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', '32').'</a>';
echo '<a href="'.api_get_self().'?action=add">'.Display::return_icon('new_class.png', get_lang('AddClasses'), '', '32').'</a>';
echo Display::url(Display::return_icon('import_csv.png', get_lang('Import'), array(), ICON_SIZE_MEDIUM), 'usergroup_import.php');
echo Display::url(Display::return_icon('export_csv.png', get_lang('Export'), array(), ICON_SIZE_MEDIUM), 'usergroup_export.php');
echo '<a href="../admin/index.php">'.
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('PlatformAdmin'), '', '32').
'</a>';
echo '<a href="'.api_get_self().'?action=add">'.
Display::return_icon('new_class.png', get_lang('AddClasses'), '', '32').
'</a>';
echo Display::url(
Display::return_icon('import_csv.png', get_lang('Import'), [], ICON_SIZE_MEDIUM),
'usergroup_import.php'
);
echo Display::url(
Display::return_icon('export_csv.png', get_lang('Export'), [], ICON_SIZE_MEDIUM),
'usergroup_export.php'
);
echo '</div>';
echo Display::grid_html('usergroups');
}
@ -222,7 +232,7 @@ class UserGroup extends Model
/*
if (!empty($conditionsLike)) {
$from .= " INNER JOIN {$this->table_course} as course ON c.course_id = course.id";
$conditionSql = array();
$conditionSql = [];
foreach ($conditionsLike as $field => $value) {
$conditionSql[] = $field.' LIKE %?%';
$whereConditionValues[] = $value;
@ -244,7 +254,7 @@ class UserGroup extends Model
$where
);
$array = array();
$array = [];
if (!empty($results)) {
foreach ($results as $row) {
if ($loadCourseData) {
@ -263,7 +273,7 @@ class UserGroup extends Model
*
* @return array
*/
public function getUserGroupInCourse($options = array(), $type = -1)
public function getUserGroupInCourse($options = [], $type = -1)
{
if ($this->useMultipleUrl) {
$sql = "SELECT u.* FROM {$this->usergroup_rel_course_table} usergroup
@ -325,7 +335,7 @@ class UserGroup extends Model
*
* @return array|bool
*/
public function getUserGroupNotInCourse($options = array(), $type = -1)
public function getUserGroupNotInCourse($options = [], $type = -1)
{
$course_id = null;
if (isset($options['course_id'])) {
@ -411,7 +421,7 @@ class UserGroup extends Model
}
$results = Database::select('c.usergroup_id', $from, $options);
$array = array();
$array = [];
if (!empty($results)) {
foreach ($results as $row) {
$array[] = $row['usergroup_id'];
@ -454,7 +464,7 @@ class UserGroup extends Model
array('where' => array('usergroup_id = ?' => $id))
);
$array = array();
$array = [];
if (!empty($results)) {
foreach ($results as $row) {
$array[] = $row['session_id'];
@ -488,7 +498,7 @@ class UserGroup extends Model
}
if (empty($id)) {
$conditions = array();
$conditions = [];
} else {
$conditions = array('where' => array("usergroup_id = ? $relationCondition "=> $id));
}
@ -498,7 +508,7 @@ class UserGroup extends Model
$this->usergroup_rel_user_table,
$conditions
);
$array = array();
$array = [];
if (!empty($results)) {
foreach ($results as $row) {
$array[] = $row['user_id'];
@ -528,7 +538,7 @@ class UserGroup extends Model
$conditions
);
$array = array();
$array = [];
if (!empty($results)) {
foreach ($results as $row) {
$array[] = $row['user_id'];
@ -573,7 +583,7 @@ class UserGroup extends Model
$from,
$where
);
$array = array();
$array = [];
if (!empty($results)) {
foreach ($results as $row) {
$array[] = $row;
@ -607,7 +617,7 @@ class UserGroup extends Model
$where
);
$array = array();
$array = [];
if (!empty($results)) {
foreach ($results as $row) {
$array[] = $row['usergroup_id'];
@ -627,7 +637,7 @@ class UserGroup extends Model
$current_list = self::get_sessions_by_usergroup($usergroup_id);
$user_list = self::get_users_by_usergroup($usergroup_id);
$delete_items = $new_items = array();
$delete_items = $new_items = [];
if (!empty($list)) {
foreach ($list as $session_id) {
if (!in_array($session_id, $current_list)) {
@ -687,7 +697,7 @@ class UserGroup extends Model
$current_list = self::get_courses_by_usergroup($usergroup_id);
$user_list = self::get_users_by_usergroup($usergroup_id);
$delete_items = $new_items = array();
$delete_items = $new_items = [];
if (!empty($list)) {
foreach ($list as $id) {
if (!in_array($id, $current_list)) {
@ -788,8 +798,8 @@ class UserGroup extends Model
$session_list = self::get_sessions_by_usergroup($usergroup_id);
$relationType = (int) $relationType;
$delete_items = array();
$new_items = array();
$delete_items = [];
$new_items = [];
if (!empty($list)) {
foreach ($list as $user_id) {
@ -916,7 +926,7 @@ class UserGroup extends Model
$where = array(' access_url_id = ?' => $urlId);
} else {
$from = $this->table." u ";
$where = array();
$where = [];
}
$result = Database::select(
@ -929,7 +939,7 @@ class UserGroup extends Model
)
);
$new_result = array();
$new_result = [];
if (!empty($result)) {
foreach ($result as $group) {
$group['sessions'] = count($this->get_sessions_by_usergroup($group['id']));
@ -971,7 +981,7 @@ class UserGroup extends Model
* @param array $options
* @return array
*/
public function getDataToExport($options = array())
public function getDataToExport($options = [])
{
if ($this->useMultipleUrl) {
$urlId = api_get_current_access_url_id();
@ -983,13 +993,13 @@ class UserGroup extends Model
$classes = Database::select('id, name, description', $this->table, $options);
}
$result = array();
$result = [];
if (!empty($classes)) {
foreach ($classes as $data) {
$users = self::getUserListByUserGroup($data['id']);
$userToString = null;
if (!empty($users)) {
$userNameList = array();
$userNameList = [];
foreach ($users as $userData) {
$userNameList[] = $userData['username'];
}
@ -1028,7 +1038,7 @@ class UserGroup extends Model
public function getUserGroupNotInList($list)
{
if (empty($list)) {
return array();
return [];
}
$list = array_map('intval', $list);
@ -1392,7 +1402,7 @@ class UserGroup extends Model
* @param string $type
* @param array $data
*/
public function setForm($form, $type = 'add', $data = array())
public function setForm($form, $type = 'add', $data = [])
{
switch ($type) {
case 'add':
@ -1475,7 +1485,7 @@ class UserGroup extends Model
$size_picture = GROUP_IMAGE_SIZE_MEDIUM,
$style = ''
) {
$picture = array();
$picture = [];
//$picture['style'] = $style;
if ($picture_file === 'unknown.jpg') {
$picture['file'] = Display::returnIconPath($picture_file);
@ -1507,9 +1517,9 @@ class UserGroup extends Model
//$picture['style'] = '';
if ($height > 0) {
$dimension = api_getimagesize($picture['file']);
$margin = (($height - $dimension['width']) / 2);
$margin = ($height - $dimension['width']) / 2;
//@ todo the padding-top should not be here
//$picture['style'] = ' style="padding-top:'.$margin.'px; width:'.$dimension['width'].'px; height:'.$dimension['height'].';" ';
}
} else {
$file = $image_array_sys['dir'].$picture_file;
@ -1531,9 +1541,13 @@ class UserGroup extends Model
* the same directory.
* @param integer User ID
* @param string Type of path to return (can be 'none', 'system', 'rel', 'web')
* @param bool Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
* @param bool Whether we want to have the directory name returned 'as if'
* there was a file or not (in the case we want to know which directory to create -
* otherwise no file means no split subdir)
* @param bool If we want that the function returns the /main/img/unknown.jpg image set it at true
* @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
* @return array Array of 2 elements: 'dir' and 'file' which contain the dir
* and file as the name implies if image does not exist it will return the unknown
* image if anonymous parameter is true if not it returns an empty er's
*/
public function get_group_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false)
{
@ -1634,7 +1648,7 @@ class UserGroup extends Model
* @param int $user_id
* @return bool
*/
public function is_group_moderator($group_id, $user_id = 0)
public function isGroupModerator($group_id, $user_id = 0)
{
if (empty($user_id)) {
$user_id = api_get_user_id();
@ -1743,7 +1757,7 @@ class UserGroup extends Model
public function add_users_to_groups($user_list, $group_list, $relation_type = GROUP_USER_PERMISSION_READER)
{
$table_url_rel_group = $this->usergroup_rel_user_table;
$result_array = array();
$result_array = [];
$relation_type = intval($relation_type);
if (is_array($user_list) && is_array($group_list)) {
@ -1873,7 +1887,7 @@ class UserGroup extends Model
$relationCondition
ORDER BY created_at DESC ";
$result = Database::query($sql);
$array = array();
$array = [];
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image) {
@ -1914,7 +1928,7 @@ class UserGroup extends Model
LIMIT $num";
$result = Database::query($sql);
$array = array();
$array = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image) {
$picture = self::get_picture_group($row['id'], $row['picture'], 80);
@ -1963,7 +1977,7 @@ class UserGroup extends Model
LIMIT $num ";
$result = Database::query($sql);
$array = array();
$array = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image) {
$picture = self::get_picture_group($row['id'], $row['picture'], 80);
@ -1991,7 +2005,7 @@ class UserGroup extends Model
public function get_users_by_group(
$group_id,
$with_image = false,
$relation_type = array(),
$relation_type = [],
$from = null,
$limit = null,
$image_conf = array('size' => USER_IMAGE_SIZE_MEDIUM, 'height' => 80)
@ -2001,7 +2015,7 @@ class UserGroup extends Model
$group_id = intval($group_id);
if (empty($group_id)) {
return array();
return [];
}
$limit_text = '';
@ -2014,7 +2028,7 @@ class UserGroup extends Model
if (count($relation_type) == 0) {
$where_relation_condition = '';
} else {
$new_relation_type = array();
$new_relation_type = [];
foreach ($relation_type as $rel) {
$rel = intval($rel);
$new_relation_type[] = "'$rel'";
@ -2035,7 +2049,7 @@ class UserGroup extends Model
$limit_text";
$result = Database::query($sql);
$array = array();
$array = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
if ($with_image) {
$userInfo = api_get_user_info($row['id']);
@ -2062,7 +2076,7 @@ class UserGroup extends Model
$group_id = intval($group_id);
if (empty($group_id)) {
return array();
return [];
}
$sql = "SELECT u.id, u.firstname, u.lastname, relation_type
@ -2073,7 +2087,7 @@ class UserGroup extends Model
ORDER BY relation_type, firstname";
$result = Database::query($sql);
$array = array();
$array = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
$array[$row['id']] = $row;
}
@ -2167,7 +2181,7 @@ class UserGroup extends Model
get_lang('SocialGroups'),
$list,
'sm-groups',
array(),
[],
'groups-acordeon',
'groups-collapse'
);
@ -2242,7 +2256,7 @@ class UserGroup extends Model
$tag = Database::escape_string($tag);
$from = intval($from);
$number_of_items = intval($number_of_items);
$return = array();
$return = [];
$keyword = $tag;
$sql = "SELECT g.id, g.name, g.description, g.url, g.picture
@ -2304,7 +2318,7 @@ class UserGroup extends Model
$sql = $select_part.' '.$cond_part."WHERE rg0.subgroup_id='$group_id'";
$res = Database::query($sql);
$temp_arr = Database::fetch_array($res, 'NUM');
$toReturn = array();
$toReturn = [];
if (is_array($temp_arr)) {
foreach ($temp_arr as $elt) {
if (isset($elt)) {
@ -2376,7 +2390,7 @@ class UserGroup extends Model
*/
public static function getGroupsByDepthLevel($groupId, $levels = 10)
{
$groups = array();
$groups = [];
$groupId = intval($groupId);
$groupTable = Database::get_main_table(TABLE_USERGROUP);

@ -53,7 +53,9 @@ class aicc extends learnpath
*/
public function __construct($course_code = null, $resource_id = null, $user_id = null)
{
if ($this->debug > 0) { error_log('In aicc::aicc()', 0); }
if ($this->debug > 0) {
error_log('In aicc::aicc()');
}
if (!empty($course_code) && !empty($resource_id) && !empty($user_id)) {
parent::__construct($course_code, $resource_id, $user_id);
}
@ -79,7 +81,9 @@ class aicc extends learnpath
*/
public function parse_config_files($dir = '')
{
if ($this->debug > 0) {error_log('New LP - In aicc::parse_config_files('.$dir.')', 0); }
if ($this->debug > 0) {
error_log('New LP - In aicc::parse_config_files('.$dir.')', 0);
}
if (empty($dir)) {
// Get the path of the AICC config files dir.
$dir = $this->subdir;
@ -90,8 +94,9 @@ class aicc extends learnpath
// Parse the Course Description File (.crs) - ini-type.
$crs_file = $dir.'/'.$this->config_files['crs'];
$crs_params = $this->parse_ini_file_quotes_safe($crs_file);
//echo '<pre>crs:'.print_r($crs_params, true).'</pre>';
if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$crs_file.' has been parsed', 0); }
if ($this->debug > 1) {
error_log('New LP - In aicc::parse_config_files() - '.$crs_file.' has been parsed');
}
// CRS distribute crs params into the aicc object.
if (!empty($crs_params['course']['course_creator'])) {
@ -137,8 +142,9 @@ class aicc extends learnpath
// Parse the Descriptor File (.des) - csv-type.
$des_file = $dir.'/'.$this->config_files['des'];
$des_params = $this->parse_csv_file($des_file);
//echo '<pre>des:'.print_r($des_params, true).'</pre>';
if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$des_file.' has been parsed', 0); }
if ($this->debug > 1) {
error_log('New LP - In aicc::parse_config_files() - '.$des_file.' has been parsed', 0);
}
// Distribute des params into the aicc object.
foreach ($des_params as $des) {
// One AU in AICC is equivalent to one SCO in SCORM (scormItem class).
@ -149,8 +155,9 @@ class aicc extends learnpath
// Parse the Assignable Unit File (.au) - csv-type.
$au_file = $dir.'/'.$this->config_files['au'];
$au_params = $this->parse_csv_file($au_file);
//echo '<pre>au:'.print_r($au_params, true).'</pre>';
if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$au_file.' has been parsed', 0); }
if ($this->debug > 1) {
error_log('New LP - In aicc::parse_config_files() - '.$au_file.' has been parsed', 0);
}
// Distribute au params into the aicc object.
foreach ($au_params as $au) {
$oAu = new aiccItem('config', $au);
@ -161,8 +168,9 @@ class aicc extends learnpath
// Parse the Course Structure File (.cst) - csv-type.
$cst_file = $dir.'/'.$this->config_files['cst'];
$cst_params = $this->parse_csv_file($cst_file, ',', '"', true);
//echo '<pre>cst:'.print_r($cst_params, true).'</pre>';
if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$cst_file.' has been parsed', 0); }
if ($this->debug > 1) {
error_log('New LP - In aicc::parse_config_files() - '.$cst_file.' has been parsed', 0);
}
// Distribute cst params into the aicc object.
foreach ($cst_params as $cst) {
$oCst = new aiccBlock('config', $cst);
@ -174,8 +182,9 @@ class aicc extends learnpath
if (!empty($this->config_files['ore'])) {
$ore_file = $dir.'/'.$this->config_files['ore'];
$ore_params = $this->parse_csv_file($ore_file, ',', '"', true);
//echo '<pre>ore:'.print_r($ore_params,true).'</pre>';
if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$ore_file.' has been parsed', 0); }
if ($this->debug > 1) {
error_log('New LP - In aicc::parse_config_files() - '.$ore_file.' has been parsed', 0);
}
// Distribute ore params into the aicc object.
foreach ($ore_params as $ore) {
$oOre = new aiccObjective('config', $ore);
@ -187,8 +196,9 @@ class aicc extends learnpath
if (!empty($this->config_files['pre'])) {
$pre_file = $dir.'/'.$this->config_files['pre'];
$pre_params = $this->parse_csv_file($pre_file);
//echo '<pre>pre:'.print_r($pre_params, true).'</pre>';
if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$pre_file.' has been parsed', 0); }
if ($this->debug > 1) {
error_log('New LP - In aicc::parse_config_files() - '.$pre_file.' has been parsed', 0);
}
// Distribute pre params into the aicc object.
foreach ($pre_params as $pre) {
// Place a constraint on the corresponding block or AU.
@ -208,8 +218,9 @@ class aicc extends learnpath
if (!empty($this->config_files['cmp'])) {
$cmp_file = $dir.'/'.$this->config_files['cmp'];
$cmp_params = $this->parse_csv_file($cmp_file);
//echo '<pre>cmp:'.print_r($cmp_params, true).'</pre>';
if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$cmp_file.' has been parsed', 0); }
if ($this->debug > 1) {
error_log('New LP - In aicc::parse_config_files() - '.$cmp_file.' has been parsed', 0);
}
// Distribute cmp params into the aicc object.
foreach ($cmp_params as $cmp) {
//$oCmp = new aiccCompletionRequirements('config', $cmp);
@ -314,7 +325,9 @@ class aicc extends learnpath
"'$prereq', 0,'".(!empty($oAu->parameters) ? Database::escape_string($oAu->parameters) : '')."'".
")";
Database::query($sql_item);
if ($this->debug > 1) { error_log('New LP - In aicc::import_aicc() - inserting item : '.$sql_item.' : ', 0); }
if ($this->debug > 1) {
error_log('New LP - In aicc::import_aicc() - inserting item : '.$sql_item.' : ', 0);
}
$item_id = Database::insert_id();
if ($item_id) {
@ -355,31 +368,46 @@ class aicc extends learnpath
*/
public function import_package($zip_file_info, $current_dir = '')
{
if ($this->debug > 0) { error_log('In aicc::import_package('.print_r($zip_file_info, true).',"'.$current_dir.'") method', 0); }
if ($this->debug > 0) {
error_log('In aicc::import_package('.print_r($zip_file_info, true).',"'.$current_dir.'") method', 0);
}
//ini_set('error_log', 'E_ALL');
$maxFilledSpace = 1000000000;
$zip_file_path = $zip_file_info['tmp_name'];
$zip_file_name = $zip_file_info['name'];
if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name, 0); }
if ($this->debug > 0) {
error_log(
'New LP - aicc::import_package() - Zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name,
0
);
}
$course_rel_dir = api_get_course_path().'/scorm'; // Scorm dir web path starting from /courses
$course_sys_dir = api_get_path(SYS_COURSE_PATH).$course_rel_dir; // The absolute system path of this course.
$current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/
if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Current_dir = '.$current_dir, 0); }
if ($this->debug > 0) {
error_log('New LP - aicc::import_package() - Current_dir = '.$current_dir, 0);
}
//$uploaded_filename = $_FILES['userFile']['name'];
//$uploaded_filename = $_FILES['userFile']['name'];
// Get the name of the zip file without the extension.
if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Received zip file name: '.$zip_file_path, 0); }
if ($this->debug > 0) {
error_log('New LP - aicc::import_package() - Received zip file name: '.$zip_file_path, 0);
}
$file_info = pathinfo($zip_file_name);
$filename = $file_info['basename'];
$extension = $file_info['extension'];
$file_base_name = str_replace('.'.$extension, '', $filename); // Filename without its extension.
$this->zipname = $file_base_name; // Save for later in case we don't have a title.
if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Base file name is : '.$file_base_name, 0); }
if ($this->debug > 0) {
error_log('New LP - aicc::import_package() - Base file name is : '.$file_base_name, 0);
}
$new_dir = api_replace_dangerous_char(trim($file_base_name));
$this->subdir = $new_dir;
if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir, 0); }
if ($this->debug > 0) {
error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir, 0);
}
/*
if (check_name_exist($course_sys_dir.$current_dir.'/'.$new_dir)) {
@ -401,7 +429,11 @@ class aicc extends learnpath
foreach ($zipContentArray as $thisContent) {
if (preg_match('~.(php.*|phtml)$~i', $thisContent['filename'])) {
// If a php file is found, do not authorize (security risk).
if ($this->debug > 1) {error_log('New LP - aicc::import_package() - Found unauthorized file: '.$thisContent['filename'], 0); }
if ($this->debug > 1) {
error_log(
'New LP - aicc::import_package() - Found unauthorized file: '.$thisContent['filename']
);
}
Display::addFlash(
Display::return_message(get_lang('ZipNoPhp'))
);
@ -409,13 +441,19 @@ class aicc extends learnpath
} elseif (preg_match('?.*/aicc/$?', $thisContent['filename'])) {
// If a directory named 'aicc' is found, package type = aicc, but continue,
// because we need to find the right AICC files;
if ($this->debug > 1) { error_log('New LP - aicc::import_package() - Found aicc directory: '.$thisContent['filename'], 0); }
if ($this->debug > 1) {
error_log('New LP - aicc::import_package() - Found aicc directory: '.$thisContent['filename']);
}
$package_type = 'aicc';
} else {
// else, look for one of the files we're searching for (something.crs case insensitive).
$res = array();
if (preg_match('?^(.*)\.(crs|au|des|cst|ore|pre|cmp)$?i', $thisContent['filename'], $res)) {
if ($this->debug > 1) { error_log('New LP - aicc::import_package() - Found AICC config file: '.$thisContent['filename'].'. Now splitting: '.$res[1].' and '.$res[2], 0); }
if ($this->debug > 1) {
error_log(
'New LP - aicc::import_package() - Found AICC config file: '.$thisContent['filename'].'. Now splitting: '.$res[1].' and '.$res[2]
);
}
if ($thisContent['filename'] == basename($thisContent['filename'])) {
if ($this->debug > 2) { error_log('New LP - aicc::import_package() - '.$thisContent['filename'].' is at root level', 0); }
$at_root = true;
@ -449,8 +487,12 @@ class aicc extends learnpath
}
$realFileSize += $thisContent['size'];
}
if ($this->debug > 2) { error_log('New LP - aicc::import_package() - $files_found: '.print_r($files_found, true), 0); }
if ($this->debug > 1) { error_log('New LP - aicc::import_package() - Package type is now '.$package_type, 0); }
if ($this->debug > 2) {
error_log('New LP - aicc::import_package() - $files_found: '.print_r($files_found, true), 0);
}
if ($this->debug > 1) {
error_log('New LP - aicc::import_package() - Package type is now '.$package_type, 0);
}
$mandatory = false;
foreach ($files_found as $file_name => $file_exts) {
$temp = (
@ -460,7 +502,9 @@ class aicc extends learnpath
&& !empty($files_found[$file_name]['cst'])
);
if ($temp) {
if ($this->debug > 1) { error_log('New LP - aicc::import_package() - Found all config files for '.$file_name, 0); }
if ($this->debug > 1) {
error_log('New LP - aicc::import_package() - Found all config files for '.$file_name, 0);
}
$mandatory = true;
$package = $file_name;
// Store base config file name for reuse in parse_config_files().
@ -509,7 +553,9 @@ class aicc extends learnpath
@mkdir($course_sys_dir.$new_dir, api_get_permissions_for_new_directories())
) {
// PHP method - slower...
if ($this->debug >= 1) { error_log('New LP - Changing dir to '.$course_sys_dir.$new_dir, 0); }
if ($this->debug >= 1) {
error_log('New LP - Changing dir to '.$course_sys_dir.$new_dir, 0);
}
$saved_dir = getcwd();
chdir($course_sys_dir.$new_dir);
$unzippingState = $zipFile->extract();
@ -527,12 +573,16 @@ class aicc extends learnpath
}
// Rename files, for example with \\ in it.
if ($dir = @opendir($course_sys_dir.$new_dir)) {
if ($this->debug == 1) { error_log('New LP - Opened dir '.$course_sys_dir.$new_dir, 0); }
if ($this->debug == 1) {
error_log('New LP - Opened dir '.$course_sys_dir.$new_dir, 0);
}
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
$filetype = 'file';
if (is_dir($course_sys_dir.$new_dir.$file)) $filetype = 'folder';
if (is_dir($course_sys_dir.$new_dir.$file)) {
$filetype = 'folder';
}
// TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible!
//$safe_file = api_replace_dangerous_char($file, 'strict');
@ -551,17 +601,16 @@ class aicc extends learnpath
$mybasedir = $mybasedir.$mysubdir.'/';
if (!is_dir($mybasedir)) {
@mkdir($mybasedir, api_get_permissions_for_new_directories());
if ($this->debug == 1) { error_log('New LP - Dir '.$mybasedir.' doesnt exist. Creating.', 0); }
if ($this->debug == 1) {
error_log('New LP - Dir '.$mybasedir.' doesnt exist. Creating.');
}
}
}
}
}
@rename($course_sys_dir.$new_dir.$file, $course_sys_dir.$new_dir.$safe_file);
if ($this->debug == 1) {
error_log(
'New LP - Renaming '.$course_sys_dir.$new_dir.$file.' to '.$course_sys_dir.$new_dir.$safe_file,
0
);
error_log('New LP - Renaming '.$course_sys_dir.$new_dir.$file.' to '.$course_sys_dir.$new_dir.$safe_file);
}
}
}
@ -585,7 +634,9 @@ class aicc extends learnpath
public function set_proximity($proxy = '')
{
$course_id = api_get_course_int_id();
if ($this->debug > 0) { error_log('In aicc::set_proximity('.$proxy.') method', 0); }
if ($this->debug > 0) {
error_log('In aicc::set_proximity('.$proxy.') method', 0);
}
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@ -605,7 +656,9 @@ class aicc extends learnpath
public function set_theme($theme = '')
{
$course_id = api_get_course_int_id();
if ($this->debug > 0) { error_log('In aicc::set_theme('.$theme.') method', 0); }
if ($this->debug > 0) {
error_log('In aicc::set_theme('.$theme.') method', 0);
}
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@ -625,7 +678,9 @@ class aicc extends learnpath
public function set_preview_image($preview_image = '')
{
$course_id = api_get_course_int_id();
if ($this->debug > 0) {error_log('In aicc::set_preview_image('.$preview_image.') method', 0); }
if ($this->debug > 0) {
error_log('In aicc::set_preview_image('.$preview_image.') method', 0);
}
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@ -646,7 +701,9 @@ class aicc extends learnpath
public function set_author($author = '')
{
$course_id = api_get_course_int_id();
if ($this->debug > 0) { error_log('In aicc::set_author('.$author.') method', 0); }
if ($this->debug > 0) {
error_log('In aicc::set_author('.$author.') method', 0);
}
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@ -687,7 +744,9 @@ class aicc extends learnpath
*/
public function export_zip($lp_id = null)
{
if ($this->debug > 0) { error_log('In aicc::export_zip method('.$lp_id.')', 0); }
if ($this->debug > 0) {
error_log('In aicc::export_zip method('.$lp_id.')', 0);
}
if (empty($lp_id)) {
if (!is_object($this)) {
return false;
@ -798,7 +857,9 @@ class aicc extends learnpath
*/
public function reimport_aicc()
{
if ($this->debug > 0) { error_log('In aicc::reimport_aicc() method', 0); }
if ($this->debug > 0) {
error_log('In aicc::reimport_aicc() method', 0);
}
//query current items list
//get the identifiers
//parse the config files

@ -44,14 +44,20 @@ $use_anonymous = true;
// Use session ID as provided by the request.
if (!empty($_REQUEST['aicc_sid'])) {
session_id($_REQUEST['aicc_sid']);
if ($debug > 1) { error_log('New LP - '.__FILE__.','.__LINE__.' - reusing session ID '.$_REQUEST['aicc_sid'], 0); }
if ($debug > 1) {
error_log('New LP - '.__FILE__.','.__LINE__.' - reusing session ID '.$_REQUEST['aicc_sid']);
}
} elseif (!empty($_REQUEST['session_id'])) {
session_id($_REQUEST['session_id']);
if ($debug > 1) { error_log('New LP - '.__FILE__.','.__LINE__.' - reusing session ID '.$_REQUEST['session_id'], 0); }
if ($debug > 1) {
error_log('New LP - '.__FILE__.','.__LINE__.' - reusing session ID '.$_REQUEST['session_id']);
}
}
//Load common libraries using a compatibility script to bridge between 1.6 and 1.8.
require_once __DIR__.'/../inc/global.inc.php';
if ($debug > 2) { error_log('New LP - '.__FILE__.','.__LINE__.' - Current session ID: '.session_id(), 0); }
if ($debug > 2) {
error_log('New LP - '.__FILE__.','.__LINE__.' - Current session ID: '.session_id());
}
// Is this needed? This is probabaly done in the header file.
//$_user = $_SESSION['_user'];

@ -11,7 +11,7 @@
*/
class learnpathItem
{
const DEBUG = 0; // Logging parameter.
const DEBUG = 5; // Logging parameter.
public $attempt_id; // Also called "objectives" SCORM-wise.
public $audio; // The path to an audio file (stored in document/audio/).
public $children = array(); // Contains the ids of children items.
@ -102,8 +102,7 @@ class learnpathItem
if (self::DEBUG > 0) {
error_log(
"learnpathItem constructor: id: $id user_id: ".
"$user_id course_id: $course_id item_content: $item_content",
0
"$user_id course_id: $course_id item_content: ".print_r($item_content, 1)
);
}
$id = intval($id);
@ -1919,10 +1918,10 @@ class learnpathItem
* 0 if it is not allowed but the item has to be finished
* 1 if it is allowed. Defaults to 1
*/
public function is_restart_allowed()
public function isRestartAllowed()
{
if (self::DEBUG > 2) {
error_log('learnpathItem::is_restart_allowed()', 0);
error_log('learnpathItem::isRestartAllowed()', 0);
}
$restart = 1;
$mystatus = $this->get_status(true);
@ -1941,7 +1940,7 @@ class learnpathItem
}
if (self::DEBUG > 2) {
error_log(
'New LP - End of learnpathItem::is_restart_allowed() - Returning '.$restart,
'New LP - End of learnpathItem::isRestartAllowed() - Returning '.$restart,
0
);
}
@ -2004,10 +2003,10 @@ class learnpathItem
/**
* Parses the prerequisites string with the AICC logic language
* @param string $prereqs_string The prerequisites string as it figures in imsmanifest.xml
* @param Array $items Array of items in the current learnpath object.
* @param array $items Array of items in the current learnpath object.
* Although we're in the learnpathItem object, it's necessary to have
* a list of all items to be able to check the current item's prerequisites
* @param Array $refs_list List of references
* @param array $refs_list List of references
* (the "ref" column in the lp_item table) that are strings used in the
* expression of prerequisites.
* @param integer $user_id The user ID. In some cases like Chamilo quizzes,
@ -2031,7 +2030,6 @@ class learnpathItem
// First parse all parenthesis by using a sequential loop
// (looking for less-inclusives first).
if ($prereqs_string == '_true_') {
return true;
}
@ -2374,7 +2372,6 @@ class learnpathItem
isset($items[$refs_list[$prereqs_string]])
) {
if ($items[$refs_list[$prereqs_string]]->type == 'quiz') {
// 1. Checking the status in current items.
$status = $items[$refs_list[$prereqs_string]]->get_status(true);
$returnstatus = $status == $this->possible_status[2] || $status == $this->possible_status[3];
@ -2674,7 +2671,7 @@ class learnpathItem
}
$this->save();
$allowed = $this->is_restart_allowed();
$allowed = $this->isRestartAllowed();
if ($allowed === -1) {
// Nothing allowed, do nothing.
} elseif ($allowed === 1) {
@ -2857,7 +2854,8 @@ class learnpathItem
// Do nothing, just let the local attributes be used.
}
}
} else { // If not SCO, such messages should not be expected.
} else {
// If not SCO, such messages should not be expected.
$type = strtolower($this->type);
switch ($type) {
case 'asset':
@ -3739,7 +3737,6 @@ class learnpathItem
);
}
$this->db_item_view_id = Database::insert($item_view_table, $params);
if ($this->db_item_view_id) {
$sql = "UPDATE $item_view_table SET id = iid
WHERE iid = ".$this->db_item_view_id;

@ -95,7 +95,7 @@ $form = new FormValidator(
);
// Form title
$form->addElement('header', get_lang('AddLpToStart'));
$form->addHeader(get_lang('AddLpToStart'));
// Title
$form->addElement(

@ -39,7 +39,7 @@ class scorm extends learnpath
public function __construct($course_code = null, $resource_id = null, $user_id = null)
{
if ($this->debug > 0) {
error_log('New LP - scorm::scorm('.$course_code.','.$resource_id.','.$user_id.') - In scorm constructor', 0);
error_log('New LP - scorm::scorm('.$course_code.','.$resource_id.','.$user_id.') - In scorm constructor');
}
parent::__construct($course_code, $resource_id, $user_id);
@ -65,7 +65,8 @@ class scorm extends learnpath
/**
* Parses an imsmanifest.xml file and puts everything into the $manifest array
* @param string Path to the imsmanifest.xml file on the system. If not defined, uses the base path of the course's scorm dir
* @param string Path to the imsmanifest.xml file on the system.
* If not defined, uses the base path of the course's scorm dir
* @return array Structured array representing the imsmanifest's contents
*/
public function parse_manifest($file = '')
@ -79,7 +80,9 @@ class scorm extends learnpath
if (is_file($file) && is_readable($file) && ($xml = @file_get_contents($file))) {
// Parsing using PHP5 DOMXML methods.
if ($this->debug > 0) { error_log('In scorm::parse_manifest() - Parsing using PHP5 method', 0); }
if ($this->debug > 0) {
error_log('In scorm::parse_manifest() - Parsing using PHP5 method');
}
//$this->manifest_encoding = api_detect_encoding_xml($xml); // This is the usual way for reading the encoding.
// This method reads the encoding, it tries to be correct even in cases of wrong or missing encoding declarations.
$this->manifest_encoding = self::detect_manifest_encoding($xml);
@ -90,7 +93,7 @@ class scorm extends learnpath
$res = @$doc->loadXML($xml);
if ($res === false) {
if ($this->debug > 0) {
error_log('New LP - In scorm::parse_manifest() - Exception thrown when loading '.$file.' in DOMDocument', 0);
error_log('New LP - In scorm::parse_manifest() - Exception thrown when loading '.$file.' in DOMDocument');
}
// Throw exception?
return null;
@ -160,7 +163,11 @@ class scorm extends learnpath
foreach ($organizations_attributes as $orgs_attr) {
$this->organizations_att[$orgs_attr->name] = $orgs_attr->value;
}
$oOrganization = new scormOrganization('manifest', $orgnode, $this->manifest_encoding);
$oOrganization = new scormOrganization(
'manifest',
$orgnode,
$this->manifest_encoding
);
if ($oOrganization->identifier != '') {
$name = $oOrganization->get_name();
if (empty($name)) {
@ -211,7 +218,9 @@ class scorm extends learnpath
unset($doc);
// End parsing using PHP5 DOMXML methods.
} else {
if ($this->debug > 1) { error_log('New LP - Could not open/read file '.$file, 0); }
if ($this->debug > 1) {
error_log('New LP - Could not open/read file '.$file);
}
$this->set_error_msg("File $file could not be read");
return null;
}
@ -264,6 +273,7 @@ class scorm extends learnpath
* @param string $courseCode
* @param int $userMaxScore
* @param int $sessionId
* @param int $userId
*
* @return bool Returns -1 on error
*/
@ -445,7 +455,9 @@ class scorm extends learnpath
VALUES ($courseId, $lp_id, '$type', '$identifier', '$title', '$path' , 0, $max_score, $value_add $parent, $previous, 0, '$prereq', ".$item['rel_order'].", '".$item['datafromlms']."', '".$item['parameters']."' )";
Database::query($sql);
if ($this->debug > 1) { error_log('New LP - In import_manifest(), inserting item : '.$sql, 0); }
if ($this->debug > 1) {
error_log('New LP - In import_manifest(), inserting item : '.$sql);
}
$item_id = Database::insert_id();
if ($item_id) {
@ -565,17 +577,18 @@ class scorm extends learnpath
}
// Get name of the zip file without the extension.
if ($this->debug > 1) { error_log('New LP - Received zip file name: '.$zip_file_path, 0); }
$file_info = pathinfo($zip_file_name);
$filename = $file_info['basename'];
$extension = $file_info['extension'];
$file_base_name = str_replace('.'.$extension, '', $filename); // Filename without its extension.
$this->zipname = $file_base_name; // Save for later in case we don't have a title.
if ($this->debug > 1) { error_log("New LP - base file name is : ".$file_base_name, 0); }
$new_dir = api_replace_dangerous_char(trim($file_base_name));
$this->subdir = $new_dir;
if ($this->debug > 1) { error_log("New LP - subdir is first set to : ".$this->subdir, 0); }
if ($this->debug > 1) {
error_log('New LP - Received zip file name: '.$zip_file_path);
error_log("New LP - subdir is first set to : ".$this->subdir);
error_log("New LP - base file name is : ".$file_base_name);
}
$zipFile = new PclZip($zip_file_path);
@ -599,7 +612,9 @@ class scorm extends learnpath
if ($thisContent['filename'] == basename($thisContent['filename'])) {
$at_root = true;
} else {
if ($this->debug > 2) { error_log("New LP - subdir is now ".$this->subdir, 0); }
if ($this->debug > 2) {
error_log("New LP - subdir is now ".$this->subdir);
}
}
$package_type = 'scorm';
$manifest_list[] = $thisContent['filename'];
@ -623,10 +638,13 @@ class scorm extends learnpath
$this->subdir .= '/'.dirname($shortest_path); // Do not concatenate because already done above.
$manifest = $shortest_path;
if ($this->debug > 1) { error_log('New LP - Package type is now '.$package_type, 0); }
if ($this->debug > 1) {
error_log('New LP - Package type is now '.$package_type);
}
if ($package_type == '') {
// && defined('CHECK_FOR_SCORM') && CHECK_FOR_SCORM)
if ($this->debug > 1) { error_log('New LP - Package type is empty', 0); }
if ($this->debug > 1) {
error_log('New LP - Package type is empty');
}
Display::addFlash(
Display::return_message(get_lang('NotScormContent'))
);
@ -635,7 +653,9 @@ class scorm extends learnpath
}
if (!enough_size($realFileSize, $course_sys_dir, $maxFilledSpace)) {
if ($this->debug > 1) { error_log('New LP - Not enough space to store package', 0); }
if ($this->debug > 1) {
error_log('New LP - Not enough space to store package');
}
Display::addFlash(
Display::return_message(get_lang('NoSpace'))
);
@ -664,7 +684,9 @@ class scorm extends learnpath
@mkdir($course_sys_dir.$new_dir, api_get_permissions_for_new_directories())
) {
// PHP method - slower...
if ($this->debug >= 1) { error_log('New LP - Changing dir to '.$course_sys_dir.$new_dir, 0); }
if ($this->debug >= 1) {
error_log('New LP - Changing dir to '.$course_sys_dir.$new_dir);
}
$saved_dir = getcwd();
chdir($course_sys_dir.$new_dir);
$unzippingState = $zipFile->extract();
@ -673,7 +695,9 @@ class scorm extends learnpath
$state = $unzippingState[$j];
// TODO: Fix relative links in html files (?)
$extension = strrchr($state['stored_filename'], '.');
if ($this->debug >= 1) { error_log('New LP - found extension '.$extension.' in '.$state['stored_filename'], 0); }
if ($this->debug >= 1) {
error_log('New LP - found extension '.$extension.' in '.$state['stored_filename']);
}
}
if (!empty($new_dir)) {
@ -681,10 +705,14 @@ class scorm extends learnpath
}
// Rename files, for example with \\ in it.
if ($this->debug >= 1) { error_log('New LP - try to open: '.$course_sys_dir.$new_dir, 0); }
if ($this->debug >= 1) {
error_log('New LP - try to open: '.$course_sys_dir.$new_dir);
}
if ($dir = @opendir($course_sys_dir.$new_dir)) {
if ($this->debug >= 1) { error_log('New LP - Opened dir '.$course_sys_dir.$new_dir, 0); }
if ($this->debug >= 1) {
error_log('New LP - Opened dir '.$course_sys_dir.$new_dir);
}
while ($file = readdir($dir)) {
if ($file != '.' && $file != '..') {
$filetype = 'file';
@ -699,8 +727,10 @@ class scorm extends learnpath
$repl_str = array('/', '.txt', '.txt');
$safe_file = str_replace($find_str, $repl_str, $file);
if ($this->debug >= 1) { error_log('Comparing: '.$safe_file, 0); }
if ($this->debug >= 1) { error_log('and: '.$file, 0); }
if ($this->debug >= 1) {
error_log('Comparing: '.$safe_file);
error_log('and: '.$file);
}
if ($safe_file != $file) {
$mydir = dirname($course_sys_dir.$new_dir.$safe_file);
@ -712,13 +742,19 @@ class scorm extends learnpath
$mybasedir = $mybasedir.$mysubdir.'/';
if (!is_dir($mybasedir)) {
@mkdir($mybasedir, api_get_permissions_for_new_directories());
if ($this->debug >= 1) { error_log('New LP - Dir '.$mybasedir.' doesnt exist. Creating.', 0); }
if ($this->debug >= 1) {
error_log('New LP - Dir '.$mybasedir.' doesnt exist. Creating.');
}
}
}
}
}
@rename($course_sys_dir.$new_dir.$file, $course_sys_dir.$new_dir.$safe_file);
if ($this->debug >= 1) { error_log('New LP - Renaming '.$course_sys_dir.$new_dir.$file.' to '.$course_sys_dir.$new_dir.$safe_file, 0); }
if ($this->debug >= 1) {
error_log(
'New LP - Renaming '.$course_sys_dir.$new_dir.$file.' to '.$course_sys_dir.$new_dir.$safe_file
);
}
}
}
}
@ -727,10 +763,11 @@ class scorm extends learnpath
chdir($saved_dir);
api_chmod_R($course_sys_dir.$new_dir, api_get_permissions_for_new_directories());
if ($this->debug > 1) { error_log('New LP - changed back to init dir: '.$course_sys_dir.$new_dir, 0); }
if ($this->debug > 1) {
error_log('New LP - changed back to init dir: '.$course_sys_dir.$new_dir);
}
}
} else {
return '';
}
@ -741,11 +778,14 @@ class scorm extends learnpath
* Sets the proximity setting in the database
* @param string Proximity setting
* @param int $courseId
* @return bool
*/
public function set_proximity($proxy = '', $courseId = null)
{
$courseId = empty($courseId) ? api_get_course_int_id() : intval($courseId);
if ($this->debug > 0) { error_log('In scorm::set_proximity('.$proxy.') method', 0); }
if ($this->debug > 0) {
error_log('In scorm::set_proximity('.$proxy.') method');
}
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@ -761,11 +801,14 @@ class scorm extends learnpath
/**
* Sets the theme setting in the database
* @param string theme setting
* @return bool
*/
public function set_theme($theme = '')
{
$courseId = api_get_course_int_id();
if ($this->debug > 0) { error_log('In scorm::set_theme('.$theme.') method', 0); }
if ($this->debug > 0) {
error_log('In scorm::set_theme('.$theme.') method');
}
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@ -781,11 +824,14 @@ class scorm extends learnpath
/**
* Sets the image setting in the database
* @param string preview_image setting
* @param bool
*/
public function set_preview_image($preview_image = '')
{
$courseId = api_get_course_int_id();
if ($this->debug > 0) { error_log('In scorm::set_theme('.$preview_image.') method', 0); }
if ($this->debug > 0) {
error_log('In scorm::set_theme('.$preview_image.') method', 0);
}
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@ -800,12 +846,15 @@ class scorm extends learnpath
/**
* Sets the author setting in the database
* @param string preview_image setting
* @param string $author
* @param bool
*/
public function set_author($author = '')
{
$courseId = api_get_course_int_id();
if ($this->debug > 0) { error_log('In scorm::set_author('.$author.') method', 0); }
if ($this->debug > 0) {
error_log('In scorm::set_author('.$author.') method', 0);
}
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@ -825,7 +874,9 @@ class scorm extends learnpath
public function set_maker($maker = '', $courseId = null)
{
$courseId = empty($courseId) ? api_get_course_int_id() : intval($courseId);
if ($this->debug > 0) { error_log('In scorm::set_maker method('.$maker.')', 0); }
if ($this->debug > 0) {
error_log('In scorm::set_maker method('.$maker.')', 0);
}
$lp = $this->get_id();
if ($lp != 0) {
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
@ -845,7 +896,9 @@ class scorm extends learnpath
*/
public function export_zip($lp_id = null)
{
if ($this->debug > 0) { error_log('In scorm::export_zip method('.$lp_id.')', 0); }
if ($this->debug > 0) {
error_log('In scorm::export_zip method('.$lp_id.')');
}
if (empty($lp_id)) {
if (!is_object($this)) {
return false;
@ -863,9 +916,7 @@ class scorm extends learnpath
$courseId = api_get_course_int_id();
$_course = api_get_course_info();
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
$sql = "SELECT * FROM $tbl_lp WHERE c_id = ".$courseId." AND id=".$lp_id;
$result = Database::query($sql);
$row = Database::fetch_array($result);
@ -903,7 +954,9 @@ class scorm extends learnpath
*/
public function get_res_path($id)
{
if ($this->debug > 0) { error_log('In scorm::get_res_path('.$id.') method', 0); }
if ($this->debug > 0) {
error_log('In scorm::get_res_path('.$id.') method');
}
$path = '';
if (isset($this->resources[$id])) {
$oRes = & $this->resources[$id];
@ -914,12 +967,14 @@ class scorm extends learnpath
/**
* Gets a resource's type if available, otherwise return empty string
* @param string Resource ID as used in resource array
* @return string The resource's type as declared in imsmanifest.xml
* @param string Resource ID as used in resource array
* @return string The resource's type as declared in imsmanifest.xml
*/
public function get_res_type($id)
{
if ($this->debug > 0) { error_log('In scorm::get_res_type('.$id.') method', 0); }
if ($this->debug > 0) {
error_log('In scorm::get_res_type('.$id.') method');
}
$type = '';
if (isset($this->resources[$id])) {
$oRes = & $this->resources[$id];
@ -937,7 +992,9 @@ class scorm extends learnpath
*/
public function get_title()
{
if ($this->debug > 0) { error_log('In scorm::get_title() method', 0); }
if ($this->debug > 0) {
error_log('In scorm::get_title() method');
}
$title = '';
if (isset($this->manifest['organizations']['default'])) {
$title = $this->organizations[$this->manifest['organizations']['default']]->get_name();
@ -955,8 +1012,8 @@ class scorm extends learnpath
* // TODO @TODO Implement this function to restore items data from an imsmanifest,
* updating the existing table... This will prove very useful in case initial data
* from imsmanifest were not imported well enough
* @param string course Code
* @param string LP ID (in database)
* @param string $courseCode
* @param int LP ID (in database)
* @param string Manifest file path (optional if lp_id defined)
* @return integer New LP ID or false on failure
* TODO @TODO Implement imsmanifest_path parameter
@ -977,7 +1034,9 @@ class scorm extends learnpath
$lp_table = Database::get_course_table(TABLE_LP_MAIN);
$lp_id = intval($lp_id);
$sql = "SELECT * FROM $lp_table WHERE c_id = ".$courseId." AND id = '$lp_id'";
if ($this->debug > 2) { error_log('New LP - scorm::reimport_manifest() '.__LINE__.' - Querying lp: '.$sql, 0); }
if ($this->debug > 2) {
error_log('New LP - scorm::reimport_manifest() '.__LINE__.' - Querying lp: '.$sql);
}
$res = Database::query($sql);
if (Database::num_rows($res) > 0) {
$this->lp_id = $lp_id;
@ -1008,13 +1067,19 @@ class scorm extends learnpath
echo $manifest_file;
if (is_file($manifest_file) && is_readable($manifest_file)) {
// Re-parse the manifest file.
if ($this->debug > 1) { error_log('New LP - In scorm::reimport_manifest() - Parsing manifest '.$manifest_file, 0); }
if ($this->debug > 1) {
error_log('New LP - In scorm::reimport_manifest() - Parsing manifest '.$manifest_file);
}
$manifest = $this->parse_manifest($manifest_file);
// Import new LP in DB (ignore the current one).
if ($this->debug > 1) { error_log('New LP - In scorm::reimport_manifest() - Importing manifest '.$manifest_file, 0); }
if ($this->debug > 1) {
error_log('New LP - In scorm::reimport_manifest() - Importing manifest '.$manifest_file);
}
$this->import_manifest($this->cc);
} else {
if ($this->debug > 0) { error_log('New LP - In scorm::reimport_manifest() - Could not find manifest file at '.$manifest_file, 0); }
if ($this->debug > 0) {
error_log('New LP - In scorm::reimport_manifest() - Could not find manifest file at '.$manifest_file);
}
}
return false;
}

@ -55,7 +55,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'add') {
// we add a user only if is a open group
$user_join = intval($_GET['u']);
//if i'm a moderator
if ($userGroup->is_group_moderator($group_id)) {
if ($userGroup->isGroupModerator($group_id)) {
$userGroup->update_user_role($user_join, $group_id);
Display::addFlash(Display::return_message(get_lang('UserAdded')));
}
@ -65,7 +65,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'delete') {
// we add a user only if is a open group
$user_join = intval($_GET['u']);
//if i'm a moderator
if ($userGroup->is_group_moderator($group_id)) {
if ($userGroup->isGroupModerator($group_id)) {
$userGroup->delete_user_rel_group($user_join, $group_id);
Display::addFlash(Display::return_message(get_lang('UserDeleted')));
}

@ -51,7 +51,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'accept') {
// we add a user only if is a open group
$user_join = intval($_GET['u']);
//if i'm a moderator
if ($usergroup->is_group_moderator($group_id)) {
if ($usergroup->isGroupModerator($group_id)) {
$usergroup->update_user_role($user_join, $group_id);
Display::addFlash(Display::return_message(get_lang('UserAdded')));
}
@ -61,7 +61,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'deny') {
// we add a user only if is a open group
$user_join = intval($_GET['u']);
//if i'm a moderator
if ($usergroup->is_group_moderator($group_id)) {
if ($usergroup->isGroupModerator($group_id)) {
$usergroup->delete_user_rel_group($user_join, $group_id);
Display::addFlash(Display::return_message(get_lang('UserDeleted')));
}

Loading…
Cancel
Save