本文整理汇总了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;
}