Пример #1
0
/**
 * Return the list of assigment of the current course
 *
 * @param string coursecode or null (to take default)
 *
 * @return array of array(id,title,description,def_submission_visibility,visibility,assignment_type,start_date_unix,end_date_unix)
 */
function assignmentList($courseCode = null)
{
    $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($courseCode));
    $tbl_wrk_assignment = $tbl_cdb_names['wrk_assignment'];
    $sql = "SELECT    `id`,\n                      `title`,\n                      `description`,\n                      `def_submission_visibility`,\n                      `visibility`,\n                      `assignment_type`,\n               unix_timestamp(`start_date`)\n                   AS `start_date_unix`,\n               unix_timestamp(`end_date`)\n                   AS `end_date_unix`\n               FROM `" . $tbl_wrk_assignment . "`";
    return claro_sql_query_fetch_all_rows($sql);
}
Пример #2
0
 public function loadAll($visibility = false)
 {
     $sql = "SELECT\n                    `label`,\n                    `name`,\n                    `rank`,\n                    `visibility`\n                FROM `" . $this->tblDesktopPortlet . "`\n                WHERE 1 " . ($visibility == true ? "AND visibility = 'visible'" : '') . "ORDER BY `rank` ASC";
     if (false === ($data = claro_sql_query_fetch_all_rows($sql))) {
         return false;
     } else {
         return $data;
     }
 }
Пример #3
0
/**
 * Get list of all announcements in the given or current course.
 *
 * @param array     $thisCourse
 * @param int       $limit number of records to return
 * @param int       $startTime
 * @param bool      $visibleOnly
 * @return array of array(id, title, content, time, visibility, rank)
 * @since 1.7
 */
function announcement_get_course_item_list_portlet($thisCourse, $limit = null, $startTime = null, $visibleOnly = true)
{
    // **** Caution: has to get fixed !
    $tableAnn = get_conf('courseTablePrefix') . $thisCourse['db'] . get_conf('dbGlu') . 'announcement';
    // ****
    $curdate = claro_mktime();
    $sql = "SELECT '" . claro_sql_escape($thisCourse['sysCode']) . "' AS `courseSysCode`, \n" . "'" . claro_sql_escape($thisCourse['officialCode']) . "'  AS `courseOfficialCode`, \n" . "'CLANN'                                                 AS `toolLabel`, \n" . "CONCAT(`temps`, ' ', '00:00:00')                        AS `date`, \n" . "`id`                                                    AS `id`, \n" . "`title`                                                 AS `title`, \n" . "`contenu`                                               AS `content`, \n" . "`visibility`, \n" . "`visibleFrom`, \n" . "`visibleUntil` \n" . "FROM `" . $tableAnn . "` \n" . "WHERE CONCAT(`title`, `contenu`) != '' \n" . ($startTime ? '' : "AND DATE_FORMAT( `temps`, '%Y %m %d') >= '" . date('Y m d', (double) $startTime) . "' \n") . ($visibleOnly ? "  AND visibility = 'SHOW' \n" : '') . "            AND (UNIX_TIMESTAMP(`visibleFrom`) < '" . $curdate . "'\n                              OR `visibleFrom` IS NULL OR UNIX_TIMESTAMP(`visibleFrom`)=0\n                            )\n                        AND ('" . $curdate . "' < UNIX_TIMESTAMP(`visibleUntil`) OR `visibleUntil` IS NULL)" . "ORDER BY `date` DESC \n" . ($limit ? "LIMIT " . (int) $limit : '');
    return claro_sql_query_fetch_all_rows($sql);
}
Пример #4
0
 /**
  * load the list of recipient list of the current message
  */
 protected function loadRecipientList()
 {
     $tableName = get_module_main_tbl(array('im_recipient', 'user'));
     $recipientListSQL = "SELECT U.user_id, U.nom as lastName, U.prenom as firstName, U.username\n" . " FROM `" . $tableName['im_recipient'] . "` AS R\n" . " LEFT JOIN `" . $tableName['user'] . "` AS U ON R.user_id = U.user_id\n" . " WHERE R.message_id = " . (int) $this->getId() . " AND R.user_id > 0\n";
     $userList = claro_sql_query_fetch_all_rows($recipientListSQL);
     $sentToSQL = "SELECT DISTINCT (R.sent_to)\n" . " FROM `" . $tableName['im_recipient'] . "` AS R\n" . " WHERE R.message_id = " . (int) $this->getId() . "\n" . " LIMIT 1\n";
     $sentTo = claro_sql_query_fetch_single_value($sentToSQL);
     $this->recipientList = array();
     $this->recipientList['sentTo'] = $sentTo;
     $this->recipientList['userList'] = $userList;
 }
Пример #5
0
 /**
  * load the message list if it is not loaded
  *
  */
 protected function loadMessageList()
 {
     // If message list not loaded, load it !
     if (!$this->messageList) {
         $strategy = $this->getSelector();
         $limitClause = $strategy->getLimit();
         $orderClause = $strategy->getOrder();
         $whereClause = $strategy->getStrategy();
         $tableName = get_module_main_tbl(array('im_message', 'user', 'im_recipient'));
         $sql = "SELECT distinct M.message_id,M.sender,M.subject,M.message,M.send_time,M.course,\n" . "M.group,M.tools,U.nom AS lastName,U.prenom AS firstName\n" . " FROM `" . $tableName['im_message'] . "` AS M\n" . " LEFT JOIN `" . $tableName['user'] . "` AS U ON M.sender = U.user_id\n" . " LEFT JOIN `" . $tableName['im_recipient'] . "` AS R ON R.message_id = M.message_id" . " " . $whereClause . "\n" . " " . $orderClause . "\n" . " " . $limitClause . "\n";
         $this->messageList = claro_sql_query_fetch_all_rows($sql);
         //load number of message if its necessary
         $this->loadNumberOfMessage();
     }
 }
Пример #6
0
 /**
  * Load the current user list from DB
  *
  * @return boolean result of operation
  */
 public function load()
 {
     $sql = "SELECT \n                `U`.`prenom` as `firstname`, \n                `U`.`nom` as `lastname`,\n                `RCU`.`isCourseManager` \n            FROM `" . $this->tblChatUsers . "` as `CU`, \n                `" . $this->tblUser . "` as `U`,\n                `" . $this->tblRelCourseUser . "` as `RCU` \n            WHERE `CU`.user_id = U.user_id\n              AND `U`.`user_id` = `RCU`.`user_id` \n              AND `RCU`.`code_cours` = '" . $this->courseId . "'";
     if (!is_null($this->groupId)) {
         $sql .= " AND `CU`.`group_id` = " . (int) $this->groupId . " ";
     } else {
         $sql .= " AND `CU`.`group_id` IS NULL ";
     }
     $sql .= " ORDER BY `RCU`.`isCourseManager` DESC,\n                  `U`.`prenom` ASC,\n                  `U`.`nom` ASC";
     $userList = claro_sql_query_fetch_all_rows($sql);
     if ($userList) {
         $this->userList = $userList;
         return true;
     } else {
         return false;
     }
 }
