Ejemplo n.º 1
0
 public function getResourceName(ResourceLocator $locator)
 {
     if ($locator->hasResourceId()) {
         $parts = explode('/', ltrim($locator->getResourceId(), '/'));
         $tbl = get_module_course_tbl(array('wiki_properties'), $locator->getCourseId());
         if (count($parts) == 1) {
             $sql = "SELECT `title`\n" . "FROM `" . $tbl['wiki_properties'] . "`\n" . "WHERE `id` = " . (int) $parts[0];
             $res = Claroline::getDatabase()->query($sql);
             $res->setFetchMode(Database_ResultSet::FETCH_VALUE);
             return $res->fetch();
         } elseif (count($parts) == 2) {
             $sql = "SELECT `title`\n" . "FROM `" . $tbl['wiki_properties'] . "`\n" . "WHERE `id` = " . (int) $parts[0];
             $res = Claroline::getDatabase()->query($sql);
             $res->setFetchMode(Database_ResultSet::FETCH_VALUE);
             $pageName = $parts[1] == '__MainPage__' ? get_lang("Main page") : rawurldecode($parts[1]);
             return $res->fetch() . ' > ' . $pageName;
         } else {
             $moduleName = get_module_data('CLWIKI', 'moduleName');
             return get_lang($moduleName);
         }
     } else {
         $moduleName = get_module_data('CLWIKI', 'moduleName');
         return get_lang($moduleName);
     }
 }
Ejemplo n.º 2
0
 /**
  *
  * @param AuthProfile $userAuthProfile profile of the user we want to enrol to the cours
  * @param Claro_Course $course kernel object representing the course
  * @param type $givenCourseKey optionnal given registration key (default null)
  * @param type $categoryId optionnal given categoryId (default null)
  */
 public function __construct(AuthProfile $userAuthProfile, Claro_Course $course, $givenCourseKey = null, $categoryId = null)
 {
     $this->userAuthProfile = $userAuthProfile;
     $this->course = $course;
     $this->givenCourseKey = $givenCourseKey;
     $this->categoryId = $categoryId;
     // is the user doing the registration a super user ?
     if (claro_is_in_a_course() && claro_get_current_course_id() == $this->course->courseId) {
         $this->isSuperUser = claro_is_platform_admin() || claro_is_course_manager() || claro_is_allowed_tool_edit(get_module_data('CLUSER', 'id'));
     } else {
         $this->isSuperUser = claro_is_platform_admin();
     }
 }
Ejemplo n.º 3
0
 public function getResourceName(ResourceLocator $locator)
 {
     if ($locator->hasResourceId()) {
         $assignementId = $locator->getResourceId();
         $tbl = get_module_course_tbl(array('wrk_assignment'), $locator->getCourseId());
         $sql = "SELECT `title`\n" . "FROM `" . $tbl['wrk_assignment'] . "`\n" . "WHERE `id` = " . (int) $assignementId;
         $res = Claroline::getDatabase()->query($sql);
         $res->setFetchMode(Database_ResultSet::FETCH_VALUE);
         return $res->fetch();
     } else {
         $moduleName = get_module_data('CLWRK', 'moduleName');
         return get_lang($moduleName);
     }
 }
