function fckeditor_sorted_roles in FCKeditor - WYSIWYG HTML editor 5.2
Same name and namespace in other branches
- 6.2 fckeditor.module \fckeditor_sorted_roles()
- 6 fckeditor.module \fckeditor_sorted_roles()
sort roles according to precedence settings. previously sorted roles are followed by latest added roles.
2 calls to fckeditor_sorted_roles()
File
- ./
fckeditor.module, line 1464 - FCKeditor - The text editor for Internet - http://www.fckeditor.net Copyright (C) 2003-2007 Frederico Caldeira Knabben
Code
function fckeditor_sorted_roles($clear = FALSE) {
static $order;
if (isset($order) && $clear !== TRUE) {
return $order;
}
$order = array();
$roles = user_roles(0, 'access fckeditor');
$result = db_query("SELECT settings FROM {fckeditor_settings} WHERE name='FCKeditor Global Profile'");
$data = db_fetch_object($result);
if ($data->settings) {
$settings = unserialize($data->settings);
if (isset($settings['rank']) && !empty($settings['rank'])) {
foreach ($settings['rank'] as $rid) {
if (isset($roles[$rid])) {
$order[$rid] = $roles[$rid];
unset($roles[$rid]);
}
}
}
}
krsort($roles);
//sort the remaining unsorted roles by id, descending.
$order += $roles;
return $order;
}