Пример #7
0
 /**
  * @see MessageBox
  *
  */
 public function loadMessageList()
 {
     if (!$this->messageList) {
         if (!is_null($this->messageFilter)) {
             $strategy = $this->messageFilter->getStrategy();
             $order = $this->messageFilter->getOrder();
             $limit = $this->messageFilter->getLimit();
         } else {
             $strategy = "";
             $order = "";
             $limit = "";
         }
         $tableName = get_module_main_tbl(array('im_message'));
         $sql = "SELECT M.message_id, M.sender, M.subject, M.message, M.send_time, M.course, M.`group`, M.tools \n" . "FROM `" . $tableName['im_message'] . "` AS M \n" . "WHERE M.sender = " . (int) $this->userId . "\n" . " " . $strategy . " " . $order . " " . $limit;
         $this->messageList = claro_sql_query_fetch_all_rows($sql);
         //load number of message if its necessary
         $this->loadNumberOfMessage();
     }
 }
Пример #8
0
 public function load()
 {
     $tblNameList = claro_sql_get_main_tbl();
     $sql = "SELECT M.`label` AS `label`,\n" . "M.`script_url` AS `entry`,\n" . "M.`name` AS `name`,\n" . "M.`activation` AS `activation`,\n" . "D.`name` AS `dock`\n" . "FROM `" . $tblNameList['dock'] . "` AS D\n" . "LEFT JOIN `" . $tblNameList['module'] . "` AS M\n" . "ON D.`module_id` = M.`id`\n" . "ORDER BY D.`rank` ";
     $appletList = claro_sql_query_fetch_all_rows($sql);
     if ($appletList) {
         $dockAppletList = array();
         foreach ($appletList as $key => $applet) {
             if (!array_key_exists($applet['dock'], $dockAppletList)) {
                 $dockAppletList[$applet['dock']] = array();
             }
             $entryPath = get_module_path($applet['label']) . '/' . $applet['entry'];
             if (file_exists($entryPath)) {
                 $applet['path'] = $entryPath;
                 // $appletList[$key] = $applet;
                 $dockAppletList[$applet['dock']][] = $applet;
             }
         }
         $this->_dockAppletList = $dockAppletList;
     }
 }
Пример #9
0
 /**
  * load message list of this course from DB
  *
  * @author Sebastien Piraux <*****@*****.**>
  * @param int $from unixtime 
  * @param int $to unixtime
  * @return result of operation
  */
 public function load($from = '', $to = '')
 {
     $sql = "SELECT UNIX_TIMESTAMP(`JC`.`post_time`) as `unixPostTime`, \n                    `JC`.`message`, \n                    `U`.`nom` as `lastname`,\n                    `U`.`prenom` as `firstname`, \n                    `U`.`isCourseCreator` \n                FROM `" . $this->tblChatMsg . "` as `JC`, \n                    `" . $this->tblUser . "` as `U` \n                WHERE `JC`.`user_id` = `U`.`user_id` ";
     if (!is_null($this->groupId)) {
         $sql .= " AND `JC`.`group_id` = " . (int) $this->groupId . " ";
     } else {
         $sql .= " AND `JC`.`group_id` IS NULL ";
     }
     if ($from != '') {
         $sql .= " HAVING " . (int) $from . " < `unixPostTime` ";
         if ($to != '') {
             $sql .= " AND `unixPostTime` < " . (int) $to . " ";
         }
     }
     $sql .= " ORDER BY `post_time`";
     $messageList = claro_sql_query_fetch_all_rows($sql);
     if ($messageList) {
         $this->msgList = $messageList;
         return true;
     } else {
         return false;
     }
 }
Пример #10
0
/**
 * Get the list of all installable course tool modules from kernel
 * @author Frederic Minne <*****@*****.**>
 */