Ejemplo n.º 4
0
 protected function isModuleAllowed()
 {
     $moduleData = get_module_data($this->moduleLabel);
     if ($moduleData['type'] == 'tool') {
         $contextList = get_module_context_list($this->moduleLabel);
         if (claro_is_in_a_course()) {
             $_mainToolId = get_tool_id_from_module_label($this->moduleLabel);
             $_profileId = claro_get_current_user_profile_id_in_course();
             $_cid = claro_get_current_course_id();
             if (claro_is_in_a_group()) {
                 $_groupProperties = claro_get_main_group_properties(claro_get_current_course_id());
                 $_mainToolId = get_tool_id_from_module_label('CLGRP');
                 $is_toolAllowed = array_key_exists($this->moduleLabel, $_groupProperties['tools']) && $_groupProperties['tools'][$this->moduleLabel] && claro_is_allowed_tool_read($_mainToolId, $_profileId, $_cid);
                 if ($_groupProperties['private']) {
                     $is_toolAllowed = $is_toolAllowed && (claro_is_group_member() || claro_is_group_tutor());
                 }
                 $is_toolAllowed = $is_toolAllowed || (claro_is_course_manager() || claro_is_platform_admin());
             } else {
                 // we ignore course visibility
                 if (!claro_is_allowed_tool_edit($_mainToolId, $_profileId, $_cid) && !claro_is_allowed_tool_read($_mainToolId, $_profileId, $_cid)) {
                     $is_toolAllowed = false;
                 } else {
                     $is_toolAllowed = true;
                 }
             }
         } else {
             if (in_array('platform', iterator_to_array($contextList))) {
                 $is_toolAllowed = get_module_data($this->moduleLabel, 'activation') == 'activated';
             } else {
                 $is_toolAllowed = false;
             }
         }
         return $is_toolAllowed;
     } else {
         // if an applet "tool", return true if activated
         // and let module manage it's access by itself
         return $moduleData['activation'] == 'activated';
     }
 }
 /**
  * get module info from source
  * @param $source
  */
 private function fetch_module_info($source)
 {
     global $wp_filesystem;
     if (is_wp_error($source)) {
         return $source;
     }
     $working_directory = str_replace($wp_filesystem->wp_content_dir(), trailingslashit(WP_CONTENT_DIR), $source);
     if (!is_dir($working_directory)) {
         // Sanity check, if the above fails, let's not prevent installation.
         return $source;
     }
     // Check the folder contains at least 1 valid plugin.
     $files = glob($working_directory . '/*.php');
     if ($files) {
         foreach ($files as $file) {
             $info = get_module_data($file);
             if (!empty($info['name'])) {
                 if (!isset($info['slug'])) {
                     $info['slug'] = basename(dirname($file));
                 }
                 return $info;
                 break;
             }
         }
     }
     return $source;
 }
Ejemplo n.º 6
0
<?php

