Esempio n. 1
0
 protected function initStruct()
 {
     # hide 'goto_mailbox' if $this->new
     # (for existing aliases, init() hides it for non-mailbox aliases)
     $mbgoto = 1 - $this->new;
     $this->struct = array('status' => pacol(0, 0, 0, 'html', '', '', '', '', array('not_in_db' => 1)), 'address' => pacol($this->new, 1, 1, 'mail', 'alias', 'pCreate_alias_catchall_text'), 'localpart' => pacol($this->new, 0, 0, 'text', 'alias', 'pCreate_alias_catchall_text', '', '', 1), 'domain' => pacol($this->new, 0, 1, 'enum', '', '', '', $this->allowed_domains), 'goto' => pacol(1, 1, 1, 'txtl', 'to', 'pEdit_alias_help', array()), 'is_mailbox' => pacol(0, 0, 1, 'int', '', '', 0, '', 0, 1, 'coalesce(__is_mailbox,0) as is_mailbox, __mailbox_username', 'LEFT JOIN ( ' . ' SELECT 1 as __is_mailbox, username as __mailbox_username ' . ' FROM ' . table_by_key('mailbox') . ' WHERE username IS NOT NULL ' . ' ) AS __mailbox ON __mailbox_username = address'), 'goto_mailbox' => pacol($mbgoto, $mbgoto, $mbgoto, 'bool', 'pEdit_alias_forward_and_store', '', 0, '', 1), 'on_vacation' => pacol(1, 0, 1, 'bool', 'pUsersMenu_vacation', '', 0, '', 1), 'created' => pacol(0, 0, 0, 'ts', 'created', ''), 'modified' => pacol(0, 0, 1, 'ts', 'last_modified', ''), 'active' => pacol(1, 1, 1, 'bool', 'active', '', 1), '_can_edit' => pacol(0, 0, 1, 'vnum', '', '', 0, '', array('select' => '1 as _can_edit')), '_can_delete' => pacol(0, 0, 1, 'vnum', '', '', 0, '', array('select' => '1 as _can_delete')));
 }
Esempio n. 2
0
 protected function initStruct()
 {
     $this->struct = array('alias_domain' => pacol($this->new, 1, 1, 'enum', 'pCreate_alias_domain_alias', 'pCreate_alias_domain_alias_text', '', array(), array('linkto' => 'list-virtual.php?domain=%s')), 'target_domain' => pacol(1, 1, 1, 'enum', 'pCreate_alias_domain_target', 'pCreate_alias_domain_target_text', '', array()), 'created' => pacol(0, 0, 0, 'ts', 'created', ''), 'modified' => pacol(0, 0, 1, 'ts', 'last_modified', ''), 'active' => pacol(1, 1, 1, 'bool', 'active', '', 1));
     # check which domains are available as an alias- or target-domain
     $this->getList("");
     $used_targets = array();
     foreach ($this->allowed_domains as $dom) {
         if (isset($this->result[$dom])) {
             # already used as alias_domain
             $used_targets[$this->result[$dom]['target_domain']] = $this->result[$dom]['target_domain'];
         } else {
             # might be available
             $this->struct['alias_domain']['options'][$dom] = $dom;
             $this->struct['target_domain']['options'][$dom] = $dom;
         }
     }
     foreach ($this->struct['alias_domain']['options'] as $dom) {
         if (isset($used_targets[$dom])) {
             unset($this->struct['alias_domain']['options'][$dom]);
         }
         # don't allow chained domain aliases (domain1 -> domain2 -> domain3)
     }
     if (count($this->struct['alias_domain']['options']) == 1) {
         # only one alias_domain available - filter it out from target_domain list
         $keys = array_keys($this->struct['alias_domain']['options']);
         unset($this->struct['target_domain']['options'][$keys[0]]);
     }
 }
 protected function initStruct()
 {
     $this->struct = array('username' => pacol($this->new, 1, 1, 'mail', 'pEdit_mailbox_username', '', ''), 'local_part' => pacol($this->new, 0, 0, 'text', 'pEdit_mailbox_username', '', ''), 'domain' => pacol($this->new, 0, 1, 'enum', '', '', '', $this->allowed_domains), 'maildir' => pacol($this->new, 0, 1, 'text', '', '', ''), 'password' => pacol(1, 1, 0, 'pass', 'password', 'pCreate_mailbox_password_text', ''), 'password2' => pacol(1, 1, 0, 'pass', 'password_again', '', '', '', 0, 1, 'password as password2'), 'name' => pacol(1, 1, 1, 'text', 'name', 'pCreate_mailbox_name_text', ''), 'quota' => pacol(1, 1, 1, 'int', 'pEdit_mailbox_quota', 'pEdit_mailbox_quota_text', ''), 'active' => pacol(1, 1, 1, 'bool', 'active', '', 1), 'welcome_mail' => pacol($this->new, $this->new, 0, 'bool', 'pCreate_mailbox_mail', '', 1, '', 1), 'created' => pacol(0, 0, 1, 'ts', 'created', ''), 'modified' => pacol(0, 0, 1, 'ts', 'last_modified', ''));
     # update allowed quota
     if (count($this->struct['domain']['options']) > 0) {
         $this->prefill('domain', $this->struct['domain']['options'][0]);
     }
 }
