/** * Returns the name of the current script, WITH the querystring portion. * this function is necessary because PHP_SELF and REQUEST_URI and SCRIPT_NAME * return different things depending on a lot of things like your OS, Web * server, and the way PHP is compiled (ie. as a CGI, module, ISAPI, etc.) * <b>NOTE:</b> This function returns false if the global variables needed are not set. * * @since 1.8 * @return string */ function get_request_uri() { if (!empty($_SERVER['REQUEST_URI'])) { return $_SERVER['REQUEST_URI']; } else { if (!empty($_SERVER['PHP_SELF'])) { if (!empty($_SERVER['QUERY_STRING'])) { return $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']; } return $_SERVER['PHP_SELF']; } elseif (!empty($_SERVER['SCRIPT_NAME'])) { if (!empty($_SERVER['QUERY_STRING'])) { return $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING']; } return $_SERVER['SCRIPT_NAME']; } elseif (!empty($_SERVER['URL'])) { // May help IIS (not well tested) if (!empty($_SERVER['QUERY_STRING'])) { return $_SERVER['URL'] . '?' . $_SERVER['QUERY_STRING']; } return $_SERVER['URL']; } else { pushClaroMessage('Warning: Could not find any of these web server variables: $REQUEST_URI, $PHP_SELF, $SCRIPT_NAME or $URL'); return false; } } }
public static function log($message, $type) { if (claro_debug_mode()) { pushClaroMessage($message, $type); } Claroline::log($type, $message); }
public function isAllowedToDownload($requestedUrl) { if (!$this->isModuleAllowed()) { return false; } if (claro_is_in_a_course()) { if (!claro_is_course_allowed()) { pushClaroMessage('course not allowed', 'debug'); return false; } else { if (claro_is_in_a_group()) { if (!claro_is_group_allowed()) { pushClaroMessage('group not allowed', 'debug'); return false; } else { return true; } } else { return $this->isDocumentDownloadableInCourse($requestedUrl); } } } else { return false; } }
/** * Build the file path of a textzone in a given context * * @param string $key * @param array $context specify the context to build the path. * @param array $right specify an array of right to specify the file * @return file path */ public static function get_textzone_file_path($key, $context = null, $right = null) { $textZoneFile = null; $key .= '.'; if (!is_null($right) && is_array($right)) { foreach ($right as $context => $rightInContext) { if (is_array($rightInContext)) { $key .= $context . '_'; foreach ($rightInContext as $rightName => $rightValue) { if (is_bool($rightValue)) { $key .= $rightValue ? $rightName : 'not_' . $rightName; } else { $key .= $rightName . '_' . $rightValue; } $key .= '.'; } } } } if (is_array($context) && array_key_exists(CLARO_CONTEXT_COURSE, $context)) { if (is_array($context) && array_key_exists(CLARO_CONTEXT_GROUP, $context)) { $textZoneFile = get_conf('coursesRepositorySys') . claro_get_course_group_path($context) . '/textzone/' . $key . 'inc.html'; } else { $textZoneFile = get_conf('coursesRepositorySys') . claro_get_course_path($context[CLARO_CONTEXT_COURSE]) . '/textzone/' . $key . 'inc.html'; } } if (is_null($textZoneFile)) { $textZoneFile = get_path('rootSys') . 'platform/textzone/' . $key . 'inc.html'; } pushClaroMessage($textZoneFile); return $textZoneFile; }
/** * Load the event listener of the current module */ function load_current_module_listeners() { $claroline = Claroline::getInstance(); $path = get_module_path(Claroline::getInstance()->currentModuleLabel()) . '/connector/eventlistener.cnr.php'; if (file_exists($path)) { if (claro_debug_mode()) { pushClaroMessage('Load listeners for : ' . Claroline::getInstance()->currentModuleLabel(), 'debug'); } include $path; } else { if (claro_debug_mode()) { pushClaroMessage('No listeners for : ' . Claroline::getInstance()->currentModuleLabel(), 'warning'); } } }
private function loadModuleManager($cidReq = null) { $toolList = claro_get_main_course_tool_list(); foreach ($toolList as $tool) { if (!is_null($tool['label'])) { $file = get_module_path($tool['label']) . '/connector/trackingManager.cnr.php'; if (file_exists($file)) { require_once $file; if (claro_debug_mode()) { pushClaroMessage('Tracking : ' . $tool['label'] . ' tracking managers loaded', 'debug'); } } } } }
private function __construct() { try { // initialize the event manager and notification classes $this->eventManager = EventManager::getInstance(); $this->notification = ClaroNotification::getInstance(); $this->notifier = ClaroNotifier::getInstance(); // initialize logger $this->logger = new Logger(); $this->moduleLabelStack = array(); if (isset($GLOBALS['tlabelReq'])) { $this->pushModuleLabel($GLOBALS['tlabelReq']); pushClaroMessage("Set current module to {$GLOBALS['tlabelReq']}", 'debug'); } } catch (Exception $e) { die($e); } }
public function isAllowedToDownload($requestedUrl) { $fromCLLNP = isset($_SESSION['fromCLLNP']) && $_SESSION['fromCLLNP'] === true ? true : false; // unset CLLNP mode unset($_SESSION['fromCLLNP']); if (!$fromCLLNP || !$this->isModuleAllowed()) { return false; } if (claro_is_in_a_course()) { if (!claro_is_course_allowed()) { pushClaroMessage('course not allowed', 'debug'); return false; } else { return $this->isDocumentDownloadableInCourse($requestedUrl); } } else { return false; } }
/** * Delete a file or a directory (and its whole content) * * @param - $filePath (String) - the path of file or directory to delete * @return - boolean - true if the delete succeed * boolean - false otherwise. */ function claro_delete_file($filePath) { if (is_file($filePath)) { return unlink($filePath); } elseif (is_dir($filePath)) { $dirHandle = @opendir($filePath); if (!$dirHandle) { function_exists('claro_html_debug_backtrace') && pushClaroMessage(claro_html_debug_backtrace()); return false; } $removableFileList = array(); while (false !== ($file = readdir($dirHandle))) { if ($file == '.' || $file == '..') { continue; } $removableFileList[] = $filePath . '/' . $file; } closedir($dirHandle); // impossible to test, closedir return void ... if (sizeof($removableFileList) > 0) { foreach ($removableFileList as $thisFile) { if (!claro_delete_file($thisFile)) { return false; } } } clearstatcache(); if (is_writable($filePath)) { return @rmdir($filePath); } else { function_exists('claro_html_debug_backtrace') && pushClaroMessage(claro_html_debug_backtrace()); return false; } } // end elseif is_dir() }
/** * helper to unregister a class (and recursively unregister all its subclasses) from a course * @param Claro_Class $claroClass * @param Claro_Course $courseObj * @param Claro_BatchRegistrationResult $result * @return Claro_BatchRegistrationResult * @since Claroline 1.11.9 */ function object_unregister_class_from_course($claroClass, $courseObj, $result) { if ($claroClass->isRegisteredToCourse($courseObj->courseId)) { $classUserIdList = $claroClass->getClassUserList()->getClassUserIdList(); $courseBatchRegistretion = new Claro_BatchCourseRegistration($courseObj); $courseBatchRegistretion->removeUserIdListFromCourse($classUserIdList, $claroClass); if ($claroClass->hasSubclasses()) { pushClaroMessage("Class has subclass", 'debug'); // recursion ! foreach ($claroClass->getSubClassesIterator() as $subClass) { pushClaroMessage("Process subclass{$subClass->getName()}", 'debug'); $result = object_unregister_class_from_course($subClass, $courseObj, $result); } } else { pushClaroMessage("Class has no subclass", 'debug'); } $claroClass->unregisterFromCourse($courseObj->courseId); return $result; } else { return $result; } }
/** * Return the right of the current user * * @author Christophe Gesche <*****@*****.**> * @return boolean */ function claro_is_course_admin() { pushClaroMessage('use claro_is_course_manager() instead of claro_is_course_admin()', 'code review'); return claro_is_course_manager(); }
function generate_module_names_translation_cache() { $cacheRepositorySys = get_path('rootSys') . get_conf('cacheRepository', 'tmp/cache/'); $moduleLangCache = $cacheRepositorySys . 'module_lang_cache'; if (!file_exists($moduleLangCache)) { claro_mkdir($moduleLangCache, CLARO_FILE_PERMISSIONS, true); } $tbl = claro_sql_get_main_tbl(); $sql = "SELECT `name`, `label`\n FROM `" . $tbl['module'] . "`\n WHERE activation = 'activated'"; $module_list = claro_sql_query_fetch_all($sql); $langVars = array(); foreach ($module_list as $module) { $langPath = get_module_path($module['label']) . '/lang/'; if (file_exists($langPath)) { $it = new DirectoryIterator($langPath); foreach ($it as $file) { if ($file->isFile() && preg_match('/^lang_\\w+.php$/', $file->getFilename())) { $langName = str_replace('lang_', '', $file->getFilename()); $langName = str_replace('.php', '', $langName); if ($langName != 'english') { pushClaroMessage($langName . ':' . $module['label'], 'debug'); $_lang = array(); ob_start(); include $file->getPathname(); ob_end_clean(); if (!isset($langVars[$langName])) { $langVars[$langName] = ''; } if (isset($_lang[$module['name']])) { $langVars[$langName] .= '$_lang[\'' . $module['name'] . '\'] = \'' . str_replace("'", "\\'", $_lang[$module['name']]) . '\';' . "\n"; } } } } } } foreach ($langVars as $lgnNm => $contents) { $langFile = $moduleLangCache . '/' . $lgnNm . '.lang.php'; if (file_exists($langFile)) { unlink($langFile); } file_put_contents($langFile, "<?php\n" . $contents); } }
public static function load_module_translation($moduleLabel = null, $language = null) { global $_lang; $moduleLabel = is_null($moduleLabel) ? get_current_module_label() : $moduleLabel; // In a module if (!empty($moduleLabel)) { $module_path = get_module_path($moduleLabel); $language = is_null($language) ? language::current_language() : $language; // load english by default if exists if (file_exists($module_path . '/lang/lang_english.php')) { /* FIXME : DEPRECATED !!!!! */ $mod_lang = array(); include $module_path . '/lang/lang_english.php'; $_lang = array_merge($_lang, $mod_lang); if (claro_debug_mode()) { pushClaroMessage(__FUNCTION__ . "::" . $moduleLabel . '::' . 'English lang file loaded', 'debug'); } } else { // no language file to load if (claro_debug_mode()) { pushClaroMessage(__FUNCTION__ . "::" . $moduleLabel . '::' . 'English lang file not found', 'debug'); } } // load requested language if exists if ($language != 'english' && file_exists($module_path . '/lang/lang_' . $language . '.php')) { /* FIXME : CODE DUPLICATION see 263-274 !!!!! */ /* FIXME : DEPRECATED !!!!! */ $mod_lang = array(); include $module_path . '/lang/lang_' . $language . '.php'; $_lang = array_merge($_lang, $mod_lang); if (claro_debug_mode()) { pushClaroMessage(__FUNCTION__ . "::" . $moduleLabel . '::' . ucfirst($language) . ' lang file loaded', 'debug'); } } elseif ($language != 'english') { // no language file to load if (claro_debug_mode()) { pushClaroMessage(__FUNCTION__ . "::" . $moduleLabel . '::' . ucfirst($language) . ' lang file not found', 'debug'); } } else { // nothing to do } } else { // Not in a module } }
/** * convert a duration in seconds to a human readable duration * @author Sebastien Piraux <*****@*****.**> * @param integer duration time in seconds to convert to a human readable duration */ function claro_disp_duration($duration) { pushClaroMessage((function_exists('claro_html_debug_backtrace') ? claro_html_debug_backtrace() : 'claro_html_debug_backtrace() not defined') . 'claro_ disp _duration() is deprecated , use claro_ html _duration()', 'error'); return claro_html_duration($duration); }
function google_translation($from, $to, $string) { $string = urlencode($string); ### recherche la source chez google avec le mot à traduire: $q pushClaroMessage(__LINE__ . '<pre>"http://translate.google.com/translate_t?text=$string&langpair=$from|$to&hl=fr&ie=UTF-8&oe=UTF-8" =' . var_export("http://translate.google.com/translate_t?text={$string}&langpair={$from}|{$to}&hl=fr&ie=UTF-8&oe=UTF-8", 1) . '</pre>', 'dbg'); $source = implode('', file("http://translate.google.com/translate_t?text={$string}&langpair={$from}|{$to}&hl=fr&ie=UTF-8&oe=UTF-8")); ### decoupage de $source au debut $source = strstr($source, '<div id=result_box dir=ltr>'); ### decoupage de $source à la fin $fin_source = strstr($source, '</div>'); ### supprimer $fin_source de la chaine $source $proposition = str_replace("{$fin_source}", "", $source); $proposition = str_replace("<div id=result_box dir=ltr>", "", $proposition); ### affichage du resultat return $proposition; }
case 'exDelete': $postId = $userInput->getMandatory('post'); break; case 'exNotify': $topicId = $userInput->getMandatory('topic'); break; case 'exdoNotNotify': $topicId = $userInput->getMandatory('topic'); break; case 'show': $topicId = $userInput->getMandatory('topic'); break; } } catch (Exception $ex) { if (claro_debug_mode()) { pushClaroMessage('<pre>' . $ex->__toString() . '</pre>', 'error'); // claro_die( '<pre>' . $ex->__toString() . '</pre>' ); } if ($ex instanceof Claro_Validator_Exception) { switch ($cmd) { case 'rqPost': $dialogBox->error(get_lang('Unknown post or edition mode')); $cmd = 'dialog_only'; break; case 'exSavePost': $dialogBox->error(get_lang('Missing information')); $inputMode = 'missing_input'; break; case 'exDelete': $dialogBox->error(get_lang('Unknown post')); break;
public function ClarolineScriptEmbed() { pushClaroMessage(__CLASS__ . ' is deprecated please use the new display lib instead'); }
/** * Search in all activated modules * * @param string $cidReq */ private function loadModuleRenderer() { if (!is_null($this->courseId)) { $profileId = claro_get_current_user_profile_id_in_course($this->courseId); $toolList = claro_get_course_tool_list($this->courseId, $profileId); } else { $toolList = claro_get_main_course_tool_list(); } foreach ($toolList as $tool) { if (!is_null($tool['label'])) { $file = get_module_path($tool['label']) . '/connector/tracking.cnr.php'; if (file_exists($file)) { require_once $file; if (claro_debug_mode()) { pushClaroMessage('Tracking : ' . $tool['label'] . ' tracking renderers loaded', 'debug'); } } } } }
/** * Load user properties from session */ public function loadFromSession() { if (!empty($_SESSION[$this->sessionVarName])) { $this->_rawData = $_SESSION[$this->sessionVarName]; pushClaroMessage("Kernel object {$this->sessionVarName} loaded from session", 'debug'); } else { throw new Exception("Cannot load kernel object {$this->sessionVarName} from session"); } }
/** * Returns the documents contained into args['curDirPath'] * @param array $args array of parameters, can contain : * - (boolean) recursive : if true, return the content of the requested directory and its subdirectories, if any. Default = true * - (String) curDirPath : returns the content of the directory specified by this path. Default = '' (root) * @throws InvalidArgumentException if $cid is missing * @webservice{/module/MOBILE/CLDOC/getResourceList/cidReq/[?recursive=BOOL&curDirPath='']} * @ws_arg{Method,getResourcesList} * @ws_arg{cidReq,SYSCODE of requested cours} * @ws_arg{recursive,[Optionnal: if true\, return the content of the requested directory and its subdirectories\, if any. Default = true]} * @ws_arg{curDirPath,[Optionnal: returns the content of the directory specified by this path. Default = '' (root)]} * @return array of document object */ function getResourcesList($args) { $recursive = isset($args['recursive']) ? $args['recursive'] : true; $curDirPath = isset($args['curDirPath']) ? $args['curDirPath'] : ''; $cid = claro_get_current_course_id(); if (is_null($cid)) { throw new InvalidArgumentException('Missing cid argument!'); } elseif (!claro_is_course_allowed()) { throw new RuntimeException('Not allowed', 403); } /* READ CURRENT DIRECTORY CONTENT = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */ $claroline = Claroline::getInstance(); $exSearch = false; $groupContext = FALSE; $courseContext = TRUE; $dbTable = get_module_course_tbl(array('document'), $cid); $dbTable = $dbTable['document']; $docToolId = get_course_tool_id('CLDOC'); $groupId = claro_get_current_group_id(); $date = $claroline->notification->getLastActionBeforeLoginDate(claro_get_current_user_id()); if (!defined('A_DIRECTORY')) { define('A_DIRECTORY', 1); } if (!defined('A_FILE')) { define('A_FILE', 2); } $baseWorkDir = get_path('coursesRepositorySys') . claro_get_course_path($cid) . '/document'; /*---------------------------------------------------------------------------- LOAD FILES AND DIRECTORIES INTO ARRAYS ----------------------------------------------------------------------------*/ $searchPattern = ''; $searchRecursive = false; $searchBasePath = $baseWorkDir . $curDirPath; $searchExcludeList = array(); $searchBasePath = secure_file_path($searchBasePath); if (false === ($filePathList = claro_search_file(search_string_to_pcre($searchPattern), $searchBasePath, $searchRecursive, 'ALL', $searchExcludeList))) { switch (claro_failure::get_last_failure()) { case 'BASE_DIR_DONT_EXIST': pushClaroMessage($searchBasePath . ' : call to an unexisting directory in groups'); break; default: pushClaroMessage('Search failed'); break; } $filePathList = array(); } for ($i = 0; $i < count($filePathList); $i++) { $filePathList[$i] = str_replace($baseWorkDir, '', $filePathList[$i]); } if ($exSearch && $courseContext) { $sql = "SELECT path FROM `" . $dbTable . "`\n\t\t\t\t\tWHERE comment LIKE '%" . claro_sql_escape($searchPattern) . "%'"; $dbSearchResult = claro_sql_query_fetch_all_cols($sql); $filePathList = array_unique(array_merge($filePathList, $dbSearchResult['path'])); } $fileList = array(); if (count($filePathList) > 0) { /*-------------------------------------------------------------------------- SEARCHING FILES & DIRECTORIES INFOS ON THE DB ------------------------------------------------------------------------*/ /* * Search infos in the DB about the current directory the user is in */ if ($courseContext) { $sql = "SELECT `path`, `visibility`, `comment`\n\t\t\t\t\t\tFROM `" . $dbTable . "`\n\t\t\t\t\t\t\t\tWHERE path IN ('" . implode("', '", array_map('claro_sql_escape', $filePathList)) . "')"; $xtraAttributeList = claro_sql_query_fetch_all_cols($sql); } else { $xtraAttributeList = array('path' => array(), 'visibility' => array(), 'comment' => array()); } foreach ($filePathList as $thisFile) { $fileAttributeList['cours']['sysCode'] = $cid; $fileAttributeList['path'] = $thisFile; $fileAttributeList['resourceId'] = $thisFile; $tmp = explode('/', $thisFile); if (is_dir($baseWorkDir . $thisFile)) { $fileYear = date('n', time()) < 8 ? date('Y', time()) - 1 : date('Y', time()); $fileAttributeList['title'] = $tmp[count($tmp) - 1]; $fileAttributeList['isFolder'] = true; $fileAttributeList['type'] = A_DIRECTORY; $fileAttributeList['size'] = 0; $fileAttributeList['date'] = $fileYear . '-09-20'; $fileAttributeList['extension'] = ""; $fileAttributeList['url'] = null; } elseif (is_file($baseWorkDir . $thisFile)) { $fileAttributeList['title'] = implode('.', explode('.', $tmp[count($tmp) - 1], -1)); $fileAttributeList['type'] = A_FILE; $fileAttributeList['isFolder'] = false; $fileAttributeList['size'] = claro_get_file_size($baseWorkDir . $thisFile); $fileAttributeList['date'] = date('Y-m-d', filemtime($baseWorkDir . $thisFile)); $fileAttributeList['extension'] = get_file_extension($baseWorkDir . $thisFile); $fileAttributeList['url'] = $_SERVER['SERVER_NAME'] . claro_get_file_download_url($thisFile); } $xtraAttributeKey = array_search($thisFile, $xtraAttributeList['path']); if ($xtraAttributeKey !== false) { $fileAttributeList['description'] = $xtraAttributeList['comment'][$xtraAttributeKey]; $fileAttributeList['visibility'] = $xtraAttributeList['visibility'][$xtraAttributeKey] == 'v'; unset($xtraAttributeList['path'][$xtraAttributeKey]); } else { $fileAttributeList['description'] = null; $fileAttributeList['visibility'] = true; } $notified = $claroline->notification->isANotifiedDocument($cid, $date, claro_get_current_user_id(), $groupId, $docToolId, $fileAttributeList, false); $fileAttributeList['notifiedDate'] = $notified ? $date : $fileAttributeList['date']; $d = new DateTime($date); $d->sub(new DateInterval('P1D')); $fileAttributeList['seenDate'] = $d->format('Y-m-d'); if ($fileAttributeList['visibility'] || claro_is_allowed_to_edit()) { $fileList[] = $fileAttributeList; } } // end foreach $filePathList } if ($recursive) { foreach ($fileList as $thisFile) { if ($thisFile['type'] == A_DIRECTORY) { $args = array('curDirPath' => $thisFile['path'], 'recursive' => true); $new_list = $this->getResourcesList($args); $fileList = array_merge($fileList, $new_list); } } } return $fileList; }
if ($downloader && $downloader->isAllowedToDownload($requestUrl)) { $pathInfo = $downloader->getFilePath($requestUrl); // use slashes instead of backslashes in file path if (claro_debug_mode()) { pushClaroMessage('<p>File path : ' . $pathInfo . '</p>', 'pathInfo'); } $pathInfo = secure_file_path($pathInfo); // Check if path exists in course folder if (!file_exists($pathInfo) || is_dir($pathInfo)) { $isDownloadable = false; $dialogBox->title(get_lang('Not found')); $dialogBox->error(get_lang('The requested file <strong>%file</strong> was not found on the platform.', array('%file' => basename($pathInfo)))); } } else { $isDownloadable = false; pushClaroMessage('downloader said no!', 'debug'); $dialogBox->title(get_lang('Not allowed')); } } // Output section if ($isDownloadable) { // end session to avoid lock session_write_close(); $extension = get_file_extension($pathInfo); $mimeType = get_mime_on_ext($pathInfo); // workaround for HTML files and Links if ($mimeType == 'text/html' && $extension != 'url') { $claroline->notifier->event('download', array('data' => array('url' => $requestUrl))); if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") { $rootSys = str_replace('//', '/', strtolower(str_replace('\\', '/', $rootSys))); $pathInfo = strtolower(str_replace('\\', '/', $pathInfo));
/** * Get the authentication profile for the given user id * @param int $userId * @return AuthProfile */ public static function getUserAuthProfile($userId) { if ($userId != claro_get_current_user_id()) { $user = new Claro_User($userId); $user->loadFromDatabase(); } else { $user = Claro_CurrentUser::getInstance(); } $authSource = $user->authSource; if (!$authSource) { throw new Exception("Cannot find user authentication source for user {$userId}"); } try { $profileOptions = AuthDriverManager::getDriver($authSource)->getAuthProfileOptions(); } catch (Exception $e) { if (claro_is_platform_admin() || claro_is_in_a_course() && claro_is_course_manager() && $userId != claro_get_current_user_id()) { Console::warning("Cannot find user authentication source for user {$userId}, use claroline default options instead"); $profileOptions = AuthDriverManager::getDriver('claroline')->getAuthProfileOptions(); } else { throw $e; } } $authProfile = new AuthProfile($userId, $authSource); $authProfile->setAuthDriverOptions($profileOptions); if (claro_debug_mode()) { pushClaroMessage(var_export($profileOptions, true), 'debug'); } return $authProfile; }
$searchRecursive = true; $searchBasePath = $baseWorkDir . $cwd; } else { $searchPattern = ''; $searchRecursive = false; $searchBasePath = $baseWorkDir . $curDirPath; $searchExcludeList = array(); } $searchBasePath = secure_file_path($searchBasePath); if (false === ($filePathList = claro_search_file(search_string_to_pcre($searchPattern), $searchBasePath, $searchRecursive, 'ALL', $searchExcludeList))) { switch (claro_failure::get_last_failure()) { case 'BASE_DIR_DONT_EXIST': pushClaroMessage($searchBasePath . ' : call to an unexisting directory in groups'); break; default: pushClaroMessage('Search failed'); break; } // TODO claro_search_file would return an empty array when failed $filePathList = array(); } for ($i = 0; $i < count($filePathList); $i++) { $filePathList[$i] = str_replace($baseWorkDir, '', $filePathList[$i]); } if ($cmd == 'exSearch' && $courseContext) { $sql = "SELECT path FROM `" . $dbTable . "`\n WHERE comment LIKE '%" . claro_sql_escape($searchPatternSql) . "%'"; $dbSearchResult = claro_sql_query_fetch_all_cols($sql); if (!$is_allowedToEdit) { for ($i = 0; $i < count($searchExcludeList); $i++) { for ($j = 0; $j < count($dbSearchResult['path']); $j++) { if (preg_match('|^' . $searchExcludeList[$i] . '|', $dbSearchResult['path'][$j])) {
// COPY THE FILE TO WORK REPOSITORY pushClaroMessage(__LINE__ . 'packageCandidatePath is a path', 'dbg'); claro_mkdir(get_package_path()); $modulePath = create_unexisting_directory(get_package_path() . basename($_REQUEST['packageCandidatePath'])); claro_mkdir($modulePath); pushClaroMessage(__LINE__ . 'create target' . $modulePath, 'dbg'); if (claro_copy_file($_REQUEST['packageCandidatePath'], $modulePath . '/')) { $modulePath .= '/' . basename($_REQUEST['packageCandidatePath']); $moduleInstallable = true; } else { $dialogBox->error(get_lang('Module catching failed. Check your path')); $moduleInstallable = false; } } } pushClaroMessage(__LINE__ . '<pre>$modulePath =' . var_export($modulePath, 1) . '</pre>', 'dbg'); // OK TO TRY TO INSTALL ? if ($moduleInstallable) { list($backlog, $module_id) = install_module($modulePath); $details = $backlog->output(); if (false !== $module_id) { $summary = get_lang('Module installation succeeded'); $moduleInfo = get_module_info($module_id); $typeReq = $moduleInfo['type']; $dialogBox->success(Backlog_Reporter::report($summary, $details)); if ($activateOnInstall) { list($backlogActivation, $successActivation) = activate_module($module_id, false); $detailsActivation = $backlogActivation->output(); if ($successActivation) { $dialogBox->success(get_lang('Module activation succeeded')); if ($visibleOnInstall && $typeReq == 'tool') {
if (empty($portlet['label'])) { pushClaroMessage("Portlet with no label found ! Please check your database", 'warning'); continue; } // load portlet if (!class_exists($portlet['label'])) { pushClaroMessage("User desktop : class {$portlet['label']} not found !", 'warning'); continue; } if ($portlet['label'] == 'mycourselist') { continue; } $plabel = $portlet['label']; $portlet = new $plabel($plabel); if (!$portlet instanceof UserDesktopPortlet) { pushClaroMessage("{$portlet['label']} is not a valid user desktop portlet !"); continue; } $outPortlet .= $portlet->render(); } catch (Exception $e) { $portletDialog = new DialogBox(); $portletDialog->error(get_lang('An error occured while loading the portlet : %error%', array('%error%' => $e->getMessage()))); $outPortlet .= '<div class="claroBlock portlet">' . '<h3 class="blockHeader">' . "\n" . $portlet->renderTitle() . '</h3>' . "\n" . '<div class="claroBlockContent">' . "\n" . $portletDialog->render() . '</div>' . "\n" . '</div>' . "\n\n"; } } } else { $dialogBox->error(get_lang('Cannot load portlet list')); } // Generate Script Output CssLoader::getInstance()->load('desktop', 'all'); $template = new CoreTemplate('user_desktop.tpl.php');
/** * build htmlstream for input form of a time * * @param string $hourFieldName attribute name of the input Hour * @param string $minuteFieldName attribute name of the input minutes * @param string $unixDate unix timestamp of date to display * * @return string html stream to output input tag for an hour * * @author S�bastien Piraux <*****@*****.**> * */ function claro_disp_time_form($hourFieldName, $minuteFieldName, $unixDate = 0) { pushClaroMessage((function_exists('claro_html_debug_backtrace') ? claro_html_debug_backtrace() : 'claro_html_debug_backtrace() not defined') . 'claro_disp_time_form() is deprecated , use claro_html_time_form()', 'error'); return claro_html_time_form($hourFieldName, $minuteFieldName, $unixDate); }
/** * Send e-mail to Claroline users form their ID a user of Claroline * * Send e-mail to Claroline users form their ID a user of Claroline * default from clause in email address will be the platorm admin adress * default from name clause in email will be the platform admin name and surname * * @author Hugues Peeters <*****@*****.**> * @param int or array $userIdList - sender id's * @param string $message - mail content * @param string $subject - mail subject * @param string $specificFrom (optional) sender's email address * @param string $specificFromName (optional) sender's name * @return int total count of sent email */ function claro_mail_user($userIdList, $message, $subject, $specificFrom = '', $specificFromName = '') { if (!is_array($userIdList)) { $userIdList = array($userIdList); } if (count($userIdList) == 0) { return 0; } $tbl = claro_sql_get_main_tbl(); $tbl_user = $tbl['user']; $sql = 'SELECT DISTINCT email FROM `' . $tbl_user . '` WHERE user_id IN (' . implode(', ', array_map('intval', $userIdList)) . ')'; $emailList = claro_sql_query_fetch_all_cols($sql); $emailList = $emailList['email']; $emailList = array_filter($emailList, 'is_well_formed_email_address'); $mail = new ClaroPHPMailer(); if ($specificFrom != '') { $mail->From = $specificFrom; } else { $mail->From = get_conf('administrator_email'); } if ($specificFromName != '') { $mail->FromName = $specificFromName; } else { $mail->FromName = get_conf('administrator_name'); } $mail->Sender = $mail->From; if (strlen($subject) > 78) { $message = $subject . "\n" . $message; $subject = substr($subject, 0, 73) . '...'; } $mail->Subject = $subject; $mail->Body = $message; $emailSentCount = 0; if (claro_debug_mode()) { $message = '<p>Subject : ' . claro_htmlspecialchars($subject) . '</p>' . "\n" . '<p>Message : <pre>' . claro_htmlspecialchars($message) . '</pre></p>' . "\n" . '<p>From : ' . claro_htmlspecialchars($mail->FromName) . ' - ' . claro_htmlspecialchars($mail->From) . '</p>' . "\n" . '<p>Dest : ' . implode(', ', $emailList) . '</p>' . "\n"; pushClaroMessage($message, 'mail'); } foreach ($emailList as $thisEmail) { $mail->AddAddress($thisEmail); if ($mail->Send()) { $emailSentCount++; } else { if (claro_debug_mode()) { pushClaroMessage($mail->getError(), 'error'); } } $mail->ClearAddresses(); } return $emailSentCount; }
/** * Send a mail to the user list * * @param int $userIdList list of the user * @param string $message body of the mail * @param string $subject subject of the mail * @param string $specificFrom email of the sender * @param string $specificFromName name to display * @param string $altBody link of the message in case of problem of read * */ protected static function emailNotification($userIdList, $message, $subject, $specificFrom = '', $specificFromName = '', $altBody = '') { if (!is_array($userIdList)) { $userIdList = array($userIdList); } if (count($userIdList) == 0) { return 0; } $tbl = claro_sql_get_main_tbl(); $tbl_user = $tbl['user']; $sql = 'SELECT DISTINCT email FROM `' . $tbl_user . '` WHERE user_id IN (' . implode(', ', array_map('intval', $userIdList)) . ')'; $emailList = claro_sql_query_fetch_all_cols($sql); $emailList = $emailList['email']; $emailList = array_filter($emailList, 'is_well_formed_email_address'); $mail = new ClaroPHPMailer(); $mail->IsHTML(true); if (!empty($altBody)) { $mail->AltBody = $altBody; } if ($specificFrom != '') { $mail->From = $specificFrom; } else { $mail->From = get_conf('administrator_email'); } if ($specificFromName != '') { $mail->FromName = $specificFromName; } else { $mail->FromName = get_conf('administrator_name'); } $mail->Sender = $mail->From; if (strlen($subject) > 78) { $message = get_lang('Subject') . ' : ' . $subject . "<br />\n\n" . $message; $subject = substr($subject, 0, 73) . '...'; } $mail->Subject = $subject; $mail->Body = $message; if (claro_debug_mode()) { $message = '<p>' . get_lang('Subject') . ' : ' . claro_htmlspecialchars($subject) . '</p>' . "\n" . '<p>' . get_lang('Message') . ' : <pre>' . claro_htmlspecialchars($message) . '</pre></p>' . "\n" . '<p>' . get_lang('Sender') . ' : ' . claro_htmlspecialchars($mail->FromName) . ' - ' . claro_htmlspecialchars($mail->From) . '</p>' . "\n" . '<p>' . get_lang('Recipient') . ' : ' . implode(', ', $emailList) . '</p>' . "\n"; pushClaroMessage($message, 'mail'); } $error_list = array(); foreach ($emailList as $thisEmail) { try { $mail->AddAddress($thisEmail); $mail->Send(); } catch (phpmailerException $exception) { if (claro_debug_mode()) { pushClaroMessage('Mail Notification Failed ' . $exception->__toString()); $error_list[] = $thisEmail; } } $mail->ClearAddresses(); } }
public function loadFromModule($moduleLabel, $lib, $media = 'all') { $lib = secure_file_path($lib); $moduleLabel = secure_file_path($moduleLabel); if (!get_module_data($moduleLabel)) { pushClaroMessage(__CLASS__ . "::{$moduleLabel} does not exists", 'error'); return false; } if (claro_debug_mode()) { pushClaroMessage(__CLASS__ . "::Try to find {$lib} for {$moduleLabel}", 'debug'); } $cssPath = array(0 => array('path' => get_path('rootSys') . 'platform/css/' . $moduleLabel . '/' . $lib . '.css', 'url' => get_path('url') . '/platform/css/' . $moduleLabel . '/' . $lib . '.css'), 1 => array('path' => get_module_path($moduleLabel) . '/css/' . $lib . '.css', 'url' => get_module_url($moduleLabel) . '/css/' . $lib . '.css')); /*$path = get_module_path( $moduleLabel ) . '/css/' . $lib . '.css'; $url = get_module_url( $moduleLabel ) . '/css/' . $lib . '.css';*/ foreach ($cssPath as $cssTry) { $path = $cssTry['path']; $url = $cssTry['url']; if (claro_debug_mode()) { pushClaroMessage(__CLASS__ . "::Try {$path}::{$url} for {$moduleLabel}", 'debug'); } if (file_exists($path)) { if (array_key_exists($path, $this->css)) { return false; } $this->css[$path] = array('url' => $url . '?' . filemtime($path), 'media' => $media); if (claro_debug_mode()) { pushClaroMessage(__CLASS__ . "::Use {$path}::{$url} for {$moduleLabel}", 'debug'); } ClaroHeader::getInstance()->addHtmlHeader('<link rel="stylesheet" type="text/css"' . ' href="' . $url . '"' . ' media="' . $media . '" />'); return true; } else { if (claro_debug_mode()) { pushClaroMessage(__CLASS__ . "::Cannot found css {$lib} for {$moduleLabel}", 'error'); } return false; } } }
function claro_debug_assertion_handler($file, $line, $code) { pushClaroMessage(claro_htmlspecialchars("Assertion failed in {$file} at lin {$line} : {$code}"), 'assert'); }