本文整理汇总了PHP中UserManager::get_user_tags方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::get_user_tags方法的具体用法?PHP UserManager::get_user_tags怎么用?PHP UserManager::get_user_tags使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::get_user_tags方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: switch
} else {
switch ($extraFieldInfo['field_type']) {
case ExtraField::FIELD_TYPE_DOUBLE_SELECT:
$id_options = explode(';', $data);
$value_options = array();
// get option display text from user_field_options table
foreach ($id_options as $id_option) {
$sql = "SELECT display_text FROM {$t_ufo} WHERE id = '{$id_option}'";
$res_options = Database::query($sql);
$row_options = Database::fetch_row($res_options);
$value_options[] = $row_options[0];
}
$extra_information_value .= '<dt>' . ucfirst($extraFieldInfo['display_text']) . ':</dt>' . '<dd>' . implode(' ', $value_options) . '</dd>';
break;
case ExtraField::FIELD_TYPE_TAG:
$user_tags = UserManager::get_user_tags($user_id, $extraFieldInfo['id']);
$tag_tmp = array();
foreach ($user_tags as $tags) {
$tag_tmp[] = '<a class="label label_tag"' . ' href="' . api_get_path(WEB_PATH) . 'main/social/search.php?q=' . $tags['tag'] . '">' . $tags['tag'] . '</a>';
}
if (is_array($user_tags) && count($user_tags) > 0) {
$extra_information_value .= '<dt>' . ucfirst($extraFieldInfo['display_text']) . ':</dt>' . '<dd>' . implode('', $tag_tmp) . '</dd>';
}
break;
case ExtraField::FIELD_TYPE_SOCIAL_PROFILE:
$icon_path = UserManager::get_favicon_from_url($data);
$bottom = '0.2';
//quick hack for hi5
$domain = parse_url($icon_path, PHP_URL_HOST);
if ($domain == 'www.hi5.com' or $domain == 'hi5.com') {
$bottom = '-0.8';
示例2: set_extra_fields_in_form
//.........这里部分代码省略.........
}
}
$group = '';
$group[] = $form->createElement('select', 'extra_' . $field_details[1], '', $values[0], '');
$group[] = $form->createElement('select', 'extra_' . $field_details[1] . '*', '', $values['*'], '');
$form->addGroup($group, 'extra_' . $field_details[1], $field_details[3], ' ');
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
/* Recoding the selected values for double : if the user has
selected certain values, we have to assign them to the
correct select form */
if (array_key_exists('extra_' . $field_details[1], $extra_data)) {
// exploding all the selected values (of both select forms)
$selected_values = explode(';', $extra_data['extra_' . $field_details[1]]);
$extra_data['extra_' . $field_details[1]] = array();
// looping through the selected values and assigning the selected values to either the first or second select form
foreach ($selected_values as $key => $selected_value) {
if (array_key_exists($selected_value, $values[0])) {
$extra_data['extra_' . $field_details[1]]['extra_' . $field_details[1]] = $selected_value;
} else {
$extra_data['extra_' . $field_details[1]]['extra_' . $field_details[1] . '*'] = $selected_value;
}
}
}
break;
case ExtraField::FIELD_TYPE_DIVIDER:
$form->addElement('static', $field_details[1], '<br /><strong>' . $field_details[3] . '</strong>');
break;
case ExtraField::FIELD_TYPE_TAG:
//the magic should be here
$user_tags = UserManager::get_user_tags($user_id, $field_details[0]);
$tag_list = '';
if (is_array($user_tags) && count($user_tags) > 0) {
foreach ($user_tags as $tag) {
$tag_list .= '<option value="' . $tag['tag'] . '" class="selected">' . $tag['tag'] . '</option>';
}
}
$multi_select = '<select id="extra_' . $field_details[1] . '" name="extra_' . $field_details[1] . '">
' . $tag_list . '
</select>';
$form->addElement('label', $field_details[3], $multi_select);
$url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php';
$complete_text = get_lang('StartToType');
//if cache is set to true the jquery will be called 1 time
$jquery_ready_content = <<<EOF
\$("#extra_{$field_details['1']}").fcbkcomplete({
json_url: "{$url}?a=search_tags&field_id={$field_details['0']}",
cache: false,
filter_case: true,
filter_hide: true,
complete_text:"{$complete_text}",
firstselected: true,
//onremove: "testme",
//onselect: "testme",
filter_selected: true,
newel: true
});
EOF;
break;
case ExtraField::FIELD_TYPE_TIMEZONE:
$form->addElement('select', 'extra_' . $field_details[1], $field_details[3], api_get_timezones(), '');
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
示例3: get_addtional_profile_information_of_field_by_user
/**
* This function gets all the information of a certrain ($field_id)
* additional profile field for a specific list of users is more efficent
* than get_addtional_profile_information_of_field() function
* It gets the information of all the users so that it can be displayed
* in the sortable table or in the csv or xls export
*
* @author Julio Montoya <gugli100@gmail.com>
* @param int field id
* @param array list of user ids
* @return array
* @since Nov 2009
* @version 1.8.6.2
*/
public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
{
// Database table definition
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_user_field_values = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$extraField = Database::get_main_table(TABLE_EXTRA_FIELD);
$result_extra_field = UserManager::get_extra_field_information($field_id);
if (!empty($users)) {
if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG) {
foreach ($users as $user_id) {
$user_result = UserManager::get_user_tags($user_id, $field_id);
$tag_list = array();
foreach ($user_result as $item) {
$tag_list[] = $item['tag'];
}
$return[$user_id][] = implode(', ', $tag_list);
}
} else {
$new_user_array = array();
foreach ($users as $user_id) {
$new_user_array[] = "'" . $user_id . "'";
}
$users = implode(',', $new_user_array);
$extraFieldType = EntityExtraField::USER_FIELD_TYPE;
// Selecting only the necessary information NOT ALL the user list
$sql = "SELECT user.user_id, v.value\n \t\t\t FROM {$table_user} user\n \t\t\t INNER JOIN {$table_user_field_values} v\n ON (user.user_id = v.item_id)\n INNER JOIN {$extraField} f\n ON (f.id = v.field_id)\n WHERE\n f.extra_field_type = {$extraFieldType} AND\n v.field_id=" . intval($field_id) . " AND\n user.user_id IN ({$users})";
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
// get option value for field type double select by id
if (!empty($row['value'])) {
if ($result_extra_field['field_type'] == ExtraField::FIELD_TYPE_DOUBLE_SELECT) {
$id_double_select = explode(';', $row['value']);
if (is_array($id_double_select)) {
$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
$row['value'] = $value1 . ';' . $value2;
}
}
}
// get other value from extra field
$return[$row['user_id']][] = $row['value'];
}
}
}
return $return;
}
示例4: set_extra_fields_in_form
//.........这里部分代码省略.........
$values = array('' => get_lang('Select'));
$second_values = array();
if (!empty($options)) {
foreach ($options as $option) {
foreach ($option as $sub_option) {
if ($sub_option['option_value'] == '0') {
$values[$sub_option['id']] = $sub_option['option_display_text'];
} else {
if ($first_id === $sub_option['option_value']) {
$second_values[$sub_option['id']] = $sub_option['option_display_text'];
}
}
}
}
}
$group = array();
$group[] = $form->createElement('select', 'extra_' . $field_details['field_variable'], null, $values, array('id' => $first_select_id));
$group[] = $form->createElement('select', 'extra_' . $field_details['field_variable'] . '_second', null, $second_values, array('id' => 'second_extra_' . $field_details['field_variable']));
$form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], ' ');
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze('extra_' . $field_details['field_variable']);
}
}
break;
case ExtraField::FIELD_TYPE_DIVIDER:
$form->addElement('static', $field_details['field_variable'], '<br /><strong>' . $field_details['field_display_text'] . '</strong>');
break;
case ExtraField::FIELD_TYPE_TAG:
$field_variable = $field_details['field_variable'];
$field_id = $field_details['id'];
if ($this->type == 'user') {
// The magic should be here
$user_tags = UserManager::get_user_tags($user_id, $field_details['id']);
$tag_list = '';
if (is_array($user_tags) && count($user_tags) > 0) {
foreach ($user_tags as $tag) {
$tag_list .= '<option value="' . $tag['tag'] . '" class="selected">' . $tag['tag'] . '</option>';
}
}
$url = api_get_path(WEB_AJAX_PATH) . 'user_manager.ajax.php?';
} else {
$extraFieldValue = new ExtraFieldValue($this->type);
$tags = array();
if (!empty($itemId)) {
$tags = $extraFieldValue->getAllValuesByItemAndField($itemId, $field_id);
}
$tag_list = '';
if (is_array($tags) && count($tags) > 0) {
$extraFieldOption = new ExtraFieldOption($this->type);
foreach ($tags as $tag) {
$option = $extraFieldOption->get($tag['field_value']);
$tag_list .= '<option value="' . $option['id'] . '" class="selected">' . $option['option_display_text'] . '</option>';
}
}
$url = api_get_path(WEB_AJAX_PATH) . 'extra_field.ajax.php';
}
$form->addElement('hidden', 'extra_' . $field_details['field_variable'] . '__persist__', 1);
$multiSelect = '<select id="extra_' . $field_details['field_variable'] . '" name="extra_' . $field_details['field_variable'] . '">
' . $tag_list . '
</select>';
$form->addElement('label', $field_details['field_display_text'], $multiSelect);
$complete_text = get_lang('StartToType');
//if cache is set to true the jquery will be called 1 time
$jquery_ready_content .= <<<EOF
\$("#extra_{$field_variable}").fcbkcomplete({
示例5: set_extra_fields_in_form
//.........这里部分代码省略.........
}
}
}
$group = array();
$group[] = $form->createElement('select', 'extra_' . $field_details['variable'], null, $values, array('id' => $first_select_id));
$group[] = $form->createElement('select', 'extra_' . $field_details['variable'] . '_second', null, $second_values, array('id' => 'second_extra_' . $field_details['variable']));
$form->addGroup($group, 'extra_' . $field_details['variable'], $field_details['display_text'], ' ');
if (!$admin_permissions) {
if ($field_details['visible'] == 0) {
$form->freeze('extra_' . $field_details['variable']);
}
}
break;
case ExtraField::FIELD_TYPE_DIVIDER:
$form->addElement('static', $field_details['variable'], '<br /><strong>' . $field_details['display_text'] . '</strong>');
break;
case ExtraField::FIELD_TYPE_TAG:
$variable = $field_details['variable'];
$field_id = $field_details['id'];
//Added for correctly translate the extra_field
$get_lang_variables = false;
if (in_array($variable, ['tags'])) {
$get_lang_variables = true;
}
if ($get_lang_variables) {
$field_details['display_text'] = get_lang($field_details['display_text']);
}
$tagsSelect = $form->addSelect("extra_{$field_details['variable']}", $field_details['display_text']);
$tagsSelect->setAttribute('class', null);
$tagsSelect->setAttribute('id', "extra_{$field_details['variable']}");
$tagsSelect->setMultiple(true);
if ($this->type == 'user') {
/* //the magic should be here
$user_tags = UserManager::get_user_tags($user_id, $field_details[0]);
$tag_list = '';
if (is_array($user_tags) && count($user_tags) > 0) {
foreach ($user_tags as $tag) {
$tag_list .= '<option value="'.$tag['tag'].'" class="selected">'.$tag['tag'].'</option>';
}
}
$multi_select = '<select id="extra_'.$field_details[1].'" name="extra_'.$field_details[1].'">
'.$tag_list.'
</select>';
$form->addElement('label', $field_details[3], $multi_select);
$url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php';
$complete_text = get_lang('StartToType');
//if cache is set to true the jquery will be called 1 time
$jquery_ready_content = <<<EOF
$("#extra_$field_details[1]").fcbkcomplete({
json_url: "$url?a=search_tags&field_id=$field_details[0]",
cache: false,
filter_case: true,
filter_hide: true,
complete_text:"$complete_text",
firstselected: true,
//onremove: "testme",
//onselect: "testme",
filter_selected: true,
newel: true
});
EOF;
break;*/
// The magic should be here
示例6: get_addtional_profile_information_of_field_by_user
/**
* This function gets all the information of a certrain ($field_id)
* additional profile field for a specific list of users is more efficent
* than get_addtional_profile_information_of_field() function
* It gets the information of all the users so that it can be displayed
* in the sortable table or in the csv or xls export
*
* @author Julio Montoya <gugli100@gmail.com>
* @param int field id
* @param array list of user ids
* @return array
* @since Nov 2009
* @version 1.8.6.2
*/
public static function get_addtional_profile_information_of_field_by_user($field_id, $users)
{
// Database table definition
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$table_user_field_values = Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES);
$result_extra_field = UserManager::get_extra_field_information($field_id);
if (!empty($users)) {
if ($result_extra_field['field_type'] == UserManager::USER_FIELD_TYPE_TAG ) {
foreach($users as $user_id) {
$user_result = UserManager::get_user_tags($user_id, $field_id);
$tag_list = array();
foreach($user_result as $item) {
$tag_list[] = $item['tag'];
}
$return[$user_id][] = implode(', ',$tag_list);
}
} else {
$new_user_array = array();
foreach($users as $user_id) {
$new_user_array[]= "'".$user_id."'";
}
$users = implode(',',$new_user_array);
//selecting only the necessary information NOT ALL the user list
$sql = "SELECT user.user_id, field.field_value FROM $table_user user INNER JOIN $table_user_field_values field
ON (user.user_id = field.user_id)
WHERE field.field_id=".intval($field_id)." AND user.user_id IN ($users)";
$result = Database::query($sql);
while($row = Database::fetch_array($result)) {
// get option value for field type double select by id
if (!empty($row['field_value'])) {
if ($result_extra_field['field_type'] == USER_FIELD_TYPE_DOUBLE_SELECT) {
$id_double_select = explode(';',$row['field_value']);
if (is_array($id_double_select)) {
$value1 = $result_extra_field['options'][$id_double_select[0]]['option_value'];
$value2 = $result_extra_field['options'][$id_double_select[1]]['option_value'];
$row['field_value'] = ($value1.';'.$value2);
}
}
}
// get other value from extra field
$return[$row['user_id']][] = $row['field_value'];
}
}
}
return $return;
}
示例7: explode
.'<dd> '.implode(',',$data).'</dd>';
} else {
if ($field_type == UserManager::USER_FIELD_TYPE_DOUBLE_SELECT) {
$id_options = explode(';',$data);
$value_options = array();
// get option display text from user_field_options table
foreach ($id_options as $id_option) {
$sql = "SELECT option_display_text FROM $t_ufo WHERE id = '$id_option'";
$res_options = Database::query($sql);
$row_options = Database::fetch_row($res_options);
$value_options[] = $row_options[0];
}
$extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt>'
.'<dd>'.implode(' ',$value_options).'</dd>';
} elseif ($field_type == UserManager::USER_FIELD_TYPE_TAG ) {
$user_tags = UserManager::get_user_tags($user_id, $field_id);
$tag_tmp = array();
foreach ($user_tags as $tags) {
$tag_tmp[] = '<a class="label label_tag"'
.' href="'.api_get_path(WEB_PATH).'main/social/search.php?q='.$tags['tag'].'">'
.$tags['tag']
.'</a>';
}
if (is_array($user_tags) && count($user_tags)>0) {
$extra_information_value .= '<dt>'.ucfirst($field_display_text).':</dt>'
.'<dd>'.implode('', $tag_tmp).'</dd>';
}
} elseif ($field_type == UserManager::USER_FIELD_TYPE_SOCIAL_PROFILE) {
$icon_path = UserManager::get_favicon_from_url($data);
$bottom = '0.2';
//quick hack for hi5
示例8: delete_user_tags
/**
* Deletes an user tag
* @param int user id
* @param int field id
*
*/
public static function delete_user_tags($user_id, $field_id)
{
// database table definition
$table_user_tag = Database::get_main_table(TABLE_MAIN_TAG);
$table_user_tag_values = Database::get_main_table(TABLE_MAIN_USER_REL_TAG);
$tags = UserManager::get_user_tags($user_id, $field_id);
//echo '<pre>';var_dump($tags);
if (is_array($tags) && count($tags) > 0) {
foreach ($tags as $key => $tag) {
if ($tag['count'] > '0') {
$sql = "UPDATE {$table_user_tag} SET count = count - 1 WHERE id = {$key} ";
$result = Database::query($sql);
}
$sql = "DELETE FROM {$table_user_tag_values} WHERE user_id = {$user_id} AND tag_id = {$key}";
$result = Database::query($sql);
}
}
}