Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 371

Přidáno uživatelem Michal Kliment před asi 15 roky(ů)

Pridana funkce change_application_password pro zmenu aplikacniho hesla uzivatele. Dodelany pristupove prava, smazany nektere nepotrebne views...

Zobrazit rozdíly:

freenetis/trunk/kohana/application/i18n/cs_CZ/texts.php
'counteraccount' => 'Protiúčet',
'credit' => 'Kredit',
'credit accounts' => 'Kreditní účty',
'current application password is' => 'Současné aplikační heslo je',
'current credit' => 'Současný kredit',
'current credit on this account is' => 'Stav kreditu na tomto účtu je',
'currency' => 'Měna',
......
'honorary member' => 'Čestný člen',
'hours' => 'Hodiny',
'change' => 'Změnit',
'change application password' => 'Změnit aplikační heslo',
'change password' => 'Změnit heslo',
'channel' => 'Kanál',
'id' => 'ID',
freenetis/trunk/kohana/application/controllers/users.php
{
$user = new User_Model($user_id);
// access control
if (!$this->acl_check_edit(get_class($this),'password',$user->member_id)) Controller::error(1);
$this->user_id = $user_id;
......
$form = new Forge(url_lang::base()."users/change_password/".$user_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
// check if logged user has right to edit all passwords
if (!$this->acl_check_edit(get_class($this),'password'))
{
$form->password('oldpassword')->label(url_lang::lang('texts.Old password').':')->rules('required|length[3,50]')->callback(array($this, 'check_password'));
......
}
} // end of change password function
/**
* Function changes application password of user.
* @param $user_id
* @return unknown_type
*/
function change_application_password ($user_id = null)
{
if (isset($user_id))
{
$user = new User_Model($user_id);
// access control
if (!$this->acl_check_edit(get_class($this),'application_password',$user->member_id)) Controller::error(1);
$this->user_id = $user_id;
$form = new Forge(url_lang::base()."users/change_application_password/".$user_id, '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
$form->password('password')->label(url_lang::lang('texts.New password').':')->rules('required|length[3,50]');
$form->password('confirm_password')->label(url_lang::lang('texts.Confirm new password').':')->rules('required|length[3,50]')->matches($form->password);
$form->submit('submit')->value(url_lang::lang('texts.Change'));
if($form->validate())
{
$form_data = $form->as_array();
$user = new User_Model($user_id);
$user->application_password = $form_data['password'];
if ($user->save())
{
$this->session->set_flash('message', url_lang::lang('texts.Password has been successfully changed.'));
}
else
{
$this->session->set_flash('message', url_lang::lang('texts.Error - cant change password.'));
}
url::redirect(url_lang::base().'users/change_application_password/'.$user->id);
}
else
{
$view = new View('template');
$view->header = new View('base/header');
$view->content = new View('users/change_application_password');
$view->footer = new View('base/footer');
$view->header->menu = Controller::render_menu();
$view->header->title = url_lang::lang('texts.Change application password');
$view->content->form = $form->html();
$view->content->user_id = $user_id;
$view->content->member_id = $user->member_id;
$view->content->message = $this->session->get_once('message');
$view->content->password = $user->application_password;
$view->render(TRUE);
}
}
else
{
Controller::warning(1);
}
} // end of change password function
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql_370.php
<?php
$upgrade_sql[370] = array(
"INSERT INTO `axo_map` (`acl_id` ,`section_value` ,`value`) VALUES ('38', 'Users_Controller', 'password');"
);
?>
freenetis/trunk/kohana/application/upgrade_sql/upgrade_sql.php
}
$upgrade_sql[get_SVN_rev()] = array(
"INSERT INTO `axo_map` (`acl_id` ,`section_value` ,`value`) VALUES ('38', 'Users_Controller', 'password');"
"UPDATE `acl` SET `return_value` = '' WHERE `acl`.`id` = 65 LIMIT 1;
INSERT INTO `acl` (`id`, `section_value`, `allow`, `enabled`, `return_value`, `note`, `updated_date`) VALUES ('66', 'user', '1', '1', '', 'Administratori mohou editovat aplikacni heslo vsem, nesmi je ale videt', '1248160179');",
"INSERT INTO `aco_map` (`acl_id`, `section_value`, `value`) VALUES ('66', 'freenetis', 'edit_all');",
"INSERT INTO `aro_groups_map` (`acl_id`, `group_id`) VALUES ('66', '32');",
"INSERT INTO `axo_map` (`acl_id`, `section_value`, `value`) VALUES ('66', 'Users_Controller', 'application_password');"
);
?>
freenetis/trunk/kohana/application/views/members/show.php
if ($this->acl_check_edit('Users_Controller', 'password', $member_data->id))
$links[] = html::anchor(url_lang::base().'users/change_password/'.$member_data->id, url_lang::lang('texts.Change password'));
if ($this->acl_check_edit('Users_Controller', 'application_password', $member_data->id))
$links[] = html::anchor(url_lang::base().'users/change_application_password/'.$member_data->id, url_lang::lang('texts.Change application password'));
if ($this->acl_check_view('Devices_Controller', 'devices', $member_data->member_id))
$links[] = html::anchor(url_lang::base().'devices/show_by_member/'.$member_data->member_id,url_lang::lang('texts.Show his devices'));
freenetis/trunk/kohana/application/views/users/change_application_password.php
<h2><?php echo url_lang::lang('texts.Change application password') ?></h2><br />
<?php echo $message ? '<div class="message">'.$message.'</div>' : '' ?>
<?php
$links = array();
if ($this->acl_check_view('Members_Controller','members', $member_id))
$links[] = html::anchor(url_lang::base().'members/show/'.$member_id, url_lang::lang('texts.Back to the member'));
if ($this->acl_check_view('Members_Controller','members', $member_id))
$links[] = html::anchor(url_lang::base().'users/show/'.$user_id,url_lang::lang('texts.Back to this user'));
echo implode (' | ', $links)
?>
<br /><br />
<?php if ($this->acl_check_view('Users_Controller', 'application_password', $member_id)): ?>
<?php echo url_lang::lang('texts.Current application password is') ?> <b><?php echo $password ?></b>
<br /><br />
<?php endif ?>
<?php echo $form?>
freenetis/trunk/kohana/application/views/users/show.php
$links[] = html::anchor(url_lang::base().'users/edit/'.$user_data->id,url_lang::lang('texts.Edit user'));
if ($this->acl_check_edit(get_class($this),'password',$user_data->member_id))
$links[] = html::anchor(url_lang::base().'users/chngpass/'.$user_data->id,url_lang::lang('texts.Change password'));
$links[] = html::anchor(url_lang::base().'users/change_password/'.$user_data->id,url_lang::lang('texts.Change password'));
if ($this->acl_check_edit(get_class($this), 'application_password', $user_data->member_id))
$links[] = html::anchor(url_lang::base().'users/change_application_password/'.$user_data->member_id, url_lang::lang('texts.Change application password'));
echo implode (' | ', $links)

Také k dispozici: Unified diff