Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 822

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

ORM:
- Pridana metoda save_throwable(), ktera pri chybe ukladani vyhodi vyjimku. (Doporuceno pouzivat u databazovych transakci)
Funanbol import kontaktu:
- Optimalizace rychlosti javascriptu pri importu (Problem s mnoha uzivateli v databazi, ovlivnujici vykon javascriptu).

Zobrazit rozdíly:

freenetis/branches/testing/application/controllers/private_phone_contacts.php
{
$contact->type = Contact_Model::TYPE_PHONE;
$contact->value = $number_short;
if (!$contact->save())
{
throw new Exception();
}
$contact->save_throwable();
// add country of phone number
if ($country != NULL)
{
$contact->add($country);
if (!$contact->save())
{
throw new Exception();
}
$contact->save_throwable();
}
$contact_id = $contact->id;
}
......
$private_user_contact->contact_id = $contact_id;
$private_user_contact->user_id = $user_id;
$private_user_contact->description = $im_name;
if (!$private_user_contact->save())
{
throw new Exception();
}
$private_user_contact->save_throwable();
$private_user_contact->clear();
// output
$output[] = array (
......
$realations = $contact->count_all_users_contacts_relation();
if ($realations == 0)
{ // add relation
if (!$contact->add($user_model) || !$contact->save())
{
throw new Exception();
}
$contact->add($user_model);
$contact->save_throwable();
// output
$output[] = array (
'id' => $index,
......
{ // add whole contact
$contact->type = Contact_Model::TYPE_PHONE;
$contact->value = $number_short;
if (!$contact->save())
{
throw new Exception();
}
$contact->save_throwable();
if (!$contact->add($user_model) || !$contact->save())
{
throw new Exception();
}
$contact->add($user_model);
$contact->save_throwable();
if ($country != NULL && (!$contact->add($country) || !$contact->save()))
if ($country != NULL)
{
throw new Exception();
$contact->add($country);
$contact->save_throwable();
}
}
}
freenetis/branches/testing/application/views/users/contacts_import.php
// lock form
$(this).hide();
input.attr('disabled', 'disabled');
input.attr('readonly', 'readonly');
// data
var contact;
......
var id = responseJSON.success[i].id;
var status = responseJSON.success[i].status;
// zero is empty string
if (id == 0)
{
id = '0';
}
if (status % 2 == 0)
{ // saved
$('#td_delete_'+id).html('<?php echo html::image(array(
......
<td>\
<input name="im_private['+count+']" type="checkbox" value="1" \
class="checkbox" checked="checked" onchange="im_change(this)" />\
<select name="im_contact['+count+']" disabled="disabled">' +
users_names_options + '</select>\
<select name="im_contact['+count+']" disabled="disabled" style="display: none;"></select>\
</td>\
<?php else: ?>\
<input name="im_private['+count+']" type="hidden" value="1" />\
......
if (checkbox.attr('checked'))
{
selectbox.attr('disabled', 'disabled');
selectbox.hide();
username.removeAttr('readonly');
}
else
......
// foreach username
for (var i = 0; i < users_names.length; i++)
{
// is selectbox empty?
if (selectbox.children().length <= 0)
{ // add options
selectbox.html(users_names_options);
}
// starts with?
if (users_names[i][1].match('^' + username.val()))
{
......
}
// enable
selectbox.removeAttr('disabled');
selectbox.show();
}
}
}
freenetis/branches/testing/system/libraries/ORM.php
$this->is_in_transaction = false;
}
/**
* Saves the current object.
*
* @author Ondřej Fibich
* @chainable
* @return ORM
* @throws Kohana_Database_Exception If save was not successful.
*/
public function save_throwable()
{
$return_obj = $this->save();
if (!$return_obj || $return_obj->saved != true)
{
throw new Kohana_Database_Exception('ORM - Cannot save object.');
}
return $return_obj;
}
} // End ORM

Také k dispozici: Unified diff