示例#1
0
 protected function isDocumentDownloadableInCourse($requestedUrl)
 {
     if (claro_is_in_a_group()) {
         $groupContext = true;
         $courseContext = false;
         $is_allowedToEdit = claro_is_group_member() || claro_is_group_tutor() || claro_is_course_manager();
     } else {
         $groupContext = false;
         $courseContext = true;
         $is_allowedToEdit = claro_is_course_manager();
     }
     if ($courseContext) {
         $courseTblList = claro_sql_get_course_tbl();
         $tbl_document = $courseTblList['document'];
         if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
             $modifier = '';
         } else {
             $modifier = 'BINARY ';
         }
         $sql = "SELECT visibility\n                    FROM `{$tbl_document}`\n                    WHERE {$modifier} path = '" . claro_sql_escape($requestedUrl) . "'";
         $docVisibilityStatus = claro_sql_query_get_single_value($sql);
         if (!is_null($docVisibilityStatus) && $docVisibilityStatus == 'i' && !$is_allowedToEdit) {
             return false;
         } else {
             return true;
         }
     } else {
         // ????
     }
 }
示例#2
0
 public function __construct($courseId, $userId)
 {
     $this->courseId = $courseId;
     $this->userId = (int) $userId;
     $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($this->courseId));
     $this->tbl_course_tracking_event = $tbl_cdb_names['tracking_event'];
 }
示例#3
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);
}
 public function __construct($courseCode)
 {
     $this->courseCode = $courseCode;
     $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($this->courseCode));
     $tblToolIntro = $tbl_cdb_names['tool_intro'];
     $sql = "SELECT id, tool_id, title, display_date,\n                content, rank, visibility\n                FROM `{$tblToolIntro}`\n                ORDER BY rank ASC";
     $this->toolIntroductions = Claroline::getDatabase()->query($sql);
 }
示例#5
0
 public function __construct($courseId, $userId)
 {
     $this->courseId = $courseId;
     $this->userId = (int) $userId;
     $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($this->courseId));
     $this->tbl_wrk_assignment = $tbl_cdb_names['wrk_assignment'];
     $this->tbl_wrk_submission = $tbl_cdb_names['wrk_submission'];
     $this->tbl_group_team = $tbl_cdb_names['group_team'];
 }
示例#6
0
 protected function loadTopic($topicId)
 {
     $tbl_cdb_names = claro_sql_get_course_tbl();
     $tbl_posts = $tbl_cdb_names['bb_posts'];
     $tbl_posts_text = $tbl_cdb_names['bb_posts_text'];
     $sql = "SELECT  p.`post_id`,   p.`topic_id`,  p.`forum_id`,\n                    p.`poster_id`, p.`post_time`, p.`poster_ip`,\n                    p.`nom` lastname, p.`prenom` firstname,\n                    pt.`post_text`\n\n           FROM     `" . $tbl_posts . "`      p,\n                    `" . $tbl_posts_text . "` pt\n\n           WHERE    topic_id  = '" . (int) $topicId . "'\n             AND    p.post_id = pt.`post_id`\n\n           ORDER BY post_id";
     $postsList = claro_sql_query_fetch_all($sql);
     return $postsList;
 }
示例#7
0
 /**
  * constructor
  *
  * @param $course_id
  */
 public function __construct($course_id = null)
 {
     $this->id = (int) -1;
     $this->category = -1;
     $this->title = '';
     $this->content = '';
     $this->lastEditDate = time();
     $this->visibility = 'VISIBLE';
     $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($course_id));
     $this->tblCourseDescription = $tbl_cdb_names['course_description'];
 }
