/**
  * Load rights of a profile/course
  */
 public function load($profile)
 {
     // Load toolAction of the parent
     parent::load($profile);
     $this->defaultToolActionList = $this->getToolActionList();
     // load value of action of the courseId
     $sql = " SELECT PA.action_id, PA.value, A.tool_id, A.name\n                 FROM `" . $this->tbl['rel_profile_action'] . "` `PA`,\n                      `" . $this->tbl['action'] . "` `A`\n                 WHERE PA.profile_id = " . $this->profile->id . "\n                 AND PA.action_id = A.id\n                 AND PA.courseId = '" . claro_sql_escape($this->courseId) . "'";
     $action_list = claro_sql_query_fetch_all($sql);
     // load all actions value for the profile
     foreach ($action_list as $this_action) {
         $actionName = $this_action['name'];
         $actionValue = (bool) $this_action['value'];
         $toolId = $this_action['tool_id'];
         if (isset($this->toolActionList[$toolId][$actionName])) {
             $this->toolActionList[$toolId][$actionName] = $actionValue;
         }
     }
     // Remove deactivated tool
     $sql = "SELECT t.id\n                FROM `" . $this->tbl['module'] . "`  AS m,\n                    `" . $this->tbl['course_tool'] . "` AS t\n                WHERE t.claro_label = m.label\n                  AND m.activation <> 'activated'";
     $deactivatedToolList = claro_sql_query_fetch_all($sql);
     foreach ($deactivatedToolList as $deactivatedTool) {
         if (isset($this->toolActionList[$deactivatedTool['id']])) {
             unset($this->toolActionList[$deactivatedTool['id']]);
         }
         if (isset($this->defaultToolActionList[$deactivatedTool['id']])) {
             unset($this->defaultToolActionList[$deactivatedTool['id']]);
         }
     }
 }
Esempio n. 2
0
 /**
  * load answers in object
  *
  * @author Sebastien Piraux <*****@*****.**>
  * @return boolean result of operation
  */
 public function load()
 {
     $sql = "SELECT\n                    `answer`,\n                    `match`,\n                    `grade`,\n                    `code`\n            FROM `" . $this->tblAnswer . "`\n            WHERE `questionId` = " . (int) $this->questionId . "\n            ORDER BY `id` ASC";
     $answerList = claro_sql_query_fetch_all($sql);
     if (!empty($answerList)) {
         $this->leftList = array();
         $this->rightList = array();
         foreach ($answerList as $answer) {
             if (!is_null($answer['match'])) {
                 $this->addLeft($answer['answer'], $answer['match'], $answer['grade'], $answer['code']);
             } else {
                 $this->addRight($answer['answer'], $answer['code']);
             }
         }
         // ensure we have minimum requirements
         while (count($this->leftList) < 2) {
             // we need at least 2 answers !
             $this->addLeft();
         }
         while (count($this->rightList) < 2) {
             // we need at least 2 answers !
             $this->addRight();
         }
         shuffle($this->leftList);
         return true;
     } else {
         return false;
     }
 }
Esempio n. 3
0
/**
 * CLAROLINE
 *
 * @version     $Revision: 14314 $
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 * @license     http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE
 * @author      Piraux Sebastien <*****@*****.**>
 * @author      Lederer Guillaume <*****@*****.**>
 * @package     CLLNP
 * @since       1.8
 */
function lp_display_scorm($TABLELEARNPATHMODULE)
{
    $out = '';
    // change raw if value is a number between 0 and 100
    if (isset($_POST['newRaw']) && is_num($_POST['newRaw']) && $_POST['newRaw'] <= 100 && $_POST['newRaw'] >= 0) {
        $sql = "UPDATE `" . $TABLELEARNPATHMODULE . "`\n                SET `raw_to_pass` = " . (int) $_POST['newRaw'] . "\n                WHERE `module_id` = " . (int) $_SESSION['module_id'] . "\n                AND `learnPath_id` = " . (int) $_SESSION['path_id'];
        claro_sql_query($sql);
        $dialogBoxContent = get_lang('Minimum raw to pass has been changed');
    }
    $out .= '<hr noshade="noshade" size="1" />';
    //####################################################################################\\
    //############################### DIALOG BOX SECTION #################################\\
    //####################################################################################\\
    if (!empty($dialogBoxContent)) {
        $dialogBox = new DialogBox();
        $dialogBox->success($dialogBoxContent);
        $out .= $dialogBox->render();
    }
    // form to change raw needed to pass the exercise
    $sql = "SELECT `lock`, `raw_to_pass`\n            FROM `" . $TABLELEARNPATHMODULE . "` AS LPM\n           WHERE LPM.`module_id` = " . (int) $_SESSION['module_id'] . "\n             AND LPM.`learnPath_id` = " . (int) $_SESSION['path_id'];
    $learningPath_module = claro_sql_query_fetch_all($sql);
    if (isset($learningPath_module[0]['lock']) && $learningPath_module[0]['lock'] == 'CLOSE' && isset($learningPath_module[0]['raw_to_pass'])) {
        $out .= "\n\n" . '<form method="post" action="' . $_SERVER['PHP_SELF'] . '">' . "\n" . '<label for="newRaw">' . get_lang('Change minimum raw mark to pass this module (percentage) : ') . '</label>' . "\n" . '<input type="text" value="' . claro_htmlspecialchars($learningPath_module[0]['raw_to_pass']) . '" name="newRaw" id="newRaw" size="3" maxlength="3" /> % ' . "\n" . '<input type="submit" value="' . get_lang('Ok') . '" />' . "\n" . '</form>' . "\n\n";
    }
    return $out;
}
Esempio n. 4
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;
 }
