本文整理匯總了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);
}