示例#8
0
 function buildRecords($exportUserInfo = true)
 {
     $tbl_mdb_names = claro_sql_get_main_tbl();
     $tbl_user = $tbl_mdb_names['user'];
     $tbl_rel_course_user = $tbl_mdb_names['rel_course_user'];
     $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($this->course_id));
     $tbl_team = $tbl_cdb_names['group_team'];
     $tbl_rel_team_user = $tbl_cdb_names['group_rel_team_user'];
     $username = claro_is_platform_admin() && get_conf('export_sensitive_data_for_admin', false) || get_conf('export_user_username', false) ? "`U`.`username`     AS `username`," : "";
     if (claro_is_platform_admin() && get_conf('export_sensitive_data_for_admin', false) || get_conf('export_user_password', false)) {
         if (claro_is_platform_admin() && get_conf('export_sensitive_data_for_admin', false) || get_conf('export_user_password_encrypted', true)) {
             $password = "******";
         } else {
             $password = "******";
         }
     } else {
         $password = '';
     }
     // get user list
     $sql = "SELECT `U`.`user_id`      AS `userId`,\n                       `U`.`nom`          AS `lastname`,\n                       `U`.`prenom`       AS `firstname`,\n                       {$username}\n                       {$password}\n                       `U`.`email`        AS `email`,\n                       `U`.`officialCode`     AS `officialCode`,\n                       GROUP_CONCAT(`G`.`id`) AS `groupId`,\n                       GROUP_CONCAT(`G`.`name`) AS `groupName`\n               FROM\n                    (\n                    `" . $tbl_user . "`           AS `U`,\n                    `" . $tbl_rel_course_user . "` AS `CU`\n                    )\n               LEFT JOIN `" . $tbl_rel_team_user . "` AS `GU`\n                ON `U`.`user_id` = `GU`.`user`\n               LEFT JOIN `" . $tbl_team . "` AS `G`\n                ON `GU`.`team` = `G`.`id`\n               WHERE `U`.`user_id` = `CU`.`user_id`\n               AND   `CU`.`code_cours`= '" . claro_sql_escape($this->course_id) . "'\n               GROUP BY U.`user_id`\n               ORDER BY U.`user_id`";
     $userList = claro_sql_query_fetch_all($sql);
     // build recordlist with good values for answers
     if (is_array($userList) && !empty($userList)) {
         // add titles at row 0, for that get the keys of the first row of array
         $this->recordList[0] = array_keys($userList[0]);
         $i = 1;
         $userIdList = array();
         foreach ($userList as $user) {
             $userIdList[$user['userId']] = $i;
             if (!(claro_is_platform_admin() && get_conf('export_sensitive_data_for_admin', false) || get_conf('export_user_id', false))) {
                 $user['userId'] = $i;
             }
             // $this->recordList is defined in parent class csv
             $this->recordList[$i] = $user;
             $i++;
         }
         if ($exportUserInfo) {
             $userInfoList = new UserInfoList($this->course_id);
             $userInfoLabelList = $userInfoList->getUserInfoLabels();
             foreach ($userInfoLabelList as $catId => $catTitle) {
                 $this->recordList[0][] = $catTitle;
                 $userCatInfo = $userInfoList->getUserInfo($catId);
                 foreach ($userCatInfo as $userCatInfo) {
                     $this->recordList[$userIdList[$userCatInfo['userId']]][] = $userCatInfo['content'];
                 }
             }
         }
     }
     if (is_array($this->recordList) && !empty($this->recordList)) {
         return true;
     } else {
         return false;
     }
 }
示例#9
0
/**
 * create wiki MainPage
 * @param DatabaseConnection con database connection
 * @param int wikiId ID of the Wiki the page belongs to
 * @param int creatorId ID of the user who creates the page
 * @return boolean true if the creation succeeds, false if it fails
 */
function init_wiki_main_page($con, $wikiId, $creatorId, $wikiTitle)
{
    $tblList = claro_sql_get_course_tbl();
    $mainPageContent = get_lang("This is the main page of the Wiki %wikiTitle. Click on '''Edit''' to modify the content.", array('%wikiTitle' => $wikiTitle));
    $config = array();
    // use claro functions
    $config["tbl_wiki_pages"] = $tblList["wiki_pages"];
    $config["tbl_wiki_pages_content"] = $tblList["wiki_pages_content"];
    $wikiPage = new WikiPage($con, $config, $wikiId);
    $wikiPage->create($creatorId, '__MainPage__', $mainPageContent, date("Y-m-d H:i:s"), true);
    return !$wikiPage->hasError();
}
示例#10
0
 /**
  * Constructor
  *
  * @param integer $id
  * @param string $courseCode
  */
 public function __construct($id = null, $courseCode = null, $toolId = null, $title = '', $content = '', $rank = null, $displayDate = null, $visibility = 'SHOW')
 {
     $this->id = $id;
     $this->couseCode = $courseCode;
     $this->toolId = $toolId;
     $this->title = $title;
     $this->content = $content;
     $this->rank = $rank;
     $this->displayDate = $displayDate;
     $this->visibility = $visibility;
     $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($this->couseCode));
     $this->tblToolIntro = $tbl_cdb_names['tool_intro'];
 }
示例#11
0
/**
 * get all the items
 *
 * @param $courseId string  glued dbName of the course to affect default: current course
 *
 * @return array of arrays with data of the item
 *
 * @author Christophe Gesché <*****@*****.**>
 *
 */
