本文整理汇总了PHP中Zend_Mail_Storage_Folder::getGlobalName方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Mail_Storage_Folder::getGlobalName方法的具体用法?PHP Zend_Mail_Storage_Folder::getGlobalName怎么用?PHP Zend_Mail_Storage_Folder::getGlobalName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Mail_Storage_Folder
的用法示例。
在下文中一共展示了Zend_Mail_Storage_Folder::getGlobalName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createFolder
/**
* create a new folder
*
* This method also creates parent folders if necessary. Some mail storages may restrict, which folder
* may be used as parent or which chars may be used in the folder name
*
* @param string $name global name of folder, local name if $parentFolder is set
* @param string|Zend_Mail_Storage_Folder $parentFolder parent folder for new folder, else root folder is parent
* @return string only used internally (new created maildir)
* @throw Zend_Mail_Storage_Exception
*/
public function createFolder($name, $parentFolder = null)
{
if ($parentFolder instanceof Zend_Mail_Storage_Folder) {
$folder = $parentFolder->getGlobalName() . $this->_delim . $name;
} else {
if ($parentFolder != null) {
$folder = rtrim($parentFolder, $this->_delim) . $this->_delim . $name;
} else {
$folder = $name;
}
}
$folder = trim($folder, $this->_delim);
// first we check if we try to create a folder that does exist
$exists = null;
try {
$exists = $this->getFolders($folder);
} catch (Zend_Mail_Exception $e) {
// ok
}
if ($exists) {
throw new Zend_Mail_Storage_Exception('folder already exists');
}
if (strpos($folder, $this->_delim . $this->_delim) !== false) {
throw new Zend_Mail_Storage_Exception('invalid name - folder parts may not be empty');
}
if (strpos($folder, 'INBOX' . $this->_delim) === 0) {
$folder = substr($folder, 6);
}
$fulldir = $this->_rootdir . '.' . $folder;
// check if we got tricked and would create a dir outside of the rootdir or not as direct child
if (strpos($folder, DIRECTORY_SEPARATOR) !== false || strpos($folder, '/') !== false || dirname($fulldir) . DIRECTORY_SEPARATOR != $this->_rootdir) {
throw new Zend_Mail_Storage_Exception('invalid name - no directory seprator allowed in folder name');
}
// has a parent folder?
$parent = null;
if (strpos($folder, $this->_delim)) {
// let's see if the parent folder exists
$parent = substr($folder, 0, strrpos($folder, $this->_delim));
try {
$this->getFolders($parent);
} catch (Zend_Mail_Exception $e) {
// does not - create parent folder
$this->createFolder($parent);
}
}
if (!@mkdir($fulldir) || !@mkdir($fulldir . DIRECTORY_SEPARATOR . 'cur')) {
throw new Zend_Mail_Storage_Exception('error while creating new folder, may be created incompletly');
}
mkdir($fulldir . DIRECTORY_SEPARATOR . 'new');
mkdir($fulldir . DIRECTORY_SEPARATOR . 'tmp');
$localName = $parent ? substr($folder, strlen($parent) + 1) : $folder;
$this->getFolders($parent)->{$localName} = new Zend_Mail_Storage_Folder($localName, $folder, true);
return $fulldir;
}
示例2: createFolder
/**
* create a new folder
*
* This method also creates parent folders if necessary. Some mail storages may restrict, which folder
* may be used as parent or which chars may be used in the folder name
*
* @param string $name global name of folder, local name if $parentFolder is set
* @param string|Zend_Mail_Storage_Folder $parentFolder parent folder for new folder, else root folder is parent
* @param string
* @return null
* @throws Zend_Mail_Storage_Exception
*/
public function createFolder($name, $parentFolder = null, $_delimiter = '/')
{
if ($parentFolder instanceof Zend_Mail_Storage_Folder) {
$folder = $parentFolder->getGlobalName() . $_delimiter . $name;
} else {
if ($parentFolder != null) {
$folder = $parentFolder . $_delimiter . $name;
} else {
$folder = $name;
}
}
if (!$this->_protocol->create($folder)) {
/**
* @see Zend_Mail_Storage_Exception
*/
require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('cannot create folder ' . $folder);
}
}
示例3: createFolder
/**
* create a new folder
*
* This method also creates parent folders if necessary. Some mail storages may restrict, which folder
* may be used as parent or which chars may be used in the folder name
*
* @param string $name global name of folder, local name if $parentFolder is set
* @param string|Zend_Mail_Storage_Folder $parentFolder parent folder for new folder, else root folder is parent
* @return null
* @throws Zend_Mail_Storage_Exception
*/
public function createFolder($name, $parentFolder = null)
{
// TODO: we assume / as the hierarchy delim - need to get that from the folder class!
if ($parentFolder instanceof Zend_Mail_Storage_Folder) {
$folder = $parentFolder->getGlobalName() . '/' . $name;
} else {
if ($parentFolder != null) {
$folder = $parentFolder . '/' . $name;
} else {
$folder = $name;
}
}
if (!$this->_protocol->create($folder)) {
/**
* @see Zend_Mail_Storage_Exception
*/
require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception('cannot create folder');
}
}
示例4: transformToFolderDto
/**
* Transforms an imap Zend_Mail_Storage_Folder to an instance
* of Conjoon_Modules_Groupware_Email_Folder_Dto.
*
* @param Zend_Mail_Storage_Folder $folder
* @param boolean $lookupStandardNames Whether standard names like "INBOX"
* and trash should be looked up and addiotnal properties adjusted for them.
* @param array $config A preset set of config properties which are used
* for the properties of the created FolderDto. By now, only the id, the
* idForPath and the pendingCount property are considered.
*
* @return Conjoon_Modules_Groupware_Email_Folder_Dto
*/
public static function transformToFolderDto(Zend_Mail_Storage_Folder $folder, $lookupStandardNames = false, array $config = array())
{
/**
* @see Conjoon_Modules_Groupware_Email_Folder_Dto
*/
require_once 'Conjoon/Modules/Groupware/Email/Folder/Dto.php';
$tmpFolder = new Conjoon_Modules_Groupware_Email_Folder_Dto();
// go through predefined variables
if (isset($config['id'])) {
$tmpFolder->id = $config['id'];
} else {
$tmpFolder->id = $folder->getGlobalName();
}
if (isset($config['idForPath'])) {
$tmpFolder->idForPath = $config['idForPath'];
} else {
$tmpFolder->idForPath = $folder->getGlobalName();
}
if (isset($config['pendingCount'])) {
$tmpFolder->pendingCount = $config['pendingCount'];
}
$childCount = 0;
if (isset($config['childCount'])) {
$childCount = $config['childCount'];
}
$tmpFolder->type = $config['type'];
$tmpFolder->name = $folder->getLocalName();
$tmpFolder->isChildAllowed = 1;
$tmpFolder->isLocked = 0;
//hasChildren doesnt seem to work
$tmpFolder->childCount = $childCount;
$tmpFolder->isSelectable = $folder->isSelectable() ? 1 : 0;
return $tmpFolder;
}
示例5: createFolder
/**
* create a new folder
*
* This method also creates parent folders if necessary. Some mail storages may restrict, which folder
* may be used as parent or which chars may be used in the folder name
*
* @param string $name global name of folder, local name if $parentFolder is set
* @param string|Zend_Mail_Storage_Folder $parentFolder parent folder for new folder, else root folder is parent
* @param string
* @return null
* @throws Zend_Mail_Storage_Exception
*/
public function createFolder($name, $parentFolder = null, $_delimiter = '/')
{
if ($parentFolder instanceof Zend_Mail_Storage_Folder) {
$folder = $parentFolder->getGlobalName() . $_delimiter . $name;
} else {
if ($parentFolder != null) {
$folder = $parentFolder . $_delimiter . $name;
} else {
$folder = $name;
}
}
$translate = Tinebase_Translation::getTranslation('Felamimail');
if (!$this->_protocol->create($folder)) {
/**
* @see Zend_Mail_Storage_Exception
*/
require_once 'Zend/Mail/Storage/Exception.php';
throw new Zend_Mail_Storage_Exception($translate->_('cannot create folder') . ' ' . $folder . ', ' . $translate->_('perhaps it already exists.'));
}
}
示例6: _transformImapFolder
/**
* Gathers all needed information to tranform an imap folder to a
* Conjoon_Modules_Groupware_Email_Folder_Dto obejct.
*
* @param Zend_Mail_Storage_Folder $folder
* @param Conjoon_Modules_Groupware_Email_Account_Dto $account
* @param Zend_Mail_Protocol_Imap $protocol
* @param boolean $isRootLevel Whether the folder is on the first level of
* the mailbox hierarchy
*
* @return Conjoon_Modules_Groupware_Email_Folder_Dto
*/
private function _transformImapFolder(Zend_Mail_Storage_Folder $folder, Conjoon_Modules_Groupware_Email_Account_Dto $account, Zend_Mail_Protocol_Imap $protocol, $isRootLevel = false, $type = 'folder')
{
$delim = Conjoon_Modules_Groupware_Email_ImapHelper::getFolderDelimiterForImapAccount($account);
$globalName = $folder->getGlobalName();
$path = explode($delim, $globalName);
$path = $path[count($path) - 1];
$pendingCount = 0;
if (!$this->itemListRequestFacade) {
$this->itemListRequestFacade = Conjoon_Modules_Groupware_Email_Item_ItemListRequestFacade::getInstance();
}
if ($folder->isSelectable()) {
try {
$pendingCount = $this->itemListRequestFacade->getPendingCountForGlobalName($account, $globalName);
} catch (Exception $e) {
// ignore
}
}
$childCount = 0;
if (!$folder->isLeaf()) {
$protocol = Conjoon_Modules_Groupware_Email_ImapHelper::reuseImapProtocolForAccount($account);
/**
* @see Zend_Mail_Storage_Imap
*/
require_once 'Zend/Mail/Storage/Imap.php';
$imap = new Zend_Mail_Storage_Imap($protocol);
/**
* @ticket CN-595
*/
if ($globalName === "INBOX") {
$iFolders = $imap->getFolders(null)->getChildren();
} else {
$iFolders = $imap->getFolders($globalName)->getChildren();
}
foreach ($iFolders as $tmpFolder) {
$childCount++;
}
}
return Conjoon_Modules_Groupware_Email_ImapHelper::transformToFolderDto($folder, $isRootLevel, array('id' => $account->id . '_' . $globalName, 'idForPath' => $path, 'pendingCount' => $pendingCount, 'type' => $type, 'childCount' => $childCount));
}