// $Id: index.php 13718 2011-10-20 09:24:38Z ffervaille $
require '../inc/claro_init_global.inc.php';
FromKernel::uses('utils/input.lib', 'utils/validator.lib');
$module = Claro_UserInput::getInstance()->get('module');
$block = Claro_UserInput::getInstance()->get('block');
if (!empty($module) && $module != 'platform' && file_exists(get_module_path($module) . '/templates/help.tpl.php')) {
    $tpl = new ModuleTemplate($module, 'help.tpl.php ');
} else {
    $tpl = new CoreTemplate('help.tpl.php');
}
if ($moduleName = get_module_data($module, 'moduleName')) {
    load_module_language($module);
    $tpl->assign('module', $moduleName);
} else {
    $tpl->assign('module', $module);
}
$tpl->assign('block', $block);
$claroline->setDisplayType(Claroline::POPUP);
$claroline->display->header->setTitle(get_lang('Claroline help'));
$claroline->display->body->appendContent($tpl->render());
echo $claroline->display->render();
Ejemplo n.º 7
0
 /**
  * diplay a received message
  *
  * @param ReceivedMessage $message Message to display
  * @param string $action list of action autorised on the message
  * @return string HTML source
  */
 private static function displayReceivedMessage($message, $action)
 {
     $content = '<div id="im_message">' . "\n" . '<h4 class="header">' . claro_htmlspecialchars($message->getSubject()) . '</h4>' . "\n" . '<div class="imInfoBlock">' . "\n" . '<div class="imCmdList">' . $action . '</div>' . "\n\n" . '<div class="imInfo">' . "\n" . ' <span class="imInfoTitle">' . get_lang('Sender') . ' : </span>' . "\n" . ' <span class="imInfoValue">';
     $isAllowed = current_user_is_allowed_to_send_message_to_user($message->getSender());
     if ($isAllowed) {
         $content .= '<a href="sendmessage.php?cmd=rqMessageToUser&amp;userId=' . $message->getSender() . '">';
     }
     $content .= get_lang('%firstName %lastName', array('%firstName' => claro_htmlspecialchars($message->getSenderFirstName()), '%lastName' => claro_htmlspecialchars($message->getSenderLastName())));
     if ($isAllowed) {
         $content .= "</a>";
     }
     $isManager = FALSE;
     $isAdmin = claro_is_user_platform_admin($message->getSender());
     if (!is_null($message->getCourseCode())) {
         $isManager = claro_is_user_course_manager($message->getSender(), $message->getCourseCode());
     }
     if ($isManager) {
         $content .= '&nbsp;<img src="' . get_icon_url('manager') . '" alt="" />';
     } elseif ($isAdmin) {
         $content .= '&nbsp;<img src="' . get_icon_url('platformadmin') . '" alt="" />';
     } else {
         $content .= '&nbsp;<img src="' . get_icon_url('user') . '" alt="" />';
     }
     $content .= '' . ' </span>' . "\n" . '</div>' . "\n\n" . '<div class="imInfo">' . "\n" . '<span class="imInfoTitle">' . get_lang('Date') . ' : </span>' . "\n" . '<span class="imInfoValue">' . claro_html_localised_date(get_locale('dateTimeFormatLong'), strtotime($message->getSendTime())) . '</span>' . "\n" . '</div>' . "\n\n";
     if (!is_null($message->getCourseCode())) {
         $content .= '<div class="imInfo">' . "\n" . ' <span class="imInfoTitle">' . get_lang('Course') . '</span>' . "\n" . ' <span class="imInfoValue">' . "\n";
         $courseData = claro_get_course_data($message->getCourseCode());
         if ($courseData) {
             $content .= claro_htmlspecialchars($courseData['officialCode']) . ' - ' . claro_htmlspecialchars($courseData['name']);
         } else {
             $content .= '?';
         }
         $content .= ' </span>' . "\n" . '</div>' . "\n\n";
         if (!is_null($message->getGroupId())) {
             $content .= '<div class="imInfo">' . "\n" . ' <span class="imInfoTitle">' . get_lang('Group') . ' : </span>' . "\n" . ' <span class="imInfoValue">' . "\n";
             $groupData = claro_get_group_data(array(CLARO_CONTEXT_COURSE => $message->getCourseCode(), CLARO_CONTEXT_GROUP => $message->getGroupId()));
             if ($groupData) {
                 $content .= $groupData['name'];
             } else {
                 $content .= '?';
             }
             $content .= ' </span>' . "\n" . '</div>' . "\n\n";
         }
         if (!is_null($message->getToolsLabel())) {
             $content .= '<div class="imInfo">' . "\n" . ' <span class="imInfoTitle">' . get_lang('Tool') . ' : </span>' . "\n" . ' <span class="imInfoValue">' . "\n";
             $md = get_module_data($message->getToolsLabel());
             if ($md) {
                 $content .= get_lang($md['moduleName']);
             } else {
                 $content .= '?';
             }
             $content .= ' </span>' . "\n" . '</div>' . "\n\n";
         }
     }
     $body = $message->getMessage();
     $body = claro_html_sanitize_all($body);
     $content .= '</div>' . "\n" . '<div class="imContent">' . claro_parse_user_text($body) . '</div>' . "\n" . '</div>' . "\n\n";
     return $content;
 }
Ejemplo n.º 8
0
/**
 * Return the list of tools for a user
 *
 *  in 1.8 only  CLCAL are both  course tool and user tool.
 *  ie : profile is'nt view as module,
 *  and other course tool can't work outside a course for a user.
 *
 * @param boolean $activeOnly default true
 * @return array of tools
 */
