/** * Create a Drupal user when the Chamilo user is registered * @param HookCreateUserEventInterface $hook The hook */ public function hookCreateUser(HookCreateUserEventInterface $hook) { $data = $hook->getEventData(); $drupalDomain = CreateDrupalUser::create()->get('drupal_domain'); $drupalDomain = rtrim($drupalDomain, '/') . '/'; if ($data['type'] === HOOK_EVENT_TYPE_POST) { $return = $data['return']; $originalPassword = $data['originalPassword']; $userInfo = api_get_user_info($return); $fields = array('name' => $userInfo['username'], 'pass' => $originalPassword, 'mail' => $userInfo['email'], 'status' => 1, 'init' => $userInfo['email']); $extraFields = array('first_name' => $userInfo['firstname'], 'last_name' => $userInfo['lastname']); $options = array('location' => $drupalDomain . 'sites/all/modules/chamilo/soap.php?wsdl', 'uri' => $drupalDomain); $client = new SoapClient(null, $options); $drupalUserId = false; if (isset($_SESSION['ws_drupal_user_id'])) { $drupalUserId = $_SESSION['ws_drupal_user_id']; return true; } if ($drupalUserId === false) { $drupalUserId = $client->addUser($fields, $extraFields); } if ($drupalUserId !== false) { UserManager::update_extra_field_value($return, 'drupal_user_id', $drupalUserId); } } }
/** * constructor * @path the path to a folder * @calculateSubdir force to get the subdirectories information */ function __construct($path = null, $calculateSubdir = true) { $this->calculateSubdir = $calculateSubdir; if (defined('CONFIG_SYS_FOLDER_SHOWN_ON_TOP')) { $this->forceFolderOnTop = CONFIG_SYS_FOLDER_SHOWN_ON_TOP; } if (!is_null($path)) { $this->currentFolderPath = $path; } elseif (isset($_GET[$this->folderPathIndex]) && file_exists(base64_decode($_GET[$this->folderPathIndex])) && !is_file(base64_decode($_GET[$this->folderPathIndex]))) { $this->currentFolderPath = api_htmlentities(Security::remove_XSS($_GET[$this->folderPathIndex])); } elseif (isset($_SESSION[$this->lastVisitedFolderPathIndex]) && file_exists($_SESSION[$this->lastVisitedFolderPathIndex]) && !is_file($_SESSION[$this->lastVisitedFolderPathIndex])) { $this->currentFolderPath = $_SESSION[$this->lastVisitedFolderPathIndex]; } else { $this->currentFolderPath = CONFIG_SYS_DEFAULT_PATH; } $this->currentFolderPath = isUnderRoot($this->getCurrentFolderPath()) ? backslashToSlash(addTrailingSlash($this->getCurrentFolderPath())) : $this->currentFolderPath; $this->currentFolderPath = base64_encode($this->currentFolderPath); if ($this->calculateSubdir) { // keep track of this folder path in session $_SESSION[$this->lastVisitedFolderPathIndex] = $this->currentFolderPath; } if (is_dir($this->getCurrentFolderPath())) { $file = new file($this->getCurrentFolderPath()); $folderInfo = $file->getFileInfo(); if (sizeof($folderInfo)) { //for Chamilo in a name folder, replace num user by user names if (preg_match('/sf_user_/', basename($this->getCurrentFolderPath()))) { $userinfo = api_get_user_info(substr(basename($this->getCurrentFolderPath()), 8)); $this->currentFolderInfo['name'] = $userinfo['complete_name']; } else { $this->currentFolderInfo['name'] = str_replace('_', ' ', basename($this->getCurrentFolderPath())); //for Chamilo. Prevent long directory name } if (preg_match('/shared_folder/', basename($this->getCurrentFolderPath()))) { $this->currentFolderInfo['name'] = get_lang('UserFolders'); } if (preg_match('/shared_folder_session_/', basename($this->getCurrentFolderPath()))) { $session = explode('_', basename($this->getCurrentFolderPath())); $session = strtolower($session[sizeof($session) - 1]); $this->currentFolderInfo['name'] = get_lang('UserFolders') . ' (' . api_get_session_name($session) . ')*'; } //end Chamilo $this->currentFolderInfo['subdir'] = 0; $this->currentFolderInfo['file'] = 0; $this->currentFolderInfo['ctime'] = $folderInfo['ctime']; $this->currentFolderInfo['mtime'] = $folderInfo['mtime']; $this->currentFolderInfo['is_readable'] = $folderInfo['is_readable']; $this->currentFolderInfo['is_writable'] = $folderInfo['is_writable']; $this->currentFolderInfo['path'] = $this->getCurrentFolderPath(); $this->currentFolderInfo['path_base64'] = base64_encode($this->getCurrentFolderPath()); $this->currentFolderInfo['friendly_path'] = transformFilePath($this->getCurrentFolderPath()); $this->currentFolderInfo['type'] = 'folder'; $this->currentFolderInfo['cssClass'] = 'folder'; //$this->currentFolderInfo['flag'] = $folderInfo['flag']; } } if ($calculateSubdir && !file_exists($this->getCurrentFolderPath())) { die(ERR_FOLDER_NOT_FOUND . $this->getCurrentFolderPath()); } }
/** * @Route("/me") * @Method({"GET"}) */ public function indexAction() { $userInfo = api_get_user_info($this->getUser()->getUserId()); $this->getTemplate()->assign('user', $userInfo); $response = $this->getTemplate()->renderTemplate($this->getTemplatePath() . 'me.tpl'); return new Response($response, 200, array()); }
/** * Save the score for a HP quiz. Can be used by the learnpath tool as well * for HotPotatoes quizzes. When coming from the learning path, we * use the session variables telling us which item of the learning path has to * be updated (score-wise) * @param string File is the exercise name (the file name for a HP) * @param integer Score to save inside the tracking tables (HP and learnpath) * @return void */ function save_scores($file, $score) { global $origin; $TABLETRACK_HOTPOTATOES = Database::get_main_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES); $_user = api_get_user_info(); // if tracking is disabled record nothing $weighting = 100; // 100% $date = api_get_utc_datetime(); $c_id = api_get_course_int_id(); if ($_user['user_id']) { $user_id = $_user['user_id']; } else { // anonymous $user_id = "NULL"; } $params = ['exe_name' => $file, 'exe_user_id' => $user_id, 'exe_date' => $date, 'c_id' => $c_id, 'exe_result' => $score, 'exe_weighting' => $weighting]; Database::insert($TABLETRACK_HOTPOTATOES, $params); if ($origin == 'learnpath') { //if we are in a learning path, save the score in the corresponding //table to get tracking in there as well global $jscript2run; //record the results in the learning path, using the SCORM interface (API) $jscript2run .= "<script>\n \$(document).ready(function() {\n //API_obj = window.frames.window.content.API;\n //API_obj = \$('content_id').context.defaultView.content.API; //works only in FF\n //API_obj = window.parent.frames.window.top.API;\n API_obj = window.top.API;\n API_obj.void_save_asset('{$score}', '{$weighting}', 0, 'completed');\n });\n </script>"; } }
public function get_forum_thread_data($username, $password, $course_code, $thread_id, $field) { if ($this->verifyUserPass($username, $password) == "valid") { $course_db = CourseManager::get_course_information($course_code); $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_db['db_name']); $table_threads = Database::get_course_table(TABLE_FORUM_THREAD, $course_db['db_name']); $sql = "SELECT * FROM " . $table_threads . " threads, " . $table_item_property . " item_properties\n WHERE item_properties.tool='" . TOOL_FORUM_THREAD . "'\n AND item_properties.ref='" . Database::escape_string($thread_id) . "'\n AND threads.thread_id='" . Database::escape_string($thread_id) . "'"; $result = Database::query($sql); $thread_info = Database::fetch_array($result); switch ($field) { case 'title': $htmlcode = true; $field_table = "thread_title"; break; case 'date': $field_table = "thread_date"; break; case 'sender': $field_table = "insert_user_id"; break; case 'sender_name': $user_id = $thread_info['insert_user_id']; $user_info = api_get_user_info($user_id); return $user_info['firstname']; break; default: $field_table = "title"; } return $thread_info[$field_table]; } else { return get_lang('InvalidId'); } }
/** * * Constructor (generates a connection to the API and the Chamilo settings * required for the connection to the video conference server) * @param string $host * @param string $salt */ public function __construct($host = null, $salt = null) { // Initialize video server settings from global settings $plugin = BBBPlugin::create(); $bbb_plugin = $plugin->get('tool_enable'); if (empty($host)) { $bbb_host = $plugin->get('host'); } else { $bbb_host = $host; } if (empty($salt)) { $bbb_salt = $plugin->get('salt'); } else { $bbb_salt = $salt; } $this->logout_url = api_get_path(WEB_PLUGIN_PATH) . 'bbb/listing.php?' . api_get_cidreq(); $this->table = Database::get_main_table('plugin_bbb_meeting'); if ($bbb_plugin == true) { $userInfo = api_get_user_info(); $this->user_complete_name = $userInfo['complete_name']; $this->salt = $bbb_salt; $info = parse_url($bbb_host); $this->url = $bbb_host . '/bigbluebutton/'; if (isset($info['scheme'])) { $this->protocol = $info['scheme'] . '://'; $this->url = str_replace($this->protocol, '', $this->url); } // Setting BBB api define('CONFIG_SECURITY_SALT', $this->salt); define('CONFIG_SERVER_BASE_URL', $this->url); $this->api = new BigBlueButtonBN(); $this->plugin_enabled = true; } }
/** * Create a video chat * @param int $fromUser The sender user * @param int $toUser The receiver user * @return int The created video chat id. Otherwise return false */ public static function createRoom($fromUser, $toUser) { $fromUserInfo = api_get_user_info($fromUser); $toUserInfo = api_get_user_info($toUser); $chatName = vsprintf(get_lang('VideoChatBetweenUserXAndUserY'), [$fromUserInfo['firstname'], $toUserInfo['firstname']]); return Database::insert(Database::get_main_table(TABLE_MAIN_CHAT_VIDEO), ['from_user' => intval($fromUser), 'to_user' => intval($toUser), 'room_name' => $chatName, 'datetime' => api_get_utc_datetime()]); }
public function get_announcement_data($username, $password, $course_code, $announcement_id, $field) { if ($this->verifyUserPass($username, $password) == "valid") { $htmlcode = false; $user_id = UserManager::get_user_id_from_username($username); $result = self::get_announcements($username, $course_code, $announcement_id); while ($announcement = Database::fetch_array($result)) { $announcements[] = $announcement; } switch ($field) { case 'sender': $field_table = "insert_user_id"; $sender = api_get_user_info($announcements[0][$field_table]); $announcements[0][$field_table] = $sender['firstname'] . " " . $sender['lastname']; break; case 'title': $htmlcode = true; $field_table = "title"; break; case 'date': $field_table = "end_date"; break; case 'content': $htmlcode = true; $field_table = "content"; $announcements[0][$field_table] = nl2br_revert($announcements[0][$field_table]); break; default: $field_table = "title"; } return htmlcode ? html_entity_decode($announcements[0][$field_table]) : $announcements[0][$field_table]; } else { return get_lang('InvalidId'); } }
/** * Setups the folder */ public function setup() { $userId = api_get_user_id(); $userInfo = api_get_user_info(); $sessionId = api_get_session_id(); $courseInfo = $this->connector->course; if (!empty($courseInfo)) { $coursePath = api_get_path(SYS_COURSE_PATH); $courseDir = $courseInfo['directory'] . '/document'; $baseDir = $coursePath . $courseDir; // Creates shared folder if (!file_exists($baseDir . '/shared_folder')) { $title = get_lang('UserFolders'); $folderName = '/shared_folder'; //$groupId = 0; $visibility = 0; create_unexisting_directory($courseInfo, $userId, $sessionId, 0, null, $baseDir, $folderName, $title, $visibility); } // Creates user-course folder if (!file_exists($baseDir . '/shared_folder/sf_user_' . $userId)) { $title = $userInfo['complete_name']; $folderName = '/shared_folder/sf_user_' . $userId; $visibility = 1; create_unexisting_directory($courseInfo, $userId, $sessionId, 0, null, $baseDir, $folderName, $title, $visibility); } } }
function dc_check_phone_number($user) { $uInfo = api_get_user_info($user['user_id']); if (empty($uInfo['phone'])) { return false; } return true; }
/** * @param string $name * @param Request $request * @return Response */ public function classicAction($name, Request $request) { // get. $_GET = $request->query->all(); // post. $_POST = $request->request->all(); $rootDir = $this->get('kernel')->getRealRootDir(); //$_REQUEST = $request->request->all(); $mainPath = $rootDir . 'main/'; $fileToLoad = $mainPath . $name; // Setting legacy values inside the container /** @var Connection $dbConnection */ $dbConnection = $this->container->get('database_connection'); $em = $this->get('kernel')->getContainer()->get('doctrine.orm.entity_manager'); $database = new \Database($dbConnection, array()); $database->setConnection($dbConnection); $database->setManager($em); Container::$container = $this->container; Container::$dataDir = $this->container->get('kernel')->getDataDir(); Container::$courseDir = $this->container->get('kernel')->getDataDir(); //Container::$configDir = $this->container->get('kernel')->getConfigDir(); $this->container->get('twig')->addGlobal('api_get_cidreq', api_get_cidreq()); //$breadcrumb = $this->container->get('chamilo_core.block.breadcrumb'); if (is_file($fileToLoad) && \Security::check_abs_path($fileToLoad, $mainPath)) { // Files inside /main need this variables to be set $is_allowed_in_course = api_is_allowed_in_course(); $is_courseAdmin = api_is_course_admin(); $is_platformAdmin = api_is_platform_admin(); $toolNameFromFile = basename(dirname($fileToLoad)); $charset = 'UTF-8'; // Default values $_course = api_get_course_info(); $_user = api_get_user_info(); $debug = $this->container->get('kernel')->getEnvironment() == 'dev' ? true : false; // Loading file ob_start(); require_once $fileToLoad; $out = ob_get_contents(); ob_end_clean(); // No browser cache when executing an exercise. if ($name == 'exercice/exercise_submit.php') { $responseHeaders = array('cache-control' => 'no-store, no-cache, must-revalidate'); } $js = isset($htmlHeadXtra) ? $htmlHeadXtra : array(); // $interbreadcrumb is loaded in the require_once file. $interbreadcrumb = isset($interbreadcrumb) ? $interbreadcrumb : null; $template = Container::$legacyTemplate; $defaultLayout = 'layout_one_col.html.twig'; if (!empty($template)) { $defaultLayout = $template; } return $this->render('ChamiloCoreBundle::' . $defaultLayout, array('legacy_breadcrumb' => $interbreadcrumb, 'content' => $out, 'js' => $js)); } else { // Found does not exist throw new NotFoundHttpException(); } }
/** * Show this resource */ function show() { parent::show(); $extra = api_convert_and_format_date($this->obj->thread_date); if ($this->obj->thread_poster_id) { $user_info = api_get_user_info($this->obj->thread_poster_id); $extra = $user_info['complete_name'] . ', ' . $extra; } echo $this->obj->thread_title . ' (' . $extra . ')'; }
/** * This method check if a user is allowed to see the block inside dashboard interface * @param int User id * @return bool Is block visible for user */ public function is_block_visible_for_user($user_id) { $user_info = api_get_user_info($user_id); $user_status = $user_info['status']; $is_block_visible_for_user = false; if (UserManager::is_admin($user_id) || in_array($user_status, $this->permission)) { $is_block_visible_for_user = true; } return $is_block_visible_for_user; }
/** * Get actual array data * @return array 2-dimensional array - each array contains the elements: * 0 ['id'] : user id * 1 ['result_id'] : result id * 2 ['lastname'] : user lastname * 3 ['firstname'] : user firstname * 4 ['score'] : student's score * 5 ['display'] : custom score display (only if custom scoring enabled) */ public function get_data($sorting = 0, $start = 0, $count = null, $ignore_score_color = false, $pdf = false) { // do some checks on count, redefine if invalid value $number_decimals = api_get_setting('gradebook_number_decimals'); if (!isset($count)) { $count = count($this->results) - $start; } if ($count < 0) { $count = 0; } $scoredisplay = ScoreDisplay::instance(); // generate actual data array $table = array(); foreach ($this->results as $result) { $user = array(); $info = api_get_user_info($result->get_user_id()); $user['id'] = $result->get_user_id(); if ($pdf) { $user['username'] = $info['username']; } $user['result_id'] = $result->get_id(); $user['lastname'] = $info['lastname']; $user['firstname'] = $info['firstname']; if ($pdf) { $user['score'] = $result->get_score(); } else { $user['score'] = $this->get_score_display($result->get_score(), true, $ignore_score_color); } $user['percentage_score'] = intval($scoredisplay->display_score(array($result->get_score(), $this->evaluation->get_max()), SCORE_PERCENT, SCORE_BOTH, true)); if ($pdf && $number_decimals == null) { $user['scoreletter'] = $result->get_score(); } if ($scoredisplay->is_custom()) { $user['display'] = $this->get_score_display($result->get_score(), false, $ignore_score_color); } $table[] = $user; } // sort array if ($sorting & self::RDG_SORT_LASTNAME) { usort($table, array('ResultsDataGenerator', 'sort_by_last_name')); } elseif ($sorting & self::RDG_SORT_FIRSTNAME) { usort($table, array('ResultsDataGenerator', 'sort_by_first_name')); } elseif ($sorting & self::RDG_SORT_SCORE) { usort($table, array('ResultsDataGenerator', 'sort_by_score')); } elseif ($sorting & self::RDG_SORT_MASK) { usort($table, array('ResultsDataGenerator', 'sort_by_mask')); } if ($sorting & self::RDG_SORT_DESC) { $table = array_reverse($table); } $return = array_slice($table, $start, $count); return $return; }
public function __construct(EntityManager $entityManager, array $paths, Router $urlGenerator, Translator $translator, SecurityContext $security, $user, $course = null) { $this->paths = array('root_sys' => api_get_path(SYS_PATH), 'sys_root' => api_get_path(SYS_PATH), 'sys_course_path' => api_get_path(SYS_COURSE_PATH), 'path.temp' => api_get_path(SYS_ARCHIVE_PATH)); $this->entityManager = $entityManager; //$this->paths = $paths; $this->urlGenerator = $urlGenerator; $this->translator = $translator; $this->security = $security; $this->user = empty($user) ? api_get_user_info() : $user; $this->course = empty($course) ? api_get_course_info() : $course; $this->driverList = $this->getDefaultDriverList(); }
public function __construct() { $this->paths = array('root_sys' => api_get_path(SYS_PATH), 'sys_root' => api_get_path(SYS_PATH), 'sys_course_path' => api_get_path(SYS_COURSE_PATH), 'path.temp' => api_get_path(SYS_ARCHIVE_PATH)); /*$this->entityManager = $entityManager; $this->paths = $paths; $this->urlGenerator = $urlGenerator; $this->translator = $translator; $this->security = $security;*/ $this->user = api_get_user_info(); $this->course = api_get_course_info(); $this->driverList = $this->getDefaultDriverList(); }
/** * Handles default Chamilo scripts handled by Display::display_header() and display_footer() * * @param \Silex\Application $app * @param string $file * * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response|void */ public function classicAction(Application $app, $file) { $responseHeaders = array(); /** @var Request $request */ $request = $app['request']; // get. $_GET = $request->query->all(); // post. $_POST = $request->request->all(); // echo $request->getMethod(); //$_REQUEST = $request->request->all(); $mainPath = $app['paths']['sys_root'] . 'main/'; $fileToLoad = $mainPath . $file; if (is_file($fileToLoad) && \Security::check_abs_path($fileToLoad, $mainPath)) { // Default values $_course = api_get_course_info(); $_user = api_get_user_info(); $charset = 'UTF-8'; $debug = $app['debug']; $text_dir = api_get_text_direction(); $is_platformAdmin = api_is_platform_admin(); $_cid = api_get_course_id(); // Loading file ob_start(); require_once $mainPath . $file; $out = ob_get_contents(); ob_end_clean(); // No browser cache when executing an exercise. if ($file == 'exercice/exercise_submit.php') { $responseHeaders = array('cache-control' => 'no-store, no-cache, must-revalidate'); } // Setting page header/footer conditions (important for LPs) $app['template']->setFooter($app['template.show_footer']); $app['template']->setHeader($app['template.show_header']); if (isset($htmlHeadXtra)) { $app['template']->addJsFiles($htmlHeadXtra); } if (isset($interbreadcrumb)) { $app['template']->setBreadcrumb($interbreadcrumb); $app['template']->loadBreadcrumbToTemplate(); } if (isset($tpl)) { $response = $app['twig']->render($app['default_layout']); } else { $app['template']->assign('content', $out); $response = $app['twig']->render($app['default_layout']); } } else { return $app->abort(404, 'File not found'); } return new Response($response, 200, $responseHeaders); }
/** * Unzip the exercise in the temp folder * @param string The path of the temporary directory where the exercise was uploaded and unzipped * @param string * @return bool */ function get_and_unzip_uploaded_exercise($baseWorkDir, $uploadPath) { $_course = api_get_course_info(); $_user = api_get_user_info(); //Check if the file is valid (not to big and exists) if (!isset($_FILES['userFile']) || !is_uploaded_file($_FILES['userFile']['tmp_name'])) { // upload failed return false; } if (preg_match('/.zip$/i', $_FILES['userFile']['name']) && handle_uploaded_document($_course, $_FILES['userFile'], $baseWorkDir, $uploadPath, $_user['user_id'], 0, null, 1)) { return true; } return false; }
/** * My files * @Route("/{username}/files") * @Method({"GET"}) */ public function fileAction($username) { if ($this->getUser()->getUsername() != $username) { return $this->abort(401); } $userId = \UserManager::get_user_id_from_username($username); $userInfo = api_get_user_info($userId); $this->getTemplate()->assign('driver_list', 'PersonalDriver,DropBoxDriver'); $editor = $this->getTemplate()->renderTemplate($this->getHtmlEditor()->getEditorStandAloneTemplate()); $this->getTemplate()->assign('user', $userInfo); $this->getTemplate()->assign('editor', $editor); $response = $this->getTemplate()->renderTemplate($this->getTemplatePath() . 'files.tpl'); return new Response($response, 200, array()); }
function cloud_createCloudRegistration($cid, $lp_id, $lp_view_id) { $userInfo = api_get_user_info(); $userId = $userInfo['user_id']; $ScormService = cloud_getScormEngineService(); $regService = $ScormService->getRegistrationService(); $tbl_scorm_cloud = Database::get_main_table('scorm_cloud'); $sql_cloud_get_course = "Select cloud_course_id from {$tbl_scorm_cloud} " . "WHERE course_code = '{$cid}' AND lp_id = {$lp_id} "; //echo $sql_cloud_get_course.'<br/>'; $res = api_sql_query($sql_cloud_get_course, __FILE__, __LINE__); if (Database::num_rows($res) > 0) { $row = Database::fetch_array($res); $cloud_courseId = $row['cloud_course_id']; } $regService->CreateRegistration(cloud_getRegId($cid, $lp_view_id), $cloud_courseId, $userId, $userInfo['firstName'], $userInfo['lastName']); }
function mdo_generate_default_xml_metadata() { global $iso639_2_code, $ieee_xml; $xhtDoc = new xhtdoc($ieee_xml); $_user = api_get_user_info(); if ($xhtDoc->htt_error) { give_up('IEEE XML (metadata/md_funcs): ' . $xhtDoc->htt_error); } $xhtDoc->xht_get_lang = 'get_lang'; $xhtDoc->xht_xmldoc = new xmddoc(''); if ($xhtDoc->xht_xmldoc->error) { give_up($xhtDoc->xht_xmldoc->error); } $xhtDoc->xht_param['siteUri'] = make_uri(); $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] . '.Link.' . $this->mdo_id; // 2005-05-30: path->sysCode $xhtDoc->xht_param['location'] = $this->mdo_url . ''; $xhtDoc->xht_param['mdlang'] = strtolower($iso639_2_code); $xhtDoc->xht_param['lang'] = strtolower($iso639_2_code); $xhtDoc->xht_param['title'] = $this->mdo_title ? $this->mdo_title : get_lang('MdTitle'); if ($d = $this->mdo_description) { if ($keywords = $this->_find_keywords($d)) { $d = array_pop($keywords); } $xhtDoc->xht_param['description'] = $d; } else { $xhtDoc->xht_param['description'] = get_lang('MdDescription'); } $xhtDoc->xht_param['coverage'] = $this->mdo_category_title ? $this->mdo_category_title : get_lang('MdCoverage'); if (isset($_user)) { $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" . api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . "\\nEMAIL:" . $_user['mail'] . "\\nEND:VCARD\\n"; } $xhtDoc->xht_param['dateTime'] = date('Y-m-d'); $xhtDoc->xht_param['format'] = ''; $xhtDoc->xht_param['size'] = '0'; if (count($keywords)) { $xd = new xmddoc(explode("\n", $mdt = $xhtDoc->xht_fill_template('XML'))); if ($xd->error) { return $mdt; } // and worry later $this->_add_keywords($xd, $keywords); return $xd->xmd_xml(); } return $xhtDoc->xht_fill_template('XML'); }
/** * Constructor (generates a connection to the API and the Chamilo settings * required for the connection to the video conference server) */ public function __construct() { global $_configuration; // initialize video server settings from global settings $plugin = \OpenMeetingsPlugin::create(); $om_plugin = $plugin->get('tool_enable'); $om_host = $plugin->get('host'); $om_user = $plugin->get('user'); $om_pass = $plugin->get('pass'); $accessUrl = api_get_access_url($_configuration['access_url']); $this->externalType = substr($accessUrl['url'], strpos($accessUrl['url'], '://') + 3, -1); if (strcmp($this->externalType, 'localhost') == 0) { $this->externalType = substr(api_get_path(WEB_PATH), strpos(api_get_path(WEB_PATH), '://') + 3, -1); } $this->externalType = 'chamilolms.' . $this->externalType; $this->table = \Database::get_main_table('plugin_openmeetings'); if ($om_plugin) { $user_info = api_get_user_info(); $this->user_complete_name = $user_info['complete_name']; $this->user = $om_user; $this->pass = $om_pass; $this->url = $om_host; // Setting OM api define('CONFIG_OPENMEETINGS_USER', $this->user); define('CONFIG_OPENMEETINGS_PASS', $this->pass); define('CONFIG_OPENMEETINGS_SERVER_URL', $this->url); $this->gateway = new \OpenMeetingsGateway($this->url, $this->user, $this->pass); $this->plugin_enabled = $om_plugin; // The room has a name composed of C + course ID + '-' + session ID $this->chamiloCourseId = api_get_course_int_id(); $this->chamiloSessionId = api_get_session_id(); $this->roomName = 'C' . $this->chamiloCourseId . '-' . $this->chamiloSessionId; $return = $this->gateway->loginUser(); if ($return == 0) { $msg = 'Could not initiate session with server through OpenMeetingsGateway::loginUser()'; error_log(__FILE__ . '+' . __LINE__ . ': ' . $msg); die($msg); } $this->sessionId = $this->gateway->sessionId; } }
/** * @author Sebastien Piraux <*****@*****.**> old code * @author Julio Montoya 2013 * @desc Record information for login event when an user identifies himself with username & password */ public static function event_login($userId) { $userInfo = api_get_user_info($userId); $userId = intval($userId); if (empty($userInfo)) { return false; } $TABLETRACK_LOGIN = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN); $reallyNow = api_get_utc_datetime(); $sql = "INSERT INTO " . $TABLETRACK_LOGIN . " (login_user_id, user_ip, login_date, logout_date) VALUES\n ('" . $userId . "',\n '" . Database::escape_string(api_get_real_ip()) . "',\n '" . $reallyNow . "',\n '" . $reallyNow . "'\n )"; Database::query($sql); // Auto subscribe $user_status = $userInfo['status'] == SESSIONADMIN ? 'sessionadmin' : $userInfo['status'] == COURSEMANAGER ? 'teacher' : $userInfo['status'] == DRH ? 'DRH' : 'student'; $autoSubscribe = api_get_setting($user_status . '_autosubscribe'); if ($autoSubscribe) { $autoSubscribe = explode('|', $autoSubscribe); foreach ($autoSubscribe as $code) { if (CourseManager::course_exists($code)) { CourseManager::subscribe_user($userId, $code); } } } }
function mdo_generate_default_xml_metadata() { global $iso639_2_code, $ieee_xml; $xhtDoc = new xhtdoc($ieee_xml); $_user = api_get_user_info(); if ($xhtDoc->htt_error) { give_up('IEEE XML (metadata/md_funcs): ' . $xhtDoc->htt_error); } $xhtDoc->xht_get_lang = 'get_lang'; $xhtDoc->xht_xmldoc = new xmddoc(''); if ($xhtDoc->xht_xmldoc->error) { give_up($xhtDoc->xht_xmldoc->error); } $xhtDoc->xht_param['siteUri'] = make_uri(); $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] . '.Document.' . $this->mdo_id; // 2005-05-30: path->sysCode $xhtDoc->xht_param['location'] = api_get_path(WEB_PATH) . 'main/metadata/openobject.php?cidReq=' . urlencode($this->mdo_course['sysCode']) . '&eid=' . urlencode($this->mdo_eid); $xhtDoc->xht_param['mdlang'] = strtolower($iso639_2_code); $xhtDoc->xht_param['lang'] = strtolower($iso639_2_code); $xhtDoc->xht_param['title'] = $this->mdo_title ? $this->mdo_title : ($this->mdo_path ? $this->mdo_path : get_lang('MdTitle', '')); $xhtDoc->xht_param['description'] = $this->mdo_comment ? $this->mdo_comment : get_lang('MdDescription', ''); $xhtDoc->xht_param['coverage'] = get_lang('MdCoverage', ''); if (isset($_user)) { $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" . api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . "\\nEMAIL:" . $_user['mail'] . "\\nEND:VCARD\\n"; } $xhtDoc->xht_param['dateTime'] = date('Y-m-d'); if ($this->mdo_filetype == 'folder') { $format = "inode/directory"; } else { require_once api_get_path(LIBRARY_PATH) . 'document.lib.php'; $format = DocumentManager::file_get_mime_type($this->mdo_path); } $xhtDoc->xht_param['format'] = $format; $xhtDoc->xht_param['size'] = ($s = filesize(get_course_path() . $this->mdo_course['path'] . '/document' . $this->mdo_path)) ? $s : '0'; return $xhtDoc->xht_fill_template('XML'); }
public function get_user_name($username, $password, $id, $field) { if ($this->verifyUserPass($username, $password) == "valid") { $userInfo = api_get_user_info($id); switch ($field) { case 'firstname': return $userInfo['firstname']; break; case 'lastname': return $userInfo['lastname']; break; case 'bothfl': return $userInfo['firstname'] . " " . $userInfo['lastname']; break; case 'bothlf': return $userInfo['lastname'] . " " . $userInfo['firstname']; break; default: return $userInfo['firstname']; } return "0"; } return "0"; }
/** * Get document information */ private function get_information($course_id, $doc_id) { $course_information = api_get_course_info($course_id); $course_id = $course_information['real_id']; $course_path = $course_information['path']; if (!empty($course_information)) { $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); $doc_table = Database::get_course_table(TABLE_DOCUMENT); $doc_id = Database::escape_string($doc_id); $sql = "SELECT * FROM {$doc_table}\n WHERE {$doc_table}.id = {$doc_id} AND c_id = {$course_id}\n LIMIT 1"; $dk_result = Database::query($sql); $sql = "SELECT insert_user_id FROM {$item_property_table}\n WHERE ref = {$doc_id} AND tool = '" . TOOL_DOCUMENT . "' AND c_id = {$course_id}\n LIMIT 1"; $name = ''; if ($row = Database::fetch_array($dk_result)) { $name = $row['title']; $url = api_get_path(WEB_PATH) . 'courses/%s/document%s'; $url = sprintf($url, $course_path, $row['path']); // Get the image path $icon = FileManager::choose_image(basename($row['path'])); $thumbnail = api_get_path(WEB_IMG_PATH) . $icon; $image = $thumbnail; //FIXME: use big images // get author $author = ''; $item_result = Database::query($sql); if ($row = Database::fetch_array($item_result)) { $user_data = api_get_user_info($row['insert_user_id']); $author = api_get_person_name($user_data['firstName'], $user_data['lastName']); } } return array($thumbnail, $image, $name, $author, $url); // FIXME: is it posible to get an author here? } else { return array(); } }
/** * @param int $courseId * @param int $sessionId * @param string $filePath */ public function warnUsersByEmail($courseId, $sessionId, $filePath = null) { $courseInfo = api_get_course_info_by_id($courseId); $courseCode = $courseInfo['code']; if (empty($sessionId)) { $students = CourseManager::get_student_list_from_course_code($courseCode, false); } else { $students = CourseManager::get_student_list_from_course_code($courseCode, true, $sessionId); } $url = api_get_course_url($courseCode, $sessionId); $url = Display::url($url, $url); $subject = $this->get_lang("AgreementUpdated"); $message = sprintf($this->get_lang("AgreementWasUpdatedClickHere"), $url); $dataFile = array(); if (!empty($filePath)) { $dataFile = array('path' => $filePath, 'filename' => basename($filePath)); $message = sprintf($this->get_lang("AgreementWasUpdatedClickHere"), $url) . " \n"; $message .= $this->get_lang("TheAgreementIsAttachedInThisEmail"); } if (!empty($students)) { foreach ($students as $student) { $userInfo = api_get_user_info($student['user_id']); api_mail_html($userInfo['complete_name'], $userInfo['email'], $subject, $message, null, null, null, $dataFile); //MessageManager::send_message_simple($student['user_id'], $subject, $message); } } }
$list_get_path_web = SocialManager::get_list_web_path_user_invitation_by_user_id(api_get_user_id()); $count_pending_invitations = count($pending_invitations); } if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) { //Pending invitations if (!isset($_GET['u']) || isset($_GET['u']) && $_GET['u'] == api_get_user_id()) { if ($count_pending_invitations > 0) { $invitations = '<div><h3>' . get_lang('PendingInvitations') . '</h3></div>'; for ($i = 0; $i < $count_pending_invitations; $i++) { $user_invitation_id = $pending_invitations[$i]['user_sender_id']; $invitations .= '<div id="dpending_' . $user_invitation_id . '" class="friend_invitations">'; $invitations .= '<div style="float:left;width:60px;" >'; $invitations .= '<img style="margin-bottom:5px;"' . ' src="' . $list_get_path_web[$i]['dir'] . '/' . $list_get_path_web[$i]['file'] . '"' . ' width="60px">'; $invitations .= '</div>'; $invitations .= '<div style="padding-left:70px;">'; $user_invitation_info = api_get_user_info($user_invitation_id); $invitations .= '<a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php' . '?u=' . $user_invitation_id . '">' . api_get_person_name($user_invitation_info['firstname'], $user_invitation_info['lastname']) . '</a>'; $invitations .= '<br />'; $invitations .= Security::remove_XSS(cut($pending_invitations[$i]['content'], 50), STUDENT, true); $invitations .= '<br />'; $invitations .= '<a id="btn_accepted_' . $user_invitation_id . '"' . ' class="btn btn-default" onclick="register_friend(this)" href="javascript:void(0)">' . get_lang('SocialAddToFriends') . '</a>'; $invitations .= '<div id="id_response"></div>'; $invitations .= '</div>'; $invitations .= '</div>'; } $socialRightInformation .= SocialManager::social_wrapper_div($invitations, 4); } } // Productions $production_list = UserManager::build_production_list($user_id); $product_content = '';
$pdf->line(50, 790, 550, 790); $pdf->line(50, 40, 550, 40); $pdf->ezSetY(750); $pdf->ezTable($newarray, $header_names, '', array('showHeadings' => 1, 'shaded' => 1, 'showLines' => 1, 'rowGap' => 3, 'width' => 500)); $pdf->ezStream(); exit; } } elseif (!empty($_GET['export_certificate'])) { //@todo this code seems not to be used $user_id = strval(intval($_GET['user'])); if (!api_is_allowed_to_edit(true, true)) { $user_id = api_get_user_id(); } $category = Category::load($_GET['cat_id']); if ($category[0]->is_certificate_available($user_id)) { $user = api_get_user_info($user_id); $scoredisplay = ScoreDisplay::instance(); $scorecourse = $category[0]->calc_score($user_id); $scorecourse_display = isset($scorecourse) ? $scoredisplay->display_score($scorecourse, SCORE_AVERAGE) : get_lang('NoResultsAvailable'); $cattotal = Category::load(0); $scoretotal = $cattotal[0]->calc_score($user_id); $scoretotal_display = isset($scoretotal) ? $scoredisplay->display_score($scoretotal, SCORE_PERCENT) : get_lang('NoResultsAvailable'); //prepare all necessary variables: $organization_name = api_get_setting('Institution'); $portal_name = api_get_setting('siteName'); $stud_fn = $user['firstname']; $stud_ln = $user['lastname']; $certif_text = sprintf(get_lang('CertificateWCertifiesStudentXFinishedCourseYWithGradeZ'), $organization_name, $stud_fn . ' ' . $stud_ln, $category[0]->get_name(), $scorecourse_display); $certif_text = str_replace("\\n", "\n", $certif_text); $date = api_convert_and_format_date(null, DATE_FORMAT_SHORT); $pdf = new Cezpdf('a4', 'landscape');
function manage_form($default, $select_from_user_list = null, $sent_to = null) { $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null; $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null; $param_f = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null; $form = new FormValidator('compose_message', null, api_get_self() . '?f=' . $param_f, null, array('enctype' => 'multipart/form-data')); if (empty($group_id)) { if (isset($select_from_user_list)) { $form->addText('id_text_name', get_lang('SendMessageTo'), true, array('id' => 'id_text_name', 'onkeyup' => 'send_request_and_search()', 'autocomplete' => 'off')); $form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('html', '<div id="id_div_search" style="padding:0px" class="message-select-box" > </div>'); $form->addElement('hidden', 'user_list', 0, array('id' => 'user_list')); } else { if (!empty($sent_to)) { $form->addLabel(get_lang('SendMessageTo'), $sent_to); } if (empty($default['users'])) { //fb select $form->addElement('select_ajax', 'users', get_lang('SendMessageTo'), array(), ['multiple' => 'multiple', 'url' => api_get_path(WEB_AJAX_PATH) . 'message.ajax.php?a=find_users']); } else { $form->addElement('hidden', 'hidden_user', $default['users'][0], array('id' => 'hidden_user')); } } } else { $userGroup = new UserGroup(); $group_info = $userGroup->get($group_id); $form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name'])); $form->addElement('hidden', 'group_id', $group_id); $form->addElement('hidden', 'parent_id', $message_id); } $form->addText('title', get_lang('Subject'), true); $form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '100%', 'Height' => '250')); if (isset($_GET['re_id'])) { $message_reply_info = MessageManager::get_message_by_id($_GET['re_id']); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_reply_info['title']; $form->addElement('hidden', 're_id', intval($_GET['re_id'])); $form->addElement('hidden', 'save_form', 'save_form'); //adding reply mail $user_reply_info = api_get_user_info($message_reply_info['user_sender_id']); $default['content'] = '<p><br/></p>' . sprintf(get_lang('XWroteY'), $user_reply_info['complete_name'], Security::filter_terms($message_reply_info['content'])); } if (empty($group_id)) { $form->addElement('label', '', '<div id="filepaths" class="form-group"> <div id="filepath_1"> <label>' . get_lang('FilesAttachment') . '</label> <input type="file" name="attach_1"/> <label>' . get_lang('Description') . '</label> <input id="file-descrtiption" type="text" name="legend[]" class="form-control"/> </div> </div>'); $form->addElement('label', '', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message.message_max_upload_filesize'))) . ')'); } $form->addButtonSend(get_lang('SendMessage'), 'compose'); $form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>'); if (!empty($group_id) && !empty($message_id)) { $message_info = MessageManager::get_message_by_id($message_id); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_info['title']; } $form->setDefaults($default); $html = ''; if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $user_list = $default['users']; $file_comments = $_POST['legend']; $title = $default['title']; $content = $default['content']; $group_id = isset($default['group_id']) ? $default['group_id'] : null; $parent_id = isset($default['parent_id']) ? $default['parent_id'] : null; if (is_array($user_list) && count($user_list) > 0) { //all is well, send the message foreach ($user_list as $user) { $res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id); if ($res) { $html .= MessageManager::display_success_message($user); } } } else { Display::display_error_message('ErrorSendingMessage'); } } Security::clear_token(); } else { $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); $html .= $form->returnForm(); } return $html; }