Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 2419

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

Novinky: refs #968: Volitelna kontrola duplicit v kontaktech
Opravy: Oprava tvorby duplicitnich e-mailu pri tvorbe clena

Zobrazit rozdíly:

freenetis/branches/1.2/application/controllers/contacts.php
else
{
$contact_model = new Contact_Model();
// do not search if duplicies enabled (#968)
if ($type == Contact_Model::TYPE_EMAIL &&
Settings::get('user_email_duplicities_enabled'))
{
return;
}
if ($type == Contact_Model::TYPE_PHONE &&
Settings::get('user_phone_duplicities_enabled'))
{
return;
}
// search for contacts
$duplicip_contacts = $contact_model->find_contacts($type, trim($input->value));
freenetis/branches/1.2/application/controllers/members.php
$form->input('email')
->rules('valid_email')
->callback(array($this, 'valid_unique_email'))
->style('width:250px');
if (Settings::get('finance_enabled'))
......
$contact_model = new Contact_Model();
// search for contacts
$contact_id = $contact_model->find_contact_id(
$p_contact_id = $contact_model->find_contact_id(
Contact_Model::TYPE_PHONE, $form_data['phone']
);
if ($contact_id)
if ($p_contact_id)
{
$contact_model = ORM::factory('contact', $contact_id);
$contact_model = ORM::factory('contact', $p_contact_id);
$contact_model->add($user);
$contact_model->save_throwable();
}
......
// 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();
// search for contacts
$e_contact_id = $contact_model->find_contact_id(
Contact_Model::TYPE_EMAIL, $form_data['email']
);
if ($e_contact_id)
{
$contact_model = ORM::factory('contact', $e_contact_id);
$contact_model->add($user);
$contact_model->save_throwable();
}
else
{ // add whole contact
$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
......
self::error(PAGE);
}
$user_model=new User_Model();
$user_model = new User_Model();
$value = trim($input->value);
if (!preg_match("/^[0-9]{9,9}$/",$value))
{
$input->add_error('required', __('Bad phone format.'));
}
else if ($user_model->phone_exist($value))
else if (!Settings::get('user_phone_duplicities_enabled') &&
$user_model->phone_exist($value))
{
$input->add_error('required', __('Phone already exists in database.'));
}
}
/**
* Check if non empty email is unique.
*
* @param object $input
*/
public function valid_unique_email($input = NULL)
{
// validators cannot be accessed
if (empty($input) || !is_object($input))
{
self::error(PAGE);
}
$user_model = new User_Model();
$value = trim($input->value);
// not required by default
if ($value && !Settings::get('user_email_duplicities_enabled') &&
$user_model->email_exist($value))
{
$input->add_error('required', __('Email already exists in database.'));
}
}
/**
* Entrance has to be before current date.
*
freenetis/branches/1.2/application/controllers/settings.php
$this->form->checkbox('former_member_auto_device_remove')
->label('Enable automatical deletion of devices of former members')
->checked(Settings::get('former_member_auto_device_remove'));
$this->form->checkbox('user_phone_duplicities_enabled')
->label('Enable multiple users to have assigned same phone contact')
->checked(Settings::get('user_phone_duplicities_enabled'));
$this->form->checkbox('user_email_duplicities_enabled')
->label('Enable multiple users to have assigned same e-mail contact')
->checked(Settings::get('user_email_duplicities_enabled'));
$this->form->group('Security');
freenetis/branches/1.2/application/i18n/cs_CZ/texts.php
'enable integrity test (all numbers in invoice has to be in extended statement)' => 'Povolit test na celistvost (každé číslo ve faktuře musí být v podrobném výpisu)',
'enable mysql event scheduler' => 'Povolit MySQL plánovač akcí',
'enable monitoring' => 'Povolit monitoring',
'enable multiple users to have assigned same phone contact' => 'Povolit aby více uživatelů mohlo mít přiřazen stejný telefonní kontakt',
'enable multiple users to have assigned same e-mail contact' => 'Povolit aby více uživatelů mohlo mít přiřazen stejný e-mail',
'enable notification by redirection' => 'Povolit upozornění přesměrováním',
'enable notification by e-mail' => 'Povolit upozornění e-mailem',
'enable notification by sms messages' => 'Povolit upozornění SMS zprávami',
freenetis/branches/1.2/application/libraries/Settings.php
// javascript is enabled by default
'use_javascript' => 1,
// contact duplicities
'user_email_duplicities_enabled' => FALSE,
'user_phone_duplicities_enabled' => FALSE,
// username regex #360
'username_regex' => '/^[a-z][a-z0-9_]{4,}$/',
freenetis/branches/1.2/application/models/subnet.php
WHERE s.network_address LIKE ? COLLATE utf8_general_ci
", "$ip_prefix%");
}
/**
* Function gets phone numbers and names of users of subnet to export address book.
*
* @author Lubomir Buben
* @param integer $subnet_id
* @return Mysql_Result
*/
public function get_phones_and_names_of_subnet($subnet_id)
{
return $this->db->query("
SELECT DISTINCT(co.value) as 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 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
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));
}
/**
* Function gets phone numbers of users of subnet.
freenetis/branches/1.2/application/models/users_contacts.php
}
/**
* Returns all contacts by given type
*
* @author Michal Kliment
* @param integer $type
* @param bool $ignore_whitelisted
* @return Mysql_Result
*/
public function get_all_contacts_by_type ($type, $ignore_whitelisted = FALSE)
{
$whitelisted = '';
if (!$ignore_whitelisted)
{
$whitelisted = "AND m.id NOT IN
(
SELECT mw.member_id
FROM members_whitelists mw
WHERE mw.since <= CURDATE() AND mw.until >= CURDATE()
)";
}
return $this->db->query("
SELECT c.value, a.balance, m.id AS member_id, m.name AS member_name,
(
SELECT GROUP_CONCAT(vs.variable_symbol) AS variable_symbol
FROM variable_symbols vs
WHERE vs.account_id = a.id
) AS variable_symbol, u.login, cou.country_code
FROM contacts c
JOIN users_contacts uc ON uc.contact_id = c.id
JOIN users u ON uc.user_id = u.id
JOIN members m ON u.member_id = m.id
JOIN accounts a ON a.member_id = m.id
LEFT JOIN contacts_countries cc ON cc.contact_id = c.id
LEFT JOIN countries cou ON cou.id = cc.country_id
WHERE m.type <> ? AND c.type = ? $whitelisted AND m.id NOT IN
(
SELECT mi.member_id
FROM membership_interrupts mi
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND
mf.deactivation_date >= CURDATE()
)
GROUP BY c.id
", array(Member_Model::TYPE_FORMER, $type));
}
/**
* Finds e-mail boxes of the given user on which the inner user mail may
* be redirected.
*
freenetis/branches/1.2/application/vendors/unit_tester/unit_testing_config.xml
<attributes/>
<values>
<input/>
<input>
<param type="post" name="login" value="unit_tester____"/>
<param type="post" name="password" value="qwertzuiop7"/>
......
</input>
</values>
</method>
<method name="get_phones_and_names_of_subnet" autogenerate="off">
<attributes>
<attribute name="subnet_id" default_value=""/>
</attributes>
<values>
<input>
<param value=""/>
</input>
<input>
<param value="1"/>
</input>
<input>
<param value="1'+1"/>
</input>
</values>
</method>
<method name="get_phones_of_subnet" autogenerate="off">
<attributes>
<attribute name="subnet_id" default_value=""/>
......
</method>
</model>
<model name="users_contacts">
<method name="get_all_contacts_by_type" autogenerate="on">
<attributes>
<attribute name="type" default_value="" />
<attribute name="ignore_whitelisted" default_value="FALSE" />
</attributes>
<values>
<input>
<param value="" />
</input>
<input>
<param value="" />
<param value="FALSE" />
</input>
</values>
</method>
<method name="get_redirected_email_boxes_of" autogenerate="on">
<attributes>
<attribute name="user_id" default_value="" />

Také k dispozici: Unified diff