Esempio n. 1
0
 public function __construct($userId = null, $courseId = null, $database = null)
 {
     $this->userId = $userId ? $userId : claro_get_current_user_id();
     $this->courseId = $courseId ? $courseId : claro_get_current_course_id();
     $this->database = $database ? $database : Claroline::getDatabase();
     $this->tbl = array_merge(get_module_main_tbl(array('rel_course_user')), get_module_course_tbl(array('group_team', 'group_rel_team_user')));
 }
 /**
  * Returns a single resquested announce.
  * @param array $args must contain 'resID' key with the resource identifier of the requested resource
  * @throws InvalidArgumentException if one of the paramaters is missing
  * @webservice{/module/MOBILE/CLANN/getSingleResource/cidReq/resId}
  * @ws_arg{Method,getSingleResource}
  * @ws_arg{cidReq,SYSCODE of requested cours}
  * @ws_arg{resID,Resource Id of requested resource}
  * @return announce object (can be null if not visible for the current user)
  */
 function getSingleResource($args)
 {
     $resourceId = isset($args['resID']) ? $args['resID'] : null;
     $cid = claro_get_current_course_id();
     if ($cid == null || $resourceId == null) {
         throw new InvalidArgumentException('Missing cid or resourceId argument!');
     }
     $claroNotification = Claroline::getInstance()->notification;
     $date = $claroNotification->getLastActionBeforeLoginDate(claro_get_current_user_id());
     $d = new DateTime($date);
     $d->sub(new DateInterval('PT1M'));
     From::Module('CLANN')->uses('announcement.lib');
     if ($announce = $this->announcement_get_item($resourceId, $cid)) {
         $notified = $claroNotification->isANotifiedRessource($cid, $date, claro_get_current_user_id(), claro_get_current_group_id(), get_tool_id_from_module_label('CLANN'), $announce['id'], false);
         $announce['visibility'] = $announce['visibility'] != 'HIDE';
         $announce['content'] = trim(strip_tags($announce['content']));
         $announce['cours']['sysCode'] = $cid;
         $announce['resourceId'] = $announce['id'];
         $announce['date'] = $announce['time'];
         $announce['notifiedDate'] = $notified ? $date : $announce['time'];
         $announce['seenDate'] = $d->format('Y-m-d H:i');
         unset($announce['id']);
         return claro_is_allowed_to_edit() || $announce['visibility'] ? $announce : null;
     } else {
         throw new RuntimeException('Resource not found', 404);
     }
 }
 public function __construct($courseId)
 {
     $this->courseId = $courseId;
     $courseCode = ClaroCourse::getCodeFromId($this->courseId);
     $tbl_mdb_names = claro_sql_get_main_tbl();
     $tbl_rel_course_portlet = $tbl_mdb_names['rel_course_portlet'];
     $sql = "SELECT id, courseId, rank, label, visible\n                FROM `{$tbl_rel_course_portlet}`\n                WHERE `courseId` = {$this->courseId}\n                ORDER BY `rank` ASC";
     $result = Claroline::getDatabase()->query($sql);
     foreach ($result as $portletInfos) {
         // Require the proper portlet class
         $portletPath = get_module_path($portletInfos['label']) . '/connector/coursehomepage.cnr.php';
         $portletName = $portletInfos['label'] . '_Portlet';
         if (file_exists($portletPath)) {
             require_once $portletPath;
         } else {
             echo "Le fichier {$portletPath} est introuvable<br/>";
         }
         if (class_exists($portletName)) {
             $portlet = new $portletName($portletInfos['id'], $courseCode, $portletInfos['courseId'], $portletInfos['rank'], $portletInfos['label'], $portletInfos['visible']);
             $this->portlets[] = $portlet;
         } else {
             echo "Can't find the class {$portletName}_portlet<br/>";
             return false;
         }
     }
 }
Esempio n. 4
0
 public static function log($message, $type)
 {
     if (claro_debug_mode()) {
         pushClaroMessage($message, $type);
     }
     Claroline::log($type, $message);
 }
Esempio n. 5
0
 public function __construct($assignement, $courseId = null, $database = null)
 {
     $this->database = $database ? $database : Claroline::getDatabase();
     $this->assignement = $assignement;
     $this->courseId = $courseId ? $courseId : claro_get_current_course_id();
     $this->tbl = array_merge(get_module_main_tbl(array('rel_course_user', 'user')), get_module_course_tbl(array('wrk_submission', 'group_team'), $this->courseId));
     $this->submissionTitleList = array();
 }
