Changeset 119

Show
Ignore:
Timestamp:
02/06/05 01:02:01 (4 years ago)
Author:
davea
Message:

Multiple deletes are now functional, so #10 is closed. #8 will remain open for the time being, until a user confirmation is shown to the user before the actual delete takes place.\nAlso fixed a bug where an error would be given if the session timed out.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • admin.lib.php

    r118 r119  
    7171                        session_unset(); 
    7272                        $this->sessionError =_("Session Expired"); 
    73                         startSession(); 
     73                        $this->startSession(); 
    7474                } 
    7575/*              //close the session if its move IP 
     
    481481                                echo "<div class=\"entry\"><h2>"._("Edit Entries")."</h2>\n"; 
    482482                        } 
    483                         echo "<table class=\"td\">\n\t<tr>\n\t\t<th>Date</th>\n\t\t<th>Title</th>\n\t</tr>\n"; 
     483                        echo "<form action=\"{$this->adminPath}deleteentries/\" method=\"post\">\n<table class=\"td\">\n\t<tr>\n\t\t<th>Date</th>\n\t\t<th>Title</th>\n\t\t<th>Delete</th>\n\t</tr>\n"; 
     484                        $rownum = 0; 
    484485                        while($row = db_getrow($result)){ 
    485                         echo "\t<tr>\n\t\t<td>".strftime('%c', strtotime($row['timestamp']))."</td>\n\t\t<td><a href=\"".$this->adminPath."update/".$row['shortsubject']."\">".$row['subject']."</a></td>\n\t</tr>\n"; 
    486                         } 
    487                         echo "</table\n"; 
     486                                echo "\t<tr>\n"; 
     487                                echo "\t\t<td>".strftime('%c', strtotime($row['timestamp']))."</td>\n"; 
     488                                echo "\t\t<td><a href=\"".$this->adminPath."update/".$row['shortsubject']."\">".$row['subject']."</a></td>\n"; 
     489                                echo "\t\t<td><input type=\"checkbox\" name=\"entry[".$rownum++."]\" value=\"{$row['shortsubject']}\" /></td>\n"; 
     490                                echo "\t</tr>\n"; 
     491                        } 
     492                        echo "\t<tr>\n"; 
     493                        echo "\t\t<td></td><td></td><td><input type=\"submit\" name=\"submit\" value=\""._("Delete Selected")."\" /></td>\n"; 
     494                        echo "\t</tr>\n"; 
     495                        echo "</table>\n"; 
     496                        echo "</form>\n"; 
    488497                        if($title) { 
    489498                                echo "</div>\n"; 
    490499                        } 
     500                } 
     501        } 
     502 
     503        function deleteEntries() 
     504        { 
     505                if (count($_POST['entry'])==0) { 
     506                        error(4, _("No entries marked for deletion.")); 
     507                } else { 
     508                        $sql = "DELETE FROM entries WHERE ("; 
     509                        foreach($_POST['entry'] as $id) { 
     510                                $sql .= "shortsubject = '".$this->blog->makeCleanString($id)."' OR "; 
     511                        } 
     512                        $sql = substr($sql, 0, -4); 
     513                        $sql .= ") AND user_id = {$this->id};"; 
     514                         
     515                        db_query($sql); 
     516                        echo count($_POST['entry'])._(" post(s) deleted"); 
    491517                } 
    492518        } 
  • admin.php

    r112 r119  
    6363                                                $admin->deleteEntry(array_shift($request)) ; 
    6464                                                break; 
     65                                        case "deleteentries": 
     66                                                $admin->deleteEntries(); 
     67                                                break; 
    6568                                        default: 
    6669                                                //Should display blog entries here