Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2148

Přidáno uživatelem David Raška před asi 11 roky(ů)

Upravy:
- ref #563: dokumentace AXO (dalsi cast controlleru zacinajicich M)

Zobrazit rozdíly:

freenetis/branches/1.1/application/vendors/axo_doc/axo_doc.xml
<method name="send"></method>
<method name="send_email_to_developers"></method>
<method name="show">
<axo usage_type="accesss" section="Email_queues_Controller" value="email_queue" action="view" own="false"></axo>
<axo usage_type="access" section="Email_queues_Controller" value="email_queue" action="view" own="false"></axo>
</method>
</object>
<object name="email_queues" type="controller"
comments-en="E-mail queues - administrate sended and unsended e-mail"
comments-cs="Fronta e-mailů - spravuje odeslané a neodeslané e-maily">
comment-en="E-mail queues - administrate sended and unsended e-mail"
comment-cs="Fronta e-mailů - spravuje odeslané a neodeslané e-maily">
<method name="__construct"></method>
<method name="index"></method>
<method name="show_all_unsent">
......
<axo usage_type="access" section="Members_Controller" value="members" action="delete" own="false"></axo>
</method>
<method name="show">
<!-- show(
$member_id = NULL, $limit_results = 20, $order_by = 'ip_address',
$order_by_direction = 'ASC', $page_word = null, $page = 1)
{
// parameter is wrong
if (!$member_id || !is_numeric($member_id))
Controller::warning(PARAMETER);
$this->member = $member = new Member_Model($member_id);
// member doesn't exist
if (!$member->id)
Controller::error(RECORD);
$membership_transfer_model = new Membership_transfer_Model();
// test if member is association itself
$is_association = ($member->id == Member_Model::ASSOCIATION);
// test if member is former member
$is_former = ($member->type == Member_Model::TYPE_FORMER);
// test if member is applicant
$is_applicant = ($member->type == Member_Model::TYPE_APPLICANT);
// member is former member
if ($is_former)
{
// find possible membership transfer from member
$membership_transfer_from_member = $membership_transfer_model
->get_transfer_from_member($member->id);
}
// find possible membership transfer to member
$membership_transfer_to_member = $membership_transfer_model
->get_transfer_to_member($member->id);
// access control
if (!$this->acl_check_view(get_class($this), 'members', $member->id))
Controller::error(ACCESS);
// finds main user of member
$user = ORM::factory('user')->where(array
(
'member_id' => $member->id,
'type' => User_Model::MAIN_USER
))->find();
// building of user's name
$user_name = $user->name;
if ($user->middle_name != '')
{
$user_name .= ' '.$user->middle_name;
}
$user_name .= ' '.$user->surname;
if ($user->pre_title != '')
{
$user_name = $user->pre_title . ' ' .$user_name;
}
if ($user->post_title != '')
{
$user_name .= ' '.$user->post_title;
}
// translates member's type
$type = ORM::factory('enum_type')->get_value($member->type);
// has member active membership interrupt?
$active_interrupt = ORM::factory('membership_interrupt')
->has_member_interrupt_in_date($member->id, date('Y-m-d'));
$title = ($active_interrupt) ? $type . ' '.$member->name
. ' ('. __('I') .')' : $type . ' '.$member->name;
if ($is_applicant &&
condition::is_applicant_registration($member) &&
$this->acl_check_edit(get_class($this), 'members', $member->id))
{
$title .= ' <small style="font-size: 60%; font-weight: normal">(' . html::anchor(
'members/approve_applicant/' . $member_id,
__('Approve application for membership'),
array('class' => 'popup_link')
) . ')</small>';
}
// finds credit account of member
if (Settings::get('finance_enabled') && !$is_association)
{
$account = ORM::factory('account')->where(array
(
'member_id' => $member_id,
'account_attribute_id' => Account_attribute_Model::CREDIT
))->find();
if (!$is_former)
{
// find current regular member fee of member
$fee = ORM::factory('fee')->get_regular_member_fee_by_member_date(
$member->id,
date('Y-m-d')
);
}
$entrance_fee_paid = ORM::factory('transfer')->count_entrance_fee_transfers_of_account($account->id);
$entrance_fee_left = $member->entrance_fee - $entrance_fee_paid;
}
// gps coordinates
$gps = '';
// finds address of member
if ($member->address_point_id &&
$member->address_point->id)
{
$address = '';
if ($member->address_point->street_id &&
$member->address_point->street->id)
{
$address = $member->address_point->street->street;
}
if ($member->address_point->street_number)
{
$address .= ' '.$member->address_point->street_number;
}
if ($member->address_point->town_id &&
$member->address_point->town->id)
{
$town = $member->address_point->town->town;
if ($member->address_point->town->quarter)
{
$town .= '-'.$member->address_point->town->quarter;
}
$town .= ', '.$member->address_point->town->zip_code;
}
if ($member->address_point->country_id &&
$member->address_point->country->id)
{
$country = $member->address_point->country->country_name;
}
// gps coordinates
if (!empty($member->address_point->gps))
{
$gps_result = ORM::factory('address_point')->get_gps_coordinates(
$member->address_point->id
);
if (! empty($gps_result))
{
$gps = gps::degrees($gps_result->gpsx, $gps_result->gpsy, true);
}
}
}
// query for GMaps
if (empty($gps))
{
$map_query = $address . ', ' .$town;
}
else
{
$map_query = $gps_result->gpsx . ', ' . $gps_result->gpsy;
}
// gps domicile coordinates
$domicile_gps = '';
if ($member->members_domicile->address_point->id)
{
$domicile_address = '';
if ($member->members_domicile->address_point->street_id &&
$member->members_domicile->address_point->street->id)
{
$domicile_address = $member->members_domicile->address_point->street->street;
}
if ($member->members_domicile->address_point->street_number)
{
$domicile_address .= ' '.$member->members_domicile->address_point->street_number;
}
if ($member->members_domicile->address_point->town_id &&
$member->members_domicile->address_point->town->id)
{
$domicile_town = $member->members_domicile->address_point->town->town;
if ($member->members_domicile->address_point->town->quarter)
{
$domicile_town .= '-'.$member->members_domicile->address_point->town->quarter;
}
$domicile_town .= ', '.$member->members_domicile->address_point->town->zip_code;
}
if ($member->members_domicile->address_point->country_id &&
$member->members_domicile->address_point->country->id)
{
$domicile_country = $member->members_domicile->address_point->country->country_name;
}
// gps coordinates
if (!empty($member->members_domicile->address_point->gps))
{
$gps_result = ORM::factory('address_point')->get_gps_coordinates(
$member->members_domicile->address_point->id
);
if (! empty($gps_result))
{
$domicile_gps = gps::degrees($gps_result->gpsx, $gps_result->gpsy, true);
}
}
// query for GMaps domicile
if (empty($domicile_gps))
{
$map_d_query = $domicile_address . ', ' .$domicile_town;
}
else
{
$map_d_query = $gps_result->gpsx . ', ' . $gps_result->gpsy;
}
}
/******** VoIP ***********/
if (Settings::get('voip_enabled'))
{
// VoIP SIP model
$voip_sip = new Voip_sip_Model();
// Gets sips
$voip = $voip_sip->get_all_record_by_member_limited($member->id);
// Has driver?
$has_driver = Billing::instance()->has_driver();
// Account
$b_account = null;
// Check account only if have SIP
if ($voip->count())
{
$b_account = Billing::instance()->get_account($member->id);
}
$voip_grid = new Grid('members', null, array
(
'separator' => '<br /><br />',
'use_paginator' => false,
'use_selector' => false
));
$voip_grid->field('id')
->label('ID');
$voip_grid->field('callerid')
->label(__('Number'));
$actions = $voip_grid->grouped_action_field();
if ($this->acl_check_view('VoIP_Controller', 'voip', $member->id))
{
$actions->add_action('user_id')
->icon_action('phone')
->url('voip/show')
->label('Show VoIP account');
}
if ($this->acl_check_view('Users_Controller', 'users', $member->id))
{
$actions->add_action('user_id')
->icon_action('member')
->url('users/show')
->label('Show user who own this VoIP account');
}
$voip_grid->datasource($voip);
if ($has_driver && $b_account)
{
if ($this->acl_check_view('VoIP_Controller', 'voip', $member->id))
{
$voip_grid->add_new_button(
'voip_calls/show_by_member/'.$member->id,
__('List of all calls')
);
}
if (Settings::get('finance_enabled') &&
$this->acl_check_new('Accounts_Controller', 'transfers', $member->id) &&
!$is_association)
{
$voip_grid->add_new_button(
'transfers/add_voip/'.$account->id,
__('Recharge VoIP credit')
);
}
}
}
// finds date of expiration of member fee
$expiration_date = '';
if (Settings::get('finance_enabled') &&
isset($account) && !$is_applicant && !$is_former)
{
$expiration_date = self::get_expiration_date($account);
}
// finds total traffic of member
if (Settings::get('ulogd_enabled'))
{
$mtm = new Members_traffic_Model();
$total_traffic = $mtm->get_total_member_traffic($member->id);
$today_traffic = $mtm->get_today_member_traffic($member->id);
$month_traffic = $mtm->get_month_member_traffic($member->id);
}
// finds all contacts of main user
$contact_model = new Contact_Model();
$enum_type_model = new Enum_type_Model();
// contacts of main user of member
$contacts = $contact_model->find_all_users_contacts($user->id);
if (Settings::get('finance_enabled'))
{
$variable_symbol_model = new Variable_Symbol_Model();
$variable_symbols = 0;
if ($member_id != 1)
{
$variable_symbols = $variable_symbol_model->find_account_variable_symbols($account->id);
}
}
$contact_types = array();
foreach($contacts as $i => $contact)
$contact_types[$i] = $enum_type_model->get_value($contact->type);
// finds all users of member
$users = ORM::factory('user')->where('member_id', $member->id)->find_all();
// grid with lis of users
$users_grid = new Grid(url_lang::base().'members', null, array
(
'separator' => '<br /><br />',
'use_paginator' => false,
'use_selector' => false,
));
if ($this->acl_check_new('Users_Controller','users') ||
($this->session->get('user_type') == User_Model::MAIN_USER &&
$this->acl_check_new('Users_Controller', 'users', $member->id)))
{
$users_grid->add_new_button('users/add/'.$member->id, __('Add new user'));
}
$users_grid->field('id')
->label('ID');
$users_grid->field('name');
$users_grid->field('surname');
$users_grid->field('login')
->label('Username');
$actions = $users_grid->grouped_action_field();
if ($this->acl_check_view('Users_Controller', 'users', $member_id))
{
$actions->add_action('id')
->icon_action('show')
->url('users/show');
}
if ($this->acl_check_edit('Users_Controller', 'users') ||
($this->session->get('user_type') == User_Model::MAIN_USER &&
$this->acl_check_edit('Users_Controller','users',$member_id)))
{
$actions->add_action('id')
->icon_action('edit')
->url('users/edit');
}
if ($this->acl_check_delete('Users_Controller', 'users', $member_id))
{
$actions->add_action('id')
->icon_action('delete')
->url('users/delete')
->class('delete_link');
}
if ($this->acl_check_view('Devices_Controller', 'devices', $member_id))
{
$actions->add_action('id')
->icon_action('devices')
->url('devices/show_by_user')
->label('Show devices');
}
if (Settings::get('works_enabled') &&
$this->acl_check_edit('Works_Controller', 'work', $member_id))
{
$actions->add_action('id')
->icon_action('work')
->url('works/show_by_user')
->label('Show works');
}
$users_grid->datasource($users);
// membership interrupts
if (Settings::get('membership_interrupt_enabled'))
{
$membership_interrupts = ORM::factory('membership_interrupt')->get_all_by_member($member_id);
$membership_interrupts_grid = new Grid('members', null, array
(
'separator' => '<br /><br />',
'use_paginator' => false,
'use_selector' => false,
));
if ($this->acl_check_new(get_class($this), 'membership_interrupts', $member_id))
{
$membership_interrupts_grid->add_new_button(
'membership_interrupts/add/'.$member_id,
__('Add new interrupt of membership'),
array
(
'title' => __('Add new interrupt of membership'),
'class' => 'popup_link'
)
);
}
$membership_interrupts_grid->field('id')
->label('ID');
$membership_interrupts_grid->field('from')
->label(__('Date from'));
$membership_interrupts_grid->field('to')
->label(__('Date to'));
$membership_interrupts_grid->field('comment');
$actions = $membership_interrupts_grid->grouped_action_field();
if ($this->acl_check_edit(get_class($this), 'membership_interrupts', $member_id))
{
$actions->add_action('id')
->icon_action('edit')
->url('membership_interrupts/edit')
->class('popup_link');
}
if ($this->acl_check_delete(get_class($this), 'membership_interrupts'))
{
$actions->add_action('id')
->icon_action('delete')
->url('membership_interrupts/delete')
->class('delete_link');
}
$membership_interrupts_grid->datasource($membership_interrupts);
}
if (Settings::get('redirection_enabled'))
{
// activated redirections of member, including short statistic of whitelisted IP addresses
$ip_model = new Ip_address_Model();
$total_ips = $ip_model->count_ips_and_redirections_of_member($member_id);
// get new selector
if (is_numeric($this->input->post('record_per_page')))
$limit_results = (int) $this->input->post('record_per_page');
// limit check
if (($sql_offset = ($page - 1) * $limit_results) > $total_ips)
$sql_offset = 0;
$ip_addresses = $ip_model->get_ips_and_redirections_of_member(
$member_id, $sql_offset, $limit_results,
$order_by, $order_by_direction
);
$redir_grid = new Grid('members', null, array
(
'selector_increace' => 20,
'selector_min' => 20,
'selector_max_multiplier' => 10,
'current' => $limit_results,
'base_url' => Config::get('lang'). '/members/show/' . $member_id . '/'
. $limit_results.'/'.$order_by.'/'.$order_by_direction,
'uri_segment' => 'page',
'total_items' => $total_ips,
'items_per_page' => $limit_results,
'style' => 'classic',
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results,
'variables' => $member_id . '/',
'url_array_ofset' => 1,
'query_string' => $this->input->get(),
));
if ($this->acl_check_new('Redirect_Controller', 'redirect') &&
$total_ips < 1000) // limited count
{
$redir_grid->add_new_button(
'redirect/activate_to_member/'.$member_id,
__('Activate redirection to member'), array(),
help::hint('activate_redirection_to_member')
);
}
$redir_grid->order_callback_field('ip_address')
->label(__('IP address'))
->callback('callback::ip_address_field');
$redir_grid->order_callback_field('whitelisted')
->label(__('Whitelist').'&nbsp;'.help::hint('whitelist'))
->callback('callback::whitelisted_field');
$redir_grid->order_callback_field('message')
->label(__('Activated redirection').'&nbsp;'.help::hint('activated_redirection'))
->callback('callback::message_field');
if ($this->acl_check_view('Messages_Controller', 'member'))
{
$redir_grid->callback_field('ip_address')
->label(__('Preview').'&nbsp;'.help::hint('redirection_preview'))
->callback('callback::redirection_preview_field');
}
if ($this->acl_check_delete('Redirect_Controller', 'redirect'))
{
$redir_grid->callback_field('redirection')
->label(__('Canceling of message for redirection'))
->callback('callback::cancel_redirection_of_member');
}
$redir_grid->datasource($ip_addresses);
}
/********** BUILDING OF LINKS *************/
$member_links = array();
$user_links = array();
// member edit link
if (!$is_former &&
$this->acl_check_edit(get_class($this), 'members', $member->id))
{
$member_links[] = html::anchor(
'members/edit/'.$member->id,
__('Edit'),
array
(
'title' => __('Edit'),
'class' => 'popup_link'
)
);
}
if (Settings::get('finance_enabled'))
{
// members's transfers link
if (!$is_association &&
$this->acl_check_view('Accounts_Controller', 'transfers', $member->id))
{
$member_links[] = html::anchor(
'transfers/show_by_account/'.$account->id, __('Show transfers')
);
}
// member's tariffs link
if ($this->acl_check_view(get_class($this), 'fees', $member->id))
{
$member_links[] = html::anchor(
'members_fees/show_by_member/'.$member->id, __('Show tariffs')
);
}
}
if (!$is_association)
{
if (!$is_former)
{
// allowed subnets are enabled
if (Settings::get('allowed_subnets_enabled') &&
$this->acl_check_view('Allowed_subnets_Controller', 'allowed_subnet', $member->id))
{
$member_links[] = html::anchor(
'allowed_subnets/show_by_member/'.$member->id,
__('Allowed subnets'),
array
(
'title' => __('Show allowed subnets'),
'class' => 'popup_link'
)
);
}
}
if (module::e('notification'))
{
if ($this->acl_check_new('Notifications_Controller', 'member'))
{
$member_links[] = html::anchor(
'notifications/member/'.$member->id, __('Notifications'),
array('title' => __('Set notification to member'))
);
}
if ($this->acl_check_view('Members_whitelists_Controller', 'whitelist'))
{
$member_links[] = html::anchor(
'members_whitelists/show_by_member/'.$member->id, __('Whitelists')
);
}
}
// export contacts
if ($this->acl_check_view('Members_Controller', 'members'))
{
$member_links[] = html::anchor(
'export/vcard/' . $member_id . server::query_string(),
__('Export contacts'),
array
(
'title' => __('Export contacts'),
'class' => 'popup_link'
)
);
}
$member_links[] = html::anchor(
'members/registration_export/'.$member->id,
__('Export of registration'),
array
(
'title' => __('Export of registration'),
'class' => 'popup_link'
)
);
if (!$is_applicant)
{
if (!$is_former)
{
// end membership link
if ($this->acl_check_edit(get_class($this), 'members'))
{
$member_links[] = html::anchor(
'members/end_membership/'.$member->id,
__('End membership'),
array
(
'title' => __('End membership'),
'class' => 'popup_link'
)
);
}
}
else
{
// restore membership link
if ($this->acl_check_edit(get_class($this), 'members'))
{
$m = __('Do you want to restore membership of this member');
$member_links[] = html::anchor(
'members/restore_membership/'.$member->id,
__('Restore membership'), array
(
'onclick' => 'return window.confirm(\''.$m.'?\')'
)
);
}
// only former member without debt can transfer his membership
if ($member->get_balance() >= 0)
{
// add new membership transfer
if (!$membership_transfer_from_member)
{
if ($this->acl_check_new('Membership_transfers_Controller', 'membership_transfer', $member->id))
{
$member_links[] = html::anchor(
'membership_transfers/add/'.$member_id,
__('Add membership transfer'),
array('class' => 'popup_link')
);
}
}
// edit membership transfer
else
{
if ($this->acl_check_edit('Membership_transfers_Controller', 'membership_transfer', $member->id))
{
$member_links[] = html::anchor(
'membership_transfers/edit/'.$membership_transfer_from_member->id,
__('Edit membership transfer'),
array('class' => 'popup_link')
);
}
if ($this->acl_check_delete('Membership_transfers_Controller', 'membership_transfer', $member->id))
{
$member_links[] = html::anchor(
'membership_transfers/delete/'.$membership_transfer_from_member->id,
__('Delete membership transfer'),
array('class' => 'delete_link')
);
}
}
}
}
}
}
// user show link
if ($this->acl_check_view('Users_Controller', 'users', $member->id))
{
$user_links[] = html::anchor('users/show/'.$user->id, __('Show'));
}
// user edit link
if (!$is_former &&
$this->acl_check_edit('Users_Controller','users', $member->id))
{
$user_links[] = html::anchor(
'users/edit/'.$user->id, __('Edit'),
array
(
'title' => __('Edit'),
'class' => 'popup_link'
)
);
}
if ($this->user_id == $user->id)
{
$user_links[] = html::anchor(
'user_favourite_pages/show_all', __('Favourites')
);
}
// user's devices link
if (Settings::get('networks_enabled') &&
$this->acl_check_view('Devices_Controller', 'devices', $member->id))
{
$user_links[] = html::anchor(
'devices/show_by_user/'.$user->id,
__('Show devices')
);
}
// connection requests
if (Settings::get('connection_request_enable') &&
$this->acl_check_view('Connection_Requests_Controller', 'request', $member->id))
{
$user_links[] = html::anchor(
'connection_requests/show_by_member/'.$member->id,
__('Show connection requests')
);
}
if (!$is_association && module::e('approval'))
{
// user's works link
if (Settings::get('works_enabled') &&
$this->acl_check_view('Works_Controller', 'work', $member->id))
{
$user_links[] = html::anchor(
'works/show_by_user/'.$user->id,
__('Show works')
);
}
// user's work reports link
if (Settings::get('works_enabled') &&
$this->acl_check_view('Works_Controller', 'work', $member->id))
{
$user_links[] = html::anchor(
'work_reports/show_by_user/'.$user->id,
__('Show work reports')
);
}
// user's requests link
if ($this->acl_check_view('Requests_Controller', 'request', $member->id))
{
$user_links[] = html::anchor(
'requests/show_by_user/'.$user->id,
__('Show requests')
);
}
}
// member is not former
if (!$is_former)
{
// change password link
if ($this->acl_check_edit('Users_Controller', 'password', $member->id) &&
!($user->is_user_in_aro_group($user->id, Aro_group_Model::ADMINS) &&
$user->id != $this->user_id
))
{
$user_links[] = html::anchor(
'users/change_password/'.$user->id, __('Change password'),
array
(
'title' => __('Change password'),
'class' => 'popup_link'
)
);
}
// change application password link
if ($this->acl_check_edit('Users_Controller', 'application_password', $member->id))
{
$user_links[] = html::anchor(
'users/change_application_password/'.$user->id,
__('Change application password'),
array
(
'title' => __('Change application password'),
'class' => 'popup_link'
)
);
}
}
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('members/show_all', 'Members',
$this->acl_check_view(get_class($this),'members'))
->disable_translation()
->text("ID $member->id - $member->name");
// view
$view = new View('main');
$view->title = $title;
$view->breadcrumbs = $breadcrumbs->html();
$view->action_logs = action_logs::object_last_modif($member, $member_id);
$view->content = new View('members/show');
$view->content->title = $title;
$view->content->member = $member;
$view->content->user = $user;
$view->content->user_name = $user_name;
$view->content->users_grid = $users_grid;
$view->content->redir_grid = Settings::get('redirection_enabled') ? $redir_grid : '';
$view->content->voip_grid = (Settings::get('voip_enabled')) ? $voip_grid : '';
$view->content->membership_interrupts_grid = Settings::get('membership_interrupt_enabled') ?
$membership_interrupts_grid : '';
$view->content->contacts = $contacts;
$view->content->contact_types = $contact_types;
$view->content->variable_symbols = (isset($variable_symbols)) ? $variable_symbols : NULL;
$view->content->expiration_date = $expiration_date;
$view->content->entrance_fee_paid = (isset($entrance_fee_paid)) ? $entrance_fee_paid : NULL;
$view->content->entrance_fee_left = (isset($entrance_fee_left)) ? $entrance_fee_left : NULL;
$view->content->account = (isset($account)) ? $account : NULL;
$view->content->fee = (isset($fee)) ? $fee : NULL;
$view->content->comments = (isset($account)) ? $account->get_comments() : '';
$view->content->address = (isset($address)) ? $address : '';
$view->content->map_query = $map_query;
$view->content->map_domicile_query = isset($map_d_query) ? $map_d_query : '';
$view->content->lang = Config::get('lang');
$view->content->gps = $gps;
$view->content->domicile_address = (isset($domicile_address)) ? $domicile_address : '';
$view->content->domicile_town = (isset($domicile_town)) ? $domicile_town : '';
$view->content->domicile_country = (isset($domicile_country)) ? $domicile_country : '';
$view->content->domicile_gps = $domicile_gps;
$view->content->town = (isset($town)) ? $town : '';
$view->content->country = (isset($country)) ? $country : '';
$view->content->billing_has_driver = (Settings::get('voip_enabled')) ? $has_driver : FALSE;
$view->content->billing_account = (Settings::get('voip_enabled')) ? $b_account : NULL;
$view->content->count_voip = (Settings::get('voip_enabled')) ? count($voip) : 0;
$view->content->total_traffic = @$total_traffic;
$view->content->today_traffic = @$today_traffic;
$view->content->month_traffic = @$month_traffic;
$view->content->membership_transfer_from_member = isset($membership_transfer_from_member) ? $membership_transfer_from_member : NULL;
$view->content->membership_transfer_to_member = $membership_transfer_to_member;
$view->content->member_links = implode(' | ', $member_links);
$view->content->user_links = implode(' | ', $user_links);
$view->content->is_association = $is_association;
$view->render(TRUE);
} // end of show function
/**
* Gets expiration date of member's payments.
*
* @author Michal Kliment, Ondrej Fibich
* @param object $account
* @return string
*/
public static -->
<axo usage_type="unknown" section="Members_Controller" value="members" action="view" own="true"></axo>
<axo usage_type="unknown" section="Members_Controller" value="members" action="edit" own="true"></axo>
<axo usage_type="unknown" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
<axo usage_type="unknown" section="Users_Controller" value="users" action="view" own="true"></axo>
<axo usage_type="unknown" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
<axo usage_type="unknown" section="Accounts_Controller" value="transfers" action="new" own="true"></axo>
<axo usage_type="unknown" section="Users_Controller" value="users" action="new" own="false"></axo>
<axo usage_type="unknown" section="Users_Controller" value="users" action="new" own="true"></axo>
<axo usage_type="unknown" section="Users_Controller" value="users" action="view" own="true"></axo>
<axo usage_type="unknown" section="Users_Controller" value="users" action="edit" own="false"></axo>
<axo usage_type="unknown" section="Users_Controller" value="users" action="edit" own="true"></axo>
<axo usage_type="unknown" section="Users_Controller" value="users" action="delete" own="true"></axo>
<axo usage_type="unknown" section="Devices_Controller" value="devices" action="view" own="true"></axo>
<axo usage_type="unknown" section="Works_Controller" value="work" action="edit" own="true"></axo>
<axo usage_type="unknown" section="Members_Controller" value="membership_interrupts" action="new" own="true"></axo>
<axo usage_type="unknown" section="Members_Controller" value="membership_interrupts" action="edit" own="true"></axo>
<axo usage_type="unknown" section="Members_Controller" value="membership_interrupts" action="delete" own="false"></axo>
<axo usage_type="unknown" section="Redirect_Controller" value="redirect" action="new" own="false"></axo>
<axo usage_type="unknown" section="Messages_Controller" value="member" action="view" own="false"></axo>
<axo usage_type="unknown" section="Redirect_Controller" value="redirect" action="delete" own="false"></axo>
<axo usage_type="unknown" section="Members_Controller" value="members" action="edit" own="true"></axo>
<axo usage_type="unknown" section="Accounts_Controller" value="transfers" action="view" own="true"></axo>
<axo usage_type="unknown" section="Members_Controller" value="fees" action="view" own="true"></axo>
<axo usage_type="unknown" section="Allowed_subnets_Controller" value="allowed_subnet" action="view" own="true"></axo>
<axo usage_type="unknown" section="Notifications_Controller" value="member" action="new" own="false"></axo>
<axo usage_type="unknown" section="Members_whitelists_Controller" value="whitelist" action="view" own="false"></axo>
<axo usage_type="unknown" section="Members_Controller" value="members" action="view" own="false"></axo>
<axo usage_type="unknown" section="Members_Controller" value="members" action="edit" own="false"></axo>
<axo usage_type="unknown" section="Members_Controller" value="members" action="edit" own="false"></axo>
<axo usage_type="unknown" section="Membership_transfers_Controller" value="membership_transfer" action="new" own="true"></axo>
<axo usage_type="unknown" section="Membership_transfers_Controller" value="membership_transfer" action="edit" own="true"></axo>
<axo usage_type="unknown" section="Membership_transfers_Controller" value="membership_transfer" action="delete" own="true"></axo>
<axo usage_type="unknown" section="Users_Controller" value="users" action="view" own="true"></axo>
<axo usage_type="unknown" section="Users_Controller" value="users" action="edit" own="true"></axo>
<axo usage_type="unknown" section="Devices_Controller" value="devices" action="view" own="true"></axo>
<axo usage_type="unknown" section="Connection_Requests_Controller" value="request" action="view" own="true"></axo>
<axo usage_type="unknown" section="Works_Controller" value="work" action="view" own="true"></axo>
<axo usage_type="unknown" section="Works_Controller" value="work" action="view" own="true"></axo>
<axo usage_type="unknown" section="Requests_Controller" value="request" action="view" own="true"></axo>
<axo usage_type="unknown" section="Users_Controller" value="password" action="edit" own="true"></axo>
<axo usage_type="unknown" section="Users_Controller" value="application_password" action="edit" own="true"></axo>
<axo usage_type="unknown" section="Members_Controller" value="members" action="view" own="false"></axo>
<axo usage_type="access" section="Members_Controller" value="members" action="view" own="true"></axo>
<axo usage_type="access-partial" section="Members_Controller" value="members" action="edit" own="true"></axo>
<axo usage_type="grid-action" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
<axo usage_type="grid-action" section="Users_Controller" value="users" action="view" own="true"></axo>
<axo usage_type="links" section="VoIP_Controller" value="voip" action="view" own="true"></axo>
<axo usage_type="links" section="Accounts_Controller" value="transfers" action="new" own="true"></axo>
<axo usage_type="links" section="Users_Controller" value="users" action="new" own="false"></axo>
<axo usage_type="links" section="Users_Controller" value="users" action="new" own="true"></axo>
<axo usage_type="grid-action" section="Users_Controller" value="users" action="view" own="true"></axo>
<axo usage_type="grid-action" section="Users_Controller" value="users" action="edit" own="false"></axo>
<axo usage_type="grid-action" section="Users_Controller" value="users" action="edit" own="true"></axo>
<axo usage_type="grid-action" section="Users_Controller" value="users" action="delete" own="true"></axo>
<axo usage_type="grid-action" section="Devices_Controller" value="devices" action="view" own="true"></axo>
<axo usage_type="grid-action" section="Works_Controller" value="work" action="edit" own="true"></axo>
<axo usage_type="links" section="Members_Controller" value="membership_interrupts" action="new" own="true"></axo>
<axo usage_type="grid-action" section="Members_Controller" value="membership_interrupts" action="edit" own="true"></axo>
<axo usage_type="grid-action" section="Members_Controller" value="membership_interrupts" action="delete" own="false"></axo>
<axo usage_type="links" section="Redirect_Controller" value="redirect" action="new" own="false"></axo>
<axo usage_type="access-partial" section="Messages_Controller" value="member" action="view" own="false"></axo>
<axo usage_type="access-partial" section="Redirect_Controller" value="redirect" action="delete" own="false"></axo>
<axo usage_type="links" section="Members_Controller" value="members" action="edit" own="true"></axo>
<axo usage_type="links" section="Accounts_Controller" value="transfers" action="view" own="true"></axo>
<axo usage_type="links" section="Members_Controller" value="fees" action="view" own="true"></axo>
<axo usage_type="links" section="Allowed_subnets_Controller" value="allowed_subnet" action="view" own="true"></axo>
<axo usage_type="links" section="Notifications_Controller" value="member" action="new" own="false"></axo>
<axo usage_type="links" section="Members_whitelists_Controller" value="whitelist" action="view" own="false"></axo>
<axo usage_type="links" section="Members_Controller" value="members" action="view" own="false"></axo>
<axo usage_type="links" section="Members_Controller" value="members" action="edit" own="false"></axo>
<axo usage_type="links" section="Members_Controller" value="members" action="edit" own="false"></axo>
<axo usage_type="links" section="Membership_transfers_Controller" value="membership_transfer" action="new" own="true"></axo>
<axo usage_type="links" section="Membership_transfers_Controller" value="membership_transfer" action="edit" own="true"></axo>
<axo usage_type="links" section="Membership_transfers_Controller" value="membership_transfer" action="delete" own="true"></axo>
<axo usage_type="links" section="Users_Controller" value="users" action="view" own="true"></axo>
<axo usage_type="links" section="Users_Controller" value="users" action="edit" own="true"></axo>
<axo usage_type="links" section="Devices_Controller" value="devices" action="view" own="true"></axo>
<axo usage_type="links" section="Connection_Requests_Controller" value="request" action="view" own="true"></axo>
<axo usage_type="links" section="Works_Controller" value="work" action="view" own="true"></axo>
<axo usage_type="links" section="Works_Controller" value="work" action="view" own="true"></axo>
<axo usage_type="links" section="Requests_Controller" value="request" action="view" own="true"></axo>
<axo usage_type="links" section="Users_Controller" value="password" action="edit" own="true"></axo>
<axo usage_type="links" section="Users_Controller" value="application_password" action="edit" own="true"></axo>
<axo usage_type="breadcrumbs" section="Members_Controller" value="members" action="view" own="false"></axo>
</method>
<method name="add">
<!-- add()
{
// access rights
if (!$this->acl_check_new(get_class($this),'members'))
Controller::error(ACCESS);
$enum_types = new Enum_type_Model();
$types = $enum_types->get_values(Enum_type_Model::MEMBER_TYPE_ID);
asort($types);
// start entrance date
$association = new Member_Model(Member_Model::ASSOCIATION);
$entrace_start_year = date('Y', strtotime($association->entrance_date));
// cannot add former member
unset($types[Member_Model::TYPE_FORMER]);
unset($types[Member_Model::TYPE_APPLICANT]);
// regular member by default
$type_id = $enum_types->get_type_id('Regular member');
// entrance fee
$fee_model = new Fee_Model();
$fee = $fee_model->get_by_date_type(date('Y-m-d'), 'entrance fee');
if (is_object($fee) && $fee->id)
$entrance_fee = $fee->fee;
else
$entrance_fee = 0;
// countries
$arr_countries = ORM::factory('country')->select_list('id', 'country_name');
// streets
$arr_streets = array
(
NULL => '- ' . __('Without street') . ' -'
) + ORM::factory('street')->select_list('id', 'street');
// towns with zip code and quarter
$arr_towns = array
(
NULL => '- ' . __('Select town') . ' -'
) + ORM::factory('town')->select_list_with_quater();
// phone prefixes
$country_model = new Country_Model();
$phone_prefixes = $country_model->select_country_list();
// form
$form = new Forge();
$form->group('Basic information');
$form->input('title1')
->label('Pre title')
->rules('length[3,40]');
$form->input('name')
->rules('required|length[1,30]');
$form->input('middle_name')
->rules('length[1,30]');
$form->input('surname')
->rules('required|length[1,60]');
$form->input('title2')
->label('Post title')
->rules('length[1,30]');
$form->dropdown('type')
->options($types)
->rules('required')
->selected($type_id)
->style('width:200px');
$form->input('membername')
->label(__('Name of organization').':&nbsp;'.help::hint('member_name'))
->rules('length[1,60]');
// access control
if ($this->acl_check_new('Members_Controller', 'organization_id'))
{
$form->input('organization_identifier')
->rules('length[3,20]');
}
// access control
if ($this->acl_check_new('Members_Controller', 'vat_organization_identifier'))
{
$form->input('vat_organization_identifier')
->rules('length[3,30]');
}
$form->group('Login data');
$form->input('login')
->label('Username')
->rules('required|length[5,20]')
->callback(array($this, 'valid_username'));
$pass_min_len = Settings::get('security_password_length');
$form->password('password')
->label(__('Password').':&nbsp;'.help::hint('password'))
->rules('required|length['.$pass_min_len.',50]')
->class('main_password');
$form->password('confirm_password')
->rules('required|length['.$pass_min_len.',50]')
->matches($form->password);
$form->group('Address of connecting place');
$form->dropdown('town_id')
->label('Town')
->rules('required')
->options($arr_towns)
->style('width:200px')
->add_button('towns');
$form->dropdown('street_id')
->label('Street')
->options($arr_streets)
->style('width:200px')
->style('width:200px')
->add_button('streets');
$form->input('street_number')
->rules('length[1,50]');
$form->dropdown('country_id')
->label('Country')
->rules('required')
->options($arr_countries)
->style('width:200px')
->selected(Settings::get('default_country'));
$form->input('gpsx')
->label(__('GPS').'&nbsp;X:&nbsp;'.help::hint('gps_coordinates'))
->rules('gps');
$form->input('gpsy')
->label(__('GPS').'&nbsp;Y:&nbsp;'.help::hint('gps_coordinates'))
->rules('gps');
$form->group('Address of domicile');
$form->checkbox('use_domicile')
->label(__(
'Address of connecting place is different than address of domicile'
));
$form->dropdown('domicile_town_id')
->label('Town')
->options($arr_towns)
->style('width:200px')
->add_button('towns');
$form->dropdown('domicile_street_id')
->label('Street')
->options($arr_streets)
->style('width:200px')
->add_button('streets');
$form->input('domicile_street_number')
->label('Street number')
->rules('length[1,50]')
->callback(array($this, 'valid_docimile_street_number'))
->style('width:200px');
$form->dropdown('domicile_country_id')
->label('Country')
->options($arr_countries)
->selected(Settings::get('default_country'))
->style('width:200px');
$form->input('domicile_gpsx')
->label(__('GPS').'&nbsp;X:&nbsp;'.help::hint('gps_coordinates'))
->rules('gps');
$form->input('domicile_gpsy')
->label(__('GPS').'&nbsp;Y:&nbsp;'.help::hint('gps_coordinates'))
->rules('gps');
$form->group('Contact information');
$form->dropdown('phone_prefix')
->label('Telephone prefix')
->rules('required')
->options($phone_prefixes)
->selected(Settings::get('default_country'))
->style('width:200px');
$form->input('phone')
->rules('required|length[9,40]')
->callback(array($this, 'valid_phone'));
$form->input('email')
->rules('length[3,50]|valid_email');
if (Settings::get('finance_enabled'))
{
$form->group('Account information');
$form->input('variable_symbol')
->label(__('Variable symbol').':&nbsp;'.help::hint('variable_symbol'))
->rules('length[1,10]')
->class('join1')
->callback('Variable_Symbols_Controller::valid_var_sym');
if (Variable_Key_Generator::get_active_driver())
{
$form->checkbox('variable_symbol_generate')
->label('Generate automatically')
->checked(TRUE)
->class('join2')
->style('width:auto;margin-left:5px');
}
else
{
$form->variable_symbol->rules('required|length[1,10]');
}
$form->input('entrance_fee')
->label(__('Entrance fee').':&nbsp;'.help::hint('entrance_fee'))
->rules('valid_numeric')
->value($entrance_fee);
$form->input('debt_payment_rate')
->label(
__('Monthly instalment of entrance').
':&nbsp;'.help::hint('entrance_fee_instalment')
)
->rules('valid_numeric')
->value($entrance_fee);
}
$form->group('Additional information');
$speed_class = new Speed_class_Model();
$speed_classes = array(NULL => '') + $speed_class->select_list();
$default_speed_class = $speed_class->get_members_default_class();
$form->dropdown('speed_class')
->options($speed_classes)
->selected($default_speed_class ? $default_speed_class->id : NULL)
->add_button('speed_classes')
->style('width:200px');
$form->date('birthday')
->label('Birthday')
->years(date('Y')-100, date('Y'))
->rules('required');
$form->date('entrance_date')
->label('Entrance date')
->years($entrace_start_year)
->rules('required')
->callback(array($this, 'valid_entrance_date'));
$form->textarea('comment')
->rules('length[0,250]');
$form->submit('Add');
// posted
if($form->validate())
{
$form_data = $form->as_array();
// gps
$gpsx = NULL;
$gpsy = NULL;
if (!empty($form_data['gpsx']) && !empty($form_data['gpsy']))
{
$gpsx = doubleval($form_data['gpsx']);
$gpsy = doubleval($form_data['gpsy']);
if (gps::is_valid_degrees_coordinate($form_data['gpsx']))
{
$gpsx = gps::degrees2real($form_data['gpsx']);
}
if (gps::is_valid_degrees_coordinate($form_data['gpsy']))
{
$gpsy = gps::degrees2real($form_data['gpsy']);
}
}
// gps domicicle
$domicile_gpsx = NULL;
$domicile_gpsy = NULL;
if (!empty($form_data['domicile_gpsx']) && !empty($form_data['domicile_gpsy']))
{
$domicile_gpsx = doubleval($form_data['domicile_gpsx']);
$domicile_gpsy = doubleval($form_data['domicile_gpsy']);
if (gps::is_valid_degrees_coordinate($form_data['domicile_gpsx']))
{
$domicile_gpsx = gps::degrees2real($form_data['domicile_gpsx']);
}
if (gps::is_valid_degrees_coordinate($form_data['domicile_gpsy']))
{
$domicile_gpsy = gps::degrees2real($form_data['domicile_gpsy']);
}
}
$member = new Member_Model();
try
{
//$profiler = new Profiler();
// let's start safe transaction processing
$member->transaction_start();
$user = new User_Model();
$account = new Account_Model();
$address_point_model = new Address_point_Model();
$address_point = $address_point_model->get_address_point(
$form_data['country_id'], $form_data['town_id'],
$form_data['street_id'], $form_data['street_number'],
$gpsx, $gpsy
);
// add address point if there is no such
if (!$address_point->id)
{
$address_point->save_throwable();
}
// add GPS
if (!empty($gpsx) && !empty($gpsy))
{ // save
$address_point->update_gps_coordinates(
$address_point->id, $gpsx, $gpsy
);
}
else
{ // delete gps
$address_point->gps = '';
$address_point->save_throwable();
}
$member->address_point_id = $address_point->id;
$account->account_attribute_id = Account_attribute_Model::CREDIT;
if ($form_data['membername'] == '')
{
$account->name = $form_data['surname'].' '.$form_data['name'];
}
else
{
$account->name = $form_data['membername'];
}
$user->name = $form_data['name'];
$user->middle_name = $form_data['middle_name'];
$user->login = $form_data['login'];
$user->surname = $form_data['surname'];
$user->pre_title = $form_data['title1'];
$user->post_title = $form_data['title2'];
$user->birthday = date("Y-m-d",$form_data['birthday']);
$user->password = sha1($form_data['password']);
$user->type = User_Model::MAIN_USER;
$user->application_password = security::generate_password();
// id of user who added member
$member->user_id = $this->session->get('user_id');
$member->comment = $form_data['comment'];
if ($form_data['membername'] == '')
{
$member->name = $form_data['name'].' '.$form_data['surname'];
}
else
{
$member->name = $form_data['membername'];
}
$member->type = $form_data['type'];
// access control
if ($this->acl_check_new('Members_Controller', 'organization_id'))
{
$member->organization_identifier = $form_data['organization_identifier'];
}
// access control
if ($this->acl_check_new('Members_Controller', 'vat_organization_identifier'))
{
$member->vat_organization_identifier = $form_data['vat_organization_identifier'];
}
$member->speed_class_id = $form_data['speed_class'];
if (Settings::get('finance_enabled'))
{
$member->entrance_fee = $form_data['entrance_fee'];
$member->debt_payment_rate = $form_data['debt_payment_rate'];
}
if ($member->type == Member_Model::TYPE_APPLICANT)
{
$member->entrance_date = NULL;
}
else
{
$member->entrance_date = date('Y-m-d', $form_data['entrance_date']);
}
// saving member
$member->save_throwable();
// saving user
$user->member_id = $member->id;
$user->save_throwable();
// telephone
$contact_model = new Contact_Model();
// search for contacts
$contact_id = $contact_model->find_contact_id(
Contact_Model::TYPE_PHONE, $form_data['phone']
);
if ($contact_id)
{
$contact_model = ORM::factory('contact', $contact_id);
$contact_model->add($user);
$contact_model->save_throwable();
}
else
{ // add whole contact
$contact_model->type = Contact_Model::TYPE_PHONE;
$contact_model->value = $form_data['phone'];
$contact_model->save_throwable();
$contact_model->add($user);
$phone_country = new Country_Model($form_data['phone_prefix']);
$contact_model->add($phone_country);
$contact_model->save_throwable();
}
$contact_model->clear();
// email
if (! empty($form_data['email']))
{
$contact_model->type = Contact_Model::TYPE_EMAIL;
$contact_model->value = $form_data['email'];
$contact_model->save_throwable();
$contact_model->add($user);
$contact_model->save_throwable();
}
// saving account
$account->member_id = $member->id;
$account->save_throwable();
if (Settings::get('finance_enabled'))
{
// saving variable symbol
if (!isset($form_data['variable_symbol_generate']) ||
!$form_data['variable_symbol_generate'])
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff