Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 839

Přidáno uživatelem Ondřej Fibich před více než 13 roky(ů)

Odstraneni sloupcu phone a email z tabulky users.
Transformace dat do skupiny tabulek kolem tabulky contacts.
Zmena vsech rozhrani pracujicich s telefonem a emailem.

Zobrazit rozdíly:

freenetis/branches/testing/application/i18n/cs_CZ/texts.php
'error - wrong data' => 'Chyba - špatná data',
'error - amount has to be positive' => 'Chyba - částka musí být kladná.',
'error - cannot add message' => 'Chyba - nelze přidat zprávu.',
'error - cannot complete registration' => 'Chyba - Nelze dokončit registraci',
'error - cannot delete bank statement' => 'Chyba - nelze smazat bankovní výpis.',
'error - cannot load intelligent selection' => 'Chyba - nelze načíst inteligentní výběr',
'error - cannot update message' => 'Chyba - nelze upravit zprávu.',
......
'template name' => 'Název šablony',
'temporary whitelist' => 'Dočasný whitelist',
'telephone number' => 'Telefonní číslo',
'telephone prefix' => 'Telefonní předčíslí',
'tenth-degree certified engineers' => 'Certifikování technici desátého stupně',
'terminating call' => 'Příchozí volání',
'tertiary dns' => 'Terciární DNS.',
freenetis/branches/testing/application/models/subnet.php
se.name AS segment_name,
d.name AS device_name,
IFNULL(f.translated_term, e.value) AS device_type,
u.name AS user_name, u.surname, u.phone,
u.name AS user_name, u.surname,
m.name AS member_name, m.variable_symbol, m.entrance_date,
st.street, ap.street_number,
t.town, t.quarter, t.zip_code,
......
*/
public function get_phones_and_names_of_subnet($subnet_id){
return $this->db->query("SELECT
DISTINCT (u.phone),
DISTINCT (co.phone),
CONCAT(u.surname,' ',u.name) as name, u.id
FROM subnets su
LEFT JOIN ip_addresses ip ON ip.subnet_id = su.id
......
LEFT JOIN devices d ON d.id = i.device_id
LEFT JOIN users u ON u.id = d.user_id
LEFT JOIN members m ON m.id = u.member_id
WHERE su.id = $subnet_id AND m.id <> 1 AND m.locked <> 1;
");
LEFT JOIN users_contacts uc ON uc.user_id = u.id
LEFT JOIN contacts co ON co.id = uc.contact_id
WHERE su.id = ? AND co.type = ? AND m.id <> 1 AND m.locked <> 1;
", array($subnet_id, Contact_Model::TYPE_PHONE));
}
/**
......
* @return unknown_type
*/
public function get_phones_of_subnet($subnet_id){
return $this->db->query("SELECT DISTINCT (u.phone)
return $this->db->query("SELECT DISTINCT (co.value)
FROM subnets su
LEFT JOIN ip_addresses ip ON ip.subnet_id = su.id
LEFT JOIN ifaces i ON i.id = ip.iface_id
LEFT JOIN devices d ON d.id = i.device_id
LEFT JOIN users u ON u.id = d.user_id
LEFT JOIN members m ON m.id = u.member_id
WHERE su.id = $subnet_id AND m.id <> 1 AND m.locked <> 1;
");
LEFT JOIN users_contacts uc ON uc.user_id = u.id
LEFT JOIN contacts co ON co.id = uc.contact_id
WHERE su.id = ? AND co.type = ? AND m.id <> 1 AND m.locked <> 1;
", array($subnet_id, Contact_Model::TYPE_PHONE));
}
}
freenetis/branches/testing/application/models/phone_invoice_user.php
static $contact = NULL;
if ($contact == NULL)
{
$contact = new Contact_Model();
}
$country_code = $contact->find_phone_country_code($phone_number);
$query = $this->db->query(
"SELECT id FROM users WHERE phone = ?;",
array(substr($phone_number, mb_strlen($country_code)))
);
if ($query->count() > 0)
{
return $query->current()->id;
}
// type 21 is phone number
$query = $this->db->query(
"SELECT u.user_id FROM users_contacts u
LEFT JOIN contacts c ON c.id = u.contact_id
WHERE type = ? AND value = ?;",
freenetis/branches/testing/application/models/user.php
protected $has_many = array('jobs', 'devices', 'phone_invoices_users', 'users' => 'private_phone_contacts');
protected $has_and_belongs_to_many = array('users_contacts' => 'contacts');
public $arr_sql = array('id' => 'u.id', 'name' => 'u.name', 'surname' => 'u.surname', 'email' => 'u.email', 'phone' => 'u.phone', 'login' => 'u.login', 'member_name' => 'm.name');
public $arr_sql = array('id' => 'u.id', 'name' => 'u.name', 'surname' => 'u.surname', 'login' => 'u.login', 'member_name' => 'm.name');
/**
* Model constructor
......
else $where .= ' AND u.member_id = '.$member_id;
}
return $this->db->query('SELECT
u.id, u.name, u.surname, u.login, u.email, u.phone, u.member_id
u.id, u.name, u.surname, u.login, u.member_id
FROM users u
'.$where.'
ORDER BY '.$this->arr_sql[$order_by].' '.$order_by_direction.'
......
");
}
/**
* Function searches for items dependent on given user. Used for deleting user.
* @param $user_id
* @return unknown_type
*/
/**
* Function searches for items dependent on given user. Used for deleting user.
* @param $user_id
* @return unknown_type
*/
public function count_dependent_items($user_id)
{
return $this->db->query("
......
) di
")->current()->total;
}
/**
* Selects all users emails
* @author Ondřej Fibich
* @param integer $user_id
* @return unknown_type Mysql result
*/
public function get_user_emails($user_id)
{
return $this->db->query("
SELECT c.value as email
FROM users_contacts u
LEFT JOIN contacts c ON c.id = u.contact_id
WHERE u.user_id = ? AND c.type = ?
", array($user_id, Contact_Model::TYPE_EMAIL));
}
}
?>
freenetis/branches/testing/application/models/address_point.php
* @param $town_id id of town
* @param $street_id id of street
* @param $street_number street number
* @return address point object
* @return Address_point_Model
*/
function get_address_point($town_id = NULL, $street_id = NULL, $street_number = NULL, $gps = NULL)
{
freenetis/branches/testing/application/models/member.php
m.registration, m.name AS member_name, m.variable_symbol,
s.street, ap.street_number,
t.town, t.quarter,
u.phone, u.email, u.login AS login_name, u.birthday,
u.login AS login_name, u.birthday,
m.entrance_date,
IF(m.leaving_date = '0000-00-00', null, m.leaving_date) AS leaving_date,
IFNULL(f.translated_term, e.value) AS type, m.comment
......
'users.id', 'member_id',
'users.name', 'middle_name', 'surname',
'pre_title', 'post_title',
'login', 'email', 'users.type', 'phone', 'birthday', 'leaving_date','users.application_password','users.comment as ucomment')
'login', 'users.type', 'birthday', 'leaving_date','users.application_password','users.comment as ucomment')
)->from('members')
->join('enum_types', 'members.type', 'enum_types.id', 'LEFT')
->join('users', 'users.member_id', 'members.id', 'LEFT')
......
*/
return $this->db->query("
(
SELECT member_id FROM users u WHERE u.phone = ?
) UNION (
SELECT m.id FROM members m
JOIN users ON m.id = users.member_id
JOIN users_contacts ON users.id = users_contacts.user_id
JOIN contacts c ON users_contacts.contact_id = c.id
WHERE c.type = ? AND c.value = ?
)
", array($phone, Contact_Model::TYPE_PHONE, $phone))->current()->id;
", array(Contact_Model::TYPE_PHONE, $phone))->current()->id;
}
/**
* @author Tomas Dulik
* @author Tomas Dulik, Ondřej Fibich
* @return unknown_type
*
*/
......
WHERE REPLACE(phone," ", "") LIKE '%$phone%' LIMIT 1';
*/
return $this->db->query("
(
SELECT m.*
FROM members m
JOIN users u ON m.id = u.member_id
AND u.phone = ?
) UNION (
SELECT m.* FROM members m
JOIN users ON m.id = users.member_id
JOIN users_contacts ON users.id = users_contacts.user_id
JOIN contacts c ON users_contacts.contact_id = c.id
WHERE c.type = ? AND c.value = ?
)
", array($phone, Contact_Model::TYPE_PHONE, $phone))->current();
", array(Contact_Model::TYPE_PHONE, $phone))->current();
}
/**
freenetis/branches/testing/application/models/contact.php
}
/**
* Search for phone prefix in country table.
* @author Ondřej Fibich
* Search for phone prefix in country table.
* @param string $phone_number Telephone number with prefix
* @return integer ID of country or zero
*/
......
}
/**
* Search for phone prefix in country table.
* @author Ondřej Fibich
* Search for phone prefix in country table.
* @param string $phone_number Telephone number with prefix
* @return integer country code or zero
*/
......
}
/**
* Gets prefix of phone country code
* @author Ondřej Fibich
* Gets prefix of phone country code
* @return prefix or empty string
*/
public function get_phone_prefix()
freenetis/branches/testing/application/controllers/installation.php
$user->name = $form_data["login"];
$user->surname = $form_data["login"];
$user->birthday = date("Y-m-d", $form_data["foundation"]);
$user->phone = $form_data["phone"];
$user->email = $form_data["email"];
$user->login = $form_data["login"];
$user->password = sha1($form_data["password"]);
$user->type = User_Model::$member;
$user->application_password = security::generate_password();
$user->save();
// users telephone
$contact = new Contact_Model();
$contact->type = Contact_Model::TYPE_PHONE;
$contact->value = $form_data['phone'];
$contact->save_throwable();
$contact->add($user);
$contact->save_throwable();
$phone_country = new Country_Model($form_data['default_country']);
$contact->add($phone_country);
$contact->save_throwable();
$contact->clear();
// users email
if (! empty($form_data['email']))
{
$contact->type = Contact_Model::TYPE_EMAIL;
$contact->value = $form_data['email'];
$contact->save_throwable();
$contact->add($user);
$contact->save_throwable();
}
// association has at least one real bank account
$bank_account = new Bank_account_Model();
$bank_account->name = $form_data["account_name"];
freenetis/branches/testing/application/controllers/users.php
if (is_numeric($this->input->get('record_per_page'))) $limit_results = (int) $this->input->get('record_per_page');
// parameters control
$allowed_order_type = array('id', 'name', 'surname', 'login', 'email', 'member_name');
$allowed_order_type = array('id', 'name', 'surname', 'login', 'member_name');
if (!in_array(strtolower($order_by), $allowed_order_type))
$order_by = 'id';
if (strtolower($order_by_direction) != 'asc' && strtolower($order_by_direction) != 'desc')
......
new Table_Form_Item('text','surname','Surname'),
new Table_Form_Item('text','name','Name'),
"tr",
new Table_Form_Item('text','email','Email'),
new Table_Form_Item('text','phone','Phone'),
"tr",
new Table_Form_Item('text','login','Login name'),
new Table_Form_Item('text','member_name','Member'),
"tr", "td", "td", "td",
......
$grid->order_field('name')->label(url_lang::lang('texts.Name'));
$grid->order_field('surname')->label(url_lang::lang('texts.Surname'));
$grid->order_field('login')->label(url_lang::lang('texts.Username'));
$grid->order_field('phone')->label(url_lang::lang('texts.Phone'));
if ($this->acl_check_view(get_class($this),'users'))
$grid->action_field('id') ->label(url_lang::lang('texts.User')) ->url(url_lang::base().'users/show') ->action(url_lang::lang('texts.Show'))->class('center');
if ($this->acl_check_edit(get_class($this),'users'))
......
$grid->order_field('name')->label(url_lang::lang('texts.Name'));
$grid->order_field('surname')->label(url_lang::lang('texts.Surname'));
$grid->order_field('login')->label(url_lang::lang('texts.Username'));
$grid->order_field('email')->label('E-mail');
if ($this->acl_check_view(get_class($this),'users',$member_id))
$grid->action_field('id') ->label(url_lang::lang('texts.User')) ->url(url_lang::base().'users/show') ->action(url_lang::lang('texts.Show'));
if ($this->acl_check_edit(get_class($this),'users',$member_id))
......
$form->input('surname')->label(url_lang::lang('texts.surname').':')->rules('required|length[3,60]')->value($user_model->surname);
$form->input('post_title')->label(url_lang::lang('texts.post title').':')->rules('length[3,30]')->value($user_model->post_title);
$form->group('')->label(url_lang::lang('texts.Contact information'));
if ($this->acl_check_edit(get_class($this),'phone',$user_model->member_id))
$form->input('phone')
->label(url_lang::lang('texts.phone').':')
->rules('required|length[9,14]|valid_numeric')->callback(array($this, 'valid_phone'))->value($user_model->phone);
if ($this->acl_check_edit(get_class($this),'email',$user_model->member_id))
$form->input('email')->label(url_lang::lang('texts.email').':')
->rules('length[3,50]|valid_email')
->value($user_model->email);
$form->group('')->label(url_lang::lang('texts.Additional information'));
$form->date('birthday')->label(url_lang::lang('texts.birthday').':')->years(date('Y')-100, date('Y'))->rules('required')->value(strtotime($user_model->birthday));
......
$user_data->surname = $form_data['surname'];
$user_data->post_title = $form_data['post_title'];
if ($this->acl_check_edit(get_class($this),'phone',$user_model->member_id))
$user_data->phone = $form_data['phone'];
if ($this->acl_check_edit(get_class($this),'email',$user_model->member_id))
$user_data->email = $form_data['email'];
if ($this->acl_check_edit(get_class($this),'comment',$user_model->member_id))
$user_data->comment = $form_data['comment'];
......
$form->password('password')->label(url_lang::lang('texts.password').':')->rules('required|length[3,50]')->class('password');
$form->password('confirm_password')->label(url_lang::lang('texts.confirm password').':')->rules('required|length[3,50]')->matches($form->password);
$form->group('')->label(url_lang::lang('texts.Contact information'));
$form->input('phone')->label(url_lang::lang('texts.phone').':')->rules('required|length[9,40]')->callback(array($this, 'valid_phone'));
$form->input('email')->label(url_lang::lang('texts.email').':')->rules('length[3,50]|valid_email')->callback(array($this, 'valid_email'));
$form->group('')->label(url_lang::lang('texts.Additional information'));
$form->date('birthday')->label(url_lang::lang('texts.birthday').':')->years(date('Y')-100, date('Y'))->rules('required');
if ($this->acl_check_new(get_class($this),'comment',$member_id))
......
$user_data->middle_name = $form_data['middle_name'];
$user_data->surname = $form_data['surname'];
$user_data->post_title = $form_data['post_title'];
$user_data->phone = $form_data['phone'];
$user_data->email = $form_data['email'];
$user_data->comment = $form_data['comment'];
$user_data->type = User_Model::$user;
$user_data->member_id = $member_id;
......
{
$grid_contacts->action_field('id')->label(url_lang::lang('texts.Delete'))
->url(url_lang::base().'users/additional_contacts/delete/'.$user_id)
->action(url_lang::lang('texts.Delete'))->class('delete');
->action(url_lang::lang('texts.Delete'))->class('delete_link');
}
$grid_private_contacts = NULL;
......
}
}
function valid_phone($input)
{
$user_model=new User_Model();
if ($user_model->phone_exist($input->value,$this->user_id) || trim($input->value)=='')
{
$input->add_error('required', url_lang::lang('texts.Phone already exists in database.'));
}
}
function valid_email($input)
{ /*
$user_model=new User_Model();
if ($user_model->email_exist($input->value,$this->user_id) || trim($input->value)=='')
{
$input->add_error('required', url_lang::lang('texts.Email already exists in database.'));
}
*/
}
}
?>
freenetis/branches/testing/application/controllers/redirection.php
$subject .= $ip_address;
$sender = "FreeNetIS";
$users_model = new User_Model($redirection->admin);
$email = $users_model->email;
$emails = $users_model->get_user_emails($users_model->id);
$body = "Tento email byl odeslán ze systému FreeNetIS.\n";
$body .= "------------------------------------------------------------------\n\n";
$body .= "Uživatel s IP adresou ".$ip_address;
......
require_once 'Zend/Mail.php';
$mail = new Zend_Mail('UTF-8');
$mail->setFrom($sender, $sender);
$mail->addTo($email, $email); //2. parametr muze byt nickname nebo jmeno a prijmeni spravce oblasti
foreach ($emails as $email)
{
$mail->addTo($email->email, $email->email); //2. parametr muze byt nickname nebo jmeno a prijmeni spravce oblasti
}
$mail->setSubject($subject);
$mail->setBodyText($body);
$mail->send();
......
$subject .= $ip_address;
$sender = "FreeNetIS";
$users_model = new User_Model($redirection->admin);
$email = $users_model->email;
$emails = $users_model->get_user_emails($users_model->id);
$body = "Tento email byl odeslán ze systému FreeNetIS.\n";
$body .= "------------------------------------------------------------------\n\n";
$body .= "Uživatel s IP adresou ".$ip_address;
......
require_once 'Zend/Mail.php';
$mail = new Zend_Mail('UTF-8');
$mail->setFrom($sender, $sender);
$mail->addTo($email, $email); //2. parametr muze byt nickname nebo jmeno a prijmeni spravce oblasti
foreach ($emails as $email)
{
$mail->addTo($email->email, $email->email); //2. parametr muze byt nickname nebo jmeno a prijmeni spravce oblasti
}
$mail->setSubject($subject);
$mail->setBodyText($body);
$mail->send();
......
$subject .= $ip_address;
$sender = "FreeNetIS";
$users_model = new User_Model($redirection->admin);
$email = $users_model->email;
$emails = $users_model->get_user_emails($users_model->id);
$body = "Tento email byl odeslán ze systému FreeNetIS.\n";
$body .= "------------------------------------------------------------------\n\n";
$body .= "Uživatel s IP adresou ".$ip_address;
......
require_once 'Zend/Mail.php';
$mail = new Zend_Mail('UTF-8');
$mail->setFrom($sender, $sender);
$mail->addTo($email, $email); //2. parametr muze byt nickname nebo jmeno a prijmeni spravce oblasti
foreach ($emails as $email)
{
$mail->addTo($email->email, $email->email); //2. parametr muze byt nickname nebo jmeno a prijmeni spravce oblasti
}
$mail->setSubject($subject);
$mail->setBodyText($body);
$mail->send();
freenetis/branches/testing/application/controllers/voip.php
$voip_new->username = $number;
$voip_new->save();
// get email
$emails = $user->get_user_emails($user->id);
$email = '';
if ($emails != false)
{
$email = $emails->current()->email;
}
$voicemail = new Voip_voicemail_user_Model();
$voicemail->customer_id = $number;
$voicemail->mailbox = $number;
$voicemail->password = security::generate_numeric_password(4);
$voicemail->fullname = $username;
$voicemail->email =$user->email;
$voicemail->email =$email;
$voicemail->save();
}
freenetis/branches/testing/application/controllers/setup_config.php
}
}
/**
* Function checks validity of phone number.
* @param $input
* @return unknown_type
*/
function valid_phone($input)
{
$value = trim($input->value);
//if(!ereg("^[0-9]{9,9}$", $value))
if(!preg_match("/^[0-9]{9,9}$/", $value))
{
$input->add_error('required', url_lang::lang('texts.Bad phone format.'));
}
}
}
freenetis/branches/testing/application/controllers/registration.php
class Registration_Controller extends Controller {
/**
* @author Michal Kliment, Jiri Svitak
* @author Michal Kliment, Jiri Svitak, Ondřej Fibich
* Function to self-registration of candidates about membership (applicants)
*/
function index()
......
$country_model = new Country_Model();
$arr_countries = $country_model->select_list('id', 'country_name');
$phone_prefixes = $country_model->select_country_list();
$form = new Forge(url_lang::base()."registration", '', 'POST', array('id' => 'article_form'));
......
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('required|length[1,50]|valid_numeric');
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns);
$form->dropdown('country_id')->label(url_lang::lang('texts.Country').':')->rules('required')->options($arr_countries)->selected(Settings::get('default_country'));
$form->group('')->label(url_lang::lang('texts.Contact information'));
$form->group('')->label(url_lang::lang('texts.Contact information'));
$form->dropdown('phone_prefix')->label(url_lang::lang('texts.Telephone prefix').':')->rules('required')->options($phone_prefixes)->selected(Settings::get('default_country'));
$form->input('phone')->label(url_lang::lang('texts.phone').':')->rules('required|length[9,40]')->callback(array($this, 'valid_phone'));
$form->input('email')->label(url_lang::lang('texts.email').':')->rules('length[3,50]|valid_email')->callback(array($this, 'valid_email'));
......
if($form->validate())
{
$form_data = $form->as_array();
foreach($form_data as $key => $value)
{
$form_data[$key] = htmlspecialchars($value);
}
$user = new User_Model;
$member = new Member_Model;
$enum_type = new Enum_type_Model();
$user->login = $form_data['login'];
$user->password = sha1($form_data['passwd']);
$user->name = $form_data['name'];
$user->middle_name = $form_data['middle_name'];
$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->phone = $form_data['phone'];
$user->email = $form_data['email'];
$user->type = User_Model::$member;
try
{
// start transaction
$user->transaction_start();
// 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;
$address_point_model = new Address_point_Model();
$address_point = $address_point_model->get_address_point($form_data['town_id'],$form_data['street_id'],$form_data['street_number']);
$form_data = $form->as_array();
foreach($form_data as $key => $value)
{
$form_data[$key] = htmlspecialchars($value);
}
// address point doesn't exist exist, create it
if (!$address_point || !$address_point->id)
{
$address_point->clear();
$member = new Member_Model;
$enum_type = new Enum_type_Model();
$address_point->country_id = $form_data['country_id'];
$address_point->town_id = $form_data['town_id'];
$address_point->street_id = $form_data['street_id'];
$address_point->street_number = $form_data['street_number'];
$address_point->gps = '';
$user->login = $form_data['login'];
$user->password = sha1($form_data['passwd']);
$user->name = $form_data['name'];
$user->middle_name = $form_data['middle_name'];
$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->type = User_Model::$member;
$address_point->save();
// 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;
$address_point_model = new Address_point_Model();
$address_point = $address_point_model->get_address_point($form_data['town_id'],$form_data['street_id'],$form_data['street_number']);
// address point doesn't exist exist, create it
if (!$address_point || !$address_point->id)
{
$address_point->clear();
$address_point->country_id = $form_data['country_id'];
$address_point->town_id = $form_data['town_id'];
$address_point->street_id = $form_data['street_id'];
$address_point->street_number = $form_data['street_number'];
$address_point->gps = '';
$address_point->save_throwable();
}
$member->name = ($form_data['membername'] != '') ? $form_data['membername'] : $user->name.' '.$user->surname;
$member->address_point_id = $address_point->id;
$member->type = $enum_type->get_type_id('Applicant');
$member->organization_identifier = $form_data['organization_identifier'];
$member->entrance_fee = $entrance_fee;
$member->save_throwable();
$user->member_id = $member->id;
$user->save_throwable();
// telephone
$contact = new Contact_Model();
$contact->type = Contact_Model::TYPE_PHONE;
$contact->value = $form_data['phone'];
$contact->save_throwable();
$contact->add($user);
$contact->save_throwable();
$phone_country = new Country_Model($form_data['phone_prefix']);
$contact->add($phone_country);
$contact->save_throwable();
$contact->clear();
// email
if (! empty($form_data['email']))
{
$contact->type = Contact_Model::TYPE_EMAIL;
$contact->value = $form_data['email'];
$contact->save_throwable();
$contact->add($user);
$contact->save_throwable();
}
$account = new Account_Model();
$account->member_id = $member->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'];
$account->save_throwable();
// access rights of expectant for membership (wannabe - aro group 23)
Controller::insert_phpgacl($user->id, $user->surname.' '.$user->name, $user->type, 'wannabe');
// commit transaction
$user->transaction_commit();
url::redirect(url_lang::base().'login');
}
$member->name = ($form_data['membername'] != '') ? $form_data['membername'] : $user->name.' '.$user->surname;
$member->address_point_id = $address_point->id;
$member->type = $enum_type->get_type_id('Applicant');
$member->organization_identifier = $form_data['organization_identifier'];
$member->entrance_fee = $entrance_fee;
$member_saved = $member->save();
$user->member_id = $member->id;
$user_saved = $user->save();
$account = new Account_Model();
$account->member_id = $member->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'];
$account->save();
// access rights of expectant for membership (wannabe - aro group 23)
Controller::insert_phpgacl($user->id, $user->surname.' '.$user->name, $user->type, 'wannabe');
url::redirect(url_lang::base().'login');
catch (Exception $ex)
{
$this->session->set_flash('message', url_lang::lang('texts.Cannot complete registration.'));
$user->transaction_rollback();
}
}
$view = new View('registration');
freenetis/branches/testing/application/controllers/forgotten_password.php
$form_data[$key] = htmlspecialchars($value);
}
/* @var $user User_Model */
$user = ORM::factory('user')->where('login', $form_data['login'])->find();
$msg_err_email = '<b>'.url_lang::lang('texts.Login or e-mail do not match with data in information system').'.'.'</b>';
......
}//if login was found and method is email
else if ($form_data['method'] == self::$METHOD_EMAIL)
{
if ($user->email == $form_data['email'] && $user->email != '')
if ($user->email_exist($form_data['email'], $user->id))
{
$hash = text::random('numeric', 10);
......
}//if login was found and method is SMS
else if ($form_data['method'] == self::$METHOD_SMS)
{
/* Users phone has been disabled in database - look at contacts table
if ($user->phone == $form_data['phone'] && $user->phone != '')
{
$hash = text::random('numeric', 10);
//TODO - sms sending...
url::redirect(url_lang::base().'forgotten_password?method=phone');
}
*/
}
freenetis/branches/testing/application/controllers/members.php
$user_grid->order_field('name','name')->label(url_lang::lang('texts.Name'));
$user_grid->order_field('surname','surname')->label(url_lang::lang('texts.Surname'));
$user_grid->order_field('login','login')->label(url_lang::lang('texts.Username'));
$user_grid->order_field('email','email')->label('E-mail');
if($this->acl_check_view('Users_Controller','users',$member_id))
$user_grid->action_field('id') ->label(url_lang::lang('texts.User'))->url(url_lang::base().'users/show')->action(url_lang::lang('texts.Show'));
if($this->acl_check_edit('Users_Controller','users') || ($this->session->get('user_type') == User_Model::$member && $this->acl_check_edit('Users_Controller','users',$member_id)))
......
}
asort($arr_towns, SORT_LOCALE_STRING);
$country_model = new Country_Model();
$phone_prefixes = $country_model->select_country_list();
// form
$form = new Forge(url::base().url::current(TRUE), '', 'POST', array('id' => 'article_form'));
$form->set_attr('class', 'form_class')->set_attr('method', 'post');
......
$form->input('street_number')->label(url_lang::lang('texts.street number').':')->rules('required|length[1,50]|valid_numeric');
$form->dropdown('town_id')->label(url_lang::lang('texts.town').':')->rules('required')->options($arr_towns)->add_button('towns');
$form->group('')->label(url_lang::lang('texts.Contact information'));
$form->dropdown('phone_prefix')->label(url_lang::lang('texts.Telephone prefix').':')->rules('required')->options($phone_prefixes)->selected(Settings::get('default_country'));
$form->input('phone')->label(url_lang::lang('texts.phone').':')->rules('required|length[9,40]')->callback(array($this, 'valid_phone'));
$form->input('email')->label(url_lang::lang('texts.email').':')
->rules('length[3,50]|valid_email')
......
{
$form_data[$key] = htmlspecialchars($value);
}
$member = new Member_Model();
try
{
$member = new Member_Model();
// let's start safe transaction processing
$member->transaction_start();
$user = new User_Model();
......
$user->pre_title = $form_data['title1'];
$user->post_title = $form_data['title2'];
$user->birthday = date("Y-m-d",$form_data['birthday']);
$user->phone = $form_data['phone'];
$user->email = $form_data['email'];
$user->password = sha1($form_data['password']);
$user->type = User_Model::$member;
$user->application_password = security::generate_password();
......
$member->entrance_fee = $form_data['entrance_fee'];
$member->debt_payment_rate = $form_data['debt_payment_rate'];
// saving member
if (!$member->save())
throw new Exception();
$member->save_throwable();
// saving user
$user->member_id = $member->id;
if (!$user->save())
throw new Exception();
$user->save_throwable();
// telephone
$contact = new Contact_Model();
$contact->type = Contact_Model::TYPE_PHONE;
$contact->value = $form_data['phone'];
$contact->save_throwable();
$contact->add($user);
$contact->save_throwable();
$phone_country = new Country_Model($form_data['phone_prefix']);
$contact->add($phone_country);
$contact->save_throwable();
$contact->clear();
// email
if (! empty($form_data['email']))
{
$contact->type = Contact_Model::TYPE_EMAIL;
$contact->value = $form_data['email'];
$contact->save_throwable();
$contact->add($user);
$contact->save_throwable();
}
// saving account
$account->member_id = $member->id;
if (!$account->save())
throw new Exception();
$account->save_throwable();
// insert regular member access rights
Controller::insert_phpgacl($user->id,$user->surname.' '.$user->name,$user->login, $form_data['type']);
unset($form_data);
......
$user_model = new User_Model();
$user = $user_model->where('member_id',$member_id)->where('type',User_Model::$member)->find();
$email = $user->email;
$emails = $user->get_user_emails($user->id);
$email = '';
if ($emails)
{
$email = $emails->current()->email;
}
$birthday = date::pretty($user->birthday);
$enum_type_model = new Enum_type_Model();
freenetis/branches/testing/application/upgrade_sql/upgrade_sql.php
return $svnid;
}
//////////////////////////////////////////////////////////////////////////////
// Remove phone, email columns in users table with transformation of data
// to the table contacts and its relationms tables
// @author Ondřej Fibich
//////////////////////////////////////////////////////////////////////////////
function upgrade_sql_before()
{
$contact = new Contact_Model();
$default_country = new Country_Model(Settings::get('default_country'));
if (!$default_country || !$default_country->id)
{
return false;
}
try
{
// transaction
$contact->transaction_start();
$users = ORM::factory('user')->find_all();
foreach ($users as $user)
{
$email = $user->email;
$phone = $user->phone;
////////////////////////////////////////////////////////
// EMAIL
// is there something to add?
if (!empty($email))
{
$contact_id = $contact->find_contact_id(
Contact_Model::TYPE_EMAIL, $email
);
// contact is not in database?
if (!$contact_id)
{
// clear contact
$contact->clear();
// add contact
$contact->type = Contact_Model::TYPE_EMAIL;
$contact->value = $email;
$contact->save_throwable();
// add relation between user and email
$user->add($contact);
$user->save_throwable();
}
else
{
$contact = $contact->find($contact_id);
// is already users contact?
if (!$contact->is_users_contact($user->id))
{
// add relation between user and email
$user->add($contact);
$user->save_throwable();
}
}
// add relation between user and email
$user->add($contact);
$user->save_throwable();
}
////////////////////////////////////////////////////////
// PHONE
// is there something to add?
if (!empty($phone))
{
$contact_id = $contact->find_contact_id(
Contact_Model::TYPE_PHONE, $phone
);
// contact is not in database?
if (!$contact_id)
{
$prefix = false;
// clear contact
$contact->clear();
// has prefix?
if (mb_strlen($phone) > 9)
{
$prefix = $contact->find_phone_country_code($phone);
// remove prefix
$phone = mb_substr(mb_strlen($prefix));
}
// add contact
$contact->type = Contact_Model::TYPE_PHONE;
$contact->value = $phone;
$contact->save_throwable();
// add country
if ($prefix)
{ // not default country
$country_id = $contact->find_phone_country($phone);
$country = new Country_Model($country_id);
$contact->add($country);
}
else
{
$contact->add($default_country);
}
$user->save_throwable();
// add relation between user and phone
$user->add($contact);
$user->save_throwable();
}
else
{
$contact = $contact->find($contact_id);
// is already users contact?
if (!$contact->is_users_contact($user->id))
{
// add relation between user and email
$user->add($contact);
$user->save_throwable();
}
}
}
}
// commit
$contact->transaction_commit();
}
catch (Exception $e)
{
$contact->transaction_rollback();
return false;
}
return true;
}
// array of sql queries that upgrade database
$upgrade_sql[get_SVN_rev()] = array(
"DROP VIEW `account_balances` ,
`account_inbounds` ,
`account_outbounds` ;",
// delete phone column
"ALTER TABLE users DROP phone",
"ALTER TABLE `accounts` ADD `balance` DOUBLE NULL DEFAULT '0' COMMENT 'Account balance, value is updated with respect to transfers of account' AFTER `account_attribute_id` "
// delete emial column
"ALTER TABLE users DROP email"
);
?>
freenetis/branches/testing/application/upgrade_sql/upgrade_sql_819.php
<?php
$upgrade_sql[819] = array(
"DROP VIEW `account_balances` ,
`account_inbounds` ,
`account_outbounds` ;",
"ALTER TABLE `accounts` ADD `balance` DOUBLE NULL DEFAULT '0' COMMENT 'Account balance, value is updated with respect to transfers of account' AFTER `account_attribute_id` "
);
?>
freenetis/branches/testing/application/views/registration.php
<div id="main-padd">
<div id="content">
<h2><?php echo $title ?></h2>
<?php echo isset($message) ? '<div class="message">'.$message.'</div>' : '' ?>
<?php echo $form ?>
<p><?php echo html::anchor(url_lang::base().'login', '&laquo; '.url_lang::lang('texts.back to login')) ?></p>
freenetis/branches/testing/application/views/members_show.php
<tr>
<th colspan="2"><?php echo url_lang::lang('texts.Contact information') ?></th>
</tr>
<?php if ($this->acl_check_view('Users_Controller', 'application_password', $member_data->member_id)) { ?>
<tr>
<th><?php echo url_lang::lang('texts.Application password').'&nbsp;'.help::hint('application_password') ?></th>
<td><?php echo $member_data->application_password ?></td>
</tr>
<?php } ?>
<?php foreach ($contacts as $i => $contact):?>
<tr>
<?php if ($contact->type == Contact_Model::TYPE_PHONE): ?>
<th><table class="picturebox"><tr>
<td><?php echo url_lang::lang('texts.Phone') ?></td>
<td>
<?php
if ($this->acl_check_2D('freenetis', 'write_email') && valid::phone_cs_CZ($contact->value))
echo html::anchor(url_lang::base().'sms/send/'.$contact->value, html::image(array('src' => resource::sms('send-small'), 'alt' => url_lang::lang('texts.Send SMS'), 'title' => url_lang::lang('texts.Send SMS'))), array('title' => url_lang::lang('texts.Send SMS')));
?>
</td></tr></table></th>
<td><?php echo $contact->value ?></td>
<?php elseif ($contact->type == Contact_Model::TYPE_EMAIL): ?>
<th>
<table class="picturebox">
<tr>
<td>E-mail</td>
<td><?php echo url_lang::lang('texts.E-mail') ?></td>
<td>
<?php if ($this->acl_check_2D('freenetis', 'write_email'))
if (valid::email($member_data->email))
{
echo form::open(url_lang::base().'email') ;
echo form::hidden('email_member_id', $member_data->member_id );
echo form::hidden('address', $member_data->email );
echo form::imagebutton('submit', url::base().'media/images/email.png', array('title' => url_lang::lang('texts.Send e-mail'), 'style' => 'width:22px; height:22px; border-width: 0px 0px 0px 0px; border-spacing: 0px;'));
echo form::close();
}
<?php
if ($this->acl_check_2D('freenetis', 'write_email') && valid::email($contact->value))
{
echo form::open(url_lang::base().'email') ;
echo form::hidden('email_member_id', $member_data->member_id );
echo form::hidden('address', $contact->value );
echo form::imagebutton('submit', url::base().'media/images/email.png', array('title' => url_lang::lang('texts.Send e-mail'), 'style' => 'width:22px; height:22px; border-width: 0px 0px 0px 0px; border-spacing: 0px;'));
echo form::close();
}
?>
</td>
</tr>
</td>
</tr>
</table>
</th>
<td><?php echo $member_data->email ?></td>
</tr>
<tr>
<th>
<table class="picturebox"><tr>
<td><?php echo url_lang::lang('texts.Phone') ?></td>
<td>
<?php if ($this->acl_check_2D('freenetis', 'write_email'))
if (valid::phone_cs_CZ($member_data->phone))
{
echo html::anchor(url_lang::base().'sms/send/'.$member_data->phone, html::image(array('src' => resource::sms('send-small'), 'alt' => url_lang::lang('texts.Send SMS'), 'title' => url_lang::lang('texts.Send SMS'))), array('title' => url_lang::lang('texts.Send SMS')));
}
?>
</td>
</tr>
</table>
</th>
<td><?php echo $member_data->phone ?></td>
</tr>
<?php if ($this->acl_check_view('Users_Controller', 'application_password', $member_data->member_id)) { ?>
<tr>
<th><?php echo url_lang::lang('texts.Application password').'&nbsp;'.help::hint('application_password') ?></th>
<td><?php echo $member_data->application_password ?></td>
</tr>
<?php } ?>
<?php foreach ($contacts as $i => $contact):?>
<tr>
<td><?php echo $contact->value ?></td>
<?php else: ?>
<th><?php echo $contact_types[$i] ?></th>
<td><?php echo $contact->value ?></td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
<?php if ($this->acl_check_view('Users_Controller', 'additional_contacts') || ($member_data->id == $this->session->get('user_id') && $this->acl_check_view('Users_Controller', 'additional_contacts', $member_data->member_id))) { ?>
freenetis/branches/testing/application/views/users/additional_contacts_show_all.php
<script type="text/javascript">
$(document).ready(function() {
$('a.delete').click(function () {
return window.confirm('<?php echo url_lang::lang('texts.Do you really want to delete this record') ?>?');
});
});
</script>
<?php echo $message ? '<div class="message">'.$message.'</div>' : '' ?>
<h2><?php echo url_lang::lang('texts.User contacts'); ?></h2><br />
......
<?php if ($can_add) echo html::anchor(url_lang::base().'users/additional_contacts/add/'.$user_id, url_lang::lang('texts.Add contact')) . "<br /><br />" ?>
<?php echo $grid_contacts; ?>
<?php if (! empty($grid_private_contacts)): ?><br /><br />
<br /><br />
<h2><?php echo url_lang::lang('texts.Private user contacts'); ?></h2><br />
<p><?php echo url_lang::lang('texts.Private phone contacts of user, which are used in telephone invoices'); ?>.</p>
<p><?php echo url_lang::lang('texts.Contacts can be added in telephone invoices.'); ?>.</p><br />
<?php echo html::anchor(url_lang::base().'private_phone_contacts/import/'.$user_id, url_lang::lang('texts.Import contact from server Funanbol')) ?>
<?php if (! empty($grid_private_contacts)): ?>
<br /><br />
<?php echo $grid_private_contacts; ?>
<?php endif; ?>
freenetis/branches/testing/application/views/users_show.php
<tr>
<th colspan="2"><?php echo url_lang::lang('texts.Contact information') ?></th>
</tr>
<tr>
<th>E-mail</th>
<td><?php echo $user_data->email ?></td>
</tr>
<tr>
<th><?php echo url_lang::lang('texts.Phone') ?></th>
<td><?php echo $user_data->phone ?></td>
</tr>
<?php foreach ($contacts as $i => $contact):?>
<tr>
<th><?php echo $contact_types[$i] ?></th>

Také k dispozici: Unified diff