-
Notifications
You must be signed in to change notification settings - Fork 3
/
file.php
869 lines (759 loc) · 20.5 KB
/
file.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
<?php
namespace Bitrix\Disk;
use Bitrix\Disk\Internals\EditSessionTable;
use Bitrix\Disk\Internals\Error\Error;
use Bitrix\Disk\Internals\Error\ErrorCollection;
use Bitrix\Disk\Internals\ExternalLinkTable;
use Bitrix\Disk\Internals\FileTable;
use Bitrix\Disk\Internals\ObjectTable;
use Bitrix\Disk\Internals\RightTable;
use Bitrix\Disk\Internals\SharingTable;
use Bitrix\Disk\Internals\SimpleRightTable;
use Bitrix\Disk\Internals\VersionTable;
use Bitrix\Disk\Security\SecurityContext;
use Bitrix\Disk\Uf\FileUserType;
use Bitrix\Main\Event;
use Bitrix\Main\Localization\Loc;
use Bitrix\Main\ObjectException;
use Bitrix\Main\Type\DateTime;
use CFile;
use Bitrix\Disk\BizProcDocument;
Loc::loadMessages(__FILE__);
class File extends BaseObject
{
const ERROR_COULD_NOT_SAVE_FILE = 'DISK_FILE_22002';
const ERROR_COULD_NOT_COPY_FILE = 'DISK_FILE_22003';
const ERROR_COULD_NOT_RESTORE_FROM_OBJECT = 'DISK_FILE_22004';
const SECONDS_TO_JOIN_VERSION = 300;
/** @var int */
protected $typeFile;
/** @var int */
protected $globalContentVersion;
/** @var int */
protected $fileId;
/** @var int */
protected $prevFileId;
/** @var array */
protected $file;
/** @var int */
protected $size;
/** @var string */
protected $externalHash;
/** @var string */
protected $extenstion;
/**
* Gets the fully qualified name of table class which belongs to current model.
* @throws \Bitrix\Main\NotImplementedException
* @return string
*/
public static function getTableClassName()
{
return FileTable::className();
}
/**
* Checks rights to start bizprocess on current object.
* @param SecurityContext $securityContext Security context.
* @return bool
*/
public function canStartBizProc(SecurityContext $securityContext)
{
return $securityContext->canStartBizProc($this->id);
}
/**
* Adds row to entity table, fills error collection and builds model.
* @param array $data Data.
* @param ErrorCollection $errorCollection Error collection.
* @return \Bitrix\Disk\Internals\Model|static|null
* @throws \Bitrix\Main\NotImplementedException
* @internal
*/
public static function add(array $data, ErrorCollection $errorCollection)
{
$parent = null;
if(isset($data['PARENT']) && $data['PARENT'] instanceof Folder)
{
$parent = $data['PARENT'];
unset($data['PARENT']);
}
$file = parent::add($data, $errorCollection);
if($file)
{
if($parent !== null)
{
$file->setAttributes(array('PARENT' => $parent));
}
$versionData = array(
'ID' => $file->getFileId(),
'FILE_SIZE' => $file->getSize(),
);
if(!empty($data['UPDATE_TIME']))
{
$versionData['UPDATE_TIME'] = $data['UPDATE_TIME'];
}
$file->addVersion($versionData, $file->getCreatedBy());
}
return $file;
}
/**
* Returns once model by specific filter.
* @param array $filter Filter.
* @param array $with List of eager loading.
* @throws \Bitrix\Main\NotImplementedException
* @return static
*/
public static function load(array $filter, array $with = array())
{
$filter['TYPE'] = ObjectTable::TYPE_FILE;
return parent::load($filter, $with);
}
protected static function getClassNameModel(array $row)
{
$classNameModel = parent::getClassNameModel($row);
if(
$classNameModel === static::className() ||
is_subclass_of($classNameModel, static::className()) ||
in_array(static::className(), class_parents($classNameModel)) //5.3.9
)
{
return $classNameModel;
}
throw new ObjectException('Could not to get non subclass of ' . static::className());
}
/**
* Returns extension.
* @return string
*/
public function getExtension()
{
if($this->extenstion === null)
{
$this->extenstion = getFileExtension($this->getName());
}
return $this->extenstion;
}
/**
* Returns external hash.
* @return string
*/
public function getExternalHash()
{
return $this->externalHash;
}
/**
* Returns global content version.
*
* Version always increments after creating new version.
* @return int
*/
public function getGlobalContentVersion()
{
return $this->globalContentVersion;
}
/**
* Returns id of file (table {b_file}).
* @return int
*/
public function getFileId()
{
return $this->fileId;
}
/**
* Returns file (@see CFile::getById());
* @return array|null
* @throws \Bitrix\Main\NotImplementedException
*/
public function getFile()
{
if(!$this->fileId)
{
return null;
}
if(isset($this->file) && $this->fileId == $this->file['ID'])
{
return $this->file;
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$this->file = \CFile::getByID($this->fileId)->fetch();
if(!$this->file)
{
return array();
}
return $this->file;
}
/**
* Returns size in bytes.
* @return int
*/
public function getSize()
{
return $this->size;
}
/**
* Returns type of file.
* @see TypeFile class for details.
* @return int
*/
public function getTypeFile()
{
return $this->typeFile;
}
/**
* Renames object.
* @param string $newName New name.
* @return bool
*/
public function rename($newName)
{
$result = parent::rename($newName);
if($result)
{
$this->extenstion = null;
Driver::getInstance()->getIndexManager()->changeName($this);
}
return $result;
}
/**
* Copies object to target folder.
* @param Folder $targetFolder Target folder.
* @param int $updatedBy Id of user.
* @param bool $generateUniqueName Generates unique name for object in directory.
* @return BaseObject|null
*/
public function copyTo(Folder $targetFolder, $updatedBy, $generateUniqueName = false)
{
$this->errorCollection->clear();
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$forkFileId = \CFile::copyFile($this->getFileId(), true);
if(!$forkFileId)
{
$this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_MODEL_ERROR_COULD_NOT_COPY_FILE'), self::ERROR_COULD_NOT_COPY_FILE)));
return null;
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$fileArray = \CFile::getFileArray($forkFileId);
$fileModel = $targetFolder->addFile(array(
'NAME' => $this->getName(),
'FILE_ID' => $forkFileId,
'SIZE' => $fileArray['FILE_SIZE'],
'CREATED_BY' => $updatedBy
), array(), $generateUniqueName);
if(!$fileModel)
{
$this->errorCollection->add($targetFolder->getErrors());
return null;
}
return $fileModel;
}
/**
* Adds external link.
* @param array $data Data to create new external link (@see ExternalLink).
* @return bool|ExternalLink
* @throws \Bitrix\Main\ArgumentException
*/
public function addExternalLink(array $data)
{
$this->errorCollection->clear();
$data['OBJECT_ID'] = $this->id;
return ExternalLink::add($data, $this->errorCollection);
}
/**
* Returns external links by file.
* @param array $parameters Parameters.
* @return static[]
*/
public function getExternalLinks(array $parameters = array())
{
if(!isset($parameters['filter']))
{
$parameters['filter'] = array();
}
$parameters['filter']['OBJECT_ID'] = $this->id;
if(!isset($parameters['order']))
{
$parameters['order'] = array(
'CREATE_TIME' => 'DESC',
);
}
return ExternalLink::getModelList($parameters);
}
/**
* Increases global content version.
* @return bool
*/
public function increaseGlobalContentVersion()
{
//todo inc in DB by expression
$success = $this->update(array(
'GLOBAL_CONTENT_VERSION' => (int)$this->getGlobalContentVersion() + 1,
));
if(!$success)
{
return false;
}
$this->updateLinksAttributes(array(
'GLOBAL_CONTENT_VERSION' => $this->getGlobalContentVersion(),
));
return $success;
}
/**
* Updates file content.
*
* Runs index file, updates all FileLinks, sends notify to subscribers.
*
* @param array $file Structure like $_FILES.
* @param int $updatedBy Id of user.
* @return bool
* @throws \Bitrix\Main\ArgumentException
*/
public function updateContent(array $file, $updatedBy)
{
$this->errorCollection->clear();
$this->checkRequiredInputParams($file, array(
'ID', 'FILE_SIZE'
));
$this->prevFileId = $this->fileId;
//todo inc in DB by expression
$success = $this->update(array(
'GLOBAL_CONTENT_VERSION' => (int)$this->getGlobalContentVersion() + 1,
'FILE_ID' => $file['ID'],
'SIZE' => $file['FILE_SIZE'],
'UPDATE_TIME' => empty($file['UPDATE_TIME'])? new DateTime() : $file['UPDATE_TIME'],
'UPDATED_BY' => $updatedBy,
));
if(!$success)
{
$this->prevFileId = null;
return false;
}
$this->updateLinksAttributes(array(
'GLOBAL_CONTENT_VERSION' => $this->getGlobalContentVersion(),
'SIZE' => $file['FILE_SIZE'],
'UPDATE_TIME' => $this->getUpdateTime(),
'UPDATED_BY' => $updatedBy,
));
$driver = Driver::getInstance();
$driver->getIndexManager()->indexFile($this);
//todo little hack...We don't synchronize file in folder with uploaded files. And we have not to send notify by pull
if($this->parent === null || $this->parent && $this->parent->getCode() !== Folder::CODE_FOR_UPLOADED_FILES)
{
$driver->sendChangeStatusToSubscribers($this);
$updatedBy = $this->getUpdatedBy();
if($updatedBy)
{
$driver->sendEvent($updatedBy, 'live', array(
'objectId' => $this->getId(),
'action' => 'commit',
'contentVersion' => (int)$this->getGlobalContentVersion(),
'size' => (int)$this->getSize(),
'formatSize' => (string)CFile::formatSize($this->getSize()),
));
}
}
return true;
}
/**
* Adds new version to file.
*
* The method may joins version with last version.
*
* @param array $file Structure like $_FILES.
* @param int $createdBy Id of user.
* @param bool $disableJoin If set false the method attempts to join version with last version (@see \Bitrix\Disk\File::SECONDS_TO_JOIN_VERSION).
* @return Version|null
* @throws \Bitrix\Main\SystemException
*/
public function addVersion(array $file, $createdBy, $disableJoin = false)
{
$this->errorCollection->clear();
$now = new DateTime;
$needToJoin = false;
if(!$disableJoin && $this->updateTime && $this->updatedBy == $createdBy)
{
$updateTimestamp = $this->updateTime->getTimestamp();
if($now->getTimestamp() - $updateTimestamp < self::SECONDS_TO_JOIN_VERSION)
{
$needToJoin = true;
}
}
if(!$this->updateContent($file, $createdBy))
{
return null;
}
if($needToJoin)
{
$lastVersion = $this->getLastVersion();
if($lastVersion)
{
if(!$lastVersion->joinData(array_merge(array('CREATE_TIME' => $now), $this->getHistoricalData())))
{
$this->errorCollection->add($lastVersion->getErrors());
return null;
}
if($this->prevFileId && $this->prevFileId != $this->fileId)
{
CFile::delete($this->prevFileId);
}
return $lastVersion;
}
}
$versionModel = Version::add(array_merge(array(
'OBJECT_ID' => $this->id,
'FILE_ID' => $this->fileId,
'NAME' => $this->name,
'CREATED_BY' => $createdBy,
), $this->getHistoricalData()), $this->errorCollection);
if(!$versionModel)
{
return null;
}
$valueVersionUf = FileUserType::NEW_FILE_PREFIX . $versionModel->getId();
/** @var User $createUser */
$createUser = User::loadById($createdBy);
if(!$createUser)
{
//skip
return $versionModel;
}
$text = Loc::getMessage('DISK_FILE_MODEL_UPLOAD_NEW_VERSION_IN_COMMENT_M');
if($createUser->getPersonalGender() == 'F')
{
$text = Loc::getMessage('DISK_FILE_MODEL_UPLOAD_NEW_VERSION_IN_COMMENT_F');
}
foreach($this->getAttachedObjects() as $attache)
{
AttachedObject::storeDataByObjectId($this->getId(), array(
'IS_EDITABLE' => $attache->isEditable(),
'ALLOW_EDIT' => $attache->getAllowEdit(),
));
$attache->getConnector()->addComment($createdBy, array(
'text' => $text,
'versionId' => $valueVersionUf,
));
AttachedObject::storeDataByObjectId($this->getId(), null);
}
unset($attache);
return $versionModel;
}
/**
* Uploads new version to file.
* @see \Bitrix\Disk\File::addVersion().
* @param array $fileArray Structure like $_FILES.
* @param int $createdBy Id of user.
* @return Version|null
*/
public function uploadVersion(array $fileArray, $createdBy)
{
$this->errorCollection->clear();
if(!isset($fileArray['MODULE_ID']))
{
$fileArray['MODULE_ID'] = Driver::INTERNAL_MODULE_ID;
}
if(empty($fileArray['type']))
{
$fileArray['type'] = '';
}
$fileArray['type'] = TypeFile::normalizeMimeType($fileArray['type'], $this->name);
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$fileId = CFile::saveFile($fileArray, Driver::INTERNAL_MODULE_ID, true, true);
if(!$fileId)
{
$this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_MODEL_ERROR_COULD_NOT_SAVE_FILE'), self::ERROR_COULD_NOT_SAVE_FILE)));
return null;
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$fileArray = CFile::getFileArray($fileId);
$version = $this->addVersion($fileArray, $createdBy);
if(!$version)
{
CFile::delete($fileId);
}
return $version;
}
/**
* Returns version of file by version id.
* @param int $versionId Id of version.
* @return static
*/
public function getVersion($versionId)
{
return Version::load(array(
'ID' => $versionId,
'OBJECT_ID' => $this->id,
));
}
/**
* Gets last version of the file.
* @return Version|null
*/
public function getLastVersion()
{
$versions = $this->getVersions(array('limit' => 1));
return array_shift($versions)?: null;
}
/**
* Returns all versions by file.
* @param array $parameters Parameters.
* @return Version[]
* @throws \Bitrix\Main\ArgumentException
* @throws \Exception
*/
public function getVersions(array $parameters = array())
{
if(!isset($parameters['filter']))
{
$parameters['filter'] = array();
}
$parameters['filter']['OBJECT_ID'] = $this->id;
if(!isset($parameters['order']))
{
$parameters['order'] = array(
'CREATE_TIME' => 'DESC',
);
}
$versions = Version::getModelList($parameters);
foreach($versions as $version)
{
$version->setAttributes(array('OBJECT' => $this));
}
unset($version);
return $versions;
}
/**
* Restores file from the version.
*
* The method is similar with (@see Bitrix\Disk\File::addVersion()).
*
* @param Version $version Version which need to restore.
* @param int $createdBy Id of user.
* @return bool
*/
public function restoreFromVersion(Version $version, $createdBy)
{
$this->errorCollection->clear();
if($version->getObjectId() != $this->id)
{
$this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_MODEL_ERROR_COULD_NOT_RESTORE_FROM_ANOTHER_OBJECT'), self::ERROR_COULD_NOT_RESTORE_FROM_OBJECT)));
return false;
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
$forkFileId = \CFile::copyFile($version->getFileId(), true);
if(!$forkFileId)
{
$this->errorCollection->add(array(new Error(Loc::getMessage('DISK_FILE_MODEL_ERROR_COULD_NOT_COPY_FILE'), self::ERROR_COULD_NOT_COPY_FILE)));
return false;
}
/** @noinspection PhpDynamicAsStaticMethodCallInspection */
if($this->addVersion(\CFile::getFileArray($forkFileId), $createdBy, true) === null)
{
return false;
}
return true;
}
/**
* Marks deleted object. It equals to move in trash can.
* @param int $deletedBy Id of user (or SystemUser::SYSTEM_USER_ID).
* @return bool
*/
public function markDeleted($deletedBy)
{
return $this->markDeletedInternal($deletedBy);
}
/**
* Internal method for deleting file as child of folder.
* @param int $deletedBy Id of user.
* @param int $deletedType Type of delete (@see ObjectTable::DELETED_TYPE_ROOT, ObjectTable::DELETED_TYPE_CHILD)
* @return bool
* @internal
*/
public function markDeletedInternal($deletedBy, $deletedType = ObjectTable::DELETED_TYPE_ROOT)
{
$success = parent::markDeletedInternal($deletedBy, $deletedType);
if($success)
{
DeletedLog::addFile($this, $deletedBy, $this->errorCollection);
}
return $success;
}
/**
* Restores object from trash can.
* @param int $restoredBy Id of user (or SystemUser::SYSTEM_USER_ID).
* @return bool
*/
public function restore($restoredBy)
{
$needRecalculate = $this->deletedType == ObjectTable::DELETED_TYPE_CHILD;
$status = parent::restoreInternal($restoredBy);
if($status && $needRecalculate)
{
$this->recalculateDeletedTypeAfterRestore($restoredBy);
}
if($status)
{
Driver::getInstance()->sendChangeStatusToSubscribers($this);
}
return $status;
}
/**
* Deletes file and all connected data and entities (@see Sharing, @see Rights, etc).
* @param int $deletedBy Id of user.
* @return bool
* @throws \Bitrix\Main\ArgumentNullException
*/
public function delete($deletedBy)
{
$this->errorCollection->clear();
$success = EditSessionTable::deleteByFilter(array(
'OBJECT_ID' => $this->id,
));
if(!$success)
{
return false;
}
$success = ExternalLinkTable::deleteByFilter(array(
'OBJECT_ID' => $this->id,
));
if(!$success)
{
return false;
}
foreach($this->getSharingsAsReal() as $sharing)
{
$sharing->delete($deletedBy);
}
//with status unreplied, declined (not approved)
$success = SharingTable::deleteByFilter(array(
'REAL_OBJECT_ID' => $this->id,
));
if(!$success)
{
return false;
}
foreach($this->getAttachedObjects() as $attached)
{
$attached->delete();
}
unset($attached);
BizProcDocument::deleteWorkflowsFile($this->id);
SimpleRightTable::deleteBatch(array('OBJECT_ID' => $this->id));
$success = RightTable::deleteByFilter(array(
'OBJECT_ID' => $this->id,
));
if(!$success)
{
return false;
}
$success = VersionTable::deleteByFilter(array(
'OBJECT_ID' => $this->id,
));
if(!$success)
{
return false;
}
DeletedLog::addFile($this, $deletedBy, $this->errorCollection);
\CFile::delete($this->fileId);
$deleteResult = FileTable::delete($this->id);
if(!$deleteResult->isSuccess())
{
return false;
}
Driver::getInstance()->getIndexManager()->dropIndex($this);
if(!$this->isLink())
{
//todo potential - very hard operation.
foreach(File::getModelList(array('filter' => array('REAL_OBJECT_ID' => $this->id, '!=REAL_OBJECT_ID' => $this->id))) as $link)
{
$link->delete($deletedBy);
}
unset($link);
}
$event = new Event(Driver::INTERNAL_MODULE_ID, "onAfterDeleteFile", array($this->getId(), $deletedBy));
$event->send();
return true;
}
protected function getHistoricalData()
{
return array(
'FILE_ID' => $this->fileId,
'SIZE' => $this->size,
'GLOBAL_CONTENT_VERSION' => $this->globalContentVersion,
'OBJECT_CREATED_BY' => $this->createdBy,
'OBJECT_UPDATED_BY' => $this->updatedBy,
'OBJECT_CREATE_TIME'=> $this->createTime,
'OBJECT_UPDATE_TIME'=> $this->updateTime,
);
}
/**
* Returns all attached objects by the file.
* @param array $parameters Parameters.
* @return AttachedObject[]
*/
public function getAttachedObjects(array $parameters = array())
{
if(!isset($parameters['filter']))
{
$parameters['filter'] = array();
}
$parameters['filter']['OBJECT_ID'] = $this->id;
$parameters['filter']['=VERSION_ID'] = null;
return AttachedObject::getModelList($parameters);
}
protected function restoreFromHistoricalData(array $data)
{}
protected function updateLinksAttributes(array $attr)
{
$possibleToUpdate = array(
'GLOBAL_CONTENT_VERSION' => 'globalContentVersion',
'TYPE_FILE' => 'typeFile',
'SIZE' => 'size',
'EXTERNAL_HASH' => 'externalHash',
'UPDATE_TIME' => 'updateTime',
'UPDATED_BY' => 'updatedBy',
'UPDATE_USER' => 'updateUser',
);
$attr = array_intersect_key($attr, $possibleToUpdate);
if($attr)
{
parent::updateLinksAttributes($attr);
}
}
/**
* Returns the list of pair for mapping.
* Key is field in DataManager, value is object property.
* @return array
*/
public static function getMapAttributes()
{
static $shelve = null;
if($shelve !== null)
{
return $shelve;
}
$shelve = array_merge(parent::getMapAttributes(), array(
'ID' => 'id',
'NAME' => 'name',
'CODE' => 'code',
'STORAGE_ID' => 'storageId',
'STORAGE' => 'storage',
'TYPE' => 'type',
'REAL_OBJECT_ID' => 'realObjectId',
'REAL_OBJECT' => 'realObject',
'PARENT_ID' => 'parentId',
'DELETED_TYPE' => 'deletedType',
'TYPE_FILE' => 'typeFile',
'GLOBAL_CONTENT_VERSION' => 'globalContentVersion',
'FILE_ID' => 'fileId',
'SIZE' => 'size',
'EXTERNAL_HASH' => 'externalHash',
'CREATE_TIME' => 'createTime',
'UPDATE_TIME' => 'updateTime',
'DELETE_TIME' => 'deleteTime',
'CREATED_BY' => 'createdBy',
'CREATE_USER' => 'createUser',
'UPDATED_BY' => 'updatedBy',
'UPDATE_USER' => 'updateUser',
'DELETED_BY' => 'deletedBy',
'DELETE_USER' => 'deleteUser',
));
return $shelve;
}
}