Esempio n. 5
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;
     }
 }
Esempio n. 6
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);
    }
}
 /**
  * load answers in object
  *
  * @author Sebastien Piraux <*****@*****.**>
  * @return boolean result of operation
  */
 public function load()
 {
     $sql = "SELECT\n                    `id`,\n                    `answer`,\n                    `correct`,\n                    `grade`,\n                    `comment`\n            FROM `" . $this->tblAnswer . "`\n            WHERE `questionId` = " . (int) $this->questionId . "\n            ORDER BY `id`";
     $data = claro_sql_query_fetch_all($sql);
     if (!empty($data)) {
         $this->answerList = $data;
         if (count($data) == 1) {
             // it is not a normal comportment but we need at least 2 answers !
             $this->addAnswer();
         }
         return true;
     } else {
         return false;
     }
 }
Esempio n. 8
0
 public function loadUserList()
 {
     if (!$this->userList) {
         $tableName = get_module_main_tbl(array('user'));
         if (!is_null($this->getSelector())) {
             $limit = $this->getSelector()->getLimit();
             $where = $this->getSelector()->getStrategy();
             $order = $this->getSelector()->getOrder();
         } else {
             $limit = "";
             $where = "";
             $order = "";
         }
         $sql = "SELECT user_id AS id, nom AS lastname, prenom AS firstname, username" . " FROM `" . $tableName['user'] . "`" . " " . $where . " " . $order . " " . $limit;
         $this->userList = claro_sql_query_fetch_all($sql);
     }
 }
Esempio n. 9
0
 private function getUserWorks()
 {
     $sql = "SELECT `A`.`title` AS `a_title`,\n                   `A`.`assignment_type`,\n                   `S`.`id`, `S`.`title` AS `s_title`,\n                   `S`.`group_id`, `S`.`last_edit_date`, `S`.`authors`,\n                   `S`.`score`,\n                   `S`.`parent_id`,\n                   `G`.`name` AS `g_name`\n              FROM `" . $this->tbl_wrk_assignment . "` AS `A` ,\n                   `" . $this->tbl_wrk_submission . "` AS `S`\n              LEFT JOIN `" . $this->tbl_group_team . "` AS `G`\n                     ON `G`.`id` = `S`.`group_id`\n             WHERE `A`.`id` = `S`.`assignment_id`\n               AND ( `S`.`user_id` = " . (int) $this->userId . "\n                      OR ( `S`.`parent_id` IS NOT NULL AND `S`.`parent_id` ) )\n                    AND `A`.`visibility` = 'VISIBLE'\n             ORDER BY `A`.`title` ASC, `S`.`last_edit_date` ASC";
     $results = claro_sql_query_fetch_all($sql);
     $submissionList = array();
     // store submission details in list
     foreach ($results as $submission) {
         if (empty($submission['parent_id'])) {
             // is a submission
             $submissionList[$submission['id']] = $submission;
         }
     }
     // get scores
     foreach ($results as $submission) {
         if (!empty($submission['parent_id']) && isset($submissionList[$submission['parent_id']]) && is_array($submissionList[$submission['parent_id']])) {
             // is a feedback
             $submissionList[$submission['parent_id']]['score'] = $submission['score'];
         }
     }
     return $submissionList;
 }
Esempio n. 10
0
/**
 * Get all names of profile in an array where key are profileId
 * return array assoc profileId => profileName
 */
function claro_get_all_profile_name_list()
{
    $profileList = null;
    static $cachedProfileList = null;
    if ($cachedProfileList) {
        $profileList = $cachedProfileList;
    } else {
        $tbl_mdb_names = claro_sql_get_main_tbl();
        $tbl_profile = $tbl_mdb_names['right_profile'];
        $sql = "SELECT profile_id, name, label, description\n                FROM `" . $tbl_profile . "`\n                ORDER BY profile_id ";
        $result = claro_sql_query_fetch_all($sql);
        foreach ($result as $profile) {
            $profile_id = $profile['profile_id'];
            $profileList[$profile_id]['name'] = $profile['name'];
            $profileList[$profile_id]['label'] = $profile['label'];
            $profileList[$profile_id]['description'] = $profile['description'];
        }
        $cachedProfileList = $profileList;
        // cache for the next time ...
    }
    return $profileList;
}
Esempio n. 11
0
/**
 * Build a list of available exercises that wil be used by claro_html_form_select to show a filter list
 * @param $excludeId an exercise id that doesn't have to be shown in  filter list
 * @return array 2d array where keys are the exercise name and value is the exercise id
 * @author Sebastien Piraux <*****@*****.**>
 */
