Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1862

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

Novinky:
- fixes #461: Mazani emailu (pomoci filtru)
- ORM#truncate pro vyprazdneni tabulky

Zobrazit rozdíly:

freenetis/branches/1.1/application/i18n/cs_CZ/texts.php
$lang = array
(
'%d prefix already in database' => '%d předčíslí se již nachází v databázi',
'%d sended e-mails has been deleted' => '%d poslaných emailových zpráv bylo smazáno.',
'%d unsended e-mails has been deleted' => '%d neposlaných emailových zpráv bylo smazáno.',
'%d unsended sms messages has been deleted' => '%d neposlaných SMS zpráv bylo smazáno.',
'%s days ago' => 'před %s dny',
......
'delete_member' => 'Smazat tohoto člena',
'delete_work' => 'Smazat tuto práci',
'delete' => 'Smazat',
'delete all filtered e-mails' => 'Smazat všechny vyfiltrované e-maily',
'delete all records' => 'Smazat všechny záznamy',
'delete all unsended e-mails' => 'Smazat všechny neodeslané emaily',
'delete device' => 'Smazat zařízení',
......
'do export' => 'Exportuj',
'do transfer' => 'Proveď transakci',
'do you really want to activate notifications' => 'Chcete opravdu aktivovat upozornění?',
'do you really want to delete these' => 'Chcete opravdu smazat smazat těchto',
'do you really want to delete this record' => 'Chcete opravdu smazat tento záznam',
'do you really want to end editing of registrations' => 'Chcete opravdu ukončit editaci přihlášek?',
'do you really want to reject this request' => 'Chcete opravdu zamítnout tento požadavek',
freenetis/branches/1.1/application/models/email_queue.php
}
/**
* Returns all sent e-mails for export
*
* @param string $filter_sql
* @return Mysql_Result
*/
public function delete_sent_emails($filter_sql = '')
{
// filter
$where = '';
if (!empty($filter_sql))
$where = "WHERE $filter_sql";
// cannot select from deleted table, so.. two step function
$ids = $this->db->query("
SELECT eq.id
FROM
(
SELECT eq.*, fuc.user_id AS from_user_id,
CONCAT(fu.name,' ',fu.surname) AS from_user_name,
tuc.user_id AS to_user_id,
CONCAT(tu.name,' ',tu.surname) AS to_user_name
FROM email_queues eq
LEFT JOIN contacts fc ON eq.from = fc.value AND fc.type = ?
LEFT JOIN users_contacts fuc ON fc.id = fuc.contact_id
LEFT JOIN users fu ON fuc.user_id = fu.id
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 = ?
) eq
$where
", array
(
Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL,
self::STATE_OK
))->as_array();
$pids = array();
foreach ($ids as $id)
{
$pids[] = $id->id;
}
$this->db->query("
DELETE FROM email_queues WHERE id IN (" . implode(',', $pids) . ")
");
}
/**
* Returns all unsent e-mails
*
* @author Michal Kliment
freenetis/branches/1.1/application/controllers/email_queues.php
);
$grid->add_new_button(
'email_queues/delete_unsended', __('Delete all unsended e-mails')
'email_queues/delete_unsent', __('Delete all unsended e-mails')
);
// database columns
......
);
$grid->add_new_button(
'export/csv/email_queue_sent' . server::query_string(),
'email_queues/delete_sent' . server::query_string(),
__('Delete all filtered e-mails'), array
(
'id' => 'delete_sent_link',
'ref' => $total_emails
)
);
$grid->add_new_button(
'export/csv/email_queue_sent' . server::query_string(),
'Export to CSV', array
(
'title' => __('Export to CSV'),
......
*
* @author Ondřej Fibich
*/
public function delete_unsended()
public function delete_unsent()
{
// access
if (!$this->acl_check_view('Settings_Controller', 'system'))
if (!$this->acl_check_delete('Settings_Controller', 'system'))
{
Controller::error(ACCESS);
}
......
// send notification
status::success('%d unsended e-mails has been deleted.', TRUE, $count);
// redirects
url::redirect('email_queues/show_all_unsent');
}
/**
* Deletes filtered sent emails
*
* @author Ondřej Fibich
*/
public function delete_sent()
{
// access
if (!$this->acl_check_delete('Settings_Controller', 'system'))
{
Controller::error(ACCESS);
}
// filter load
$f = new Filter_form();
$f->autoload();
$fsql = $f->as_sql();
// model
$eq_model = new Email_queue_Model();
// count first
$count = $eq_model->count_all_sent_emails($fsql);
// delete all
if ($eq_model->count_all() == $count)
{
$eq_model->truncate();
}
// delete filtered
else
{
$eq_model->delete_sent_emails($fsql);
}
// send notification
status::success('%d sended e-mails has been deleted.', TRUE, $count);
// redirects
url::redirect('email_queues/show_all_sent');
}
freenetis/branches/1.1/application/views/js/email_queues_show_all_sent.php
<?php
/**
* Sent e-mails show javascript view.
*
* @author Ondřej Fibich
*/
// IDE complementation
if (FALSE): ?><script type="text/javascript"><?php endif
?>
// confirmation before deletion
$('#delete_sent_link').click(function ()
{
var m = '<?php echo __('Do you really want to delete these') ?> ';
m += $(this).attr('ref'); // count of e-mails
m += ' <?php echo __('e-mails', array(), 1) ?>?';
return window.confirm(m);
});
freenetis/branches/1.1/system/libraries/ORM.php
}
/**
* Truncate table content
*
* @author Ondřej Fibicho
*/
public function truncate()
{
$this->db->query("
TRUNCATE `$this->table_name`
");
}
/**
* Returns the last query run.
*
* @author Ondřej Fibich

Také k dispozici: Unified diff