Ignore:
Timestamp:
Jul 7, 2011 7:44:26 AM (23 months ago)
Author:
alecpl <alec@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
65b61cd
Parents:
632528f
Message:
  • Added possibility to undo last contact delete operation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • program/include/rcube_contacts.php

    rcc90ed1 r7f5a849  
    5353    public $readonly = false; 
    5454    public $groups = true; 
     55    public $undelete = true; 
    5556    public $list_page = 1; 
    5657    public $page_size = 10; 
     
    693694 
    694695    /** 
     696     * Undelete one or more contact records 
     697     * 
     698     * @param array  Record identifiers 
     699     */ 
     700    function undelete($ids) 
     701    { 
     702        if (!is_array($ids)) 
     703            $ids = explode(',', $ids); 
     704 
     705        $ids = $this->db->array2list($ids, 'integer'); 
     706 
     707        // flag record as deleted 
     708        $this->db->query( 
     709            "UPDATE ".get_table_name($this->db_name). 
     710            " SET del=0, changed=".$this->db->now(). 
     711            " WHERE user_id=?". 
     712                " AND contact_id IN ($ids)", 
     713            $this->user_id 
     714        ); 
     715 
     716        $this->cache = null; 
     717 
     718        return $this->db->affected_rows(); 
     719    } 
     720 
     721 
     722    /** 
    695723     * Remove all records from the database 
    696724     */ 
    697725    function delete_all() 
    698726    { 
    699         $this->db->query("DELETE FROM ".get_table_name($this->db_name)." WHERE user_id = ?", $this->user_id); 
    700727        $this->cache = null; 
     728 
     729        $this->db->query("UPDATE ".get_table_name($this->db_name). 
     730            " SET del=1, changed=".$this->db->now(). 
     731            " WHERE user_id = ?", $this->user_id); 
     732 
    701733        return $this->db->affected_rows(); 
    702734    } 
Note: See TracChangeset for help on using the changeset viewer.