function get_filter_list($excludeId = '')
{
    $tbl_cdb_names = get_module_course_tbl(array('qwz_exercise'), claro_get_current_course_id());
    $tbl_quiz_exercise = $tbl_cdb_names['qwz_exercise'];
    $filterList[get_lang('All exercises')] = 'all';
    $filterList[get_lang('Orphan questions')] = 'orphan';
    // get exercise list
    $sql = "SELECT `id`, `title`\n              FROM `" . $tbl_quiz_exercise . "`\n              ORDER BY `title`";
    $exerciseList = claro_sql_query_fetch_all($sql);
    if (is_array($exerciseList) && !empty($exerciseList)) {
        foreach ($exerciseList as $anExercise) {
            if ($excludeId != $anExercise['id']) {
                $filterList[$anExercise['title']] = $anExercise['id'];
            }
        }
    }
    $questionCategoryList = getQuestionCategoryList();
    // category
    foreach ($questionCategoryList as $category) {
        $filterList[get_lang('Category') . ' ' . $category['title']] = 'categoryId' . $category['id'];
    }
    return $filterList;
}
Esempio n. 12
0
 /**
  * Load tool action list value of a profile
  */
 public function loadToolActionList()
 {
     // load all action for this profile type
     $sql = " SELECT A.id, A.name, A.tool_id, CT.claro_label\n                 FROM `" . $this->tbl['action'] . "` `A`,\n                      `" . $this->tbl['course_tool'] . "` `CT`\n                 WHERE type = '" . claro_sql_escape($this->profile->type) . "'\n                    AND A.tool_id = CT.id\n                 ORDER BY CT.def_rank";
     $actionResult = claro_sql_query_fetch_all($sql);
     // initialise all tool action
     foreach ($actionResult as $action) {
         $toolId = $action['tool_id'];
         $actionName = $action['name'];
         $this->toolActionList[$toolId][$actionName] = false;
     }
     // load value of action
     $sql = " SELECT PA.action_id, PA.value, A.tool_id, A.name\n                 FROM `" . $this->tbl['rel_profile_action'] . "` `PA`,\n                      `" . $this->tbl['action'] . "` `A`\n                 WHERE PA.profile_id = " . $this->profile->id . "\n                 AND PA.action_id = A.id\n                 AND PA.courseId = ''";
     $action_list = claro_sql_query_fetch_all($sql);
     // load all actions value for the profile
     foreach ($action_list as $this_action) {
         $actionName = $this_action['name'];
         $actionValue = (bool) $this_action['value'];
         $toolId = $this_action['tool_id'];
         if (isset($this->toolActionList[$toolId][$actionName])) {
             $this->toolActionList[$toolId][$actionName] = $actionValue;
         }
     }
 }
Esempio n. 13
0
 /**
  * Get related course to the current course (parent or child) for a
  * given user.
  *
  * @return array    courses
  * @since 1.11
  */
 public function getRelatedUserCourses($userId)
 {
     // Declare needed tables
     $tbl_mdb_names = claro_sql_get_main_tbl();
     $tbl_course = $tbl_mdb_names['course'];
     $tbl_rel_user_courses = $tbl_mdb_names['rel_course_user'];
     $sql = "SELECT c.cours_id               AS id,\n                       c.titulaires             AS titular,\n                       c.code                   AS sysCode,\n                       c.isSourceCourse         AS isSourceCourse,\n                       c.sourceCourseId         AS sourceCourseId,\n                       c.intitule               AS title,\n                       c.administrativeNumber   AS officialCode,\n                       c.language,\n                       c.directory,\n                       c.visibility,\n                       c.access,\n                       c.registration,\n                       c.email,\n                       c.status,\n                       c.userLimit\n                FROM `" . $tbl_course . "` AS c\n                \n                RIGHT JOIN `" . $tbl_rel_user_courses . "` AS rcu\n                ON rcu.user_id = " . (int) $userId . "\n                AND rcu.code_cours = c.code\n                \n                WHERE c.sourceCourseId = " . $this->id . "\n                OR c.cours_id = " . $this->id;
     if (!empty($this->sourceCourseId)) {
         $sql .= "\n                OR cours_id = " . $this->sourceCourseId . "\n                OR c.sourceCourseId = " . $this->sourceCourseId;
     }
     $sql .= "\n                ORDER BY c.isSourceCourse DESC, c.intitule ASC";
     return claro_sql_query_fetch_all($sql);
 }
Esempio n. 14
0
 private function getUserLastTenPosts()
 {
     $sql = "SELECT `bb_t`.`topic_id`,\n                        `bb_t`.`topic_title`,\n                        max(`bb_t`.`topic_time`) AS `last_message`\n                    FROM `" . $this->tbl_bb_posts . "`  AS `bb_p`\n                       , `" . $this->tbl_bb_topics . "` AS `bb_t`\n                    WHERE `bb_p`.`poster_id` = '" . (int) $this->userId . "'\n                      AND `bb_t`.`topic_id` = `bb_p`.`topic_id`\n                    GROUP BY `bb_t`.`topic_title`\n                    ORDER BY `bb_p`.`post_time` DESC\n                    LIMIT 10";
     $results = claro_sql_query_fetch_all($sql);
     return $results;
 }
