Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F803560
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
Tue, Feb 25, 1:33 PM
Size
7 KB
Mime Type
text/x-diff
Expires
Thu, Feb 27, 1:33 PM (19 h, 59 m)
Engine
blob
Format
Raw Data
Handle
576364
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/RC/core/units/fck/fck_eh.php
===================================================================
--- branches/RC/core/units/fck/fck_eh.php (revision 11567)
+++ branches/RC/core/units/fck/fck_eh.php (revision 11568)
@@ -1,198 +1,191 @@
<?php
class FckEventHandler extends kDBEventHandler {
function mapPermissions()
{
parent::mapPermissions();
$permissions = array(
'OnLoadCmsTree' => array('self' => true),
'OnLoadResources' => array('self' => true),
'OnRenameFile' => array('self' => true),
'OnDeleteFiles' => array('self' => true),
'OnGetFoldersFilesList' => array('self' => true),
'OnCreateFolder' => array('self' => true),
'OnUploadFile' => array('self' => true),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
}
/**
* Checks permissions of user
*
* @param kEvent $event
*/
function CheckPermission(&$event)
{
if ($this->Application->LoggedIn() && $this->Application->IsAdmin()) {
return true;
}
return parent::CheckPermission($event);
}
function CreateXmlHeader()
{
ob_end_clean() ;
// Prevent the browser from caching the result.
// Date in the past
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ;
// always modified
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ;
// HTTP/1.1
header('Cache-Control: no-store, no-cache, must-revalidate') ;
header('Cache-Control: post-check=0, pre-check=0', false) ;
// HTTP/1.0
header('Pragma: no-cache') ;
// Set the response format.
header( 'Content-Type: text/xml; charset=utf-8' ) ;
// Create the XML document header.
}
function OnLoadCmsTree(&$event)
{
$event->status = erSTOP;
$this->CreateXmlHeader();
$res = '<?xml version="1.0" encoding="utf-8" ?>'."\n" ;
$res.= "<CmsPages>"."\n";
- if ($this->Application->isModuleEnabled('Proj-CMS')) {
- $lang = $this->Application->GetVar('m_lang');
- $st =& $this->Application->recallObject('st.-dummy');
- $st_options = $this->Application->getUnitOption('st'.'.ParentId', 'Fields');
- $pages = $st_options['options'];
- $page_ids = array_keys($pages);
- $tpls = $this->Application->Conn->GetCol('SELECT NamedParentPath, CategoryId FROM '.TABLE_PREFIX.'Category WHERE CategoryId IN ('.join(',', $page_ids).')', 'CategoryId');
-
- //$res = '';
- foreach ($pages as $id => $title) {
- $page_path = preg_replace('/^Content\//i', '', strtolower($tpls[$id]).'.html');
- $title = $title.' ('.$page_path.')';
- $real_url = $this->Application->HREF($tpls[$id], '_FRONT_END_', array('pass'=>'m'), 'index.php');
- $res .= '<CmsPage real_url="'.$real_url.'" path="@@'.$id.'@@" title="'.$prefix.htmlspecialchars($title,ENT_QUOTES).'" st_id="'.$id.'" serverpath="" />'."\n";
- }
- }
- else {
- $lang = $this->Application->GetVar('m_lang');
+ $lang = $this->Application->GetVar('m_lang');
- $query = 'SELECT PageId, Path, l'.$lang.'_Title AS Title FROM '.TABLE_PREFIX.'Pages ORDER By l'.$lang.'_Title';
- $pages = $this->Application->Conn->Query($query);
+ $st =& $this->Application->recallObject('st.-dummy');
+ /* @var $st kDBItem */
-// $res = '';
- foreach ($pages as $page) {
- $page_path = $page['Path'].'.html';
- $title = $page['Title'].' ('.$page_path.')';
- $res .= '<CmsPage path="'.$page_path.'" title="'.$prefix.htmlspecialchars($title,ENT_QUOTES).'" st_id="'.$page['PageId'].'" serverpath="'.BASE_PATH.'/" />';
- }
+ $st_options = $this->Application->getUnitOption('st'.'.ParentId', 'Fields');
+ $pages = $st_options['options'];
+ $page_ids = array_keys($pages);
+
+ $sql = 'SELECT NamedParentPath, CategoryId
+ FROM ' . TABLE_PREFIX . 'Category
+ WHERE CategoryId IN (' . implode(',', $page_ids) . ')';
+ $tpls = $this->Application->Conn->GetCol($sql, 'CategoryId');
+
+ //$res = '';
+ foreach ($pages as $id => $title) {
+ $page_path = preg_replace('/^Content\//i', '', strtolower($tpls[$id]).'.html');
+ $title = $title.' ('.$page_path.')';
+ $real_url = $this->Application->HREF($tpls[$id], '_FRONT_END_', array('pass'=>'m'), 'index.php');
+ $res .= '<CmsPage real_url="'.$real_url.'" path="@@'.$id.'@@" title="'.$prefix.htmlspecialchars($title,ENT_QUOTES).'" st_id="'.$id.'" serverpath="" />'."\n";
}
+
$res.= "</CmsPages>";
echo $res;
}
function OnRenameFile(&$event)
{
$event->status = erSTOP;
$old_name = $this->Application->GetVar('old_name');
$new_name = $this->Application->GetVar('new_name');
$folder = $this->Application->GetVar('folder');
$sServerDir = WRITEABLE.'/user_files/'.$folder.'/';
if (!file_exists($sServerDir.$old_name) || !is_file($sServerDir.$old_name)) {
echo 204;
return;
}
$fck_helper =& $this->Application->recallObject('FCKHelper');
/* @var fck_helper fckFCKHelper*/
if (!$fck_helper->IsAllowedExtension($folder, $new_name)) {
echo 203;
return;
}
if (!rename($sServerDir.$old_name,$sServerDir.$new_name)) {
// echo $sServerDir.$old_name.' -> '.$sServerDir.$new_name;
echo 205;
return;
}
echo '0';
}
function OnDeleteFiles(&$event)
{
$event->status = erSTOP;
$files = trim($this->Application->GetVar('files'),'|');
// echo $files;
$a_files = explode('|', $files);
$folder = $this->Application->GetVar('folder');
$sServerDir = WRITEABLE.'/user_files/'.$folder.'/';
foreach ($a_files AS $file) {
@unlink($sServerDir.$file);
}
// print_r($a_files);
}
function OnGetFoldersFilesList(&$event)
{
$this->CreateXmlHeader();
$fck_helper =& $this->Application->recallObject('FCKHelper');
/* @var fck_helper fckFCKHelper*/
$ret = '<?xml version="1.0" encoding="utf-8" ?>'."\n" ;
$ret .= "<content>"."\n";
$ret .= $fck_helper->PrintFolders();
$ret .= $fck_helper->PrintFiles();
$ret .= "</content>"."\n";
echo $ret;
exit;
}
function OnCreateFolder(&$event)
{
$event->status = erSTOP;
$new_folder = $this->Application->GetVar('new_folder');
$current_folder = $this->Application->GetVar('current_folder');
$folderPath = WRITEABLE.'/user_files'.'/'.$current_folder."/".$new_folder;
if ( file_exists( $folderPath ) && is_dir($folderPath)) {
echo "101";
}
if ( !file_exists( $folderPath ) )
{
// Turn off all error reporting.
error_reporting( 0 ) ;
// Enable error tracking to catch the error.
ini_set( 'track_errors', '1' ) ;
// To create the folder with 0777 permissions, we need to set umask to zero.
$oldumask = umask(0) ;
mkdir( $folderPath, 0777 ) ;
umask( $oldumask ) ;
$sErrorMsg = $php_errormsg ;
// Restore the configurations.
ini_restore( 'track_errors' ) ;
ini_restore( 'error_reporting' ) ;
if ($sErrorMsg)
echo $sErrorMsg ;
else
echo '0';
}
}
function OnUploadFile(&$event)
{
$event->status = erSTOP;
$fck_helper =& $this->Application->recallObject('FCKHelper');
/* @var fck_helper fckFCKHelper*/
$fck_helper->UploadFile();
}
}
Property changes on: branches/RC/core/units/fck/fck_eh.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.1.2.5
\ No newline at end of property
+1.1.2.6
\ No newline at end of property
Event Timeline
Log In to Comment