# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /home/dzolo/Projects/FreenetIS/freenetis-stable
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: application/controllers/contacts.php
--- application/controllers/contacts.php Base (BASE)
+++ application/controllers/contacts.php Locally Modified (Based On LOCAL)
@@ -599,7 +599,19 @@
else
{
$contact_model = new Contact_Model();
-
\ No newline at end of file
+
+ // 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;
+ }
+
\ No newline at end of file
// search for contacts
$duplicip_contacts = $contact_model->find_contacts($type, trim($input->value));
Index: application/controllers/members.php
--- application/controllers/members.php Base (BASE)
+++ application/controllers/members.php Locally Modified (Based On LOCAL)
@@ -2522,6 +2522,7 @@
$form->input('email')
->rules('valid_email')
+ ->callback(array($this, 'valid_unique_email'))
->style('width:250px');
if (Settings::get('finance_enabled'))
@@ -2813,13 +2814,13 @@
$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();
}
@@ -2842,11 +2843,25 @@
// 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
@@ -4532,19 +4547,44 @@
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.
*
Index: application/controllers/settings.php
--- application/controllers/settings.php Base (BASE)
+++ application/controllers/settings.php Locally Modified (Based On LOCAL)
@@ -774,6 +774,14 @@
$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');
Index: application/i18n/cs_CZ/texts.php
--- application/i18n/cs_CZ/texts.php Base (BASE)
+++ application/i18n/cs_CZ/texts.php Locally Modified (Based On LOCAL)
@@ -1039,6 +1039,8 @@
'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',
Index: application/libraries/Settings.php
--- application/libraries/Settings.php Base (BASE)
+++ application/libraries/Settings.php Locally Modified (Based On LOCAL)
@@ -257,6 +257,10 @@
// 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,}$/',
Index: application/models/email_queue.php
--- application/models/email_queue.php Base (BASE)
+++ application/models/email_queue.php Locally Modified (Based On LOCAL)
@@ -88,14 +88,14 @@
LEFT JOIN contacts tc ON eq.to = tc.value AND tc.type = ?
LEFT JOIN users_contacts tuc ON tc.id = tuc.contact_id
LEFT JOIN users tu ON tuc.user_id = tu.id
- WHERE eq.state = ?";
+ WHERE eq.state = ?
+ GROUP BY eq.id";
// filter
if (empty($filter_sql))
{
return $this->db->query("
$body
- GROUP BY eq.id
ORDER BY ".$this->db->escape_column($order_by)." $order_by_direction
LIMIT " . intval($limit_from) . "," . intval($limit_results) . "
", $args);
@@ -148,6 +148,7 @@
LEFT JOIN users_contacts tuc ON tc.id = tuc.contact_id
LEFT JOIN users tu ON tuc.user_id = tu.id
WHERE eq.state = ?
+ GROUP BY eq.id
$having
", array
(
@@ -190,6 +191,7 @@
LEFT JOIN users_contacts tuc ON tc.id = tuc.contact_id
LEFT JOIN users tu ON tuc.user_id = tu.id
WHERE eq.state = ?
+ GROUP BY eq.id
$having
) eq
", Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL, self::STATE_OK);
@@ -222,6 +224,7 @@
LEFT JOIN users_contacts tuc ON tc.id = tuc.contact_id
LEFT JOIN users tu ON tuc.user_id = tu.id
WHERE eq.state = ?
+ GROUP BY eq.id
$having
", array
(
@@ -275,6 +278,7 @@
LEFT JOIN users_contacts tuc ON tc.id = tuc.contact_id
LEFT JOIN users tu ON tuc.user_id = tu.id
WHERE eq.state <> ?
+ GROUP BY eq.id
$having
ORDER BY ".$this->db->escape_column($order_by)." $order_by_direction
LIMIT " . intval($limit_from) . "," . intval($limit_results) . "
@@ -317,7 +321,8 @@
LEFT JOIN contacts tc ON eq.to = tc.value AND tc.type = ?
LEFT JOIN users_contacts tuc ON tc.id = tuc.contact_id
LEFT JOIN users tu ON tuc.user_id = tu.id
- WHERE eq.state <> ?
+ WHERE eq.state <> ?
+ GROUP BY eq.id
$having
", array
(
Index: application/models/subnet.php
--- application/models/subnet.php Base (BASE)
+++ application/models/subnet.php Locally Modified (Based On LOCAL)
@@ -357,29 +357,6 @@
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.
Index: application/models/users_contacts.php
--- application/models/users_contacts.php Base (BASE)
+++ application/models/users_contacts.php Locally Modified (Based On LOCAL)
@@ -233,54 +233,6 @@
}
/**
- * 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.
*
Index: application/vendors/unit_tester/unit_testing_config.xml
--- application/vendors/unit_tester/unit_testing_config.xml Base (BASE)
+++ application/vendors/unit_tester/unit_testing_config.xml Locally Modified (Based On LOCAL)
@@ -4104,7 +4104,7 @@
-
+
@@ -12581,22 +12581,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -13612,21 +13596,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-