function get_course_installable_tool_list()
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_courseTool = $tbl_mdb_names['tool'];
    $sql = "SELECT id, def_access, def_rank, claro_label, add_in_course " . "FROM `" . $tbl_courseTool . "` ";
    $list = claro_sql_query_fetch_all_rows($sql);
    return $list;
}
Пример #11
0
 /**
  * insert or update course data
  *
  * @return boolean success
  */
 public function save()
 {
     if (empty($this->courseId)) {
         // Insert
         $keys = define_course_keys($this->officialCode, '', get_conf('dbNamePrefix'));
         $courseSysCode = trim($keys['currentCourseId']);
         $courseDbName = trim($keys['currentCourseDbName']);
         $courseDirectory = trim($keys['currentCourseRepository']);
         if (empty($courseSysCode) || empty($courseDbName) || empty($courseDirectory)) {
             throw new Exception("Error missing data for course {$this->officialCode}");
         }
         if (!$this->useExpirationDate) {
             $this->expirationDate = 'NULL';
         }
         // Session courses are created without categories links:
         // so we duplicate the source course's categories links
         /*if ( !is_null($this->sourceCourseId) && !empty($this->sourceCourseId) )
           {
               $sourceCourse = new claroCourse();
               $sourceCourse->load(claroCourse::getCodeFromId($this->sourceCourseId));
               
               $this->categories = $sourceCourse->categories;
           }*/
         if (!is_null($this->sourceCourseId) && !empty($this->sourceCourseId)) {
             $sourceCourse = new claroCourse();
             $sourceCourse->load(claroCourse::getCodeFromId($this->sourceCourseId));
             if ($sourceCourse->sourceCourseId) {
                 throw new Exception('You cannot create a course session from another course session');
             }
         }
         if (prepare_course_repository($courseDirectory, $courseSysCode) && register_course($courseSysCode, $this->officialCode, $this->sourceCourseId, $courseDirectory, $courseDbName, $this->titular, $this->email, $this->categories, $this->title, $this->language, $GLOBALS['_uid'], $this->access, $this->registration, $this->registrationKey, $this->visibility, $this->departmentName, $this->extLinkUrl, $this->publicationDate, $this->expirationDate, $this->status, $this->userLimit) && install_course_database($courseDbName) && install_course_tools($courseDbName, $this->language, $courseDirectory)) {
             $courseObj = new Claro_Course($courseSysCode);
             $courseObj->load();
             $courseRegistration = new Claro_CourseUserRegistration(AuthProfileManager::getUserAuthProfile($GLOBALS['_uid']), $courseObj, null, null);
             $courseRegistration->ignoreRegistrationKeyCheck();
             $courseRegistration->ignoreCategoryRegistrationCheck();
             $courseRegistration->setCourseAdmin();
             $courseRegistration->setCourseTutor();
             $courseRegistration->forceSuperUser();
             if ($courseRegistration->addUser()) {
                 // Set course id
                 $this->courseId = $courseSysCode;
                 // Notify event manager
                 $args['courseSysCode'] = $courseSysCode;
                 $args['courseDbName'] = $courseDbName;
                 $args['courseDirectory'] = $courseDirectory;
                 $args['courseCategory'] = $this->categories;
                 $GLOBALS['eventNotifier']->notifyEvent("course_created", $args);
                 return true;
             } else {
                 $this->backlog->failure($courseRegistration->getErrorMessage());
                 return false;
             }
         } else {
             $lastFailure = claro_failure::get_last_failure();
             $this->backlog->failure('Error : ' . $lastFailure);
             return false;
         }
     } else {
         // Update
         $tbl_mdb_names = claro_sql_get_main_tbl();
         $tbl_course = $tbl_mdb_names['course'];
         $tbl_cdb_names = claro_sql_get_course_tbl();
         $tbl_course_properties = $tbl_cdb_names['course_properties'];
         if (!$this->useExpirationDate) {
             $this->expirationDate = null;
         }
         $sqlExpirationDate = is_null($this->expirationDate) ? 'NULL' : 'FROM_UNIXTIME(' . claro_sql_escape($this->expirationDate) . ')';
         $sqlCreationDate = is_null($this->publicationDate) ? 'NULL' : 'FROM_UNIXTIME(' . claro_sql_escape($this->publicationDate) . ')';
         $sql = "UPDATE `" . $tbl_course . "`\n                    SET `intitule`             = '" . claro_sql_escape($this->title) . "',\n                        `titulaires`           = '" . claro_sql_escape($this->titular) . "',\n                        `administrativeNumber` = '" . claro_sql_escape($this->officialCode) . "',\n                        `language`             = '" . claro_sql_escape($this->language) . "',\n                        `extLinkName`          = '" . claro_sql_escape($this->departmentName) . "',\n                        `extLinkUrl`           = '" . claro_sql_escape($this->extLinkUrl) . "',\n                        `email`                = '" . claro_sql_escape($this->email) . "',\n                        `visibility`           = '" . ($this->visibility ? 'visible' : 'invisible') . "',\n                        `access`               = '" . claro_sql_escape($this->access) . "',\n                        `registration`         = '" . claro_sql_escape($this->registration) . "',\n                        `registrationKey`      = '" . claro_sql_escape($this->registrationKey) . "',\n                        `lastEdit`             = NOW(),\n                        `creationDate`         = " . $sqlCreationDate . ",\n                        `expirationDate`       = " . $sqlExpirationDate . ",\n                        `status`               = '" . claro_sql_escape($this->status) . "',\n                        `userLimit`            = '" . (int) $this->userLimit . "'\n                    WHERE code='" . claro_sql_escape($this->courseId) . "'";
         // Handle categories
         // 1/ Remove all links in database
         $this->unlinkCategories();
         // 2/ Link new categories selection
         $this->linkCategories($this->categories);
         // If it's a source course, do the same for all its session courses
         if ($this->isSourceCourse) {
             $sql2 = "SELECT cours_id FROM `" . $tbl_course . "`\n                        WHERE sourceCourseId = " . $this->id;
             $sessionCourses = claro_sql_query_fetch_all_rows($sql2);
             foreach ($sessionCourses as $sessionCourse) {
                 unlink_course_categories($sessionCourse['cours_id']);
                 link_course_categories($sessionCourse['cours_id'], $this->categories);
             }
         }
         return claro_sql_query($sql);
     }
 }
Пример #12
0
/**
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 *
 * @param $pathId integer id of a learnPath
 * @return boolean true if learnpath is blocked, false instead
 *
 **/