function claro_get_user_tool_list($activeOnly = true)
{
    $toolDataList = array();
    $toolData = get_module_data('CLCAL');
    if (false !== $toolData && (!$activeOnly || $toolData['activation'] != 'desactivated')) {
        $toolData['entry'] = 'myagenda.php';
        $toolDataList[] = $toolData;
    }
    return $toolDataList;
}
Ejemplo n.º 9
0
 public function loadFromModule($moduleLabel, $lib, $media = 'all')
 {
     $lib = secure_file_path($lib);
     $moduleLabel = secure_file_path($moduleLabel);
     if (!get_module_data($moduleLabel)) {
         pushClaroMessage(__CLASS__ . "::{$moduleLabel} does not exists", 'error');
         return false;
     }
     if (claro_debug_mode()) {
         pushClaroMessage(__CLASS__ . "::Try to find {$lib} for {$moduleLabel}", 'debug');
     }
     $cssPath = array(0 => array('path' => get_path('rootSys') . 'platform/css/' . $moduleLabel . '/' . $lib . '.css', 'url' => get_path('url') . '/platform/css/' . $moduleLabel . '/' . $lib . '.css'), 1 => array('path' => get_module_path($moduleLabel) . '/css/' . $lib . '.css', 'url' => get_module_url($moduleLabel) . '/css/' . $lib . '.css'));
     /*$path = get_module_path( $moduleLabel ) . '/css/' . $lib . '.css';
       $url = get_module_url( $moduleLabel ) . '/css/' . $lib . '.css';*/
     foreach ($cssPath as $cssTry) {
         $path = $cssTry['path'];
         $url = $cssTry['url'];
         if (claro_debug_mode()) {
             pushClaroMessage(__CLASS__ . "::Try {$path}::{$url} for {$moduleLabel}", 'debug');
         }
         if (file_exists($path)) {
             if (array_key_exists($path, $this->css)) {
                 return false;
             }
             $this->css[$path] = array('url' => $url . '?' . filemtime($path), 'media' => $media);
             if (claro_debug_mode()) {
                 pushClaroMessage(__CLASS__ . "::Use {$path}::{$url} for {$moduleLabel}", 'debug');
             }
             ClaroHeader::getInstance()->addHtmlHeader('<link rel="stylesheet" type="text/css"' . ' href="' . $url . '"' . ' media="' . $media . '" />');
             return true;
         } else {
             if (claro_debug_mode()) {
                 pushClaroMessage(__CLASS__ . "::Cannot found css {$lib} for {$moduleLabel}", 'error');
             }
             return false;
         }
     }
 }