Esempio n. 6
0
 public function __construct($courseId, $database = null)
 {
     $this->database = $database ? $database : Claroline::getDatabase();
     $tbl_cdb_names = get_module_course_tbl(array('qwz_exercise', 'qwz_tracking', 'qwz_tracking_questions', 'qwz_tracking_answers'), $courseId);
     $this->tbl_qwz_tracking = $tbl_cdb_names['qwz_tracking'];
     $this->tbl_qwz_tracking_questions = $tbl_cdb_names['qwz_tracking_questions'];
     $this->tbl_qwz_tracking_answers = $tbl_cdb_names['qwz_tracking_answers'];
 }
 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);
 }
Esempio n. 8
0
 protected function getModuleLinkList()
 {
     //$toolNameList = claro_get_tool_name_list();
     $claro_notifier = Claroline::getInstance()->notification;
     // Get tool id where new events have been recorded since last login
     if ($this->userId) {
         $date = $claro_notifier->get_notification_date($this->userId);
         $modified_tools = $claro_notifier->get_notified_tools($this->courseCode, $date, $this->userId);
     } else {
         $modified_tools = array();
     }
     $toolLinkList = array();
     $toolName = get_lang('Course homepage');
     // Trick to find how to build URL, must be IMPROVED
     $url = claro_htmlspecialchars(Url::Contextualize(get_path('url') . '/claroline/course/index.php?cid=' . $this->courseCode));
     $icon = get_icon_url('coursehome');
     $htmlId = 'id="courseHomePage"';
     $removableTool = false;
     $classCurrent = empty($GLOBALS['tlabelReq']) ? ' currentTool' : '';
     $toolLinkList[] = '<a ' . $htmlId . 'class="item' . $classCurrent . '" href="' . $url . '">' . '<img class="clItemTool"  src="' . $icon . '" alt="" />&nbsp;' . $toolName . '</a>' . "\n";
     // Generate tool lists
     $toolListSource = claro_get_course_tool_list($this->courseCode, $this->profileId, true);
     foreach ($toolListSource as $thisTool) {
         // Special case when display mode is student and tool invisible doesn't display it
         if ($this->viewMode == 'STUDENT' && !$thisTool['visibility']) {
             continue;
         }
         if (isset($thisTool['label'])) {
             $thisToolName = $thisTool['name'];
             $toolName = get_lang($thisToolName);
             // Trick to find how to build URL, must be IMPROVED
             $url = claro_htmlspecialchars(Url::Contextualize(get_module_url($thisTool['label']) . '/' . $thisTool['url'], $this->currentCourseContext));
             $icon = get_module_url($thisTool['label']) . '/' . $thisTool['icon'];
             $htmlId = 'id="' . $thisTool['label'] . '"';
             $removableTool = false;
         } else {
             if (!empty($thisTool['external_name'])) {
                 $toolName = $thisTool['external_name'];
             } else {
                 $toolName = '<i>no name</i>';
             }
             $url = claro_htmlspecialchars(trim($thisTool['url']));
             $icon = get_icon_url('link');
             $htmlId = '';
             $removableTool = true;
         }
         $style = !$thisTool['visibility'] ? 'invisible ' : '';
         $classItem = in_array($thisTool['id'], $modified_tools) ? ' hot' : '';
         $classCurrent = isset($thisTool['label']) && $thisTool['label'] == $GLOBALS['tlabelReq'] ? ' currentTool' : '';
         if (!empty($url)) {
             $toolLinkList[] = '<a ' . $htmlId . 'class="' . $style . 'item' . $classItem . $classCurrent . '" href="' . $url . '">' . '<img class="clItemTool"  src="' . $icon . '" alt="" />&nbsp;' . $toolName . '</a>' . "\n";
         } else {
             $toolLinkList[] = '<span ' . $style . '>' . '<img class="clItemTool" src="' . $icon . '" alt="" />&nbsp;' . $toolName . '</span>' . "\n";
         }
     }
     return $toolLinkList;
 }
 public function __construct($courseId)
 {
     $this->courseId = $courseId;
     $courseCode = ClaroCourse::getCodeFromId($this->courseId);
     $tbl_mdb_names = claro_sql_get_main_tbl();
     $tbl_rel_course_portlet = $tbl_mdb_names['rel_course_portlet'];
     $sql = "SELECT id, courseId, rank, label, visible\n                FROM `{$tbl_rel_course_portlet}`\n                WHERE `courseId` = {$this->courseId}\n                ORDER BY `rank` ASC";
     $this->portlets = Claroline::getDatabase()->query($sql);
 }