function is_learnpath_accessible($pathId)
{
    $blocked = false;
    $tbl_cdb_names = claro_sql_get_course_tbl();
    $tbl_lp_learnPath = $tbl_cdb_names['lp_learnPath'];
    $tbl_lp_rel_learnPath_module = $tbl_cdb_names['lp_rel_learnPath_module'];
    $tbl_lp_user_module_progress = $tbl_cdb_names['lp_user_module_progress'];
    $tbl_lp_module = $tbl_cdb_names['lp_module'];
    $tbl_lp_asset = $tbl_cdb_names['lp_asset'];
    // select all the LP upper than this one
    $sql = "SELECT `rank`, `visibility` FROM `" . $tbl_lp_learnPath . "` WHERE `learnPath_id` = " . (int) $pathId . " LIMIT 1";
    $path = claro_sql_query_fetch_single_row($sql);
    if ($path['visibility'] == 'HIDE') {
        $blocked = true;
    } else {
        $sql = "SELECT `learnPath_id`, `lock`, `visibility` FROM `" . $tbl_lp_learnPath . "` WHERE `rank` < " . (int) $path['rank'] . " ORDER BY `rank` DESC";
        $upperPaths = claro_sql_query_fetch_all_rows($sql);
        // get the first blocked LP
        $upperBlockId = 0;
        $upperLock = 'OPEN';
        foreach ($upperPaths as $upperPath) {
            if (strtolower($upperPath['lock']) == 'close') {
                $upperBlockId = $upperPath['learnPath_id'];
                $upperLock = $upperPath['lock'];
                break;
            }
        }
        if (!empty($upperBlockId)) {
            // step 1. find last visible module of the current learning path in DB
            $blocksql = "SELECT `learnPath_module_id`\n                          FROM `" . $tbl_lp_rel_learnPath_module . "`\n                          WHERE `learnPath_id`=" . (int) $upperBlockId . "\n                          AND `visibility` = \"SHOW\"\n                          ORDER BY `rank` DESC\n                          LIMIT 1\n                         ";
            $listblock = claro_sql_query_fetch_single_row($blocksql);
            // step 2. see if there is a user progression in db concerning this module of the current learning path
            if ($listblock && is_array($listblock) && count($listblock)) {
                $blocksql2 = "SELECT `credit`\n                           FROM `" . $tbl_lp_user_module_progress . "`\n                           WHERE `learnPath_module_id`=" . (int) $listblock['learnPath_module_id'] . "\n                           AND `user_id`='" . (int) claro_get_current_user_id() . "'\n                          ";
                $resultblock2 = claro_sql_query($blocksql2);
                $moduleNumber = mysql_num_rows($resultblock2);
            } else {
                $moduleNumber = 0;
            }
            if ($moduleNumber != 0) {
                $listblock2 = mysql_fetch_array($resultblock2);
                if ($listblock2['credit'] == "NO-CREDIT" && $upperLock == 'CLOSE') {
                    $blocked = true;
                }
            } elseif ($moduleNumber == 0 && $upperLock == 'CLOSE') {
                $blocked = true;
            }
        }
    }
    return $blocked;
}
Пример #13
0
function getQuestionCategoryList()
{
    $categoryList = array();
    $tbl_cdb_names = get_module_course_tbl(array('qwz_questions_categories'), claro_get_current_course_id());
    $tblQuestionCategories = $tbl_cdb_names['qwz_questions_categories'];
    $query = "SELECT `id`, `title` FROM `" . $tblQuestionCategories . "`\n               ORDER BY `title`";
    if (claro_sql_query($query)) {
        return claro_sql_query_fetch_all_rows($query);
    } else {
        return $categoryList;
    }
}
Пример #14
0
 $submission->setTitle($wrkForm['wrkTitle']);
 $submission->setAuthor($wrkForm['wrkAuthors']);
 $submission->setVisibility($assignment->getDefaultSubmissionVisibility());
 $submission->setSubmittedText($wrkForm['wrkTxt']);
 $submission->setSubmittedFilename($wrkForm['filename']);
 if ($assignment->getAssignmentType() == 'GROUP' && isset($wrkForm['wrkGroup'])) {
     $submission->setGroupId($wrkForm['wrkGroup']);
 }
 $submission->save();
 $dialogBox->success(get_lang('Work added'));
 // notify eventmanager that a new submission has been posted
 $eventNotifier->notifyCourseEvent("work_submission_posted", claro_get_current_course_id(), claro_get_current_tool_id(), $assignmentId, '0', '0');
 if (get_conf('mail_notification') && (claro_get_current_course_data('notify_submissions') || get_conf('automatic_mail_notification', false))) {
     // get teacher(s) mail
     $sql = "SELECT `U`.`user_id`\n                        FROM `" . $tbl_rel_cours_user . "` AS `CU`,`" . $tbl_user . "` AS `U`\n                        WHERE `CU`.`user_id` = `U`.`user_id`\n                        AND `CU`.`code_cours` = '" . claro_get_current_course_id() . "'\n                        AND `CU`.`isCourseManager` = 1";
     $userIdList = claro_sql_query_fetch_all_rows($sql);
     if (is_array($userIdList) && !empty($userIdList)) {
         require_once dirname(__FILE__) . '/../messaging/lib/message/platformmessagetosend.lib.php';
         require_once dirname(__FILE__) . '/../messaging/lib/recipient/userlistrecipient.lib.php';
         // subject
         $subject = $_user['firstName'] . ' ' . $_user['lastName'] . ' : ' . get_lang('New submission posted in assignment tool.');
         if ($assignment->getAssignmentType() == 'GROUP' && isset($_REQUEST['wrkGroup'])) {
             $authId = $wrkForm['wrkGroup'];
         } else {
             $authId = $_REQUEST['authId'];
         }
         $url = Url::Contextualize(get_path('rootWeb') . 'claroline/work/user_work.php?authId=' . $authId . '&assigId=' . $assignmentId);
         // email content
         $body = get_lang('New submission posted in assignment tool.') . "\n\n" . $_user['firstName'] . ' ' . $_user['lastName'] . "\n" . '<a href="' . claro_htmlspecialchars($url) . '">' . $wrkForm['wrkTitle'] . '</a>' . "\n";
         $message = new MessageToSend(claro_get_current_user_id(), $subject, $body);
         // TODO use official code everywhere : $message->setCourse(claro_get_current_course_data('officialCode'));
Пример #15
0
 /**
  * @see MessageBox
  *
  */
 public function loadMessageList()
 {
     if (!$this->messageList) {
         $tableName = get_module_main_tbl(array('im_message', 'im_message_status', 'user', 'im_recipient'));
         if (!is_null($this->messageFilter)) {
             $strategy = $this->messageFilter->getStrategy();
             $order = $this->messageFilter->getOrder();
             $limit = $this->messageFilter->getLimit();
         } else {
             $strategy = "";
             $order = "";
             $limit = "";
         }
         $sql = "SELECT  U.nom AS lastName, U.prenom AS firstName, M.message_id, M.sender, M.subject,\n" . "M.message, M.send_time, R.is_read, R.is_deleted, R.user_id, M.course, M.group, M.tools,\n" . "RE.sent_to" . " FROM `" . $tableName['im_message'] . "` as M\n" . " LEFT JOIN `" . $tableName['im_message_status'] . "` as R ON M.message_id = R.message_id\n" . " LEFT JOIN `" . $tableName['user'] . "` AS U ON M.sender = U.user_id\n" . " LEFT JOIN `" . $tableName['im_recipient'] . "` AS RE ON M.message_id = RE.message_id AND RE.user_id = R.user_id\n" . " WHERE (R.user_id = " . (int) $this->getUserId() . " OR R.user_id = 0) \n" . " " . $strategy . " " . $order . " " . $limit;
         $this->messageList = claro_sql_query_fetch_all_rows($sql);
         //load number of message if its necessary
         $this->loadNumberOfMessage();
     }
 }
Пример #16
0
            foreach ($completeVarList as $completeVar) {
                $string = build_translation_line_file($completeVar['varName'], '');
                fwrite($fileHandle, $string) or die("FILE WRITE FAILED: " . __LINE__);
            }
        }
        fwrite($fileHandle, "?>");
    }
} else {
    die("QUERY FAILED: " . __LINE__);
}
// build language files
fclose($fileHandle) or die("FILE CLOSE FAILED: " . __LINE__);
echo '<p><a href="' . $urlAppend . '/claroline/lang/' . LANG_EMPTY_FILENAME . '">Download it</a></p>';
//-- INSTALL
$sqlInstall = "SELECT DISTINCT u.varName\n         FROM " . $tbl_used_lang . " u\n         WHERE u.sourceFile LIKE '%/install/%'\n         ORDER BY u.varName";
$installVarList = claro_sql_query_fetch_all_rows($sqlInstall);
if (is_array($installVarList)) {
    echo '<p>Create file: ' . $path_lang . '/' . LANG_EMPTY_INSTALL_FILENAME . '</p>' . "\n";
    $fileHandle = fopen(LANG_EMPTY_INSTALL_FILENAME, 'w') or die("FILE OPEN FAILED: " . __LINE__);
    if ($fileHandle) {
        fwrite($fileHandle, "<?php \n");
        if (!empty($installVarList)) {
            foreach ($installVarList as $installVar) {
                $string = build_translation_line_file($installVar['varName'], '');
                fwrite($fileHandle, $string) or die("FILE WRITE FAILED: " . __LINE__);
            }
        }
        fwrite($fileHandle, "?>");
    }
} else {
    die("QUERY FAILED: " . __LINE__);
Пример #17
0
/**
 * return the list of user of the course in parameter. It use by default the
 * current course identification
 *
 * @param string $courseCode course identication
 * @return array of int
 */
function claro_get_course_user_list($courseCode = NULL)
{
    if ($courseCode == NULL) {
        $courseCode = claro_get_current_course_id();
    }
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_rel_course_user = $tbl_mdb_names['rel_course_user'];
    $tbl_users = $tbl_mdb_names['user'];
    $sqlGetUsers = "SELECT `user`.`user_id`      AS `user_id`,\n                       `user`.`nom`          AS `nom`,\n                       `user`.`prenom`       AS `prenom`,\n                       `user`.`email`        AS `email`,\n                       `course_user`.`profile_id`,\n                       `course_user`.`isCourseManager`,\n                       `course_user`.`tutor`  AS `tutor`,\n                       `course_user`.`role`   AS `role`\n               FROM `" . $tbl_users . "`           AS user,\n                    `" . $tbl_rel_course_user . "` AS course_user\n               WHERE `user`.`user_id`=`course_user`.`user_id`\n               AND   `course_user`.`code_cours`='" . claro_sql_escape($courseCode) . "'\n               ORDER BY `user`.`nom`,  `user`.`prenom` ;";
    return claro_sql_query_fetch_all_rows($sqlGetUsers);
}
Пример #18
0
function upgrade_category_to_110()
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tool = 'CATEGORY_110';
    switch ($step = get_upgrade_status($tool)) {
        case 1:
            // Create new tables `category` and `rel_course_category`
            $sqlForUpdate[] = "CREATE TABLE IF NOT EXISTS `" . $tbl_mdb_names['category'] . "` (\n                                `id` int(11) NOT NULL AUTO_INCREMENT,\n                                `name` varchar(100) NOT NULL DEFAULT '',\n                                `code` varchar(12) NOT NULL DEFAULT '',\n                                `idParent` int(11) DEFAULT '0',\n                                `rank` int(11) NOT NULL DEFAULT '0',\n                                `visible` tinyint(1) NOT NULL DEFAULT '1',\n                                `canHaveCoursesChild` tinyint(1) NOT NULL DEFAULT '1',\n                                PRIMARY KEY (`id`),\n                                UNIQUE KEY `code` (`code`)\n                                ) ENGINE=MyISAM";
            $sqlForUpdate[] = "CREATE TABLE IF NOT EXISTS `" . $tbl_mdb_names['rel_course_category'] . "` (\n                                `courseId` int(11) NOT NULL,\n                                `categoryId` int(11) NOT NULL,\n                                `rootCourse` tinyint(1) NOT NULL DEFAULT '0',\n                                PRIMARY KEY (`courseId`,`categoryId`)\n                                ) ENGINE=MyISAM";
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sqlForUpdate);
        case 2:
            // Insert root category
            $sqlForUpdate[] = "INSERT INTO `" . $tbl_mdb_names['category'] . "`\n                                ( `name`, `code`, `idParent`, `rank`, `visible`, `canHaveCoursesChild`)\n                                VALUES\n                                ( 'Root', 'ROOT', NULL, 0, 0, 0)";
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sqlForUpdate);
        case 3:
            // Update root category to 0
            $sqlForUpdate[] = " UPDATE `" . $tbl_mdb_names['category'] . "`\n                                SET `id` = 0\n                                WHERE `code` = 'ROOT';";
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sqlForUpdate);
        case 4:
            // Insert all previous categories ("faculties") in the new table `category`
            $sql = "SELECT f1.`id`, f1.`name`, f1.`code`, f1.`code_P`, f1.`treePos`, f1.`nb_childs`,\n                    f1.`canHaveCoursesChild`, f1.`canHaveCatChild`, f2.`id` as idParent\n                    FROM `" . get_conf('mainTblPrefix') . "faculte` f1, `" . get_conf('mainTblPrefix') . "faculte` f2\n                    WHERE f1.code_P = f2.code OR f1.code_P IS NULL\n                    GROUP BY f1.id\n                    ORDER BY idParent ASC, f1.`treePos` ASC";
            $categoriesList = claro_sql_query_fetch_all_rows($sql);
            $tempIdParent = null;
            $rank = 0;
            $visibile = 1;
            // Change this value if you want to change the default value of visibility (1 or 0)
            foreach ($categoriesList as $category) {
                // Manage the rank
                if ($tempIdParent != $category['idParent']) {
                    $tempIdParent = $category['idParent'];
                    $rank = 1;
                } else {
                    $rank++;
                }
                // what this for ????
                if (empty($category['code_P']) || empty($category['idParent'])) {
                    $category['idParent'] = 0;
                }
                $sqlForUpdate[] = "INSERT INTO `" . $tbl_mdb_names['category'] . "`\n                                   ( `id`, `name`, `code`, `idParent`, `rank`, `visible`, `canHaveCoursesChild`)\n                                   VALUES\n                                   ( " . (int) $category['id'] . ", '" . addslashes($category['name']) . "', '" . $category['code'] . "', " . $category['idParent'] . ", " . $rank . ", {$visibile}, " . $category['canHaveCoursesChild'] . ")";
            }
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sqlForUpdate);
        case 5:
            // Associate courses to new categories through `rel_course_categories`
            $sql = "SELECT co.cours_id AS courseId, ca.id AS categoryId\n                    FROM `" . $tbl_mdb_names['course'] . "` co, `" . get_conf('mainTblPrefix') . "faculte` f, `" . $tbl_mdb_names['category'] . "` ca\n                    WHERE co.faculte = f.code AND f.code = ca.code\n                    ORDER BY co.`cours_id` ASC";
            $associationsList = claro_sql_query_fetch_all_rows($sql);
            $rootCourse = 0;
            // Change this value if you want to change the default value of rootCourse (1 or 0)
            foreach ($associationsList as $assoc) {
                $sqlForUpdate[] = "INSERT INTO `" . $tbl_mdb_names['rel_course_category'] . "`\n                                   (`courseId`, `categoryId`, `rootCourse`)\n                                   VALUES\n                                   (" . (int) $assoc['courseId'] . ", " . (int) $assoc['categoryId'] . ", " . $rootCourse . ")";
            }
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sqlForUpdate);
        case 6:
            // Drop deprecated attribute "faculte" from `cours` table
            $sqlForUpdate[] = "ALTER TABLE `" . $tbl_mdb_names['course'] . "` DROP `faculte`";
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sqlForUpdate);
        case 7:
            // Drop deprecated table `faculty`
            $sqlForUpdate[] = "DROP TABLE `" . get_conf('mainTblPrefix') . "faculte`";
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sqlForUpdate);
        default:
            $step = set_upgrade_status($tool, 0);
            return $step;
    }
    return false;
}
Пример #19
0
 public function merge($uidToRemove, $uidToKeep)
 {
     $mainTbl = claro_sql_get_main_tbl();
     // inherit platform admin status ? harmful !
     /*$toKeep_isPlatformAdmin = claro_sql_query_fetch_single_value("
                 SELECT isPlatformAdmin FROM `{$mainTbl['user']}` WHERE user_id = " . (int) $uidToKeep . "
             ");
     
             $toRemove_isPlatformAdmin = claro_sql_query_fetch_single_value("
                 SELECT isPlatformAdmin FROM `{$mainTbl['user']}` WHERE user_id = " . (int) $uidToRemove . "
             ");
     
             if ( $toKeep_isPlatformAdmin && ! $toRemove_isPlatformAdmin )
             {
                 claro_sql_query("UPDATE `{$mainTbl['user']}` SET `isPlatformAdmin` = 1 WHERE user_id = ".(int) $uidToKeep );
             }*/
     // inherit course creator status
     $toKeep_isCourseCreator = claro_sql_query_fetch_single_value("\n            SELECT isCourseCreator FROM `{$mainTbl['user']}` WHERE user_id = " . (int) $uidToKeep . "\n        ");
     $toRemove_isCourseCreator = claro_sql_query_fetch_single_value("\n            SELECT isCourseCreator FROM `{$mainTbl['user']}` WHERE user_id = " . (int) $uidToRemove . "\n        ");
     if ($toRemove_isCourseCreator && !$toKeep_isCourseCreator) {
         claro_sql_query("UPDATE `{$mainTbl['user']}` SET `isCourseCreator` = 1 WHERE user_id = " . (int) $uidToKeep);
     }
     // Get course list for the user to remove
     $sql = "\n            SELECT\n                c.`code` AS `code`,\n                cu.`isCourseManager`,\n                cu.`profile_id`\n            FROM\n                `{$mainTbl['course']}` c,\n                `{$mainTbl['rel_course_user']}` cu\n            WHERE\n                cu.user_id = " . (int) $uidToRemove . "\n              AND\n                c.code = cu.code_cours";
     $courseList = claro_sql_query_fetch_all_rows($sql);
     foreach ($courseList as $thisCourse) {
         // Check if the user to keep is registered to the course
         $sql = "\n                SELECT\n                    `code_cours`,\n                    `isCourseManager`,\n                    `profile_id`\n                FROM\n                    `{$mainTbl['rel_course_user']}`\n                WHERE\n                    code_cours = '" . claro_sql_escape($thisCourse['code']) . "'\n                AND\n                    user_id = " . (int) $uidToKeep;
         $userToKeepCourseList = claro_sql_query_fetch_single_row($sql);
         if (!empty($userToKeepCourseList)) {
             // inherit isCourseManager
             if ($thisCourse['isCourseManager'] == 1 && $userToKeepCourseList['isCourseManager'] != 1) {
                 if (!claro_sql_query("\n                        UPDATE `{$mainTbl['rel_course_user']}`\n                        SET `isCourseManager` = 1\n                        WHERE code_cours = '" . claro_sql_escape($thisCourse['code']) . "'\n                        AND user_id = " . (int) $uidToKeep)) {
                     Console::error("Cannot change rel_course_user from -{$uidToRemove} to +{$uidToKeep} isCourseManager in {$thisCourse['code']}");
                     $this->hasError = true;
                 }
             }
             // inherit profile
             if ($thisCourse['profile_id'] > $userToKeepCourseList['profile_id']) {
                 if (!claro_sql_query("\n                        UPDATE `{$mainTbl['rel_course_user']}`\n                        SET `profile_id` = " . (int) $thisCourse['profile_id'] . "\n                        WHERE code_cours = '" . claro_sql_escape($thisCourse['code']) . "'\n                        AND user_id = " . (int) $uidToKeep)) {
                     Console::error("Cannot change rel_course_user from -{$uidToRemove} to +{$uidToKeep} profile in {$thisCourse['code']}");
                     $this->hasError = true;
                 }
             }
             // Remove the user to remove from the course
             $sql = "DELETE FROM `{$mainTbl['rel_course_user']}`\n                    WHERE user_id    = " . (int) $uidToRemove . "\n                      AND code_cours = '" . claro_sql_escape($thisCourse['code']) . "'";
             if (!claro_sql_query($sql)) {
                 Console::error("Cannot change rel_course_user from -{$uidToRemove} to +{$uidToKeep}  in {$thisCourse['code']}");
                 $this->hasError = true;
             }
         } else {
             // Replace the user id of the user to remove
             $sql = "UPDATE `{$mainTbl['rel_course_user']}`\n                    SET   user_id    = " . (int) $uidToKeep . "\n                    WHERE user_id    = " . (int) $uidToRemove . "\n                      AND code_cours = '" . claro_sql_escape($thisCourse['code']) . "'";
             if (!claro_sql_query($sql)) {
                 Console::error("Cannot change rel_course_user from -{$uidToRemove} to +{$uidToKeep} in {$thisCourse['code']}");
                 $this->hasError = true;
             }
         }
         if (!claro_sql_query($sql)) {
             Console::error("Cannot change rel_course_user from -{$uidToRemove} to +{$uidToKeep} in {$thisCourse['code']}");
             $this->hasError = true;
         }
         $sql = "UPDATE `{$mainTbl['rel_class_user']}`\n                SET   user_id    = " . (int) $uidToKeep . "\n                WHERE user_id    = " . (int) $uidToRemove;
         if (!claro_sql_query($sql)) {
             Console::error("Cannot change rel_class_user from -{$uidToRemove} to +{$uidToKeep} in {$thisCourse['code']}");
             $this->hasError = true;
         }
         // Update course
         self::mergeCourseUsers($uidToRemove, $uidToKeep, $thisCourse['code']);
         self::mergeCourseModuleUsers($uidToRemove, $uidToKeep, $thisCourse['code']);
         // update course messaging
         self::mergeCourseMessaging($uidToRemove, $uidToKeep, $thisCourse['code']);
     }
     // Update modules
     self::mergeModuleUsers($uidToRemove, $uidToKeep);
     // Update main tracking
     self::mergeMainTrackingUsers($uidToRemove, $uidToKeep);
     // updtae main messaging
     self::mergeMainMessaging($uidToRemove, $uidToKeep);
     // Delete old user
     $sql = "DELETE FROM `{$mainTbl['user']}`\n            WHERE user_id = " . (int) $uidToRemove;
     if (!claro_sql_query($sql)) {
         Console::error("Cannot delete old user -{$uidToRemove}");
         $this->hasError = true;
     }
     return !self::hasError();
 }
