Ticket #300: dgm.patch

File dgm.patch, 11.5 kB (added by shalligan@…, 6 years ago)

patch for dgm

  • php/themes/dgm/templates/cache_pager.tpl

     
    1  
    2 {if count($data.pages) > 1} 
     1{if $pages.total > 1} 
    32<div align="center"> 
    4 {if $offset > 0} 
    5 <a href="list-cache.php{$msid}cache_type={$cache_type}&amp;offset={$data.prev}">&lt;&lt; {$lang.link_prev} </a>&nbsp;| 
    6 {/if} 
    7 {strip} 
    8 {foreach key=page item=start from=$data.pages} 
    9 {if $start != $offset} 
    10   <a href="list-cache.php{$msid}cache_type={$cache_type}&amp;offset={$start}">{$page}</a> 
    11   {else} 
    12      {$page} 
    13   {/if} 
    14   {if $page < count($data.pages)} 
    15 &nbsp;|&nbsp; 
    16    {/if} 
    17 {/foreach} 
    18 {/strip} 
    19 {if $data.to < $data.numrows} 
    20   | <a href="list-cache.php{$msid}cache_type={$cache_type}&amp;offset={$data.next}">{$lang.link_next}&gt;&gt;</a> 
    21 {/if} 
     3{$links} 
    224</div> 
    235{/if} 
    246<div> 
  • php/themes/dgm/templates/list-cache-table.tpl

     
    4747        </div> 
    4848     *}    
    4949        <div class="cache_select"> 
    50             <input type="checkbox" class="cachecheck" name="cache_item[{$row[hamloop].id}]" value="{$row[hamloop].id}"> 
     50            <input type="checkbox" class="cachecheck" name="cache_item[generic][{$row[hamloop].id}]" value="{$row[hamloop].id}"> 
    5151        </div> 
    5252      </div> <!-- cache row --> 
    5353    {/strip} 
  • php/themes/dgm/templates/viewmail.tpl

     
    77{if ! $error} 
    88<div class="viewmail_container"> 
    99<form action="list-cache.php{$msid}cache_type={$cache_type}" name="cache" method="post"> 
    10 <input type="hidden" name="cache_item[{$id}]" value="{$id}"> 
     10<input type="hidden" name="cache_item[generic][{$id}]" value="{$id}"> 
    1111 
    1212<div class="viewmail_table"> 
    1313{include file="viewmail_menu.tpl" showraw=true} 
  • php/cache.php

     
    205205    } 
    206206     
    207207    function set_select() { 
    208        $this->select_stmt = "SELECT maia_mail.id, maia_mail.received_date, maia_mail.score, " . 
    209                      "maia_mail.sender_email, maia_mail.subject, maia_mail.envelope_to " . 
     208       $this->select_count = "SELECT COUNT(*) " . 
    210209              "FROM maia_mail, maia_mail_recipients " . 
    211210              "WHERE maia_mail.id = maia_mail_recipients.mail_id " . 
    212211              "AND maia_mail_recipients.type = '". $this->get_sort_abbrev() ."' " . 
    213               "AND maia_mail_recipients.recipient_id = ? " . 
    214               "ORDER BY maia_mail." . $this->sortby['column'] . " " . $this->sort_order; 
     212              "AND maia_mail_recipients.recipient_id = ? "; 
     213 
     214        $this->select_stmt = "SELECT maia_mail.id, maia_mail.received_date, maia_mail.score, " . 
     215               "maia_mail.sender_email, maia_mail.subject, maia_mail.envelope_to " . 
     216              "FROM maia_mail, maia_mail_recipients " . 
     217              "WHERE maia_mail.id = maia_mail_recipients.mail_id " . 
     218              "AND maia_mail_recipients.type = '". $this->get_sort_abbrev() ."' " . 
     219              "AND maia_mail_recipients.recipient_id = ? " .  
     220              " ORDER BY maia_mail." . $this->sortby['column'] . " " . $this->sort_order; 
     221         
    215222    } 
    216223     
    217224    function confirm_cache($euid) {     
     
    222229                $rescued = 0; 
    223230        global $_POST, $lang; 
    224231        $items = $_POST['cache_item']; 
    225         foreach ($items as $mail_id => $value) { 
    226                 // report item 
    227                 if ($_POST['submit'] == "spam") { 
    228                      switch ($this->type) { 
    229                        case 'ham': 
    230                           // Mark the item as Confirmed Spam 
    231                           $update = "UPDATE maia_mail_recipients SET type = 'C' " . 
    232                                     "WHERE recipient_id = ? AND mail_id = ?"; 
    233                           $this->dbh->query($update, array($euid, $mail_id)); 
    234                           record_mail_stats($euid, $mail_id, "fn"); 
    235                           $reported++; 
    236                           break; 
    237                        case 'spam': 
    238                          confirm_spam($euid, $mail_id); 
    239                          $confirmed++; 
    240                        default: 
    241                      } 
    242                  //send item 
    243                 } elseif ($_POST['submit'] == "ham") { 
    244                     switch ($this->type) { 
    245                        case 'ham': 
    246                           confirm_ham($euid, $mail_id); 
    247                           $confirmed++; 
    248                           break; 
    249                        default: 
    250                           $result = rescue_item($euid, $mail_id); 
    251                           if (strncmp($result, "2", 1) == 0) { 
    252                             $rescued++; 
    253                           } else { 
    254                                 $message .= $result . "\n";                     
    255                           }                       
    256                     } 
     232        foreach ($items as $type => $mail_item) { 
     233                foreach ($mail_item as $mail_id => $value) { 
     234                        if ($type == "generic") { 
     235                                $newtype = $_POST['submit']; 
     236                        } else { 
     237                                $newtype = $type; 
     238                        } 
     239                        // report item 
     240                        if ($newtype == "spam") { 
     241                                switch ($this->type) { 
     242                                case 'ham': 
     243                                        // Mark the item as Confirmed Spam 
     244                                        $update = "UPDATE maia_mail_recipients SET type = 'C' " . 
     245                                                "WHERE recipient_id = ? AND mail_id = ?"; 
     246                                        $this->dbh->query($update, array($euid, $mail_id)); 
     247                                        record_mail_stats($euid, $mail_id, "fn"); 
     248                                        $reported++; 
     249                                        break; 
     250                                case 'spam': 
     251                                        confirm_spam($euid, $mail_id); 
     252                                        $confirmed++; 
     253                                default: 
     254                                } 
     255                        //send item 
     256                        } elseif ($newtype == "ham") { 
     257                                switch ($this->type) { 
     258                                case 'ham': 
     259                                        confirm_ham($euid, $mail_id); 
     260                                        $confirmed++; 
     261                                        break; 
     262                                default: 
     263                                        $result = rescue_item($euid, $mail_id); 
     264                                        if (strncmp($result, "2", 1) == 0) { 
     265                                        $rescued++; 
     266                                        } else { 
     267                                                $message .= $result . "\n";                     
     268                                        }                       
     269                                } 
    257270                        
    258271                        
    259                     //delete item. 
    260                 } elseif ($_POST['submit'] == "delete") { 
     272                        //delete item. 
     273                        } elseif ($newtype == "delete") { 
    261274 
    262                     delete_mail_reference($euid, $mail_id); 
    263                     $deleted++; 
     275                                delete_mail_reference($euid, $mail_id); 
     276                                $deleted++; 
    264277 
    265                 } 
    266         } 
    267         
     278                        } 
     279                } 
     280        } 
     281        $message = "confirmed = " . $confirmed . "<br>reported = " . $reported . "<br>";        
    268282        //$sth->free(); */ 
    269283        update_mail_stats($euid, "suspected_ham"); 
    270284        if ($confirmed > 0) { 
    271             $message .= sprintf($lang['text_ham_confirmed'], $confirmed) . ".<br>"; 
     285                if ($this->type == "ham") {     
     286                        $message .= sprintf($lang['text_ham_confirmed'], $confirmed) . ".<br>"; 
     287                } else { 
     288                        $message .= sprintf($lang['text_spam_confirmed'], $confirmed) . ".<br>"; 
     289                } 
    272290        } 
    273291 
    274292        if ($reported > 0) { 
    275293            $message .= sprintf($lang['text_spam_reported'], $reported) . ".<br>"; 
    276294        } 
    277295        if ($deleted > 0) { 
    278             $message .= sprintf($lang['text_ham_deleted'], $deleted) . ".<br>"; 
     296            if ( $this->type == "ham") { 
     297                $message .= sprintf($lang['text_ham_deleted'], $deleted) . ".<br>"; 
     298                } else { 
     299                $message .= sprintf($lang['text_spam_deleted'], $deleted) . ".<br>";         
     300                } 
     301        } 
     302        if ($rescued > 0) { 
     303                $message .= sprintf($lang['text_spam_rescued'], $rescued) . ".<br>"; 
    279304        } 
    280         $this->smarty->assign("message", $message); 
     305        $this->smarty->assign("message", $message); 
    281306     
    282307    } 
    283308     
     
    285310        global $lang, $msid, $html_charset, $offset; 
    286311        $magic_quotes = get_magic_quotes_gpc(); 
    287312        $nothing_to_show = true; 
    288          
     313        $offset = 0; 
    289314        $this->smarty->assign("msid", $msid); 
    290315        $this->smarty->assign("lang", $lang); 
    291  
    292            $sth = $this->dbh->query($this->select_stmt, array($euid)); 
    293            if ($sth->numRows() > 0) 
     316error_log($this->select_count,0); 
     317error_log($euid,0); 
     318           $numRows = $this->dbh->getOne($this->select_count, array($euid)); 
     319error_log($numRows,0); 
     320           if ($numRows > 0) 
    294321           { 
    295322              $select2 = "SELECT email FROM users WHERE maia_user_id = ?"; 
    296323              $sth2 = $this->dbh->query($select2, array($euid)); 
     
    301328              $personal_addresses = array_flip($personal_addresses); 
    302329              $domain_default = is_a_domain_default_user($euid); 
    303330              $per_page = get_user_value($euid, "items_per_page"); 
    304               $pager = new DB_Pager($sth, $offset, $per_page); 
    305               $data = $pager->build(); 
     331 
     332              $pagerOptions = array( 
     333                 'mode'    => 'Sliding', 
     334                 'delta'   => 5, 
     335                 'perPage' => $per_page, 
     336                 'totalItems' => $numRows, 
     337                 ); 
     338 
     339              $paged_data = Pager_Wrapper_DB($this->dbh, $this->select_stmt, $pagerOptions, null, null, array($euid)); 
     340              //$paged_data['data'];  //paged data 
     341              //$paged_data['links']; //xhtml links for page navigation 
     342              //$paged_data['page_numbers']; //array('current', 'total'); 
     343                       
     344                 
     345 
     346 
     347              //$pager = new DB_Pager($sth, $offset, $per_page); 
     348              //$data = $pager->build(); 
    306349              $maxid = 0; 
    307350              $nothing_to_show = false; 
    308351         
    309               $this->smarty->assign("data", $data); 
     352              $this->smarty->assign("data", $paged_data['data']); 
    310353              $this->smarty->assign("offset", $offset); 
     354print_r($paged_data['page_numbers']); 
     355              $this->smarty->assign("pages", $paged_data['page_numbers']); 
    311356         
    312          
    313             if ($sth->numrows() == 1) { 
     357            if ($numRows == 1) { 
    314358                $item_text = $lang['text_item']; 
    315359            } else { 
    316360                $item_text = $lang['text_items']; 
     
    319363            $count = 0; 
    320364            $rows = array(); 
    321365         
    322               while ($row = $pager->fetchrow()) 
     366              foreach ($paged_data['data'] as $row) 
    323367              { 
    324368                if ($row["id"] > $maxid) { 
    325369                      $maxid = $row["id"]; 
     
    357401                  $rows[$count]['subject'] = $subject; 
    358402                  $count++; 
    359403          } 
    360           $sth->free(); 
     404          //$sth->free(); 
    361405              $this->smarty->assign("row", $rows);  
    362406              $this->smarty->assign("maxid", $maxid); 
     407//print_r($paged_data['links']); 
     408              $this->smarty->assign("links", $paged_data['links']); 
    363409        } 
    364410        $this->smarty->assign("nothing_to_show", $nothing_to_show);    
    365411        $this->smarty->display("list-cache.tpl");