Esempio n. 4
0
 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('id' => pacol(0, 0, 1, 'num', '', ''), 'domain' => pacol(0, 0, 1, 'text', '', ''), 'mailbox' => pacol(1, 1, 1, 'enum', 'pFetchmail_field_mailbox', 'pFetchmail_desc_mailbox'), '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);
 }
Esempio n. 5
0
 protected function initStruct()
 {
     # NOTE: There are dependencies between domains and domain_count
     # NOTE: If you disable "display in list" for domain_count, the SQL query for domains might break.
     # NOTE: (Disabling both shouldn't be a problem.)
     # TODO: move to a db_group_concat() function?
     if (db_pgsql()) {
         $domains_grouped = "array_to_string(array_agg(domain), ',')";
     } else {
         # mysql
         $domains_grouped = 'group_concat(domain)';
     }
     $this->struct = array('username' => pacol($this->new, 1, 1, 'text', 'admin', 'email_address', '', '', array('linkto' => 'list.php?table=domain&username=%s')), 'password' => pacol(1, 1, 0, 'pass', 'password', ''), 'password2' => pacol(1, 1, 0, 'pass', 'password_again', '', '', '', 0, 1, 'password as password2'), 'superadmin' => pacol(1, 1, 0, 'bool', 'super_admin', 'super_admin_desc', 0), 'domains' => pacol(1, 1, 0, 'list', 'domain', '', array(), list_domains(), 0, 1, "coalesce(domains,'') as domains"), 'domain_count' => pacol(0, 0, 1, 'vnum', 'pAdminList_admin_count', '', '', '', 0, 1, 'coalesce(__domain_count,0) as domain_count', 'LEFT JOIN ( ' . ' SELECT count(*) AS __domain_count, ' . $domains_grouped . ' AS domains, username AS __domain_username ' . ' FROM ' . table_by_key('domain_admins') . " WHERE domain != 'ALL' GROUP BY username " . ' ) AS __domain on username = __domain_username'), 'active' => pacol(1, 1, 1, 'bool', 'active', '', 1), 'created' => pacol(0, 0, 0, 'ts', 'created', ''), 'modified' => pacol(0, 0, 1, 'ts', 'last_modified', ''));
 }
 protected function initStruct()
 {
     # TODO: shorter PALANG labels ;-)
     $super = $this->is_superadmin;
     $transp = min($super, Config::intbool('transport'));
     $editquota = min($super, Config::intbool('quota'));
     $quota = Config::intbool('quota');
     $edit_dom_q = min($super, Config::intbool('domain_quota'), $quota);
     $dom_q = min(Config::intbool('domain_quota'), $quota);
     $query_used_domainquota = 'round(coalesce(__total_quota/' . intval(Config::read('quota_multiplier')) . ',0))';
     # NOTE: There are dependencies between alias_count, mailbox_count and total_quota.
     # NOTE: If you disable "display in list" for one of them, the SQL query for the others might break.
     # NOTE: (Disabling all of them shouldn't be a problem.)
     $this->struct = array('domain' => pacol($this->new, 1, 1, 'text', 'domain', '', '', '', array('linkto' => 'list-virtual.php?domain=%s')), 'description' => pacol($super, $super, $super, 'text', 'description', ''), 'aliases' => pacol($super, $super, 0, 'num', 'aliases', 'pAdminEdit_domain_aliases_text', Config::read('aliases')), 'alias_count' => pacol(0, 0, 1, 'vnum', '', '', '', '', 0, 1, 'coalesce(__alias_count,0) - coalesce(__mailbox_count,0)  as alias_count', 'left join ( select count(*) as __alias_count, domain as __alias_domain from ' . table_by_key('alias') . ' group by domain) as __alias on domain = __alias_domain'), 'aliases_quot' => pacol(0, 0, 1, 'quot', 'aliases', '', 0, '', array('select' => db_quota_text('__alias_count - coalesce(__mailbox_count,0)', 'aliases', 'aliases_quot'))), '_aliases_quot_percent' => pacol(0, 0, 1, 'vnum', '', '', 0, '', array('select' => db_quota_percent('__alias_count - coalesce(__mailbox_count,0)', 'aliases', '_aliases_quot_percent'))), 'mailboxes' => pacol($super, $super, 0, 'num', 'mailboxes', 'pAdminEdit_domain_aliases_text', Config::read('mailboxes')), 'mailbox_count' => pacol(0, 0, 1, 'vnum', '', '', '', '', 0, 1, 'coalesce(__mailbox_count,0) as mailbox_count', 'left join ( select count(*) as __mailbox_count, sum(quota) as __total_quota, domain as __mailbox_domain from ' . table_by_key('mailbox') . ' group by domain) as __mailbox on domain = __mailbox_domain'), 'mailboxes_quot' => pacol(0, 0, 1, 'quot', 'mailboxes', '', 0, '', array('select' => db_quota_text('__mailbox_count', 'mailboxes', 'mailboxes_quot'))), '_mailboxes_quot_percent' => pacol(0, 0, 1, 'vnum', '', '', 0, '', array('select' => db_quota_percent('__mailbox_count', 'mailboxes', '_mailboxes_quot_percent'))), 'maxquota' => pacol($editquota, $editquota, $quota, 'num', 'pOverview_get_quota', 'pAdminEdit_domain_maxquota_text', Config::read('maxquota')), 'quota' => pacol($edit_dom_q, $edit_dom_q, 0, 'num', 'pAdminEdit_domain_quota', 'pAdminEdit_domain_maxquota_text', Config::read('domain_quota_default')), 'total_quota' => pacol(0, 0, 1, 'vnum', '', '', '', '', array('select' => "{$query_used_domainquota} AS total_quota")), 'total_quot' => pacol(0, 0, $dom_q, 'quot', 'pAdminEdit_domain_quota', '', 0, '', array('select' => db_quota_text($query_used_domainquota, 'quota', 'total_quot'))), '_total_quot_percent' => pacol(0, 0, $dom_q, 'vnum', '', '', 0, '', array('select' => db_quota_percent($query_used_domainquota, 'quota', '_total_quot_percent'))), 'transport' => pacol($transp, $transp, $transp, 'enum', 'transport', 'pAdminEdit_domain_transport_text', Config::read('transport_default'), Config::read('transport_options')), 'backupmx' => pacol($super, $super, 1, 'bool', 'pAdminEdit_domain_backupmx', '', 0), 'active' => pacol($super, $super, 1, 'bool', 'active', '', 1), 'default_aliases' => pacol($this->new, $this->new, 0, 'bool', 'pAdminCreate_domain_defaultaliases', '', 1, '', 1), 'created' => pacol(0, 0, 0, 'ts', 'created', ''), 'modified' => pacol(0, 0, $super, 'ts', 'last_modified', ''), '_can_edit' => pacol(0, 0, 1, 'int', '', '', 0, '', 0, 1, $this->is_superadmin . ' as _can_edit'), '_can_delete' => pacol(0, 0, 1, 'int', '', '', 0, '', 0, 1, $this->is_superadmin . ' as _can_delete'));
 }
