Restricted Auditor=1: Empty search results

Issue #555 resolved
Former user created an issue

After adding "$config['RESTRICTED_AUDITOR'] = 1;" to the configuration, I can't find any mails.

I added a user and assigned him to the domain, but the results are always empty. Without RESTRICTED_AUDITOR the search works.

Jun 17 11:31:39 mailarchive0 piler-webui[1158]: sphinx query: 'SELECT id FROM main1,dailydelta1,delta1 WHERE MATCH(' (@todomain domainXtld| | @fromdomain domainXtld| ) ') ORDER BY sent DESC LIMIT 0,1000 OPTION max_matches=1000' in 0.00 s, 0 hits, 0 total found

piler 1.1.1 on Ubuntu 14.04.2 [1] https://bitbucket.org/jsuto/piler/issue/154/permissions-for-auditor

Comments (7)

  1. Sebastian Henze

    Hey jsuto, Thank you very much for your response! I downloaded the master branch and replaced the webui. After this I copied back my config.php and config-site.php. But still the same issue :(

  2. Janos SUTO repo owner

    OK, replace the assemble_email_address_filter function with this one in model/search/search.php:

       private function assemble_email_address_filter() {
          $session = Registry::get('session');
    
          if(Registry::get('auditor_user') == 1) {
    
             if(RESTRICTED_AUDITOR == 1) {
    
                $session_domains = $this->fix_email_address_for_sphinx($session->get('auditdomains'));
    
                syslog(LOG_INFO, "domain=*" . $session->get('domain') . "*");
    
                $sd = $this->fix_email_address_for_sphinx($session->get('domain'));
                syslog(LOG_INFO, "sd=*$sd*");
    
                foreach ($session_domains as $d) {
                    if($d) { syslog(LOG_INFO, "d=*$d*"); $sd .= '|' . $d; }
                }
    
                $sd = preg_replace("/^\|/", "", $sd);
    
                return " (@todomain $sd | @fromdomain $sd ) ";
             }
    
             else { return ""; }
          }
    
          if(ENABLE_FOLDER_RESTRICTIONS == 1) { return ""; }
    
          $all_your_addresses = $this->get_all_your_address();
          return " (@from $all_your_addresses | @to $all_your_addresses) ";
       }
    

    Then logout and login again, and let's see what the gui syslogs when you login back.

  3. Sebastian Henze

    I just changed search.php the way you wrote :)

    Old code:

       private function assemble_email_address_filter() {
          $session = Registry::get('session');
    
          if(Registry::get('auditor_user') == 1) {
    
             if(RESTRICTED_AUDITOR == 1) {
                $session_domains = $this->fix_email_address_for_sphinx($session->get('auditdomains'));
    
                $sd = $this->fix_email_address_for_sphinx($session->get('domain'));
    
                foreach ($session_domains as $d) { $sd .= '|' . $d; }
    
                $sd = preg_replace("/^\|/", "", $sd);
    
                return " (@todomain $sd | @fromdomain $sd ) ";
             }
    
             else { return ""; }
          }
    
          if(ENABLE_FOLDER_RESTRICTIONS == 1) { return ""; }
    
          $all_your_addresses = $this->get_all_your_address();
          return " (@from $all_your_addresses | @to $all_your_addresses) ";
       }
    
  4. Log in to comment