Пример #20
0
/**
 * Alias for claro_sql_query_fetch_all_rows
 * @see claro_sql_query_fetch_all_rows()
 * @deprecated since Claroline 1.9, use Claroline::getDatabase() and new classes
 *  in database/database.lib.php instead
 */
function claro_sql_query_fetch_all($sqlQuery, $dbHandler = '#')
{
    return claro_sql_query_fetch_all_rows($sqlQuery, $dbHandler);
}
Пример #21
0
 /**
  * Provide the list of available resources for a resource
  *
  * @para ResourceLocator $locator The resource locator.
  * @return LinkerResourceIterator Resource list as an iterator
  */
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl_cdb_names = get_module_course_tbl(array('lp_learnPath'), $locator->getCourseId());
     $tblPath = $tbl_cdb_names['lp_learnPath'];
     $resourceList = new LinkerResourceIterator();
     $sql = "SELECT `learnPath_id` AS `id`, `name`, `visibility`\n                FROM `" . $tblPath . "`\n                ORDER BY `name` ASC";
     $pathList = claro_sql_query_fetch_all_rows($sql);
     foreach ($pathList as $path) {
         $fileLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLLNP', $path['id']);
         $fileResource = new LinkerResource($path['name'], $fileLoc, true, $path['visibility'] == 'SHOW' ? true : false, false);
         $resourceList->addResource($fileResource);
     }
     return $resourceList;
 }
