Merge remote-tracking branch 'svnexport/master'
commit
ee7514c1ca
@ -1,409 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Postfix Admin
|
||||
*
|
||||
* LICENSE
|
||||
* This source file is subject to the GPL license that is bundled with
|
||||
* this package in the file LICENSE.TXT.
|
||||
*
|
||||
* Further details on the project are available at http://postfixadmin.sf.net
|
||||
*
|
||||
* @version $Id$
|
||||
* @license GNU GPL v2 or later.
|
||||
*
|
||||
* File: fetchmail.php
|
||||
* Responsible for setting up fetchmail
|
||||
* template : fetchmail.tpl
|
||||
*
|
||||
* @version $Id$
|
||||
* @license GNU GPL v2 or later.
|
||||
*
|
||||
* Template Variables:
|
||||
*
|
||||
* Form POST \ GET Variables:
|
||||
*
|
||||
* GET:
|
||||
* - edit
|
||||
* - delete
|
||||
* - new
|
||||
*
|
||||
* POST:
|
||||
* - save
|
||||
* - cancel
|
||||
* - all editable form values, see $fm_struct
|
||||
*/
|
||||
|
||||
require_once('common.php');
|
||||
|
||||
authentication_require_role('admin');
|
||||
|
||||
# workaround for https://sourceforge.net/p/postfixadmin/bugs/322/
|
||||
# TODO: convert fetchmail.php to FetchmailHandler
|
||||
$old_error_reporting = error_reporting();
|
||||
error_reporting($old_error_reporting ^ E_NOTICE);
|
||||
|
||||
$extra_options = 0;
|
||||
if ($CONF['fetchmail_extra_options'] == 'YES') $extra_options = 1;
|
||||
|
||||
# import control GET/POST variables. Form values are imported below.
|
||||
$new = (int) safeget ("new") == 1 ? 1:0;
|
||||
$edit = (int) safeget ("edit");
|
||||
$delete = (int) safeget ("delete");
|
||||
$save = safepost("save") != "" ? 1:0;
|
||||
$cancel = safepost("cancel") != "" ? 1:0;
|
||||
|
||||
$display_status = 1;
|
||||
if ($new || $edit) $display_status = 0;
|
||||
|
||||
$fm_struct=array( // list($editible,$view,$type)
|
||||
# field name allow editing? display field? type
|
||||
"id" => array(0, 0, 'id' ),
|
||||
"mailbox" => array(1, 1, 'enum' ),
|
||||
"src_server" => array(1, 1, 'text' ),
|
||||
"src_auth" => array(1, 1, 'enum' ),
|
||||
"src_user" => array(1, 1, 'text' ),
|
||||
"src_password" => array(1, 0, 'password' ),
|
||||
"src_folder" => array(1, 1, 'text' ),
|
||||
"poll_time" => array(1, 1, 'num' ),
|
||||
"fetchall" => array(1, 1, 'bool' ),
|
||||
"keep" => array(1, 1, 'bool' ),
|
||||
"protocol" => array(1, 1, 'enum' ),
|
||||
"usessl" => array(1, 1, 'bool' ),
|
||||
"sslcertck" => array(1, 1, 'bool' ),
|
||||
"sslcertpath" => array($extra_options, $extra_options, 'text' ), # TODO: input validation
|
||||
"sslfingerprint" => array($extra_options, $extra_options, 'text' ), # TODO: input validation
|
||||
"extra_options" => array($extra_options, $extra_options, 'longtext' ),
|
||||
"mda" => array($extra_options, $extra_options, 'longtext' ),
|
||||
"date" => array(0, $display_status, 'text' ),
|
||||
"returned_text" => array(0, $display_status, 'longtext' ),
|
||||
);
|
||||
# labels and descriptions are taken from $PALANG['pFetchmail_field_xxx'] and $PALANG['pFetchmail_desc_xxx']
|
||||
|
||||
# TODO: After pressing save or cancel in edit form, date and returned text are not displayed in list view.
|
||||
# TODO: Reason: $display_status is set before $new and $edit are reset to 0.
|
||||
# TODO: Fix: split the "display field?" column into "display in list" and "display in edit mode".
|
||||
|
||||
$SESSID_USERNAME = authentication_get_username();
|
||||
if (!$SESSID_USERNAME )
|
||||
exit;
|
||||
|
||||
$fm_defaults=array(
|
||||
"id" =>0,
|
||||
"mailbox" => array($SESSID_USERNAME),
|
||||
"poll_time" => 10,
|
||||
"src_auth" =>
|
||||
array('password','kerberos_v5','kerberos','kerberos_v4','gssapi','cram-md5','otp','ntlm','msn','ssh','any'),
|
||||
"protocol" =>
|
||||
array('POP3','IMAP','POP2','ETRN','AUTO'),
|
||||
);
|
||||
|
||||
$table_fetchmail = table_by_key('fetchmail');
|
||||
$table_mailbox = table_by_key('mailbox');
|
||||
|
||||
if (authentication_has_role('global-admin')) {
|
||||
$list_domains = list_domains ();
|
||||
} else {
|
||||
$list_domains = list_domains_for_admin(authentication_get_username());
|
||||
}
|
||||
|
||||
$user_domains=implode(", ",array_values($list_domains)); # for displaying
|
||||
$user_domains_sql=implode("','",escape_string(array_values($list_domains))); # for SQL
|
||||
$sql="SELECT username FROM $table_mailbox WHERE domain in ('".$user_domains_sql."')"; # TODO: replace with domain selection dropdown
|
||||
|
||||
$res = db_query ($sql);
|
||||
if ($res['rows'] > 0){
|
||||
$fm_defaults["mailbox"]=array();
|
||||
while ($name = db_array ($res['result'])){
|
||||
$fm_defaults["mailbox"][] = $name["username"];
|
||||
}
|
||||
}
|
||||
else{
|
||||
$fm_defaults["mailbox"]=array();
|
||||
$fm_defaults["mailbox"][]=$SESSID_USERNAME; # TODO: Does this really make sense? Or should we display a message "please create a mailbox first!"?
|
||||
}
|
||||
|
||||
$row_id = 0;
|
||||
if ($delete) {
|
||||
$row_id = $delete;
|
||||
} elseif ($edit) {
|
||||
$row_id = $edit;
|
||||
}
|
||||
|
||||
$user_mailboxes_sql= "'" . implode("','",escape_string(array_values($fm_defaults["mailbox"]))) . "'"; # mailboxes as SQL
|
||||
if ($row_id) {
|
||||
$result = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail WHERE id=$row_id AND mailbox IN ($user_mailboxes_sql)");
|
||||
# TODO: the "AND mailbox IN ..." part should obsolete the check_owner call. Remove it after checking again.
|
||||
if ($result['rows'] > 0) {
|
||||
$edit_row = db_array ($result['result']);
|
||||
$account = $edit_row['src_user'] . " @ " . $edit_row['src_server'];
|
||||
}
|
||||
|
||||
$edit_row_domain = explode('@', $edit_row['mailbox']);
|
||||
if ($result['rows'] <= 0 || !check_owner($SESSID_USERNAME, $edit_row_domain[1])) { # owner check for $edit and $delete
|
||||
flash_error(sprintf($PALANG['pFetchmail_error_invalid_id'], $row_id));
|
||||
$edit = 0; $delete = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($cancel) { # cancel $new or $edit
|
||||
$edit=0;
|
||||
$new=0;
|
||||
} elseif ($delete) { # delete an entry
|
||||
$result = db_query ("delete from $table_fetchmail WHERE id=".$delete);
|
||||
if ($result['rows'] != 1)
|
||||
{
|
||||
flash_error($PALANG['pDelete_delete_error']);
|
||||
} else {
|
||||
flash_info(sprintf($PALANG['pDelete_delete_success'],$account));
|
||||
}
|
||||
$delete=0;
|
||||
} elseif ( ($edit || $new) && $save) { # $edit or $new AND save button pressed
|
||||
$formvars=array();
|
||||
foreach($fm_struct as $key=>$row){
|
||||
list($editible,$view,$type)=$row;
|
||||
if ($editible != 0){
|
||||
$func="_inp_".$type;
|
||||
$val=safepost($key);
|
||||
if ($type!="password" || strlen($val) > 0) { # skip on empty (aka unchanged) password
|
||||
$formvars[$key]= escape_string( function_exists($func) ?$func($val) :$val);
|
||||
}
|
||||
}
|
||||
}
|
||||
$formvars['id'] = $edit; # results in 0 on $new
|
||||
if(db_pgsql() && $new) {
|
||||
// skip - shouldn't need to specify this as it will default to the next available value anyway.
|
||||
unset($formvars['id']);
|
||||
}
|
||||
|
||||
if (!in_array($formvars['mailbox'], $fm_defaults['mailbox'])) {
|
||||
flash_error($PALANG['pFetchmail_invalid_mailbox']);
|
||||
$save = 0;
|
||||
}
|
||||
if ($formvars['src_server'] == '') {
|
||||
flash_error($PALANG['pFetchmail_server_missing']);
|
||||
# TODO: validate domain name
|
||||
$save = 0;
|
||||
}
|
||||
if (empty($formvars['src_user']) ) {
|
||||
flash_error($PALANG['pFetchmail_user_missing']);
|
||||
$save = 0;
|
||||
}
|
||||
if ($new && empty($formvars['src_password']) ) {
|
||||
flash_error($PALANG['pFetchmail_password_missing']);
|
||||
$save = 0;
|
||||
}
|
||||
|
||||
if ($save) {
|
||||
if ($new) {
|
||||
$sql="INSERT INTO $table_fetchmail (".implode(",",escape_string(array_keys($formvars))).") VALUES ('".implode("','",escape_string($formvars))."')";
|
||||
} else { # $edit
|
||||
foreach(array_keys($formvars) as $key) {
|
||||
$formvars[$key] = escape_string($key) . "='" . escape_string($formvars[$key]) . "'";
|
||||
}
|
||||
$sql="UPDATE $table_fetchmail SET ".implode(",",$formvars).",returned_text='', date=NOW() WHERE id=".$edit;
|
||||
}
|
||||
$result = db_query ($sql);
|
||||
if ($result['rows'] != 1)
|
||||
{
|
||||
flash_error($PALANG['pFetchmail_database_save_error']);
|
||||
} else {
|
||||
flash_info($PALANG['pFetchmail_database_save_success']);
|
||||
$edit = 0; $new = 0; # display list after saving
|
||||
}
|
||||
} else {
|
||||
$formvars['src_password'] = ''; # never display password
|
||||
}
|
||||
|
||||
} elseif ($edit) { # edit entry form
|
||||
$formvars = $edit_row;
|
||||
$formvars['src_password'] = '';
|
||||
if (db_pgsql()) {
|
||||
$formvars['fetchall']=('t'==$formvars['fetchall']) ? 1 : 0;
|
||||
$formvars['keep']=('t'==$formvars['keep']) ? 1 : 0;
|
||||
$formvars['usessl']=('t'==$formvars['usessl']) ? 1 : 0;
|
||||
$formvars['sslcertck']=('t'==$formvars['sslcertck']) ? 1: 0;
|
||||
}
|
||||
} elseif ($new) { # create entry form
|
||||
foreach (array_keys($fm_struct) as $value) {
|
||||
if (isset($fm_defaults[$value])) {
|
||||
$formvars[$value] = $fm_defaults[$value];
|
||||
} else {
|
||||
$formvars[$value] = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tFmail = array();
|
||||
if ($edit + $new == 0) { # display list
|
||||
# TODO: ORDER BY would even be better if it would order by the _domain_ of the target mailbox first
|
||||
$res = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail WHERE mailbox IN ($user_mailboxes_sql) ORDER BY mailbox,src_server,src_user");
|
||||
if ($res['rows'] > 0) {
|
||||
while ($row = db_array ($res['result'])) {
|
||||
if (db_pgsql()) {
|
||||
//. at least in my database, $row['modified'] already looks like : 2009-04-11 21:38:10.75586+01,
|
||||
// while gmstrftime expects an integer value. strtotime seems happy though.
|
||||
//$row['date']=gmstrftime('%c %Z',$row['date']);
|
||||
$row['date'] = date('Y-m-d H:i:s', strtotime($row['date']));
|
||||
$row['fetchall']=('t'==$row['fetchall']) ? 1 : 0;
|
||||
$row['keep']=('t'==$row['keep']) ? 1 : 0;
|
||||
$row['usessl']=('t'==$row['usessl']) ? 1 : 0;
|
||||
$row['sslcertck']=('t'==$row['sslcertck']) ? 1: 0;
|
||||
}
|
||||
$tFmail[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function _inp_num($val){
|
||||
return (int)($val);
|
||||
}
|
||||
|
||||
function _inp_bool($val){
|
||||
return $val ? db_get_boolean(true): db_get_boolean(false);
|
||||
}
|
||||
|
||||
function _inp_password($val){
|
||||
return base64_encode($val);
|
||||
}
|
||||
//*****
|
||||
$headers=array();
|
||||
foreach(array_keys($fm_struct) as $row){
|
||||
list($editible,$view,$type)=$fm_struct[$row];
|
||||
$title = $PALANG['pFetchmail_field_' . $row];
|
||||
$comment = $PALANG['pFetchmail_desc_' . $row];
|
||||
if ($view){
|
||||
$headers[]=$title;
|
||||
// $headers[]=array($editible, $view, $type, $title, $comment);
|
||||
}
|
||||
}
|
||||
function fetchmail_edit_row($data=array())
|
||||
{
|
||||
global $fm_struct,$fm_defaults,$PALANG;
|
||||
$id = $data["id"];
|
||||
$_id = $data["id"] * 100 + 1;
|
||||
$ret = "<table>";
|
||||
$ret .= '<tr><th colspan="3">'.$PALANG['pMenu_fetchmail'] . '</th></tr>';
|
||||
# TODO: $formvars possibly contains db-specific boolean values
|
||||
# TODO: no problems with MySQL, to be tested with PgSQL
|
||||
# TODO: undefined values may also occour
|
||||
foreach($fm_struct as $key=>$struct){
|
||||
list($editible,$view,$type)=$struct;
|
||||
$title = $PALANG['pFetchmail_field_' . $key];
|
||||
$comment = $PALANG['pFetchmail_desc_' . $key];
|
||||
if ($editible){
|
||||
$ret.="<tr><td class=\"label\"><label for='${_id}'>${title}:</label></td>";
|
||||
$ret.="<td>";
|
||||
$func="_edit_".$type;
|
||||
if (! function_exists($func))
|
||||
$func="_edit_text";
|
||||
$val=isset($data[$key])
|
||||
?$data[$key]
|
||||
:(! is_array($fm_defaults[$key])
|
||||
?$fm_defaults[$key]
|
||||
:''
|
||||
);
|
||||
$fm_defaults_key = ""; if (isset($fm_defaults[$key])) $fm_defaults_key = $fm_defaults[$key];
|
||||
$ret.=$func($_id++,$key,$fm_defaults_key,$val);
|
||||
$ret.="</td><td><em>${comment}</em></td></tr>\n";
|
||||
}
|
||||
elseif($view){
|
||||
$func="_view_".$type;
|
||||
$val=isset($data[$key])
|
||||
?(function_exists($func)
|
||||
?$func($data[$key])
|
||||
:nl2br($data[$key])
|
||||
)
|
||||
:"--x--";
|
||||
$ret.="<tr><td class=\"label\">${title}:</label></td>";
|
||||
$ret.="<td >".$val;
|
||||
$ret.="</td><td><em>${comment}</em></td></tr>\n";
|
||||
}
|
||||
}
|
||||
$ret.="<tr><td> </td><td colspan=2>
|
||||
<input type=submit class=\"button\" name=save value='" . $PALANG['save'] . "' />
|
||||
<input type=submit class=\"button\" name=cancel value='" . $PALANG['cancel'] . "' />
|
||||
";
|
||||
if ($id){
|
||||
$ret.="<input type=hidden name=edit value='${id}'>";
|
||||
}
|
||||
$ret.="</td></tr>\n";
|
||||
$ret.="</table>\n";
|
||||
$ret.="<br />\n";
|
||||
$ret.="</form>\n";
|
||||
$ret.="</div>\n";
|
||||
return $ret;
|
||||
}
|
||||
function _edit_text($id,$key,$def_vals,$val=""){
|
||||
$val=htmlspecialchars($val);
|
||||
return "<input type=text name=${key} id=${id} value='${val}' />";
|
||||
}
|
||||
|
||||
function _edit_password($id,$key,$def_vals,$val=""){
|
||||
$val=preg_replace("{.}","*",$val);
|
||||
return "<input type=password name=${key} id=${id} value='${val}' />";
|
||||
}
|
||||
|
||||
function _edit_num($id,$key,$def_vals,$val=""){
|
||||
$val=(int)($val);
|
||||
return "<input type=text name=${key} id=${id} value='${val}' />";
|
||||
}
|
||||
|
||||
function _edit_bool($id,$key,$def_vals,$val=""){
|
||||
$ret="<input type=checkbox name=${key} id=${id}";
|
||||
if ($val)
|
||||
$ret.=' checked="checked"';
|
||||
$ret.=" />";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function _edit_longtext($id,$key,$def_vals,$val=""){
|
||||
$val=htmlspecialchars($val);
|
||||
return "<textarea name=${key} id=${id} rows=2 style='width:20em;'>${val}</textarea>";
|
||||
}
|
||||
|
||||
function _edit_enum($id,$key,$def_vals,$val=""){
|
||||
$ret="<select name=${key} id=${id}>";
|
||||
foreach($def_vals as $opt_val){
|
||||
$ret.="<option";
|
||||
if ($opt_val==$val)
|
||||
$ret.=" selected";
|
||||
$ret.=">${opt_val}</option>\n";
|
||||
}
|
||||
$ret.="</select>\n";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function _listview_id($val){
|
||||
return "<a href='?edit=${val}'> ${val} </a>";
|
||||
}
|
||||
|
||||
function _listview_bool($val){
|
||||
return $val?"+":"";
|
||||
}
|
||||
|
||||
function _listview_longtext($val){
|
||||
return strlen($val)?"Text - ".strlen($val)." chars":"--x--";
|
||||
}
|
||||
|
||||
function _listview_text($val){
|
||||
return sizeof($val)?$val:"--x--";
|
||||
}
|
||||
|
||||
function _listview_password($val){
|
||||
return preg_replace("{.}","*",$val);
|
||||
}
|
||||
|
||||
$smarty->assign ('edit', $edit);
|
||||
$smarty->assign ('new', $new);
|
||||
$smarty->assign ('fetchmail_edit_row', fetchmail_edit_row($formvars),false);
|
||||
$smarty->assign ('headers', $headers);
|
||||
$smarty->assign ('user_domains', $user_domains);
|
||||
$smarty->assign ('tFmail', $tFmail);
|
||||
$smarty->assign ('extra_options', $extra_options);
|
||||
|
||||
$smarty->assign ('smarty_template', 'fetchmail');
|
||||
$smarty->display ('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||||
?>
|
Binary file not shown.
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Postfix Admin
|
||||
*
|
||||
* LICENSE
|
||||
* This source file is subject to the GPL license that is bundled with
|
||||
* this package in the file LICENSE.TXT.
|
||||
*
|
||||
* Further details on the project are available at http://postfixadmin.sf.net
|
||||
*
|
||||
* @version $Id$
|
||||
* @license GNU GPL v2 or later.
|
||||
*
|
||||
* File: list-admin.php
|
||||
* Lists all administrators
|
||||
* Template File: list-admin.tpl
|
||||
*
|
||||
* Template Variables: -none-
|
||||
*
|
||||
* Form POST \ GET Variables: -none-
|
||||
*/
|
||||
|
||||
require_once("common.php");
|
||||
|
||||
authentication_require_role('global-admin');
|
||||
|
||||
$admin_properties = list_admins();
|
||||
|
||||
$smarty->assign ('admin_properties', $admin_properties);
|
||||
$smarty->assign ('smarty_template', 'adminlistadmin');
|
||||
$smarty->display ('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
@ -0,0 +1,181 @@
|
||||
<?php
|
||||
# $Id$
|
||||
|
||||
/**
|
||||
* Handler for fetchmail jobs
|
||||
*/
|
||||
class FetchmailHandler extends PFAHandler {
|
||||
|
||||
protected $db_table = 'fetchmail';
|
||||
protected $id_field = 'id';
|
||||
protected $domain_field = 'domain';
|
||||
protected $order_by = 'domain, mailbox';
|
||||
|
||||
|
||||
protected function initStruct() {
|
||||
$src_auth_options = array('password','kerberos_v5','kerberos','kerberos_v4','gssapi','cram-md5','otp','ntlm','msn','ssh','any');
|
||||
$src_protocol_options = array('POP3','IMAP','POP2','ETRN','AUTO');
|
||||
|
||||
$extra = Config::intbool('fetchmail_extra_options');
|
||||
|
||||
$this->struct=array(
|
||||
# field name allow display in... type $PALANG label $PALANG description default / options / ...
|
||||
# editing? form list
|
||||
'id' => pacol( 0, 0, 1, 'num' , '' , '' ),
|
||||
'domain' => pacol( 0, 0, 1, 'text', '' , '' ),
|
||||
'mailbox' => pacol( 1, 1, 1, 'enum', 'pFetchmail_field_mailbox' , 'pFetchmail_desc_mailbox' ), # mailbox list
|
||||
'src_server' => pacol( 1, 1, 1, 'text', 'pFetchmail_field_src_server' , 'pFetchmail_desc_src_server' ),
|
||||
'src_auth' => pacol( 1, 1, 1, 'enum', 'pFetchmail_field_src_auth' , 'pFetchmail_desc_src_auth' , '', $src_auth_options),
|
||||
'src_user' => pacol( 1, 1, 1, 'text', 'pFetchmail_field_src_user' , 'pFetchmail_desc_src_user' ),
|
||||
'src_password' => pacol( 1, 1, 0, 'b64p', 'pFetchmail_field_src_password' , 'pFetchmail_desc_src_password' ),
|
||||
'src_folder' => pacol( 1, 1, 1, 'text', 'pFetchmail_field_src_folder' , 'pFetchmail_desc_src_folder' ),
|
||||
'poll_time' => pacol( 1, 1, 1, 'num' , 'pFetchmail_field_poll_time' , 'pFetchmail_desc_poll_time' , 10 ),
|
||||
'fetchall' => pacol( 1, 1, 1, 'bool', 'pFetchmail_field_fetchall' , 'pFetchmail_desc_fetchall' ),
|
||||
'keep' => pacol( 1, 1, 1, 'bool', 'pFetchmail_field_keep' , 'pFetchmail_desc_keep' ),
|
||||
'protocol' => pacol( 1, 1, 1, 'enum', 'pFetchmail_field_protocol' , 'pFetchmail_desc_protocol' , '', $src_protocol_options),
|
||||
'usessl' => pacol( 1, 1, 1, 'bool', 'pFetchmail_field_usessl' , 'pFetchmail_desc_usessl' ),
|
||||
'sslcertck' => pacol( 1, 1, 1, 'bool', 'pFetchmail_field_sslcertck' , '' ),
|
||||
'sslcertpath' => pacol( $extra, $extra, $extra, 'text', 'pFetchmail_field_sslcertpath' , '' ),
|
||||
'sslfingerprint'=> pacol( $extra, $extra, $extra, 'text', 'pFetchmail_field_sslfingerprint','' ),
|
||||
'extra_options' => pacol( $extra, $extra, $extra, 'text', 'pFetchmail_field_extra_options', 'pFetchmail_desc_extra_options' ),
|
||||
'mda' => pacol( $extra, $extra, $extra, 'text', 'pFetchmail_field_mda' , 'pFetchmail_desc_mda' ),
|
||||
'date' => pacol( 0, 0, 1, 'text', 'pFetchmail_field_date' , 'pFetchmail_desc_date' , 1 ),
|
||||
'returned_text' => pacol( 0, 0, 1, 'text', 'pFetchmail_field_returned_text', 'pFetchmail_desc_returned_text' ),
|
||||
'active' => pacol( 1, 1, 1, 'bool', 'active' , '' , 1 ),
|
||||
'created' => pacol( 0, 0, 0, 'ts', 'created' , '' ),
|
||||
'modified' => pacol( 0, 0, 1, 'ts', 'last_modified' , '' ),
|
||||
);
|
||||
|
||||
# get list of mailboxes (for currently logged in user)
|
||||
$handler = new MailboxHandler(0, $this->admin_username);
|
||||
$handler->getList('1=1');
|
||||
$this->struct['mailbox']['options'] = array_keys($handler->result);
|
||||
}
|
||||
|
||||
protected function initMsg() {
|
||||
$this->msg['error_already_exists'] = 'fetchmail_already_exists';
|
||||
$this->msg['error_does_not_exist'] = 'fetchmail_does_not_exist';
|
||||
$this->msg['confirm_delete'] = 'confirm_delete_fetchmail';
|
||||
|
||||
if ($this->new) {
|
||||
$this->msg['logname'] = 'create_fetchmail';
|
||||
$this->msg['store_error'] = 'pFetchmail_database_save_error';
|
||||
$this->msg['successmessage'] = 'pFetchmail_database_save_success';
|
||||
} else {
|
||||
$this->msg['logname'] = 'edit_fetchmail';
|
||||
$this->msg['store_error'] = 'pFetchmail_database_save_error';
|
||||
$this->msg['successmessage'] = 'pFetchmail_database_save_success';
|
||||
}
|
||||
}
|
||||
|
||||
public function webformConfig() {
|
||||
return array(
|
||||
# $PALANG labels
|
||||
'formtitle_create' => 'pMenu_fetchmail',
|
||||
'formtitle_edit' => 'pMenu_fetchmail',
|
||||
'create_button' => 'pFetchmail_new_entry',
|
||||
|
||||
# various settings
|
||||
'required_role' => 'admin',
|
||||
'listview' => 'list.php?table=fetchmail',
|
||||
'early_init' => 0,
|
||||
'prefill' => array('mailbox'),
|
||||
);
|
||||
}
|
||||
|
||||
protected function domain_from_id() {
|
||||
# do nothing, setmore() does the work
|
||||
}
|
||||
|
||||
protected function setmore($values) {
|
||||
# set domain based on the target mailbox
|
||||
if ($this->new || isset($values['mailbox']) ) {
|
||||
list(/*NULL*/,$domain) = explode('@', $values['mailbox']);
|
||||
$this->values['domain'] = $domain;
|
||||
$this->domain = $domain;
|
||||
}
|
||||
}
|
||||
|
||||
protected function validate_new_id() {
|
||||
# auto_increment - any non-empty ID is an error
|
||||
if ($this->id != '') {
|
||||
$this->errormsg[$this->id_field] = 'auto_increment value, you must pass an empty string!';
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return true on success false on failure
|
||||
*/
|
||||
public function delete() {
|
||||
if ( ! $this->view() ) {
|
||||
$this->errormsg[] = Config::lang($this->msg['error_does_not_exist']);
|
||||
return false;
|
||||
}
|
||||
|
||||
db_delete($this->db_table, $this->id_field, $this->id);
|
||||
|
||||
db_log ($this->id, 'delete_fetchmail', $this->result['id']);
|
||||
$this->infomsg[] = Config::Lang_f('pDelete_delete_success', $this->result['src_user'] . ' -> ' . $this->result['mailbox']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* validate src_server - must be non-empty and survive check_domain()
|
||||
*/
|
||||
protected function _validate_src_server($field, $val) {
|
||||
if ($val == '') {
|
||||
$msg = Config::Lang('pFetchmail_server_missing');
|
||||
} else {
|
||||
$msg = check_domain($val);
|
||||
}
|
||||
|
||||
if ($msg == '') {
|
||||
return true;
|
||||
} else {
|
||||
$this->errormsg[$field] = $msg;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* validate src_user and src_password - must be non-empty
|
||||
* (we can't assume anything about valid usernames and passwords on remote
|
||||
* servers, so the validation can't be more strict)
|
||||
*/
|
||||
protected function _validate_src_user($field, $val) {
|
||||
if ($val == '') {
|
||||
$this->errormsg[$field] = Config::lang('pFetchmail_user_missing');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
protected function _validate_src_password($field, $val) {
|
||||
if ($val == '') {
|
||||
$this->errormsg[$field] = Config::lang('pFetchmail_password_missing');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* validate poll interval - must be numeri and > 0
|
||||
*/
|
||||
protected function _validate_poll_time($field, $val) {
|
||||
# must be > 0
|
||||
if ($val < 1) {
|
||||
$this->errormsg[$field] = Config::Lang_f('must_be_numeric_bigger_than_null', $field);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
@ -1,29 +0,0 @@
|
||||
{if $admin_properties}
|
||||
<table id="admin_table">
|
||||
{#tr_header#}
|
||||
<td>{$PALANG.admin}</td>
|
||||
<td>{$PALANG.pAdminList_admin_count}</td>
|
||||
<td>{$PALANG.last_modified}</td>
|
||||
<td>{$PALANG.active}</td>
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
{foreach from=$admin_properties item=admin}
|
||||
{#tr_hilightoff#}
|
||||
<td><a href="list.php?table=domain&username={$admin.username|escape:"url"}">{$admin.username}</a></td>
|
||||
<td>
|
||||
{if $admin.superadmin == 1}
|
||||
{$PALANG.super_admin}
|
||||
{else}
|
||||
{$admin.domain_count}
|
||||
{/if}
|
||||
</td>
|
||||
<td>{$admin.modified}</td>
|
||||
<td><a href="{#url_editactive#}admin&id={$admin.username|escape:"url"}&active={if ($admin.active==0)}1{else}0{/if}&token={$smarty.session.PFA_token|escape:"url"}">{$admin._active}</a></td>
|
||||
<td><a href="{#url_edit_admin#}&edit={$admin.username|escape:"url"}">{$PALANG.edit}</a></td>
|
||||
<td><a href="{#url_delete#}?table=admin&delete={$admin.username|escape:"url"}&token={$smarty.session.PFA_token|escape:"url"}"
|
||||
onclick="return confirm ('{$PALANG.confirm}{$PALANG.admin}: {$admin.username}');">{$PALANG.del}</a></td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
<br /><a href="{#url_create_admin#}" class="button">{$PALANG.pAdminMenu_create_admin}</a><br />
|
||||
{/if}
|
@ -1,51 +0,0 @@
|
||||
{if $edit || $new}
|
||||
<div id="edit_form">
|
||||
<form name="fetchmail" method="post" action="">
|
||||
{$fetchmail_edit_row}
|
||||
{else}
|
||||
{assign var="colspan" value=$headers|@count}
|
||||
<div id="overview">
|
||||
<form name="frmOverview" method="post" action="">
|
||||
<table id="log_table" border="0">
|
||||
<tr>
|
||||
<th colspan="{$colspan+2}">{$PALANG.pFetchmail_welcome}{$user_domains}</th>
|
||||
</tr>
|
||||
{#tr_header#}
|
||||
{foreach from=$headers item=header}
|
||||
<td>{$header}</td>
|
||||
{/foreach}
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
{if $tFmail}
|
||||
{foreach from=$tFmail item=row}
|
||||
{#tr_hilightoff#}
|
||||
<td nowrap="nowrap">{$row.mailbox} </td>
|
||||
<td nowrap="nowrap">{$row.src_server} </td>
|
||||
<td nowrap="nowrap">{$row.src_auth} </td>
|
||||
<td nowrap="nowrap">{$row.src_user} </td>
|
||||
<td nowrap="nowrap">{$row.src_folder} </td>
|
||||
<td nowrap="nowrap">{$row.poll_time} </td>
|
||||
<td nowrap="nowrap">{$row.fetchall} </td>
|
||||
<td nowrap="nowrap">{$row.keep} </td>
|
||||
<td nowrap="nowrap">{$row.protocol} </td>
|
||||
<td nowrap="nowrap">{$row.usessl} </td>
|
||||
<td nowrap="nowrap">{$row.sslcertck} </td>
|
||||
{if $extra_options}
|
||||
<td nowrap="nowrap">{$row.sslcertpath} </td>
|
||||
<td nowrap="nowrap">{$row.sslfingerprint} </td>
|
||||
<td nowrap="nowrap">{$row.extra_options} </td>
|
||||
<td nowrap="nowrap">{$row.mda} </td>
|
||||
{/if}
|
||||
<td nowrap="nowrap">{$row.date} </td>
|
||||
<td nowrap="nowrap">{$row.returned_text}--x-- </td> <!-- Inhalt mit if auswerten! -->
|
||||
<td><a href="fetchmail.php?edit={$row.id|escape:"url"}">{$PALANG.edit}</a></td>
|
||||
<td><a href="fetchmail.php?delete={$row.id|escape:"url"}&token={$smarty.session.PFA_token|escape:"url"}"
|
||||
onclick="return confirm('{$PALANG.confirm}{$PALANG.pMenu_fetchmail}:{$row.src_user}@{$row.src_server}')">{$PALANG.del}</a></td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
<br /><a href='?new=1' class="button">{$PALANG.pFetchmail_new_entry}</a><br />
|
||||
{/if}
|
@ -1,52 +1,10 @@
|
||||
{#tr_header#}
|
||||
{if $CONF.show_status===YES}
|
||||
<td></td>
|
||||
{/if}
|
||||
<td>{$PALANG.pOverview_alias_address}</td>
|
||||
<td>{$PALANG.to}</td>
|
||||
<td>{$PALANG.last_modified}</td>
|
||||
<td>{$PALANG.active}</td>
|
||||
<td colspan="2"> </td>
|
||||
</tr>
|
||||
{foreach from=$tAlias item=item key=i}
|
||||
{#tr_hilightoff#}
|
||||
{if $CONF.show_status===YES}
|
||||
<td>{$gen_show_status[$i]}</td>
|
||||
{/if}
|
||||
<td>
|
||||
{if $search eq ""}
|
||||
{$item.address}
|
||||
{else}
|
||||
{$item.address|replace:$search:"<span class='searchresult'>$search</span>"}
|
||||
{/if}
|
||||
</td>
|
||||
{if $CONF.alias_goto_limit>0}
|
||||
<td><i>sorry, alias_goto_limit > 0 not handled</i></td>
|
||||
{else}
|
||||
<td>
|
||||
{foreach key=key2 item=singlegoto from=$item.goto}
|
||||
{assign var="table" value='alias'}
|
||||
{assign var="struct" value=$alias_data.struct}
|
||||
{assign var="msg" value=$alias_data.msg}
|
||||
{assign var="id_field" value=$msg.id_field}
|
||||
{assign var="formconf" value=$alias_data.formconf}
|
||||
{assign var="items" value=$tAlias}
|
||||
{assign var="RAW_items" value=$RAW_tAlias}
|
||||
|
||||
{if $search eq ""}
|
||||
{$singlegoto}<br />
|
||||
{else}
|
||||
{$singlegoto|replace:$search:"<span class='searchresult'>$search</span>"}<br />
|
||||
{/if}
|
||||
|
||||
{/foreach}
|
||||
</td>
|
||||
{/if}
|
||||
<td>{$item.modified}</td>
|
||||
{if $check_alias_owner[$i]==true}
|
||||
<td><a href="{#url_editactive#}alias&id={$item.address|escape:"url"}&active={if ($item.active==0)}1{else}0{/if}&token={$smarty.session.PFA_token|escape:"url"}"
|
||||
>{if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if}</a></td>
|
||||
<td><a href="{#url_create_alias#}&edit={$item.address|escape:"url"}">{$PALANG.edit}</a></td>
|
||||
<td><a href="delete.php?table=alias&delete={$item.address|escape:"url"}&token={$smarty.session.PFA_token|escape:"url"}"
|
||||
onclick="return confirm ('{$PALANG.confirm}{$PALANG.aliases}: {$item.address}');">{$PALANG.del}</a></td>
|
||||
{else}
|
||||
<td>{if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if}</td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
{include 'list.tpl'}
|
||||
|
||||
|
@ -1,46 +1,9 @@
|
||||
{*** Domain Aliases ***}
|
||||
<table id="alias_domain_table">
|
||||
<tr>
|
||||
<th colspan="6">{$PALANG.pOverview_alias_domain_title}</th>
|
||||
</tr>
|
||||
{if $tAliasDomains|@count>0}
|
||||
{if $tAliasDomains|@count>0} {* -> HAT alias-domains *}
|
||||
{#tr_header#}
|
||||
<td>{$PALANG.pOverview_alias_address}</td>
|
||||
<td>{$PALANG.to}</td>
|
||||
<td>{$PALANG.last_modified}</td>
|
||||
<td>{$PALANG.active}</td>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
{foreach from=$tAliasDomains item=item}
|
||||
{#tr_hilightoff#}
|
||||
<td>{if $item.alias_domain != $fDomain}<a href="{$smarty.config.url_list_virtual}?domain={$item.alias_domain|escape:"url"}">{/if}
|
||||
{if $search eq ""}
|
||||
{$item.alias_domain}
|
||||
{else}
|
||||
{$item.alias_domain|replace:$search:"<span class='searchresult'>$search</span>"}
|
||||
{/if}
|
||||
{if $item.alias_domain != $fDomain}</a>{/if}</td>
|
||||
<td>{if $item.target_domain != $fDomain}<a href="{$smarty.config.url_list_virtual}?domain={$item.target_domain|escape:"url"}">{/if}
|
||||
{if $search eq ""}
|
||||
{$item.target_domain}
|
||||
{else}
|
||||
{$item.target_domain|replace:$search:"<span class='searchresult'>$search</span>"}
|
||||
{/if}
|
||||
{if $item.target_domain != $fDomain}</a>{/if}</td>
|
||||
<td>{$item.modified}</td>
|
||||
<td><a href="{#url_editactive#}aliasdomain&id={$item.alias_domain|escape:"url"}&active={if ($item.active==0)}1{else}0{/if}&token={$smarty.session.PFA_token|escape:"url"}">{if $item.active==1}{$PALANG.YES}{else}{$PALANG.NO}{/if}</a></td>
|
||||
<td><a href="{#url_create_alias_domain#}&edit={$item.alias_domain|escape:"url"}">{$PALANG.edit}</a></td>
|
||||
<td><a href="{#url_delete#}?table=aliasdomain&delete={$item.alias_domain|escape:"url"}&token={$smarty.session.PFA_token|escape:"url"}"
|
||||
onclick="return confirm ('{$PALANG.confirm}{$PALANG.pOverview_get_alias_domains}: {$item.alias_domain} -> {$item.target_domain}');">{$PALANG.del}</a></td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{/if}
|
||||
{/if}
|
||||
</table>
|
||||
{if $can_create_alias_domain}
|
||||
<br/>
|
||||
<br /><a href="{#url_create_alias_domain#}&target_domain={$fDomain|escape:"url"}" class="button">{$PALANG.add_alias_domain}</a><br />
|
||||
|
||||
{/if}
|
||||
{assign var="table" value='aliasdomain'}
|
||||
{assign var="struct" value=$aliasdomain_data.struct}
|
||||
{assign var="msg" value=$aliasdomain_data.msg}
|
||||
{assign var="id_field" value=$msg.id_field}
|
||||
{assign var="formconf" value=$aliasdomain_data.formconf}
|
||||
{assign var="items" value=$tAliasDomains}
|
||||
{include 'list.tpl'}
|
||||
|
Loading…
Reference in New Issue