Esempio n. 10
0
 public function __construct($type = 'COURSE', $database = null)
 {
     if (!$database) {
         $this->database = Claroline::getDatabase();
         $this->type = $type;
     } else {
         $this->database = $database;
         $this->type = $type;
     }
 }
Esempio n. 11
0
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('calendar_event'), $locator->getCourseId());
     $sql = "SELECT `id`, `titre`, `day`, `visibility`\n" . "FROM `{$tbl['calendar_event']}`";
     $res = Claroline::getDatabase()->query($sql);
     $resourceList = new LinkerResourceIterator();
     foreach ($res as $event) {
         $eventLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLCAL', (int) $event['id']);
         $eventResource = new LinkerResource(empty($event['titre']) ? $event['day'] : $event['titre'], $eventLoc, true, $event['visibility'] == 'HIDE' ? false : true, false);
         $resourceList->addResource($eventResource);
     }
     return $resourceList;
 }
Esempio n. 12
0
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('announcement'), $locator->getCourseId());
     $sql = "SELECT `id`, `title`, `visibility`\n" . "FROM `{$tbl['announcement']}`";
     $res = Claroline::getDatabase()->query($sql);
     $resourceList = new LinkerResourceIterator();
     foreach ($res as $annoucement) {
         $annoucementLoc = new ClarolineResourceLocator($locator->getCourseId(), 'CLANN', (int) $annoucement['id']);
         $annoucementResource = new LinkerResource(empty($annoucement['title']) ? get_lang('Untitled') : $annoucement['title'], $annoucementLoc, true, $annoucement['visibility'] == 'HIDE' ? false : true, false);
         $resourceList->addResource($annoucementResource);
     }
     return $resourceList;
 }
Esempio n. 13
0
 /**
  * Render the template
  * @return  string
  * @throws  Exception if file not found or error/exception in the template
  */
 public function render()
 {
     if (file_exists($this->_templatePath)) {
         $claroline = Claroline::getInstance();
         claro_ob_start();
         include $this->_templatePath;
         $render = claro_ob_get_contents();
         claro_ob_end_clean();
         return $render;
     } else {
         throw new Exception("Template file not found {$this->_templatePath}");
     }
 }
Esempio n. 14
0
 public function addPortlet($label, $name, $rank = null, $visible = true)
 {
     if (Claroline::getDatabase()->query("SELECT `label` FROM `{$this->tblDesktopPortlet}` WHERE `label` = '" . claro_sql_escape($label) . "'")->numRows()) {
         return false;
     }
     $sql = "SELECT MAX(rank) FROM  `" . $this->tblDesktopPortlet . "`";
     $maxRank = claro_sql_query_get_single_value($sql);
     $sqlRank = empty($rank) ? $maxRank + 1 : (int) $rank;
     $sqlVisibility = $visible ? "visible" : "invisible";
     // insert
     $sql = "INSERT INTO `" . $this->tblDesktopPortlet . "`\n                SET `label` = '" . claro_sql_escape($label) . "',\n                    `name` = '" . claro_sql_escape($name) . "',\n                    `visibility` = '" . $sqlVisibility . "',\n                    `rank` = " . $sqlRank;
     return claro_sql_query($sql) != false;
 }
Esempio n. 15
0
 public function getResourceList(ResourceLocator $locator)
 {
     $tbl = get_module_course_tbl(array('wrk_assignment'), $locator->getCourseId());
     $resourceList = new LinkerResourceIterator();
     if (!$locator->hasResourceId()) {
         $sql = "SELECT `title`, `visibility`, `id`\n" . "FROM `{$tbl['wrk_assignment']}`\n";
         $res = Claroline::getDatabase()->query($sql);
         foreach ($res as $assig) {
             $loc = new ClarolineResourceLocator($locator->getCourseId(), 'CLWRK', (int) $assig['id']);
             $resource = new LinkerResource($assig['title'], $loc, true, $assig['visibility'] == 'VISIBLE', false);
             $resourceList->addResource($resource);
         }
     }
     return $resourceList;
 }