Пример #22
0
/**
 * Is the given tool activated in the given course
 * @param string $courseId course code
 * @param string $toolId tool id in the course, not the main tool id !
 * @return boolean
 */
function claro_is_course_tool_activated($courseId, $toolId)
{
    static $activatedCourseToolList = false;
    if (!$activatedCourseToolList) {
        $activatedCourseToolList = array();
        $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($courseId));
        $tbl_course_tool_list = $tbl_cdb_names['tool'];
        /*
         * Search all the tool corresponding to this access levels
         */
        // find module or claroline existing tools
        $sql = "SELECT ctl.id, ctl.activated\n" . "FROM `" . $tbl_course_tool_list . "` AS ctl";
        $toolList = claro_sql_query_fetch_all_rows($sql);
        foreach ($toolList as $tool) {
            $activatedCourseToolList[$tool['id']] = $tool['activated'];
        }
    }
    return $activatedCourseToolList[$toolId] == 'true';
}
Пример #23
0
/**
 * Get list of all  user properties for this course
 *
 * @param string $course_id coude code of course
 * @return array containing a list of arrays.
 *           And each of these arrays contains
 *           'catId', 'title', 'comment', and 'nbline',
 *
 */
function claro_user_info_claro_user_info_get_cat_def_list($course_id = NULL)
{
    $tbl = claro_sql_get_course_tbl(claro_get_course_db_name_glued($course_id));
    $sql = "SELECT id catId, " . "\n" . "          title," . "\n" . "          comment ," . "\n" . "          nbline" . "\n" . "FROM  `" . $tbl['userinfo_def'] . "`" . "\n" . "ORDER BY rank";
    $cat_def_list = claro_sql_query_fetch_all_rows($sql);
    if (!empty($cat_def_list)) {
        return $cat_def_list;
    } else {
        return false;
    }
}
Пример #24
0
/**
 * Get the module label corresponding to the given tool id
 * @param int $toolId
 * @return string
 */