Esempio n. 15
0
        }
        $sqlClauseString = implode("\n OR \n", $sqlClauseList);
    } else {
        $sqlClauseString = null;
    }
} else {
    $sqlClauseString = null;
}
if ($sqlClauseString) {
    $tbl_cdb_names = claro_sql_get_course_tbl();
    $tbl_posts_text = $tbl_cdb_names['bb_posts_text'];
    $tbl_posts = $tbl_cdb_names['bb_posts'];
    $tbl_topics = $tbl_cdb_names['bb_topics'];
    $tbl_forums = $tbl_cdb_names['bb_forums'];
    $sql = "SELECT pt.post_id,\n                       pt.post_text,\n                       p.nom         AS lastname,\n                       p.prenom      AS firstname,\n                       p.`poster_id`,\n                       p.post_time,\n                       t.topic_id,\n                       t.topic_title,\n                       f.forum_id,\n                       f.forum_name,\n                       f.group_id\n               FROM  `" . $tbl_posts_text . "` AS pt,\n                     `" . $tbl_posts . "`      AS p,\n                     `" . $tbl_topics . "`     AS t,\n                     `" . $tbl_forums . "`     AS f\n               WHERE ( " . $sqlClauseString . ")\n                 AND pt.post_id = p.post_id\n                 AND p.topic_id = t.topic_id\n                 AND t.forum_id = f.forum_id\n               ORDER BY p.post_time DESC, t.topic_id";
    $searchResultList = claro_sql_query_fetch_all($sql);
    $userGroupList = get_user_group_list(claro_get_current_user_id());
    $userGroupList = array_keys($userGroupList);
    $tutorGroupList = get_tutor_group_list(claro_get_current_user_id());
} else {
    $searchResultList = array();
}
$pagetype = 'viewsearch';
ClaroBreadCrumbs::getInstance()->prepend(get_lang('Forums'), 'index.php');
CssLoader::getInstance()->load('clfrm', 'screen');
$noPHP_SELF = true;
$out = '';
$out .= claro_html_tool_title(get_lang('Forums'), $is_allowedToEdit ? get_help_page_url('blockForumsHelp', 'CLFRM') : false);
$out .= claro_html_menu_horizontal(disp_forum_toolbar($pagetype, null)) . disp_forum_breadcrumb($pagetype, null, null, null) . '<h4>' . get_lang('Search result') . ' : ' . (isset($_REQUEST['searchPattern']) ? claro_htmlspecialchars($_REQUEST['searchPattern']) : '') . '</h4>' . "\n";
if (count($searchResultList) < 1) {
    $out .= '<p>' . get_lang('No result') . '</p>';
Esempio n. 16
0
/**
 * to know if user is registered to a course or not
 *
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 * @param  int     id of user in DB
 * @param  int     id of course in DB
 * @return boolean true if user is enrolled false otherwise
 */
function is_registered_to($user_id, $course_id)
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_rel_course_user = $tbl_mdb_names['rel_course_user'];
    $sql = "SELECT count(*) `user_reg`\n                 FROM `" . $tbl_rel_course_user . "`\n                 WHERE `code_cours` = '" . claro_sql_escape($course_id) . "' AND `user_id` = '" . (int) $user_id . "'";
    $res = claro_sql_query_fetch_all($sql);
    return (bool) ($res[0]['user_reg'] > 0);
}
Esempio n. 17
0
 private function getUserExerciceDetails($exerciseId)
 {
     $sql = "SELECT `id`, `date`, `result`, `weighting`, `time`\n                FROM `" . $this->tbl_qwz_tracking . "`\n                WHERE `exo_id` = " . (int) $exerciseId . "\n                AND `user_id` = " . (int) $this->userId . "\n                ORDER BY `date` ASC";
     $results = claro_sql_query_fetch_all($sql);
     return $results;
 }
Esempio n. 18
0
function class_exist()
{
    $tbl = claro_sql_get_main_tbl();
    $sql = "\n        SELECT id FROM `" . $tbl['class'] . "`";
    return claro_sql_query_fetch_all($sql);
}
Esempio n. 19
0
/**
 * Upgrade assignment tool to 1.6
 */
