It looks like you're new here. If you want to get involved, click one of these buttons!
function form_fields($values = null) {
$CI = & get_instance();
$CI->load->helper('directory');
$fields = parent::form_fields();
unset($fields['super_admin']);
// save reference it so we can reorder
$pwd_field = $fields['password'];
unset($fields['password']);
$user_id = NULL;
if (!empty($values['id'])) {
$user_id = $values['id'];
}
if (!empty($user_id)) {
$fields['new_password'] = array('label' => lang('form_label_new_password'), 'type' => 'password', 'size' => 20, 'order' => 5);
} else {
$pwd_field['type'] = 'password';
$pwd_field['size'] = 20;
$pwd_field['order'] = 5;
$fields['password'] = $pwd_field;
}
$lang_dirs = list_directories(FUEL_PATH . 'language/', array(), FALSE);
$lang_options = array_combine($lang_dirs, $lang_dirs);
if (count($lang_options) >= 2) {
$fields['language'] = array('type' => 'select', 'options' => $lang_options, 'value' => 'english');
} else {
$fields['language']['type'] = 'hidden';
}
$fields['user_name']['order'] = 1;
$fields['email']['order'] = 2;
$fields['first_name']['order'] = 3;
$fields['last_name']['order'] = 4;
$fields['confirm_password'] = array('label' => lang('form_label_confirm_password'), 'type' => 'password', 'size' => 20, 'order' => 6);
$fields['active']['order'] = 8;
// get permissions
$CI = & get_instance();
$perm_fields = array();
$user = $CI->fuel_auth->user_data();
//Modified by Pedro Simões
if (($user['id'] != $user_id) OR
(!$CI->fuel_auth->is_super_admin() AND $CI->fuel_auth->has_permission('permissions')))
{
$CI->load->module_model(FUEL_FOLDER, 'user_to_permissions_model');
$selected_perms = $CI->user_to_permissions_model->get_permissions($user_id, FALSE);
$fields[lang('permissions_heading')] = array('type' => 'section', 'order' => 10);
$CI->load->module_model(FUEL_FOLDER, 'permissions_model');
if ($CI->fuel_auth->is_super_admin() || $CI->fuel_auth->has_permission('permissions')) {
$perms = $CI->permissions_model->find_all_array(array('active' => 'yes'), 'name asc');
} else {
$editor_permissions = $CI->user_to_permissions_model->get_permissions($user['id'], FALSE);
$perms = Array();
foreach ($editor_permissions as $val) {
$perms = array_merge($perms, $CI->permissions_model->find_all_array(array('id' => $val['perm_id'])));
}
}
$order = 11;
foreach ($perms as $val) {
$perm_field = 'permissions_' . $val['id'];
$perm_fields[$perm_field]['type'] = 'checkbox';
$perm_fields[$perm_field]['value'] = $val['id'];
$perm_fields[$perm_field]['order'] = $order;
$label = lang('perm_' . $val['name']);
if (empty($label)) {
$label = (!empty($val['description'])) ? $val['description'] : $val['name'];
}
$perm_fields[$perm_field]['label'] = $label;
if (!empty($selected_perms[$val['id']]))
$perm_fields[$perm_field]['checked'] = TRUE;
$order++;
}
}
//Modified end
$fields = array_merge($fields, $perm_fields);
unset($fields['reset_key']);
return $fields;
}
Comments
https://github.com/daylightstudio/FUEL-CMS/commit/f6d157691cdd70ff365e857fbc3d96b5e603abda
I already checked out 1.0, and I saw some fields named 'language', do you have plans to support multiple languages?
My solution for multiple languages was to create a languages model, and linking it to my custom modules, on native modules (pages) I created a layout for each language and a navigation group for each language, it's not the best solution, but it's the best that I found without great modifications to the v0.93 platform, and in short time.
Thanks, Pedro Simões.
For displaying on the front end, you can use the Fuel_language class to detect and set the language to be displayed on the front end:
// to set $this->fuel->language->set_selected('spanish'); ... // to detect in order of query string, cookie, user agent $lang = $this->fuel->language->detect(); // or $lang = $this->fuel->language->selected();