Esempio n. 16
0
 public function render()
 {
     // Select current course's datas
     $tbl_mdb_names = claro_sql_get_main_tbl();
     $tbl_courses = $tbl_mdb_names['course'];
     $curdate = claro_mktime();
     $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.status,\n                       course.sourceCourseId,\n                       UNIX_TIMESTAMP(course.expirationDate) AS expirationDate,\n                       UNIX_TIMESTAMP(course.creationDate)   AS creationDate\n                FROM `" . $tbl_courses . "` AS course\n                WHERE course.code = " . Claroline::getDatabase()->quote($this->courseCode);
     $result = Claroline::getDatabase()->query($sql);
     $courseData = $result->fetch(Database_ResultSet::FETCH_ASSOC);
     $courseEventList = get_agenda_next_items_list($courseData, 10, $this->month, $this->year);
     if (is_array($courseEventList)) {
         $courseDigestList = array();
         foreach ($courseEventList as $thisEvent) {
             $eventLine = trim(strip_tags($thisEvent['title']));
             if ($eventLine == '') {
                 $eventContent = trim(strip_tags($thisEvent['content']));
                 $eventLine = substr($eventContent, 0, 60) . (strlen($eventContent) > 60 ? ' (...)' : '');
             }
             $eventDate = $thisEvent['day'];
             if (!array_key_exists($eventDate, $courseDigestList)) {
                 $courseDigestList[$eventDate] = array();
                 $courseDigestList[$eventDate]['eventList'] = array();
                 $courseDigestList[$eventDate]['date'] = $eventDate;
             }
             $courseDigestList[$eventDate]['eventList'][] = array('id' => $thisEvent['id'], 'hour' => $thisEvent['hour'], 'location' => $thisEvent['location'], 'courseOfficialCode' => $courseData['officialCode'], 'courseSysCode' => $courseData['sysCode'], 'content' => $eventLine, 'url' => get_path('url') . '/claroline/calendar/agenda.php?cidReq=' . $courseData['sysCode']);
         }
     }
     $output = '';
     //$output .= '<div class="calendar">'.$this->ajaxMiniCalendar($agendaItemList).'</div>';
     $output .= '<div class="details">' . "\n" . '<dl>' . "\n";
     if ($courseDigestList) {
         foreach ($courseDigestList as $agendaItem) {
             $output .= '<dt>' . "\n" . '<h2>' . claro_html_localised_date(get_locale('dateFormatLong'), strtotime($agendaItem['date'])) . '</h2>' . "\n" . '</dt>' . "\n";
             foreach ($agendaItem['eventList'] as $agendaEvent) {
                 $output .= '<dd>' . '<b>' . $agendaEvent['content'] . '</b>' . "\n" . (!empty($agendaEvent['hour']) ? ' &ndash; ' . ucfirst(strftime(get_locale('timeNoSecFormat'), strtotime($agendaEvent['hour']))) : '') . (!empty($agendaEvent['location']) ? ' | ' . $agendaEvent['location'] : '') . ' (<a href="' . $agendaEvent['url'] . '#item' . $agendaEvent['id'] . '">' . get_lang('more details') . '</a>)' . "\n" . '</dd>' . "\n";
             }
         }
     } else {
         $output .= '<dt>' . "\n" . get_lang('No event to display') . "\n" . '</dt>' . "\n";
     }
     $output .= '' . '</dl>' . "\n" . '</div>' . "\n";
     return $output;
 }
Esempio n. 17
0
/**
 * Count the number of student in both the given course and the given class
 * @param string $course_id
 * @param int $class_id
 * @param bool $include_children recursively count students from subclasses
 * @return int
 */
