本文整理汇总了PHP中UserManager::get_api_keys方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::get_api_keys方法的具体用法?PHP UserManager::get_api_keys怎么用?PHP UserManager::get_api_keys使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::get_api_keys方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WSEventsList
/**
* Get a list of events between two dates for the given username
* Function registered as service. Returns strings in UTF-8.
* @param string Username
* @param string User's API key (the user's API key)
* @param int Start date, in YYYYMMDD format
* @param int End date, in YYYYMMDD format
* @return array Events list
*/
function WSEventsList($username, $signature, $datestart = 0, $dateend = 0)
{
if (empty($username) or empty($signature)) {
return -1;
}
global $_configuration;
$info = api_get_user_info_from_username($username);
$user_id = $info['user_id'];
$list = UserManager::get_api_keys($user_id, 'dokeos');
$key = '';
foreach ($list as $key) {
break;
}
$local_key = $username . $key;
if (!api_is_valid_secret_key($signature, $local_key)) {
return -1;
// The secret key is incorrect.
}
$events_list = array();
$user_id = UserManager::get_user_id_from_username($username);
if ($user_id === false) {
return $events_list;
}
// Error in user id recovery.
$ds = substr($datestart, 0, 4) . '-' . substr($datestart, 4, 2) . '-' . substr($datestart, 6, 2) . ' 00:00:00';
$de = substr($dateend, 0, 4) . '-' . substr($dateend, 4, 2) . '-' . substr($dateend, 6, 2) . ' 00:00:00';
$events_list = Agenda::get_personal_agenda_items_between_dates($user_id, $ds, $de);
return $events_list;
}
示例2: isValidApiKey
/**
* Check if the api is valid for a user
* @param string $username The username
* @param string $apiKeyToValidate The api key
* @return boolean Whether the api belongs to the user return true. Otherwise return false
*/
public static function isValidApiKey($username, $apiKeyToValidate)
{
$userInfo = api_get_user_info_from_username($username);
$userId = $userInfo['user_id'];
$apiKeys = UserManager::get_api_keys($userId, self::SERVICE_NAME);
if (!empty($apiKeys)) {
$apiKey = current($apiKeys);
if ($apiKey == $apiKeyToValidate) {
return true;
}
}
return false;
}
示例3: WSCourseList
/**
* Get a list of courses (code, url, title, teacher, language) and return to caller
* Function registered as service. Returns strings in UTF-8.
* @param string User name in Chamilo
* @param string Signature (composed of the sha1(username+apikey)
* @param mixed Array or string. Type of visibility of course (public, public-registered, private, closed)
* @return array Courses list (code=>[title=>'title',url='http://...',teacher=>'...',language=>''],code=>[...],...)
*/
function WSCourseList($username, $signature, $visibilities = 'public') {
if (empty($username) or empty($signature)) { return -1; }
global $_configuration;
$info = api_get_user_info_from_username($username);
$user_id = $info['user_id'];
if (!UserManager::is_admin($user_id)) { return -1; }
$list = UserManager::get_api_keys($user_id, 'dokeos');
$key = '';
foreach ($list as $key) {
break;
}
$local_key = $username.$key;
if (!api_is_valid_secret_key($signature, $local_key) && !api_is_valid_secret_key($signature, $username.$_configuration['security_key'])) {
return -1; // The secret key is incorrect.
}
//public-registered = open
$vis = array('public' => '3', 'public-registered' => '2', 'private' => '1', 'closed' => '0');
$courses_list = array();
if (!is_array($visibilities)) {
$visibilities = split(',', $visibilities);
}
foreach ($visibilities as $visibility) {
if (!in_array($visibility, array_keys($vis))) {
return array('error_msg' => 'Security check failed');
}
$courses_list_tmp = CourseManager::get_courses_list(null, null, null, null, $vis[$visibility]);
foreach ($courses_list_tmp as $index => $course) {
$course_info = CourseManager::get_course_information($course['code']);
$courses_list[] = array('code' => $course['code'], 'title' => api_utf8_encode($course_info['title']), 'url' => api_get_path(WEB_COURSE_PATH).$course_info['directory'].'/', 'teacher' => api_utf8_encode($course_info['tutor_name']), 'language' => $course_info['course_language']);
}
}
return $courses_list;
}
示例4: WSUpdateUserApiKey
function WSUpdateUserApiKey($params)
{
if (!WSHelperVerifyKey($params)) {
return return_error(WS_ERROR_SECRET_KEY);
}
$user_id = UserManager::get_user_id_from_original_id($params['original_user_id_value'], $params['original_user_id_name']);
if (!$user_id) {
if (!empty($params['chamilo_username'])) {
$info = api_get_user_info_from_username($params['chamilo_username']);
$user_id = $info['user_id'];
// Save new fieldlabel into user_field table.
$field_id = UserManager::create_extra_field($params['original_user_id_name'], 1, $params['original_user_id_name'], '');
// Save the external system's id into user_field_value table.
$res = UserManager::update_extra_field_value($user_id, $params['original_user_id_name'], $params['original_user_id_value']);
} else {
return 0;
}
}
$list = UserManager::get_api_keys($user_id);
$key_id = UserManager::get_api_key_id($user_id, 'dokeos');
if (isset($list[$key_id])) {
$apikey = $list[$key_id];
} else {
$lastid = UserManager::update_api_key($user_id, 'dokeos');
if ($lastid) {
$apikeys = UserManager::get_api_keys($user_id);
$apikey = $apikeys[$lastid];
}
}
return $apikey;
}
示例5: array
echo '';
} else {
if (isset($_GET['tag']) && isset($_GET['field_id'])) {
echo UserManager::get_tags($_GET['tag'], $_GET['field_id'], 'json', '10');
}
}
break;
case 'generate_api_key':
if (api_is_anonymous()) {
echo '';
} else {
$array_list_key = array();
$user_id = api_get_user_id();
$api_service = 'dokeos';
$num = UserManager::update_api_key($user_id, $api_service);
$array_list_key = UserManager::get_api_keys($user_id, $api_service);
?>
<div class="row">
<div class="label"><?php
echo get_lang('MyApiKey');
?>
</div>
<div class="formw">
<input type="text" name="api_key_generate" id="id_api_key_generate" size="40" value="<?php
echo $array_list_key[$num];
?>
"/>
</div>
</div>
<?php
}
示例6: is_profile_editable
$jquery_ready_content = '';
if (api_get_setting('message.allow_message_tool') == 'true') {
$jquery_ready_content = <<<EOF
\$(".message-content .message-delete").click(function(){
\$(this).parents(".message-content").animate({ opacity: "hide" }, "slow");
\$(".message-view").animate({ opacity: "show" }, "slow");
});
EOF;
}
$tool_name = is_profile_editable() ? get_lang('ModifProfile') : get_lang('ViewProfile');
$table_user = Database::get_main_table(TABLE_MAIN_USER);
/*
* Get initial values for all fields.
*/
$user_data = api_get_user_info(api_get_user_id());
$array_list_key = UserManager::get_api_keys(api_get_user_id());
$id_temp_key = UserManager::get_api_key_id(api_get_user_id(), 'dokeos');
$value_array = $array_list_key[$id_temp_key];
$user_data['api_key_generate'] = $value_array;
if ($user_data !== false) {
if (api_get_setting('profile.login_is_email') == 'true') {
$user_data['username'] = $user_data['email'];
}
if (is_null($user_data['language'])) {
$user_data['language'] = api_get_setting('language.platform_language');
}
}
/*
* Initialize the form.
*/
$form = new FormValidator('profile', 'post', api_get_self() . "?" . str_replace('&fe=1', '', Security::remove_XSS($_SERVER['QUERY_STRING'])), null);
示例7: ensure_user_token
/**
* Ensure a security token is available for the user and rss service- create one if needed.
*
* @return string The security token
*/
public function ensure_user_token()
{
$user_id = $this->get_user_id();
$service = $this->service_name();
$keys = UserManager::get_api_keys($user_id, $service);
if (empty($keys)) {
UserManager::add_api_key($user_id, $service);
$keys = UserManager::get_api_keys($user_id, $service);
}
return end($keys);
}