note 61472 deleted from function.imap-getmailboxes by betz

From: Date: Sat, 04 Feb 2006 15:24:43 +0000
Subject: note 61472 deleted from function.imap-getmailboxes by betz
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-102997@lists.php.net to get a copy of this message
Note Submitter: ---- i was looking for a function to test the attributes. and it was hard to find an answer or code. Maybe there is a function availeble, but i couldn't find it. the first function: returns all mailboxes in on the server The second function: returns a bitstring from the attr_number returned by getmailboxes() The tirth function: returns an array with the active attributes on the specific mailbox Last Line: is a combination of the functions: the output is, any map witch can hold no mail but only sub boxes... <?php function getFolders($mailbox, $serverString) { $list = imap_getmailboxes($mailbox, $serverString, "*"); if (is_array($list)) { foreach ($list as $key => $val) { $mapname = str_replace($serverString, "", imap_utf7_decode($val->name)); if ($mapname[0] != ".") { $list_folders[$key]['name'] = $mapname; $list_folders[$key]['delimiter'] = $val->delimiter; $list_folders[$key]['attributes'] = $val->attributes; } } } else { echo "imap_getmailboxes failed: " . imap_last_error() . "\n"; } return $list_folders; } function IntToBin($number) { $BitWaarde = 1; $IntNum = $number; $BinString = ""; if ($IntNum > 0) { // bepaal de max bitwaarde aan de hand van $IntNum while ($IntNum > $BitWaarde) { $BitWaarde = $BitWaarde * 2; } // maken van een binaire string. while ($BitWaarde >= 1 ) { if ($IntNum < $BitWaarde) { if ($BinString != "") $BinString .= "0"; } else { $BinString .= "1"; $IntNum = $IntNum-$BitWaarde; } $BitWaarde = $BitWaarde / 2; } } return $BinString; } function Attributes($BinString) { $BinInt = (int)$BinString; if ($BinInt >=1000){ $setAttribute['LATT_UNMARKED'] = true; $BinInt = $BinInt-1000; } else $setAttribute['LATT_UNMARKED'] = false; if ($BinInt >=100){ $setAttribute['LATT_MARKED'] = true; $BinInt = $BinInt-100; } else $setAttribute['LATT_MARKED'] = false; if ($BinInt >=10){ $setAttribute['LATT_NOSELECT'] = true; $BinInt = $BinInt-10; } else $setAttribute['LATT_NOSELECT'] = false; if ($BinInt >=1){ $setAttribute['LATT_NOINFERIORS'] = true; $BinInt = $BinInt-1; } else $setAttribute['LATT_NOINFERIORS'] = false; return $setAttribute; } foreach (getFolders($mailbox, $config['Server_string']) as $key => $val) { $Attr = Attributes(IntToBin((int)$val['attributes'])); if (!$Attr['LATT_NOINFERIORS']) { echo "<option value='".$val['name']."'>".$val['name']."</option>"; } } ?>

« previous php.notes (#102997) next »