Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1236

Přidáno uživatelem Michal Kliment před asi 13 roky(ů)

Vylepsena aktivace zprav pro vsechny cleny - nyni lze vybrat jestli se ma aktivovat pouze presmerovani, e-mal nebo oboji.

Zobrazit rozdíly:

freenetis/branches/testing/application/i18n/cs_CZ/texts.php
'action logs of user' => 'Logy akcí uživatele',
'actions' => 'Akce',
'activate' => 'Aktivovat',
'activate message for all members' => 'Aktivovat zprávu pro všechny členy',
'activate redirection' => 'Aktivovat přesměrování',
'activate redirection to member' => 'Aktivovat členovi přesměrování',
'activated number has not been changed' => 'Aktivované číslo již nelze změnit',
......
'changed values' => 'Změněné hodnoty',
'change voicemail password' => 'Změnit heslo hlasové schránky',
'channel' => 'Kanál',
'channel %s' => '%s. kanál',
'channel width' => 'Šířka kanálu',
'check again' => 'Znovu zkontrolovat',
'choose date' => 'Vyberte datum',
......
'confirmed by' => 'Potvrzeno od',
'confirmed time' => 'Čas potvrzení',
'confirmed works' => 'Potvrzené práce',
'connected to' => 'Připojeno k',
'connecting place' => 'Přípojné místo',
'connections' => 'Připojení',
'constant symbol' => 'Konstantní symbol',
......
'norm' => 'Norma',
'normal' => 'normální',
'not assigned' => 'Nepřiřazeno',
'not connected' => 'Nepřipojeno',
'not registered' => 'Neregistrovaný',
'not filled in' => 'Nevyplněno',
'not found' => 'Nenalezeno',
......
'select area' => 'Vyber oblast',
'select area prefix' => 'Vyber prefix oblasti',
'select cloud' => 'Vyber oblast',
'select channel' => 'Vyber kanál',
'select destination web' => 'Vyber cíl přesměrování',
'select device' => 'Vyber zařízení',
'select duration' => 'Vyber trvání přesměrování',
'select fee' => 'Vyber poplatek',
'select fee type' => 'Vyber typ poplatku',
'select free subnet' => 'Vyber volnou podsíť',
'select frequency' => 'Vyber frekvenci',
'select interface' => 'Vyber rozhraní',
'select medium' => 'Vyber médium',
'select member' => 'Vyber člena',
......
'whole d' => 'Celé z.',
'without change' => 'Beze změny',
'wireless' => 'bezdrátové',
'wireless interfaces' => 'Bezdrátová rozhraní',
'work' => 'Práce',
'work approval' => 'Schválení práce',
'work confirmation' => 'Potvrzení práce',
freenetis/branches/testing/application/models/message.php
* @param integer $debtor_boundary
* @return int
*/
public function activate_debtor_message($user_id, $debtor_boundary)
public function activate_debtor_message($user_id, $debtor_boundary, $redirection, $email)
{
// user id
$user_id = intval($user_id);
......
$ip_count = 0;
// delete old redirections
$database = Database::instance();
$database->delete('messages_ip_addresses', array('message_id' => $message->id));
// finding IP addresses to redirect to debtor message
$ip_model = new Ip_address_Model();
$ips = $ip_model->get_ip_addresses_of_debtors($debtor_boundary);
// first sql for inserting transfers
$sql_insert = "INSERT INTO messages_ip_addresses " .
"(message_id, ip_address_id, user_id, comment, datetime) VALUES ";
$values = array();
// set new redirections in junction table
foreach($ips as $ip)
{
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
}
if (count($values) > 0)
if ($redirection == Notifications_Controller::ACTIVATE)
{
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
$database->delete('messages_ip_addresses', array('message_id' => $message->id));
// finding IP addresses to redirect to debtor message
$ip_model = new Ip_address_Model();
$ips = $ip_model->get_ip_addresses_of_debtors($debtor_boundary);
// first sql for inserting transfers
$sql_insert = "INSERT INTO messages_ip_addresses " .
"(message_id, ip_address_id, user_id, comment, datetime) VALUES ";
$values = array();
// set new redirections in junction table
foreach($ips as $ip)
{
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
}
if (count($values) > 0)
{
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
}
}
$users_contacts_model = new Users_contacts_Model();
$contacts = $users_contacts_model->get_contacts_of_debtors_by_type(
$debtor_boundary, Contact_Model::TYPE_EMAIL
);
$sql_insert = "INSERT INTO email_queues ".
"(`from`, `to`, subject, body, state) VALUES ";
$values = array();
$email_count = 0;
foreach ($contacts as $contact)
if ($email == Notifications_Controller::ACTIVATE)
{
$text = $message->email_text;
foreach ($contact as $key => $value)
$users_contacts_model = new Users_contacts_Model();
$contacts = $users_contacts_model->get_contacts_of_debtors_by_type(
$debtor_boundary, Contact_Model::TYPE_EMAIL
);
$sql_insert = "INSERT INTO email_queues ".
"(`from`, `to`, subject, body, state) VALUES ";
$values = array();
foreach ($contacts as $contact)
{
if ($key != 'email_text')
$text = str_replace('{'.$key.'}', $value, $text);
$text = $message->email_text;
foreach ($contact as $key => $value)
{
if ($key != 'email_text')
$text = str_replace('{'.$key.'}', $value, $text);
}
if ($text == '')
continue;
$values[] = "('".Settings::get('email_default_email')."', '$contact->value', '".
Settings::get('email_subject_prefix').": ".__('Debtor message')."', '$text', 0)";
$email_count++;
}
$values[] = "('".Settings::get('email_default_email')."', '$contact->value', '".
Settings::get('email_subject_prefix').": ".__('Debtor message')."', '$text', 0)";
$email_count++;
if (count($values) > 0)
{
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
}
}
if (count($values) > 0)
{
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
}
return array
(
'ip_count' => $ip_count,
......
* @return int
*/
public function activate_payment_notice_message(
$user_id, $payment_notice_boundary, $debtor_boundary)
$user_id, $payment_notice_boundary, $debtor_boundary, $redirection, $email)
{
// user id
$user_id = intval($user_id);
......
$ip_count = 0;
// delete old redirections
$database = Database::instance();
$database->delete('messages_ip_addresses', array('message_id' => $message->id));
// finding IP addresses to redirect to debtor message
$ip_model = new Ip_address_Model();
$ips = $ip_model->get_ip_addresses_of_almostdebtors(
$payment_notice_boundary, $debtor_boundary
);
// first sql for inserting transfers
$sql_insert = "INSERT INTO messages_ip_addresses ".
"(message_id, ip_address_id, user_id, comment, datetime) VALUES ";
$values = array();
// set new redirections in junction table
foreach($ips as $ip)
if ($redirection == Notifications_Controller::ACTIVATE)
{
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
$database->delete('messages_ip_addresses', array('message_id' => $message->id));
// finding IP addresses to redirect to debtor message
$ip_model = new Ip_address_Model();
$ips = $ip_model->get_ip_addresses_of_almostdebtors(
$payment_notice_boundary, $debtor_boundary
);
// first sql for inserting transfers
$sql_insert = "INSERT INTO messages_ip_addresses ".
"(message_id, ip_address_id, user_id, comment, datetime) VALUES ";
$values = array();
// set new redirections in junction table
foreach($ips as $ip)
{
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
$users_contacts_model = new Users_contacts_Model();
$contacts = $users_contacts_model->get_contacts_of_almostdebtors_by_type(
$payment_notice_boundary, $debtor_boundary,
Contact_Model::TYPE_EMAIL
);
$sql_insert = "INSERT INTO email_queues ".
"(`from`, `to`, subject, body, state) VALUES ";
$values = array();
$email_count = 0;
foreach ($contacts as $contact)
if ($email == Notifications_Controller::ACTIVATE)
{
$text = $message->email_text;
foreach ($contact as $key => $value)
$users_contacts_model = new Users_contacts_Model();
$contacts = $users_contacts_model->get_contacts_of_almostdebtors_by_type(
$payment_notice_boundary, $debtor_boundary,
Contact_Model::TYPE_EMAIL
);
$sql_insert = "INSERT INTO email_queues ".
"(`from`, `to`, subject, body, state) VALUES ";
$values = array();
foreach ($contacts as $contact)
{
if ($key != 'email_text')
$text = str_replace('{'.$key.'}', $value, $text);
$text = $message->email_text;
foreach ($contact as $key => $value)
{
if ($key != 'email_text')
$text = str_replace('{'.$key.'}', $value, $text);
}
if ($text == '')
continue;
$values[] = "('".Settings::get('email_default_email')."', '$contact->value', '".
Settings::get('email_subject_prefix').": ".__('Payment notice')."', '$text', 0)";
$email_count++;
}
$values[] = "('".Settings::get('email_default_email')."', '$contact->value', '".
Settings::get('email_subject_prefix').": ".__('Payment notice')."', '$text', 0)";
$email_count++;
if (count($values))
{
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
}
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
return array
(
......
* @param integer $user_id
* @return array
*/
public function activate_user_message ($message_id, $user_id)
public function activate_user_message ($message_id, $user_id, $redirection, $email)
{
// user id
$user_id = intval($user_id);
......
$ip_count = 0;
// delete old redirections
$database = Database::instance();
$database->delete('messages_ip_addresses', array('message_id' => $message->id));
// finding IP addresses to redirect to debtor message
$ip_model = new Ip_address_Model();
$ips = $ip_model->find_all();
// first sql for inserting transfers
$sql_insert = "INSERT INTO messages_ip_addresses ".
"(message_id, ip_address_id, user_id, comment, datetime) VALUES ";
$values = array();
// set new redirections in junction table
foreach($ips as $ip)
if ($redirection == Notifications_Controller::ACTIVATE)
{
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
$database->delete('messages_ip_addresses', array('message_id' => $message->id));
// finding IP addresses to redirect to debtor message
$ip_model = new Ip_address_Model();
$ips = $ip_model->find_all();
// first sql for inserting transfers
$sql_insert = "INSERT INTO messages_ip_addresses ".
"(message_id, ip_address_id, user_id, comment, datetime) VALUES ";
$values = array();
// set new redirections in junction table
foreach($ips as $ip)
{
// insert values
$values[] = "($message->id, $ip->id, $user_id, '', '$datetime')";
$ip_count++;
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
$users_contacts_model = new Users_contacts_Model();
$contacts = $users_contacts_model->get_all_contacts_by_type(
Contact_Model::TYPE_EMAIL, $message->ignore_whitelist
);
$sql_insert = "INSERT INTO email_queues ".
"(`from`, `to`, subject, body, state) VALUES ";
$values = array();
$email_count = 0;
foreach ($contacts as $contact)
if ($email == Notifications_Controller::ACTIVATE)
{
$text = $message->email_text;
foreach ($contact as $key => $value)
$users_contacts_model = new Users_contacts_Model();
$contacts = $users_contacts_model->get_all_contacts_by_type(
Contact_Model::TYPE_EMAIL, $message->ignore_whitelist
);
$sql_insert = "INSERT INTO email_queues ".
"(`from`, `to`, subject, body, state) VALUES ";
$values = array();
foreach ($contacts as $contact)
{
if ($key != 'email_text')
$text = str_replace('{'.$key.'}', $value, $text);
$text = $message->email_text;
foreach ($contact as $key => $value)
{
if ($key != 'email_text')
$text = str_replace('{'.$key.'}', $value, $text);
}
if ($text == '')
continue;
$values[] = "('".Settings::get('email_default_email')."', '$contact->value', '".Settings::get('email_subject_prefix').": ".$message->name."', '$text', 0)";
$email_count++;
}
$values[] = "('".Settings::get('email_default_email')."', '$contact->value', '".Settings::get('email_subject_prefix').": ".__('Payment notice')."', '$text', 0)";
$email_count++;
if (count($values))
{
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
}
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
return array
(
freenetis/branches/testing/application/controllers/messages.php
{
Controller::error(RECORD);
}
$message_model = new Message_Model();
$user_id = $this->session->get('user_id');
try
$this->message_id = $message_id;
$form = new Forge(
url::base(TRUE) . url::current(TRUE), '', 'POST',
array('id' => 'article_form')
);
$form->dropdown('redirection')
->label(__('Redirection').':')
->options(array
(
Notifications_Controller::ACTIVATE => __('Activate'),
Notifications_Controller::KEEP => __('Without change')
))
->selected(Notifications_Controller::KEEP);
$form->dropdown('email')
->label(__('E-mail').':')
->options(array
(
Notifications_Controller::ACTIVATE => __('Activate'),
Notifications_Controller::KEEP => __('Without change')
))
->selected(Notifications_Controller::KEEP)
->callback(array($this,'valid_email'));
$form->submit('submit')
->value(__('Send'));
special::required_forge_style($form, ' *', 'required');
if ($form->validate())
{
//$message_model->transaction_start();
// choose which message to update
switch($message->type)
$form_data = $form->as_array();
$message_model = new Message_Model();
$user_id = $this->session->get('user_id');
$ip_count = 0;
$email_count = 0;
try
{
case Message_Model::INTERRUPTED_MEMBERSHIP_MESSAGE:
$ip_count = $message_model->activate_interrupted_membership_message($user_id);
break;
case Message_Model::DEBTOR_MESSAGE:
$debtor_boundary = $this->settings->get('debtor_boundary');
if ($debtor_boundary == "")
{
//$message_model->transaction_rollback();
status::error('Error - debtor credit boundary has not been set.');
url::redirect(url_lang::base().'messages/show_all');
}
$counts = $message_model->activate_debtor_message($user_id, $debtor_boundary);
$ip_count = $counts['ip_count'];
$email_count = $counts['email_count'];
break;
case Message_Model::PAYMENT_NOTICE_MESSAGE:
// boundary credit status
$payment_notice_boundary = $this->settings->get('payment_notice_boundary');
if ($payment_notice_boundary == "")
{
//$message_model->transaction_rollback();
status::success('Error - payment notice credit boundary has not been set.');
url::redirect(url_lang::base().'messages/show_all');
}
$debtor_boundary = $this->settings->get('debtor_boundary');
if ($debtor_boundary == "")
{
//$message_model->transaction_rollback();
status::success('Error - debtor credit boundary has not been set.');
url::redirect(url_lang::base().'messages/show_all');
}
$counts = $message_model->activate_payment_notice_message($user_id, $payment_notice_boundary, $debtor_boundary);
$ip_count = $counts['ip_count'];
$email_count = $counts['email_count'];
break;
//$message_model->transaction_start();
// choose which message to update
switch($message->type)
{
case Message_Model::INTERRUPTED_MEMBERSHIP_MESSAGE:
if ($form_data['redirection'] == Notifications_Controller::ACTIVATE)
$ip_count = $message_model->activate_interrupted_membership_message($user_id);
break;
case Message_Model::DEBTOR_MESSAGE:
$debtor_boundary = $this->settings->get('debtor_boundary');
if ($debtor_boundary == "")
{
//$message_model->transaction_rollback();
status::error('Error - debtor credit boundary has not been set.');
url::redirect(url_lang::base().'messages/show_all');
}
$counts = $message_model
->activate_debtor_message(
$user_id,
$debtor_boundary,
$form_data['redirection'],
$form_data['email']
);
$ip_count = $counts['ip_count'];
$email_count = $counts['email_count'];
break;
case Message_Model::PAYMENT_NOTICE_MESSAGE:
// boundary credit status
$payment_notice_boundary = $this->settings->get('payment_notice_boundary');
if ($payment_notice_boundary == "")
{
//$message_model->transaction_rollback();
status::success('Error - payment notice credit boundary has not been set.');
url::redirect(url_lang::base().'messages/show_all');
}
$debtor_boundary = $this->settings->get('debtor_boundary');
if ($debtor_boundary == "")
{
//$message_model->transaction_rollback();
status::success('Error - debtor credit boundary has not been set.');
url::redirect(url_lang::base().'messages/show_all');
}
$counts = $message_model
->activate_payment_notice_message(
$user_id,
$payment_notice_boundary,
$debtor_boundary,
$form_data['redirection'],
$form_data['email']
);
$ip_count = $counts['ip_count'];
$email_count = $counts['email_count'];
break;
case Message_Model::UNALLOWED_CONNECTING_PLACE_MESSAGE:
case Message_Model::UNALLOWED_CONNECTING_PLACE_MESSAGE:
$ip_count = $message_model->activate_unallowed_connecting_place_message($user_id);
if ($form_data['redirection'] == Notifications_Controller::ACTIVATE)
$ip_count = $message_model->activate_unallowed_connecting_place_message($user_id);
break;
break;
case Message_Model::USER_MESSAGE:
case Message_Model::USER_MESSAGE:
$counts = $message_model->activate_user_message($message_id, $user_id);
$ip_count = $counts['ip_count'];
$email_count = $counts['email_count'];
break;
$counts = $message_model
->activate_user_message(
$message_id,
$user_id,
$form_data['redirection'],
$form_data['email']
);
$ip_count = $counts['ip_count'];
$email_count = $counts['email_count'];
break;
default:
Controller::warning(PARAMETER);
}
$message_model->transaction_commit();
default:
Controller::warning(PARAMETER);
}
$message_model->transaction_commit();
$info_message = __('Redirection "%s" for %d IP addresses have been activated.',
array
(
0 => __(''.$message->name),
1 => $ip_count
));
$info_message = __('Redirection "%s" for %d IP addresses have been activated.',
array
(
0 => __(''.$message->name),
1 => $ip_count
));
if (isset($email_count))
if (isset($email_count))
{
$info_message .= '<br />'.__('E-mail "%s" has been sent for %d e-mail addresses.',
array
(
0 => __(''.$message->name),
1 => $email_count
));
}
status::success($info_message, FALSE);
url::redirect(url_lang::base().'messages/show_all');
}
catch (Exception $e)
{
$info_message .= '<br />'.__('E-mail "%s" has been sent for %d e-mail addresses.',
array
(
0 => __(''.$message->name),
1 => $email_count
));
$message_model->transaction_rollback();
status::error('Error - cant set redirection.');
url::redirect(url_lang::base().'messages/show_all');
}
status::success($info_message, FALSE);
url::redirect(url_lang::base().'messages/show_all');
}
catch (Exception $e)
$headline = __('Activate message for all members');
if ($message->type > 0)
{
$message_model->transaction_rollback();
status::error('Error - cant set redirection.');
url::redirect(url_lang::base().'messages/show_all');
$breadcrumbs = breadcrumbs::add()
->link('messages/show_all', 'Messages',
$this->acl_check_view(
'Redirection_Controller', 'redirection'
)
)
->text($message->name)
->text($headline);
}
else
{
$breadcrumbs = breadcrumbs::add()
->link('messages/show_all', 'Messages',
$this->acl_check_view(
'Redirection_Controller', 'redirection'
)
)
->disable_translation()
->text($message->name . ' (' . $message->id . ')')
->text($headline);
}
$view = new View('main');
$view->breadcrumbs = $breadcrumbs->html();
$view->title = $headline;
$view->content = new View('form');
$view->content->headline = $headline;
$view->content->form = $form;
$view->render(TRUE);
}
/**
......
status::success(__("Activated redirections of this message have been successfuly deactivated."));
url::redirect(url_lang::base().'messages/show_all');
}
/**
* Callback function to validate e-mail notification
*
* @author Michal Kliment
* @param type $input
*/
public function valid_email ($input)
{
$email = $input->value;
if ($email == Notifications_Controller::ACTIVATE)
{
$message = new Message_Model($this->message_id);
if ($message->type != Message_Model::DEBTOR_MESSAGE &&
$message->type != Message_Model::PAYMENT_NOTICE_MESSAGE &&
$message->type != Message_Model::USER_MESSAGE)
{
$input->add_error('required', __('It is not possible activate e-mail notification for this message.'));
}
}
}
}

Také k dispozici: Unified diff