function assignment_upgrade_to_16($course_code)
{
    global $currentCourseVersion, $currentcoursePathSys, $currentCourseCreationDate;
    global $_uid;
    $versionRequiredToProceed = '/^1.5/';
    $tool = 'CLWRK';
    $currentCourseDbNameGlu = claro_get_course_db_name_glued($course_code);
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_rel_course_user = $tbl_mdb_names['rel_course_user'];
    $tbl_course_tool = $tbl_mdb_names['tool'];
    if (preg_match($versionRequiredToProceed, $currentCourseVersion)) {
        switch ($step = get_upgrade_status($tool, $course_code)) {
            case 1:
                /**
                 * STEP 1 Create new work table
                 */
                $sql_step1[] = "CREATE TABLE IF NOT EXISTS `" . $currentCourseDbNameGlu . "wrk_assignment` (\n                `id` int(11) NOT NULL auto_increment,\n                `title` varchar(200) NOT NULL default '',\n                `description` text NOT NULL,\n                `visibility` enum('VISIBLE','INVISIBLE') NOT NULL default 'VISIBLE',\n                `def_submission_visibility` enum('VISIBLE','INVISIBLE') NOT NULL default 'VISIBLE',\n                `assignment_type` enum('INDIVIDUAL','GROUP') NOT NULL default 'INDIVIDUAL',\n                `authorized_content` enum('TEXT','FILE','TEXTFILE') NOT NULL default 'FILE',\n                `allow_late_upload` enum('YES','NO') NOT NULL default 'YES',\n                `start_date` datetime NOT NULL default '0000-00-00 00:00:00',\n                `end_date` datetime NOT NULL default '0000-00-00 00:00:00',\n                `prefill_text` text NOT NULL,\n                `prefill_doc_path` varchar(200) NOT NULL default '',\n                `prefill_submit` enum('ENDDATE','AFTERPOST') NOT NULL default 'ENDDATE',\n                PRIMARY KEY  (`id`)\n                ) ENGINE=MyISAM";
                /*
                            $sql_step1[] = "UPDATE `".$currentCourseDbNameGlu."wrk_assignment`
                                SET
                                `end_date` = '".date('Y-m-d H:i:00', mktime( date('H'),date('i'),0,date('m'), date('d'), date('Y')+1 ) )."'
                                WHERE `end_date` = '0000-00-00 00:00:00'
                                ";
                */
                $sql_step1[] = "CREATE TABLE IF NOT EXISTS `" . $currentCourseDbNameGlu . "wrk_submission` (\n                `id` int(11) NOT NULL auto_increment,\n                `assignment_id` int(11) default NULL,\n                `parent_id` int(11) default NULL,\n                `user_id`  int(11) default NULL ,\n                `group_id` int(11) default NULL,\n                `title` varchar(200) NOT NULL default '',\n                `visibility` enum('VISIBLE','INVISIBLE') default 'VISIBLE',\n                `creation_date` datetime NOT NULL default '0000-00-00 00:00:00',\n                `last_edit_date` datetime NOT NULL default '0000-00-00 00:00:00',\n                `authors` varchar(200) NOT NULL default '',\n                `submitted_text` text NOT NULL,\n                `submitted_doc_path` varchar(200) NOT NULL default '',\n                `private_feedback` text,\n                `original_id` int(11) default NULL,\n                `score` smallint(3) default NULL,\n                PRIMARY KEY  (`id`)\n                ) ENGINE=MyISAM";
                if (!upgrade_apply_sql($sql_step1)) {
                    return $step;
                }
                $step = set_upgrade_status($tool, 2, $course_code);
            case 2:
                /**
                 * STEP 2 : Create a new assignment
                 */
                // get work intro in tool
                $sql_work_intro = "SELECT ti.texte_intro\n                                    FROM `" . $currentCourseDbNameGlu . "tool_list` tl,\n                                         `" . $currentCourseDbNameGlu . "tool_intro` ti,\n                                         `" . $tbl_course_tool . "` ct\n                                    WHERE ti.id = tl.id\n                                        AND tl.tool_id =  ct.id\n                                        AND ct.claro_label = 'CLWRK___'";
                $work_intro = claro_sql_query_get_single_value($sql_work_intro);
                if ($work_intro === FALSE) {
                    $work_intro = '';
                }
                $sql_step2[] = "INSERT INTO `" . $currentCourseDbNameGlu . "wrk_assignment`\n                    SET `id` = 1,\n                    `title` = 'Assignments',\n                    `description`= '" . mysql_real_escape_string($work_intro) . "',\n                    `visibility` = 'VISIBLE',\n                    `def_submission_visibility` = 'VISIBLE',\n                    `assignment_type` = 'INDIVIDUAL',\n                    `authorized_content` = 'FILE',\n                    `allow_late_upload` = 'NO',\n                    `start_date` = '" . $currentCourseCreationDate . "',\n                    `end_date` = DATE_ADD(NOW(),INTERVAL 1 YEAR),\n                    `prefill_text` = '',\n                    `prefill_doc_path` = '',\n                    `prefill_submit` = 'ENDDATE' ";
                if (!upgrade_apply_sql($sql_step2)) {
                    return $step;
                }
                $step = set_upgrade_status($tool, 3, $course_code);
            case 3:
                /**
                 * STEP 3 : Add old works as submissions of new assignment
                 */
                // get course manager of the course
                $sql_get_id_of_one_teacher = "SELECT `user_id` `uid` " . " FROM `" . $tbl_rel_course_user . "` " . " WHERE `code_cours` = '" . $course_code . "' LIMIT 1";
                $teacher = claro_sql_query_fetch_all($sql_get_id_of_one_teacher);
                $teacher_uid = $teacher[0]['uid'];
                // if no course manager, you are enrolled in as
                if (!is_numeric($teacher_uid)) {
                    $teacher_uid = $_uid;
                    $sql_set_teacher = "INSERT INTO `" . $tbl_rel_course_user . "`\n                                        SET `user_id` = '" . $teacher_uid . "'\n                                             , `code_cours` = '" . $course_code . "'\n                                             , `role` = 'Course missing manager';";
                    if (!claro_sql_query($sql_set_teacher)) {
                        return $step;
                    }
                    log_message('Warning : Course ' . $course_code . ' has no teacher, you are enrolled in as course manager.');
                }
                // add old work in submission of course manager
                $sql_step3[] = "INSERT IGNORE INTO `" . $currentCourseDbNameGlu . "wrk_submission`\n                 (assignment_id,user_id,title,visibility,authors,submitted_text,submitted_doc_path)\n                 SELECT 1, '" . $teacher_uid . "', titre, IF(accepted,'VISIBLE','INVISIBLE'), auteurs, description, url\n                    FROM `" . $currentCourseDbNameGlu . "assignment_doc`";
                if (!upgrade_apply_sql($sql_step3)) {
                    return $step;
                }
                $step = set_upgrade_status($tool, 4, $course_code);
            case 4:
                /**
                 * STEP 4 : Update document path of submissions
                 */
                $sql_step4[] = "UPDATE `" . $currentCourseDbNameGlu . "wrk_submission`\n                                SET submitted_doc_path = REPLACE (`submitted_doc_path` ,'work/','')";
                if (!upgrade_apply_sql($sql_step4)) {
                    return $step;
                }
                $step = set_upgrade_status($tool, 5, $course_code);
            case 5:
                /**
                 * STEP 5 : Create new folder to store assig_1 and move old old work documents in it
                 */
                // create new folder
                $work_dirname = $currentcoursePathSys . 'work/';
                $assignment_dirname = $work_dirname . 'assig_1/';
                if (!is_dir($assignment_dirname)) {
                    if (!@mkdir($assignment_dirname, CLARO_FILE_PERMISSIONS)) {
                        log_message('Error: Cannot create ' . $assignment_dirname);
                        return $step;
                    }
                }
                // move assignment from work to work/assig_1
                if (is_dir($work_dirname)) {
                    if ($handle = opendir($work_dirname)) {
                        while (FALSE !== ($file = readdir($handle))) {
                            if (is_dir($work_dirname . $file)) {
                                continue;
                            }
                            if (@rename($work_dirname . $file, $assignment_dirname . $file) === FALSE) {
                                log_message('Error: Cannot rename ' . $work_dirname . $file . ' to ' . $assignment_dirname . $file);
                                return $step;
                            }
                        }
                        closedir($handle);
                    }
                }
                $step = set_upgrade_status($tool, 6, $course_code);
            case 6:
                /**
                 * STEP 6 Drop deprecated assignment_doc
                 */
                // $sql_step6[] = "DROP TABLE IF EXISTS `".$currentCourseDbNameGlu."assignment_doc`";
                // if ( ! upgrade_apply_sql($sql_step6) ) return $step;
                $step = set_upgrade_status($tool, 0, $course_code);
            default:
                return $step;
        }
        // end switch
    }
    return false;
}
Esempio n. 20
0
    $sortKeyList['fb.last_edit_date'] = SORT_ASC;
    $sortKeyList['g.name'] = SORT_ASC;
    // get last submission titles
    $sql2 = "SELECT `s`.`group_id` as `authId`, `s`.`title`, DATE(`s`.`last_edit_date`) as date\n                FROM `" . $tbl_wrk_submission . "` AS `s`\n            LEFT JOIN `" . $tbl_wrk_submission . "` AS `s2`\n                ON `s`.`group_id` = `s2`.`group_id`\n                AND `s2`.`assignment_id` = " . (int) $req['assignmentId'] . "\n                AND `s`.`last_edit_date` < `s2`.`last_edit_date`\n            WHERE `s2`.`group_id` IS NULL\n                AND `s`.`original_id` IS NULL\n                AND `s`.`assignment_id` = " . (int) $req['assignmentId'] . "\n            " . $submissionFilterSql . "";
}
/*--------------------------------------------------------------------
WORK LIST
--------------------------------------------------------------------*/
$offset = isset($_REQUEST['offset']) && !empty($_REQUEST['offset']) ? $_REQUEST['offset'] : 0;
$workPager = new claro_sql_pager($sql, $offset, $usersPerPage);
foreach ($sortKeyList as $thisSortKey => $thisSortDir) {
    $workPager->add_sort_key($thisSortKey, $thisSortDir);
}
$workList = $workPager->get_result_list();
// add the title of the last submission in each displayed line
$results = claro_sql_query_fetch_all($sql2);
$lastWorkTitleList = array();
$last_edit_date_list = array();
foreach ($results as $result) {
    $lastWorkTitleList[$result['authId']] = $result['title'];
    $last_edit_date_list[$result['authId']] = $result['date'];
}
if (!empty($lastWorkTitleList)) {
    for ($i = 0; $i < count($workList); $i++) {
        if (isset($lastWorkTitleList[$workList[$i]['authId']])) {
            $workList[$i]['title'] = $lastWorkTitleList[$workList[$i]['authId']];
        }
        if (isset($last_edit_date_list[$workList[$i]['authId']])) {
            $workList[$i]['last_edit_date'] = $last_edit_date_list[$workList[$i]['authId']];
        }
    }
Esempio n. 21
0
    // end if claro_dispLocalAuthForm
    $template = new CoreTemplate('auth_form.tpl.php');
    $template->assign('dialogBox', $dialogBox);
    $template->assign('formAction', $formAction);
    $template->assign('sourceUrl', $sourceUrl);
    $template->assign('sourceCid', $sourceCid);
    $template->assign('sourceGid', $sourceGid);
    $template->assign('cidRequired', $cidRequired);
    $template->assign('defaultLoginValue', $defaultLoginValue);
    $template->assign('sourceUrl', $sourceUrl);
    $claroline->display->body->appendContent($template->render());
    echo $claroline->display->render();
} elseif (!claro_is_in_a_course() && $cidRequired) {
    $tbl = claro_sql_get_main_tbl();
    $sql = "\n            SELECT c.code                                             AS `value`,\n                   CONCAT(c.intitule,' (',c.administrativeNumber,')') AS `name`\n            FROM `" . $tbl['course'] . "`          AS c ,\n                 `" . $tbl['rel_course_user'] . "` AS cu\n            WHERE c.code = cu.code_cours\n            AND cu.user_id = " . (int) claro_get_current_user_id();
    $courseList = claro_sql_query_fetch_all($sql);
    $template = new CoreTemplate('select_course_form.tpl.php');
    $template->assign('formAction', $_SERVER['PHP_SELF']);
    $template->assign('sourceUrl', $sourceUrl);
    $template->assign('sourceCid', $sourceCid);
    $template->assign('sourceGid', $sourceGid);
    $template->assign('cidRequired', $cidRequired);
    $template->assign('courseList', $courseList);
    $claroline->display->body->appendContent($template->render());
    echo $claroline->display->render();
} else {
    if (!isset($userLoggedOnCas)) {
        $userLoggedOnCas = false;
    }
    $claroline->notifier->event('user_login', array('data' => array('ip' => $_SERVER['REMOTE_ADDR'])));
    if (claro_is_in_a_course() && !claro_is_course_allowed()) {
Esempio n. 22
0
function announcement_get_item_list($context, $order = 'DESC')
{
    $tbl = claro_sql_get_course_tbl(claro_get_course_db_name_glued($context[CLARO_CONTEXT_COURSE]));
    $sql = "SELECT id,\n                   title,\n                   contenu          AS content,\n                   visibleFrom,\n                   visibleUntil,\n                   temps            AS `time`,\n                   visibility,\n                   ordre            AS rank\n            FROM `" . $tbl['announcement'] . "`\n            ORDER BY ordre " . ($order == 'DESC' ? 'DESC' : 'ASC');
    return claro_sql_query_fetch_all($sql);
}
Esempio n. 23
0
/**
 * Update the file or directory path in the document db document table
 *
 * @param  String action    - action type require : 'delete' or 'update'
 * @param  String filePath  - original path of the file
 * @param  String $newParam - new param of the file, can contain
 *                              'path', 'visibility' and 'comment'
 *
 */
function update_db_info($action, $filePath, $newParamList = array())
{
    global $dbTable;
    // table 'document'
    if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") {
        $modifier = '';
    } else {
        $modifier = 'BINARY ';
    }
    $newComment = isset($newParamList['comment']) ? trim($newParamList['comment']) : null;
    $newVisibility = isset($newParamList['visibility']) ? trim($newParamList['visibility']) : null;
    $newPath = isset($newParamList['path']) ? trim($newParamList['path']) : null;
    if ($action == 'delete') {
        $theQuery = "DELETE FROM `" . $dbTable . "`\n                     WHERE path=\"" . claro_sql_escape($filePath) . "\"\n                     OR    path LIKE \"" . claro_sql_escape($filePath) . "/%\"";
        claro_sql_query($theQuery);
    } elseif ($action == 'update') {
        // GET OLD PARAMETERS IF THEY EXIST
        $sql = "SELECT path, comment, visibility\n                FROM `" . $dbTable . "`\n                WHERE {$modifier} path=\"" . claro_sql_escape($filePath) . "\"";
        $result = claro_sql_query_fetch_all($sql);
        if (count($result) > 0) {
            list($oldAttributeList) = $result;
        } else {
            $oldAttributeList = null;
        }
        if (!$oldAttributeList) {
            if ($newComment || $newVisibility == 'i') {
                if ($newVisibility != 'i') {
                    $newVisibility = 'v';
                }
                $insertedPath = $newPath ? $newPath : $filePath;
                $theQuery = "INSERT INTO `" . $dbTable . "`\n                             SET path       = \"" . claro_sql_escape($insertedPath) . "\",\n                                 comment    = \"" . claro_sql_escape($newComment) . "\",\n                                 visibility = \"" . claro_sql_escape($newVisibility) . "\"";
            }
            // else noop
        } else {
            if (is_null($newVisibility)) {
                $newVisibility = $oldAttributeList['visibility'];
            }
            if (is_null($newComment)) {
                $newComment = $oldAttributeList['comment'];
            }
            if (empty($newComment) && $newVisibility == 'v') {
                // NO RELEVANT PARAMETERS ANYMORE => DELETE THE RECORD
                $theQuery = "DELETE FROM `" . $dbTable . "`\n                             WHERE {$modifier} path=\"" . $filePath . "\"";
            } else {
                $theQuery = "UPDATE `" . $dbTable . "`\n                             SET   comment    = '" . claro_sql_escape($newComment) . "',\n                                   visibility = '" . claro_sql_escape($newVisibility) . "'\n                             WHERE {$modifier} path     = '" . claro_sql_escape($filePath) . "'";
            }
        }
        // end else if ! $oldAttributeList
        if (isset($theQuery)) {
            claro_sql_query($theQuery);
        }
        if ($newPath) {
            $theQuery = "UPDATE `" . $dbTable . "`\n                        SET path = CONCAT('" . claro_sql_escape($newPath) . "',\n                                   SUBSTRING(path, LENGTH('" . claro_sql_escape($filePath) . "')+1) )\n                        WHERE {$modifier} path = '" . claro_sql_escape($filePath) . "'\n                        OR {$modifier} path LIKE '" . claro_sql_escape($filePath) . "/%'";
            claro_sql_query($theQuery);
        }
    }
    // end else if action == update
}
Esempio n. 24
0
function fetchtCourseList()
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $sqlListCoursesSel = "\n        SELECT administrativeNumber AS officialCode,\n               code                 AS sysCode\n          FROM `" . $tbl_mdb_names['course'] . "`\n      ORDER BY trim(administrativeNumber) ASC\n      ";
    return claro_sql_query_fetch_all($sqlListCoursesSel);
}
Esempio n. 25
0
/**
 * 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;
}
Esempio n. 26
0
/**
 * Return the list of disabled or unpublished course of a user.
 *
 * @param int $userId valid id of a user
 * @param boolean $renew whether true, force to read databaseingoring an existing cache.
 * @return array (list of course) of array (course settings) of the given user.
 * @todo search and merge other instance of this functionality
 * @deprecated use UserCourseList instead
 */