function class_get_number_of_users_in_course($course_id, $class_id, $include_children = true)
{
    $tbl_mdb_names = claro_sql_get_main_tbl();
    $tbl_class_user = $tbl_mdb_names['rel_class_user'];
    $tbl_class = $tbl_mdb_names['class'];
    $tbl_course_user = $tbl_mdb_names['rel_course_user'];
    $sqlCourseId = Claroline::getDatabase()->quote($course_id);
    //1- get class users number
    $sqlcount = "SELECT COUNT(clu.`user_id`) AS qty_user\n                 FROM `{$tbl_class_user}` AS clu\n                 INNER JOIN `{$tbl_course_user}` AS cu \n                 ON `cu`.`user_id` = `clu`.`user_id`\n                 AND `cu`.`code_cours` = {$sqlCourseId}\n                 WHERE clu.`class_id` = " . (int) $class_id;
    $qty_user = Claroline::getDatabase()->query($sqlcount)->setFetchMode(Database_ResultSet::FETCH_VALUE)->fetch();
    if ($include_children) {
        $sql = "SELECT `id`\n                FROM `" . $tbl_class . "`\n                WHERE `class_parent_id`=" . (int) $class_id;
        $subClassesList = Claroline::getDatabase()->query($sql);
        //2- recursive call to get subclasses'users too
        foreach ($subClassesList as $subClass) {
            $qty_user += class_get_number_of_users_in_course($subClass['id'], true);
        }
    }
    //3- return result of counts and recursive calls
    return $qty_user;
}
Esempio n. 18
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']);
        }
    }
}
Esempio n. 19
0
Claroline::getDisplay()->body->appendContent(claro_html_tool_title(array('supraTitle' => get_lang("Groups"), 'mainTitle' => claro_get_current_group_data('name') . ' <img src="' . get_icon_url('group') . '" alt="" />')));
$groupSpaceTemplate = new CoreTemplate('group_space.tpl.php');
$groupSpaceTemplate->assign('dialogBox', $dialogBox);
$groupSpaceTemplate->assign('displayRegistrationLink', $is_allowedToSelfRegInGroup && !array_key_exists('registration', $_REQUEST));
$groupSpaceTemplate->assign('displayUnregistrationLink', $is_allowedToSelfUnregInGroup && !array_key_exists('unregistration', $_REQUEST));
$groupSpaceTemplate->assign('displayTutorRegistrationLink', $isTutorRegAllowed && !array_key_exists('tutorRegistration', $_REQUEST));
$groupSpaceTemplate->assign('displayTutorUnregistrationLink', $isTutorUnregAllowed && !array_key_exists('tutorUnregistration', $_REQUEST));
$groupSpaceTemplate->assign('toolLinkList', $toolLinkList);
/*----------------------------------------------------------------------------
DISPLAY GROUP DESCRIPTION
----------------------------------------------------------------------------*/
if (strlen(claro_get_current_group_data('description')) > 0) {
    $groupSpaceTemplate->assign('groupDescription', claro_get_current_group_data('description'));
} else {
    $groupSpaceTemplate->assign('groupDescription', get_lang("(none)"));
}
/*----------------------------------------------------------------------------
DISPLAY GROUP TUTOR INFORMATION
----------------------------------------------------------------------------*/
$groupSpaceTemplate->assign('tutorDataList', $tutorDataList);
/*----------------------------------------------------------------------------
DISPLAY GROUP MEMBER LIST
----------------------------------------------------------------------------*/
$context = Claro_Context::getCurrentContext();
$context[CLARO_CONTEXT_GROUP] = null;
$urlContext = Claro_Context::getUrlContext($context);
$groupSpaceTemplate->assign('urlContext', $urlContext);
$groupSpaceTemplate->assign('groupMemberList', $groupMemberList);
Claroline::getDisplay()->body->appendContent($groupSpaceTemplate->render());
echo Claroline::getDisplay()->render();
Esempio n. 20
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();
}
Esempio n. 21
0
 public function __construct($database)
 {
     $this->database = $database ? $database : Claroline::getDatabase();
 }
Esempio n. 22
0
 public function getUserInfo($catId)
 {
     $tbl = claro_sql_get_course_tbl(claro_get_course_db_name_glued($this->courseId));
     return Claroline::getDatabase()->query("\n            SELECT\n                content.user_id     AS userId,\n                cat.id              AS catId,\n                cat.title           AS title,\n                content.content     AS content\n            FROM\n                `" . $tbl['userinfo_def'] . "`     AS cat\n            LEFT JOIN\n                `" . $tbl['userinfo_content'] . "` AS content\n            ON\n                cat.id = content.def_id\n            WHERE\n                cat.id = " . (int) $catId . "\n            ORDER BY `cat`.`id`\n        ");
 }
