Changeset 8131


Ignore:
Timestamp:
05/02/13 15:19:28 (11 years ago)
Author:
cristiano
Message:

Ticket #3209 - Integrar módulo de sincronização Z-push ao Expresso

Location:
trunk/zpush
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/zpush/backend/expresso/expresso.php

    r7671 r8131  
    2424    private function getProvider( $folderId ) 
    2525    { 
     26 
     27 
    2628        foreach($this->providers as $provider) 
    2729        { 
     
    109111    public function ChangeFolder($folderid, $oldid, $displayname, $type) 
    110112    { 
    111         // TODO: Implement ChangeFolder() method. 
     113        return $this->getProvider($oldid ? $oldid: $folderid)->ChangeFolder($folderid, $oldid, $displayname, $type); 
    112114    } 
    113115 
     
    124126    public function DeleteFolder($id, $parentid) 
    125127    { 
    126         // TODO: Implement DeleteFolder() method. 
     128        return $this->getProvider($id)->DeleteFolder($id, $parentid); 
    127129    } 
    128130 
  • trunk/zpush/backend/expresso/providers/calendarProvider.php

    r8030 r8131  
    154154    public function ChangeFolder($folderid, $oldid, $displayname, $type) 
    155155    { 
     156        if($oldid) 
     157        { 
     158            $idNumber = (int)str_replace('calendar' , '' , $oldid); 
     159            $calendarSignature =  Controller::read( array( 'concept' => 'calendarSignature' , 'id' => $idNumber )); 
     160 
     161            Controller::update( array('concept' => 'calendar' , 'id' => $calendarSignature['calendar']), array( 'name' => $displayname) ); 
     162 
     163            return $this->StatFolder($oldid); 
     164        } 
     165        else 
     166        { 
     167             $cal = array('name' => $displayname, 
     168                'timezone' => 'America/Sao_Paulo', 
     169                'type' => '0' 
     170            ); 
     171 
     172            $calCreated = Controller::create(array('concept' => 'calendar'), $cal); 
     173 
     174            if(!$calCreated){ 
     175                return false; 
     176            } 
     177 
     178            $sig = array('user' => $_SESSION['wallet']['user']['uidNumber'], 
     179                'calendar' => $calCreated['id'], 
     180                'isOwner' => '1', 
     181                'dtstamp' => time() . '000', 
     182                'fontColor' => 'FFFFFF', 
     183                'backgroundColor' => '3366CC', 
     184                'borderColor' => '3366CC', 
     185            ); 
     186 
     187            $sigCreated = Controller::create(array('concept' => 'calendarSignature'), $sig); 
     188 
     189            if(!$sigCreated){ 
     190                return false; 
     191            } 
     192            else 
     193            { 
     194                $return = array(); 
     195                $return["id"] = 'calendar'.$calCreated; 
     196                $return["parent"] = 0; 
     197                $return["mod"] = $displayname; 
     198                return $return; 
     199            } 
     200        } 
     201 
    156202        return false; 
    157203 
     
    168214     * @throws StatusException              could throw specific SYNC_FSSTATUS_* exceptions 
    169215     */ 
    170     public function DeleteFolder($id, $parentid) 
    171     { 
    172         return false; 
     216    public function DeleteFolder($id, $parent) 
     217    { 
     218        $interation = array(); 
     219        $idNumber = (int)str_replace('calendar' , '' , $id); 
     220        $calendarSignature =  Controller::read( array( 'concept' => 'calendarSignature' , 'id' => $idNumber )); 
     221 
     222        $interation['calendar://' . $calendarSignature['calendar']] = false; 
     223        ob_start(); 
     224        $args = $interation; 
     225        include EXPRESSO_PATH.'/prototype/Sync.php'; 
     226        ob_end_clean(); 
     227 
     228        return true; 
    173229    } 
    174230 
  • trunk/zpush/backend/expresso/providers/imapProvider.php

    r8026 r8131  
    903903 
    904904        // build name for new mailboxBackendMaildir 
    905         $displayname = Utils::Utf7_iconv_encode(Utils::Utf8_to_utf7($displayname)); 
    906         $newname = $this->server . $folderid . $this->serverdelimiter . $displayname; 
    907  
     905        $displayname = Utils::Utf7_iconv_encode(Utils::Utf8_to_utf7($displayname));; 
     906        $new = $this->server . $this->getImapIdFromFolderId($folderid) . $this->serverdelimiter.  $displayname; 
    908907        $csts = false; 
    909         // if $id is set => rename mailbox, otherwise create 
    910         if ($oldid) { 
    911             // rename doesn't work properly with IMAP 
    912             // the activesync client doesn't support a 'changing ID' 
    913             // TODO this would be solved by implementing hex ids (Mantis #459) 
    914             //$csts = imap_renamemailbox($this->mbox, $this->server . imap_utf7_encode(str_replace(".", $this->serverdelimiter, $oldid)), $newname); 
    915         } 
    916         else { 
    917             $csts = @imap_createmailbox($this->mbox, $newname); 
    918         } 
     908 
     909        $csts = ($oldid) ? imap_renamemailbox($this->mbox,  $this->server .$this->getImapIdFromFolderId($oldid) , $new) : imap_createmailbox($this->mbox, $new); 
     910 
    919911        if ($csts) { 
    920             return $this->StatFolder($folderid . $this->serverdelimiter . $displayname); 
     912           $newId =  $this->convertImapId($new); 
     913           return $this->StatFolder($newId); 
    921914        } 
    922915        else 
     
    935928     * 
    936929     */ 
    937     public function DeleteFolder($id, $parentid){ 
    938         // TODO implement 
    939         return false; 
     930    public function DeleteFolder($id, $parentid) 
     931    { 
     932        $ret = imap_deletemailbox($this->mbox , $this->server .$this->getImapIdFromFolderId($id) ); 
     933        imap_expunge( $this->mbox ); 
     934        return $ret; 
    940935    } 
    941936 
  • trunk/zpush/lib/utils/utils.php

    r7589 r8131  
    446446    static public function IsSystemFolder($foldertype) { 
    447447        return ($foldertype == SYNC_FOLDER_TYPE_INBOX || $foldertype == SYNC_FOLDER_TYPE_DRAFTS || $foldertype == SYNC_FOLDER_TYPE_WASTEBASKET || $foldertype == SYNC_FOLDER_TYPE_SENTMAIL || 
    448                 $foldertype == SYNC_FOLDER_TYPE_OUTBOX || $foldertype == SYNC_FOLDER_TYPE_TASK || $foldertype == SYNC_FOLDER_TYPE_APPOINTMENT || $foldertype == SYNC_FOLDER_TYPE_CONTACT || 
     448                $foldertype == SYNC_FOLDER_TYPE_OUTBOX || $foldertype == SYNC_FOLDER_TYPE_TASK /*|| $foldertype == SYNC_FOLDER_TYPE_APPOINTMENT */|| $foldertype == SYNC_FOLDER_TYPE_CONTACT || 
    449449                $foldertype == SYNC_FOLDER_TYPE_NOTE || $foldertype == SYNC_FOLDER_TYPE_JOURNAL) ? true:false; 
    450450    } 
Note: See TracChangeset for help on using the changeset viewer.