Index: branches/RC/core/units/users/users_config.php =================================================================== diff -u -r9419 -r9616 --- branches/RC/core/units/users/users_config.php (.../users_config.php) (revision 9419) +++ branches/RC/core/units/users/users_config.php (.../users_config.php) (revision 9616) @@ -133,10 +133,11 @@ ), 'CalculatedFields' => Array( - '' => Array( - 'PrimaryGroup' => 'g.Name', - ), - ), + '' => Array( + 'PrimaryGroup' => 'g.Name', + 'FullName' => 'CONCAT(FirstName, " ", LastName)', + ), + ), 'Fields' => Array ( @@ -184,13 +185,15 @@ ), 'VirtualFields' => Array( - 'ValidateLogin' => Array('type'=>'string','default'=>''), - 'SubscribeEmail' => Array('type'=>'string','default'=>''), - 'PrimaryGroup' => Array('type' => 'string', 'default' => ''), - 'Captcha' => Array('type' => 'string', 'default' => ''), - 'RootPassword' => Array('type' => 'string', 'formatter' => 'kPasswordFormatter', 'encryption_method' => 'md5', 'verify_field' => 'VerifyRootPassword', 'skip_empty' => 1, 'default' => md5('') ), - ), + 'ValidateLogin' => Array('type'=>'string','default'=>''), + 'SubscribeEmail' => Array('type'=>'string','default'=>''), + 'PrimaryGroup' => Array('type' => 'string', 'default' => ''), + 'Captcha' => Array('type' => 'string', 'default' => ''), + 'RootPassword' => Array('type' => 'string', 'formatter' => 'kPasswordFormatter', 'encryption_method' => 'md5', 'verify_field' => 'VerifyRootPassword', 'skip_empty' => 1, 'default' => md5('') ), + 'FullName' => Array ('type' => 'string', 'default' => ''), + ), + 'Grids' => Array( 'Default' => Array( 'Icons' => Array(0 => 'icon16_user_disabled.gif', 1 => 'icon16_user.gif', 2 => 'icon16_user_pending.gif'), Index: branches/RC/core/units/files/file_eh.php =================================================================== diff -u -r9598 -r9616 --- branches/RC/core/units/files/file_eh.php (.../file_eh.php) (revision 9598) +++ branches/RC/core/units/files/file_eh.php (.../file_eh.php) (revision 9616) @@ -2,6 +2,20 @@ 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 * @@ -50,6 +64,25 @@ $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 Index: branches/RC/core/units/files/files_config.php =================================================================== diff -u -r9600 -r9616 --- branches/RC/core/units/files/files_config.php (.../files_config.php) (revision 9600) +++ branches/RC/core/units/files/files_config.php (.../files_config.php) (revision 9616) @@ -5,7 +5,7 @@ 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'), 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'), 'EventHandlerClass' => Array ('class' => 'FileEventHandler', 'file' => 'file_eh.php', 'build_event' => 'OnBuild'), - 'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'), + 'TagProcessorClass' => Array ('class' => 'FileTagProcessor', 'file' => 'file_tp.php', 'build_event' => 'OnBuild'), 'AutoLoad' => true, @@ -47,7 +47,6 @@ 'ListSortings' => Array ( '' => Array ( - 'ForcedSorting' => Array('Priority' => 'desc'), 'Sorting' => Array ('FileName' => 'asc'), ) ), @@ -65,8 +64,6 @@ ), 'Size' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'Status' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Enabled', 0 => 'la_Disabled'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 1), - 'IsPrimary' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), - 'Priority' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'CreatedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'not_null' => 1, 'default' => '#NOW#'), 'CreatedById' => Array ('type' => 'int', 'not_null' => 1, 'default' => -1), 'MimeType' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''), Index: branches/RC/kernel/units/files/files_config.php =================================================================== diff -u -r9600 -r9616 --- branches/RC/kernel/units/files/files_config.php (.../files_config.php) (revision 9600) +++ branches/RC/kernel/units/files/files_config.php (.../files_config.php) (revision 9616) @@ -5,7 +5,7 @@ 'ItemClass' => Array ('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'), 'ListClass' => Array ('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'), 'EventHandlerClass' => Array ('class' => 'FileEventHandler', 'file' => 'file_eh.php', 'build_event' => 'OnBuild'), - 'TagProcessorClass' => Array ('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'), + 'TagProcessorClass' => Array ('class' => 'FileTagProcessor', 'file' => 'file_tp.php', 'build_event' => 'OnBuild'), 'AutoLoad' => true, @@ -47,7 +47,6 @@ 'ListSortings' => Array ( '' => Array ( - 'ForcedSorting' => Array('Priority' => 'desc'), 'Sorting' => Array ('FileName' => 'asc'), ) ), @@ -65,8 +64,6 @@ ), 'Size' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'Status' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options' => Array (1 => 'la_Enabled', 0 => 'la_Disabled'), 'use_phrases' => 1, 'not_null' => 1, 'default' => 1), - 'IsPrimary' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), - 'Priority' => Array ('type' => 'int', 'not_null' => 1, 'default' => 0), 'CreatedOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'not_null' => 1, 'default' => '#NOW#'), 'CreatedById' => Array ('type' => 'int', 'not_null' => 1, 'default' => -1), 'MimeType' => Array ('type' => 'string', 'max_len' => 255, 'not_null' => 1, 'default' => ''), Index: branches/RC/core/kernel/event_manager.php =================================================================== diff -u -r9298 -r9616 --- branches/RC/core/kernel/event_manager.php (.../event_manager.php) (revision 9298) +++ branches/RC/core/kernel/event_manager.php (.../event_manager.php) (revision 9616) @@ -99,10 +99,8 @@ function setQueryMap($prefix_special) { list($prefix) = explode('.', $prefix_special); - $query_map = $this->Application->getUnitOption($prefix, 'QueryString'); - if (!$query_map && preg_match('/(.*)-cdata/', $prefix)) { - $query_map = $this->Application->getUnitOption('cdata', 'QueryString'); - } + + $query_map = $this->getQueryMap($prefix); if ($query_map) { $this->queryMaps[$prefix_special] = $query_map; } @@ -116,6 +114,27 @@ } /** + * Returns QueryMap for requested unit config. In case if unit config is a clone, then get parent item's (from prefix) config to create clone + * + * @param string $prefix + * @return Array + */ + function getQueryMap($prefix) + { + $query_map = $this->Application->getUnitOption($prefix, 'QueryString'); + if (!$query_map) { + if (preg_match('/(.*?)-(.*)/', $prefix, $regs)) { + // #prefix - format for configs, that are only cloned & optionally used for hooking (without # is old format) + $prefix = $this->Application->UnitConfigReader->prefixRegistred('#'.$regs[2]) ? '#'.$regs[2] : $regs[2]; + + return $this->Application->getUnitOption($prefix, 'QueryString'); + } + } + + return $query_map; + } + + /** * Registers new regular event * * @param string $short_name name to be used to store last maintenace run info @@ -281,6 +300,13 @@ $event_handler =& $this->Application->recallObject($event->Prefix.'_EventHandler'); /* @var $event_handler kEventHandler */ + + if (preg_match('/(.*?)-(.*)/', $event->Prefix, $regs)) { + // this is event from cloned config -> load parent config to create valid clone + $this->Application->UnitConfigReader->loadConfig($regs[1]); + $this->Application->HandleEvent( new kEvent($regs[1].':OnAfterConfigRead') ); + } + $event->setEventParam('top_prefix', $this->Application->GetTopmostPrefix($event->Prefix, true)); if (($this->Application->RecallVar('user_id') == -1) || $event_handler->CheckPermission($event)) { $this->HandleEvent($event); Index: branches/RC/core/units/general/cat_event_handler.php =================================================================== diff -u -r9598 -r9616 --- branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 9598) +++ branches/RC/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 9616) @@ -2327,15 +2327,11 @@ return ; } - $filename = $object->GetField($field, 'full_path'); + $file_helper =& $this->Application->recallObject('FileHelper'); + /* @var $file_helper FileHelper */ - $content_type = function_exists('mime_content_type') ? mime_content_type($filename) : 'application/octet-stream'; - - header('Content-type: '.$content_type); - header('Content-Disposition: attachment; filename="'.basename($filename).'"'); - header('Content-Length: '.filesize($filename)); - readfile($filename); - flush(); + $filename = $object->GetField($field, 'full_path'); + $file_helper->DownloadFile($filename); } } Index: branches/RC/kernel/units/helpers/file_helper.php =================================================================== diff -u -r9598 -r9616 --- branches/RC/kernel/units/helpers/file_helper.php (.../file_helper.php) (revision 9598) +++ branches/RC/kernel/units/helpers/file_helper.php (.../file_helper.php) (revision 9616) @@ -183,6 +183,22 @@ $this->Application->setUnitOption($prefix, 'Fields', $fields); $this->Application->setUnitOption($prefix, 'VirtualFields', $virtual_fields); } + + /** + * Downloads file to user + * + * @param string $filename + */ + function DownloadFile($filename) + { + $content_type = function_exists('mime_content_type') ? mime_content_type($filename) : 'application/octet-stream'; + + header('Content-type: '.$content_type); + header('Content-Disposition: attachment; filename="'.basename($filename).'"'); + header('Content-Length: '.filesize($filename)); + readfile($filename); + flush(); + } } ?> \ No newline at end of file Index: branches/RC/kernel/units/files/file_tp.php =================================================================== diff -u --- branches/RC/kernel/units/files/file_tp.php (revision 0) +++ branches/RC/kernel/units/files/file_tp.php (revision 9616) @@ -0,0 +1,14 @@ +getPrefixSpecial().'_event'] = 'OnDownloadFile'; + $params['pass'] = 'm,'.$this->Application->getUnitOption($this->Prefix, 'ParentPrefix').','.$this->getPrefixSpecial(); + + return $this->ItemLink($params); + } + } + +?> \ No newline at end of file Index: branches/RC/core/units/files/file_tp.php =================================================================== diff -u --- branches/RC/core/units/files/file_tp.php (revision 0) +++ branches/RC/core/units/files/file_tp.php (revision 9616) @@ -0,0 +1,14 @@ +getPrefixSpecial().'_event'] = 'OnDownloadFile'; + $params['pass'] = 'm,'.$this->Application->getUnitOption($this->Prefix, 'ParentPrefix').','.$this->getPrefixSpecial(); + + return $this->ItemLink($params); + } + } + +?> \ No newline at end of file Index: branches/RC/core/kernel/db/db_tag_processor.php =================================================================== diff -u -r9535 -r9616 --- branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 9535) +++ branches/RC/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 9616) @@ -1554,9 +1554,7 @@ } } - ksort($imatrix); - reset($imatrix); - return $imatrix; + return array_values($imatrix); } /** @@ -1911,7 +1909,10 @@ { $object =& $this->getObject($params); - $params['pass'] = 'm'; + if (!isset($params['pass'])) { + $params['pass'] = 'm'; + } + $params[$object->getPrefixSpecial().'_id'] = $object->GetID(); $m =& $this->Application->recallObject('m_TagProcessor'); Index: branches/RC/kernel/units/files/file_eh.php =================================================================== diff -u -r9598 -r9616 --- branches/RC/kernel/units/files/file_eh.php (.../file_eh.php) (revision 9598) +++ branches/RC/kernel/units/files/file_eh.php (.../file_eh.php) (revision 9616) @@ -2,6 +2,20 @@ 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 * @@ -50,6 +64,25 @@ $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