Esempio n. 7
0
 protected function initStruct()
 {
     # TODO: shorter PALANG labels ;-)
     $this->struct = array('username' => pacol(0, 1, 1, 'text', 'admin', ''), 'oldpass' => pacol(1, 1, 0, 'pass', 'pPassword_password_current', '', '', '', 1), 'password' => pacol(1, 1, 0, 'pass', 'pPassword_password', ''), 'password2' => pacol(1, 1, 0, 'pass', 'pPassword_password2', '', '', '', 0, 1, 'password as password2'));
 }
Esempio n. 8
0
 protected function initStruct()
 {
     $this->struct = array('email' => pacol($this->new, 1, 1, 'text', 'pLogin_username', '', ''), 'domain' => pacol(1, 0, 0, 'text', '', '', ''), 'subject' => pacol(1, 1, 0, 'text', 'pUsersVacation_subject', '', ''), 'body' => pacol(1, 1, 0, 'text', 'pUsersVacation_body', '', ''), 'activefrom' => pacol(1, 1, 1, 'text', 'pUsersVacation_activefrom', '', ''), 'activeuntil' => pacol(1, 1, 1, 'text', 'pUsersVacation_activeuntil', '', ''), 'active' => pacol(1, 1, 1, 'bool', 'active', '', 1), 'created' => pacol(0, 0, 1, 'ts', 'created', ''), 'modified' => pacol(0, 0, 1, 'ts', 'last_modified', ''));
 }
