本文整理汇总了PHP中api_get_user_info函数的典型用法代码示例。如果您正苦于以下问题:PHP api_get_user_info函数的具体用法?PHP api_get_user_info怎么用?PHP api_get_user_info使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了api_get_user_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hookCreateUser
/**
* 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);
}
}
}
示例2: __construct
/**
* 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());
}
}
示例3: indexAction
/**
* @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());
}
示例4: save_scores
/**
* 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>";
}
}
示例5: get_forum_thread_data
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');
}
}
示例6: __construct
/**
*
* 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;
}
}
示例7: createRoom
/**
* 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()]);
}
示例8: get_announcement_data
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');
}
}
示例9: setup
/**
* 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);
}
}
}
示例10: dc_check_phone_number
function dc_check_phone_number($user)
{
$uInfo = api_get_user_info($user['user_id']);
if (empty($uInfo['phone'])) {
return false;
}
return true;
}
示例11: classicAction
/**
* @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();
}
}
示例12: show
/**
* 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 . ')';
}
示例13: is_block_visible_for_user
/**
* 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;
}
示例14: get_data
/**
* 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;
}
示例15: __construct
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();
}