Revize 1744
Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)
freenetis/branches/1.1/application/helpers/callback.php | ||
---|---|---|
* @param type $name
|
||
* @param type $args
|
||
*/
|
||
public function not_empty($item, $name, $args = array())
|
||
public static function not_empty($item, $name, $args = array())
|
||
{
|
||
if ($item->$name === NULL)
|
||
{
|
||
... | ... | |
* @param type $item
|
||
* @param type $name
|
||
*/
|
||
public function port_mode_field($item, $name)
|
||
public static function port_mode_field($item, $name)
|
||
{
|
||
echo Iface_Model::get_port_mode($item->port_mode);
|
||
}
|
freenetis/branches/1.1/application/models/contact.php | ||
---|---|---|
/**
|
||
* Search for relation between users and countacts (users_contacts)
|
||
*
|
||
* @param integer $contact_id
|
||
* @return integer Number of relation
|
||
*/
|
||
public function count_all_users_contacts_relation()
|
||
public function count_all_users_contacts_relation($contact_id = NULL)
|
||
{
|
||
if (!$this->id)
|
||
if ($contact_id == NULL && $this)
|
||
{
|
||
return 0;
|
||
$contact_id = $this->id;
|
||
}
|
||
|
||
return $this->db->query("
|
||
SELECT COUNT(contact_id) AS count
|
||
FROM users_contacts
|
||
WHERE contact_id = ?
|
||
", $this->id, $this->id)->current()->count;
|
||
", $contact_id)->current()->count;
|
||
}
|
||
|
||
/**
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Find for contacts
|
||
*
|
||
* @param string $type Type of contact
|
||
* @param string $value Value of contact
|
||
* @return Mysql_Result
|
||
*/
|
||
public function find_contacts($type, $value)
|
||
{
|
||
return $this->db->query("
|
||
SELECT c.*
|
||
FROM contacts c
|
||
WHERE c.type = ? AND c.value = ?
|
||
", $type, $value);
|
||
}
|
||
|
||
/**
|
||
* Gets prefix of phone country code
|
||
*
|
||
* @author Ondřej Fibich
|
freenetis/branches/1.1/application/controllers/contacts.php | ||
---|---|---|
{
|
||
Controller::error(RECORD);
|
||
}
|
||
|
||
$this->_contact_id = NULL;
|
||
|
||
$contact_model = new Contact_Model($contact_id);
|
||
$country_model = new Country_Model();
|
||
... | ... | |
|
||
if ($form->validate())
|
||
{
|
||
if ($contact_model->value != $form->value->value &&
|
||
$contact_model->find_contact_id(
|
||
$contact_model->type, $form->value->value
|
||
))
|
||
$contact_model->value = $form->value->value;
|
||
|
||
if ($contact_model->save())
|
||
{
|
||
status::warning('Contact is already in database');
|
||
status::success('Additional contacts have been successfully updated');
|
||
}
|
||
else
|
||
{
|
||
$issaved = TRUE;
|
||
|
||
$contact_model->value = $form->value->value;
|
||
$issaved = $issaved && $contact_model->save();
|
||
|
||
if ($issaved)
|
||
{
|
||
status::success('Additional contacts have been successfully updated');
|
||
}
|
||
else
|
||
{
|
||
status::error('Error - cant update additional contacts');
|
||
}
|
||
status::error('Error - cant update additional contacts');
|
||
}
|
||
|
||
$this->redirect('contacts/show_by_user/',$user_id);
|
||
... | ... | |
$contact_model = new Contact_Model();
|
||
|
||
// search for contacts
|
||
$contact_id = $contact_model->find_contact_id(
|
||
$type, trim($input->value)
|
||
);
|
||
|
||
if ($contact_id && $contact_id != $this->_contact_id)
|
||
$duplicip_contacts = $contact_model->find_contacts($type, trim($input->value));
|
||
|
||
foreach ($duplicip_contacts as $c)
|
||
{
|
||
$contact_model = ORM::factory('contact', $contact_id);
|
||
if ($contact_model->count_all_users_contacts_relation() > 0)
|
||
if ($c->id && ($c->id != $this->_contact_id))
|
||
{
|
||
$input->add_error('required', __('Contact is already in database'));
|
||
if ($contact_model->count_all_users_contacts_relation($c->id) > 0)
|
||
{
|
||
$input->add_error('required', __('Contact is already in database'));
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
Také k dispozici: Unified diff
Opravy:
- #380: opet nelze pridat tel.c. - chyba ve validatorech
- #381: vadne validatory u tel. cisel