Ejemplo n.º 10
0
 /*---------------------------------------------------------------------
    Upgrade 1.9 to 1.10
   ---------------------------------------------------------------------*/
 if (preg_match('/^1.9/', $currentCourseVersion)) {
     // Function to upgrade tool to 1.10
     $function_list = array();
     $toolCLANN = get_module_data('CLANN');
     if (is_tool_activated_in_course($toolCLANN['id'], $currentCourseCode)) {
         $function_list[] = 'announcements_upgrade_to_110';
     }
     $toolCLCAL = get_module_data('CLCAL');
     if (is_tool_activated_in_course($toolCLCAL['id'], $currentCourseCode)) {
         $function_list[] = 'calendar_upgrade_to_110';
     }
     $function_list[] = 'tool_intro_upgrade_to_110';
     $toolCLQWZ = get_module_data('CLQWZ');
     if (is_tool_activated_in_course($toolCLQWZ['id'], $currentCourseCode)) {
         $function_list[] = 'exercise_upgrade_to_110';
     }
     foreach ($function_list as $function) {
         $step = $function($currentCourseCode);
         if ($step > 0) {
             echo 'Error : ' . $function . ' at step ' . $step . '<br />';
             $error = true;
         }
     }
     if (!$error) {
         // Upgrade succeeded
         clean_upgrade_status($currentCourseCode);
         $currentCourseVersion = '1.10';
     } else {
Ejemplo n.º 11
0
 public function getResourceName(ResourceLocator $locator)
 {
     return get_lang(get_module_data($locator->getModuleLabel(), 'moduleName'));
 }
Ejemplo n.º 12
0
/**
 * Get module entry filename
 * @param string $claroLabel module label
 * @return string
 */
function get_module_entry($claroLabel)
{
    return get_module_data($claroLabel, 'entry');
}
Ejemplo n.º 13
0
                $cidReset = TRUE;
                $cidReq = claro_get_current_course_id();
                include get_path('incRepositorySys') . '/claro_init_local.inc.php';
            } else {
                $dialogBox->error(get_lang('Cannot remove tool from course'));
            }
        } else {
            $dialogBox->error(get_lang('Not a valid tool'));
        }
    }
}
if ('exAddTool' == $cmd) {
    if (is_null($toolLabel)) {
        $dialogBox->error(get_lang('Missing tool label'));
    } else {
        $moduleData = get_module_data($toolLabel);
        if ($moduleData['access_manager'] == 'COURSE_ADMIN' || claro_is_platform_admin()) {
            // get tool id
            $toolId = get_tool_id_from_module_label($toolLabel);
            if ($toolId) {
                if (!is_module_registered_in_course($toolId, claro_get_current_course_id())) {
                    register_module_in_single_course($toolId, claro_get_current_course_id());
                }
                // update course_tool.activated
                if (update_course_tool_activation_in_course($toolId, claro_get_current_course_id(), true)) {
                    set_module_visibility_in_course($toolId, $_cid, true);
                    $dialogBox->success(get_lang('Tool added to course'));
                    $cidReset = TRUE;
                    $cidReq = claro_get_current_course_id();
                    $groupToolList = get_group_tool_label_list();
                    foreach ($groupToolList as $group) {
Ejemplo n.º 14
0
function claro_is_module_allowed()
{
    if (!array_key_exists('tlabelReq', $GLOBALS)) {
        return claro_failure::set_failure('MISSING TOOL LABEL');
    }
    $moduleLabel = $GLOBALS['tlabelReq'];
    $moduleData = get_module_data($moduleLabel);
    if ($moduleData['type'] == 'tool') {
        $contextList = get_module_context_list($moduleLabel);
        // pushClaroMessage(var_export(iterator_to_array($contextList), true),'kernel');
        if (!claro_is_in_a_course() && in_array('platform', iterator_to_array($contextList))) {
            return get_module_data($moduleLabel, 'activation') == 'activated';
        }
        // if a course tool, use claro_is_tool_allowed
        return claro_is_tool_allowed();
    } else {
        // if an applet "tool", return true if activated
        // and let module manage it's access by itself
        return $moduleData['activation'] == 'activated';
    }
}
Ejemplo n.º 15
0
 foreach ($box as $key => $message) {
     $recipientList = $message->getRecipientList();
     $content .= '<tr';
     if ($message->isPlatformMessage()) {
         $content .= ' class="platformMessage"';
     }
     $content .= '><td>';
     if ($message->isPlatformMessage()) {
         $content .= '<img src="' . get_icon_url('important') . '" alt="" />';
     }
     if (!is_null($message->getCourseCode())) {
         $courseData = claro_get_course_data($message->getCourseCode());
         if ($courseData) {
             $content .= '<span class="im_context">' . '[' . $courseData['officialCode'];
             if (!is_null($message->getToolsLabel())) {
                 $md = get_module_data($message->getToolsLabel());
                 $content .= ' - ' . get_lang($md['moduleName']);
             }
             $content .= ']</span> ';
         }
     }
     $content .= ' <a href="readmessage.php?messageId=' . $message->getId() . '&amp;type=sent&amp;userId=' . $currentUserId . '">';
     $content .= claro_htmlspecialchars($message->getSubject()) . '</a></td>' . "\n" . '<td>';
     if ($recipientList['sentTo'] == 'toUser') {
         $content .= claro_htmlspecialchars($recipientList['userList'][0]['firstName']) . " " . claro_htmlspecialchars($recipientList['userList'][0]['lastName']);
         if (count($recipientList['userList']) > 1) {
             $content .= ", " . claro_htmlspecialchars($recipientList['userList'][1]['firstName']) . " " . claro_htmlspecialchars($recipientList['userList'][1]['lastName']);
         }
         if (count($recipientList['userList']) > 2) {
             $content .= ",...";
         }
Ejemplo n.º 16
0
function upgrade_chat_to_19()
{
    global $includePath;
    // activate new module to replace the old one
    $tool = 'CLCHAT_19';
    switch ($step = get_upgrade_status($tool)) {
        case 1:
            // install new chat
            if (!file_exists($includePath . '/../../module/CLCHAT')) {
                log_message('New Chat module not found : keep the old one !');
                $step = set_upgrade_status($tool, 0);
                return $step;
            }
            list($backLog, $moduleId) = install_module($includePath . '/../../module/CLCHAT', true);
            log_message($backLog->output());
            if ($moduleId) {
                list($backLog, $success) = activate_module_in_platform($moduleId);
                log_message($backLog->output());
            } else {
                return $step;
            }
            if ($success) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
        case 2:
            // remove old chat
            $moduleId = get_module_data('CLCHT', 'id');
            if ($moduleId) {
                list($backLog, $success) = uninstall_module($moduleId);
                log_message($backLog->output());
            } else {
                $success = true;
            }
            if ($success) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
        default:
            $step = set_upgrade_status($tool, 0);
            return $step;
    }
    return false;
}
Ejemplo n.º 17
0
/**
 * delete a list of user id from a list of courses
 * @param array $userIdList list of user id to remove
 * @param array|string $courseCodeList array of course codes or one single course code
 * @param bool $force forece the deletion
 * @param bool $delTrackData delete tracking data
 * @param bool $unregister_by_class unregister by class
 * @return int number of deleted users
 */
function user_remove_userlist_from_course($userIdList, $courseCodeList = array(), $force = false, $delTrackData = false, $unregister_by_class = false)
{
    $tbl = claro_sql_get_main_tbl();
    $userDeletedCount = 0;
    if (!is_array($courseCodeList)) {
        $courseCodeList = array($courseCodeList);
    }
    foreach ($userIdList as $userIdToProcess) {
        $userId = is_numeric($userIdToProcess) ? $userIdToProcess : $userIdToProcess['user_id'];
        if (!$force && $userId == $GLOBALS['_uid']) {
            // PREVIOUSLY CHECK THE USER IS NOT COURSE ADMIN OF THESE COURSES
            $sql = "SELECT COUNT(user_id)\n                    FROM `" . $tbl['rel_course_user'] . "`\n                    WHERE user_id = " . (int) $userId . "\n                      AND isCourseManager = 1\n                      AND code_cours IN ('" . implode("', '", array_map('claro_sql_escape', $courseCodeList)) . "') ";
            if (claro_sql_query_get_single_value($sql) > 0) {
                Claroline::getInstance()->log('DELETE_USER_FAILED', array('USER' => $userId, 'failure' => 'course_manager_cannot_unsubscribe_himself'));
                continue;
            }
        }
        $sql = "SELECT code_cours , count_user_enrol, count_class_enrol\n                FROM `" . $tbl['rel_course_user'] . "`\n                WHERE `code_cours` IN ('" . implode("', '", array_map('claro_sql_escape', $courseCodeList)) . "')\n                AND   `user_id` = " . $userId;
        $userEnrolCourseList = claro_sql_query_fetch_all($sql);
        foreach ($userEnrolCourseList as $thisUserEnrolCourse) {
            $thisCourseCode = $thisUserEnrolCourse['code_cours'];
            $count_user_enrol = $thisUserEnrolCourse['count_user_enrol'];
            $count_class_enrol = $thisUserEnrolCourse['count_class_enrol'];
            if ($count_user_enrol + $count_class_enrol <= 1) {
                // remove user from course
                if (user_remove_from_group($userId, $thisCourseCode) == false) {
                    return false;
                }
                $dbNameGlued = claro_get_course_db_name_glued($thisCourseCode);
                $tbl_cdb_names = claro_sql_get_course_tbl($dbNameGlued);
                $tbl_bb_notify = $tbl_cdb_names['bb_rel_topic_userstonotify'];
                $tbl_group_team = $tbl_cdb_names['group_team'];
                $tbl_userinfo_content = $tbl_cdb_names['userinfo_content'];
                $sqlList = array();
                $toolCLFRM = get_module_data('CLFRM');
                if (is_tool_activated_in_course($toolCLFRM['id'], $thisUserEnrolCourse['code_cours'])) {
                    $sqlList = array("DELETE FROM `" . $tbl_bb_notify . "` WHERE user_id = " . (int) $userId);
                }
                array_push($sqlList, "DELETE FROM `" . $tbl_userinfo_content . "` WHERE user_id = " . (int) $userId, "UPDATE `" . $tbl_group_team . "` SET `tutor` = NULL WHERE `tutor`='" . (int) $userId . "'");
                foreach ($sqlList as $thisSql) {
                    if (claro_sql_query($thisSql) == false) {
                        continue;
                    }
                }
                if ($delTrackData) {
                    if (user_delete_course_tracking_data($userId, $thisCourseCode) == false) {
                        continue;
                    }
                }
                $sql = "DELETE FROM `" . $tbl['rel_course_user'] . "`\n                    WHERE user_id = " . (int) $userId . "\n                      AND code_cours = '" . claro_sql_escape($thisCourseCode) . "'";
                if (claro_sql_query($sql) == false) {
                    continue;
                }
            } else {
                // decrement the count of registration by the user or class
                if (!$unregister_by_class) {
                    $count_user_enrol--;
                } else {
                    $count_class_enrol--;
                }
                // update enrol count in table rel_course_user
                $sql = "UPDATE `" . $tbl['rel_course_user'] . "`\n                          SET `count_user_enrol` = '" . $count_user_enrol . "',\n                            `count_class_enrol` = '" . $count_class_enrol . "'\n                          WHERE `user_id`   =  " . (int) $userId . "\n                          AND  `code_cours` = '" . claro_sql_escape($thisCourseCode) . "'";
                if (!claro_sql_query($sql)) {
                    continue;
                }
            }
        }
        $userDeletedCount++;
    }
    return $userDeletedCount;
}
Ejemplo n.º 18
0
    // 3. compare the two lists and register and install/activate missing tool if necessary
    $listOfToolsToAdd = array();
    foreach ($mainCourseToolList as $thisToolId => $thisMainCourseTool) {
        if (!array_key_exists($thisMainCourseTool['label'], $tmp)) {
            $listOfToolsToAdd[$thisMainCourseTool['label']] = $thisToolId;
        }
    }
    foreach ($listOfToolsToAdd as $toolLabel => $toolId) {
        if (!is_module_registered_in_course($toolId, $_cid)) {
            register_module_in_single_course($toolId, $_cid);
        }
        if (!is_module_installed_in_course($toolLabel, $_cid) && 'AUTOMATIC' == get_module_data($toolLabel, 'add_in_course')) {
            install_module_in_course($toolLabel, $_cid);
        }
        if ('AUTOMATIC' == get_module_data($toolLabel, 'add_in_course')) {
            if ('activated' == get_module_data($toolLabel, 'activation')) {
                update_course_tool_activation_in_course($toolId, $_cid, true);
                set_module_visibility_in_course($toolId, $_cid, true);
            }
        }
    }
}
/*---------------------------------------------------------------------------
  Course / tool relation initialisation
 ---------------------------------------------------------------------------*/
// if the requested tool is different from the current tool in session
// (special request can come from the tool id, or the tool label)
if ($tidReq && $tidReq != $_SESSION['_tid'] || $tlabelReq && (!isset($_SESSION['_courseTool']['label']) || $tlabelReq != $_SESSION['_courseTool']['label'])) {
    $tidReset = true;
}
if ($tidReset || $cidReset) {
Ejemplo n.º 19
0
}
if (isset($tlabelReq) && !empty($tlabelReq)) {
    /*----------------------------------------------------------------------
          Check tool access right an block unautorised users
      ----------------------------------------------------------------------*/
    if (claro_is_course_required() && !claro_is_in_a_course()) {
        claro_disp_auth_form(true);
    }
    if (get_module_data($tlabelReq, 'type') == 'admin' && !claro_is_platform_admin()) {
        if (!claro_is_user_authenticated()) {
            claro_disp_auth_form();
        } else {
            claro_die(get_lang('Not allowed'));
        }
    }
    if (get_module_data($tlabelReq, 'type') == 'crsmanage' && !(claro_is_course_manager() || claro_is_platform_admin())) {
        if (!claro_is_user_authenticated()) {
            claro_disp_auth_form(true);
        } else {
            claro_die(get_lang('Not allowed'));
        }
    }
    if ($tlabelReq !== 'CLWRK' && $tlabelReq !== 'CLGRP' && !claro_is_module_allowed() && !(isset($_SESSION['inPathMode']) && $_SESSION['inPathMode'] && ($tlabelReq == 'CLQWZ' || $tlabelReq == 'CLDOC'))) {
        if (!claro_is_user_authenticated()) {
            claro_disp_auth_form(true);
        } else {
            claro_die(get_lang('Not allowed'));
        }
    }
    if ($tlabelReq !== 'CLGRP' && $tlabelReq !== 'CLWRK' && claro_is_in_a_group() && (!claro_is_group_allowed() || !claro_is_allowed_to_edit() && !is_tool_activated_in_groups($_cid, $tlabelReq))) {
        claro_die(get_lang('Not allowed'));