Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F849111
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Apr 20, 2:33 PM
Size
5 KB
Mime Type
text/x-diff
Expires
Tue, Apr 22, 2:33 PM (19 h, 43 m)
Engine
blob
Format
Raw Data
Handle
603648
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/RC/kernel/units/files/file_eh.php
===================================================================
--- branches/RC/kernel/units/files/file_eh.php (revision 9627)
+++ branches/RC/kernel/units/files/file_eh.php (revision 9628)
@@ -1,88 +1,89 @@
<?php
class FileEventHandler extends kDBEventHandler {
/**
* Allows to override standart permission mapping
*
*/
function mapPermissions()
{
parent::mapPermissions();
$permissions = Array(
'OnDownloadFile' => Array('subitem' => 'view'),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
/**
* [HOOK] Allows to apply file functionality to specific config
* When main item is created, then #file config is cloned
*
* @param kEvent $event
*/
function OnDefineFiles(&$event)
{
$clones = $this->Application->getUnitOption('#file', 'Clones');
$clones[$event->MasterEvent->Prefix.'-file'] = Array (
'ParentPrefix' => $event->MasterEvent->Prefix,
);
$this->Application->setUnitOption('#file', 'Clones', $clones);
}
/**
* Remembers user, who is created file record. Makes file primary if no other files are uploaded.
*
* @param kEvent $event
*/
function OnBeforeItemCreate(&$event)
{
+ $object =& $event->getObject();
$object->SetDBField('CreatedById', $this->Application->RecallVar('user_id'));
}
/**
* Resets primary file mark when more then one file is marked as primary
*
* @param kEvent $event
*/
function OnBeforeItemUpdate(&$event)
{
$object =& $event->getObject();
if (!$object->GetDBField('FileName')) {
$object->SetDBField('FileName', basename($object->GetDBField('FilePath')));
}
}
function SetCustomQuery(&$event)
{
parent::SetCustomQuery($event);
$object =& $event->getObject();
if (!$this->Application->IsAdmin()) {
$object->addFilter('active_filter', '%1$s.Status = '.STATUS_ACTIVE);
}
}
/**
* Returns file contents associated with item
*
* @param kEvent $event
*/
function OnDownloadFile(&$event)
{
$object =& $event->getObject();
/* @var $object kDBItem */
$file_helper =& $this->Application->recallObject('FileHelper');
/* @var $file_helper FileHelper */
$filename = $object->GetField('FilePath', 'full_path');
$file_helper->DownloadFile($filename);
$event->status = erSTOP;
}
}
?>
\ No newline at end of file
Property changes on: branches/RC/kernel/units/files/file_eh.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1.2.3
\ No newline at end of property
+1.1.2.4
\ No newline at end of property
Index: branches/RC/core/units/files/file_eh.php
===================================================================
--- branches/RC/core/units/files/file_eh.php (revision 9627)
+++ branches/RC/core/units/files/file_eh.php (revision 9628)
@@ -1,88 +1,89 @@
<?php
class FileEventHandler extends kDBEventHandler {
/**
* Allows to override standart permission mapping
*
*/
function mapPermissions()
{
parent::mapPermissions();
$permissions = Array(
'OnDownloadFile' => Array('subitem' => 'view'),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
/**
* [HOOK] Allows to apply file functionality to specific config
* When main item is created, then #file config is cloned
*
* @param kEvent $event
*/
function OnDefineFiles(&$event)
{
$clones = $this->Application->getUnitOption('#file', 'Clones');
$clones[$event->MasterEvent->Prefix.'-file'] = Array (
'ParentPrefix' => $event->MasterEvent->Prefix,
);
$this->Application->setUnitOption('#file', 'Clones', $clones);
}
/**
* Remembers user, who is created file record. Makes file primary if no other files are uploaded.
*
* @param kEvent $event
*/
function OnBeforeItemCreate(&$event)
{
+ $object =& $event->getObject();
$object->SetDBField('CreatedById', $this->Application->RecallVar('user_id'));
}
/**
* Resets primary file mark when more then one file is marked as primary
*
* @param kEvent $event
*/
function OnBeforeItemUpdate(&$event)
{
$object =& $event->getObject();
if (!$object->GetDBField('FileName')) {
$object->SetDBField('FileName', basename($object->GetDBField('FilePath')));
}
}
function SetCustomQuery(&$event)
{
parent::SetCustomQuery($event);
$object =& $event->getObject();
if (!$this->Application->IsAdmin()) {
$object->addFilter('active_filter', '%1$s.Status = '.STATUS_ACTIVE);
}
}
/**
* Returns file contents associated with item
*
* @param kEvent $event
*/
function OnDownloadFile(&$event)
{
$object =& $event->getObject();
/* @var $object kDBItem */
$file_helper =& $this->Application->recallObject('FileHelper');
/* @var $file_helper FileHelper */
$filename = $object->GetField('FilePath', 'full_path');
$file_helper->DownloadFile($filename);
$event->status = erSTOP;
}
}
?>
\ No newline at end of file
Property changes on: branches/RC/core/units/files/file_eh.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1.2.3
\ No newline at end of property
+1.1.2.4
\ No newline at end of property
Event Timeline
Log In to Comment