function course_description_get_item_list($courseId = null)
{
    $tbl = claro_sql_get_course_tbl(claro_get_course_db_name_glued($courseId));
    $tblCourseDescription = $tbl['course_description'];
    if (get_conf('cldsc_use_new_ordering_of_labels')) {
        // sort first the principal categories
        $sql = "SELECT `cd`.`id`,\n\t                   `cd`.`category`,\n\t                   `cd`.`title`,\n\t                   `cd`.`content`,\n\t                UNIX_TIMESTAMP(cd.`lastEditDate`)\n\t                   AS `unix_lastEditDate`,\n\t                   `cd`.`visibility`\n\t            FROM `" . $tblCourseDescription . "` AS `cd`\n\t            WHERE `cd`.`category` != '-1'\n\t            ORDER BY `cd`.`category` ASC";
        // and then the "other" category ... by title
        $sql2 = "SELECT cd.`id`,\n\t                   cd.`category`,\n\t                   cd.`title`,\n\t                   cd.`content`,\n\t                UNIX_TIMESTAMP(`cd`.`lastEditDate`)\n\t                   AS `unix_lastEditDate`,\n\t                   `cd`.`visibility`\n\t            FROM `" . $tblCourseDescription . "` AS `cd`\n\t            WHERE `cd`.`category` = '-1'\n\t            ORDER BY `cd`.`title` ASC";
        return array_merge(claro_sql_query_fetch_all($sql), claro_sql_query_fetch_all($sql2));
    } else {
        $sql = "SELECT `cd`.`id`,\n\t                   `cd`.`category`,\n\t                   `cd`.`title`,\n\t                   `cd`.`content`,\n\t                UNIX_TIMESTAMP(cd.`lastEditDate`)\n\t                   AS `unix_lastEditDate`,\n\t                   `cd`.`visibility`\n\t            FROM `" . $tblCourseDescription . "` AS `cd`\n\t            ORDER BY `cd`.`category` ASC";
        return claro_sql_query_fetch_all($sql);
    }
}
示例#12
0
function delete_wiki($groupId)
{
    $tblList = claro_sql_get_course_tbl();
    $config = array();
    $config["tbl_wiki_properties"] = $tblList["wiki_properties"];
    $config["tbl_wiki_pages"] = $tblList["wiki_pages"];
    $config["tbl_wiki_pages_content"] = $tblList["wiki_pages_content"];
    $config["tbl_wiki_acls"] = $tblList["wiki_acls"];
    $con = Claroline::getDatabase();
    $store = new WikiStore($con, $config);
    if (strtoupper($groupId) == 'ALL') {
        $wikiList = $store->getGroupWikiList();
    } else {
        $wikiList = $store->getWikiListByGroup($groupId);
    }
    if (count($wikiList) > 0) {
        foreach ($wikiList as $wiki) {
            $store->deleteWiki($wiki['id']);
        }
    }
}
示例#13
0
 public function __construct($courseId, $userId)
 {
     $this->courseId = $courseId;
     $this->userId = (int) $userId;
     $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($this->courseId));
     $this->tbl_bb_topics = $tbl_cdb_names['bb_topics'];
     $this->tbl_bb_posts = $tbl_cdb_names['bb_posts'];
 }
示例#14
0
/**
 * delete a course of the plateform
 *
 * TODO detect failure with claro_failure
 *
 * @param string $cid
 *
 * @return boolean TRUE        if suceed
 *         boolean FALSE       otherwise.
 */
