/** * CLAROLINE * * @version $Revision: 13708 $ * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE * @package CLANN * @subpackage CLICAL * @author Claro Team <*****@*****.**> */ function CLANN_write_ical($iCal, $context) { if (is_array($context) && count($context) > 0) { $courseId = array_key_exists(CLARO_CONTEXT_COURSE, $context) ? $context[CLARO_CONTEXT_COURSE] : claro_get_current_course_id(); } require_once dirname(__FILE__) . '/../lib/announcement.lib.php'; $courseData = claro_get_course_data($courseId); $toolNameList = claro_get_tool_name_list(); $announcementList = announcement_get_item_list($context, 'DESC'); $organizer = (array) array($courseData['titular'], $courseData['email']); $attendees = array(); $categories = array(get_conf('siteName'), $courseData['officialCode'], trim($toolNameList['CLANN'])); foreach ($announcementList as $announcementItem) { if ('SHOW' == $announcementItem['visibility']) { /* $rssList[] = array( 'title' => trim($announcementItem['title']) , 'category' => trim($toolNameList['CLANN']) , 'guid' => get_module_url('CLANN') . '/announcements.php?cidReq='.claro_get_current_course_id().'&l#ann'.$announcementItem['id'] , 'link' => get_module_url('CLANN') . '/announcements.php?cidReq='.claro_get_current_course_id().'&l#ann'.$announcementItem['id'] , 'description' => trim(str_replace('<!-- content: html -->','',$announcementItem['content'])) , 'pubDate' => date('r', stripslashes(strtotime($announcementItem['time']))) //, 'author' => $_course['email'] ); */ $iCal->addJournal(trim($announcementItem['title']), trim(str_replace('<!-- content: html -->', '', $announcementItem['content'])), strtotime($announcementItem['time']), strtotime($announcementItem['time']), time(), 1, 1, $organizer, $attendees, $categories, 5, 10, 1, array(), 0, '', get_path('rootWeb') . get_module_url('CLANN') . '/announcements.php?cidReq=' . $courseId . '&l#ann' . $announcementItem['id'], get_locale('iso639_1_code'), ''); } } return $iCal; }
/** * notify by email the user of the reception of a message * * @param array of int: $userDataList user identificatin list * @param MessageToSend $message message envoy� * @param int $messageId identification of the message * */ public function notify($userDataList, $message, $messageId) { if (!get_conf('mailNotification', TRUE)) { return; } // sender name and email if ($message->getSender() == 0) { $userData = array('mail' => get_conf('no_reply_mail') ? get_conf('no_reply_mail') : get_conf('administrator_email'), 'firstName' => get_lang('Message from %platformName', array('%platformName' => get_conf('siteName'))), 'lastName' => ''); } else { $userData = claro_get_current_user_data(); } //************************************ IS MANAGER $stringManager = false; $courseManagers = claro_get_course_manager_id($message->getCourseCode()); $nbrOfManagers = count($courseManagers); for ($countManager = 0; $countManager < $nbrOfManagers; $countManager++) { if ($message->getSender() == $courseManagers[$countManager]) { $courseData = claro_get_course_data($message->getCourseCode()); $stringManager = get_block('Course manager of %course%(%courseCode%)', array('%course%' => $courseData['name'], '%courseCode%' => $courseData['officialCode'])); } } //---------------------- email subject $emailSubject = '[' . get_conf('siteName'); if (!is_null($message->getCourseCode())) { $courseData = claro_get_course_data($message->getCourseCode()); if ($courseData) { $emailSubject .= ' - ' . $courseData['officialCode']; } } $emailSubject .= '] ' . $message->getSubject(); //------------------------------subject /* $altBody = get_lang('If you can\'t read this message go to: ') . rtrim( get_path('rootWeb'), '/' ) . '/claroline/messaging/readmessage.php?messageId=' . $messageId . '&type=received' . "\n\n" . '-- ' . claro_get_current_user_data('lastName') . " " . claro_get_current_user_data('firstName') . "\n" . $stringManager . "\n\n" . get_conf('siteName') ." <" . get_conf('rootWeb') . '>' . "\n" . ' ' . get_lang('Administrator') . ' : ' . get_conf('administrator_name') . ' <' . get_conf('administrator_email') . '>' . "\n" ; */ //-------------------------BODY $msgContent = claro_parse_user_text($message->getMessage()); $urlAppend = get_path('url'); if (!empty($urlAppend)) { $msgContent = preg_replace('!href="' . get_path('url') . '!', 'href="' . rtrim(get_path('rootWeb'), '/') . '/', $msgContent); $msgContent = preg_replace('!\\>' . get_path('url') . '!', '>' . get_path('rootWeb'), $msgContent); } else { $msgContent = preg_replace('!href="/!', 'href="' . rtrim(get_path('rootWeb'), '/') . '/', $msgContent); } $emailBody = "<html><head></head><body>" . $msgContent . '<br /><br />' . '-- <br />' . get_lang('%firstName %lastName', array('%firstName' => $userData['firstName'], '%lastName' => $userData['lastName'])) . "<br />" . $stringManager . '<br /><br /><a href="' . get_conf('rootWeb') . '">' . get_conf('siteName') . '</a><br />' . ' ' . get_lang('Administrator') . ': <a href="mailto:' . get_conf('administrator_email') . '">' . get_conf('administrator_name') . '</a><br />' . '</body></html>'; //******************************** END BODY //****************************************** if (empty($userData['mail']) || !is_well_formed_email_address($userData['mail'])) { // do not send email for a user with no mail address pushClaroMessage('Mail Notification Failed : User has no email or an invalid one : ' . var_export($userData, true) . '!'); return claro_failure::set_failure(get_lang("Mail Notification Failed : You don't have any email address defined in your user profile or the defined email address is not valid.")); } self::emailNotification($userDataList, $emailBody, $emailSubject, $userData['mail'], get_lang('%firstName %lastName', array('%firstName' => $userData['firstName'], '%lastName' => $userData['lastName']))); }
/** * Returns the list of courses followed by the user. * @webservice{/module/MOBILE/User/getCourseList} * @ws_arg{Method,getCourseList} * @return array of course object */ function getCourseList() { FromKernel::uses('courselist.lib'); $claroNotification = Claroline::getInstance()->notification; $date = $claroNotification->getLastActionBeforeLoginDate(claro_get_current_user_id()); $courseList = array(); $notifiedCourses = $claroNotification->getNotifiedCourses($date, claro_get_current_user_id()); foreach (get_user_course_list(claro_get_current_user_id()) as $course) { $course_data = claro_get_course_data($course['sysCode']); $course['officialEmail'] = $course_data['email']; $course['notifiedDate'] = in_array($course['sysCode'], $notifiedCourses); $courseList[] = $course; } return $courseList; }
/** * CLAROLINE * * @version 1.8 $Revision: 13708 $ * * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE * * @package CLWRK * * @author Claro Team <*****@*****.**> */ function CLWRK_write_ical($iCal, $context) { if (is_array($context) && count($context) > 0) { $courseCode = array_key_exists(CLARO_CONTEXT_COURSE, $context) ? $context[CLARO_CONTEXT_COURSE] : ($courseCode = claro_get_current_course_id()); $courseData = claro_get_course_data($courseCode); $toolNameList = claro_get_tool_name_list(); $assignmentList = assignmentList($courseCode); $organizer = (array) array($courseData['titular'], $courseData['email']); $attendees = array(); $categories = array(get_conf('siteName'), $courseData['officialCode'], trim($toolNameList['CLWRK'])); foreach ($assignmentList as $thisAssignment) { if ('VISIBLE' == $thisAssignment['visibility']) { $categories[] = $thisAssignment['assignment_type']; $assignmentContent = trim(strip_tags($thisAssignment['description'])); $iCal->addToDo(trim($thisAssignment['title']), $assignmentContent, '', (int) $thisAssignment['start_date_unix'], 3600, (int) $thisAssignment['end_date_unix'], 0, 5, 1, 1, $organizer, $attendees, $categories, time(), 0, 0, 0, 0, array(), 1, '', get_path('rootWeb') . 'work/work_list.php?cidReq=' . $courseCode . '&assigId=' . $thisAssignment['id'], get_locale('iso639_1_code'), ''); } } } return $iCal; }
/** * Returns the complete path to the requested file, depending on the context * @param string $requestedUrl the relative path of the requested file * @return string the complete path to the requested file */ public function getFilePath($requestedUrl) { if (!is_null($this->cid)) { $courseInfo = claro_get_course_data($this->cid); $coursePath = $courseInfo['path']; if (claro_is_in_a_group() && claro_is_group_allowed()) { $intermediatePath = get_path('coursesRepositorySys') . $coursePath . '/group/' . claro_get_current_group_data('directory'); } else { $intermediatePath = get_path('coursesRepositorySys') . $coursePath . '/document'; } } else { $intermediatePath = rtrim(str_replace('\\', '/', get_path('rootSys')), '/') . '/platform/document'; } if (get_conf('secureDocumentDownload') && $GLOBALS['is_Apache']) { // pretty url $path = realpath($intermediatePath . '/' . $requestedUrl); } else { // TODO check if we can remove rawurldecode $path = $intermediatePath . implode('/', array_map('rawurldecode', explode('/', $requestedUrl))); } return $path; }
/** * CLAROLINE * * @version $Revision: 13708 $ * @copyright (c) 2001-2011, Universite catholique de Louvain (UCL) * @license http://www.gnu.org/copyleft/gpl.html (GPL) GENERAL PUBLIC LICENSE * @package CLCAL * @subpackage CLRSS * @author Claro Team <*****@*****.**> */ function CLCAL_write_ical($iCal, $context) { if (is_array($context) && count($context) > 0) { $courseId = array_key_exists(CLARO_CONTEXT_COURSE, $context) ? $context[CLARO_CONTEXT_COURSE] : claro_get_current_course_id(); } if (false !== ($courseData = claro_get_course_data($courseId))) { $toolNameList = claro_get_tool_name_list(); require_once dirname(__FILE__) . '/../lib/agenda.lib.php'; $eventList = agenda_get_item_list($context, 'ASC'); $organizer = (array) array($courseData['titular'], $courseData['email']); $attendees = array(); $categories = array(get_conf('siteName'), $courseData['officialCode'], trim($toolNameList['CLCAL'])); foreach ($eventList as $thisEvent) { if ('SHOW' == $thisEvent['visibility']) { $eventDuration = isset($thisEvent['duration']) ? $thisEvent['duration'] : get_conf('defaultEventDuration', '60'); $startDate = strtotime($thisEvent['day'] . ' ' . $thisEvent['hour']); // Start Time (timestamp; for an allday event the startdate has to start at YYYY-mm-dd 00:00:00) $endDate = $startDate + $eventDuration; $iCal->addEvent($organizer, $startDate, $endDate, '', 0, $categories, trim(str_replace('<!-- content: html -->', '', $thisEvent['content'])), trim($thisEvent['title']), 1, $attendees, 5, 0, 0, 0, array(), 1, '', 0, 1, get_path('rootWeb') . get_module_url('CLCAL') . '/agenda.php?cidReq=' . $courseId . '&l#item' . $thisEvent['id'], get_locale('iso639_1_code'), ''); } } } return $iCal; }
public function getResourceName(ResourceLocator $locator) { $courseData = claro_get_course_data($locator->getCourseId()); return $courseData['officialCode'] . ' : ' . $courseData['name']; }
/** * Get the official code of a course. * @param string $course_id (optionnal) If not set, it use the current course * will be taken. * @return string path * @author Christophe Gesche <*****@*****.**> * @since 1.7 */ function claro_get_course_officialCode($cid = NULL) { $k = claro_get_course_data($cid); if (isset($k['officialCode'])) { return $k['officialCode']; } else { return NULL; } }
$notifyFeedbacks = $userInput->getMandatory('feedback'); if (false === save_course_property('notify_submissions', $notifySubmissions, claro_get_current_course_id())) { $errorsCount++; } if (false === save_course_property('notify_feedbacks', $notifyFeedbacks, claro_get_current_course_id())) { $errorsCount++; } if ($errorCount > 0) { $dialogBox->error(get_lang('Error while saving notification preferences')); } else { $dialogBox->success(get_lang('Notification preferences saved')); } //force refresh of course data in session! $courseData = claro_get_course_data(claro_get_current_course_id(), true); } else { $courseData = claro_get_course_data(claro_get_current_course_id(), false); } } catch (Exception $ex) { $dialogBox->error($ex->getMessage()); } //init other vars if (!isset($courseData['notify_submissions'])) { $courseData['notify_submissions'] = get_conf('mail_notification', false) && get_conf('automatic_mail_notification', false) ? '1' : '0'; } if (!isset($courseData['notify_feedbacks'])) { $courseData['notify_feedbacks'] = get_conf('mail_notification', false) && get_conf('automatic_mail_notification', false) ? '1' : '0'; } //display $out = ''; $nameTools = get_lang('Assignments preferences'); $out .= claro_html_tool_title($nameTools);
/** * diplay a received message * * @param ReceivedMessage $message Message to display * @param string $action list of action autorised on the message * @return string HTML source */ private static function displayReceivedMessage($message, $action) { $content = '<div id="im_message">' . "\n" . '<h4 class="header">' . claro_htmlspecialchars($message->getSubject()) . '</h4>' . "\n" . '<div class="imInfoBlock">' . "\n" . '<div class="imCmdList">' . $action . '</div>' . "\n\n" . '<div class="imInfo">' . "\n" . ' <span class="imInfoTitle">' . get_lang('Sender') . ' : </span>' . "\n" . ' <span class="imInfoValue">'; $isAllowed = current_user_is_allowed_to_send_message_to_user($message->getSender()); if ($isAllowed) { $content .= '<a href="sendmessage.php?cmd=rqMessageToUser&userId=' . $message->getSender() . '">'; } $content .= get_lang('%firstName %lastName', array('%firstName' => claro_htmlspecialchars($message->getSenderFirstName()), '%lastName' => claro_htmlspecialchars($message->getSenderLastName()))); if ($isAllowed) { $content .= "</a>"; } $isManager = FALSE; $isAdmin = claro_is_user_platform_admin($message->getSender()); if (!is_null($message->getCourseCode())) { $isManager = claro_is_user_course_manager($message->getSender(), $message->getCourseCode()); } if ($isManager) { $content .= ' <img src="' . get_icon_url('manager') . '" alt="" />'; } elseif ($isAdmin) { $content .= ' <img src="' . get_icon_url('platformadmin') . '" alt="" />'; } else { $content .= ' <img src="' . get_icon_url('user') . '" alt="" />'; } $content .= '' . ' </span>' . "\n" . '</div>' . "\n\n" . '<div class="imInfo">' . "\n" . '<span class="imInfoTitle">' . get_lang('Date') . ' : </span>' . "\n" . '<span class="imInfoValue">' . claro_html_localised_date(get_locale('dateTimeFormatLong'), strtotime($message->getSendTime())) . '</span>' . "\n" . '</div>' . "\n\n"; if (!is_null($message->getCourseCode())) { $content .= '<div class="imInfo">' . "\n" . ' <span class="imInfoTitle">' . get_lang('Course') . '</span>' . "\n" . ' <span class="imInfoValue">' . "\n"; $courseData = claro_get_course_data($message->getCourseCode()); if ($courseData) { $content .= claro_htmlspecialchars($courseData['officialCode']) . ' - ' . claro_htmlspecialchars($courseData['name']); } else { $content .= '?'; } $content .= ' </span>' . "\n" . '</div>' . "\n\n"; if (!is_null($message->getGroupId())) { $content .= '<div class="imInfo">' . "\n" . ' <span class="imInfoTitle">' . get_lang('Group') . ' : </span>' . "\n" . ' <span class="imInfoValue">' . "\n"; $groupData = claro_get_group_data(array(CLARO_CONTEXT_COURSE => $message->getCourseCode(), CLARO_CONTEXT_GROUP => $message->getGroupId())); if ($groupData) { $content .= $groupData['name']; } else { $content .= '?'; } $content .= ' </span>' . "\n" . '</div>' . "\n\n"; } if (!is_null($message->getToolsLabel())) { $content .= '<div class="imInfo">' . "\n" . ' <span class="imInfoTitle">' . get_lang('Tool') . ' : </span>' . "\n" . ' <span class="imInfoValue">' . "\n"; $md = get_module_data($message->getToolsLabel()); if ($md) { $content .= get_lang($md['moduleName']); } else { $content .= '?'; } $content .= ' </span>' . "\n" . '</div>' . "\n\n"; } } $body = $message->getMessage(); $body = claro_html_sanitize_all($body); $content .= '</div>' . "\n" . '<div class="imContent">' . claro_parse_user_text($body) . '</div>' . "\n" . '</div>' . "\n\n"; return $content; }
/** * Send enroll to course succeded email to user * @author Mathieu Laurent <*****@*****.**> * * @param $userId integer * @param $data array * @return boolean */ function user_send_enroll_to_course_mail($userId, $data, $course = null) { require_once dirname(__FILE__) . '/../../messaging/lib/message/messagetosend.lib.php'; require_once dirname(__FILE__) . '/../../messaging/lib/recipient/singleuserrecipient.lib.php'; $courseData = claro_get_course_data($course); $subject = get_lang('Your registration'); $body = get_block('blockCourseSubscriptionNotification', array('%firstname' => $data['firstname'], '%lastname' => $data['lastname'], '%courseCode' => $courseData['officialCode'], '%courseName' => $courseData['name'], '%coursePath' => get_path('rootWeb') . 'claroline/course/index.php?cid=' . $courseData['sysCode'], '%siteName' => get_conf('siteName'), '%rootWeb' => get_path('rootWeb'), '%administratorName' => get_conf('administrator_name'), '%administratorPhone' => get_conf('administrator_phone'), '%administratorEmail' => get_conf('administrator_email'))); $message = new MessageToSend(claro_get_current_user_id(), $subject, $body); $message->setCourse($courseData['sysCode']); $recipient = new SingleUserRecipient($userId); //$message->sendTo($recipient); $recipient->sendMessage($message); return true; }
/** * Send registration succeded email to user * @author Mathieu Laurent <*****@*****.**> * * @param integer $userId * @param mixed $data array of user data or null to keep data following $userId param. * @return boolean */ function user_send_registration_mail($userId, $data, $courseCode = null) { require_once dirname(__FILE__) . '/sendmail.lib.php'; require_once dirname(__FILE__) . '/../../messaging/lib/message/messagetosend.lib.php'; require_once dirname(__FILE__) . '/../../messaging/lib/recipient/singleuserrecipient.lib.php'; if (!empty($data['email'])) { // email subjet $emailSubject = '[' . get_conf('siteName') . '] ' . get_lang('Your registration'); // email body $emailBody = get_block('blockAccountCreationNotification', array('%firstname' => $data['firstname'], '%lastname' => $data['lastname'], '%username' => $data['username'], '%password' => $data['password'], '%siteName' => get_conf('siteName'), '%rootWeb' => get_path('rootWeb'), '%administratorName' => get_conf('administrator_name'), '%administratorPhone' => get_conf('administrator_phone'), '%administratorEmail' => get_conf('administrator_email'))); // add information about course manager if user created in course if (isset($courseCode)) { $courseData = claro_get_course_data($courseCode); $emailBody .= get_lang('User created by ') . ' - ' . $courseData['titular'] . ' - ' . $courseData['email'] . ' ( ' . $courseData['officialCode'] . ' - ' . $courseData['name'] . ' )'; } if (claro_mail_user($userId, $emailBody, $emailSubject)) { return true; } else { return false; } } else { return false; } }
if ($_REQUEST['isCourseManager']) { $properties['isCourseManager'] = 1; $properties['tutor'] = 1; } else { $properties['isCourseManager'] = 0; $properties['tutor'] = 0; } user_set_course_properties($user_id, $cidToEdit, $properties); //set dialogbox message if ($done) { $dialogBox->success(get_lang('The user has been enroled to the course')); } break; } //build and call DB to get info about current course (for title) if needed : $courseData = claro_get_course_data($cidToEdit); if (!$courseData) { unset($_REQUEST['cidToEdit']); claro_die('ERROR : COURSE NOT FOUND!!!'); } //---------------------------------- // Build query and find info in db //---------------------------------- $sql = "\nSELECT\n U.nom, U.prenom, U.`user_id` AS ID,\n CU.*,\n CU.`user_id` AS Register\nFROM `" . $tbl_user . "` AS U"; $toAdd = "\nLEFT JOIN `" . $tbl_course_user . "` AS CU\n ON CU.`user_id`=U.`user_id`\n AND CU.`code_cours` = '" . claro_sql_escape($cidToEdit) . "'\n "; $sql .= $toAdd; //deal with LETTER classification call if (isset($_GET['letter'])) { $toAdd = "\n AND U.`nom` LIKE '" . claro_sql_escape($_GET['letter']) . "%' "; $sql .= $toAdd; }
/** * load course data from database * * @param string $courseId string course identifier * @return boolean success */ public function load($courseId) { if (($course_data = claro_get_course_data($courseId)) !== false) { // Generate the array of categories (excepted for session courses) $categoriesList = array(); //if (is_null($course_data['sourceCourseId'])) //{ foreach ($course_data['categories'] as $cat) { $tempCat = new claroCategory(); $tempCat->load($cat['categoryId']); $categoriesList[] = $tempCat; } //} // Assign $this->courseId = $courseId; $this->id = $course_data['id']; $this->isSourceCourse = $course_data['isSourceCourse']; $this->sourceCourseId = $course_data['sourceCourseId']; $this->title = $course_data['name']; $this->officialCode = $course_data['officialCode']; $this->titular = $course_data['titular']; $this->email = $course_data['email']; $this->categories = $categoriesList; $this->departmentName = $course_data['extLinkName']; $this->extLinkUrl = $course_data['extLinkUrl']; $this->language = $course_data['language']; $this->access = $course_data['access']; $this->visibility = $course_data['visibility']; $this->registration = $course_data['registrationAllowed']; $this->registrationKey = $course_data['registrationKey']; $this->publicationDate = $course_data['publicationDate']; $this->expirationDate = $course_data['expirationDate']; $this->status = $course_data['status']; $this->userLimit = $course_data['userLimit']; $this->useExpirationDate = isset($this->expirationDate); return true; } else { return false; } }
case DISPLAY_MESSAGE_SCREEN: $mainTitle = get_lang('User\'s course'); $subTitle = $userInfo['firstname'] . ' ' . $userInfo['lastname']; $out .= claro_html_tool_title(array('mainTitle' => $mainTitle, 'subTitle' => $subTitle)) . $dialogBox->render(); break; /*--------------------------------------------------------------------- Display user courses in order to unenroll (default display) ---------------------------------------------------------------------*/ /*--------------------------------------------------------------------- Display user courses in order to unenroll (default display) ---------------------------------------------------------------------*/ case DISPLAY_USER_COURSES: $out .= claro_html_tool_title(array('mainTitle' => get_lang('User\'s course') . ' : ' . $userInfo['firstname'] . ' ' . $userInfo['lastname'], 'subTitle' => get_lang('Remove course from your personal course list'))) . $dialogBox->render() . $courseListView->render(); break; case DISPLAY_REGISTRATION_KEY_FORM: $courseData = claro_get_course_data($_REQUEST['course']); $courseName = $courseData['name']; $out .= claro_html_tool_title(array('mainTitle' => get_lang('User\'s course') . ' : ' . $userInfo['firstname'] . ' ' . $userInfo['lastname'], 'subTitle' => get_lang('Enrol to %course', array('%course' => $courseName)))); $template = new CoreTemplate('course_registration_key_form.tpl.php'); $template->assign('formAction', Url::Contextualize($_SERVER['PHP_SELF'])); $template->assign('courseCode', $courseCode); $dialogBox->form($template->render()); $out .= $dialogBox->render(); break; case DISPLAY_REGISTRATION_DISABLED_FORM: if (empty($courseData['email'])) { $courseData['email'] = get_conf('administrator_email'); } if (empty($courseData['titular'])) { $courseData['titular'] = get_conf('administrator_name'); }
/** * Get the path of a course. * @param string $course_id (optionnal) If not set, it use the current course * will be taken. * @return string path * @author Christophe Gesche <*****@*****.**> * @since 1.7 */ function claro_get_course_path($cid = NULL) { $k = claro_get_course_data($cid); if (isset($k['path'])) { return $k['path']; } else { return NULL; } }
/** * Replace the Claroline SQL place holders __CL_MAIN__ and __CL_COURSE__ by * the corresponding value in the given SQL query * @param string $sql * @return string * @since Claroline 1.10 */ protected static function prepareQueryForExecution($sql) { $sql = str_replace('__CL_MAIN__', get_conf('mainTblPrefix'), $sql); if (claro_is_in_a_course()) { $currentCourseDbNameGlu = claro_get_course_data(claro_get_current_course_id(), 'dbNameGlu'); $sql = str_replace('__CL_COURSE__', $currentCourseDbNameGlu['dbNameGlu'], $sql); } else { if (preg_match('/__CL_COURSE__/', $sql)) { throw new Exception("Trying to execute course SQL query while not in a course contexte"); } } return $sql; }
$acceptedCmdList = array('getFileList'); if (isset($_REQUEST['cmd']) && in_array($_REQUEST['cmd'], $acceptedCmdList)) { $cmd = $_REQUEST['cmd']; } else { $cmd = null; } if (!empty($_REQUEST['relPath']) && $_REQUEST['relPath'] != '/' && $_REQUEST['relPath'] != '.') { $relPath = str_replace('..', '', $_REQUEST['relPath']) . '/'; } else { $relPath = ''; } /* * Init other vars */ if (claro_is_in_a_course() && !claro_is_in_a_group()) { $course_data = claro_get_course_data(); // course context $is_allowedToEdit = claro_is_allowed_to_edit(); $pathSys = get_path('coursesRepositorySys') . claro_get_course_path() . '/document/'; $pathWeb = get_path('coursesRepositoryWeb') . claro_get_course_path() . '/document/'; } elseif (claro_is_in_a_group()) { // course context $is_allowedToEdit = claro_is_allowed_to_edit(); $pathSys = get_path('coursesRepositorySys') . claro_get_course_path() . '/group/' . claro_get_current_group_data('directory'); $pathWeb = get_path('coursesRepositoryWeb') . claro_get_course_path() . '/group/' . claro_get_current_group_data('directory'); require claro_get_conf_repository() . 'CLDOC.conf.php'; $maxFilledSpace = get_conf('maxFilledSpace_for_course'); } else { // platform context $is_allowedToEdit = claro_is_platform_admin(); $pathSys = get_path('rootSys') . 'platform/document/';
$_SESSION['admin_course_access'] = trim($_REQUEST['access']); } if (isset($_REQUEST['visibility'])) { $_SESSION['admin_course_visibility'] = trim($_REQUEST['visibility']); } if (isset($_REQUEST['subscription'])) { $_SESSION['admin_course_subscription'] = trim($_REQUEST['subscription']); } if ('clist' != $cfrom) { $addToURL .= '&offsetC=' . $offsetC; } $dialogBox = new DialogBox(); /** * PARSE COMMAND */ $courseToDelete = claro_get_course_data($delCode); if ('exDelete' == $cmd) { if ($courseToDelete) { $do = 'delete'; } else { switch (claro_failure::get_last_failure()) { case 'course_not_found': $dialogBox->error(get_lang('Course not found')); break; default: $dialogBox->error(get_lang('Course not found')); } } } elseif ('rqDelete' == $cmd) { if ($courseToDelete) { $dialogBox->question(get_lang('Are you sure to delete course %name', array('%name' => $courseToDelete['name'])) . '<br/><br/>' . "\n" . '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exDelete&delCode=' . $delCode . '&offsetC=' . $offsetC . $addToURL . '">' . get_lang('Yes') . '</a>' . ' | ' . '<a href="' . $_SERVER['PHP_SELF'] . '">' . get_lang('No') . '</a>' . "\n");
/** * 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; } }
} $content .= ' <a href="readmessage.php?messageId=' . $message->getId() . '&type=sent&userId=' . $currentUserId . '">'; $content .= claro_htmlspecialchars($message->getSubject()) . '</a></td>' . "\n" . '<td>'; if ($recipientList['sentTo'] == 'toUser') { $content .= claro_htmlspecialchars($recipientList['userList'][0]['firstName']) . " " . claro_htmlspecialchars($recipientList['userList'][0]['lastName']); if (count($recipientList['userList']) > 1) { $content .= ", " . claro_htmlspecialchars($recipientList['userList'][1]['firstName']) . " " . claro_htmlspecialchars($recipientList['userList'][1]['lastName']); } if (count($recipientList['userList']) > 2) { $content .= ",..."; } } elseif ($recipientList['sentTo'] == 'toCourse') { $content .= get_lang('Course: ') . " " . $message->getCourseCode(); } elseif ($recipientList['sentTo'] == 'toGroup') { $groupInfo = claro_get_group_data(array(CLARO_CONTEXT_COURSE => $message->getCourseCode(), CLARO_CONTEXT_GROUP => $message->getGroupId())); $courseInfo = claro_get_course_data($message->getCourseCode()); if (!$groupInfo) { $content .= get_lang('Course') . ' : ' . get_lang('unknown') . "; " . get_lang('Group') . ' : ' . get_lang('unknown'); } else { $content .= get_lang('Course') . ' : ' . $courseInfo['officialCode'] . "; " . get_lang('Group') . ' : ' . $groupInfo['name']; } } elseif ($message->isPlatformMessage()) { $content .= get_lang('All users of the platform'); } else { $content .= get_lang('Unknown recipient'); } $content .= '</td>' . '<td>' . claro_html_localised_date(get_locale('dateTimeFormatLong'), strtotime($message->getSendTime())) . '</td>' . "\n"; $content .= '</tr>' . "\n\n"; } } $content .= '</table>' . "\n";
$_uid = null; $is_platformAdmin = false; $is_allowedCreateCourse = false; } /*--------------------------------------------------------------------------- Course initialisation ---------------------------------------------------------------------------*/ // if the requested course is different from the course in session if ($cidReq && (!isset($_SESSION['_cid']) || $cidReq != $_SESSION['_cid'])) { $cidReset = true; $gidReset = true; // As groups depend from courses, group id is reset } if ($cidReset) { if ($cidReq) { $_course = claro_get_course_data($cidReq, true); if ($_course == false) { die('WARNING !! The course\'s datas couldn\'t be loaded at line ' . __LINE__ . '. Please contact your platform administrator.'); } $_cid = $_course['sysCode']; $_groupProperties = claro_get_main_group_properties($_cid); if ($_groupProperties == false) { die('WARNING !! The group\'s properties couldn\'t be loaded at line ' . __LINE__ . '. Please contact your platform administrator.'); } } else { $_cid = null; $_course = null; $_groupProperties['registrationAllowed'] = false; $groupToolList = get_group_tool_label_list(); foreach ($groupToolList as $thisGroupTool) { $thisGroupToolLabel = $thisGroupTool['label'];
function build_rss($context) { if (is_array($context) && count($context) > 0) { $rss = new UniversalFeedCreator(); if (array_key_exists(CLARO_CONTEXT_COURSE, $context)) { // $rssFilePath .= $context[CLARO_CONTEXT_COURSE] . '.'; $_course = claro_get_course_data($context[CLARO_CONTEXT_COURSE]); $rss->title = '[' . get_conf('siteName') . '] ' . $_course['officialCode']; $rss->description = $_course['name']; $rss->editor = $_course['titular'] == '' ? get_conf('administrator_name') : $_course['titular']; $rss->editorEmail = $_course['email'] == '' ? get_conf('administrator_email') : $_course['email']; $rss->link = get_path('rootWeb') . get_path('coursesRepositoryAppend') . claro_get_course_path(); $rss->generator = 'Feedcreator'; if (array_key_exists(CLARO_CONTEXT_GROUP, $context)) { // $rssFilePath .= 'g'.$context[CLARO_CONTEXT_GROUP] . '.'; $rss->title .= '[' . get_lang('Group') . $context[CLARO_CONTEXT_GROUP] . ']'; $rss->description .= get_lang('Group') . $context[CLARO_CONTEXT_GROUP]; } } else { $rss->title = '[' . get_conf('siteName') . '] ' . $_course['officialCode']; $rss->description = $_course['name']; $rss->editor = get_conf('administrator_name'); $rss->editorEmail = get_conf('administrator_email'); $rss->link = get_path('rootWeb'); } $rss->language = get_locale('iso639_1_code'); $rss->docs = 'http://blogs.law.harvard.edu/tech/rss'; $rss->pubDate = date("r", time()); $toolLabelList = rss_get_tool_compatible_list(); //var_dump($toolLabelList); $rssItems = array(); foreach ($toolLabelList as $toolLabel) { /*var_dump(is_tool_activated_in_course( get_tool_id_from_module_label( $toolLabel ), $context[CLARO_CONTEXT_COURSE] ));*/ if (is_tool_activated_in_course(get_tool_id_from_module_label($toolLabel), $context[CLARO_CONTEXT_COURSE])) { if (!is_module_installed_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE])) { install_module_in_course($toolLabel, $context[CLARO_CONTEXT_COURSE]); } $rssToolLibPath = get_module_path($toolLabel) . '/connector/rss.write.cnr.php'; $rssToolFuncName = $toolLabel . '_write_rss'; if (file_exists($rssToolLibPath)) { include_once $rssToolLibPath; if (function_exists($rssToolFuncName)) { $rssItems = array_merge($rssItems, call_user_func($rssToolFuncName, $context)); } } } } $sortDate = array(); foreach ($rssItems as $key => $rssItem) { $sortDate[$key] = $rssItem['pubDate']; } // die(var_export($sortDate, true)); array_multisort($sortDate, SORT_DESC, $rssItems); foreach ($rssItems as $rssItem) { $item = new FeedItem(); $item->title = claro_utf8_encode($rssItem['title'], get_conf('charset')); $item->description = claro_utf8_encode($rssItem['description']); $item->category = $rssItem['category']; $item->guid = $rssItem['guid']; $item->link = $rssItem['link']; $item->date = $rssItem['pubDate']; $rss->addItem($item); } return $rss->outputFeed("RSS2.0"); } return false; }