function get_module_label_from_tool_id($toolId, $forceCacheRefresh = false)
{
    static $toolIdList = false;
    if (!$toolIdList || $forceCacheRefresh) {
        $toolIdList = array();
        $tbl = claro_sql_get_main_tbl();
        $sql = "SELECT claro_label, id\n                FROM `" . $tbl['tool'] . "`";
        $result = claro_sql_query_fetch_all_rows($sql);
        foreach ($result as $tool) {
            $toolIdList[$tool['id']] = $tool['claro_label'];
        }
    }
    if (isset($toolIdList[$toolId])) {
        return $toolIdList[$toolId];
    } else {
        return false;
    }
}
Пример #25
0
/**
 * Move tracking data from old tables to new ones.
 *
 * @return upgrade status
 */
function upgrade_main_database_tracking_data_to_19()
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tool = 'MAIN_TRACKING_DATA_19';
    switch ($step = get_upgrade_status($tool)) {
        case 1:
            // drop id to be able to recreate it with correct autoincrement values at last step
            $sql = "ALTER TABLE `" . $tbl_mdb_names['tracking_event'] . "` DROP `id`";
            if (upgrade_sql_query($sql)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sql);
        case 2:
            // get total number of rows in track_e_login
            $sql = "SELECT COUNT(*)\n                        FROM `" . get_conf('statsDbName') . '`.`' . get_conf('statsTblPrefix') . "track_e_login`";
            $tableRows = (int) claro_sql_query_fetch_single_value($sql);
            $recoveredOffset = UpgradeTrackingOffset::retrieve();
            // get a subgroup of 250 rows and insert group by group in tracking_event table
            for ($offset = $recoveredOffset; $offset < $tableRows; $offset += 250) {
                // we have to store offset to start again from it if something failed
                UpgradeTrackingOffset::store($offset);
                $query = "SELECT `login_id`, `login_user_id`, `login_date`, `login_ip`\n                            FROM `" . get_conf('statsDbName') . '`.`' . get_conf('statsTblPrefix') . "track_e_login`\n                        ORDER BY `login_date`, `login_id`\n                           LIMIT " . $offset . ", 250";
                // then copy these 250 rows to tracking_event
                $eventList = claro_sql_query_fetch_all_rows($query);
                // build query to insert all 250 rows
                $sql = "INSERT INTO `" . get_conf('statsDbName') . '`.`' . get_conf('statsTblPrefix') . "tracking_event`\n                        ( `user_id`, `date`, `type`, `data` )\n                        VALUES\n                        ";
                //inject former data into new table structure
                foreach ($eventList as $event) {
                    $sql .= "(" . (int) $event['login_user_id'] . ",'" . claro_sql_escape($event['login_date']) . "','user_login','" . claro_sql_escape(serialize(array('ip' => $event['login_ip']))) . "'),\n";
                }
                unset($eventList);
                if (upgrade_sql_query(rtrim($sql, ",\n"))) {
                    unset($sql);
                    //continue;
                } else {
                    return $step;
                }
            }
            UpgradeTrackingOffset::reset();
            $step = set_upgrade_status($tool, $step + 1);
        case 3:
            // get total number of rows in track_e_login
            $sql = "SELECT COUNT(*)\n                        FROM `" . get_conf('statsDbName') . '`.`' . get_conf('statsTblPrefix') . "track_e_open`";
            $tableRows = (int) claro_sql_query_fetch_single_value($sql);
            $recoveredOffset = UpgradeTrackingOffset::retrieve();
            // get a subgroup of 250 rows and insert group by group in tracking_event table
            for ($offset = $recoveredOffset; $offset < $tableRows; $offset += 250) {
                // we have to store offset to start again from it if something failed
                UpgradeTrackingOffset::store($offset);
                $query = "SELECT `open_id`, `open_date`\n                            FROM `" . get_conf('statsDbName') . '`.`' . get_conf('statsTblPrefix') . "track_e_open`\n                        ORDER BY `open_date`, `open_id`\n                           LIMIT " . $offset . ", 250";
                // then copy these 250 rows to tracking_event
                $eventList = claro_sql_query_fetch_all_rows($query);
                // build query to insert all 250 rows
                $sql = "INSERT INTO `" . get_conf('statsDbName') . '`.`' . get_conf('statsTblPrefix') . "tracking_event`\n                        ( `user_id`, `date`, `type`, `data` )\n                        VALUES\n                        ";
                //inject former data into new table structure
                foreach ($eventList as $event) {
                    $sql .= "(NULL,'" . claro_sql_escape($event['open_date']) . "','platform_access',''),\n";
                }
                unset($eventList);
                if (upgrade_sql_query(rtrim($sql, ",\n"))) {
                    unset($sql);
                    //continue;
                } else {
                    return $step;
                }
            }
            UpgradeTrackingOffset::reset();
            $step = set_upgrade_status($tool, $step + 1);
        case 4:
            // order table using dates then recreate primary key with correct autoincrement value
            $sqlForUpdate[] = "ALTER TABLE `" . $tbl_mdb_names['tracking_event'] . "`  ORDER BY `date`";
            $sqlForUpdate[] = "ALTER TABLE `" . $tbl_mdb_names['tracking_event'] . "` ADD `id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST";
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
        case 5:
            //drop deprecated tracking tables
            $sqlForUpdate[] = "DROP TABLE IF EXISTS `" . get_conf('statsDbName') . '`.`' . get_conf('statsTblPrefix') . "track_e_open`";
            $sqlForUpdate[] = "DROP TABLE IF EXISTS `" . get_conf('statsDbName') . '`.`' . get_conf('statsTblPrefix') . "track_e_login`";
            // we should probably keep this table as it may be usefull for history purpose.  By the way it is not used in
            // any tracking interface.
            //$sqlForUpdate[] = "DROP TABLE IF EXISTS `" . get_conf( 'mainTblPrefix' ) . "track_e_default`";
            if (upgrade_apply_sql($sqlForUpdate)) {
                $step = set_upgrade_status($tool, $step + 1);
            } else {
                return $step;
            }
            unset($sqlForUpdate);
        default:
            $step = set_upgrade_status($tool, 0);
            return $step;
    }
    return false;
}
Пример #26
0
/**
 * get the list of extraProperties for user accounts
 *
 * @since claroline 1.8
 *
 * @return array('propertyId'=>array('propertyId', 'label', 'type', 'defaultValue', 'required');
 */