function delete_course($code, $sourceCourseId)
{
    global $eventNotifier;
    // Declare needed tables
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_course = $tbl_mdb_names['course'];
    $tbl_rel_course_user = $tbl_mdb_names['rel_course_user'];
    $tbl_course_class = $tbl_mdb_names['rel_course_class'];
    $tbl_rel_course_category = $tbl_mdb_names['rel_course_category'];
    $tbl_rel_course_portlet = $tbl_mdb_names['rel_course_portlet'];
    $this_course = claro_get_course_data($code);
    if (!$this_course) {
        // This is bad !
        throw new Exception("Course not found");
    }
    $currentCourseId = trim($this_course['sysCode']);
    if (empty($currentCourseId)) {
        // This is bad !
        throw new Exception("Missing course id");
    }
    // Delete user registrations into this course
    $sql = 'DELETE FROM `' . $tbl_rel_course_user . '`
            WHERE code_cours="' . $currentCourseId . '"';
    claro_sql_query($sql);
    // Remove any recording in rel_cours_class
    $sql = "DELETE FROM `" . $tbl_course_class . "`\n            WHERE courseId ='" . claro_sql_escape($currentCourseId) . "'";
    claro_sql_query($sql);
    // Remove links between this course and categories
    $sql = "DELETE FROM `" . $tbl_rel_course_category . "`\n            WHERE courseId ='" . $this_course['id'] . "'";
    claro_sql_query($sql);
    // Remove links between this course and portlets
    $sql = "DELETE FROM `" . $tbl_rel_course_portlet . "`\n            WHERE courseId ='" . $this_course['id'] . "'";
    claro_sql_query($sql);
    // Delete the course inside the platform course registery
    $sql = 'DELETE FROM `' . $tbl_course . '`
            WHERE code= "' . claro_sql_escape($currentCourseId) . '"';
    claro_sql_query($sql);
    // Is it a session course ?
    if (!is_null($sourceCourseId)) {
        // Does the source course still have session courses ?
        $sql = "SELECT COUNT(cours_id) AS nbSessionCourses\n                FROM `" . $tbl_course . "`\n                WHERE sourceCourseId = " . (int) $sourceCourseId;
        $result = claro_sql_query_get_single_row($sql);
        if ($result['nbSessionCourses'] == 0) {
            $sql = "UPDATE `" . $tbl_course . "`\n                    SET isSourceCourse = 0\n                    WHERE cours_id = " . (int) $sourceCourseId;
            claro_sql_query($sql);
        }
    }
    // Delete course right
    RightCourseProfileToolRight::resetAllRightProfile($currentCourseId);
    // Delete course module tables
    // FIXME handle errors
    list($success, $log) = delete_all_modules_from_course($currentCourseId);
    // Notify the course deletion event
    $args['cid'] = $this_course['sysCode'];
    $args['tid'] = null;
    $args['rid'] = null;
    $args['gid'] = null;
    $args['uid'] = $GLOBALS['_uid'];
    $eventNotifier->notifyEvent("course_deleted", $args);
    if ($currentCourseId == $code) {
        $currentCourseDbName = trim($this_course['dbName']);
        $currentCourseDbNameGlu = trim($this_course['dbNameGlu']);
        $currentCoursePath = trim($this_course['path']);
        if (empty($currentCourseDbName)) {
            // This is bad !
            throw new Exception("Missing db name");
        }
        if (empty($currentCourseDbNameGlu)) {
            // This is bad !
            throw new Exception("Missing db name glu");
        }
        if (get_conf('singleDbEnabled')) {
            // SEARCH ALL TABLES RELATED TO THE CURRENT COURSE
            claro_sql_query("use " . get_conf('mainDbName'));
            $tbl_to_delete = claro_sql_get_course_tbl(claro_get_course_db_name_glued($currentCourseId));
            foreach ($tbl_to_delete as $tbl_name) {
                $sql = 'DROP TABLE IF EXISTS `' . $tbl_name . '`';
                claro_sql_query($sql);
            }
            // Underscores must be replaced because they are used as wildcards in LIKE sql statement
            $cleanCourseDbNameGlu = str_replace("_", "\\_", $currentCourseDbNameGlu);
            $sql = 'SHOW TABLES LIKE "' . $cleanCourseDbNameGlu . '%"';
            $result = claro_sql_query($sql);
            // DELETE ALL TABLES OF THE CURRENT COURSE
            $tblSurvivor = array();
            while (false !== ($courseTable = mysql_fetch_array($result, MYSQL_NUM))) {
                $tblSurvivor[] = $courseTable[0];
                //$tblSurvivor[$courseTable]='not deleted';
            }
            if (sizeof($tblSurvivor) > 0) {
                Claroline::getInstance()->log('DELETE_COURSE', array_merge(array('DELETED_COURSE_CODE' => $code, 'UNDELETED_TABLE_COUNTER' => sizeof($tblSurvivor)), $tblSurvivor));
            }
        } else {
            $sql = "DROP DATABASE `" . $currentCourseDbName . "`";
            claro_sql_query($sql);
        }
        // MOVE THE COURSE DIRECTORY INTO THE COURSE GARBAGE COLLECTOR
        if (!empty($currentCoursePath)) {
            if (file_exists(get_conf('coursesRepositorySys') . $currentCoursePath . '/')) {
                claro_mkdir(get_conf('garbageRepositorySys'), CLARO_FILE_PERMISSIONS, true);
                rename(get_conf('coursesRepositorySys') . $currentCoursePath . '/', get_conf('garbageRepositorySys', 'garbage') . '/' . $currentCoursePath . '_' . date('YmdHis'));
            } else {
                Console::warning("DELETE_COURSE : Course directory not found {$currentCoursePath} for course {$currentCourseId}");
            }
            Claroline::log('COURSE_DELETED', array('courseCode' => $currentCourseId, 'courseDbName' => $currentCourseDbName, 'courseDbNameGlu' => $currentCourseDbNameGlu, 'coursePath' => $currentCoursePath));
            return true;
        } else {
            Console::error("DELETE_COURSE : Try to delete a course repository with no folder name {$currentCourseId} !");
            return true;
        }
    } else {
        return false;
    }
}
示例#15
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;
    }
}
示例#16
0
文件: wiki.php 项目: rhertzog/lcs
    }
    if ($wikiACL['other_read'] == false && $wikiACL['other_edit'] == true) {
        $wikiACL['other_edit'] = false;
    }
    if ($wikiACL['course_edit'] == false && $wikiACL['course_create'] == true) {
        $wikiACL['course_create'] = false;
    }
    if ($wikiACL['group_edit'] == false && $wikiACL['group_create'] == true) {
        $wikiACL['group_create'] = false;
    }
    if ($wikiACL['other_edit'] == false && $wikiACL['other_create'] == true) {
        $wikiACL['other_create'] = false;
    }
}
// Database nitialisation
$tblList = claro_sql_get_course_tbl();
$config = array();
$config['tbl_wiki_properties'] = $tblList['wiki_properties'];
$config['tbl_wiki_pages'] = $tblList['wiki_pages'];
$config['tbl_wiki_pages_content'] = $tblList['wiki_pages_content'];
$config['tbl_wiki_acls'] = $tblList['wiki_acls'];
$con = Claroline::getDatabase();
// DEVEL_MODE database initialisation
if (defined('DEVEL_MODE') && DEVEL_MODE == true) {
    init_wiki_tables($con, false);
}
// Objects instantiation
$wikiStore = new WikiStore($con, $config);
$wikiList = array();
// --------- Start of command processing ----------------
switch ($action) {
示例#17
0
/**
 * Execute repair query on course table
 *
 * @since  1.7
 */
function sql_repair_course_database($courseDbNameGlu)
{
    $tbl_names = claro_sql_get_course_tbl($courseDbNameGlu);
    foreach ($tbl_names as $tbl) {
        $sql = "REPAIR TABLE `" . $tbl . "`";
        mysql_query($sql);
    }
}
示例#18
0
 /**
  * Get the properties of the user in the current Group/Team
  * @param Claro_User $userObj
  * @return stdClass user properties record :
  *      $userProperties->isGroupMember : boolean
  *      $userProperties->status : boolean
  *      $userProperties->role : string or null
  *      $userProperties->isGroupTutor : boolean
  */
 public function getUserPropertiesInGroup(Claro_User $userObj)
 {
     if (!$this->_rawData) {
         throw new Exception("Group data not loaded !");
     }
     $tbl = claro_sql_get_course_tbl($this->_courseObj->dbNameGlu);
     $sql = "SELECT\n                    status,\n                    role\n                FROM\n                    `{$tbl['group_rel_team_user']}`\n                WHERE\n                    `user` = {$userObj->userId}\n                AND\n                    `team`   = {$this->_groupId};";
     $result = Claroline::getDatabase()->query($sql)->fetch();
     $userProperties = new stdClass();
     if (!$result) {
         $userProperties->isGroupMember = false;
         $userProperties->status = false;
         $userProperties->role = null;
         $userProperties->isGroupTutor = $this->_rawData['tutorId'] == $userId;
     } else {
         $userProperties->isGroupMember = true;
         $userProperties->status = $result['status'];
         $userProperties->role = $result['role'];
         $userProperties->isGroupTutor = $this->_rawData['tutorId'] == $userId;
     }
     return $userProperties;
 }
示例#19
0
function clann_get_max_and_min_rank($course_id = null)
{
    $course_id = is_null($course_id) ? claro_get_current_course_id() : $course_id;
    $tbl = claro_sql_get_course_tbl(claro_get_course_db_name_glued($course_id));
    return Claroline::getDatabase()->query("\n      SELECT \n        MAX(ordre) AS maxRank,\n        MIN(ordre) AS minRank\n     FROM `" . $tbl['announcement'] . "`")->fetch();
}
示例#20
0
    claro_die(get_lang('Tracking has been disabled by system administrator.'));
}
if (!claro_is_in_a_course() || !claro_is_course_allowed()) {
    claro_disp_auth_form();
}
if (!claro_is_course_manager()) {
    claro_die(get_lang('Not allowed'));
}
/*
 * Libraries
 */