function get_user_course_list_desactivated($userId, $renew = false)
{
    static $cached_uid = null, $userCourseList = null;
    $curdate = claro_mktime();
    if ($cached_uid != $userId || is_null($userCourseList) || $renew) {
        $cached_uid = $userId;
        $tbl_mdb_names = claro_sql_get_main_tbl();
        $tbl_courses = $tbl_mdb_names['course'];
        $tbl_link_user_courses = $tbl_mdb_names['rel_course_user'];
        $sql = "SELECT course.cours_id,\n                       course.code                 AS `sysCode`,\n                       course.directory            AS `directory`,\n                       course.administrativeNumber AS `officialCode`,\n                       course.dbName               AS `db`,\n                       course.intitule             AS `title`,\n                       course.titulaires           AS `titular`,\n                       course.language             AS `language`,\n                       course.access               AS `access`,\n                       course_user.isCourseManager,\n                       course.status,\n                       UNIX_TIMESTAMP(course.expirationDate) AS expirationDate,\n                       UNIX_TIMESTAMP(course.creationDate)     AS creationDate\n                       \n                       FROM `" . $tbl_courses . "`           AS course,\n                            `" . $tbl_link_user_courses . "` AS course_user\n                       \n                       WHERE course.code         = course_user.code_cours\n                         AND course_user.user_id = " . (int) $userId . "\n                         AND (course.`status` = 'disable'\n                              OR course.`status` = 'pending'\n                              OR (course.`status` = 'date'\n                                  AND (UNIX_TIMESTAMP(`creationDate`) > '" . $curdate . "'\n                                       OR '" . $curdate . "'> UNIX_TIMESTAMP(`expirationDate`)\n                                       )\n                                  )\n                              ) ";
        if (get_conf('course_order_by') == 'official_code') {
            $sql .= " ORDER BY UPPER(`administrativeNumber`), `title`";
        } else {
            $sql .= " ORDER BY `title`, UPPER(`administrativeNumber`)";
        }
        $userCourseListDesactivated = claro_sql_query_fetch_all($sql);
    }
    return $userCourseListDesactivated;
}
Esempio n. 27
0
            $dialogBox->form(get_lang('Confirm your unsubscription as tutor from the group &quot;<b>%group_name</b>&quot;', array('%group_name' => claro_get_current_group_data('name'))) . "\n" . '<form action="' . claro_htmlspecialchars($_SERVER['PHP_SELF']) . '" method="post">' . "\n" . claro_form_relay_context() . '<input type="hidden" name="tutorUnregistration" value="1" />' . "\n" . '<input type="hidden" name="doUnreg" value="1" />' . "\n" . '<br />' . "\n" . '<input type="submit" value="' . get_lang("Ok") . '" />' . "\n" . claro_html_button(claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'])), get_lang("Cancel")) . "\n" . '</form>' . "\n");
        }
    }
}
/********************************
 * GROUP INFORMATIONS RETRIVIAL
 ********************************/
