/** * @param CApiMailFolder $oMailFolder * @return bool */ public function AddWithPositionSearch($oMailFolder) { $oItemFolder = null; $bIsAdded = false; $aList =& $this->GetAsArray(); foreach ($aList as $oItemFolder) { if ($oMailFolder instanceof CApiMailFolder && 0 === strpos($oMailFolder->FullNameRaw(), $oItemFolder->FullNameRaw() . $oItemFolder->Delimiter())) { if ($oItemFolder->SubFolders(true)->AddWithPositionSearch($oMailFolder)) { $bIsAdded = true; } break; } } if (!$bIsAdded && $oMailFolder instanceof CApiMailFolder) { $bIsAdded = true; $this->Add($oMailFolder); } return $bIsAdded; }