require_once get_path('incRepositorySys') . '/lib/statsUtils.lib.inc.php';
/*
 * DB tables definition
 */
$tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued(claro_get_current_course_id()));
$tbl_course_tracking_event = $tbl_cdb_names['tracking_event'];
/*
 * Input
 */
if (!empty($_REQUEST['displayType']) && in_array($_REQUEST['displayType'], array('month', 'day', 'hour'))) {
    $displayType = $_REQUEST['displayType'];
} else {
    $displayType = '';
}
if (!empty($_REQUEST['period']) && in_array($_REQUEST['period'], array('year', 'month', 'day'))) {
    $period = $_REQUEST['period'];
} else {
    $period = 'day';
}
if (!empty($_REQUEST['reqdate'])) {
示例#21
0
/**
 * Save a course property in 'course_properties' table
 * @param  string $propertyName
 * @param  string $propertyValue
 * @param  string $cid
 * @return boolean true on success, false on failure
 * @author Jean-Roch Meurisse <*****@*****.**>
 * @since 1.9.5
 */
function save_course_property($propertyName, $propertyValue, $cid)
{
    $tbl_cdb_names = claro_sql_get_course_tbl();
    $tbl_course_properties = $tbl_cdb_names['course_properties'];
    $check = "SELECT `id`\n           FROM `" . $tbl_course_properties . "`\n          WHERE `name` = " . Claroline::getDatabase()->quote($propertyName) . "\n            AND `category` = 'MAIN'";
    $exists = Claroline::getDatabase()->query($check)->numRows();
    if ($exists) {
        $statement = "UPDATE `" . $tbl_course_properties . "`\n                SET `value` = " . Claroline::getDatabase()->quote($propertyValue) . "\n              WHERE `name` = " . Claroline::getDatabase()->quote($propertyName) . "\n                AND `category` = 'MAIN'";
    } else {
        $statement = "INSERT INTO `" . $tbl_course_properties . "`\n                     SET `name` = " . Claroline::getDatabase()->quote($propertyName) . ",\n                         `value` = " . Claroline::getDatabase()->quote($propertyValue) . ",\n                         `category` = 'MAIN'";
    }
    return Claroline::getDatabase()->exec($statement);
}
示例#22
0
文件: server.php 项目: rhertzog/lcs
/**
 * get user parameter on the base of a cookie value
 *
 * @author Hugues Peeters <*****@*****.**>
 * @param string $auth
 * @param string $cookie
 * @param string $cid
 * @param int    $gid
 * @return array   user parameters if it suceeds
 *         boolean false otherwise
 */
function get_user_info_from_cookie($auth, $cookie, $cid, $gid)
{
    if (!is_allowed_to_receive_user_info($auth)) {
        return null;
    }
    $res = array('userLastname' => null, 'userFirstname' => null, 'userLoginName' => null, 'userEmail' => null, 'userOfficialCode' => null, 'ssoCookieName' => null, 'ssoCookieValue' => null, 'ssoCookieExpireTime' => null, 'ssoCookieDomain' => null, 'ssoCookiePath' => null, 'courseTitle' => null, 'courseTitular' => null, 'courseCode' => null, 'courseDbName' => null, 'courseRegistrationAllowed' => null, 'courseVisibility' => null, 'courseAccess' => null, 'is_courseMember' => null, 'is_courseTutor' => null, 'is_courseAdmin' => null, 'is_courseAllowed' => null, 'groupName' => null, 'groupDescription' => null, 'groupPrivate' => null, 'is_groupMember' => null, 'is_groupTutor' => null, 'is_groupAllowed' => null);
    $ssoCookieName = get_conf('ssoCookieName');
    $ssoCookieDomain = get_conf('ssoCookieDomain');
    $ssoCookiePath = get_conf('ssoCookiePath');
    $ssoCookieExpireTime = time() + get_conf('ssoCookiePeriodValidity', 3600);
    $mainTblList = claro_sql_get_main_tbl();
    $tbl_user = $mainTblList['user'];
    $tbl_sso = $mainTblList['sso'];
    $sql = "SELECT user.nom          lastname,\n                   user.prenom       firstname,\n                   user.username     loginName,\n                   user.email        email,\n                   user.officialCode officialCode,\n                   user.user_id      userId\n\n            FROM `" . $tbl_sso . "`  AS sso,\n                 `" . $tbl_user . "` AS user\n            WHERE cookie = '" . $cookie . "'\n              AND user.user_id = sso.user_id";
    $userResult = claro_sql_query_fetch_all($sql);
    if (count($userResult) > 0) {
        $user = $userResult[0];
        $uid = $user['userId'];
        $res['userLastname'] = $user['lastname'];
        $res['userFirstname'] = $user['firstname'];
        $res['userLoginName'] = $user['loginName'];
        $res['userEmail'] = $user['email'];
        $res['userOfficialCode'] = $user['officialCode'];
        $newSsoCookieValue = generate_cookie();
        record_sso_cookie($uid, $newSsoCookieValue);
        $res['ssoCookieName'] = $ssoCookieName;
        $res['ssoCookieValue'] = $newSsoCookieValue;
        $res['ssoCookieExpireTime'] = $ssoCookieExpireTime;
        $res['ssoCookieDomain'] = $ssoCookieDomain;
        $res['ssoCookiePath'] = $ssoCookiePath;
    } else {
        return null;
    }
    if ($uid && $cid) {
        $tbl_course = $mainTblList['course'];
        // for claroline 1.6
        // $tbl_course          = $mainTblList['cours'       ]; // for claroline 1.5
        $tbl_rel_course_user = $mainTblList['rel_course_user'];
        $sql = "SELECT `c`.`intitule`              AS title,\n                       `c`.`administrativeNumber`  AS officialCode,\n                       `c`.`titulaires`            AS titular,\n                       `c`.`dbName`                AS dbName,\n                       `c`.`visibility`            AS visibility,\n                       `c`.`access`                AS access,\n                       `c`.`registration`          AS registration,\n                       `cu`.`isCourseManager`      AS isCourseManager,\n                       `cu`.`role`                 AS userRole,\n                       `cu`.`tutor`                AS tutor\n                FROM      `" . $tbl_course . "`          AS c\n                LEFT JOIN `" . $tbl_rel_course_user . "` AS cu\n                ON    `c`.`code`     = `cu`.`code_cours`\n                AND   `cu`.`user_id` = " . (int) $uid . "\n                WHERE `c`.`code`     = '" . $cid . "'";
        $courseResult = claro_sql_query_fetch_all($sql);
        if (count($courseResult > 0)) {
            $course = $courseResult[0];
            $res['courseTitle'] = $course['title'];
            $res['courseTitular'] = $course['titular'];
            $res['courseCode'] = $course['officialCode'];
            $res['courseDbName'] = $course['dbName'];
            $res['courseRegistrationAllowed'] = (bool) ($course['registration'] == 'OPEN');
            $res['courseVisibility'] = (bool) ($course['visibility'] == 'VISIBLE');
            $res['courseAccess'] = (bool) ($course['access'] == 'PUBLIC');
            $res['is_courseMember'] = (bool) (!is_null($course['userStatus']));
            $res['is_courseTutor'] = (bool) ($course['tutor'] == 1);
            $res['is_courseAdmin'] = (bool) ($course['isCourseManager'] == 1);
            $res['is_courseAllowed'] = (bool) ($course['visibility'] || $course['is_courseMember']);
        }
    }
    if ($uid && $cid && $gid) {
        $courseTblList = claro_sql_get_course_tbl(claro_get_course_db_name_glued($cid));
        $tbl_group_team = $courseTblList['group_team'];
        $tbl_group_property = $courseTblList['group_property'];
        $tbl_group_rel_team_user = $courseTblList['group_rel_team_user'];
        $sql = "SELECT g.`name`,\n                       g.`description`,\n                       g.`tutor` tutorId,\n                       gp.`private`,\n                       gp.`self_registration`,\n                       gtu.`user`,\n                       gtu.`team`,\n                       gtu.`status`,\n                       gtu.`role`\n                FROM `" . $tbl_group_team . "`          AS g,\n                     `" . $tbl_group_property . "`      AS gp,\n                     `" . $tbl_group_rel_team_user . "` AS gtu\n                WHERE gtu.`user` = '" . $uid . "'\n                  AND gtu.`team` = '" . $gid . "'\n                  AND gtu.`team` = g.`id`";
        $groupResult = claro_sql_query_fetch_all($sql);
        if (count($groupResult) > 0) {
            $group = $groupResult[0];
            $res['groupName'] = $group['name'];
            $res['groupDescription'] = $group['description'];
            $res['groupPrivate'] = (bool) ($group['private'] == 1);
            $res['is_groupMember'] = (bool) ($group['user'] == $uid);
            $res['is_groupTutor'] = (bool) ($group['tutorId'] == $uid);
            $res['is_groupAllowed'] = (bool) ($group['is_groupMember'] || $group['is_groupTutor'] || !$group['private']);
        }
    }
    return $res;
}
示例#23
0
/**
 * move a tool up or down
 *
 * @author Hugues Peeters <*****@*****.**>
 * @param int $reqToolId - the tool to move
 * @param string $moveDirection - should be 'UP' or 'DOWN'
 * @return
 */
function move_course_tool($reqToolId, $moveDirection)
{
    $tbl_cdb_names = claro_sql_get_course_tbl();
    $tbl_course_tool_list = $tbl_cdb_names['tool'];
    if (strtoupper($moveDirection) == 'DOWN') {
        $sortDirection = 'DESC';
    } elseif (strtoupper($moveDirection) == 'UP') {
        $sortDirection = 'ASC';
    }
    if ($sortDirection) {
        $sql = "SELECT id, rank\n                FROM `" . $tbl_course_tool_list . "`\n                ORDER BY rank " . $sortDirection;
        $toolList = claro_sql_query_fetch_all($sql);
        $reqToolFound = false;
        // init reqToolFound with default value
        $reqToolRank = false;
        foreach ($toolList as $thisTool) {
            // STEP 2 : FOUND THE NEXT ANNOUNCEMENT ID AND ORDER.
            //          COMMIT ORDER SWAP ON THE DB
            if ($reqToolFound) {
                $nextToolId = $thisTool['id'];
                $nextToolRank = $thisTool['rank'];
                $sql = "UPDATE `" . $tbl_course_tool_list . "`\n                        SET rank = " . (int) $nextToolRank . "\n                        WHERE id = " . (int) $reqToolId;
                claro_sql_query($sql);
                $sql = "UPDATE `" . $tbl_course_tool_list . "`\n                        SET rank = " . (int) $reqToolRank . "\n                        WHERE id = " . (int) $nextToolId;
                claro_sql_query($sql);
                return true;
            }
            // STEP 1 : FIND THE ORDER OF THE ANNOUNCEMENT
            if ($thisTool['id'] == $reqToolId) {
                $reqToolRank = $thisTool['rank'];
                $reqToolFound = true;
            }
        }
        // end foreach toolList as thisTool
    }
    // end if sortDirection
}
示例#24
0
/**
 * Get the list of invisible documents of the current course
 *
 * @param $baseWorkDir path document
 * @param $cidReq course identifier
 * @return list of invisible document
 */
function getInvisibleDocumentList($baseWorkDir, $cidReq = null)
{
    $documentList = array();
    if (is_null($cidReq)) {
        $cid = claro_get_current_course_id();
    } else {
        $cid = $cidReq;
    }
    $tbl_cdb_names = claro_sql_get_course_tbl(claro_get_course_db_name_glued($cid));
    $tbl_document = $tbl_cdb_names['document'];
    $sql = "SELECT path\n            FROM `" . $tbl_document . "`\n            WHERE visibility = 'i'";
    $documentList = claro_sql_query_fetch_all_cols($sql);
    $documentList = $documentList['path'];
    for ($i = 0; $i < count($documentList); $i++) {
        $documentList[$i] = '/' . ltrim($baseWorkDir . $documentList[$i], '/');
    }
    return $documentList;
}
 function announcement_get_item($announcement_id, $course_id = NULL)
 {
     $tbl = claro_sql_get_course_tbl(claro_get_course_db_name_glued($course_id));
     $sql = "SELECT                id,\n\t\t\t\t\t\t\t\t\t  title,\n\t\t\t\t\t   contenu     AS content,\n\t\t\t\t\t\t   temps   AS `time`,\n\t\t\t\t\t\t\t\t\t  visibility,\n\t\t\t\t\t   ordre       AS rank\n\t\t\t\tFROM  `" . $tbl['announcement'] . "`\n\t\t\t\tWHERE id=" . (int) $announcement_id;
     $announcement = claro_sql_query_get_single_row($sql);
     if ($announcement) {
         return $announcement;
     } else {
         return claro_failure::set_failure('ANNOUNCEMENT_UNKNOW');
     }
 }
示例#26
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);
     }
 }
