Changeset 5341 for trunk/prototype/services/ImapServiceAdapter.php
- Timestamp:
- 01/10/12 11:25:51 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/prototype/services/ImapServiceAdapter.php
r5204 r5341 1 1 <?php 2 2 3 include_once "../header.session.inc.php";4 5 include_once "../expressoMail1_2/inc/class.imap_functions.inc.php";3 include_once ROOTPATH."/../header.session.inc.php"; 4 5 include_once ROOTPATH."/../expressoMail1_2/inc/class.imap_functions.inc.php"; 6 6 7 7 class ImapServiceAdapter extends imap_functions/* implements Service*/ … … 12 12 } 13 13 14 public function connect( $config ) 15 { 16 $this->init(); 17 } 18 19 public function find( $URI, $context, $justthese = false, $criteria = false ) 20 { 14 // public function connect( $config ) 15 // { 16 // $this->init(); 17 // } 21 18 22 if( is_array($URI))19 public function find( $URI, $justthese = false, $criteria = false ) 23 20 { 24 $criteria = $justthese; 25 $justthese = $context; 26 $context = $URI['context']; 21 $context = $justthese['context']; 27 22 $URI = $URI['concept']; 28 }29 23 30 24 switch( $URI ) … … 54 48 $sord = $criteria['sord']; //{desc} get the direction 55 49 50 $filter = $criteria['filter']; 51 56 52 if( !$sidx ) $sidx = 1; 57 53 58 54 $folder_name = str_replace( '.', $this->imap_delimiter, $context['folder'] ); 59 55 60 $folder = $this->get_range_msgs2(array('folder'=>$folder_name)); 61 62 $count = $folder['num_msgs']; 56 $count = imap_num_msg( $this->open_mbox( $folder_name ) ); 63 57 64 58 $total_pages = $count > 0 ? ceil( $count/$limit ) : 0; … … 67 61 $page = $total_pages; 68 62 69 $start = $limit * $page - $limit; // do not put $limit*($page - 1) 63 $start = $limit * $page - $limit; 64 65 // do not put $limit*($page - 1) 70 66 //end: for grid 71 67 72 $service_params = array( 'folder' => $folder_name, //INBOX 68 if( $filter ) 69 { 70 if( $filter[0] !== 'msgNumber' ) 71 { 72 for( $i = 0; $i < count($filter); $i++ ) 73 { 74 if( count( $filter[$i] ) === 4 ) 75 $criteria['isExact'] = ( array_shift( $filter[$i] ) === 'AND' ); 76 77 $criteria[ $filter[$i][0] ] = array( 'criteria' => $filter[$i][2], 'filter' => $filter[$i][1] ); 78 } 79 80 return $this->searchSieveRule($criteria); 81 } 82 83 $msgNumber = array(); 84 85 for( $i = $start; $i < $start + $limit && isset( $filter[2][$i] ); $i++ ) 86 $msgNumber[] = $filter[2][$i]; 87 88 if( empty( $msgNumber ) ) 89 return( false ); 90 91 $result = $this->get_info_msgs( array( 'folder' => $folder_name, 92 'msgs_number' => implode( ',', $msgNumber ) ) ); 93 94 foreach( $result as $i => $val ) 95 $result[$i] = unserialize( $val ); 96 97 } 98 else 99 { 100 $result = $this->get_range_msgs2( array( 'folder' => $folder_name, //INBOX 73 101 'msg_range_begin' => $start + 1, //?? 74 102 'msg_range_end' => $start + $limit, //$limit = $_GET['rows']; // get how many rows we want to have into the grid 75 103 'sort_box_type' => 'SORTARRIVAL', 76 104 'search_box_type' => 'ALL', 77 'sort_box_reverse' => 1 ); 78 79 $result = $this->to_utf8($this->get_range_msgs2($service_params)); 105 'sort_box_reverse' => 1 ) ); 106 } 80 107 //return var_export($result); 81 108 82 $response = array( "page" => $page, "total" => $total_pages, "records" => $ result['num_msgs']);109 $response = array( "page" => $page, "total" => $total_pages, "records" => $count ); 83 110 84 111 for ($i=0; $i<count($result); $i++) … … 96 123 { 97 124 $response["rows"][$i] = $result[$i]; 98 $response["rows"][$i]['body'] = $this->to_utf8($result[$i]['body']); 99 $response["rows"][$i]['timestamp'] = ( ( $result[$i]['udate']) * 1000 ); 100 //USA OS TIME ZONES 101 //$response["rows"][$i]['timestamp'] = ( ( $result[$i]['udate'] + $this->functions->CalculateDateOffset()) * 1000 ); 125 $response["rows"][$i]['timestamp'] = ( ( $result[$i]['udate'] + $this->functions->CalculateDateOffset() ) * 1000 ); 102 126 $response["rows"][$i]['flags'] = implode(',', $flags_enum); 103 127 $response["rows"][$i]['size'] = $response["rows"][$i]['Size']; 104 128 // $response["rows"][$i]['udate'] = ( $result[$i]['udate'] + $this->functions->CalculateDateOffset() * 1000 ); 105 129 unset($response["rows"][$i]['Size']); 106 130 } 107 131 } 132 133 $response = $this->to_utf8($response); 108 134 109 135 break; … … 113 139 } 114 140 115 public function retrieve( $concept, $id, $parents, $justthese = false, $criteria = false )116 {117 return $this->read( array( 'id' => $id,118 'concept' => $concept,119 'context' => $parents ), $justthese );120 }141 // public function retrieve( $concept, $id, $parents, $justthese = false, $criteria = false ) 142 // { 143 // return $this->read( array( 'id' => $id, 144 // 'concept' => $concept, 145 // 'context' => $parents ), $justthese ); 146 // } 121 147 122 148 public function read( $URI, $justthese = false ) 123 149 { 124 $folder_name = str_replace( '.', $this->imap_delimiter, $URI['context']['folder'] ); 125 126 $response = $this->get_info_msg( array('msg_number'=>$URI['id'],'msg_folder'=>$folder_name) ); 127 128 return $this->to_utf8( $response ); 150 151 return $this->to_utf8( $this->get_info_msg( array('msg_number'=>$URI['id'], 152 'msg_folder'=>str_replace( '.', $this->imap_delimiter, $justthese['context']['folder'] )) ) ); 129 153 } 130 154 … … 149 173 public function setup() 150 174 {} 175 176 public function commit( $uri ) 177 { return( true ); } 178 179 public function rollback( $uri ) 180 {} 181 182 public function begin( $uri ) 183 {} 184 151 185 152 186 public function teardown() … … 160 194 } 161 195 } elseif(is_string($in)) { 162 //if(mb_detect_encoding($in) != "UTF-8")163 196 return mb_convert_encoding( $in , 'UTF-8' , 'UTF-8 , ISO-8859-1' ); 164 //else165 // return $in;166 197 } else { 167 198 return $in;
Note: See TracChangeset
for help on using the changeset viewer.