Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1177

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

Modul presmerovani prejmenovan na Upozorneni a rozsiren o upozorneni e-mailem. V budocnu bude snadne jej rozsirit napr. SMS uzporneni. Implementovana e-mailova fronta. Mozne upozornit clena, podsit nebo celou oblast. Rada dalsich vylepseni.

Zobrazit rozdíly:

freenetis/branches/testing/application/i18n/cs_CZ/texts.php
'bitrate' => 'Rychlost přenosu',
'bitrate is required' => 'Rychlost přenosu je povinná.',
'before getting started, we need some information on the database' => 'Předtím než začneme, potřebujeme několik informací o databázi.',
'body' => 'Tělo',
'both' => 'obojí',
'bug report from' => 'Chyba nahlášena z',
'but there are some problems' => 'Ale je zde několik problémů',
......
'contains' => 'obsahuje',
'contains not' => 'neobsahuje',
'content of file htaccess' => 'Obsah souboru .htaccess',
'content of the message' => 'Obsah zprávy',
'content of the message for e-mail' => 'Obsah zprávy pro e-mail',
'content of the message for redirection' => 'Obsah zprávy pro přesměrování',
'contractual increase' => 'Smluvní navýšení',
'cookies must be enabled' => 'Musí být zapnuty cookies.',
'count' => 'Počet',
......
'day book' => 'Účetní deník',
'db' => 'DŽ',
'db schema revision' => 'Revize struktury DB',
'deactivate' => 'Deaktivovat',
'deactivation date' => 'Datum deaktivace',
'debtor' => 'Dlužník',
'debtor boundary' => 'Hranice pro dlužníka',
......
'editing of user' => 'Úprava uživatele',
'eighth-degree certified engineers' => 'Certifikování technici osmého stupně',
'email' => 'E-mail',
'e-mail from' => 'E-mail Od',
'e-mail to' => 'E-mail Komu',
'empty input' => 'Prázdný vstup',
'email address' => 'emailová adresa',
'e-mail has been successfully sent' => 'E-mail byl úspěšně odeslán',
'e-mail has been sent for %s e-mail addresses' => 'E-mail byl odeslán pro %s e-mailových adres',
'e-mail settings' => 'Nastavení e-mailu',
'e-mail subject prefix' => 'Předpona předmětu e-mailu',
'e-mail variables' => 'Proměnné e-mailu',
'e-mail variables have been successfully updated' => 'Proměnné e-mailu byly úspěšně aktualizovány.',
'e-mail variables havent been successfully updated' => 'Proměnné e-mailu nebyly úspěšně aktualizovány.',
'e-mails' => 'E-maily',
'enable action logs' => 'Zapnout logy akcí',
'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í',
......
'error - debtor credit boundary has not been set' => 'Chyba - hranice kreditu pro dlužníka nebyla nastavena.',
'error - during searching long term connections' => 'Chyba - během hledání dlouhotrvajícího připojení.',
'error - during extraction of data' => 'Chyba - během extrakcce dat.',
'error - it is not possible delete already sent message' => 'Chyba - není možné smazat již odeslanou zprávu',
'error - it is not possible to remove admin' => 'Chyba - nelze odebrat správce zařízení.',
'error - it is not possible to remove engineer' => 'Chyba - nelze odebrat technika zařízení.',
'error - not enough money on origin account' => 'Chyba - nedostatek peněz na zdrojovém účtě.',
......
'first number can\'t be larger then second number' => 'První číslo nesmí být větší než druhé číslo',
'first or last day of month is not valid' => 'První nebo poslední den v měsíci není správně.',
'firstname of user' => 'Křestní jméno uživatele',
'for all type' => 'Pro všechny typy',
'fixed line' => 'Pevná linka',
'fixed line number' => 'Číslo v pevné lince',
'for smtp settings only' => 'Pouze pro nastavení SMTP.',
......
'is not' => 'není',
'is not in' => 'není v',
'it can means that username/password/host are bad or host is unavailable' => 'To může znamenat, že uživatelské jméno/heslo/hostitel je špatné nebo je hostitel nedostupný.',
'it is not possible activate e-mail notification for this message' => 'Není možné aktivovat e-mail upozornění pro tuto zprávu.',
'it is not possible delete used template' => 'Není možné smazat použitou šablonu.',
'it is not possible delete item of used template' => 'Není možné smazat položku použité šablony.',
'it is not possible delete locked work' => 'Není možné smazat zamčenou práci.',
......
'is not in system' => 'Není v systému',
'is not telephonists' => 'Není telefonista',
'is missing from' => 'chybí z',
'iw' => 'IBL',
'january' => 'Leden',
'june' => 'Červen',
'july' => 'Červenec',
......
'list of all redirection messages' => 'Seznam všech zpráv přesměrování',
'list of all rejected work reports' => 'Seznam všech zamítnutých pracovních výkazů',
'list of all rejected works' => 'Seznam všech zamítnutých prací',
'list of all sent e-mails' => 'Seznam všech odeslaných e-mailů',
'list of all smokeping records' => 'Seznam všech záznamů smokepingu',
'list of all streets' => 'Seznam všech ulic',
'list of all towns' => 'Seznam všech měst',
'list of all transactions' => 'Seznam všech převodů',
'list of all unconfirmed works' => 'Seznam všech nepotvrzených prací',
'list of all unsent e-mails' => 'Seznam všech neodeslaných e-mailů',
'list of all users' => 'Seznam všech uživatelů',
'list of calls' => 'Výpis hovorů',
'list of calls for account' => 'Výpis hovorů pro účet',
......
'networks' => 'Síť',
'never' => 'Nikdy',
'never redirect' => 'Nikdy nepřesměrovat',
'new' => 'Nová',
'new bank accounts' => 'Nové bankovní účty',
'new device admin has been successfully saved' => 'Nový správce zařízení byl úspěšně uložen.',
'new device engineer has been successfully saved' => 'Nový technik zařízení byl úspěšně uložen.',
......
'not filled in' => 'Nevyplněno',
'not found' => 'Nenalezeno',
'note' => 'Poznámka',
'notification setting' => 'Nastavení upozornění',
'notification setting of cloud' => 'Nastavení upozornění pro oblast',
'notification setting of member' => 'Nastavení upozornění pro člena',
'notification setting of subnet' => 'Nastavení upozornění pro podsíť',
'notification settings' => 'Nastavení upozornění',
'notification settings have been successfully updated' => 'Nastavení upozornění bylo úspěšně upraveno.',
'notification settings have not been updated' => 'Nastavení upozornění nebylo upraveno.',
'notifications' => 'Upozornění',
'november' => 'Listopad',
'number' => 'Číslo',
'number of the recipient' => 'Číslo příjemce',
......
'redirected' => 'Přesměroval',
'redirection' => 'Přesměrování',
'redirection enabled' => 'Přesměrování zapnuto',
'redirection has been activated for %s ip addresses' => 'Přesměrování bylo aktivováno pro %s IP adres',
'redirection has been deactivated for %s ip addresses' => 'Přesměrování bylo deaktivováno pro %s IP adres',
'redirection has been successfully canceled' => 'Přesměrování bylo úspěšně zrušeno.',
'redirection has been successfully update' => 'Přesměrování bylo úspěšně upraveno.',
'redirection has been successfully set' => 'Přesměrování bylo úspěšně nastaveno.',
......
'redirection preview' => 'Náhled přesměrování',
'redirection records' => 'Záznamy přesměrování',
'redirection settings' => 'Nastavení přesměrování',
'redirection settings have been successfully updated' => 'Nastavení přesměrování bylo úspěšně upraveno.',
'redirection settings have not been updated' => 'Nastavení přesměrování nebylo upraveno.',
'redirection type' => 'Typ přesměrování',
'reg' => 'Přih.',
'register' => 'Registrovat',
......
'save changes' => 'Uložit změny',
'save' => 'Uložit',
'save wireless setting' => 'Uložit bezdrátové nastavení',
'sc' => 'SZ',
'schedule' => 'Plán',
'search' => 'Hledat',
'searching' => 'Vyhledávání',
......
'select free subnet' => 'Vyber volnou podsíť',
'select interface' => 'Vyber rozhraní',
'select member' => 'Vyber člena',
'select message' => 'Vyber zprávu',
'select vlan interface' => 'Vyber VLAN rozhraní',
'select only one subnet' => 'Vyberte jen jednu podsíť.',
'select only one type of iface' => 'Vyberte jen jeden typ rozhraní.',
......
'self-cancelable message' => 'Samozrušitelná zpráva',
'self-registration' => 'Samo-registrace',
'sending message failed' => 'Odeslání zprávy selhalo',
'send again' => 'Odeslat znovu',
'send date' => 'Datum odeslání',
'send e-mail' => 'Pošli e-mail',
'send e-mail notification after expiration' => 'Poslat zprávu na e-mail po vypršení přesměrování',
......
'send sms message' => 'Poslat SMS zprávu',
'send to member' => 'Pošli členovi',
'sent' => 'Odeslaná',
'sent e-mails' => 'Odeslané e-maily',
'sent message' => 'Odeslaná zpráva',
'september' => 'Září',
'service' => 'Služba',
......
'show all invoices' => 'Zobrazit všechny faktury',
'show all logs' => 'Zobrazit všechny logy',
'show all messages' => 'Zobrazit všechnny zprávy',
'show all sent e-mails' => 'Zobrazit všechny odeslané e-maily',
'show all transfers on the account' => 'Ukaž všechny převody tohoto účtu',
'show all unconfirmed works' => 'Zobraz všechnny nepotvrzené práce',
'show all unsent e-mails' => 'Zobrazit všechny neodeslané e-maily',
'show all users contacts' => 'Zobrazit všechny uživatelské kontakty',
'show allowed subnets' => 'Zobrazit povolené podsítě',
'show answer for this message' => 'Zobrazit odpověď na tuto zprávu',
......
'unlimited' => 'neomezený',
'unlimited' => 'neomezený',
'unlogged user' => 'Nepřihlášený uživatel',
'unsent e-mails' => 'Neodeslané e-maily',
'um' => 'UZ',
'umark this invoice' => 'Odznačit fakturu',
'unallowed connecting place' => 'Nepovolené přípojné místo',
'unread' => 'Nepřečtená',
'unsent' => 'Neodeslaná',
'until' => 'do',
......
'user can disable redirection' => 'Uživatel může zrušit přesměrování',
'user cannot be deleted, he has some dependent items in database' => 'Uživatel nelze smazat, má závislé objekty v databázi.',
'user contacts' => 'Uživatelské kontakty',
'user from' => 'Uživatel Od',
'user id' => 'ID uživatele',
'user identification' => 'Identifikace uživatele',
'user has been assigned' => 'Uživatel byl přiřazen',
......
'user has been successfully updated' => 'Uživatel byl úspěšně upraven.',
'user message' => 'Uživatelská zpráva',
'user name' => 'Uživatelské jméno',
'user to' => 'Uživatel Komu',
'user_name' => 'Křestní jméno',
'username already exists in database' => 'Uživatelské jméno již v databázi existuje',
'username or password do not match' => 'Uživatelské jméno nebo heslo nesouhlasí',
freenetis/branches/testing/application/vendors/unit_tester/unit_testing_config.xml
<input></input>
</values>
</method>
<method name="test" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
</controller>
<controller name="email_queues">
<method name="index" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="send" autogenerate="on">
<attributes>
<attribute name="email_queue_id" default_value="" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
</values>
</method>
<method name="delete" autogenerate="on">
<attributes>
<attribute name="email_queue_id" default_value="" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
</values>
</method>
</controller>
<controller name="enum_types">
<method name="index" autogenerate="on">
<attributes></attributes>
......
<input></input>
</values>
</method>
<method name="user_fullname" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="user_login" autogenerate="on">
<attributes></attributes>
<values>
......
</values>
</method>
</controller>
<controller name="notifications">
<method name="member" autogenerate="on">
<attributes>
<attribute name="member_id" default_value="" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
</values>
</method>
<method name="subnet" autogenerate="on">
<attributes>
<attribute name="subnet_id" default_value="" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
</values>
</method>
<method name="cloud" autogenerate="on">
<attributes>
<attribute name="cloud_id" default_value="" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
</values>
</method>
<method name="settings" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="set_whitelist" autogenerate="on">
<attributes>
<attribute name="member_id" default_value="" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
</values>
</method>
<method name="valid_email" autogenerate="on">
<attributes>
<attribute name="input" default_value="" />
</attributes>
<values>
<input>
<param value="" />
</input>
</values>
</method>
</controller>
<controller name="phone_invoices">
<method name="index" autogenerate="on">
<attributes></attributes>
......
</method>
</controller>
<controller name="redirect">
<method name="settings" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="activate_to_ip_address" autogenerate="off">
<attributes>
<attribute name="ip_address_id" default_value=""/>
......
<param value=""/>
</input>
</values>
</method>
<method name="set_whitelist" autogenerate="off">
<attributes>
<attribute name="member_id" default_value=""/>
</attributes>
<values>
<input>
<param value=""/>
</input>
<input>
<param value="1"/>
</input>
</values>
</method>
</controller>
</method></controller>
<controller name="registration">
<method name="index" autogenerate="off">
<attributes/>
......
</input>
</values>
</method></model>
<model name="email_queue">
<method name="get_current_queue" autogenerate="on">
<attributes>
<attribute name="count" default_value="10" />
</attributes>
<values>
<input></input>
<input>
<param value="10" />
</input>
</values>
</method>
<method name="count_all_sent_emails" autogenerate="on">
<attributes>
<attribute name="filter_sql" default_value="" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
</values>
</method>
<method name="count_all_unsent_emails" autogenerate="on">
<attributes>
<attribute name="filter_sql" default_value="" />
</attributes>
<values>
<input></input>
<input>
<param value="" />
</input>
</values>
</method>
</model>
<model name="enum_type">
<method name="get_value" autogenerate="off">
<attributes>
......
<input></input>
</values>
</method>
<method name="get_ip_addresses_with_unallowed_connecting_place" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
<method name="get_ip_addresses_of_debtors" autogenerate="off">
<attributes>
<attribute name="debtor_boundary" default_value=""/>
......
</input>
</values>
</method>
<method name="activate_unallowed_connecting_place_message" autogenerate="on">
<attributes>
<attribute name="user_id" default_value="" />
</attributes>
<values>
<input>
<param value="" />
</input>
</values>
</method>
<method name="activate_debtor_message" autogenerate="on">
<attributes>
<attribute name="user_id" default_value="" />
......
<param value="1'+1"/>
</input>
</values>
</method></model>
</method>
<method name="delete_redirection_of_ip_address" autogenerate="on">
<attributes>
<attribute name="message_id" default_value="" />
<attribute name="ip_address_id" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="add_redirection_to_ip_address" autogenerate="on">
<attributes>
<attribute name="message_id" default_value="" />
<attribute name="ip_address_id" default_value="" />
<attribute name="comment" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="" />
</input>
</values>
</method>
</model>
<model name="phone_call">
<method name="get_history" autogenerate="off">
<attributes>
......
</values>
</method>
</model>
<model name="users_contacts">
<method name="set_whitelist_by_member_and_type" autogenerate="on">
<attributes>
<attribute name="whitelist" default_value="" />
<attribute name="member_id" default_value="" />
<attribute name="type" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="clean_temporary_whitelist" autogenerate="on">
<attributes></attributes>
<values>
<input></input>
</values>
</method>
</model>
<model name="users_key">
<method name="get_keys_by_device" autogenerate="off">
<attributes>
......
</attributes>
<values>
</values>
</method></helper>
</method>
<method name="email_from_field" autogenerate="on">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="email_to_field" autogenerate="on">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="email_subject_field" autogenerate="on">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="email_state_field" autogenerate="on">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="message_self_cancel_field" autogenerate="on">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="boolean_field" autogenerate="on">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
</helper>
<helper name="cookie">
<method name="set" autogenerate="on">
<attributes>
freenetis/branches/testing/application/helpers/callback.php
*/
public static function message_field($item, $name)
{
// condition suspects, that type 1 corresponds with Message_Model::contact_information
// and 6 coresponds with Message_Model::payment_notice_message
if ($item->type >= 1 && $item->type <= 6)
// system messages
if ($item->type >= 0)
{
// system messages
echo url_lang::lang('texts.'.$item->message);
echo __($item->message);
}
elseif ($item->type === 0)
elseif ($item->type == 0)
{
// user messages
echo $item->message;
......
static function message_activate_field($item, $name)
{
$message = new Message_Model($item->id);
if ($message->type == Message_Model::$contact_information
|| $message->type == Message_Model::$cancel_message
|| $message->type == Message_Model::$unknown_device_message)
if ($message->type == Message_Model::CONTACT_INFORMATION
|| $message->type == Message_Model::CANCEL_MESSAGE
|| $message->type == Message_Model::UNKNOWN_DEVICE_MESSAGE)
{
echo '&nbsp;';
}
......
static function message_delete_field($item, $name)
{
$message = new Message_Model($item->id);
if ($message->type == Message_Model::$user_message)
if ($message->type == Message_Model::USER_MESSAGE)
{
echo html::anchor(url_lang::base().'messages/delete/'.$message->id, url_lang::lang('texts.Delete'));
}
......
{
echo '<span class="help" title="'.$item->items_count_title.'">'.$item->items_count.'</span>';
}
/**
* Callback function to print e-mail From address
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function email_from_field ($item, $name)
{
if ($item->from_user_id)
echo html::anchor(url_lang::base().'users/show/'.$item->from_user_id, $item->from_user_name, array('title' => $item->from));
else
echo $item->from;
}
/**
* Callback function to print e-mail To address
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function email_to_field ($item, $name)
{
if ($item->to_user_id)
echo html::anchor(url_lang::base().'users/show/'.$item->to_user_id, $item->to_user_name, array('title' => $item->to));
else
echo $item->to;
}
/**
* Callback function to print e-mail subject
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function email_subject_field ($item, $name)
{
echo "<span class='help' title='".$item->body."'>".$item->subject."</span>";
}
/**
* Callback function to print e-mail state
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function email_state_field ($item, $name)
{
switch ($item->state)
{
case Email_queue_Model::STATE_NEW:
echo __('New');
break;
case Email_queue_Model::STATE_OK:
echo "<span style='color: green'>".__('Sent')."</span>";
break;
case Email_queue_Model::STATE_FAIL:
echo "<span style='color: red'>".__('Failed')."</span>";
break;
}
}
/**
* Callback function to print self-cancel state of message
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function message_self_cancel_field ($item, $name)
{
switch ($item->self_cancel)
{
case Message_Model::SELF_CANCEL_DISABLED:
echo __('No');
break;
case Message_Model::SELF_CANCEL_MEMBER:
echo "<span class='help' title='".__('Possibility of canceling redirection to all IP addresses of member')."'>".__('Yes')."</span>";
break;
case Message_Model::SELF_CANCEL_IP:
echo "<span class='help' title='".__('Possibility of canceling redirection to only current IP address')."'>".__('Yes')."</span>";
break;
}
}
/**
* Callback function to print boolean as word (yes or no)
*
* @author Michal Kliment
* @param type $item
* @param type $name
*/
public static function boolean_field ($item, $name)
{
if ($item->$name)
echo __('Yes');
else
echo __('No');
}
}
freenetis/branches/testing/application/models/email_queue.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is release under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* @author Michal Kliment
* @package Model
*
* @property string $from
* @property string $to
* @property string $subject
* @property string $body
* @property integer $state
* @property timestamp $access_time
*/
class Email_queue_Model extends ORM
{
/**
* New e-mail in queue
*/
const STATE_NEW = 0;
/**
* Successfully sent e-mail
*/
const STATE_OK = 1;
/**
* Unsuccessfully sent e-mail, almost same as new
*/
const STATE_FAIL = 2;
/**
* Returns current email queue, by default 10 e-mails to send
*
* @author Michal Kliment
* @param integer $count
* @return Email_queue_Model
*/
public function get_current_queue($count = 10)
{
return $this->where('state <> ',self::STATE_OK)
->orderby('access_time')
->limit($count,0)
->find_all();
}
/**
* Returns all sent e-mails
*
* @author Michal Kliment
* @param integer $limit_from
* @param integer $limit_results
* @param string $order_by
* @param string $order_by_direction
* @param string $filter_sql
* @return MySQL_Iterator
*/
public function get_all_sent_emails(
$limit_from = 0, $limit_results = 50,
$order_by = 'id', $order_by_direction = 'ASC', $filter_sql='')
{
// filter
$where = "";
if ($filter_sql != '')
$where = " AND $filter_sql";
return $this->db->query("
SELECT * 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
) eq
WHERE eq.state = ? $where
GROUP BY eq.id
ORDER BY ".$this->db->escape_column($order_by)." $order_by_direction
LIMIT " . intval($limit_from) . "," . intval($limit_results) . "
", Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL, self::STATE_OK);
}
/**
* Counts all sent e-mails
*
* @author Michal Kliment
* @param string $filter_sql
* @return integer
*/
public function count_all_sent_emails($filter_sql='')
{
// filter
$where = "";
if ($filter_sql != '')
$where = " AND $filter_sql";
return $this->db->query("
SELECT COUNT(*) AS total FROM
(
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
) eq
WHERE eq.state = ? $where
GROUP BY eq.id
) eq
", Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL, self::STATE_OK)
->current()->total;
}
/**
* Returns all unsent e-mails
*
* @author Michal Kliment
* @param integer $limit_from
* @param integer $limit_results
* @param string $order_by
* @param string $order_by_direction
* @param string $filter_sql
* @return MySQL_Iterator
*/
public function get_all_unsent_emails(
$limit_from = 0, $limit_results = 50,
$order_by = 'id', $order_by_direction = 'ASC', $filter_sql='')
{
// filter
$where = "";
if ($filter_sql != '')
$where = " AND $filter_sql";
return $this->db->query("
SELECT * 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
) eq
WHERE eq.state <> ? $where
GROUP BY eq.id
ORDER BY ".$this->db->escape_column($order_by)." $order_by_direction
LIMIT " . intval($limit_from) . "," . intval($limit_results) . "
", Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL, self::STATE_OK);
}
/**
* Counts all unsent e-mails
*
* @author Michal Kliment
* @param string $filter_sql
* @return integer
*/
public function count_all_unsent_emails($filter_sql='')
{
// filter
$where = "";
if ($filter_sql != '')
$where = " AND $filter_sql";
return $this->db->query("
SELECT COUNT(*) AS total FROM
(
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
) eq
WHERE eq.state <> ? $where
GROUP BY eq.id
) eq
", Contact_Model::TYPE_EMAIL, Contact_Model::TYPE_EMAIL, self::STATE_OK)
->current()->total;
}
}
?>
freenetis/branches/testing/application/models/messages_ip_addresses.php
", $ip_address_id);
}
/**
* Deletes redirection of ip address
*
* @author Michal Kliment
* @param integer $message_id
* @param integer $ip_address_id
* @return integer
*/
public function delete_redirection_of_ip_address ($message_id, $ip_address_id)
{
return $this->db->delete('messages_ip_addresses', array
(
'message_id' => $message_id,
'ip_address_id' => $ip_address_id
))->count();
}
/**
* Adds new redirection to ip address
*
* @author Michal Kliment
* @param integer $message_id
* @param integer $ip_address_id
* @param string $comment
* @return integer
*/
public function add_redirection_to_ip_address ($message_id, $ip_address_id, $comment)
{
return $this->db->insert('messages_ip_addresses', array
(
'message_id' => $message_id,
'ip_address_id' => $ip_address_id,
'user_id' => Session::instance()->get('user_id'),
'comment' => $comment,
'datetime' => date('Y-m-d H:i:s')
))->count();
}
}
freenetis/branches/testing/application/models/ip_address.php
public function get_ip_addresses_of_subnet($subnet_id)
{
return $this->db->query("
SELECT q.ip_address_id, q.ip_address, q.gateway,
d.name AS device_name, d.id AS device_id,
SELECT q.ip_address_id AS id, q.ip_address_id, q.ip_address,
q.gateway, d.name AS device_name, d.id AS device_id,
m.name AS member_name, m.id AS member_id
FROM
(
......
}
/**
* Returns all ip addresses with unallowed connecting place
*
* @author Michal Kliment
* @return MySQL Iterator
*/
public function get_ip_addresses_with_unallowed_connecting_place()
{
return $this->db->query("
SELECT q.id, ip_address FROM
(
SELECT subnet_id, q.id, ip_address, IFNULL(q.member_id, u.member_id) AS member_id FROM
(
SELECT ip.ip_address, ip.id, ip.subnet_id,
IFNULL(i1.device_id, i2.device_id) AS device_id, ip.member_id
FROM ip_addresses ip
LEFT JOIN ifaces i1 ON ip.iface_id = i1.id
LEFT JOIN vlan_ifaces vi ON ip.vlan_iface_id = vi.id
LEFT JOIN ifaces i2 ON vi.iface_id = i2.id
) AS q
LEFT JOIN devices d ON q.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
) q
WHERE q.member_id <> 1 AND q.subnet_id NOT IN
(
SELECT a.subnet_id
FROM allowed_subnets a
WHERE a.subnet_id = q.subnet_id AND a.member_id = q.member_id AND enabled = 1
)
");
}
/**
* Gets all IP addresses of members who have credit negative credit status.
* @author Jiri Svitak
* @param $debtor_boundary
freenetis/branches/testing/application/models/message.php
class Message_Model extends ORM
{
// user message, can be added and deleted by user
public static $user_message = 0;
const USER_MESSAGE = 0;
// not exactly message, it is content of side panel, should be used for information for all redirections
public static $contact_information = 1;
const CONTACT_INFORMATION = 1;
// content of page shown after canceling redirection
public static $cancel_message = 2;
const CANCEL_MESSAGE = 2;
// content of page with text for unknown device
public static $unknown_device_message = 3;
const UNKNOWN_DEVICE_MESSAGE = 3;
// content of page for interrupted member, this redirection can be set in system
public static $interrupted_membership_message = 4;
const INTERRUPTED_MEMBERSHIP_MESSAGE = 4;
// content of page for debtor, this redirection can be set in system
public static $debtor_message = 5;
const DEBTOR_MESSAGE = 5;
// content of page for payment notice, this redirection can be set in system and can be canceled by user
public static $payment_notice_message = 6;
const PAYMENT_NOTICE_MESSAGE = 6;
// content of page for unallowed connecting place, depends on allowed subnets
const UNALLOWED_CONNECTING_PLACE_MESSAGE = 7;
// self cancel disabled, remote computer cannot cancel this message
public static $self_cancel_disabled = 0;
const SELF_CANCEL_DISABLED = 0;
// self cancel enabled, every member's IP address will have cancelled given redirection
public static $self_cancel_member = 1;
const SELF_CANCEL_MEMBER = 1;
// self cancel enabled, redirection is canceled only for current remote computer
public static $self_cancel_ip = 2;
const SELF_CANCEL_IP = 2;
/**
......
}
// query
return $this->db->query("
SELECT m.id, m.name AS message, m.type
SELECT m.id, m.name AS message, m.type, m.self_cancel,
m.ignore_whitelist
FROM messages m
ORDER BY $order_by $order_by_direction
LIMIT " . intval($limit_from) . ", " . intval($limit_results) . "
......
$user_id = ($user_id) ? $user_id : 'NULL';
// preparation
$message = ORM::factory('message')->where(
'type', self::$interrupted_membership_message)->find();
'type', self::INTERRUPTED_MEMBERSHIP_MESSAGE)->find();
$content = $message->text;
$datetime = date('Y-m-d H:i:s');
$ip_count = 0;
......
throw new Exception();
return $ip_count;
}
/**
* Activates notifications for ip addresses with unallowed connecting place
*
* @author Michal Kliment
* @param integer $user_id
* @return integer
*/
public function activate_unallowed_connecting_place_message($user_id)
{
// user id
$user_id = intval($user_id);
$user_id = ($user_id) ? $user_id : 'NULL';
// preparation
$message = ORM::factory('message')->where(
'type', self::UNALLOWED_CONNECTING_PLACE_MESSAGE)->find();
$content = $message->text;
$datetime = date('Y-m-d H:i:s');
$ip_count = 0;
// delete old redirections
$database = new Database();
$database->delete('messages_ip_addresses', array('message_id' => $message->id));
// find IP addresses with interrupted membership
$ip_model = new Ip_address_Model();
$ips = $ip_model->get_ip_addresses_with_unallowed_connecting_place();
// 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();
return $ip_count;
}
/**
......
$user_id = ($user_id) ? $user_id : 'NULL';
// preparation
$message = ORM::factory('message')->where(
'type', self::$debtor_message)->find();
'type', self::DEBTOR_MESSAGE)->find();
$content = $message->text;
$datetime = date('Y-m-d H:i:s');
$ip_count = 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();
foreach ($contacts as $contact)
{
$text = $message->email_text;
foreach ($contact as $key => $value)
{
if ($key != 'email_text')
$text = str_replace('{'.$key.'}', $value, $text);
}
$values[] = "('".Settings::get('email_default_email')."', '$contact->value', '".Settings::get('email_subject_prefix').": ".__('Debtor message')."', '$text', 0)";
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
return $ip_count;
}
......
$user_id = ($user_id) ? $user_id : 'NULL';
// preparation
$message = ORM::factory('message')->where(
'type', self::$payment_notice_message)->find();
'type', self::PAYMENT_NOTICE_MESSAGE)->find();
$content = $message->text;
$datetime = date('Y-m-d H:i:s');
$ip_count = 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_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)
{
$text = $message->email_text;
foreach ($contact as $key => $value)
{
if ($key != 'email_text')
$text = str_replace('{'.$key.'}', $value, $text);
}
$values[] = "('".Settings::get('email_default_email')."', '$contact->value', '".Settings::get('email_subject_prefix').": ".__('Payment notice')."', '$text', 0)";
}
$sql_insert .= implode(",", $values);
if (!$database->query($sql_insert))
throw new Exception();
return $ip_count;
}
}
freenetis/branches/testing/application/models/users_contacts.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreeNetIS
* and it is release under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* @package Model
*/
class Users_contacts_Model extends Model
{
const NO_WHITELIST = 0;
const PERMANENT_WHITELIST = 1;
const TEMPORARY_WHITELIST = 2;
/**
* Sets whitelist flag for member's conntact
*
* @author Michal Kliment
* @param integer $whitelist
* @param integer $member_id
* @param integer $type
*/
public function set_whitelist_by_member_and_type($whitelist, $member_id, $type)
{
$this->db->query("
UPDATE users_contacts uc, contacts c, users u
SET uc.whitelisted = ?
WHERE
uc.contact_id = c.id
AND c.type = ?
AND uc.user_id = u.id
AND u.member_id = ?
", $whitelist, $type, $member_id);
}
/**
* Cleans temporary whitelist for contacs
*
* @author Michal Kliment
*/
public function clean_temporary_whitelist()
{
$this->db->query("
UPDATE users_contacts uc, contacts c, users u
SET uc.whitelisted = ?
WHERE uc.whitelisted = ?
", self::NO_WHITELIST, self::TEMPORARY_WHITELIST);
}
/**
* Returns all contacts of debtors by type
*
* @author Michal Kliment
* @param integer $debtor_boundary
* @param integer $type
* @return MySQL iteraor
*/
public function get_contacts_of_debtors_by_type(
$debtor_boundary, $type)
{
return $this->db->query("
SELECT
c.value, a.balance, m.id AS member_id, m.name AS member_name,
m.variable_symbol
FROM members m
JOIN accounts a ON a.member_id = m.id AND m.id <> 1
JOIN users u ON u.member_id = m.id
JOIN users_contacts uc ON uc.user_id = u.id
JOIN contacts c ON uc.contact_id = c.id AND c.type = ?
WHERE uc.whitelisted = ? AND m.type <> 15 AND m.id NOT IN
(
SELECT m.id
FROM members m
JOIN membership_interrupts mi ON mi.member_id = m.id
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
) AND a.balance < ".intval($debtor_boundary)
, $type, self::NO_WHITELIST);
}
/**
* Returns all contacts of almost-debtors
*
* @author Michal Kliment
* @param integer $payment_notice_boundary
* @param integer $debtor_boundary
* @param integer $type
* @return MySQL iterator
*/
public function get_contacts_of_almostdebtors_by_type(
$payment_notice_boundary, $debtor_boundary, $type)
{
return $this->db->query("
SELECT
c.value, a.balance, m.id AS member_id, m.name AS member_name,
m.variable_symbol
FROM members m
JOIN accounts a ON a.member_id = m.id AND m.id <> 1
JOIN users u ON u.member_id = m.id
JOIN users_contacts uc ON uc.user_id = u.id
JOIN contacts c ON uc.contact_id = c.id AND c.type = ?
WHERE uc.whitelisted = ? AND m.type <> 15 AND m.id NOT IN
(
SELECT m.id
FROM members m
JOIN membership_interrupts mi ON mi.member_id = m.id
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
) AND a.balance >= ".intval($debtor_boundary)." AND a.balance < ".intval($payment_notice_boundary)
, $type, self::NO_WHITELIST);
}
/**
* Returns all contacts from subnets by type
*
* @author Michal Kliment
* @param integer $subnet_id
* @param integer $type
* @param bool $ignore_whitelisted
* @return MySQL iterator
*/
public function get_contacts_by_subnet_and_type (
$subnet_id, $type, $ignore_whitelisted = FALSE)
{
if ($ignore_whitelisted)
$whitelisted = "";
else
$whitelisted = "AND uc.whitelisted = 0";
return $this->db->query("
SELECT
c.value, a.balance, m.id AS member_id, m.name AS member_name,
m.variable_symbol
FROM
(
SELECT
IFNULL(u.member_id,ip.member_id) AS member_id
FROM
(
SELECT
IFNULL(i1.device_id, i2.device_id) AS device_id,
ip.member_id
FROM ip_addresses ip
LEFT JOIN ifaces i1 ON ip.iface_id = i1.id
LEFT JOIN vlan_ifaces vi ON ip.vlan_iface_id = vi.id
LEFT JOIN ifaces i2 ON vi.iface_id = i2.id
WHERE ip.subnet_id = ?
) ip
LEFT JOIN devices d ON ip.device_id = d.id
LEFT JOIN users u ON d.user_id = u.id
) ip
JOIN members m ON ip.member_id = m.id AND m.id <> 1 AND m.type <> ?
JOIN accounts a ON a.member_id = m.id
JOIN users u ON u.member_id = m.id
JOIN users_contacts uc ON uc.user_id = u.id $whitelisted
JOIN contacts c ON uc.contact_id = c.id AND c.type = ?
WHERE m.id NOT IN
(
SELECT m.id
FROM members m
JOIN membership_interrupts mi ON mi.member_id = m.id
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
)
GROUP BY c.value
", $subnet_id, Member_Model::TYPE_FORMER, $type);
}
/**
* Returns all contacts of members by type
*
* @author Michal Kliment
* @param type $member_id
* @param integer $type
* @param bool $ignore_whitelisted
* @return MySQL iterator
*/
public function get_contacts_by_member_and_type (
$member_id, $type, $ignore_whitelisted = FALSE)
{
if ($ignore_whitelisted)
$whitelisted = "";
else
$whitelisted = "AND uc.whitelisted = 0";
return $this->db->query("
SELECT c.value, a.balance, m.id AS member_id, m.name AS member_name,
m.variable_symbol
FROM members m
JOIN accounts a ON a.member_id = m.id
JOIN users u ON u.member_id = m.id
JOIN users_contacts uc ON uc.user_id = u.id $whitelisted
JOIN contacts c ON uc.contact_id = c.id AND c.type = ?
WHERE m.id = ? AND m.type <> ? AND m.id NOT in
(
SELECT m.id
FROM members m
JOIN membership_interrupts mi ON mi.member_id = m.id
JOIN members_fees mf ON mi.members_fee_id = mf.id
WHERE mf.activation_date <= CURDATE() AND mf.deactivation_date >= CURDATE()
)
", $type, $member_id, Member_Model::TYPE_FORMER);
}
}
freenetis/branches/testing/application/controllers/clouds.php
$form->set_attr('class', 'form_class')
->set_attr('method', 'post');
$form->dropdown('subnet')
$form->dropdown('subnet_id')
->label(__('Subnet') . ':')
->options($arr_subnet);
->options($arr_subnet)
... Rozdílový soubor je zkrácen, protože jeho délka přesahuje max. limit.

Také k dispozici: Unified diff