示例#27
0
/**
 * Return a list of user and  groups of these users
 *
 * @param array     context
 * @return array    list of users
 */
function get_group_member_list($context = array())
{
    $currentCourseId = array_key_exists(CLARO_CONTEXT_COURSE, $context) ? $context['CLARO_CONTEXT_COURSE'] : claro_get_current_course_id();
    $currentGroupId = array_key_exists(CLARO_CONTEXT_GROUP, $context) ? $context['CLARO_CONTEXT_GROUP'] : claro_get_current_group_id();
    $tblc = claro_sql_get_course_tbl();
    $tblm = claro_sql_get_main_tbl();
    $sql = "SELECT `ug`.`id`       AS id,\n               `u`.`user_id`       AS user_id,\n               `u`.`nom`           AS name,\n               `u`.`prenom`        AS firstname,\n               `u`.`email`         AS email,\n               `u`.`officialEmail` AS officialEmail,\n               `cu`.`role`         AS `role`\n        FROM (`" . $tblm['user'] . "`           AS u\n           , `" . $tblm['rel_course_user'] . "` AS cu\n           , `" . $tblc['group_rel_team_user'] . "` AS ug)\n        WHERE  `cu`.`code_cours` = '" . $currentCourseId . "'\n          AND   `cu`.`user_id`   = `u`.`user_id`\n          AND   `ug`.`team`      = " . (int) $currentGroupId . "\n          AND   `ug`.`user`      = `u`.`user_id`\n        ORDER BY UPPER(`u`.`nom`), UPPER(`u`.`prenom`), `u`.`user_id`";
    $result = Claroline::getDatabase()->query($sql);
    $result->setFetchMode(Database_ResultSet::FETCH_ASSOC);
    $usersInGroupList = array();
    foreach ($result as $member) {
        $label = claro_htmlspecialchars(ucwords(strtolower($member['name'])) . ' ' . ucwords(strtolower($member['firstname'])) . ($member['role'] != '' ? ' (' . $member['role'] . ')' : ''));
        $usersInGroupList[$member['user_id']] = $label;
    }
    return $usersInGroupList;
}
示例#28
0
/**
 * Install module databases at course creation
 */