Esempio n. 23
0
 * @author      Claroline Team <*****@*****.**>
 * @author      Christophe Mertens <*****@*****.**>
 * @license     http://www.gnu.org/copyleft/gpl.html
 *              GNU GENERAL PUBLIC LICENSE version 2 or later
 * @package     internal_messaging
 */
$cidReset = true;
require_once dirname(__FILE__) . '/../../claroline/inc/claro_init_global.inc.php';
// manager of the admin message box
require_once dirname(__FILE__) . '/lib/messagebox/adminmessagebox.lib.php';
require_once dirname(__FILE__) . '/lib/tools.lib.php';
require_once dirname(__FILE__) . '/lib/displaymessage.lib.php';
// search user info
require_once get_path('incRepositorySys') . '/lib/user.lib.php';
// move to kernel
$claroline = Claroline::getInstance();
// ------------- permission ---------------------------
if (!claro_is_user_authenticated()) {
    claro_disp_auth_form(false);
}
if (!claro_is_platform_admin()) {
    claro_die(get_lang('Not allowed'));
}
// -------------- business logic ----------------------
$content = "";
$arguments = array();
$displayTable = true;
$acceptedSearch = array('fromUser', 'olderThan', 'timeInterval', 'platformMessage');
$acceptedCommand = array('rqDeleteSelection', 'exDeleteSelection', 'rqDeleteMessage', 'exDeleteMessage');
$box = new AdminMessageBox();
$strategy = $box->getSelector();
Esempio n. 24
0
 public function __construct()
 {
     parent::__construct(Claroline::getDatabase());
 }
Esempio n. 25
0
 public function getIterator()
 {
     $tbl_mdb_names = claro_sql_get_main_tbl();
     $tbl_courses = $tbl_mdb_names['course'];
     $upperKeyword = addslashes(strtoupper($this->keyword));
     $sql = "SELECT\n                c.code                  AS courseId,\n                c.code                  AS sysCode,\n                c.cours_id              AS id,\n                c.isSourceCourse        AS isSourceCourse,\n                c.sourceCourseId        AS sourceCourseId,\n                c.intitule              AS name,\n                c.administrativeNumber  AS officialCode,\n                c.administrativeNumber  AS administrativeNumber,\n                c.directory             AS path,\n                c.dbName                AS dbName,\n                c.titulaires            AS titular,\n                c.email                 AS email,\n                c.language              AS language,\n                c.extLinkUrl            AS extLinkUrl,\n                c.extLinkName           AS extLinkName,\n                c.visibility            AS visibility,\n                c.access                AS access,\n                c.registration          AS registration,\n                c.registrationKey       AS registrationKey,\n                c.diskQuota             AS diskQuota,\n                UNIX_TIMESTAMP(c.creationDate)      AS publicationDate,\n                UNIX_TIMESTAMP(c.expirationDate)    AS expirationDate,\n                c.status                AS status,\n                c.userLimit             AS userLimit\n                \n                FROM `" . $tbl_courses . "` AS c\n                \n                WHERE UPPER(administrativeNumber) LIKE '%" . $upperKeyword . "%'\n                OR UPPER(intitule) LIKE '%" . $upperKeyword . "%'\n                OR UPPER(titulaires) LIKE '%" . $upperKeyword . "%'\n                \n                ORDER BY " . $this->orderBy . " ASC";
     $result = Claroline::getDatabase()->query($sql);
     return new CourseListIterator($result);
 }
Esempio n. 26
0
<?php

/**
 * CLAROLINE Applet
 *
 * @author Loic Fortemps
 *
 * @package MOBILE
 *
 */
$tlabelReq = 'MOBILE';
require_once dirname(__FILE__) . '/../../claroline/inc/claro_init_global.inc.php';
Claroline::initDisplay(Claroline::POPUP);
CssLoader::getInstance()->load('mobile', 'all');
$pageTitle = array('mainTitle' => get_lang('Mobile Apps Configuration'), 'subTitle' => get_lang('Configuration helper'));
ClaroBreadCrumbs::getInstance()->append($pageTitle['mainTitle'], $_SERVER['PHP_SELF']);
ClaroBreadCrumbs::getInstance()->append($pageTitle['subTitle']);
$template = new ModuleTemplate($tlabelReq, 'popup.tpl.php');
Claroline::getInstance()->display->body->appendContent(claro_html_tool_title($pageTitle) . $template->render());
echo Claroline::getInstance()->display->render();
Esempio n. 27
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;
    }
}
Esempio n. 28
0
 /**
  * 
  * @param string $cid id(code) of the course
  * @param mixed $database Database_Connection instance or null, if null, the default database connection will be used
  */
 public function __construct($cid = null, $database = null)
 {
     $this->cid = is_null($cid) ? claro_get_current_course_id() : $cid;
     $this->database = is_null($database) ? Claroline::getDatabase() : $database;
     $this->course = new Claro_course($cid);
     $this->course->load();
     $this->tables = claro_sql_get_main_tbl();
 }
