本文整理匯總了PHP中CUtils::assemblyPaths方法的典型用法代碼示例。如果您正苦於以下問題:PHP CUtils::assemblyPaths方法的具體用法?PHP CUtils::assemblyPaths怎麽用?PHP CUtils::assemblyPaths使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CUtils
的用法示例。
在下文中一共展示了CUtils::assemblyPaths方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: canShared
/**
* 是否能被共享
* @param array $sharePaths - 數組,有包含user_id的path組成
* @param string $path - 包含user_id的path
* @return bool
*/
public function canShared($sharePaths, $path)
{
$paths = CUtils::assemblyPaths($path);
$keys = array_keys($paths);
if (count($keys) > 0) {
unset($paths[$keys[0]]);
}
//
// 檢查path,如果存在於$paths中則父目錄存在共享
//
foreach ($sharePaths as $k => $sharePath) {
if (isset($paths[$sharePath])) {
return false;
}
}
//
// 檢查子目錄是否存在共享,如果存在則返回false
//
$path .= '/';
foreach ($sharePaths as $k => $sharePath) {
if (strpos($sharePath, $path) === 0) {
return false;
}
}
return true;
}
示例2: handlerCheckById
/**
*
* 根據id檢查是否是共享目錄
*/
public function handlerCheckById($userId, $id)
{
$this->stop = 0;
$file = MiniFile::getInstance()->getById($id);
if ($file === NULL) {
return false;
}
$this->tmp_file = $file;
$paths = CUtils::assemblyPaths($file['file_path']);
$keys = array_keys($paths);
// 去掉 /{user_id}
if (count($keys) > 0) {
unset($paths[$keys[0]]);
}
$access = new SharesAccessFilter();
$sharePaths = $access->handleGetAllSharesFolder($userId);
$sharedPath = '';
foreach ($sharePaths as $sharePath) {
if (isset($paths[$sharePath])) {
$sharedPath = $sharePath;
}
}
$meta = MiniFileMeta::getInstance()->getFileMeta($sharedPath, 'shared_folders');
if ($meta === NULL) {
return false;
}
$meta_value = unserialize($meta['meta_value']);
$slaves = $meta_value['slaves'];
if ($userId === $meta_value['master']) {
return $file;
}
if (!isset($slaves[$userId])) {
return false;
}
$this->_file = UserFile::model()->findByAttributes(array('file_path' => $slaves[$userId]));
if ($file['file_type'] == 3 || $file['file_type'] == 4) {
$file = UserFile::model()->findByAttributes(array('file_path' => $meta_value['path']));
$this->stop = $file['parent_file_id'];
} elseif ($file['file_type'] == 2) {
$this->stop = $file['parent_file_id'];
} else {
$share = UserFile::model()->findByAttributes(array('file_path' => $meta_value['path']));
if ($share) {
$this->stop = $share['parent_file_id'];
}
}
return $file;
}