function install_module_at_course_creation($moduleLabel, $courseDbName, $language, $courseDirectory)
{
    $sqlPath = get_module_path($moduleLabel) . '/setup/course_install.sql';
    $phpPath = get_module_path($moduleLabel) . '/setup/course_install.php';
    if (file_exists($sqlPath)) {
        if (!execute_sql_at_course_creation($sqlPath, $courseDbName)) {
            return false;
        }
    }
    if (file_exists($phpPath)) {
        // include the language file with all language variables
        language::load_translation($language);
        language::load_locale_settings($language);
        language::load_module_translation($moduleLabel, $language);
        // define tables to use in php install scripts
        $courseDbName = get_conf('courseTablePrefix') . $courseDbName . get_conf('dbGlu');
        $moduleCourseTblList = claro_sql_get_course_tbl($courseDbName);
        /*
         * @todo select database should not be needed if the setup scripts are
         * well written !
         */
        if (!get_conf('singleDbEnabled')) {
            claro_sql_select_db($courseDbName);
        }
        require_once $phpPath;
    }
    return true;
}
示例#29
0
 * @author      Claro Team <*****@*****.**>
 * @since       1.8
 */
$tlabelReq = 'CLWRK';
require '../inc/claro_init_global.inc.php';
if (!claro_is_in_a_course() || !claro_is_course_allowed()) {
    claro_disp_auth_form(true);
}
require_once './lib/assignment.class.php';
include_once get_path('incRepositorySys') . '/lib/fileManage.lib.php';
include_once get_path('incRepositorySys') . '/lib/pager.lib.php';
include_once get_path('incRepositorySys') . '/lib/group.lib.inc.php';
$tbl_mdb_names = claro_sql_get_main_tbl();
$tbl_user = $tbl_mdb_names['user'];
$tbl_rel_course_user = $tbl_mdb_names['rel_course_user'];
$tbl_cdb_names = claro_sql_get_course_tbl();
$tbl_wrk_submission = $tbl_cdb_names['wrk_submission'];
$tbl_group_team = $tbl_cdb_names['group_team'];
$tbl_group_rel_team_user = $tbl_cdb_names['group_rel_team_user'];
$currentUserFirstName = claro_get_current_user_data('firstName');
$currentUserLastName = claro_get_current_user_data('lastName');
// 'step' of pager
$usersPerPage = get_conf('usersPerPage', 20);
// use viewMode
claro_set_display_mode_available(true);
/*============================================================================
    Basic Variables Definitions
  ============================================================================*/
$fileAllowedSize = get_conf('max_file_size_per_works');
//file size in bytes (from config file)
$maxFilledSpace = get_conf('maxFilledSpace', 100000000);
示例#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];
}