Esempio n. 9
0
 /**
  * Constructor: fill $struct etc.
  * @param integer - 0 is edit mode, set to 1 to switch to create mode
  * @param string - if an admin_username is specified, permissions will be restricted to the domains this admin may manage
  * @param integer - 0 if logged in as user, 1 if logged in as admin or superadmin
  */
 public function __construct($new = 0, $username = "", $is_admin = 1)
 {
     # set label_field if not explicitely set
     if (empty($this->label_field)) {
         $this->label_field = $this->id_field;
     }
     # set order_by if not explicitely set
     if (empty($this->order_by)) {
         $this->order_by = $this->id_field;
     }
     if ($new) {
         $this->new = 1;
     }
     if ($is_admin) {
         $this->admin_username = $username;
     } else {
         $this->username = $username;
         $this->is_admin = 0;
         $this->is_superadmin = 0;
     }
     if ($username != "" && !authentication_has_role('global-admin')) {
         $this->is_superadmin = 0;
     }
     if ($this->domain_field == "") {
         $this->no_domain_field();
     } else {
         if ($this->admin_username != "") {
             $this->allowed_domains = list_domains_for_admin($username);
         } else {
             $this->allowed_domains = list_domains();
         }
     }
     if ($this->user_field == '') {
         $this->no_user_field();
     }
     $this->initStruct();
     if (!isset($this->struct['_can_edit'])) {
         $this->struct['_can_edit'] = pacol(0, 0, 1, 'vnum', '', '', '', '', 0, 1, '1 as _can_edit');
     }
     if (!isset($this->struct['_can_delete'])) {
         $this->struct['_can_delete'] = pacol(0, 0, 1, 'vnum', '', '', '', '', 0, 1, '1 as _can_delete');
     }
     $struct_hook = Config::read($this->db_table . '_struct_hook');
     if ($struct_hook != 'NO' && function_exists($struct_hook)) {
         $this->struct = $struct_hook($this->struct);
     }
     $this->initMsg();
     $this->msg['id_field'] = $this->id_field;
     $this->msg['show_simple_search'] = count($this->searchfields) > 0;
 }