function get_userInfoExtraDefinitionList()
{
    $tbl = claro_sql_get_tbl('property_definition');
    $sql = "SELECT propertyId, label, type, defaultValue, required\n             FROM `" . $tbl['property_definition'] . "`\n             WHERE contextScope = 'USER'\n             ORDER BY rank\n             ";
    $result = claro_sql_query_fetch_all_rows($sql);
    $extraInfoDefList = array();
    foreach ($result as $userPropertyDefinition) {
        $extraInfoDefList[$userPropertyDefinition['propertyId']] = $userPropertyDefinition;
    }
    return $extraInfoDefList;
}
Пример #27
0
    $is_courseAllowed = !empty($_SESSION['is_courseAllowed']) ? $_SESSION['is_courseAllowed'] : false;
    $is_courseTutor = !empty($_SESSION['is_courseTutor']) ? $_SESSION['is_courseTutor'] : false;
    // not used !?!
    $_courseUser = !empty($_SESSION['_courseUser']) ? $_SESSION['_courseUser'] : null;
}
// Installed module in course if available in platform and not in course
if ($_cid && is_array($_course) && isset($_course['dbNameGlu']) && !empty($_course['dbNameGlu']) && trim($_course['dbNameGlu'])) {
    // 0. load course configuration to avoid creating uneeded examples
    require claro_get_conf_repository() . 'course_main.conf.php';
    // 1. get tool list from main db
    $mainCourseToolList = claro_get_main_course_tool_list();
    // 2. get list af already installed tools from course
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_tool = $tbl_mdb_names['tool'];
    $sql = " SELECT pct.id                    AS toolId       ,\n                  pct.claro_label           AS label\n\n            FROM `" . $_course['dbNameGlu'] . "tool_list` AS ctl\n            INNER JOIN `" . $tbl_tool . "` AS pct\n            ON `ctl`.`tool_id` = `pct`.`id`\n            WHERE ctl.installed = 'true'";
    $courseToolList = claro_sql_query_fetch_all_rows($sql);
    $tmp = array();
    foreach ($courseToolList as $thisCourseTool) {
        $tmp[$thisCourseTool['label']] = $thisCourseTool['toolId'];
    }
    // 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);
        }
Пример #28
0
/**
 * Get list of forums linked to ALL or a specific group.
 *
 * @param integer $groupId or ALL
 *        If param is 'ALL', all groups forums are returned
 *        otherwise the param is use as group id to filter result.
 * @return array of integer. Each integer is a forum id.
 */
function get_group_forum_list($groupId)
{
    $tbl_cdb_names = claro_sql_get_course_tbl();
    $tbl_forums = $tbl_cdb_names['bb_forums'];
    if ($groupId == 'ALL') {
        $sql = " SELECT forum_id\n                FROM `" . $tbl_forums . "`\n                where group_id IS NOT NULL";
    } else {
        $sql = " SELECT forum_id\n                FROM `" . $tbl_forums . "`\n                where group_id = " . (int) $groupId;
    }
    return claro_sql_query_fetch_all_rows($sql);
}
Пример #29
0
    // list of dirs to add in archive
    $filePathList[] = $question->questionDirSys;
    /*
     * BUILD THE ZIP ARCHIVE
     */
    // build and send the zip
    if (sendZip($question->getTitle(), $filePathList, $question->questionDirSys)) {
        exit;
    } else {
        $dialogBox->error(get_lang("Unable to send zip file"));
    }
}
if ($cmd == 'recupMultipleQuestions' && !is_null($exId)) {
    // add multiple question selection
    $sql = "SELECT `id` FROM `" . $tbl_quiz_question . "` ORDER BY `id`";
    $list = claro_sql_query_fetch_all_rows($sql);
    $ok = true;
    foreach ($list as $questionInfo) {
        $quId = $questionInfo['id'];
        if (isset($_REQUEST[$quId])) {
            if (!$exercise->addQuestion($quId)) {
                $ok = false;
            }
        }
    }
    if ($ok) {
        // TODO show confirmation and back link
        header('Location: ' . Url::Contextualize('edit_exercise.php?exId=' . $exId));
    }
}
/*
Пример #30
0
/**
 * Is tool visible
 *
 * @param integer $tid tool identifier
 * @param string courseId
 * @todo to move in a lib
 *
 * @return boolean 'true' if it's visible
 */
function claro_is_tool_visible($tid, $courseId)
{
    global $_mainToolId;
    static $toolVisibilityCache = false;
    // load tool id
    if (is_null($tid)) {
        if (!empty($_mainToolId)) {
            $tid = $_mainToolId;
        } else {
            return false;
        }
    }
    // load course id
    if (is_null($courseId)) {
        if (claro_is_in_a_course()) {
            $courseId = claro_get_current_course_id();
        } else {
            return false;
        }
    }
    if (!$toolVisibilityCache) {
        $toolVisibilityCache = array();
        $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($courseId));
        $sql = " SELECT tool_id, visibility\n                 FROM `" . $tbl_cdb_names['tool'] . "`";
        $tool_visibilityTmp = claro_sql_query_fetch_all_rows($sql);
        foreach ($tool_visibilityTmp as $tool) {
            $toolVisibilityCache[$tool['tool_id']] = $tool['visibility'];
        }
    }
    return (bool) $toolVisibilityCache[$tid];
}