Esempio n. 29
0
            $previousTotalTimeTab[1] += $spentTime;
            $previousTotalTimeTab[0] += (int) ($previousTotalTimeTab[1] / 60);
            $previousTotalTimeTab[1] %= 60;
            $newTotalTime = '';
            if ($previousTotalTimeTab[0] > 9999) {
                $newTotalTime = '9999:59:59';
            } else {
                if ($previousTotalTimeTab[0] < 10) {
                    $newTotalTime .= 0;
                }
                $newTotalTime .= $previousTotalTimeTab[0] . ':';
                if ($previousTotalTimeTab[1] < 10) {
                    $newTotalTime .= 0;
                }
                $newTotalTime .= $previousTotalTimeTab[1] . ':' . $previousTotalTimeTab[2];
            }
            $tblUserModuleProgress = get_module_course_tbl(array('lp_user_module_progress'), $courseCode);
            Claroline::getDatabase()->exec("UPDATE `{$tblUserModuleProgress['lp_user_module_progress']}`\n                    SET total_time = " . Claroline::getDatabase()->quote($newTotalTime) . ",\n                        session_time = " . Claroline::getDatabase()->quote($sessionTime) . "\n                  WHERE user_module_progress_id = " . Claroline::getDatabase()->escape((int) $userModuleProgressId));
            $documentTimeUpdateArgs = array('sessionTime' => $sessionTime, 'date' => $date, 'userId' => $userId, 'courseCode' => $courseCode, 'learnPathId' => $learnPathId, 'moduleId' => $moduleId);
            $documentTimeUpdateEvent = new Event('lp_document_time_update', $documentTimeUpdateArgs);
            EventManager::notify($documentTimeUpdateEvent);
            echo 'Document spent time updated';
        } else {
            echo 'Wrong userId or wrong courseCode';
        }
    } else {
        echo 'There is at least one null param';
    }
} else {
    echo 'User not authenticated';
}
Esempio n. 30
0
/**
 * Route the script to an auhtentication form if user id is missing.
 * Once authenticated, the system get back to the source where the form
 * was trigged
 *
 * @param boolean $cidRequired - if the course id is required to leave the form
 * @author Christophe gesche <*****@*****.**>
 * @copyright   (c) 2001-2011, Universite catholique de Louvain (UCL)
 */
function claro_disp_auth_form($cidRequired = false)
{
    if (isset($_SESSION['login_already_claimed']) && $_SESSION['login_already_claimed'] === true) {
        $_SESSION['login_already_claimed'] = false;
        return;
    }
    $_SESSION['login_already_claimed'] = true;
    // TODO check if it does not break the CAS mechanism
    if (get_conf('claro_secureLogin', false)) {
        $sourceUrl = base64_encode(rtrim(get_path('rootWeb'), '/') . $_SERVER['REQUEST_URI']);
    } else {
        $sourceUrl = base64_encode($_SERVER['REQUEST_URI']);
    }
    if (!headers_sent()) {
        $urlCmd = $cidRequired && !claro_is_in_a_course() ? '&cidRequired=true' : '';
        header('Location:' . get_path('url') . '/claroline/auth/login.php?sourceUrl=' . urlencode($sourceUrl) . $urlCmd);
    } else {
        Claroline::getDisplay()->body->appendContent('<p align="center">' . 'WARNING ! Login Required <br />' . 'Click ' . '<a href="' . get_path('url') . '/claroline/auth/login.php' . '?sourceUrl=' . urlencode($sourceUrl) . '">' . 'here' . '</a>' . '</p>');
        Claroline::getDisplay()->render();
    }
    die;
    // necessary to prevent any continuation of the application
}