Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F773660
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, Feb 2, 7:02 PM
Size
39 KB
Mime Type
text/x-diff
Expires
Tue, Feb 4, 7:02 PM (4 h, 7 m)
Engine
blob
Format
Raw Data
Handle
556854
Attached To
rINP In-Portal
in-portal
View Options
Index: trunk/kernel/units/general/cat_event_handler.php
===================================================================
--- trunk/kernel/units/general/cat_event_handler.php (revision 1582)
+++ trunk/kernel/units/general/cat_event_handler.php (revision 1583)
@@ -1,146 +1,146 @@
<?php
$application =& kApplication::Instance();
$application->Factory->includeClassFile('kDBEventHandler');
class kCatDBEventHandler extends InpDBEventHandler {
function OnCopy(&$event)
{
$object = $event->getObject();
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard', implode(',', $ids));
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard_mode', 'copy');
- $this->Application->StoreVar('clipboard', 'COPY-0.'.TABLE_PREFIX.'Products.ResourceId=0');
+ $this->Application->StoreVar('clipboard', 'COPY-0.'.$object->TableName.'.ResourceId=0');
$event->redirect_params = Array('opener' => 's', 'pass_events'=>true); //do not go up - STAY
}
function OnCut(&$event)
{
$object = $event->getObject();
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard', implode(',', $ids));
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard_mode', 'cut');
- $this->Application->StoreVar('clipboard', 'CUT-0.'.TABLE_PREFIX.'Products.ResourceId=0');
+ $this->Application->StoreVar('clipboard', 'CUT-0.'.$object->TableName.'.ResourceId=0');
$event->redirect_params = Array('opener' => 's', 'pass_events'=>true); //do not go up - STAY
}
function OnPaste(&$event)
{
$ids = $this->Application->RecallVar($event->getPrefixSpecial().'_clipboard');
if ($ids == '') {
$event->redirect = false;
return;
}
//recalling by different name, because we may get kDBList, if we recall just by prefix
$object =& $this->Application->recallObject($event->getPrefixSpecial().'.item', $event->Prefix);
$this->prepareObject($object,$event);
if ($this->Application->RecallVar($event->getPrefixSpecial().'_clipboard_mode') == 'copy') {
$ids_arr = explode(',', $ids);
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
if($ids_arr)
{
$temp->CloneItems($event->Prefix, $event->Special, $ids_arr);
}
}
else { // mode == cut
$ids_arr = explode(',', $ids);
foreach ($ids_arr as $id) {
$object->Load($id);
$object->MoveToCat();
}
}
$event->status = erSUCCESS;
}
/**
* Apply scope clause
*
* @param kEvent $event
*/
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
if ($event->Special != 'showall') {
if ( $event->getEventParam('parent_cat_id') ) {
$parent_cat_id = $event->getEventParam('parent_cat_id');
}
else {
$parent_cat_id = $this->Application->GetVar('c_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
if (!$parent_cat_id) {
$parent_cat_id = 0;
}
}
if ((string) $parent_cat_id != 'any') {
if ($event->getEventParam('recursive')) {
$current_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$parent_cat_id);
$subcats = $this->Conn->GetCol('SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE ParentPath LIKE "'.$current_path.'%" ');
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.CategoryId IN ('.implode(', ', $subcats).')');
}
else {
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.CategoryId = '.$parent_cat_id );
}
}
}
else {
$object->addFilter('primary_filter', 'PrimaryCat = 1');
}
$view_perm = 1;
$object->addFilter('perm_filter', 'perm.PermId = '.$view_perm);
if (!defined('ADMIN')) {
$groups = explode(',',$this->Application->RecallVar('UserGroups'));
foreach ($groups as $group) {
$view_filters[] = 'FIND_IN_SET('.$group.', perm.acl) || ((NOT FIND_IN_SET('.$group.',perm.dacl)) AND perm.acl=\'\')';
}
$view_filter = implode(' OR ', $view_filters);
$object->addFilter('perm_filter2', $view_filter);
}
if (!defined('ADMIN')) {
$object->addFilter('status_filter', $object->TableName.'.Status = 1');
}
/*$list_type = $event->getEventParam('ListType');
switch($list_type)
{
case 'favorites':
$fav_table = $this->Application->getUnitOption('fav','TableName');
$user_id =& $this->Application->GetVar('u_id');
$sql = 'SELECT DISTINCT f.ResourceId
FROM '.$fav_table.' f
LEFT JOIN '.$object->TableName.' p ON p.ResourceId = f.ResourceId
WHERE f.PortalUserId = '.$user_id;
$ids = $this->Conn->GetCol($sql);
if(!$ids) $ids = Array(-1);
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.PrimaryCat = 1');
$object->addFilter('favorites_filter', '%1$s.`ResourceId` IN ('.implode(',',$ids).')');
break;
case 'search':
$search_results_table = TABLE_PREFIX.'ses_'.$this->Application->GetVar('sid').'_'.TABLE_PREFIX.'Search';
$sql = ' SELECT DISTINCT ResourceId
FROM '.$search_results_table.'
WHERE ItemType=11';
$ids = $this->Conn->GetCol($sql);
if(!$ids) $ids = Array(-1);
$object->addFilter('search_filter', '%1$s.`ResourceId` IN ('.implode(',',$ids).')');
break;
} */
}
}
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/general/cat_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/kernel/units/general/my_application.php
===================================================================
--- trunk/kernel/units/general/my_application.php (revision 1582)
+++ trunk/kernel/units/general/my_application.php (revision 1583)
@@ -1,46 +1,46 @@
-<?php
-
- k4_include_once(MODULES_PATH.'/kernel/units/general/inp_db_event_handler.php');
-
- class MyApplication extends kApplication {
-
- function RegisterDefaultClasses()
- {
- parent::RegisterDefaultClasses();
-
- $this->registerClass('Inp1Parser',MODULES_PATH.'/kernel/units/general/inp1_parser.php','Inp1Parser');
-
- $this->registerClass('InpSession',MODULES_PATH.'/kernel/units/general/inp_ses_storage.php','Session');
- $this->registerClass('InpSessionStorage',MODULES_PATH.'/kernel/units/general/inp_ses_storage.php','SessionStorage');
-
- $this->registerClass('kCatDBItem',MODULES_PATH.'/kernel/units/general/cat_dbitem.php');
- $this->registerClass('kCatDBList',MODULES_PATH.'/kernel/units/general/cat_dblist.php');
- $this->registerClass('kCatDBEventHandler',MODULES_PATH.'/kernel/units/general/cat_event_handler.php');
- $this->registerClass('InpLoginEventHandler',MODULES_PATH.'/kernel/units/general/inp_login_event_handler.php','login_EventHandler');
- $this->registerClass('InpDBEventHandler',MODULES_PATH.'/kernel/units/general/inp_db_event_handler.php','kDBEventHandler');
- $this->registerClass('InpTempTablesHandler',MODULES_PATH.'/kernel/units/general/inp_temp_handler.php','kTempTablesHandler');
- $this->registerClass('InpUnitConfigReader',MODULES_PATH.'/kernel/units/general/inp_unit_config_reader.php','kUnitConfigReader');
-
- $this->registerClass('InpCustomFieldsHelper',MODULES_PATH.'/kernel/units/general/custom_fields.php','InpCustomFieldsHelper');
- $this->registerClass('kCountryStatesHelper',MODULES_PATH.'/kernel/units/general/country_states.php','CountryStatesHelper');
- }
-
- /**
- * Checks if user is logged in, and creates
- * user object if so. User object can be recalled
- * later using "u" prefix. Also you may
- * get user id by getting "u_id" variable.
- *
- * @access private
- */
- function ValidateLogin()
- {
- $session =& $this->recallObject('Session');
- $user_id = $session->GetField('PortalUserId');
- if (!$user_id) $user_id = -2;
- $this->SetVar('u_id', $user_id);
- $this->StoreVar('user_id', $user_id);
- }
- }
-
+<?php
+
+ k4_include_once(MODULES_PATH.'/kernel/units/general/inp_db_event_handler.php');
+
+ class MyApplication extends kApplication {
+
+ function RegisterDefaultClasses()
+ {
+ parent::RegisterDefaultClasses();
+
+ $this->registerClass('Inp1Parser',MODULES_PATH.'/kernel/units/general/inp1_parser.php','Inp1Parser');
+
+ $this->registerClass('InpSession',MODULES_PATH.'/kernel/units/general/inp_ses_storage.php','Session');
+ $this->registerClass('InpSessionStorage',MODULES_PATH.'/kernel/units/general/inp_ses_storage.php','SessionStorage');
+
+ $this->registerClass('kCatDBItem',MODULES_PATH.'/kernel/units/general/cat_dbitem.php');
+ $this->registerClass('kCatDBList',MODULES_PATH.'/kernel/units/general/cat_dblist.php');
+ $this->registerClass('kCatDBEventHandler',MODULES_PATH.'/kernel/units/general/cat_event_handler.php');
+ $this->registerClass('InpLoginEventHandler',MODULES_PATH.'/kernel/units/general/inp_login_event_handler.php','login_EventHandler');
+ $this->registerClass('InpDBEventHandler',MODULES_PATH.'/kernel/units/general/inp_db_event_handler.php','kDBEventHandler');
+ $this->registerClass('InpTempTablesHandler',MODULES_PATH.'/kernel/units/general/inp_temp_handler.php','kTempTablesHandler');
+ $this->registerClass('InpUnitConfigReader',MODULES_PATH.'/kernel/units/general/inp_unit_config_reader.php','kUnitConfigReader');
+
+ $this->registerClass('InpCustomFieldsHelper',MODULES_PATH.'/kernel/units/general/custom_fields.php','InpCustomFieldsHelper');
+ $this->registerClass('kCountryStatesHelper',MODULES_PATH.'/kernel/units/general/country_states.php','CountryStatesHelper');
+ }
+
+ /**
+ * Checks if user is logged in, and creates
+ * user object if so. User object can be recalled
+ * later using "u" prefix. Also you may
+ * get user id by getting "u_id" variable.
+ *
+ * @access private
+ */
+ function ValidateLogin()
+ {
+ $session =& $this->recallObject('Session');
+ $user_id = $session->GetField('PortalUserId');
+ if (!$user_id) $user_id = -2;
+ $this->SetVar('u_id', $user_id);
+ $this->StoreVar('user_id', $user_id);
+ }
+ }
+
?>
\ No newline at end of file
Property changes on: trunk/kernel/units/general/my_application.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/core/kernel/processors/main_processor.php
===================================================================
--- trunk/core/kernel/processors/main_processor.php (revision 1582)
+++ trunk/core/kernel/processors/main_processor.php (revision 1583)
@@ -1,735 +1,736 @@
<?php
class MainProcessor extends TagProcessor {
function Init($prefix,$special)
{
parent::Init($prefix,$special);
$actions =& $this->Application->recallObject('kActions');
$actions->Set('t', $this->Application->GetVar('t'));
$actions->Set('sid', $this->Application->GetSID());
$actions->Set('m_opener', $this->Application->GetVar('m_opener') );
}
/**
* Used to handle calls where tag name
* match with existing php function name
*
* @param Tag $tag
* @return string
*/
function ProcessTag(&$tag)
{
if ($tag->Tag=='include') $tag->Tag='MyInclude';
return parent::ProcessTag($tag);
}
/**
* Creates <base href ..> HTML tag for all templates
* affects future css, js files and href params of links
*
* @return string
* @access public
*/
function Base_Ref()
{
$url = $this->Application->BaseURL().substr(THEMES_PATH,1).'/';
return '<base href="'.$url.'" />';
}
/**
* Returns base url for web-site
*
* @return string
* @access public
*/
function BaseURL()
{
return $this->Application->BaseURL();
}
function TemplatesBase($params)
{
return $this->Application->BaseURL().THEMES_PATH;
}
function ProjectBase($params)
{
return $this->Application->BaseURL();
}
/*function Base($params)
{
return $this->Application->BaseURL().$params['add'];
}*/
/**
* Used to create link to any template.
* use "pass" paramter if "t" tag to specify
* prefix & special of object to be represented
* in resulting url
*
* @param Array $params
* @return string
* @access public
*/
function T($params)
{
//by default link to current template
$t = $this->SelectParam($params, 't,template');
if ($t === false) {
$t = $this->Application->GetVar('t');
}
unset($params['t']);
unset($params['template']);
$prefix=isset($params['prefix']) ? $params['prefix'] : ''; unset($params['prefix']);
$index_file = isset($params['index_file']) ? $params['index_file'] : null; unset($params['index_file']);
/*$pass=isset($params['pass']) ? $params['pass'] : $this->Application->GetVar('t_pass'); unset($params['pass']);
$this->Application->SetVar('t_pass', $pass);
$pass_events = isset($params['pass_events']) && $params['pass_events'] ? 1 : 0; unset($params['pass_events']);
$this->Application->SetVar('t_pass_events', $pass_events);*/
//Use only implicit params passing, do not set into APP
// $this->Set($params); // set other params as application vars
return str_replace('&', '&', $this->Application->HREF($t,$prefix,$params,$index_file));
}
function Link($params)
{
if (isset($params['template'])) {
$params['t'] = $params['template'];
unset($params['template']);
}
- if (!isset($params['pass'])) $params['pass'] = 'm';
+ if (!isset($params['pass']) && !isset($params['no_pass'])) $params['pass'] = 'm';
+ if (isset($params['no_pass'])) unset($params['no_pass']);
return $this->T($params);
}
function Env($params)
{
$t = $params['template'];
unset($params['template']);
return $this->Application->BuildEnv($t, $params, 'm', null, false);
}
function FormAction($params)
{
return $this->Application->ProcessParsedTag('m', 't', Array( 'pass'=>'all,m' ) );
}
/*// NEEDS TEST
function Config($params)
{
return $this->Application->ConfigOption($params['var']);
}
function Object($params)
{
$name = $params['name'];
$method = $params['method'];
$tmp =& $this->Application->recallObject($name);
if ($tmp != null) {
if (method_exists($tmp, $method))
return $tmp->$method($params);
else
echo "Method $method does not exist in object ".get_class($tmp)." named $name<br>";
}
else
echo "Object $name does not exist in the appliaction<br>";
}*/
/**
* Tag, that always returns true.
* For parser testing purposes
*
* @param Array $params
* @return bool
* @access public
*/
function True($params)
{
return true;
}
/**
* Tag, that always returns false.
* For parser testing purposes
*
* @param Array $params
* @return bool
* @access public
*/
function False($params)
{
return false;
}
/**
* Returns block parameter by name
*
* @param Array $params
* @return stirng
* @access public
*/
function Param($params)
{
//$parser =& $this->Application->recallObject('TemplateParser');
$res = $this->Application->Parser->GetParam($params['name']);
if ($res === false) $res = '';
if (isset($params['plus']))
$res += $params['plus'];
return $res;
}
/**
* Compares block parameter with value specified
*
* @param Array $params
* @return bool
* @access public
*/
function ParamEquals($params)
{
//$parser =& $this->Application->recallObject('TemplateParser');
$name = $this->SelectParam($params, 'name,var,param');
$value = $params['value'];
return ($this->Application->Parser->GetParam($name) == $value);
}
/*function PHP_Self($params)
{
return $HTTP_SERVER_VARS['PHP_SELF'];
}
*/
/**
* Returns session variable value by name
*
* @param Array $params
* @return string
* @access public
*/
function Recall($params)
{
$ret = $this->Application->RecallVar( $this->SelectParam($params,'name,var,param') );
$ret = ($ret === false && isset($params['no_null'])) ? '' : $ret;
if( getArrayValue($params,'special') || getArrayValue($params,'htmlchars')) $ret = htmlspecialchars($ret);
return $ret;
}
// bad style to store something from template to session !!! (by Alex)
// Used here only to test how session works, nothing more
function Store($params)
{
//echo"Store $params[name]<br>";
$name = $params['name'];
$value = $params['value'];
$this->Application->StoreVar($name,$value);
}
/**
* Sets application variable value(-s)
*
* @param Array $params
* @access public
*/
function Set($params)
{
foreach ($params as $param => $value) {
$this->Application->SetVar($param, $value);
}
}
/**
* Increment application variable
* specified by number specified
*
* @param Array $params
* @access public
*/
function Inc($params)
{
$this->Application->SetVar($params['param'], $this->Application->GetVar($params['param']) + $params['by']);
}
/**
* Retrieves application variable
* value by name
*
* @param Array $params
* @return string
* @access public
*/
function Get($params)
{
$ret = $this->Application->GetVar($this->SelectParam($params, 'name,var,param'), EMPTY_ON_NULL);
return getArrayValue($params, 'htmlchars') ? htmlspecialchars($ret) : $ret;
}
/**
* Retrieves application constant
* value by name
*
* @param Array $params
* @return string
* @access public
*/
function GetConst($params)
{
return defined($this->SelectParam($params, 'name,const')) ? constant($this->SelectParam($params, 'name,const,param')) : '';
}
/*function Config_Equals($params)
{
foreach ($params as $name => $val) {
if (in_array($name, Array( 'prefix', 'function'))) continue;
return $this->Application->ConfigOption($name) == $val;
}
return false;
}*/
/**
* Creates all hidden fields
* needed for kernel_form
*
* @param Array $params
* @return string
* @access public
*/
function DumpSystemInfo($params)
{
$actions =& $this->Application->recallObject('kActions');
$actions->Set('t', $this->Application->GetVar('t') );
$params = $actions->GetParams();
$o='';
foreach ($params AS $name => $val)
{
$o .= "<input type='hidden' name='$name' id='$name' value='$val'>\n";
}
return $o;
}
function GetFormHiddens($params)
{
$sid = $this->Application->GetSID();
$t = $this->SelectParam($params, 'template,t');
unset($params['template']);
$env = $this->Application->BuildEnv($t, $params, 'm', null, false);
$o = '';
if (defined('MOD_REWRITE') && MOD_REWRITE) {
$session =& $this->Application->recallObject('Session');
if ($session->NeedQueryString()) {
$o .= "<input type='hidden' name='sid' id='sid' value='$sid'>\n";
}
}
else {
$o .= "<input type='hidden' name='env' id='env' value='$env'>\n";
}
return $o;
}
function Odd_Even($params)
{
$odd = $params['odd'];
$even = $params['even'];
if (!isset($params['var'])) {
$var = 'odd_even';
}
else {
$var = $params['var'];
}
if ($this->Application->GetVar($var) == 'even') {
$this->Application->SetVar($var, 'odd');
return $even;
}
else {
$this->Application->SetVar($var, 'even');
return $odd;
}
}
/**
* Returns phrase translation by name
*
* @param Array $params
* @return string
* @access public
*/
function Phrase($params)
{
// m:phrase name="phrase_name" default="Tr-alala" updated="2004-01-29 12:49"
if (array_key_exists('default', $params)) return $params['default']; //backward compatibility
return $this->Application->Phrase($this->SelectParam($params, 'label,name,title'));
}
// for tabs
function is_active($params)
{
$test_templ = $this->SelectParam($params, 'templ,template,t');
if ( !getArrayValue($params,'allow_empty') )
{
$if_true=getArrayValue($params,'true') ? $params['true'] : 1;
$if_false=getArrayValue($params,'false') ? $params['false'] : 0;
}
else
{
$if_true=$params['true'];
$if_false=$params['false'];
}
if ( preg_match("/^".str_replace('/', '\/', $test_templ)."/", $this->Application->GetVar('t'))) {
return $if_true;
}
else {
return $if_false;
}
}
function IsNotActive($params)
{
return !$this->is_active($params);
}
function IsActive($params)
{
return $this->is_active($params);
}
function is_t_active($params)
{
return $this->is_active($params);
}
function CurrentTemplate($params)
{
return $this->is_active($params);
}
/**
* Checks if session variable
* specified by name value match
* value passed as parameter
*
* @param Array $params
* @return string
* @access public
*/
function RecallEquals($params)
{
$name = $params['var'];
$value = $params['value'];
return ($this->Application->RecallVar($name) == $value);
}
/**
* Checks if application variable
* specified by name value match
* value passed as parameter
*
* @param Array $params
* @return bool
* @access public
*/
function GetEquals($params)
{
$name = $this->SelectParam($params, 'var,name,param');
$value = $params['value'];
if ($this->Application->GetVar($name) == $value) {
return 1;
}
}
/**
* Includes template
* and returns it's
* parsed version
*
* @param Array $params
* @return string
* @access public
*/
function MyInclude($params)
{
$BlockParser =& $this->Application->makeClass('TemplateParser');
$BlockParser->SetParams($params);
$parser =& $this->Application->Parser;
$this->Application->Parser =& $BlockParser;
$t = $this->SelectParam($params, 't,template,block,name');
$t = eregi_replace("\.tpl$", '', $t);
$templates_cache =& $this->Application->recallObject('TemplatesCache');
$res = $BlockParser->Parse( $templates_cache->GetTemplateBody($t), $t );
if ( !$BlockParser->DataExists && (isset($params['data_exists']) || isset($params['block_no_data'])) ) {
if ($block_no_data = getArrayValue($params, 'block_no_data')) {
$res = $BlockParser->Parse(
$templates_cache->GetTemplateBody($block_no_data, $silent),
$t
);
}
else {
$res = '';
}
}
$this->Application->Parser =& $parser;
$this->Application->Parser->DataExists = $this->Application->Parser->DataExists || $BlockParser->DataExists;
return $res;
}
/*function Kernel_Scripts($params)
{
return '<script type="text/javascript" src="'.PROTOCOL.SERVER_NAME.BASE_PATH.'/kernel3/js/grid.js"></script>';
}*/
/*function GetUserPermission($params)
{
// echo"GetUserPermission $params[name]";
if ($this->Application->RecallVar('user_type') == 1)
return 1;
else {
$perm_name = $params[name];
$aPermissions = unserialize($this->Application->RecallVar('user_permissions'));
if ($aPermissions)
return $aPermissions[$perm_name];
}
}*/
/**
* Set's parser block param value
*
* @param Array $params
* @access public
*/
function AddParam($params)
{
$parser =& $this->Application->Parser; // recallObject('TemplateParser');
foreach ($params as $param => $value) {
$this->Application->SetVar($param, $value);
$parser->SetParam($param, $value);
$parser->AddParam('/\$'.$param.'/', $value);
}
}
/*function ParseToVar($params)
{
$var = $params['var'];
$tagdata = $params['tag'];
$parser =& $this->Application->Parser; //recallObject('TemplateParser');
$res = $this->Application->ProcessTag($tagdata);
$parser->SetParam($var, $res);
$parser->AddParam('/\$'.$var.'/', $res);
return '';
}*/
/*function TagNotEmpty($params)
{
$tagdata = $params['tag'];
$res = $this->Application->ProcessTag($tagdata);
return $res != '';
}*/
/*function TagEmpty($params)
{
return !$this->TagNotEmpty($params);
}*/
/**
* Parses block and returns result
*
* @param Array $params
* @return string
* @access public
*/
function ParseBlock($params)
{
$parser =& $this->Application->Parser; // recallObject('TemplateParser');
return $parser->ParseBlock($params);
}
/**
* Checks if debug mode is on
*
* @return bool
* @access public
*/
function IsDebugMode()
{
return $this->Application->isDebugMode();
}
function MassParse($params)
{
$qty = $params['qty'];
$block = $params['block'];
$mode = $params['mode'];
$o = '';
if ($mode == 'func') {
$func = create_function('$params', '
$o = \'<tr>\';
$o.= \'<td>a\'.$params[\'param1\'].\'</td>\';
$o.= \'<td>a\'.$params[\'param2\'].\'</td>\';
$o.= \'<td>a\'.$params[\'param3\'].\'</td>\';
$o.= \'<td>a\'.$params[\'param4\'].\'</td>\';
$o.= \'</tr>\';
return $o;
');
for ($i=1; $i<$qty; $i++) {
$block_params['param1'] = rand(1, 10000);
$block_params['param2'] = rand(1, 10000);
$block_params['param3'] = rand(1, 10000);
$block_params['param4'] = rand(1, 10000);
$o .= $func($block_params);
}
return $o;
}
$block_params['name'] = $block;
for ($i=0; $i<$qty; $i++) {
$block_params['param1'] = rand(1, 10000);
$block_params['param2'] = rand(1, 10000);
$block_params['param3'] = rand(1, 10000);
$block_params['param4'] = rand(1, 10000);
$block_params['passed'] = $params['passed'];
$block_params['prefix'] = 'm';
$o.= $this->Application->ParseBlock($block_params, 1);
}
return $o;
}
function AfterScript($params)
{
$after_script = $this->Application->GetVar('after_script');
if ( $after_script ) {
return '<script type="text/javascript">'.$after_script.'</script>';
}
return '';
}
function LoggedIn($params)
{
return $this->Application->LoggedIn();
}
/**
* Checks if user is logged in and if not redirects it to template passed
*
* @param Array $params
*/
function RequireLogin($params)
{
if($permission_groups = getArrayValue($params, 'permissions'))
{
$permission_groups = explode('|', $permission_groups);
$group_has_permission = false;
foreach($permission_groups as $permission_group)
{
$permissions = explode(',', $permission_group);
$has_permission = true;
foreach($permissions as $permission)
{
$has_permission = $has_permission && $this->Application->CheckPermission($permission);
}
$group_has_permission = $group_has_permission || $has_permission;
if($group_has_permission)
{
return;
}
}
if( !$this->Application->LoggedIn() )
{
$t = $this->Application->GetVar('t');
$this->Application->Redirect( $params['login_template'], Array('next_template'=>$t) );
}
else
{
$this->Application->Redirect( $params['no_permissions_template'] );
}
}
$condition = getArrayValue($params,'condition');
if(!$condition)
{
$condition = true;
}
else
{
if( substr($condition,0,1) == '!' )
{
$condition = !$this->Application->ConfigValue( substr($condition,1) );
}
else
{
$condition = $this->Application->ConfigValue($condition);
}
}
if( !$this->Application->LoggedIn() && $condition )
{
$t = $this->Application->GetVar('t');
$this->Application->Redirect( $params['login_template'], Array('next_template'=>$t) );
}
}
function SaveReturnScript($params)
{
// admin/save_redirect.php?do=
$url = str_replace($this->Application->BaseURL(), '', $this->T($params) );
$url = explode('?', $url, 2);
$url = 'save_redirect.php?'.$url[1].'&do='.$url[0];
$this->Application->StoreVar('ReturnScript', $url);
}
/*
function Login($params)
{
$user_prefix = 'users';
$this->parser->registerprefix($user_prefix);
$user_class = $this->parser->processors[$user_prefix]->item_class;
$candidate = new $user_class(NULL, $this->parser->processors[$user_prefix]);
//print_pre($this->Session->Property);
$special = array_shift($params);
//echo"$special<br>";
$candidate_id = $candidate->Login($this->Session->GetProperty('username'), $this->Session->GetProperty('password'), $special);
if ($candidate_id !== false) {
$this->Session->SetField('user_id', $candidate_id);
$this->Session->Update();
$this->Session->AfterLogin();
$this->parser->register_prefix('m');
$template = array_shift($params);
if ($template == '') $template = 'index';
$location = $this->parser->do_process_tag('m', 't', Array($template));
header("Location: $location");
exit;
}
elseif ($this->Session->GetProperty('username') != '') {
$this->Session->SetProperty('login_error', 'Incorrect username or password');
}
}
*/
}
?>
\ No newline at end of file
Property changes on: trunk/core/kernel/processors/main_processor.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.7
\ No newline at end of property
+1.8
\ No newline at end of property
Index: trunk/core/units/general/cat_event_handler.php
===================================================================
--- trunk/core/units/general/cat_event_handler.php (revision 1582)
+++ trunk/core/units/general/cat_event_handler.php (revision 1583)
@@ -1,146 +1,146 @@
<?php
$application =& kApplication::Instance();
$application->Factory->includeClassFile('kDBEventHandler');
class kCatDBEventHandler extends InpDBEventHandler {
function OnCopy(&$event)
{
$object = $event->getObject();
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard', implode(',', $ids));
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard_mode', 'copy');
- $this->Application->StoreVar('clipboard', 'COPY-0.'.TABLE_PREFIX.'Products.ResourceId=0');
+ $this->Application->StoreVar('clipboard', 'COPY-0.'.$object->TableName.'.ResourceId=0');
$event->redirect_params = Array('opener' => 's', 'pass_events'=>true); //do not go up - STAY
}
function OnCut(&$event)
{
$object = $event->getObject();
$this->StoreSelectedIDs($event);
$ids = $this->getSelectedIDs($event);
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard', implode(',', $ids));
$this->Application->StoreVar($event->getPrefixSpecial().'_clipboard_mode', 'cut');
- $this->Application->StoreVar('clipboard', 'CUT-0.'.TABLE_PREFIX.'Products.ResourceId=0');
+ $this->Application->StoreVar('clipboard', 'CUT-0.'.$object->TableName.'.ResourceId=0');
$event->redirect_params = Array('opener' => 's', 'pass_events'=>true); //do not go up - STAY
}
function OnPaste(&$event)
{
$ids = $this->Application->RecallVar($event->getPrefixSpecial().'_clipboard');
if ($ids == '') {
$event->redirect = false;
return;
}
//recalling by different name, because we may get kDBList, if we recall just by prefix
$object =& $this->Application->recallObject($event->getPrefixSpecial().'.item', $event->Prefix);
$this->prepareObject($object,$event);
if ($this->Application->RecallVar($event->getPrefixSpecial().'_clipboard_mode') == 'copy') {
$ids_arr = explode(',', $ids);
$temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
if($ids_arr)
{
$temp->CloneItems($event->Prefix, $event->Special, $ids_arr);
}
}
else { // mode == cut
$ids_arr = explode(',', $ids);
foreach ($ids_arr as $id) {
$object->Load($id);
$object->MoveToCat();
}
}
$event->status = erSUCCESS;
}
/**
* Apply scope clause
*
* @param kEvent $event
*/
function SetCustomQuery(&$event)
{
$object =& $event->getObject();
if ($event->Special != 'showall') {
if ( $event->getEventParam('parent_cat_id') ) {
$parent_cat_id = $event->getEventParam('parent_cat_id');
}
else {
$parent_cat_id = $this->Application->GetVar('c_id');
if (!$parent_cat_id) {
$parent_cat_id = $this->Application->GetVar('m_cat_id');
}
if (!$parent_cat_id) {
$parent_cat_id = 0;
}
}
if ((string) $parent_cat_id != 'any') {
if ($event->getEventParam('recursive')) {
$current_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$parent_cat_id);
$subcats = $this->Conn->GetCol('SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE ParentPath LIKE "'.$current_path.'%" ');
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.CategoryId IN ('.implode(', ', $subcats).')');
}
else {
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.CategoryId = '.$parent_cat_id );
}
}
}
else {
$object->addFilter('primary_filter', 'PrimaryCat = 1');
}
$view_perm = 1;
$object->addFilter('perm_filter', 'perm.PermId = '.$view_perm);
if (!defined('ADMIN')) {
$groups = explode(',',$this->Application->RecallVar('UserGroups'));
foreach ($groups as $group) {
$view_filters[] = 'FIND_IN_SET('.$group.', perm.acl) || ((NOT FIND_IN_SET('.$group.',perm.dacl)) AND perm.acl=\'\')';
}
$view_filter = implode(' OR ', $view_filters);
$object->addFilter('perm_filter2', $view_filter);
}
if (!defined('ADMIN')) {
$object->addFilter('status_filter', $object->TableName.'.Status = 1');
}
/*$list_type = $event->getEventParam('ListType');
switch($list_type)
{
case 'favorites':
$fav_table = $this->Application->getUnitOption('fav','TableName');
$user_id =& $this->Application->GetVar('u_id');
$sql = 'SELECT DISTINCT f.ResourceId
FROM '.$fav_table.' f
LEFT JOIN '.$object->TableName.' p ON p.ResourceId = f.ResourceId
WHERE f.PortalUserId = '.$user_id;
$ids = $this->Conn->GetCol($sql);
if(!$ids) $ids = Array(-1);
$object->addFilter('category_filter', TABLE_PREFIX.'CategoryItems.PrimaryCat = 1');
$object->addFilter('favorites_filter', '%1$s.`ResourceId` IN ('.implode(',',$ids).')');
break;
case 'search':
$search_results_table = TABLE_PREFIX.'ses_'.$this->Application->GetVar('sid').'_'.TABLE_PREFIX.'Search';
$sql = ' SELECT DISTINCT ResourceId
FROM '.$search_results_table.'
WHERE ItemType=11';
$ids = $this->Conn->GetCol($sql);
if(!$ids) $ids = Array(-1);
$object->addFilter('search_filter', '%1$s.`ResourceId` IN ('.implode(',',$ids).')');
break;
} */
}
}
?>
\ No newline at end of file
Property changes on: trunk/core/units/general/cat_event_handler.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Index: trunk/core/units/general/my_application.php
===================================================================
--- trunk/core/units/general/my_application.php (revision 1582)
+++ trunk/core/units/general/my_application.php (revision 1583)
@@ -1,46 +1,46 @@
-<?php
-
- k4_include_once(MODULES_PATH.'/kernel/units/general/inp_db_event_handler.php');
-
- class MyApplication extends kApplication {
-
- function RegisterDefaultClasses()
- {
- parent::RegisterDefaultClasses();
-
- $this->registerClass('Inp1Parser',MODULES_PATH.'/kernel/units/general/inp1_parser.php','Inp1Parser');
-
- $this->registerClass('InpSession',MODULES_PATH.'/kernel/units/general/inp_ses_storage.php','Session');
- $this->registerClass('InpSessionStorage',MODULES_PATH.'/kernel/units/general/inp_ses_storage.php','SessionStorage');
-
- $this->registerClass('kCatDBItem',MODULES_PATH.'/kernel/units/general/cat_dbitem.php');
- $this->registerClass('kCatDBList',MODULES_PATH.'/kernel/units/general/cat_dblist.php');
- $this->registerClass('kCatDBEventHandler',MODULES_PATH.'/kernel/units/general/cat_event_handler.php');
- $this->registerClass('InpLoginEventHandler',MODULES_PATH.'/kernel/units/general/inp_login_event_handler.php','login_EventHandler');
- $this->registerClass('InpDBEventHandler',MODULES_PATH.'/kernel/units/general/inp_db_event_handler.php','kDBEventHandler');
- $this->registerClass('InpTempTablesHandler',MODULES_PATH.'/kernel/units/general/inp_temp_handler.php','kTempTablesHandler');
- $this->registerClass('InpUnitConfigReader',MODULES_PATH.'/kernel/units/general/inp_unit_config_reader.php','kUnitConfigReader');
-
- $this->registerClass('InpCustomFieldsHelper',MODULES_PATH.'/kernel/units/general/custom_fields.php','InpCustomFieldsHelper');
- $this->registerClass('kCountryStatesHelper',MODULES_PATH.'/kernel/units/general/country_states.php','CountryStatesHelper');
- }
-
- /**
- * Checks if user is logged in, and creates
- * user object if so. User object can be recalled
- * later using "u" prefix. Also you may
- * get user id by getting "u_id" variable.
- *
- * @access private
- */
- function ValidateLogin()
- {
- $session =& $this->recallObject('Session');
- $user_id = $session->GetField('PortalUserId');
- if (!$user_id) $user_id = -2;
- $this->SetVar('u_id', $user_id);
- $this->StoreVar('user_id', $user_id);
- }
- }
-
+<?php
+
+ k4_include_once(MODULES_PATH.'/kernel/units/general/inp_db_event_handler.php');
+
+ class MyApplication extends kApplication {
+
+ function RegisterDefaultClasses()
+ {
+ parent::RegisterDefaultClasses();
+
+ $this->registerClass('Inp1Parser',MODULES_PATH.'/kernel/units/general/inp1_parser.php','Inp1Parser');
+
+ $this->registerClass('InpSession',MODULES_PATH.'/kernel/units/general/inp_ses_storage.php','Session');
+ $this->registerClass('InpSessionStorage',MODULES_PATH.'/kernel/units/general/inp_ses_storage.php','SessionStorage');
+
+ $this->registerClass('kCatDBItem',MODULES_PATH.'/kernel/units/general/cat_dbitem.php');
+ $this->registerClass('kCatDBList',MODULES_PATH.'/kernel/units/general/cat_dblist.php');
+ $this->registerClass('kCatDBEventHandler',MODULES_PATH.'/kernel/units/general/cat_event_handler.php');
+ $this->registerClass('InpLoginEventHandler',MODULES_PATH.'/kernel/units/general/inp_login_event_handler.php','login_EventHandler');
+ $this->registerClass('InpDBEventHandler',MODULES_PATH.'/kernel/units/general/inp_db_event_handler.php','kDBEventHandler');
+ $this->registerClass('InpTempTablesHandler',MODULES_PATH.'/kernel/units/general/inp_temp_handler.php','kTempTablesHandler');
+ $this->registerClass('InpUnitConfigReader',MODULES_PATH.'/kernel/units/general/inp_unit_config_reader.php','kUnitConfigReader');
+
+ $this->registerClass('InpCustomFieldsHelper',MODULES_PATH.'/kernel/units/general/custom_fields.php','InpCustomFieldsHelper');
+ $this->registerClass('kCountryStatesHelper',MODULES_PATH.'/kernel/units/general/country_states.php','CountryStatesHelper');
+ }
+
+ /**
+ * Checks if user is logged in, and creates
+ * user object if so. User object can be recalled
+ * later using "u" prefix. Also you may
+ * get user id by getting "u_id" variable.
+ *
+ * @access private
+ */
+ function ValidateLogin()
+ {
+ $session =& $this->recallObject('Session');
+ $user_id = $session->GetField('PortalUserId');
+ if (!$user_id) $user_id = -2;
+ $this->SetVar('u_id', $user_id);
+ $this->StoreVar('user_id', $user_id);
+ }
+ }
+
?>
\ No newline at end of file
Property changes on: trunk/core/units/general/my_application.php
___________________________________________________________________
Modified: cvs2svn:cvs-rev
## -1 +1 ##
-1.4
\ No newline at end of property
+1.5
\ No newline at end of property
Event Timeline
Log In to Comment