/*----------------------------------------------------------------------------
GET GROUP MEMBER LIST
----------------------------------------------------------------------------*/
$groupMemberList = get_group_user_list(claro_get_current_group_id(), claro_get_current_course_id());
/*----------------------------------------------------------------------------
GET TUTOR(S) DATA
----------------------------------------------------------------------------*/
$sql = "SELECT user_id AS id, nom AS lastName, prenom AS firstName, email\n        FROM `" . $tbl_user . "` user\n        WHERE user.user_id='" . claro_get_current_group_data('tutorId') . "'";
$tutorDataList = claro_sql_query_fetch_all($sql);
/*----------------------------------------------------------------------------
GET FORUM POINTER
----------------------------------------------------------------------------*/
$forumId = claro_get_current_group_data('forumId');
$toolList = get_group_tool_list();
if (claro_is_in_a_course()) {
    $date = $claro_notifier->get_notification_date(claro_get_current_user_id());
    $modified_tools = $claro_notifier->get_notified_tools(claro_get_current_course_id(), $date, claro_get_current_user_id(), claro_get_current_group_id());
} else {
    $modified_tools = array();
}
$toolLinkList = array();
foreach ($toolList as $thisTool) {
    if (!array_key_exists($thisTool['label'], $_groupProperties['tools'])) {
        continue;
Esempio n. 28
0
// Initialise variables
$dialogBox = new DialogBox();
$extAuthPasswordCount = 0;
$passwordFound = false;
$userAccountList = array();
// Get the forgotten email from the form
if (isset($_REQUEST['Femail'])) {
    $emailTo = strtolower(trim($_REQUEST['Femail']));
} else {
    $emailTo = '';
}
// Main section
if (isset($_REQUEST['searchPassword']) && !empty($emailTo)) {
    // search user with this email
    $sql = "SELECT  `user_id`   `uid`       ,\n                    `nom`       `lastName`  ,\n                    `prenom`    `firstName` ,\n                    `username`  `loginName` ,\n                    `password`              ,\n                    `email`                 ,\n                    `authSource`            ,\n                    `creatorId`\n             FROM `" . $tbl_user . "`\n             WHERE LOWER(email) = '" . claro_sql_escape($emailTo) . "'";
    $userList = claro_sql_query_fetch_all($sql);
    if (count($userList) > 0) {
        $allowedAuthSources = AuthDriverManager::getDriversAllowingLostPassword();
        foreach ($userList as $user) {
            if (isset($allowedAuthSources[$user['authSource']])) {
                $passwordFound = true;
                if (get_conf('userPasswordCrypted', false)) {
                    /*
                     * If password are crypted, we can not send them as such.
                     * We have to generate new ones.
                     */
                    $user['password'] = generate_passwd();
                    // UPDATE THE DB WITH THE NEW GENERATED PASSWORD
                    $sql = 'UPDATE `' . $tbl_user . '`
                            SET   `password` = "' . claro_sql_escape(md5($user['password'])) . '"
                             WHERE `user_id` = "' . $user['uid'] . '"';
Esempio n. 29
0
 /**
  * Trig the execution of the SQL queries
  *
  * @access private
  */
 function _execute_pager_queries()
 {
     $preparedQuery = $this->_get_prepared_query($this->sql, $this->offset, $this->step, $this->sortKeyList);
     $this->resultList = claro_sql_query_fetch_all($preparedQuery);
     // The query below has to be executed immediateley after the previous one.
     // Otherwise other potential queries could impair the reliability
     // of mySQL FOUND_ROWS() function.
     $this->totalItemCount = claro_sql_query_get_single_value('SELECT FOUND_ROWS()');
 }
Esempio n. 30
0
/**
 * Return course list which have an unexisting category as parent
 *
 * @author Christophe Gesché <*****@*****.**>
 * @since 1.8
 *
 * @return array('Course code'=>string, 'Unknow faculty'=>string)
 */
function checkCourseOwnance()
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $sql = "SELECT c.code    AS `Course code`,\n                   c.faculte AS `Unknow faculty`\n        FROM  `" . $tbl_mdb_names['course'] . "`       AS c\n        LEFT JOIN  `" . $tbl_mdb_names['category'] . "` AS f\n        ON c.FACULTE = f.code\n        WHERE f.id IS null ";
    if (false !== ($res = claro_sql_query_fetch_all($sql))) {
        return $res;
    } else {
        return claro_failure::set_failure('QUERY_ERROR_' . __LINE__);
    }
}