本文整理汇总了PHP中BxDolStorage::setFilePrivate方法的典型用法代码示例。如果您正苦于以下问题:PHP BxDolStorage::setFilePrivate方法的具体用法?PHP BxDolStorage::setFilePrivate怎么用?PHP BxDolStorage::setFilePrivate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BxDolStorage
的用法示例。
在下文中一共展示了BxDolStorage::setFilePrivate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFilePrivate
/**
* Set file private or public.
*/
public function setFilePrivate($iFileId, $isPrivate = true)
{
$aFile = $this->_oDb->getFileById($iFileId);
$sFileLocation = $this->getObjectBaseDir($aFile['private']) . $aFile['path'];
if (($aACP = $this->_s3->getAccessControlPolicy($this->_sBucket, $sFileLocation)) === false) {
$this->setErrorCode(BX_DOL_STORAGE_ERR_ENGINE_GET);
return false;
}
if (!is_array($aACP['acl']) || !$aACP['acl']) {
$this->setErrorCode(BX_DOL_STORAGE_ERR_ENGINE_GET);
return false;
}
// check current permissions
$aNewACP = $aACP;
unset($aNewACP['acl']);
$aNewACP['acl'] = array();
$aGroupPublic = false;
$aGroupPrivate = false;
foreach ($aACP['acl'] as $r) {
if ('Group' == $r['type']) {
if (isset($r['uri']) && $r['uri'] == 'http://acs.amazonaws.com/groups/global/AllUsers') {
$aGroupPublic = $r;
} elseif (isset($r['uri']) && $r['uri'] == 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers') {
$aGroupPrivate = $r;
} else {
$aNewACP['acl'][] = $r;
}
} else {
$aNewACP['acl'][] = $r;
}
}
// determine permissions changing
$aGroupAdd = false;
if ($isPrivate && (!$aGroupPrivate || $aGroupPublic)) {
// make private
$aGroupAdd = array('type' => 'Group', 'uri' => 'http://acs.amazonaws.com/groups/global/AuthenticatedUsers', 'permission' => 'READ');
} elseif (!$isPrivate && ($aGroupPrivate || !$aGroupPublic)) {
// make public
$aGroupAdd = array('type' => 'Group', 'uri' => 'http://acs.amazonaws.com/groups/global/AllUsers', 'permission' => 'READ');
}
// change permission if necessary
if ($aGroupAdd) {
$aNewACP['acl'][] = $aGroupAdd;
if (!$this->_s3->setAccessControlPolicy($this->_sBucket, $sFileLocation, $aNewACP)) {
$this->setErrorCode(BX_DOL_STORAGE_ERR_ENGINE_GET);
return false;
}
}
return parent::setFilePrivate($iFileId, $isPrivate);
}