function flag_lists_get_user_flags in Flag Lists 6
Same name and namespace in other branches
- 7.3 flag_lists.module \flag_lists_get_user_flags()
- 7 flag_lists.module \flag_lists_get_user_flags()
Get a single user's lists, and merge in flag module flags
3 calls to flag_lists_get_user_flags()
- flag_lists_generate_lists_form_submit in ./
flag_lists.admin.inc - Submit handler for flag_lists_generate_lists_form.
- theme_flag_lists_list in ./
flag_lists.module - theme_flag_lists_user_page in ./
flag_lists.module - Theme the output for a user flag administration page.
File
- ./
flag_lists.module, line 535 - The Flag Lists module.
Code
function flag_lists_get_user_flags($content_type = NULL, $account = NULL, $use_flags = FALSE) {
$flags = array();
$lists = array();
if (!isset($account)) {
$account = $GLOBALS['user'];
}
// Get flag lists flags
$sql = "SELECT fl.*, ft.type from {flag_lists_flags} fl\n LEFT JOIN {flags} f on fl.pfid = f.fid\n LEFT JOIN {flag_lists_types} ft on ft.name = f.name\n WHERE fl.uid = %d";
if ($content_type) {
$sql .= " AND ft.type = '%s'";
}
$result = db_query($sql, $account->uid, $content_type);
while ($row = db_fetch_object($result)) {
if (!isset($lists[$row->name])) {
$lists[$row->name] = flag_flag::factory_by_row($row);
$lists[$row->name]->module = 'flag_lists';
}
else {
$lists[$row->name]->types[] = $row->type;
}
}
// Get regular flags.
if ($use_flags) {
$flags = flag_get_flags('node', $content_type, $account);
// Strip out any list templates
foreach ($flags as $key => $flag) {
if (stristr($flag->name, 'fl_template') !== FALSE) {
unset($flags[$key]);
}
}
}
$flags = array_merge($lists, $flags);
return $flags;
}