Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2241

Přidáno uživatelem Ondřej Fibich před asi 11 roky(ů)

freenetis_1.1.0~beta2

Novinky:
- closes #806: Pozadavek na podporu (detaily v redmine)
- moznost jednohlasneho schvalovani

Upravy:
- closes #805: K podmodulum hlasovani pridat textovy popis, aby uzivatele chapaly jejich vyznam
- spousta vylepseni kodu ve schvalovani
- zakomentovani nedodelanych intervalu v hloasovani

Opravy:
- opraveny tucty chyb v hlasovani (ignorovani hierarchie pri hlasovani, smichane hlasy z vice kategorii, ...)

Zobrazit rozdíly:

freenetis/branches/1.1/application/controllers/approval_templates.php
->link('approval_types/show', 'name');
$items_grid->callback_field('group_id')
->label(__('Group'))
->label('Group')
->callback('Approval_types_Controller::group_field');
$items_grid->callback_field('type')
->callback('Approval_types_Controller::type_field');
/* TODO: #815
$items_grid->callback_field('interval')
->callback('Approval_types_Controller::interval_field');
->callback('Approval_types_Controller::interval_field');*/
$items_grid->callback_field('min_suggest_amount')
->label(__('Minimal suggest amount'))
->label('Minimal suggest amount')
->callback('Approval_types_Controller::min_suggest_amount_field');
$items_grid->callback_field('one_vote')
->label('Single vote is enough?')
->callback('callback::boolean');
$items_grid->callback_field('priority')
->callback('Approval_templates_Controller::priority_field')
->help(help::hint('approval_priority'));
freenetis/branches/1.1/application/controllers/approval_types.php
*/
class Approval_types_Controller extends Controller
{
public static $vote_options = array();
public static $types = array
(
1 => 'Simple majority',
2 => 'Absolute majority',
);
public function __construct()
{
parent::__construct();
// approval are not enabled
if (!Settings::get('approval_enabled'))
Controller::error (ACCESS);
self::$vote_options = array
(
NULL => __('None'),
1 => __('Agree'),
-1 => __('Disagree'),
0 => __('Abstain')
);
self::$types = array
(
1 => __('Simple majority'),
2 => __('Absolute majority')
);
{
self::error(ACCESS);
}
}
/**
......
{
//access control
if (!$this->acl_check_view('approval', 'types'))
Controller::error(ACCESS);
self::error(ACCESS);
// gets new selector
if (is_numeric($this->input->post('record_per_page')))
......
->label('Percent for majority')
->callback('callback::percent');
/* TODO: #815
$grid->order_callback_field('interval')
->label('Interval')
->callback('Approval_types_Controller::interval_field');
$grid->order_callback_field('default_vote')
->label('Default vote')
->callback('Approval_types_Controller::default_vote_field');
->callback('Approval_types_Controller::default_vote_field');*/
$grid->order_callback_field('min_suggest_amount')
->label('Minimal suggest amount')
->callback('Approval_types_Controller::min_suggest_amount_field');
$actions = $grid->grouped_action_field();
if ($this->acl_check_new('approval', 'types'))
{
$actions->add_action('id')
->icon_action('show')
->url('approval_types/show');
}
$grid->datasource($approval_types);
// view
......
{
// access control
if (!$this->acl_check_view('approval', 'types'))
Controller::error('ACCESS');
self::error('ACCESS');
// bad parameter
if (!$approval_type_id || !is_numeric($approval_type_id))
Controller::warning(PARAMETER);
self::warning(PARAMETER);
$approval_type = new Approval_type_Model($approval_type_id);
// record doesn't exist
if (!$approval_type->id)
Controller::error(RECORD);
self::error(RECORD);
$state = $approval_type->get_state($approval_type->id);
......
{
// access control
if (!$this->acl_check_new('approval', 'types'))
Controller::error('ACCESS');
self::error('ACCESS');
$aro_group_model = new Aro_group_Model();
$aro_groups = $aro_group_model->get_traverz_tree();
......
->label('Group')
->options($arr_aro_groups)
->rules('required')
->style('width:500px');
->style('width:500px')
->help('Who votes');
$form->input('min_suggest_amount')
->label('Minimal suggest amount')
->rules('valid_numeric');
->rules('valid_numeric')
->help(help::hint('approval_type_min_suggested_amount'));
$form->checkbox('one_vote')
->label('Single vote is enough?')
->value('1')
->help(help::hint('approval_type_one_vote'));
$form->group('Type');
$form->dropdown('type')
->options(self::$types)
->options(Approval_type_Model::get_type_names())
->rules('required')
->style('width:200px');
......
->value('51')
->callback(array($this, 'valid_majority_percent'));
/* TODO: #815
$form->group('Time constraints');
$form->input('interval')
......
->callback(array($this, 'valid_interval'));
$form->dropdown('default_vote')
->options(self::$vote_options)
->callback(array($this, 'valid_default_vote'));
->options(Vote_Model::get_vote_options(NULL, NULL, TRUE))
->callback(array($this, 'valid_default_vote'));*/
$form->submit('Save');
......
$at->aro_group_id = $form_data['aro_group_id'];
$at->type = $form_data['type'];
$at->majority_percent = $form_data['majority_percent'];
$at->interval = date::from_interval($form_data['interval']);
/* TODO: #815
$at->interval = date::from_interval($form_data['interval']); */
$at->min_suggest_amount = $form_data['min_suggest_amount'];
$at->save();
status::success('Approval type has been successfully added.');
$at->one_vote = ($form_data['one_vote'] == 1);
$this->redirect('approval_types/show/', $at->id);
if ($at->save())
{
status::success('Approval type has been successfully added.');
$this->redirect('approval_types/show/', $at->id);
}
else
{
status::success('Approval type has not been added.');
}
}
// headline
......
{
// access control
if (!$this->acl_check_edit('approval', 'types'))
Controller::error('ACCESS');
self::error('ACCESS');
// bad parameter
if (!$approval_type_id || !is_numeric($approval_type_id))
Controller::warning(PARAMETER);
self::warning(PARAMETER);
$at = new Approval_type_Model($approval_type_id);
// record doesn't exist
if (!$at->id)
Controller::error(RECORD);
self::error(RECORD);
$state = $at->get_state($at->id);
......
$arr_aro_groups[$aro_group->id] = $ret.__(''.$aro_group->name);
}
$interval = date::interval($at->interval);
/* TODO: #815 $interval = date::interval($at->interval); */
// form
$form = new Forge(url_lang::base().'approval_types/edit/'.$at->id);
$form = new Forge('approval_types/edit/'.$at->id);
$form->group('Basic information');
......
->value($at->comment);
$form->dropdown('aro_group_id')
->label(__('Group').':')
->label('Group')
->options($arr_aro_groups)->rules('required')
->selected($at->aro_group_id);
->selected($at->aro_group_id)
->help('Who votes');
$form->input('min_suggest_amount')
->label(__('Minimal suggest amount').':')
->label('Minimal suggest amount')
->rules('valid_numeric')
->value($at->min_suggest_amount);
->value($at->min_suggest_amount)
->help(help::hint('approval_type_min_suggested_amount'));
$form->checkbox('one_vote')
->label('Single vote is enough?')
->value('1')
->help(help::hint('approval_type_one_vote'))
->checked($at->one_vote);
$form->group('Type');
$form->dropdown('type')
->options(self::$types)
->options(Approval_type_Model::get_type_names())
->rules('required')
->selected($at->type);
$form->input('majority_percent')
->label(__('Percent for majority').':')
->label('Percent for majority')
->rules('valid_numeric')
->value($at->majority_percent)
->callback(array($this,'valid_majority_percent'));
/* TODO: #815
$form->group('Time constraints');
$form->input('interval')
......
->callback(array($this,'valid_interval'));
$form->dropdown('default_vote')
->label(__('Default vote').':')
->options(self::$vote_options)
->label('Default vote')
->options(Vote_Model::get_vote_options(NULL, NULL, TRUE))
->selected($at->default_vote)
->callback(array($this,'valid_default_vote'));
->callback(array($this,'valid_default_vote'));*/
$form->submit('submit')
->value(__('Save'));
->value('Save');
// form is validate
if ($form->validate())
......
$at->aro_group_id = $form_data['aro_group_id'];
$at->type = $form_data['type'];
$at->majority_percent = $form_data['majority_percent'];
/* TODO: #815
$at->interval = date::from_interval($form_data['interval']);
if ($form_data['default_vote'] != NULL)
{
$at->default_vote = $form_data['default_vote'];
}
else
{
$at->default_vote = NULL;
}*/
$at->min_suggest_amount = $form_data['min_suggest_amount'];
$at->one_vote = ($form_data['one_vote'] == 1);
$at->save();
status::success('Approval type has been successfully updated.');
url::redirect('approval_types/show/'.$at->id);
if ($at->save())
{
status::success('Approval type has been successfully updated.');
url::redirect('approval_types/show/'.$at->id);
}
else
{
status::success('Approval type has not been updated.');
}
}
// breadcrums
......
{
// access control
if (!$this->acl_check_delete('approval', 'types'))
Controller::error('ACCESS');
self::error('ACCESS');
// bad parameter
if (!$approval_type_id || !is_numeric($approval_type_id))
Controller::warning(PARAMETER);
self::warning(PARAMETER);
$at = new Approval_type_Model($approval_type_id);
// record doesn't exist
if (!$at->id)
Controller::error(RECORD);
self::error(RECORD);
$state = $at->get_state($at->id);
......
url::redirect('approval_types/show/'.$at->id);
}
$at->delete();
status::success('Approval type has been successfully deleted.');
url::redirect('approval_types/show_all');
if ($at->delete())
{
status::success('Approval type has been successfully deleted.');
url::redirect('approval_types/show_all');
}
else
{
status::success('Approval type has not been deleted.');
}
}
/* CALLBACK FUNCTIONS */
......
*/
protected static function type_field($item, $name)
{
echo __(''.self::$types[$item->type]);
echo Approval_type_Model::get_type_name($item->type);
}
/**
......
protected static function interval_field($item, $name)
{
if (!$item->interval)
{
echo __('None');
}
else
{
$interval = date::interval($item->interval);
......
*/
protected static function default_vote_field($item, $name)
{
echo self::$vote_options[$item->default_vote];
echo Vote_Model::get_vote_option_name($item->default_vote, TRUE);
}
/**
......
}
}
/* VALIDATORS */
/**
* Callback function
freenetis/branches/1.1/application/controllers/requests.php
// works are not enabled
if (!Settings::get('approval_enabled'))
Controller::error (ACCESS);
{
self::error(ACCESS);
}
}
/**
......
* @author Michal Kliment
*/
public function show_all(
$limit_results = 100, $order_by = 'date',
$limit_results = 20, $order_by = 'date',
$order_by_direction = 'ASC',
$page_word = null, $page = 1)
{
// access control
if (!$this->acl_check_view(get_class($this), 'request'))
Controller::error(ACCESS);
{
self::error(ACCESS);
}
// gets new selector
if (is_numeric($this->input->post('record_per_page')))
{
$limit_results = (int) $this->input->post('record_per_page');
}
$filter_form = new Filter_form('r');
......
->callback('json/user_fullname')
->label('User');
$filter_form->add('type')
->type('select')
->values(Request_Model::get_types());
$filter_form->add('description');
$filter_form->add('suggest_amount')
......
$request_to_vote = array();
if (array_key_exists(Vote_Model::REQUEST, $items_to_vote))
{
$request_to_vote = $items_to_vote[Vote_Model::REQUEST];
}
}
// create grid
......
'use_paginator' => true,
'use_selector' => true,
'current' => $limit_results,
'selector_increace' => 100,
'selector_min' => 100,
'selector_increace' => 20,
'selector_min' => 20,
'selector_max_multiplier' => 20,
'base_url' => Config::get('lang').'/requests/show_all/'
. $limit_results.'/'.$order_by.'/'.$order_by_direction ,
......
'filter' => $filter_form
));
if ($this->acl_check_new(get_class($this),'request'))
if ($this->acl_check_new(get_class($this), 'request'))
{
$grid->add_new_button(
'requests/add',
__('Add new request'),
array
(
'class' => 'popup_link'
)
);
$grid->add_new_button('requests/add', 'Add new request', array
(
'class' => 'popup_link'
));
}
$grid->order_field('id')
......
->link('users/show', 'uname')
->label('User');
$grid->order_callback_field('type')
->callback('callback::request_type');
$grid->order_callback_field('description')
->label(__('Description'))
->label('Description')
->callback('callback::limited_text');
$grid->order_callback_field('suggest_amount')
->label(__('Suggest amount'))
->label('Suggest amount')
->callback('callback::money');
$grid->order_field('date')
->label(__('Date'));
->label('Date');
$grid->order_callback_field('approval_state')
->label(__('State'))
->label('State')
->help(help::hint('approval_state'))
->callback('callback::vote_state_field');
$grid->order_callback_field('comments_count')
->label(__('comments'))
->label('Comments')
->callback('callback::comments_field')
->class('center');
......
if (!$hide_grid && count($request_to_vote))
{
$grid->order_form_field('vote')
->label(__('Vote'))
->label('Vote')
->type('dropdown')
->options(array
(
......
))
->callback(
'Votes_Controller::vote_form_field',
$request_to_vote,
Vote_Model::REQUEST
$request_to_vote, Vote_Model::REQUEST
);
$grid->order_form_field('comment')
->label(__('Comment'))
->label('Comment')
->type('textarea')
->callback(
'Votes_Controller::comment_form_field',
......
}
if (!$hide_grid)
{
$grid->datasource($requests);
}
// form is submited
if (isset ($_POST) && count ($_POST) > 1)
if (isset($_POST) && count($_POST) > 1)
{
try
{
......
$vote_model->transaction_start();
$request_ids = $_POST['ids'];
$votes = $_POST['vote'];
$comments = $_POST['comment'];
$votes = $_POST['vote'];
$comments = $_POST['comment'];
$approval_template_item_model = new Approval_template_item_Model();
......
$request->suggest_amount
);
$new_vote = $votes[$request->id];
$new_comment = $comments[$request->id];
$new_vote = isset($votes[$request->id]) ? $votes[$request->id] : '';
$new_comment = isset($comments[$request->id]) ? $comments[$request->id] : '';
$vote = $vote_model->where(array
(
......
$vote_model->transaction_commit();
status::success('Votes has been successfully updated.');
url::redirect(url::base(TRUE).url::current(TRUE));
}
catch (Exception $e)
{
Log::add_exception($e);
status::error('Votes has not been updated.', $e);
$vote_model->transaction_rollback();
}
url::redirect(url::base(TRUE).url::current(TRUE));
}
$view = new View('main');
......
public function show_by_user ($user_id = NULL)
{
if (!$user_id || !is_numeric ($user_id))
Controller::warning (PARAMETER);
{
self::warning(PARAMETER);
}
$user = new User_Model($user_id);
if (!$user->id)
Controller::error(RECORD);
{
self::error(RECORD);
}
if (!$this->acl_check_view('Requests_Controller', 'request', $user->member_id))
Controller::error(ACCESS);
{
self::error(ACCESS);
}
$request_model = new Request_Model();
......
$user->id, 'pending'
);
$approval_template_item_model = new Approval_template_item_Model();
$total_pending = array();
$total_pending['suggest_amount'] = 0;
......
}
// create grid
$pending_requests_grid = new Grid(url_lang::base().'requests/rejected', '', array
$pending_requests_grid = new Grid('requests/rejected', '', array
(
'use_paginator' => false,
'use_selector' => false,
......
if ($this->acl_check_new('Requests_Controller','request', $user->member_id))
{
$pending_requests_grid->add_new_button(
url_lang::base().'requests/add/'.$user->id,
__('Add new request'), array('class' => 'popup_link')
'requests/add/'.$user->id, 'Add new request',
array('class' => 'popup_link')
);
}
$pending_requests_grid->field('id')
->label(__('Id'));
->label('ID');
$pending_requests_grid->callback_field('description')
->label(__('Description'))
->label('Description')
->callback('callback::limited_text');
$pending_requests_grid->callback_field('type')
->callback('callback::request_type');
$pending_requests_grid->field('date')
->label(__('Date'));
->label('Date');
$pending_requests_grid->callback_field('suggest_amount')
->label(__('Suggest amount'))
->label('Suggest amount')
->callback('callback::money');
$pending_requests_grid->callback_field('approval_state')
->label(__('State'))
->label('State')
->help(help::hint('approval_state'))
->callback('callback::vote_state_field');
->callback('callback::vote_state_field');
$pending_requests_grid->callback_field('comments_count')
->label(__('comments'))
->label('Comments')
->callback('callback::comments_field')
->class('center');
$actions = $pending_requests_grid->grouped_action_field();
// access control
if ($this->acl_check_view('Requests_Controller','request',$user->member_id))
if ($this->acl_check_view('Requests_Controller','request', $user->member_id))
{
$actions->add_action('id')
->icon_action('show')
......
}
// access control
if ($this->acl_check_edit('Requests_Controller','request',$user->member_id))
if ($this->acl_check_edit('Requests_Controller','request', $user->member_id))
{
$actions->add_conditional_action('id')
->icon_action('edit')
......
}
// access control
if ($this->acl_check_delete('Requests_Controller','request',$user->member_id))
if ($this->acl_check_delete('Requests_Controller','request', $user->member_id))
{
$actions->add_conditional_action('id')
->icon_action('delete')
......
foreach ($approved_requests as $approved_request)
{
$total_approved['suggest_amount'] += $approved_request->rating;
$total_approved['suggest_amount'] += $approved_request->suggest_amount;
}
// create grid
......
));
$approved_requests_grid->field('id')
->label(__('Id'));
->label('ID');
$approved_requests_grid->callback_field('description')
->label(__('Description'))
->label('Description')
->callback('callback::limited_text');
$approved_requests_grid->callback_field('type')
->callback('callback::request_type');
$approved_requests_grid->field('date')
->label(__('Date'));
->label('Date');
$approved_requests_grid->callback_field('suggest_amount')
->label(__('Suggest amount'))
->callback('callback::money');
$approved_requests_grid->callback_field('approval_state')
->label(__('State'))
->label('State')
->help(help::hint('approval_state'))
->callback('callback::vote_state_field');
$approved_requests_grid->callback_field('comments_count')
->label(__('comments'))
->label('Comments')
->callback('callback::comments_field');
$actions = $approved_requests_grid->grouped_action_field();
......
));
$rejected_requests_grid->field('id')
->label(__('Id'));
->label('ID');
$rejected_requests_grid->callback_field('description')
->label(__('Description'))
->label('Description')
->callback('callback::limited_text');
$rejected_requests_grid->callback_field('type')
->callback('callback::request_type');
$rejected_requests_grid->field('date')
->label(__('Date'));
->label('Date');
$rejected_requests_grid->callback_field('suggest_amount')
->label(__('Suggest amount'))
->label('Suggest amount')
->callback('callback::money');
$rejected_requests_grid->callback_field('approval_state')
->label(__('State'))->help(help::hint('approval_state'))
->label('State')->help(help::hint('approval_state'))
->callback('callback::vote_state_field');
$rejected_requests_grid->callback_field('comments_count')
->label(__('comments'))
->label('comments')
->callback('callback::comments_field');
$actions = $rejected_requests_grid->grouped_action_field();
......
$user->member_id
)
)->disable_translation()
->link('users/show/'.$user->id,
$user->name . ' ' . $user->surname .
' (' . $user->login . ')',
->link('users/show/'.$user->id, $user->get_full_name_with_login(),
$this->acl_check_view(
'Users_Controller','users',
'Users_Controller', 'users',
$user->member_id
)
)->enable_translation()
->text('Requests');
$view = new View('main');
$view->title = __('List of requests of user').' '.$user->name.' '.$user->surname;
$view->title = __('List of requests of user').' '.$user->get_full_name();
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('requests/show_by_user');
$view->content->headline = __('List of requests of user').' '.$user->name.' '.$user->surname;
$view->content->headline = __('List of requests of user') . ' '
. $user->get_full_name() . ' ' . help::hint('request_description');
$view->content->user = $user;
$view->content->pending_requests_grid = $pending_requests_grid;
$view->content->approved_requests_grid = $approved_requests_grid;
......
{
// missing or bad parameter
if (!$request_id || !is_numeric($request_id))
Controller::warning (PARAMETER);
{
self::warning(PARAMETER);
}
$request = new Request_Model($request_id);
// record doesn't exist
if (!$request->id)
Controller::error(RECORD);
{
self::error(RECORD);
}
// access control
if (!$this->acl_check_new('Requests_Controller', 'request', $request->user->member_id))
Controller::error(ACCESS);
{
self::error(ACCESS);
}
$approval_template_item_model = new Approval_template_item_Model();
......
foreach ($votes as $vote)
{
if ($this->user_id == $vote->user_id)
{
$user_vote = $vote->vote;
}
$sums[$i] += $vote->vote;
if ($vote->vote == 0)
if ($vote->vote == Request_Model::STATE_NEW)
{
$total_votes[$i]--;
continue;
}
if ($vote->vote == 1)
if ($vote->vote == Request_Model::STATE_OPEN)
{
$agrees[$i]++;
continue;
......
));
$vote_rights = $approval_template_item_model->check_user_vote_rights(
$request, $this->user_id
$request, Vote_Model::REQUEST, $this->user_id,
$request->suggest_amount
);
if ($user_aro_group &&
......
$vote_rights)
{
$vote_grids[$i]->add_new_button(
url_lang::base().'votes/add/'.Vote_Model::REQUEST.'/'.$request->id,
'votes/add/'.Vote_Model::REQUEST.'/'.$request->id,
__('Add vote'), array('class' => 'popup_link')
);
}
$vote_grids[$i]->callback_field('vote')
->label(__('Vote'))
->label('Vote')
->callback('callback::vote');
$vote_grids[$i]->link_field('user_id')
......
$vote_grids[$i]->callback_field('comment');
$vote_grids[$i]->callback_field('time')
->label(__('Time'))
->label('Time')
->callback('callback::datetime');
$actions = $vote_grids[$i]->grouped_action_field();
......
);
$comments_grid->field('text')
->label(__('Text'));
->label('Text');
$comments_grid->link_field('user_id')
->link('users/show', 'user_name')
->label('User');
$comments_grid->field('datetime')
->label(__('Time'));
->label('Time');
$actions = $comments_grid->grouped_action_field();
......
if ($request->state == Request_Model::STATE_NEW &&
$this->acl_check_edit('Requests_Controller', 'request', $request->user->member_id))
{
$links[] = html::anchor('requests/edit/'.$request->id,__('Edit'), array
$links[] = html::anchor('requests/edit/'.$request->id, __('Edit'), array
(
'class' => 'popup_link'
));
......
if ($request->state == Request_Model::STATE_NEW &&
$this->acl_check_delete('Requests_Controller', 'request', $request->user->member_id))
{
$links[] = html::anchor('requests/delete/'.$request->id,__('Delete'),
array
$links[] = html::anchor('requests/delete/'.$request->id, __('Delete'), array
(
'class' => 'delete_link'
));
......
$view->breadcrumbs = $breadcrumbs->html();
$view->title = __('Show request');
$view->content = new View('requests/show');
$view->content->links = implode(" | ", $links);
$view->content->links = implode(' | ', $links);
$view->content->request = $request;
$view->content->state_text = Request_Model::get_state_name($request->state);
$view->content->vote_groups = $vote_groups;
......
$view->content->agrees = $agrees;
if ($this->acl_check_view('Comments_Controller', 'requests', $request->user->member_id))
{
$view->content->comments_grid = $comments_grid;
}
$view->render(TRUE);
}
......
$user = new User_Model($user_id);
if (!$user->id)
Controller::error(RECORD);
{
self::error(RECORD);
}
// access control
if (!$this->acl_check_new(get_class($this), 'request', $user->member_id))
Controller::error(ACCESS);
{
self::error(ACCESS);
}
// association connot create request
if ($user->member_id == Member_Model::ASSOCIATION)
Controller::error(RECORD);
{
self::error(RECORD);
}
$selected = $user->id;
$arr_users[$user->id] = $user->get_full_name() . ' - ' . $user->login;
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
......
{
// access control
if (!$this->acl_check_new(get_class($this), 'request'))
Controller::error(ACCESS);
{
self::error(ACCESS);
}
$selected = NULL;
......
{
$arr_approval_templates = array
(
NULL => '----- '.__('select approval template').' -----'
NULL => '----- '.__('Select approval template').' -----'
) + ORM::factory('approval_template')->select_list();
}
......
$form->group('Basic information');
$form->dropdown('user_id')
->label('User')
->options($arr_users)
->rules('required')
->selected($selected)
->style('width:600px');
if (isset($arr_users))
{
$form->dropdown('user_id')
->label('User')
->options($arr_users)
->rules('required')
->selected($selected)
->style('width:600px');
}
$form->radio('type')
->label('Type')
->options(Request_Model::get_types())
->default(Request_Model::TYPE_SUPPORT)
->help(help::hint('request_type'));
$form->textarea('description')
->rules('required');
......
->label('Approval template')
->rules('required')
->options($arr_approval_templates)
->selected($this->settings->get('default_request_approval_template'))
->selected(Settings::get('default_request_support_approval_template'))
->style('width:200px');
}
......
if ($form->validate())
{
$form_data = $form->as_array();
$request = new Request_Model();
try
{
$request = new Request_Model();
$request->transaction_start();
$request->user_id = $form_data['user_id'];
if (isset($arr_users))
{
$request->user_id = $form_data['user_id'];
}
else
{
$request->user_id = $user->id;
}
$request->type = $form_data['type'];
// test if user can change approval template
if ($this->acl_check_view(get_class($this), 'approval_template', $member_id))
{
$request->approval_template_id = $form_data['approval_template_id'];
}
else
$request->approval_template_id = Settings::get('default_request_approval_template');
{
if ($request->type == Request_Model::TYPE_SUPPORT)
{
$request->approval_template_id =
Settings::get('default_request_support_approval_template');
}
else
{
$request->approval_template_id =
Settings::get('default_request_approval_template');
}
}
$request->description = $form_data['description'];
$request->suggest_amount = $form_data['suggest_amount'];
if ($request->type !== Request_Model::TYPE_SUPPORT)
{
$request->suggest_amount = doubleval($form_data['suggest_amount']);
}
$request->date = date('Y-m-d H:i:s');
$request->state = Request_Model::STATE_NEW;
......
status::success('Request has been successfully added.');
if ($user_id)
$this->redirect ('users/show_request/', $request->id);
{
$this->redirect('users/show_request', $request->id);
}
else
$this->redirect ('requests/show/', $request->id);
{
$this->redirect('requests/show', $request->id);
}
}
catch (Exception $e)
{
......
status::error('Error - Cannot add request', $e);
Log::add_exception($e);
}
$this->redirect('show_all');
}
$title = __('Add new request');
......
{
// bad parameter
if (!$request_id || !is_numeric($request_id))
Controller::warning(PARAMETER);
{
self::warning(PARAMETER);
}
$request = new Request_Model($request_id);
// record doesn't exist
if (!$request->id)
Controller::error(RECORD);
{
self::error(RECORD);
}
// access control
if (!$this->acl_check_edit(get_class($this), 'request', $request->user->member_id))
Controller::error(ACCESS);
{
self::error(ACCESS);
}
// request is locked
if ($request->state != Request_Model::STATE_NEW)
......
|| Path::instance()->uri(TRUE)->previous(1, 1) == 'show_by_user');
$user_model = new User_Model();
$arr_users = null;
// check if user has access rights to edit request of all users
if ($this->acl_check_edit(get_class($this), 'request'))
{
// gets all user's names
$users = $user_model->get_his_users_names($request->user_id);
$arr_users = arr::from_objects(
$user_model->get_his_users_names($request->user_id), 'username'
);
}
else
{
$users = $user_model->get_his_username($request->user_id);
}
// transforms array of objects to classic array
$arr_users = arr::from_objects($users, 'username');
if ($this->acl_check_view(get_class($this), 'approval_template'))
{
$arr_approval_templates = array
......
$this->form->group('Basic information');
$this->form->dropdown('user_id')
->label('User')
->options($arr_users)
->rules('required')
->selected($request->user_id)
->style('width:600px');
if (isset($arr_users))
{
$this->form->dropdown('user_id')
->label('User')
->options($arr_users)
->rules('required')
->selected($request->user_id)
->style('width:600px');
}
$this->form->radio('type')
->label('Type')
->options(Request_Model::get_types())
->default($request->type)
->help(help::hint('request_type'));
$this->form->textarea('description')
->rules('required|length[0,65535]')
->value($request->description)
......
{
$request->transaction_start();
$request->user_id = $form_data['user_id'];
$request->description = $form_data['description'];
$request->date = date('Y-m-d', $form_data['date']);
$request->suggest_amount = $form_data['suggest_amount'];
$request->type = $form_data['type'];
if (isset($arr_users))
{
$request->user_id = $form_data['user_id'];
}
$request->description = $form_data['description'];
$request->date = date('Y-m-d', $form_data['date']);
if ($request->type !== Request_Model::TYPE_SUPPORT)
{
$request->suggest_amount = doubleval($form_data['suggest_amount']);
}
else
{
$request->suggest_amount = NULL;
}
$old_approval_template_id = $request->approval_template_id;
if ($this->acl_check_view(get_class($this), 'approval_template', $request->user->member_id))
{
$request->approval_template_id = $form_data['approval_template_id'];
}
else
$request->approval_template_id = $this->settings->get('default_request_approval_template');
{
if ($request->type == Request_Model::TYPE_SUPPORT)
{
$request->approval_template_id =
Settings::get('default_request_support_approval_template');
}
else
{
$request->approval_template_id =
Settings::get('default_request_approval_template');
}
}
$request->save_throwable();
......
}
if ($is_from_user)
{
$this->redirect('users/show_request/', $request->id);
}
else
{
$this->redirect('requests/show/', $request->id);
}
}
else
{
......
{
// bad parameter
if (!$request_id || !is_numeric($request_id))
Controller::warning(PARAMETER);
{
self::warning(PARAMETER);
}
$request = new Request_Model($request_id);
// record doesn't exist
if (!$request->id)
Controller::error(RECORD);
{
self::error(RECORD);
}
// access control
if (!$this->acl_check_delete('Requests_Controller', 'request', $request->user->member_id))
Controller::error(ACCESS);
{
self::error(ACCESS);
}
// request is locked
if ($request->state > 0)
......
$request->delete_throwable();
// set up state of approval template
Approval_template_Model::update_state(
$approval_template_id
);
Approval_template_Model::update_state($approval_template_id);
$request->transaction_commit();
status::success('Request has been successfully deleted');
......
}
if ($is_from_user)
url::redirect(url_lang::base().'requests/show_by_user/'.$request_user_id);
{
url::redirect('requests/show_by_user/'.$request_user_id);
}
else
url::redirect(url_lang::base().'requests/show_all');
{
url::redirect('requests/show_all');
}
}
}
freenetis/branches/1.1/application/controllers/settings.php
public static function isModuleEnabled($module)
{
if (isset(self::$modules[$module]['name']))
{
return Settings::get(self::$modules[$module]['name']);
}
else
{
throw new Exception('Unknown module: '.$module);
}
}
/**
......
private static function disableModule($module)
{
if (isset(self::$modules[$module]['name']))
{
return Settings::set(self::$modules[$module]['name'], 0);
}
else
{
throw new Exception('Unknown module: '.$module);
}
}
/**
......
$this->form->group('Request');
$this->form->dropdown('default_request_approval_template')
->label('Default approval template')
->label('Default approval template for "proposals to association"')
->options($arr_approval_templates)
->selected(Settings::get('default_request_approval_template'))
->rules('required');
$this->form->dropdown('default_request_support_approval_template')
->label('Default approval template for "support requests"')
->options($arr_approval_templates)
->selected(Settings::get('default_request_support_approval_template'))
->rules('required');
$this->form->submit('Save');
if ($this->form->validate())
freenetis/branches/1.1/application/controllers/votes.php
);
$vote_rights = $approval_template_item_model->check_user_vote_rights(
$object, $this->user_id
$object, $type, $this->user_id, $object->suggest_amount
);
// access control
......
$approval_template_item = new Approval_template_item_Model();
$aro_group = $approval_template_item->get_aro_group_by_approval_template_id_and_user_id(
$object->approval_template_id,
$this->user_id,
$object->approval_template_id, $this->user_id,
$object->suggest_amount
);
$vote_rights = $approval_template_item->check_user_vote_rights(
$object, $this->user_id
$object, $vote->type, $this->user_id, $object->suggest_amount
);
// access control
......
$approval_template_item = new Approval_template_item_Model();
$aro_group = $approval_template_item->get_aro_group_by_approval_template_id_and_user_id(
$object->approval_template_id,
$this->user_id,
$object->approval_template_id, $this->user_id,
$object->suggest_amount
);
$vote_rights = $approval_template_item->check_user_vote_rights(
$object, $this->user_id
$object, $vote->type, $this->user_id, $object->suggest_amount
);
// access control
freenetis/branches/1.1/application/controllers/work_reports.php
* @param integer $page
*/
public function show_all(
$limit_results = 100, $order_by = 'id', $order_by_direction = 'ASC',
$limit_results = 20, $order_by = 'id', $order_by_direction = 'ASC',
$page_word = null, $page = 1)
{
// acccess control
......
'use_paginator' => true,
'use_selector' => true,
'current' => $limit_results,
'selector_increace' => 100,
'selector_min' => 100,
'selector_increace' => 20,
'selector_min' => 20,
'selector_max_multiplier' => 20,
'base_url' => Config::get('lang').'/work_reports/show_all/'
. $limit_results.'/'.$order_by.'/'.$order_by_direction,
......
$view->title = $headline;
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('work_reports/show_by_user');
$view->content->headline = $headline;
$view->content->headline = $headline . ' ' . help::hint('work_report_description');
$view->content->user = $user;
$view->content->show_concepts = ($user->id == $this->user_id);
$view->content->grid_concepts = $grid_concepts;
freenetis/branches/1.1/application/controllers/works.php
* @param number $page
*/
public function show_all(
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff