325
* Take two entities of possibly different classes and make the second entity as close a copy of
326
* the first entity as possible. Copy the id but not the entity type because the entity type
327
* must always match the class name.
328
* @param object GalleryEntity $sourceEntity entity to copy from
329
* @param object GalleryEntity $mirrorEntity entity to copy to
330
* @return array object GalleryStatus a status code
331
* object GalleryEntity the mirror entity
333
function mirrorEntity($sourceEntity, $mirrorEntity) {
334
$className = $mirrorClassName = $mirrorEntity->getClassName();
335
list ($ret, $entityInfo) = GalleryCoreApi::describeEntity($className);
337
return array($ret, null);
340
list ($ret, $memberAccessInfo) =
341
GalleryCoreApi::getExternalAccessMemberList($className);
343
return array($ret, null);
345
/* We need to override id and pathComponent */
346
$override = array('id', 'pathComponent');
349
* Walk down the mirror entity's class hierarchy copying class members from the source
350
* entity if they are defined
352
while (!empty($className)) {
353
foreach ($entityInfo[$className]['members'] as $memberName => $memberInfo) {
354
if (isset($sourceEntity->$memberName)
355
&& (!empty($memberAccessInfo[$memberName]['write'])
356
|| in_array($memberName, $override))) {
357
$mirrorEntity->$memberName = $sourceEntity->$memberName;
361
$className = $entityInfo[$className]['parent'];
365
* Reset the entity type to the mirror entity's class name because the entity type must
366
* always match the class name
368
$mirrorEntity->entityType = $mirrorClassName;
370
return array(null, $mirrorEntity);
325
374
* Get singleton WebDAV server library instance.
327
376
* If it didn't need path and baseUrl, we could eliminate and call library methods staticly.
694
749
$childPath = "$path/" . $childPath;
697
$ret = WebDavHelper::_propfindFiles($childItem, $childPath, $depth - 1, $files);
752
$ret = WebDavHelper::_propfindFiles($childItem, $childPath,
753
$depth == 'infinity' ? $depth : $depth - 1,
839
$ret = GalleryCoreApi::assertHasItemPermission($itemId, 'core.edit');
782
844
/* Prepare data-structure from PROPPATCH request */
783
845
list ($ret, $webDavOptions, $props) = WebDavHelper::proppatchRequestHelper();
1264
1326
$error[] = 'form[error][destination][empty]';
1267
if (!empty($newParent)) {
1329
if (empty($error)) {
1268
1330
$newParentId = $newParent->getId();
1270
1332
list ($ret, $permissions) = GalleryCoreApi::getPermissions($newParentId);
1277
1339
if (!$canAddAlbum && !$canAddItem) {
1278
1340
$error[] = 'form[error][destination][permission]';
1344
if (empty($error)) {
1281
1345
if (!GalleryUtilities::isA($newParent, 'GalleryAlbumItem')) {
1282
1346
/* The view should never let this happen */
1283
1347
return array(GalleryCoreApi::error(ERROR_BAD_DATA_TYPE), null);
1430
1494
/* If all errors were permission denied return more specific error */
1431
1495
return GalleryCoreApi::error(ERROR_PERMISSION_DENIED);
1498
$ret = GalleryCoreApi::assertHasItemPermission($item->getId(), 'core.edit');
1435
1504
list ($ret, $conflictingItemId) = GalleryCoreApi::fetchItemIdByPath($newPath);
1764
list ($ret, $permissions) = GalleryCoreApi::fetchPermissionsForItems(array($itemId));
1768
if (empty($permissions[$itemId]['core.edit'])
1769
&& empty($permissions[$itemId]['core.delete'])) {
1770
return GalleryCoreApi::error(ERROR_PERMISSION_DENIED);
1695
1773
/* Refresh lock */
1696
1774
if (!empty($update)) {
1697
1775
/* Don't join with the Gallery lock table since we might be using flock system */