Index: branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php =================================================================== diff -u -r6031 -r6078 --- branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 6031) +++ branches/unlabeled/unlabeled-1.64.2/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 6078) @@ -328,20 +328,20 @@ FROM '.TABLE_PREFIX.'PermissionConfig WHERE PermissionName = "'.$this->Application->getUnitOption($event->Prefix, 'PermItemPrefix').'.VIEW"'; $view_perm = $this->Conn->GetOne($sql); - } - $object->addFilter('perm_filter', 'perm.PermId = '.$view_perm); - - if ( !$this->Application->IsAdmin() ) - { $groups = explode( ',', $this->Application->RecallVar('UserGroups') ); foreach($groups as $group) { $view_filters[] = 'FIND_IN_SET('.$group.', perm.acl)'; } $view_filter = implode(' OR ', $view_filters); $object->addFilter('perm_filter2', $view_filter); + } + $object->addFilter('perm_filter', 'perm.PermId = '.$view_perm); + + if ( !$this->Application->IsAdmin() ) + { $object->addFilter('status_filter', $object->TableName.'.Status = 1'); if ($this->Application->getUnitOption($event->Prefix, 'UsePendingEditing')) { // if category item uses pending editing abilities, then in no cases show pending copies on front Index: branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php =================================================================== diff -u -r6026 -r6078 --- branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6026) +++ branches/unlabeled/unlabeled-1.22.2/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6078) @@ -114,7 +114,7 @@ } $object->addFilter('perm_filter', 'PermId = 1'); // check for CATEGORY.VIEW permission - if ($this->Application->GetVar('u_id') > 0) { + if ($this->Application->GetVar('u_id') != -1) { // apply permission filters to all users except "root" $groups = explode(',',$this->Application->RecallVar('UserGroups')); foreach ($groups as $group) { Index: branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php =================================================================== diff -u -r6031 -r6078 --- branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 6031) +++ branches/unlabeled/unlabeled-1.64.2/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 6078) @@ -328,20 +328,20 @@ FROM '.TABLE_PREFIX.'PermissionConfig WHERE PermissionName = "'.$this->Application->getUnitOption($event->Prefix, 'PermItemPrefix').'.VIEW"'; $view_perm = $this->Conn->GetOne($sql); - } - $object->addFilter('perm_filter', 'perm.PermId = '.$view_perm); - - if ( !$this->Application->IsAdmin() ) - { $groups = explode( ',', $this->Application->RecallVar('UserGroups') ); foreach($groups as $group) { $view_filters[] = 'FIND_IN_SET('.$group.', perm.acl)'; } $view_filter = implode(' OR ', $view_filters); $object->addFilter('perm_filter2', $view_filter); + } + $object->addFilter('perm_filter', 'perm.PermId = '.$view_perm); + + if ( !$this->Application->IsAdmin() ) + { $object->addFilter('status_filter', $object->TableName.'.Status = 1'); if ($this->Application->getUnitOption($event->Prefix, 'UsePendingEditing')) { // if category item uses pending editing abilities, then in no cases show pending copies on front Index: branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php =================================================================== diff -u -r6026 -r6078 --- branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php (.../application.php) (revision 6026) +++ branches/unlabeled/unlabeled-1.155.2/core/kernel/application.php (.../application.php) (revision 6078) @@ -1367,7 +1367,9 @@ // to put category & item templates into cache $filename = $this->getFilename('c', $category_id); if ($item_id) { - $t = $this->getCache('item_templates', $category_id); + $mod_rw_helper =& $this->Application->recallObject('ModRewriteHelper'); + $t = $mod_rw_helper->GetItemTemplate($category_id, $pass_element); // $pass_element should be the last processed element +// $t = $this->getCache('item_templates', $category_id); } elseif ($category_id) { $t = $this->getCache('category_templates', $category_id); Index: branches/unlabeled/unlabeled-1.6.2/kernel/units/permissions/permissions_event_handler.php =================================================================== diff -u -r5619 -r6078 --- branches/unlabeled/unlabeled-1.6.2/kernel/units/permissions/permissions_event_handler.php (.../permissions_event_handler.php) (revision 5619) +++ branches/unlabeled/unlabeled-1.6.2/kernel/units/permissions/permissions_event_handler.php (.../permissions_event_handler.php) (revision 6078) @@ -14,7 +14,7 @@ ); $this->permMapping = array_merge($this->permMapping, $permissions); } - + /** * Save category permissions * @@ -27,31 +27,31 @@ $permissions = $this->Application->GetVar($event->getPrefixSpecial(true)); if (isset($permissions[$group_id])) { $permissions = $permissions[$group_id]; - + $object =& $event->getObject( Array('skip_autoload' => true) ); $permissions_helper =& $this->Application->recallObject('PermissionsHelper'); - $permissions_helper->LoadPermissions($group_id, $category_id, 0, true); - + $permissions_helper->LoadPermissions($group_id, $category_id, 0); + // format: ['inherited'] || ['value'] - + $delete_ids = Array(); $create_sql = Array(); $update_sql = Array(); $create_mask = '(%s,%s,'.$group_id.',%s,0,'.$category_id.')'; $new_id = (int)$this->Conn->GetOne('SELECT MIN('.$object->IDField.') FROM '.$object->TableName); if($new_id > 0) $new_id = 0; --$new_id; - + foreach ($permissions as $perm_name => $perm_data) { $inherited = $perm_data['inherited']; $perm_value = isset($perm_data['value']) ? $perm_data['value'] : false; $perm_id = $permissions_helper->getPermissionID($perm_name); - + if ($inherited && ($perm_id != 0)) { // permission become inherited (+ direct value was set before) => DELETE $delete_ids[] = $permissions_helper->getPermissionID($perm_name); } - + if (!$inherited) { // not inherited if (($perm_id != 0) && ($perm_value != $permissions_helper->getPermissionValue($perm_name))) { @@ -60,22 +60,22 @@ SET PermissionValue = '.$perm_value.' WHERE (PermissionId = '.$perm_id.')'; } - + if ($perm_id == 0) { // not found in db, but set directly => INSERT $create_sql[] = sprintf($create_mask, $new_id--, $this->Conn->qstr($perm_name), $this->Conn->qstr($perm_value)); } } // permission state was not changed in all other cases } - + $this->UpdatePermissions($event, $create_sql, $update_sql, $delete_ids); } - + $event->MasterEvent->SetRedirectParam('item_prefix', $this->Application->GetVar('item_prefix')); $event->MasterEvent->SetRedirectParam('group_id', $this->Application->GetVar('group_id')); } - + /** * Saves permissions while editing group * @@ -87,7 +87,7 @@ // no permission to save permissions return false; } - + $permissions = $this->Application->GetVar($event->getPrefixSpecial(true)); if (!$permissions) { return false; @@ -108,11 +108,11 @@ foreach ($permissions as $section_name => $section_permissions) { foreach ($section_permissions as $perm_name => $perm_value) { - + if (!$permissions_helper->isOldPermission($section_name, $perm_name)) { $perm_name = $section_name.'.'.$perm_name; } - + $db_perm_value = $permissions_helper->getPermissionValue($perm_name); if ($db_perm_value == 1 && $perm_value == 0) { // permission was disabled => delete it's record @@ -127,7 +127,7 @@ } $this->UpdatePermissions($event, $create_sql, Array(), $delete_ids); - + if ($this->Application->GetVar('advanced_save') == 1) { // advanced permission popup [save button] $this->finalizePopup($event); @@ -139,7 +139,7 @@ } } - + /** * Apply modification sqls to permissions table * @@ -151,7 +151,7 @@ function UpdatePermissions(&$event, $create_sql, $update_sql, $delete_ids) { $object =& $event->getObject(); - + if ($delete_ids) { $delete_sql = ' DELETE FROM '.$object->TableName.' WHERE '.$object->IDField.' IN ('.implode(',', $delete_ids).')'; @@ -163,7 +163,7 @@ VALUES '.implode(',', $create_sql); $this->Conn->Query($create_sql); } - + if ($update_sql) { foreach ($update_sql as $sql) { $this->Conn->Query($sql); @@ -172,13 +172,13 @@ if ($delete_ids || $create_sql || $update_sql) { $object->setModifiedFlag(); - + if ($event->Name == 'OnCategorySavePermissions') { $this->Application->StoreVar('PermCache_UpdateRequired', 1); } } } - + /** * Don't delete permissions from live table in case of new category creation. * Called as much times as permission count for categories set, so don't @@ -191,7 +191,7 @@ if ($event->Prefix == 'c-perm') { // only when saving category permissions, not group permissions $foreign_keys = $event->getEventParam('foreign_key'); - + if ((count($foreign_keys) == 1) && ($foreign_keys[0] == 0)) { // parent item has zero id $temp_object =& $this->Application->recallObject('c'); Index: branches/unlabeled/unlabeled-1.11.2/kernel/units/general/cat_tag_processor.php =================================================================== diff -u -r5869 -r6078 --- branches/unlabeled/unlabeled-1.11.2/kernel/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 5869) +++ branches/unlabeled/unlabeled-1.11.2/kernel/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 6078) @@ -8,13 +8,13 @@ * @var kPermissionsHelper */ var $PermHelper = null; - + function kCatDBTagProcessor() { parent::kDBTagProcessor(); $this->PermHelper = $this->Application->recallObject('PermissionsHelper'); } - + function ItemIcon($params) { $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); @@ -122,7 +122,7 @@ { if ($this->Special == 'import') { $this->Application->StoreVar('PermCache_UpdateRequired', 1); - $this->Application->Redirect('categories/cache_updater', Array('pass' => 'm', 'continue' => 1, 'no_amp' => 1)); + $this->Application->Redirect('categories/cache_updater', Array('m_opener' => 'r', 'pass' => 'm', 'continue' => 1, 'no_amp' => 1)); } elseif ($this->Special == 'export') { $template = $this->Application->getUnitOption($this->Prefix, 'ModuleFolder').'/'.$this->Special.'_finish'; @@ -161,23 +161,23 @@ $tab_params['mode'] = $this->Application->GetVar('tm'); // single/multi selection possible $tab_params['special'] = $this->Application->GetVar('ts'); // use special for this tab $tab_params['dependant'] = $this->Application->GetVar('td'); // is grid dependant on categories grid - + // set default params (same as in catalog) if ($tab_params['mode'] === false) $tab_params['mode'] = 'multi'; if ($tab_params['special'] === false) $tab_params['special'] = ''; if ($tab_params['dependant'] === false) $tab_params['dependant'] = 'yes'; - + // pass params to block with tab content $params['name'] = $params['render_as']; $params['prefix'] = trim($this->Prefix.'.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.'); $params['cat_prefix'] = trim('c.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.'); $params['tab_mode'] = $tab_params['mode']; $params['tab_dependant'] = $tab_params['dependant']; $params['show_category'] = $tab_params['special'] == 'showall' ? 1 : 0; // this is advanced view -> show category name - + return $this->Application->ParseBlock($params, 1); } - + /** * Show CachedNavbar of current item primary category * @@ -186,10 +186,10 @@ */ function CategoryName($params) { - // show category cachednavbar of + // show category cachednavbar of $object =& $this->getObject($params); $category_id = isset($params['cat_id']) ? $params['cat_id'] : $object->GetDBField('CategoryId'); - + $category_path = $this->Application->getCache('category_paths', $category_id); if ($category_path === false) { // not chached @@ -203,7 +203,7 @@ } return $category_path; } - + /** * Allows to determine if original value should be shown * @@ -214,10 +214,10 @@ { // original id found & greather then zero + show original $display_original = isset($params['display_original']) && $params['display_original']; - + $object =& $this->getObject($params); $perm_value = $this->PermHelper->ModifyCheckPermission($object->GetDBField('CreatedById'), $object->GetDBField('CategoryId'), $this->Prefix); - + return $display_original && ($perm_value == 1) && $this->Application->GetVar($this->Prefix.'.original_id'); } Index: branches/unlabeled/unlabeled-1.10.2/core/kernel/utility/params.php =================================================================== diff -u -r5715 -r6078 --- branches/unlabeled/unlabeled-1.10.2/core/kernel/utility/params.php (.../params.php) (revision 5715) +++ branches/unlabeled/unlabeled-1.10.2/core/kernel/utility/params.php (.../params.php) (revision 6078) @@ -2,13 +2,13 @@ class Params extends kBase { var $_Params = Array(); - + function Params($params_str = null) { parent::kBase(); if($params_str != '') $this->SplitParamsStr($params_str); } - + /** * Splits tag params into associative array * @@ -17,15 +17,17 @@ */ function SplitParamsStr($params_str) { +// $re = preg_quote('([\${}a-zA-Z0-9_.-#\[\]]+)=(["\']{1,1})(.*?)(? $val){ $values[$val[1]] = str_replace('\\' . $val[2], $val[2], $val[3]); } $this->AddParams($values); } - + /** * Sets new parameter value * @@ -37,7 +39,7 @@ { $this->_Params[$name] = $val; } - + /** * Removes parameter * @@ -48,7 +50,7 @@ { unset($this->_Params[$name]); } - + /** * Gets parameter value by parameter name * @@ -61,7 +63,7 @@ { return isset($this->_Params[$name]) ? $this->_Params[$name] : $default; } - + /** * Mass parameter setting from hash * @@ -72,15 +74,15 @@ { if (!is_array($params)) return; /*if (count($this->_Params) == 0) { - $this->_Params = $params; + $this->_Params = $params; } else {*/ foreach ($params as $name => $val) // $this->Set(strtolower($name), $val); $this->Set($name, $val); //} } - + /** * Return all paramters as hash * @@ -95,7 +97,7 @@ class kArray extends kBase { var $_Array; - + /** * Returns array value with any deep key * @@ -111,9 +113,9 @@ function SetArrayValue() { - $args = func_get_args(); + $args = func_get_args(); $value = array_pop($args); - + $arr =& $this->_Array; for ($i=0; $ipermMapping = array_merge($this->permMapping, $permissions); } - + /** * Save category permissions * @@ -27,31 +27,31 @@ $permissions = $this->Application->GetVar($event->getPrefixSpecial(true)); if (isset($permissions[$group_id])) { $permissions = $permissions[$group_id]; - + $object =& $event->getObject( Array('skip_autoload' => true) ); $permissions_helper =& $this->Application->recallObject('PermissionsHelper'); - $permissions_helper->LoadPermissions($group_id, $category_id, 0, true); - + $permissions_helper->LoadPermissions($group_id, $category_id, 0); + // format: ['inherited'] || ['value'] - + $delete_ids = Array(); $create_sql = Array(); $update_sql = Array(); $create_mask = '(%s,%s,'.$group_id.',%s,0,'.$category_id.')'; $new_id = (int)$this->Conn->GetOne('SELECT MIN('.$object->IDField.') FROM '.$object->TableName); if($new_id > 0) $new_id = 0; --$new_id; - + foreach ($permissions as $perm_name => $perm_data) { $inherited = $perm_data['inherited']; $perm_value = isset($perm_data['value']) ? $perm_data['value'] : false; $perm_id = $permissions_helper->getPermissionID($perm_name); - + if ($inherited && ($perm_id != 0)) { // permission become inherited (+ direct value was set before) => DELETE $delete_ids[] = $permissions_helper->getPermissionID($perm_name); } - + if (!$inherited) { // not inherited if (($perm_id != 0) && ($perm_value != $permissions_helper->getPermissionValue($perm_name))) { @@ -60,22 +60,22 @@ SET PermissionValue = '.$perm_value.' WHERE (PermissionId = '.$perm_id.')'; } - + if ($perm_id == 0) { // not found in db, but set directly => INSERT $create_sql[] = sprintf($create_mask, $new_id--, $this->Conn->qstr($perm_name), $this->Conn->qstr($perm_value)); } } // permission state was not changed in all other cases } - + $this->UpdatePermissions($event, $create_sql, $update_sql, $delete_ids); } - + $event->MasterEvent->SetRedirectParam('item_prefix', $this->Application->GetVar('item_prefix')); $event->MasterEvent->SetRedirectParam('group_id', $this->Application->GetVar('group_id')); } - + /** * Saves permissions while editing group * @@ -87,7 +87,7 @@ // no permission to save permissions return false; } - + $permissions = $this->Application->GetVar($event->getPrefixSpecial(true)); if (!$permissions) { return false; @@ -108,11 +108,11 @@ foreach ($permissions as $section_name => $section_permissions) { foreach ($section_permissions as $perm_name => $perm_value) { - + if (!$permissions_helper->isOldPermission($section_name, $perm_name)) { $perm_name = $section_name.'.'.$perm_name; } - + $db_perm_value = $permissions_helper->getPermissionValue($perm_name); if ($db_perm_value == 1 && $perm_value == 0) { // permission was disabled => delete it's record @@ -127,7 +127,7 @@ } $this->UpdatePermissions($event, $create_sql, Array(), $delete_ids); - + if ($this->Application->GetVar('advanced_save') == 1) { // advanced permission popup [save button] $this->finalizePopup($event); @@ -139,7 +139,7 @@ } } - + /** * Apply modification sqls to permissions table * @@ -151,7 +151,7 @@ function UpdatePermissions(&$event, $create_sql, $update_sql, $delete_ids) { $object =& $event->getObject(); - + if ($delete_ids) { $delete_sql = ' DELETE FROM '.$object->TableName.' WHERE '.$object->IDField.' IN ('.implode(',', $delete_ids).')'; @@ -163,7 +163,7 @@ VALUES '.implode(',', $create_sql); $this->Conn->Query($create_sql); } - + if ($update_sql) { foreach ($update_sql as $sql) { $this->Conn->Query($sql); @@ -172,13 +172,13 @@ if ($delete_ids || $create_sql || $update_sql) { $object->setModifiedFlag(); - + if ($event->Name == 'OnCategorySavePermissions') { $this->Application->StoreVar('PermCache_UpdateRequired', 1); } } } - + /** * Don't delete permissions from live table in case of new category creation. * Called as much times as permission count for categories set, so don't @@ -191,7 +191,7 @@ if ($event->Prefix == 'c-perm') { // only when saving category permissions, not group permissions $foreign_keys = $event->getEventParam('foreign_key'); - + if ((count($foreign_keys) == 1) && ($foreign_keys[0] == 0)) { // parent item has zero id $temp_object =& $this->Application->recallObject('c'); Index: branches/unlabeled/unlabeled-1.11.2/core/units/general/cat_tag_processor.php =================================================================== diff -u -r5869 -r6078 --- branches/unlabeled/unlabeled-1.11.2/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 5869) +++ branches/unlabeled/unlabeled-1.11.2/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 6078) @@ -8,13 +8,13 @@ * @var kPermissionsHelper */ var $PermHelper = null; - + function kCatDBTagProcessor() { parent::kDBTagProcessor(); $this->PermHelper = $this->Application->recallObject('PermissionsHelper'); } - + function ItemIcon($params) { $object =& $this->Application->recallObject($this->getPrefixSpecial(),$this->Prefix, $params); @@ -122,7 +122,7 @@ { if ($this->Special == 'import') { $this->Application->StoreVar('PermCache_UpdateRequired', 1); - $this->Application->Redirect('categories/cache_updater', Array('pass' => 'm', 'continue' => 1, 'no_amp' => 1)); + $this->Application->Redirect('categories/cache_updater', Array('m_opener' => 'r', 'pass' => 'm', 'continue' => 1, 'no_amp' => 1)); } elseif ($this->Special == 'export') { $template = $this->Application->getUnitOption($this->Prefix, 'ModuleFolder').'/'.$this->Special.'_finish'; @@ -161,23 +161,23 @@ $tab_params['mode'] = $this->Application->GetVar('tm'); // single/multi selection possible $tab_params['special'] = $this->Application->GetVar('ts'); // use special for this tab $tab_params['dependant'] = $this->Application->GetVar('td'); // is grid dependant on categories grid - + // set default params (same as in catalog) if ($tab_params['mode'] === false) $tab_params['mode'] = 'multi'; if ($tab_params['special'] === false) $tab_params['special'] = ''; if ($tab_params['dependant'] === false) $tab_params['dependant'] = 'yes'; - + // pass params to block with tab content $params['name'] = $params['render_as']; $params['prefix'] = trim($this->Prefix.'.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.'); $params['cat_prefix'] = trim('c.'.($tab_params['special'] ? $tab_params['special'] : $this->Special), '.'); $params['tab_mode'] = $tab_params['mode']; $params['tab_dependant'] = $tab_params['dependant']; $params['show_category'] = $tab_params['special'] == 'showall' ? 1 : 0; // this is advanced view -> show category name - + return $this->Application->ParseBlock($params, 1); } - + /** * Show CachedNavbar of current item primary category * @@ -186,10 +186,10 @@ */ function CategoryName($params) { - // show category cachednavbar of + // show category cachednavbar of $object =& $this->getObject($params); $category_id = isset($params['cat_id']) ? $params['cat_id'] : $object->GetDBField('CategoryId'); - + $category_path = $this->Application->getCache('category_paths', $category_id); if ($category_path === false) { // not chached @@ -203,7 +203,7 @@ } return $category_path; } - + /** * Allows to determine if original value should be shown * @@ -214,10 +214,10 @@ { // original id found & greather then zero + show original $display_original = isset($params['display_original']) && $params['display_original']; - + $object =& $this->getObject($params); $perm_value = $this->PermHelper->ModifyCheckPermission($object->GetDBField('CreatedById'), $object->GetDBField('CategoryId'), $this->Prefix); - + return $display_original && ($perm_value == 1) && $this->Application->GetVar($this->Prefix.'.original_id'); } Index: branches/unlabeled/unlabeled-1.17.2/core/units/general/helpers/permissions_helper.php =================================================================== diff -u -r6026 -r6078 --- branches/unlabeled/unlabeled-1.17.2/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6026) +++ branches/unlabeled/unlabeled-1.17.2/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6078) @@ -9,12 +9,10 @@ */ var $Permissions = Array(); - function LoadPermissions($group_id, $cat_id, $type = 1, $temp_mode = false) + function LoadPermissions($group_id, $cat_id, $type = 1) { $perm_table = $this->Application->getUnitOption('perm', 'TableName'); - if ($temp_mode) { - $perm_table = $this->Application->GetTempName($perm_table); - } + $perm_table = $this->Application->GetTempName($perm_table); $sql = 'SELECT * FROM '.$perm_table.' WHERE (GroupId = '.$group_id.') AND (CatId = '.$cat_id.') AND (Type = '.$type.')'; Index: branches/unlabeled/unlabeled-1.75.2/kernel/frontaction.php =================================================================== diff -u -r6031 -r6078 --- branches/unlabeled/unlabeled-1.75.2/kernel/frontaction.php (.../frontaction.php) (revision 6031) +++ branches/unlabeled/unlabeled-1.75.2/kernel/frontaction.php (.../frontaction.php) (revision 6078) @@ -983,6 +983,7 @@ //echo "Searching for categories
"; $objAdvSearch = new clsAdvancedSearchResults("Category","clsCategory", $_GET["type"]); + foreach($objSearchConfig->Items as $field) { $fld = $field->Get("FieldName"); @@ -1018,10 +1019,12 @@ $Verb = 'contains'; } + + if(strlen($Value) && strlen($Verb)>0 && $Verb!="any") { -// echo "Adding CAT SearchField: [".$field->Get("TableName")."]; [".$field->Get("FieldName")."]; [$Verb]; [$Value]; [$Conjuction]
"; - $objAdvSearch->AddAdvancedField($field->Get("TableName"),$field->Get("FieldName"),$Verb,$Value,$Conjuction, 'c'); + // echo "Adding CAT SearchField: [".$field->Get("TableName")."]; [".$field->Get("FieldName")."]; [$Verb]; [$Value]; [$Conjuction]
"; + $objAdvSearch->AddAdvancedField($field->Get("TableName"),$field->Get("FieldName"),$Verb,$Value,$Conjuction, 'c'); } } Index: branches/unlabeled/unlabeled-1.17.2/kernel/units/general/helpers/permissions_helper.php =================================================================== diff -u -r6026 -r6078 --- branches/unlabeled/unlabeled-1.17.2/kernel/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6026) +++ branches/unlabeled/unlabeled-1.17.2/kernel/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6078) @@ -9,12 +9,10 @@ */ var $Permissions = Array(); - function LoadPermissions($group_id, $cat_id, $type = 1, $temp_mode = false) + function LoadPermissions($group_id, $cat_id, $type = 1) { $perm_table = $this->Application->getUnitOption('perm', 'TableName'); - if ($temp_mode) { - $perm_table = $this->Application->GetTempName($perm_table); - } + $perm_table = $this->Application->GetTempName($perm_table); $sql = 'SELECT * FROM '.$perm_table.' WHERE (GroupId = '.$group_id.') AND (CatId = '.$cat_id.') AND (Type = '.$type.')'; Index: branches/unlabeled/unlabeled-1.8.2/kernel/units/permissions/permissions_tag_processor.php =================================================================== diff -u -r5651 -r6078 --- branches/unlabeled/unlabeled-1.8.2/kernel/units/permissions/permissions_tag_processor.php (.../permissions_tag_processor.php) (revision 5651) +++ branches/unlabeled/unlabeled-1.8.2/kernel/units/permissions/permissions_tag_processor.php (.../permissions_tag_processor.php) (revision 6078) @@ -1,24 +1,24 @@ Application->recallObject('SectionsHelper'); $section_data =& $sections_helper->getSectionData($section_name); - + return array_search($params['perm_name'], $section_data['permissions']) !== false; } - + function HasAdvancedPermissions($params) { $section_name = $params['section_name']; - + $sections_helper =& $this->Application->recallObject('SectionsHelper'); $section_data =& $sections_helper->getSectionData($section_name); - + $ret = false; foreach ($section_data['permissions'] as $perm_name) { if (preg_match('/^advanced:(.*)/', $perm_name)) { @@ -28,43 +28,43 @@ } return $ret; } - + function PermissionValue($params) { $section_name = $params['section_name']; - + $sections_helper =& $this->Application->recallObject('SectionsHelper'); $section_data =& $sections_helper->getSectionData($section_name); $perm_name = $params['perm_name']; - + $permissions_helper =& $this->Application->recallObject('PermissionsHelper'); if (!$permissions_helper->isOldPermission($section_name, $perm_name)) { $perm_name = $section_name.'.'.$perm_name; } - + return $permissions_helper->getPermissionValue($perm_name); } - + function LoadPermissions($params) { $permissions_helper =& $this->Application->recallObject('PermissionsHelper'); $prefix_parts = explode('-', $this->Prefix, 2); $permissions_helper->LoadPermissions($this->Application->GetVar('g_id'), 0, 1); } - + function LevelIndicator($params) { return $params['level'] * $params['multiply']; } - + function PrintPermissions($params) { $category =& $this->Application->recallObject('c'); - + $group_id = $this->Application->GetVar('group_id'); $prefix = $this->Application->GetVar('item_prefix'); $module = $this->Application->findModule('Var', $prefix, 'Name'); - + $perm_live_table = $this->Application->getUnitOption('c-perm', 'TableName'); $perm_temp_table = $this->Application->GetTempName($perm_live_table); @@ -74,13 +74,13 @@ else { $categories = explode('|', substr($category->GetDBField('ParentPath'), 1, -1)); } - + if (count($categories) == 1 || $category->GetID() == 0) { // category located in root category ("Home") => then add it to path virtually array_unshift($categories, 0); } $this_cat = array_pop($categories); - + // get permission name + category position in parent path that has value set for that permission $case = 'MAX(CASE c.CategoryId'; foreach ($categories as $pos => $cat_id) { @@ -95,17 +95,17 @@ CategoryId IN ('.implode(',', $categories).') AND ModuleId = "'.$module.'" AND ( - (p.GroupId = '.$group_id.' AND p.Type = 0) + (p.GroupId = '.$group_id.' AND p.Type = 0) ) GROUP BY Perm'; $perm_positions = $this->Conn->GetCol($sql, 'Perm'); - + $pos_sql = ''; foreach ($perm_positions as $perm_name => $category_pos) { - $pos_sql .= '(#TABLE_PREFIX#.Permission = "'.$perm_name.'" AND #TABLE_PREFIX#.CatId = '.$categories[$category_pos].') OR '; + $pos_sql .= '(#TABLE_PREFIX#.Permission = "'.$perm_name.'" AND #TABLE_PREFIX#.CatId = '.$categories[$category_pos].') OR '; } $pos_sql = $pos_sql ? preg_replace('/(.*) OR $/', '\\1', $pos_sql) : '0'; - + // get all permissions list with iheritence status, inherited category id and permission value $sql = 'SELECT pc.PermissionName, pc.Description, @@ -117,13 +117,13 @@ IF(tmp_p.CatId = '.$category->GetID().', 0, 1) AS Inherited, IF(p.PermissionValue IS NOT NULL, p.PermissionValue, 0) AS InheritedValue FROM '.TABLE_PREFIX.'PermissionConfig pc - LEFT JOIN '.$perm_live_table.' p + LEFT JOIN '.$perm_live_table.' p ON (p.Permission = pc.PermissionName) AND ('.str_replace('#TABLE_PREFIX#', 'p', $pos_sql).') AND (p.GroupId = '.$group_id.') - LEFT JOIN '.$perm_temp_table.' tmp_p + LEFT JOIN '.$perm_temp_table.' tmp_p ON (tmp_p.Permission = pc.PermissionName) AND (tmp_p.CatId = '.$this_cat.') AND (tmp_p.GroupId = '.$group_id.') WHERE ModuleId = "'.$module.'"'; $permissions = $this->Conn->Query($sql); - + $ret = ''; $block_params = array_merge_recursive2( $this->prepareTagParams($params), Array('name' => $params['render_as'])); foreach ($permissions as $perm_record) { @@ -132,7 +132,7 @@ } return $ret; } - + /** * Print module tab for each module * @@ -149,7 +149,7 @@ } return $ret; } - + /** * Returns category name by ID * @@ -177,12 +177,12 @@ } return $category_path; } - + function PermInputName($params) { return $this->Prefix.'['.$this->Application->GetVar('group_id').']['.$this->Application->Parser->GetParam('PermissionName').']['.$params['sub_key'].']'; } - + } ?> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.8.2/core/units/permissions/permissions_tag_processor.php =================================================================== diff -u -r5651 -r6078 --- branches/unlabeled/unlabeled-1.8.2/core/units/permissions/permissions_tag_processor.php (.../permissions_tag_processor.php) (revision 5651) +++ branches/unlabeled/unlabeled-1.8.2/core/units/permissions/permissions_tag_processor.php (.../permissions_tag_processor.php) (revision 6078) @@ -1,24 +1,24 @@ Application->recallObject('SectionsHelper'); $section_data =& $sections_helper->getSectionData($section_name); - + return array_search($params['perm_name'], $section_data['permissions']) !== false; } - + function HasAdvancedPermissions($params) { $section_name = $params['section_name']; - + $sections_helper =& $this->Application->recallObject('SectionsHelper'); $section_data =& $sections_helper->getSectionData($section_name); - + $ret = false; foreach ($section_data['permissions'] as $perm_name) { if (preg_match('/^advanced:(.*)/', $perm_name)) { @@ -28,43 +28,43 @@ } return $ret; } - + function PermissionValue($params) { $section_name = $params['section_name']; - + $sections_helper =& $this->Application->recallObject('SectionsHelper'); $section_data =& $sections_helper->getSectionData($section_name); $perm_name = $params['perm_name']; - + $permissions_helper =& $this->Application->recallObject('PermissionsHelper'); if (!$permissions_helper->isOldPermission($section_name, $perm_name)) { $perm_name = $section_name.'.'.$perm_name; } - + return $permissions_helper->getPermissionValue($perm_name); } - + function LoadPermissions($params) { $permissions_helper =& $this->Application->recallObject('PermissionsHelper'); $prefix_parts = explode('-', $this->Prefix, 2); $permissions_helper->LoadPermissions($this->Application->GetVar('g_id'), 0, 1); } - + function LevelIndicator($params) { return $params['level'] * $params['multiply']; } - + function PrintPermissions($params) { $category =& $this->Application->recallObject('c'); - + $group_id = $this->Application->GetVar('group_id'); $prefix = $this->Application->GetVar('item_prefix'); $module = $this->Application->findModule('Var', $prefix, 'Name'); - + $perm_live_table = $this->Application->getUnitOption('c-perm', 'TableName'); $perm_temp_table = $this->Application->GetTempName($perm_live_table); @@ -74,13 +74,13 @@ else { $categories = explode('|', substr($category->GetDBField('ParentPath'), 1, -1)); } - + if (count($categories) == 1 || $category->GetID() == 0) { // category located in root category ("Home") => then add it to path virtually array_unshift($categories, 0); } $this_cat = array_pop($categories); - + // get permission name + category position in parent path that has value set for that permission $case = 'MAX(CASE c.CategoryId'; foreach ($categories as $pos => $cat_id) { @@ -95,17 +95,17 @@ CategoryId IN ('.implode(',', $categories).') AND ModuleId = "'.$module.'" AND ( - (p.GroupId = '.$group_id.' AND p.Type = 0) + (p.GroupId = '.$group_id.' AND p.Type = 0) ) GROUP BY Perm'; $perm_positions = $this->Conn->GetCol($sql, 'Perm'); - + $pos_sql = ''; foreach ($perm_positions as $perm_name => $category_pos) { - $pos_sql .= '(#TABLE_PREFIX#.Permission = "'.$perm_name.'" AND #TABLE_PREFIX#.CatId = '.$categories[$category_pos].') OR '; + $pos_sql .= '(#TABLE_PREFIX#.Permission = "'.$perm_name.'" AND #TABLE_PREFIX#.CatId = '.$categories[$category_pos].') OR '; } $pos_sql = $pos_sql ? preg_replace('/(.*) OR $/', '\\1', $pos_sql) : '0'; - + // get all permissions list with iheritence status, inherited category id and permission value $sql = 'SELECT pc.PermissionName, pc.Description, @@ -117,13 +117,13 @@ IF(tmp_p.CatId = '.$category->GetID().', 0, 1) AS Inherited, IF(p.PermissionValue IS NOT NULL, p.PermissionValue, 0) AS InheritedValue FROM '.TABLE_PREFIX.'PermissionConfig pc - LEFT JOIN '.$perm_live_table.' p + LEFT JOIN '.$perm_live_table.' p ON (p.Permission = pc.PermissionName) AND ('.str_replace('#TABLE_PREFIX#', 'p', $pos_sql).') AND (p.GroupId = '.$group_id.') - LEFT JOIN '.$perm_temp_table.' tmp_p + LEFT JOIN '.$perm_temp_table.' tmp_p ON (tmp_p.Permission = pc.PermissionName) AND (tmp_p.CatId = '.$this_cat.') AND (tmp_p.GroupId = '.$group_id.') WHERE ModuleId = "'.$module.'"'; $permissions = $this->Conn->Query($sql); - + $ret = ''; $block_params = array_merge_recursive2( $this->prepareTagParams($params), Array('name' => $params['render_as'])); foreach ($permissions as $perm_record) { @@ -132,7 +132,7 @@ } return $ret; } - + /** * Print module tab for each module * @@ -149,7 +149,7 @@ } return $ret; } - + /** * Returns category name by ID * @@ -177,12 +177,12 @@ } return $category_path; } - + function PermInputName($params) { return $this->Prefix.'['.$this->Application->GetVar('group_id').']['.$this->Application->Parser->GetParam('PermissionName').']['.$params['sub_key'].']'; } - + } ?> \ No newline at end of file Index: branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php =================================================================== diff -u -r5980 -r6078 --- branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 5980) +++ branches/unlabeled/unlabeled-1.24.2/core/kernel/parser/template_parser.php (.../template_parser.php) (revision 6078) @@ -333,7 +333,7 @@ } if ($opening_tag == ''); + $this->AppendOutput(''); $tag = '__COMMENT__'; } Index: branches/unlabeled/unlabeled-1.56.2/kernel/include/category.php =================================================================== diff -u -r6026 -r6078 --- branches/unlabeled/unlabeled-1.56.2/kernel/include/category.php (.../category.php) (revision 6026) +++ branches/unlabeled/unlabeled-1.56.2/kernel/include/category.php (.../category.php) (revision 6078) @@ -839,8 +839,8 @@ function GetNavbar() { - $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - return str_replace('&|&', ' > ', $this->Get($ml_formatter->LangFieldName('CachedNavbar'))); + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + return str_replace('&|&', ' > ', $this->Get($ml_formatter->LangFieldName('CachedNavbar'))); } function ParseObject($element) Index: branches/unlabeled/unlabeled-1.26.2/kernel/units/languages/languages_event_handler.php =================================================================== diff -u -r5732 -r6078 --- branches/unlabeled/unlabeled-1.26.2/kernel/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 5732) +++ branches/unlabeled/unlabeled-1.26.2/kernel/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 6078) @@ -13,6 +13,7 @@ 'OnChangeLanguage' => Array('self' => true), 'OnSetPrimary' => Array('self' => 'advanced:set_primary|add|edit'), 'OnImportLanguage' => Array('self' => 'advanced:import'), + 'OnImportProgress' => Array('self' => 'advanced:import'), 'OnExportLanguage' => Array('self' => 'advanced:export'), 'OnExportProgress' => Array('self' => 'advanced:export'), @@ -42,6 +43,10 @@ */ function OnSetPrimary(&$event) { + if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + return; + } + $this->StoreSelectedIDs($event); $ids = $this->getSelectedIDs($event); if ($ids) { @@ -198,6 +203,10 @@ */ function OnImportLanguage(&$event) { + if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + return; + } + $items_info = $this->Application->GetVar('phrases_import'); if($items_info) { @@ -287,8 +296,17 @@ $this->Application->InitParser(); $this->Application->setUnitOption('phrases','AutoLoad',false); echo $this->Application->ParseBlock($block_params); + + //break out of buffering + $buffer_content = Array(); + while (ob_get_level()) { + $buffer_content[] = ob_get_clean(); + } + $ret = implode('', array_reverse($buffer_content)); + echo $ret; flush(); + $sql = 'SELECT * FROM %s LIMIT %s,%s'; $rows = $this->Conn->Query( sprintf($sql,$src_table,$import_start,IMPORT_BY) ); @@ -349,6 +367,10 @@ */ function OnExportLanguage(&$event) { + if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + return; + } + $this->Application->setUnitOption('phrases','AutoLoad',false); $this->StoreSelectedIDs($event); Index: branches/unlabeled/unlabeled-1.26.2/core/units/languages/languages_event_handler.php =================================================================== diff -u -r5732 -r6078 --- branches/unlabeled/unlabeled-1.26.2/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 5732) +++ branches/unlabeled/unlabeled-1.26.2/core/units/languages/languages_event_handler.php (.../languages_event_handler.php) (revision 6078) @@ -13,6 +13,7 @@ 'OnChangeLanguage' => Array('self' => true), 'OnSetPrimary' => Array('self' => 'advanced:set_primary|add|edit'), 'OnImportLanguage' => Array('self' => 'advanced:import'), + 'OnImportProgress' => Array('self' => 'advanced:import'), 'OnExportLanguage' => Array('self' => 'advanced:export'), 'OnExportProgress' => Array('self' => 'advanced:export'), @@ -42,6 +43,10 @@ */ function OnSetPrimary(&$event) { + if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + return; + } + $this->StoreSelectedIDs($event); $ids = $this->getSelectedIDs($event); if ($ids) { @@ -198,6 +203,10 @@ */ function OnImportLanguage(&$event) { + if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + return; + } + $items_info = $this->Application->GetVar('phrases_import'); if($items_info) { @@ -287,8 +296,17 @@ $this->Application->InitParser(); $this->Application->setUnitOption('phrases','AutoLoad',false); echo $this->Application->ParseBlock($block_params); + + //break out of buffering + $buffer_content = Array(); + while (ob_get_level()) { + $buffer_content[] = ob_get_clean(); + } + $ret = implode('', array_reverse($buffer_content)); + echo $ret; flush(); + $sql = 'SELECT * FROM %s LIMIT %s,%s'; $rows = $this->Conn->Query( sprintf($sql,$src_table,$import_start,IMPORT_BY) ); @@ -349,6 +367,10 @@ */ function OnExportLanguage(&$event) { + if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) { + return; + } + $this->Application->setUnitOption('phrases','AutoLoad',false); $this->StoreSelectedIDs($event); Index: branches/unlabeled/unlabeled-1.89.2/kernel/include/parseditem.php =================================================================== diff -u -r5656 -r6078 --- branches/unlabeled/unlabeled-1.89.2/kernel/include/parseditem.php (.../parseditem.php) (revision 5656) +++ branches/unlabeled/unlabeled-1.89.2/kernel/include/parseditem.php (.../parseditem.php) (revision 6078) @@ -7,7 +7,7 @@ function RegisterPrefix($class,$prefix,$file) { global $ItemTypePrefixes, $ItemTagFiles; - + $ItemTypePrefixes[$class] = $prefix; $ItemTagFiles[$prefix] = $file; } @@ -16,7 +16,7 @@ { var $TagPrefix; var $Parser; - var $AdminParser; + var $AdminParser; function clsParsedItem($id=NULL) { @@ -26,7 +26,7 @@ $this->Parser = new clsTemplateList($TemplateRoot); $this->AdminParser = new clsAdminTemplateList(); } - + /* function ParseObject($element) { $extra_attribs = ExtraAttributes($element->attributes); @@ -42,12 +42,12 @@ function ParseTimeStamp($d,$attribs=array()) { global $objSession; - + if (isset($attribs['_tz'])) { $timezone = $attribs['_tz'] == 'auto' ? null : $objSession->Get('tz'); $d = GetLocalTime($d, $timezone); } - + $part = isset($attribs['_part']) ? strtolower($attribs['_part']) : ''; if ($part) { $ret = ExtractDatePart($part,$d); @@ -57,23 +57,23 @@ } return $ret; } - + function ParseObject($element) { global $objConfig, $objCatList, $var_list_update, $var_list, $n_var_list_update, $m_var_list_update; $extra_attribs = ExtraAttributes($element->attributes); $ret = ""; - + if ($this->TagPrefix == "email" && strtolower($element->name) == "touser") { - $this->TagPrefix = "touser"; + $this->TagPrefix = "touser"; } - + if(strtolower($element->name)==$this->TagPrefix) { $field = strtolower($element->attributes["_field"]); switch($field) - { + { case 'primarycategorylink': $m_var_list_update['cat'] = (int)$this->GetPrimaryCategory(); $m_var_list_update['p'] = 1; @@ -82,54 +82,54 @@ unset($m_var_list_update['p']); return $ret; break; - + case 'primarycategory': $db =& GetADODBConnection(); $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - + $sql = 'SELECT '.$ml_formatter->LangFieldName('CachedNavbar').' FROM '.$objCatList->SourceTable.' WHERE CategoryId = '.(int)$this->GetPrimaryCategory(); $ret = prompt_language($objConfig->Get("Root_Name")); if ($this->GetPrimaryCategory()) { $ret .= ' > '.str_replace('&|&', ' > ', $db->GetOne($sql)); } break; - + case "id": $ret = $this->Get($this->id_field); - break; + break; case "resourceid": if(!$this->NoResourceId) $ret = $this->Get("ResourceId"); - break; + break; case "category": $c = $objCatList->GetItem($this->Get("CategoryId")); if(is_object($c)) { $ret = $c->parsetag($element->attributes["_cattag"]); } - break; + break; case "priority": if($this->Get("Priority")!=0) - { + { $ret = (int)$this->Get("Priority"); } else $ret = ""; - break; + break; case "link": /* if(method_exists($this,"ItemURL")) - { - $ret = $this->ItemURL($element->attributes["_template"],FALSE,""); + { + $ret = $this->ItemURL($element->attributes["_template"],FALSE,""); } break; */ case "cat_link": if(method_exists($this,"ItemURL")) { - $ret = $this->ItemURL($element->attributes["_template"],TRUE,""); - } + $ret = $this->ItemURL($element->attributes["_template"],TRUE,""); + } break; - case "fullpath": - $ret = $this->Get("CachedNavbar"); + case "fullpath": + $ret = str_replace('&|&', ' > ', $this->Get("CachedNavbar")); if(!strlen($ret)) { if(is_numeric($this->Get("CategoryId"))) @@ -145,34 +145,34 @@ $cat = $this->GetPrimaryCategory(); $c = $objCatList->GetItem($cat); if(is_object($c)) - $ret = $c->GetNavBar(); + $ret = $c->GetNavBar(); } } } // $ret = $this->HighlightText($ret); - break; - - case "relevance": - $style = $element->attributes["_displaymode"]; + break; + + case "relevance": + $style = $element->attributes["_displaymode"]; if(!strlen($style)) $style = "numerical"; switch ($style) - { - case "numerical": + { + case "numerical": $ret = (100 * LangNumber($this->Get("Relevance"),1))."%"; - break; - case "bar": + break; + case "bar": $OffColor = $element->attributes["_offbackgroundcolor"]; $OnColor = $element->attributes["_onbackgroundcolor"]; $percentsOff = (int)(100 - (100 * $this->Get("Relevance"))); if ($percentsOff) { $percentsOn = 100 - $percentsOff; - $ret = ""; + $ret = ""; } else - $ret = ""; - break; - case "graphical": + $ret = ""; + break; + case "graphical": $OnImage = $element->attributes["_onimage"]; if (!strlen($OnImage)) break; @@ -182,24 +182,24 @@ unset($image_data[count($image_data)-1]); $rel = (10 * LangNumber($this->Get("Relevance"),1)); $OnImage1 = join(".", $image_data); - + if ($rel) - $img_src = $OnImage1."_".$rel.".".$image_ext; + $img_src = $OnImage1."_".$rel.".".$image_ext; else $img_src = $OnImage; - + $ret = "\"".(10*$rel)."\""; break; - } - + } + break; - + case "rating": $style = $element->GetAttributeByName("_displaymode"); if(!strlen($style)) - $style = "numerical"; + $style = "numerical"; switch($style) - { + { case "numerical": $ret = LangNumber($this->Get("CachedRating"),1); break; @@ -210,12 +210,12 @@ $OnImage = $element->attributes["_onimage"]; $OffImage = $element->attributes["_offimage"]; $images = RatingTickImage($this->Get("CachedRating"),$OnImage,$OffImage); - + for($i=1;$i<=count($images);$i++) { $url = $images[$i]; if(strlen($url)) - { + { $ret .= ""; $ret .= $element->GetAttributeByName('_separator'); } @@ -225,39 +225,39 @@ break; case "reviews": $today = FALSE; - + if(method_exists($this,"ReviewCount")) - { + { if($element->GetAttributeByName("_today")) - $today = TRUE; + $today = TRUE; $ret = $this->ReviewCount($today); - $ret = ($element->GetAttributeByName("_dataexists") && empty($ret))? "" : $ret; + $ret = ($element->GetAttributeByName("_dataexists") && empty($ret))? "" : $ret; } else $ret = ""; - + break; case "votes": $ret = (int)$this->Get("CachedVotesQty"); - break; + break; case "favorite": if(method_exists($this,"IsFavorite")) - { + { if($this->IsFavorite()) { $ret = $element->attributes["_label"]; if(!strlen($ret)) $ret = "lu_favorite"; - $ret = language($ret); + $ret = language($ret); } else $ret = ""; } - break; + break; case "new": if(method_exists($this,"IsNewItem")) - { + { if($this->IsNewItem()) { $ret = $element->GetAttributeByName('_label'); @@ -271,7 +271,7 @@ break; case "pop": if(method_exists($this,"IsPopItem")) - { + { if($this->IsPopItem()) { $ret = $element->GetAttributeByName('_label'); @@ -307,7 +307,7 @@ } else $ret = ""; - break; + break; case "admin_icon": if(method_exists($this,"StatusIcon")) { @@ -318,7 +318,7 @@ else $ret = $this->StatusIcon(); } - break; + break; case "custom": if(method_exists($this,"GetCustomFieldValue")) { @@ -328,11 +328,11 @@ if (strlen($field)) $ret = $this->GetCustomFieldValue($field, $default, $listvalue); } - break; + break; case "image": $default = $element->attributes["_primary"]; $name = $element->attributes["_name"]; - + if(strlen($name)) { $img = $this->GetImageByName($name); @@ -342,10 +342,10 @@ if($default) $img = $this->GetDefaultImage(); } - + if(is_object($img)) { - + if(strlen($element->attributes["_imagetemplate"])) { $ret = $img->ParseTemplate($element->attributes["_imagetemplate"]); @@ -354,18 +354,18 @@ else { if($element->attributes["_thumbnail"]) - { + { $url = $img->parsetag("thumb_url"); } else { - + if(!$element->attributes["_nothumbnail"]) { - $url = $img->parsetag("image_url"); + $url = $img->parsetag("image_url"); } else - { + { $url = $img->FullURL(TRUE,""); } } @@ -374,7 +374,7 @@ else { $url = $element->attributes["_defaulturl"]; - + } if($element->attributes["_imagetag"]) @@ -398,14 +398,14 @@ $ret = "Undefined:".$element->name; break; } - + } else if ($this->TagPrefix == 'email'){ $ret = "Undefined:".$element->name; } return $ret; } - + function ParseString($name) { $el = new clsHtmlTag(); @@ -455,17 +455,17 @@ $tag->inner_html = $inner_html; if($tag->parsed) - { + { if($tag->name=="include" || $tag->name=="perm_include" || $tag->name=="lang_include") { $output = $this->Parser->IncludeTemplate($tag); } else - { - $output = $this->ParseObject($tag); + { + $output = $this->ParseObject($tag); //echo $output."
"; if(substr($output,0,9)=="Undefined") - { + { $output = $tag->Execute(); // if(substr($output,0,8)="{Unknown") // $output = $raw; @@ -534,7 +534,7 @@ if ($TagNameEnd) { $Tag = strtolower(substr($html, $next_tag, $TagNameEnd-$next_tag)); - $TagName = explode(":", $Tag); + $TagName = explode(":", $Tag); if (strlen($TagName[1])) $CloserTag = ""; } @@ -577,7 +577,7 @@ function ParseTemplate($tname) { global $objTemplate, $LogLevel,$ptime,$timestart; - + //echo 'Saving ID'.$this->UniqueId().' in Main parseTempalate
'; //$GLOBALS[$this->TagPrefix.'_ID'] = $this->UniqueId(); LogEntry("Parsing $tname\n"); @@ -605,7 +605,7 @@ } return $html; } - + function SendUserEventMail($EventName,$ToUserId,$LangId=NULL,$RecptName=NULL) { global $objMessageList,$FrontEnd; @@ -616,9 +616,9 @@ { if($Event->Get("Enabled")=="1" || ($Event->Get("Enabled")==2 && $FrontEnd)) { - $Event->Item = $this; + $Event->Item = $this; if(is_numeric($ToUserId)) - { + { return $Event->SendToUser($ToUserId); } else @@ -647,7 +647,7 @@ function parse_template($t) { } - + } class clsItemCollection @@ -665,74 +665,74 @@ var $id_field = null; // id field for list item var $BasePermission; var $Dummy = null; - + // enshure that same sql won't be queried twice var $QueryDone = false; var $LastQuerySQL = ''; - + var $Prefix = ''; var $Special = ''; - + /** * Application object * * @var kApplication */ var $Application = null; - + /** * Connection to database * * @var kDBConnection */ var $Conn = null; - + function isLiveTable() { global $objSession; return !preg_match('/'.GetTablePrefix().'ses_'.$objSession->GetSessionKey().'_edit_(.*)/', $this->SourceTable); } - + function SetTable($action, $table_name = null) // new by Alex { // $action = {'live', 'restore','edit'} switch($action) { - case 'live': + case 'live': $this->LiveTable = $table_name; $this->SourceTable = $this->LiveTable; break; - case 'restore': - $this->SourceTable = $this->LiveTable; + case 'restore': + $this->SourceTable = $this->LiveTable; break; case 'edit': global $objSession; $this->SourceTable = $objSession->GetEditTable($this->LiveTable); break; } } - + function &GetDummy() // new by Alex { if( !isset($this->Dummy) ) $this->Dummy =& new $this->classname(); - $this->Dummy->tablename = $this->SourceTable; + $this->Dummy->tablename = $this->SourceTable; return $this->Dummy; } - + function clsItemCollection() { if (class_exists('kApplication')) { // just in case when aplication is not found - $this->Application =& kApplication::Instance(); + $this->Application =& kApplication::Instance(); $this->Conn =& $this->Application->GetADODBConnection(); } - + $this->adodbConnection =& GetADODBConnection(); - + $this->Clear(); $this->BasePermission = ''; - } + } function GetIDField() // new by Alex { @@ -749,12 +749,12 @@ { return new $this->classname(); } - + function Clear() { unset($this->Items); $this->Items = array(); - $this->CurrentItem=0; + $this->CurrentItem=0; } function &SetCurrentItem($id) @@ -783,7 +783,7 @@ else return 0; } - + function ItemLike($index, $string) { // check if any of the item field @@ -800,42 +800,42 @@ } return $found; } - + function DeleteItem($index) // by Alex { // deletes item with specific index from list $i = $index; $item_count = $this->NumItems(); while($i < $item_count - 1) { $this->Items[$i] = $this->Items[$i + 1]; - $i++; + $i++; } unset($this->Items[$i]); } - + function ShowItems() { $i = 0; $item_count = $this->NumItems(); while($i < $item_count) { echo "Item No $i:
"; $this->Items[$i]->PrintVars(); - $i++; + $i++; } } - + function SwapItems($Index,$Index2) { $temp = $this->Items[$Index]->GetData(); $this->Items[$Index]->SetData($this->Items[$Index2]->GetData()); $this->Items[$Index2]->SetData($temp); - + } - + function CopyResource($OldId,$NewId, $main_prefix) { $this->Clear(); - + $sql = "SELECT * FROM ".$this->SourceTable." WHERE ResourceId=$OldId"; $this->Query_Item($sql); // echo $sql."
\n"; @@ -849,20 +849,20 @@ } } } - + function ItemsOnClipboard() { global $objSession; $clip = $objSession->GetPersistantVariable("ClipBoard"); $count = 0; $table = $this->SourceTable; $prefix = GetTablePrefix(); - - + + if(substr($table,0,strlen($prefix))==$prefix) $table = substr($table,strlen($prefix)); - + if(strlen($clip)) { $clipboard = ParseClipboard($clip); @@ -878,7 +878,7 @@ return $count; } - + function CopyToClipboard($command,$idfield, $idlist) { global $objSession,$objCatList; @@ -890,14 +890,14 @@ else $list = $idlist; $clip = $command."-".$objCatList->CurrentCategoryID().".".$this->SourceTable.".$idfield=".$list; - + $objSession->SetVariable("ClipBoard",$clip); } - + function SortItems($asc=TRUE) { $done = FALSE; - + $field = $this->SortField; $ItemCount = $this->NumItems(); while(!$done) @@ -907,16 +907,16 @@ { $doswap = FALSE; if($asc) - { - $val1 = $this->Items[$i-1]->Get($field); + { + $val1 = $this->Items[$i-1]->Get($field); $val2 = $this->Items[$i]->Get($field); - $doswap = ($val1 > $val2); + $doswap = ($val1 > $val2); } else { $val1 = $this->Items[$i-1]->Get($field); - $val2 = $this->Items[$i]->Get($field); - $doswap = ($val1 < $val2); + $val2 = $this->Items[$i]->Get($field); + $doswap = ($val1 < $val2); } if($doswap) { @@ -938,17 +938,17 @@ { $i =& $this->GetItemRefByIndex($x); if($i->UniqueID()==$ID) - { + { $found=TRUE; break; } } } - + if(!$found) { if($LoadFromDB) - { + { $n = NULL; $n = new $this->classname(); $n->tablename = $this->SourceTable; @@ -1028,13 +1028,13 @@ } function GetNumPages($ItemsPerPage) - { + { if( isset($_GET['reset']) && $_GET['reset'] == 1) $this->Page = 1; return GetPageCount($ItemsPerPage,$this->QueryItemCount); } function &AddItemFromArray($data, $clean=FALSE) - { + { $class = new $this->classname; $class->SetFromArray($data); $class->tablename = $this->SourceTable; @@ -1046,8 +1046,8 @@ } function Query_Item($sql, $offset=-1,$rows=-1) - { - global $Errors, $objConfig; + { + global $Errors, $objConfig; //echo "Method QItem [".get_class($this).'], sql: ['.$sql.']
'; $dummy =& $this->GetDummy(); if( !$dummy->TableExists() ) @@ -1064,21 +1064,21 @@ //echo "Executing SelectLimit $sql Offset: $offset,$rows
\n"; $result = $this->adodbConnection->SelectLimit($sql, $rows,$offset); } - else { + else { $result = $this->adodbConnection->Execute($sql); } - + if ($result === false) { $Errors->AddError("error.DatabaseError",NULL,$this->adodbConnection->ErrorMsg(),"",get_class($this),"Query_Item"); if($this->debuglevel) { echo '

'.$sql.'

'; - echo "Error: ".$this->adodbConnection->ErrorMsg()."
"; + echo "Error: ".$this->adodbConnection->ErrorMsg()."
"; } $this->Clear(); return false; } - + $this->Clear(); if($this->debuglevel > 0) @@ -1093,12 +1093,12 @@ //echo "SQL: $sql

"; LogEntry("SQL Loop Start\n"); $count = 0; - + while ($result && !$result->EOF) { $count++; $data = $result->fields; - $this->AddItemFromArray($data,TRUE); + $this->AddItemFromArray($data,TRUE); if( defined('ADODB_EXTENSION') && constant('ADODB_EXTENSION') > 0 ) adodb_movenext($result); else @@ -1119,23 +1119,23 @@ $TableName = $this->SourceTable."."; } else - $TableName = ""; + $TableName = ""; $PriorityClause = $TableName."EditorsPick DESC, ".$TableName."Priority DESC"; - + if(strlen(trim($FieldVar))>0) { if(is_object($objSession)) { - if(strlen($objSession->GetPersistantVariable($FieldVar))>0) - { - $OrderBy = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ". + if(strlen($objSession->GetPersistantVariable($FieldVar))>0) + { + $OrderBy = trim($TableName.$objSession->GetPersistantVariable($FieldVar) . " ". $objSession->GetPersistantVariable($OrderVar)); - $FieldUsed = $objSession->GetPersistantVariable($FieldVar); + $FieldUsed = $objSession->GetPersistantVariable($FieldVar); } - } + } $OrderBy = trim($OrderBy); - if (strlen(trim($OrderBy))==0) + if (strlen(trim($OrderBy))==0) { if(!$UseTableName) { @@ -1147,20 +1147,20 @@ { $OrderBy = $this->SourceTable.".".$DefaultField.".".$DefaultVar; } - $FieldUsed=$DefaultField; + $FieldUsed=$DefaultField; } } - } + } if(($FieldUsed != "Priority" || strlen($OrderBy)==0) && $Priority==TRUE) { if(strlen($OrderBy)==0) { $OrderBy = $PriorityClause; } - else + else $OrderBy = $PriorityClause.", ".$OrderBy; } - return $OrderBy; + return $OrderBy; } function GetResourceIDList() @@ -1196,9 +1196,9 @@ $this->Clear(); $this->Query_Item($sql); if($this->NumItems()>0) - { + { foreach($this->Items as $i) - { + { $i->DeleteCategoryItems($CatId,$CatTable); } } @@ -1207,7 +1207,7 @@ function CopyToEditTable($idfield = null, $idlist = 0) { global $objSession; - + if($idfield == null) $idfield = $this->GetIDField(); $edit_table = $objSession->GetEditTable($this->SourceTable); @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); @@ -1225,14 +1225,14 @@ } function CreateEmptyEditTable($idfield = null) - { + { global $objSession; if($idfield == null) $idfield = $this->GetIDField(); - + $edit_table = $objSession->GetEditTable($this->SourceTable); @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); $query = "SELECT * FROM ".$this->SourceTable." WHERE $idfield = -1"; - $insert = "CREATE TABLE ".$edit_table." ".$query; + $insert = "CREATE TABLE ".$edit_table." ".$query; if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($insert,ENT_NOQUOTES)."
\n"; $this->adodbConnection->Execute($insert); @@ -1246,18 +1246,18 @@ $dropRelTableFlag = false; if($idfield == null) $idfield = $this->GetIDField(); - $edit_table = $objSession->GetEditTable($this->SourceTable); + $edit_table = $objSession->GetEditTable($this->SourceTable); $sql = "SELECT * FROM $edit_table"; $rs = $this->adodbConnection->Execute($sql); - + $item_ids = Array(); while ($rs && !$rs->EOF) { - $data = $rs->fields; + $data = $rs->fields; $c = new $this->classname; $c->SetFromArray($data); $c->idfield = $idfield; $c->Dirty(); - + if($c->Get($idfield) < 1) { $old_id = $c->Get($idfield); @@ -1275,22 +1275,22 @@ $org->DeleteCustomData(); $org->Delete(TRUE); $c->Set("OrgId",0); - } - } + } + } $c->Create(); } $item_ids[] = $c->UniqueId(); // save item id for future use if(is_numeric($c->Get("ResourceId"))) - { + { if( isset($c->Related) && is_object($c->Related) ) - { - $r = $c->Related; + { + $r = $c->Related; $r->CopyFromEditTable($c->Get("ResourceId")); $dropRelTableFlag = true; - } - + } + unset($r); - + if( isset($c->Reviews) && is_object($c->Reviews) ) { $r = $c->Reviews; @@ -1310,9 +1310,9 @@ $org->DeleteCustomData(); $org->Delete(TRUE); $c->Set("OrgId",0); - } - } - + } + } + $GLOBALS['_CopyFromEditTable']=1; if(method_exists($c,"CategoryMemberList")) { @@ -1327,38 +1327,38 @@ unset($c); unset($r); - + $rs->MoveNext(); } - + $objReviews = new clsItemReviewList(); $objReviews->PurgeEditTable(); - + if ($dropRelTableFlag) { - $objRelGlobal = new clsRelationshipList(); + $objRelGlobal = new clsRelationshipList(); $objRelGlobal->PurgeEditTable(); } - - if($edit_table) @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); + + if($edit_table) @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); @$this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$objSession->GetEditTable("CategoryItems")); unset($GLOBALS['_CopyFromEditTable']); - + return $item_ids; } - + function GetNextTempID() { // get next temporary id (lower then zero) from temp table $db =& $this->adodbConnection; $sql = 'SELECT MIN(%s) AS MinValue FROM %s'; return $db->GetOne( sprintf($sql, $this->GetIDField(), $this->SourceTable) ) - 1; } - + function PurgeEditTable($idfield = null) { global $objSession; - + if($idfield == null) $idfield = $this->GetIDField(); $edit_table = $objSession->GetEditTable($this->SourceTable); /* $rs = $this->adodbConnection->Execute("SELECT * FROM $edit_table"); @@ -1379,7 +1379,7 @@ function CopyCatListToEditTable($idfield, $idlist) { global $objSession; - + $edit_table = $objSession->GetEditTable("CategoryItems"); @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); if(is_array($idlist)) @@ -1389,32 +1389,32 @@ else $list = $idlist; $query = "SELECT * FROM ".GetTablePrefix()."CategoryItems WHERE $idfield IN ($list)"; - + $insert = "CREATE TABLE ".$edit_table." ".$query; if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($insert,ENT_NOQUOTES)."
\n"; $this->adodbConnection->Execute($insert); } - + function CreateEmptyCatListTable($idfield) { global $objSession; - + $edit_table = $objSession->GetEditTable("CategoryItems"); @$this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); $query = "SELECT * FROM ".GetTablePrefix()."CategoryItems WHERE $idfield = -1"; $insert = "CREATE TABLE ".$edit_table." ".$query; if($objSession->HasSystemPermission("DEBUG.LIST")) - echo htmlentities($insert,ENT_NOQUOTES)."
\n"; + echo htmlentities($insert,ENT_NOQUOTES)."
\n"; $this->adodbConnection->Execute($insert); } - + function RefreshPage($page_var, $total_items) { global $objConfig, $objSession; - + $this->QueryItemCount = $total_items; - + if ( (int)GetVar('lpn') > 0) { $this->Page = $_GET['lpn']; @@ -1423,21 +1423,21 @@ { $this->Page = $objConfig->Get($page_var); } - + if ( ($this->Page > $this->GetNumPages($this->PerPage) || $this->Page == 0) && ($this->PerPage != -1) ) { - $this->Page = 1; + $this->Page = 1; } - + $objSession->SetVariable($page_var, $this->Page); } - + function PurgeCatListEditTable() { global $objSession; - + $edit_table = $objSession->GetEditTable("CategoryItems"); - $this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); + $this->adodbConnection->Execute("DROP TABLE IF EXISTS $edit_table"); } function AdminSearchWhereClause($SearchList) @@ -1453,12 +1453,12 @@ $SearchList=$SearchListTmp; if( !count($SearchList) || !count($this->AdminSearchFields) ) return ''; - + for($f = 0; $f < count($SearchList); $f++) - { + { $value = $SearchList[$f]; if( strlen($value) ) - { + { $inner_sql = ""; for($i = 0; $i < count($this->AdminSearchFields); $i++) { @@ -1471,7 +1471,7 @@ } if( strlen($inner_sql) ) { - $sql .= '('.$inner_sql.') '; + $sql .= '('.$inner_sql.') '; if($f < count($SearchList) - 1) $sql .= " AND "; } } @@ -1499,7 +1499,7 @@ $this->Clear(); } } - + function RestoreData($InFileName,$Start,$Limit) { $res = -1; @@ -1515,29 +1515,29 @@ $Line++; } $res = ftell($fp); - fclose($fp); + fclose($fp); } return $res; } - + function Delete_Item($Id, $DetectCategories = false) { global $objCatList; - + $l =& $this->GetItem($Id); $l->BasePermission=$this->BasePermission; - + if (!$DetectCategories) { - $l->DeleteCategoryItems($objCatList->CurrentCategoryID()); + $l->DeleteCategoryItems($objCatList->CurrentCategoryID()); } else { $l->RemoveFromAllCategories(); $l->Delete(); } } - + function Move_Item($Id, $OldCat, $ParentTo) - { + { global $objCatList; $l = $this->GetItem($Id); @@ -1547,15 +1547,15 @@ } function Copy_Item($Id, $ParentTo) - { + { $l = $this->GetItem($Id); $l->BasePermission=$this->BasePermission; $l->AddtoCategory($ParentTo); - } - + } + }/* clsItemCollection */ -class clsItemList extends clsItemCollection +class clsItemList extends clsItemCollection { var $Page; var $PerPageVar; @@ -1565,23 +1565,23 @@ var $PageEnvar; var $PageEnvarIndex; var $ListType; - + var $LastLimitClause = ''; // used to store last limit cluse used in query - + function setPageFromENV() { $this->Page=$GLOBALS[$this->PageEnvar][$this->PageEnvarIndex]; } - + function clsItemList() { $this->clsItemCollection(); - $this->EnablePaging = TRUE; - $this->PageEnvarIndex = "p"; + $this->EnablePaging = TRUE; + $this->PageEnvarIndex = "p"; } - + function GetPageLimitSQL() - { + { global $objConfig; $limit = NULL; if($this->EnablePaging) @@ -1595,34 +1595,34 @@ $limit = "LIMIT ".$Start.",".$objConfig->Get($this->PerPageVar); } else - $limit = NULL; + $limit = NULL; } - else + else { if($this->MaxListCount) { $limit = 'LIMIT 0, '.$this->MaxListCount; } } return $limit; - } - + } + function GetPageOffset() { $Start = 0; if($this->EnablePaging) - { + { if($this->Page < 1) $this->Page = 1; $PerPage = $this->GetPerPage(); $Start = ($this->Page - 1) * $PerPage; } - else - { + else + { if((int)$this->MaxListCount == 0) $Start = -1; } return $Start; } - + function GetPageRowCount() { if($this->EnablePaging) @@ -1631,10 +1631,10 @@ //echo "Got PerPage: ".$this->GetPerPage()."
"; return $this->GetPerPage(); } - else + else return (int)$this->MaxListCount; - } - + } + function Query_Item($sql,$limit = null, $fix_method = 'set_first') { // query itemlist (module items) using $sql specified @@ -1645,22 +1645,22 @@ $sql .= " ".$limit; return parent::Query_Item($sql); } - else - { + else + { //echo "page fix pre (class: ".get_class($this).")
"; $this->QueryItemCount = QueryCount($sql); // must get total item count before fixing - + $this->FixInvalidPage($fix_method); - + // specially made for cats delete if ( GetVar('Action', true) != 'm_cat_delete') { - return parent::Query_Item($sql,$this->GetPageOffset(),$this->GetPageRowCount()); + return parent::Query_Item($sql,$this->GetPageOffset(),$this->GetPageRowCount()); } - else { + else { return parent::Query_Item($sql); } } - } + } function Query_List($whereClause,$orderByClause=NULL,$JoinCats=TRUE,$fix_method='set_first') { @@ -1669,7 +1669,7 @@ if($JoinCats) { $cattable = GetTablePrefix()."CategoryItems"; - $t = $this->SourceTable; + $t = $this->SourceTable; $sql = "SELECT *,CategoryId FROM $t INNER JOIN $cattable ON $cattable.ItemResourceId=$t.ResourceId"; } else @@ -1685,20 +1685,20 @@ { $sql .= " ".$orderByClause; } - else + else { $sql .= " ORDER BY $orderByClause"; } } if($objSession->HasSystemPermission("DEBUG.LIST")) echo $sql."
\n"; - + return $this->Query_Item($sql, null, $fix_method); - } - + } + function GetPerPage() - { + { //echo "Getting Per Page ".get_class($this)."
"; // return category perpage global $objConfig; @@ -1708,7 +1708,7 @@ //echo "Returning: $PerPage
"; return $PerPage; } - + /** * Returns current page from env var * @@ -1719,68 +1719,68 @@ $var_name = preg_replace('/(.*)_update$/', '\\1', $this->PageEnvar); return $GLOBALS[$var_name]['p']; } - + function FixInvalidPage($fix_method = 'set_first') { // in case if current page > total page count, // then set current page to last possible "set_last" // or first possible "set_first" $PerPage = $this->GetPerPage(); $NumPages = ceil( $this->GetNumPages($PerPage) ); -/* +/* echo "=====
"; echo "Class ".get_class($this).": Page ".$this->Page." of $NumPages
"; echo "PerPage: $PerPage
"; echo "Items Queries: ".$this->QueryItemCount."
"; echo "=====
"; -*/ +*/ // if ( $this->getEnvPage() ) $fix_method = 'set_current'; - + if( ($this->Page > $NumPages || $this->Page == 0) && $PerPage != -1) { switch($fix_method) { - case 'set_first': - $this->Page = 1; - //echo "Move 2 First (class ".get_class($this).")
"; + case 'set_first': + $this->Page = 1; + //echo "Move 2 First (class ".get_class($this).")
"; break; - case 'set_last': - $this->Page = $NumPages; - //echo "Move 2 Last (class ".get_class($this).")
"; + case 'set_last': + $this->Page = $NumPages; + //echo "Move 2 Last (class ".get_class($this).")
"; break; case 'set_current': $this->Page = $this->getEnvPage(); - //echo "Move 2 Page reflected in env (class ".get_class($this).")
"; + //echo "Move 2 Page reflected in env (class ".get_class($this).")
"; break; } $this->SaveNewPage(); } } - + function SaveNewPage() { - // redefine in each list, should save to env array new page value - + // redefine in each list, should save to env array new page value + } - + function GetPageLinkList($dest_template=NULL,$page = "",$PagesToList=10, $HideEmpty=TRUE,$EnvSuffix = '', $extra_attributes = '') { global $objConfig, $var_list_update, $var_list; $url_params = $EnvSuffix ? ExtractParams($EnvSuffix) : Array(); - + $v= $this->PageEnvar; - - global ${$v}; - + + global ${$v}; + // if(!strlen($page)) $page = GetIndexURL(2); $PerPage = $objConfig->Get($this->PerPageVar); if($PerPage < 1) $PerPage = 20; $NumPages = ceil( $this->GetNumPages($PerPage) ); if($NumPages == 1 && $HideEmpty) return ''; - + $var_list_update['t'] = isset($dest_template) && $dest_template ? $dest_template : $var_list['t']; $o = ''; @@ -1802,7 +1802,7 @@ if($StartPage > 1) { ${$v}[$this->PageEnvarIndex] = $this->Page - $PagesToList; - + $prev_url = HREF_Wrapper('', $url_params); $o .= '<<'; } @@ -1829,24 +1829,24 @@ } unset(${$v}[$this->PageEnvarIndex],$var_list_update["t"] ); return $o; - } - + } + function GetAdminPageLinkList($url) { global $objConfig; - + $update =& $GLOBALS[$this->PageEnvar]; // env_var_update - + $page_backup = $update[$this->PageEnvarIndex]; - + // insteresting stuff :) if(!$this->PerPageVar) $this->PerPageVar = "Perpage_Links"; $PerPage = $objConfig->Get($this->PerPageVar); if($PerPage < 1) $PerPage = 20; - + $NumPages = ceil($this->GetNumPages($PerPage)); - + //echo $this->CurrentPage." of ".$NumPages." Pages"; if($this->Page > $NumPages) $this->Page = $NumPages; @@ -1855,7 +1855,7 @@ if($StartPage < 1) $StartPage = 1; $EndPage = $StartPage + 9; if($EndPage > $NumPages) - { + { $EndPage = $NumPages; $StartPage = $EndPage-9; if($StartPage < 1) $StartPage = 1; @@ -1870,7 +1870,7 @@ $o .= '<<'; } - + for($p = $StartPage; $p <= $EndPage; $p++) { if($p != $this->Page) @@ -1891,8 +1891,8 @@ $o .= ' >>'; } $update[$this->PageEnvarIndex] = $page_backup; - return $o; - } + return $o; + } } function ParseClipboard($clip) @@ -1905,7 +1905,7 @@ $prefix = GetTablePrefix(); if(substr($table,0,strlen($prefix))==$prefix) $table = substr($table,strlen($prefix)); - + $subparts = explode("=",$parts[2],2); $idfield = $subparts[0]; $idlist = $subparts[1]; @@ -1922,7 +1922,7 @@ function UpdateCategoryItems($item,$NewCatList,$PrimaryCatId = false) { global $objCatList; - + $CurrentList = explode(",",$item->CategoryMemberList()); $del_list = array(); $ins_list = array(); @@ -1932,7 +1932,7 @@ { if(strlen(trim($NewCatList))==0) $NewCatList = $objCatList->CurrentCategoryID(); - + $NewCatList = explode(",",$NewCatList); } //print_r($NewCatList); @@ -1956,28 +1956,28 @@ } for($i=0;$iRemoveFromCategory($cat); } if($PrimaryCatId !== false) $item->SetPrimaryCategory($PrimaryCatId); } -class clsCatItemList extends clsItemList +class clsCatItemList extends clsItemList { var $PerPageVarLong; var $PerPageShortVar; var $Query_SortField; var $Query_SortOrder; var $ItemType; - + function clsCatItemList() { $this->ClsItemList(); $this->Query_SortField = array(); $this->Query_SortOrder = array(); - } - - function QueryOrderByClause($EditorsPick=FALSE,$Priority=FALSE,$UseTableName=FALSE) + } + + function QueryOrderByClause($EditorsPick=FALSE,$Priority=FALSE,$UseTableName=FALSE) { global $objSession; @@ -2006,7 +2006,7 @@ { $FieldVar = $this->Query_SortField[$x]; $OrderVar = $this->Query_SortOrder[$x]; - + if(is_object($objSession)) { $FieldVarData = $objSession->GetPersistantVariable($FieldVar); @@ -2029,7 +2029,7 @@ //echo "ORDER BY: $OrderBy
"; return $OrderBy; } - + function AddSortField($SortField, $SortOrder) { if(strlen($SortField)) @@ -2038,38 +2038,38 @@ $this->Query_SortOrder[] = $SortOrder; } } - + function ClearSortFields() { $this->Query_SortField = array(); $this->Query_SortOrder = array(); } - + /* skeletons in this closet */ - + function GetNewValue($CatId=NULL) { return 0; } - + function GetPopValue($CategoryId=NULL) { return 0; - } - + } + /* end of skeletons */ - + function GetCountSQL($PermName,$CatId=NULL, $GroupId=NULL, $AdditonalWhere="") { global $objSession, $objPermissions, $objCatList; - + $ltable = $this->SourceTable; $acl = $objSession->GetACLClause(); $cattable = GetTablePrefix()."CategoryItems"; $CategoryTable = GetTablePrefix()."Category"; - $ptable = GetTablePrefix()."PermCache"; + $ptable = GetTablePrefix()."PermCache"; $VIEW = $objPermissions->GetPermId($PermName); - + $sql = "SELECT count(*) as CacheVal FROM $ltable "; $sql .="INNER JOIN $cattable ON ($cattable.ItemResourceId=$ltable.ResourceId) "; $sql .="INNER JOIN $CategoryTable ON ($CategoryTable.CategoryId=$cattable.CategoryId) "; @@ -2079,39 +2079,39 @@ if(strlen($AdditonalWhere)>0) { $sql .= "AND (".$AdditonalWhere.")"; - } - + } + return $sql; } - + function SqlCategoryList($attribs = array()) - { + { $CatTable = GetTablePrefix()."CategoryItems"; $t = $this->SourceTable; - + $sql = "SELECT *,$CatTable.CategoryId FROM $t INNER JOIN $CatTable ON $CatTable.ItemResourceId=$t.ResourceId "; $sql .="WHERE ($CatTable.CategoryId=".$catid." AND $t.Status=1)"; - + return $sql; } - - + + function CategoryCount($attribs=array()) - { + { global $objCatList, $objCountCache; - + $cat = $attribs["_catid"]; if(!is_numeric($cat)) { $cat = $objCatList->CurrentCategoryID(); } if((int)$cat>0) - $c = $objCatList->GetCategory($cat); - + $c = $objCatList->GetCategory($cat); + $CatTable = GetTablePrefix()."CategoryItems"; $t = $this->SourceTable; - - $sql = "SELECT count(*) as MyCount FROM $t INNER JOIN $CatTable ON ($CatTable.ItemResourceId=$t.ResourceId) "; + + $sql = "SELECT count(*) as MyCount FROM $t INNER JOIN $CatTable ON ($CatTable.ItemResourceId=$t.ResourceId) "; if($attribs["_subcats"]) { $ctable = $objCatList->SourceTable; @@ -2125,12 +2125,12 @@ $sql .=") AND ($t.Status=1)"; } else - $sql .="WHERE ($CatTable.CategoryId=".$cat." AND $t.Status=1) "; - + $sql .="WHERE ($CatTable.CategoryId=".$cat." AND $t.Status=1) "; + if($attribs["_today"]) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); - $sql .= "AND ($t.CreatedOn>=$today) "; + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $sql .= "AND ($t.CreatedOn>=$today) "; } //echo $sql."

\n"; $rs = $this->adodbConnection->Execute($sql); @@ -2139,11 +2139,11 @@ $ret = (int)$rs->fields["MyCount"]; return $ret; } - + function SqlGlobalCount($attribs=array()) { global $objSession; - + $where = ''; $p = $this->BasePermission.'.VIEW'; $t = $this->SourceTable; @@ -2152,19 +2152,19 @@ $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); $where = "($t.CreatedOn>=$today)"; } - + $GroupList = getArrayValue($attribs,'_grouponly') ? $objSession->Get('GroupList') : null; $sql = $this->GetCountSQL($p,NULL,$GroupList,$where); return $sql; } - + function DoGlobalCount($attribs) { global $objCountCache; - + $cc = $objCountCache->GetValue($this->CacheListType("_"),$this->ItemType,$this->CacheListExtraId("_"),(int)getArrayValue($attribs,'_today'), 3600); if(!is_numeric($cc)) - { + { $sql = $this->SqlGlobalCount($attribs); $ret = QueryCount($sql); $objCountCache->SetValue($this->CacheListType("_"),$this->ItemType,$this->CacheListExtraId("_"),(int)getArrayValue($attribs,'_today'),$ret); @@ -2173,22 +2173,22 @@ $ret = $cc; return $ret; } - + function CacheListExtraId($ListType) { global $objSession; - + if(!strlen($ListType)) - $ListType="_"; + $ListType="_"; switch($ListType) - { + { case "_": - $ExtraId = $objSession->Get("GroupList"); + $ExtraId = $objSession->Get("GroupList"); break; case "category": $ExtraId = $objSession->Get("GroupList"); - break; + break; case "myitems": $ExtraId = $objSession->Get("PortalUserId"); break; @@ -2206,12 +2206,12 @@ break; case "new": $ExtraId = $objSession->Get("GroupList"); - break; + break; } return $ExtraId; } - - + + /** * Return all listype (from tags) to id mappings * @@ -2222,46 +2222,46 @@ { return Array('_' => 0, 'category' => 1, 'myitems' => 2, 'hot' => 3, 'pop' => 4, 'pick' => 5, 'favorites' => 6, 'new' => 8); } - + function CacheListType($ListType) { if(empty($ListType)) $ListType='_'; - + $mapping = $this->GetListTypes(); - + return $mapping[$ListType]; - } + } function PerformItemCount($attribs=array()) { global $objCountCache, $objSession; - + $ret = ""; $sql = ""; $ListType = getArrayValue($attribs,'_listtype'); if(!strlen($ListType)) $ListType="_"; - + $ListTypeId = $this->CacheListType($ListType); - //echo "ListType: $ListType ($ListTypeId)
\n"; + //echo "ListType: $ListType ($ListTypeId)
\n"; $ExtraId = $this->CacheListExtraId($ListType); switch($ListType) - { + { case "_": $ret = $this->DoGlobalCount($attribs); break; - case "category": + case "category": $ret = $this->CategoryCount($attribs); - break; + break; case "myitems": - $sql = $this->SqlMyItems($attribs); + $sql = $this->SqlMyItems($attribs); break; case "hot": - $sql = $this->SqlHotItems($attribs); + $sql = $this->SqlHotItems($attribs); break; case "pop": - $sql = $this->SqlPopItems($attribs); + $sql = $this->SqlPopItems($attribs); break; case "pick": $sql = $this->SqlPickItems($attribs); @@ -2282,7 +2282,7 @@ if(is_numeric($ListTypeId) && $ListTypeId) { $cc = $objCountCache->GetValue($ListTypeId,$this->ItemType,$ExtraId,(int)getArrayValue($attribs,'_today'), 3600); - + if(!is_numeric($cc) || $attribs['_nocache'] == 1) { $ret = QueryCount($sql); @@ -2294,32 +2294,32 @@ else $ret = QueryCount($sql); } - - return $ret; + + return $ret; } - + function GetJoinedSQL($PermName, $CatId=NULL, $AdditionalWhere="", $LoadOnlyPrimary = true) { global $objSession, $objPermissions; - + $ltable = $this->SourceTable; $acl = $objSession->GetACLClause(); $cattable = GetTablePrefix()."CategoryItems"; $CategoryTable = GetTablePrefix()."Category"; - $ptable = GetTablePrefix()."PermCache"; + $ptable = GetTablePrefix()."PermCache"; $VIEW = $objPermissions->GetPermId($PermName); $sql ="INNER JOIN $cattable ON ($cattable.ItemResourceId=$ltable.ResourceId) "; $sql .="INNER JOIN $CategoryTable ON ($CategoryTable.CategoryId=$cattable.CategoryId) "; $sql .= "INNER JOIN $ptable ON ($cattable.CategoryId=$ptable.CategoryId) "; - + // here will come checking for PrimaryCat on search if ($LoadOnlyPrimary) { $sql .="WHERE ($acl AND PermId=$VIEW AND PrimaryCat=1 AND $CategoryTable.Status=1) "; } else { $sql .="WHERE ($acl AND PermId=$VIEW AND $CategoryTable.Status=1) "; } - + if(is_numeric($CatId) && $CatId > 0) { $sql .= " AND ($CategoryTable.CategoryId=$CatId) "; @@ -2330,16 +2330,16 @@ } return $sql; } - + /** * Not used in php files directly [comment by Alex] * * @param unknown_type $attribs * @return unknown - * + * */ function CountFavorites($attribs) - { + { if($attribs["_today"]) { global $objSession, $objConfig, $objPermissions; @@ -2350,15 +2350,15 @@ $cattable = GetTablePrefix()."CategoryItems"; $CategoryTable = GetTablePrefix()."Category"; $ptable = GetTablePrefix()."PermCache"; - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); - + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $where = "PortalUserId=".$objSession->Get("PortalUserId")." AND $ltable.Status=1"; - $where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType; + $where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType; $p = $this->BasePermission.".VIEW"; - + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $sql = "SELECT $ltable.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavBar')." AS CachedNavBar FROM $favtable INNER JOIN $ltable ON ($favtable.ResourceId=$ltable.ResourceId) "; - $sql .= $this->GetJoinedSQL($p,NULL,$where); + $sql .= $this->GetJoinedSQL($p,NULL,$where); $ret = QueryCount($sql); } else @@ -2367,101 +2367,101 @@ { $this->ListType = "favorites"; $this->LoadFavorites($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; } return $ret; } - - - + + + function CountPickItems($attribs) - { + { if (!$this->ListType == "pick") { $this->ListType = "pick"; $this->LoadPickItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - + function CountMyItems($attribs) - { + { if (!$this->ListType == "myitems") { $this->ListType = "myitems"; $this->LoadMyItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - + function CountHotItems($attribs) - { + { if (!$this->ListType == "hotitems") { $this->ListType = "hotitems"; $this->LoadHotItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - + function CountNewItems($attribs) - { + { if (!$this->ListType == "newitems") { $this->ListType = "newitems"; $this->LoadNewItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - + function CountPopItems($attribs) - { + { if (!$this->ListType == "popitems") { $this->ListType = "popitems"; $this->LoadPopItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - - + + function CountSearchItems($attribs) - { + { if (!$this->ListType == "search") { $this->ListType = "search"; $this->LoadSearchItems($attribs); - $ret = $this->QueryItemCount; + $ret = $this->QueryItemCount; } else $ret = $this->QueryItemCount; - + return $ret; } - + function SqlFavorites($attribs) { global $objSession, $objConfig, $objPermissions; @@ -2472,15 +2472,15 @@ $cattable = GetTablePrefix()."CategoryItems"; $CategoryTable = GetTablePrefix()."Category"; $ptable = GetTablePrefix()."PermCache"; - + $where = "PortalUserId=".$objSession->Get("PortalUserId")." AND $ltable.Status=1"; if($attribs["_today"]) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); - $where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType; + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $where .= " AND $favtable.Modified >= $today AND ItemTypeId=".$this->ItemType; } $p = $this->BasePermission.".VIEW"; - + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $sql = "SELECT $ltable.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavBar')." AS CachedNavBar FROM $favtable INNER JOIN $ltable ON ($favtable.ResourceId=$ltable.ResourceId) "; $sql .= $this->GetJoinedSQL($p,NULL,$where); @@ -2490,54 +2490,54 @@ $sql .= " ".$OrderBy; return $sql; } - + function LoadFavorites($attribs) { global $objSession, $objCountCache, $objConfig; - + $sql = $this->SqlFavorites($attribs); - + if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; if($attribs["_shortlist"]) { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else + else $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("favorites"),$this->ItemType,$this->CacheListExtraId("favorites"),(int)$attribs["_today"],3600); + + $CachedCount = $objCountCache->GetValue($this->CacheListType("favorites"),$this->ItemType,$this->CacheListExtraId("favorites"),(int)$attribs["_today"],3600); if(!is_numeric($CachedCount)) { $this->QueryItemCount = QueryCount($sql); $objCountCache->SetValue($this->CacheListType("favorites"),$this->ItemType,$this->CacheListExtraId("favorites"),(int)$attribs["_today"],$this->QueryItemCount); } else $this->QueryItemCount = (int)$CachedCount; - - return $this->Query_Item($sql); + + return $this->Query_Item($sql); } - + function SqlPickItems($attribs) { global $objSession, $objCatList; $catid = (int)getArrayValue($attribs,'_catid'); $scope = (int)getArrayValue($attribs,'_scope'); - //$JoinCats = (int)$attribs["_catinfo"] || $scope; - + //$JoinCats = (int)$attribs["_catinfo"] || $scope; + $TableName = $this->SourceTable; if($scope) { - if (!$catid) + if (!$catid) { $catid = $objCatList->CurrentCategoryID(); - } + } $where = GetTablePrefix()."CategoryItems.CategoryId =".$catid." AND ".$TableName.".EditorsPick=1 AND ".$TableName.".Status=1"; } else @@ -2547,44 +2547,44 @@ } if(getArrayValue($attribs,'_today')) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); $where .= " AND ($TableName.CreatedOn>=$today)"; - } + } $CategoryTable = GetTablePrefix()."Category"; $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavBar FROM $TableName "; $p = $this->BasePermission.".VIEW"; $sql .= $this->GetJoinedSQL($p,$catid,$where); - + $OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE); - $sql .= " ".$OrderBy; - - //echo "SQL: $sql
"; - + $sql .= " ".$OrderBy; + + //echo "SQL: $sql
"; + return $sql; - } - + } + function LoadPickItems($attribs) { global $objSession, $objCountCache, $objConfig; - - $sql = $this->SqlPickItems($attribs); + + $sql = $this->SqlPickItems($attribs); if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; - + if($attribs["_shortlist"]) - { + { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else + else $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("pick"),$this->ItemType,$this->CacheListExtraId("pick"),(int)getArrayValue($attribs,'_today'),3600); + + $CachedCount = $objCountCache->GetValue($this->CacheListType("pick"),$this->ItemType,$this->CacheListExtraId("pick"),(int)getArrayValue($attribs,'_today'),3600); if(!is_numeric($CachedCount)) { $this->QueryItemCount= QueryCount($sql); @@ -2593,9 +2593,9 @@ else $this->QueryItemCount=$CachedCount; - return $this->Query_Item($sql); + return $this->Query_Item($sql); } - + function SqlMyItems($attribs= array()) { global $objSession; @@ -2604,77 +2604,77 @@ $where = " ".$TableName.".Status>-1 AND ".$TableName.".CreatedById=".$objSession->Get("PortalUserId"); if(getArrayValue($attribs,'_today')) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); $where .= " AND ($TableName.CreatedOn>=$today)"; } $CategoryTable = GetTablePrefix()."Category"; $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavBar FROM $TableName "; $p = $this->BasePermission.".VIEW"; $sql .= $this->GetJoinedSQL($p,null,$where); // maybe null should be replaced by some CategoryId - + $OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE); - $sql .= " ".$OrderBy; - + $sql .= " ".$OrderBy; + return $sql; - } - + } + function LoadMyItems($attribs=array()) - { - global $objSession,$objCountCache; + { + global $objSession,$objCountCache; $sql = $this->SqlMyItems($attribs); if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; if($attribs["_shortlist"]) { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else - $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("myitems"),$this->ItemType,$this->CacheListExtraId("myitems"),(int)$attribs["_today"],3600); + else + $this->PerPageVar = $this->PerPageVarLong; + + $CachedCount = $objCountCache->GetValue($this->CacheListType("myitems"),$this->ItemType,$this->CacheListExtraId("myitems"),(int)$attribs["_today"],3600); if(!is_numeric($CachedCount)) { $this->QueryItemCount= QueryCount($sql); $objCountCache->SetValue($this->CacheListType("myitems"),$this->ItemType,$this->CacheListExtraId("myitems"),(int)$attribs["_today"],$this->QueryItemCount); } else $this->QueryItemCount=$CachedCount; - - return $this->Query_Item($sql); - } - + + return $this->Query_Item($sql); + } + function SqlNewItems($attribs = array()) { global $objSession, $objCatList; $catid = (int)getArrayValue($attribs,'_catid'); $scope = (int)getArrayValue($attribs,'_scope'); $show_since_last = (int)getArrayValue($attribs,'_show_since_last'); - //$JoinCats = (int)$attribs["_catinfo"] || $scope; + //$JoinCats = (int)$attribs["_catinfo"] || $scope; //echo "Last: $scope

"; $TableName = $this->SourceTable; if(getArrayValue($attribs,'_today')) { - $cutoff = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $cutoff = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); } else { if($scope) { - if (!$catid) + if (!$catid) { $catid = $objCatList->CurrentCategoryID(); - } + } if (!$show_since_last) { $cutoff = $this->GetNewValue($catid); } - else { + else { $cutoff = $scope; } } @@ -2683,16 +2683,16 @@ } if($scope) { - if (!$catid) + if (!$catid) { $catid = $objCatList->CurrentCategoryID(); - } - + } + if (!$show_since_last) { - $where = "CategoryId =".$catid." AND ((".$TableName.".CreatedOn >=".$cutoff." AND ".$TableName.".NewItem != 0) OR ".$TableName.".NewItem=1 ) AND ".$TableName.".Status=1 "; + $where = "CategoryId =".$catid." AND ((".$TableName.".CreatedOn >=".$cutoff." AND ".$TableName.".NewItem != 0) OR ".$TableName.".NewItem=1 ) AND ".$TableName.".Status=1 "; } else { - $where = $TableName.".CreatedOn >=".$cutoff." AND ".$TableName.".Status=1 "; + $where = $TableName.".CreatedOn >=".$cutoff." AND ".$TableName.".Status=1 "; } } else @@ -2705,194 +2705,194 @@ $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavBar FROM $TableName "; $p = $this->BasePermission.".VIEW"; $sql .= $this->GetJoinedSQL($p,$catid,$where); - + $OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE); - $sql .= " ".$OrderBy; - //echo "SQL: $sql

"; + $sql .= " ".$OrderBy; + //echo "SQL: $sql

"; return $sql; } function LoadNewItems($attribs) { global $objSession,$objCountCache,$objConfig; - + $sql = $this->SqlNewItems($attribs); - + if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; if( getArrayValue($attribs,'_shortlist') ) { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else + else $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("new"),$this->ItemType,$this->CacheListExtraId("new"),(int)getArrayValue($attribs,'_today'),3600); + + $CachedCount = $objCountCache->GetValue($this->CacheListType("new"),$this->ItemType,$this->CacheListExtraId("new"),(int)getArrayValue($attribs,'_today'),3600); if(!is_numeric($CachedCount)) { $this->QueryItemCount= QueryCount($sql); $objCountCache->SetValue($this->CacheListType("new"),$this->ItemType,$this->CacheListExtraId("new"),(int)getArrayValue($attribs,'_today'),$this->QueryItemCount); } else - $this->QueryItemCount=$CachedCount; - + $this->QueryItemCount=$CachedCount; + $ret = $this->Query_Item($sql); - return $ret; - } + return $ret; + } function SqlPopItems($attribs) { global $objSession, $objCatList; $catid = (int)$attribs["_catid"]; $scope = (int)$attribs["_scope"]; - //$JoinCats = (int)$attribs["_catinfo"] || $scope; - + //$JoinCats = (int)$attribs["_catinfo"] || $scope; + $TableName = $this->SourceTable; if($scope) { - if (!$catid) + if (!$catid) { $catid = $objCatList->CurrentCategoryID(); - } + } $where = "CategoryId =".$catid." AND ((".$TableName.".Hits >=".$this->GetLinkPopValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1"; } - else + else { $where = "((".$TableName.".CachedRating >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0 ) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 "; - + $where = "((".$TableName.".Hits >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 "; } if($attribs["_today"]) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); $where .= " AND ($TableName.CreatedOn>=$today)"; - } + } $CategoryTable = GetTablePrefix()."Category"; $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavBar FROM $TableName "; $p = $this->BasePermission.".VIEW"; $sql .= $this->GetJoinedSQL($p,$catid,$where); - + $OrderBy = $this->QueryOrderByClause(TRUE,TRUE,TRUE); $sql .= " ".$OrderBy; - + return $sql; } - + function LoadPopItems($attribs) { global $objSession,$objCountCache; $sql = $this->SqlPopItems($attribs); - + if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; if($attribs["_shortlist"]) { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else + else $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("pop"),$this->ItemType,$this->CacheListExtraId("pop"),(int)$attribs["_today"],3600); + + $CachedCount = $objCountCache->GetValue($this->CacheListType("pop"),$this->ItemType,$this->CacheListExtraId("pop"),(int)$attribs["_today"],3600); if(!is_numeric($CachedCount)) { $this->QueryItemCount= QueryCount($sql); $objCountCache->SetValue($this->CacheListType("pop"),$this->ItemType,$this->CacheListExtraId("pop"),(int)$attribs["_today"],$this->QueryItemCount); } else $this->QueryItemCount=$CachedCount; - - return $this->Query_Item($sql); - } + return $this->Query_Item($sql); + } + function SqlHotItems($attribs) { global $objSession, $objCatList; $catid = (int)$attribs["_catid"]; $scope = (int)$attribs["_scope"]; -// $JoinCats = (int)$attribs["_catinfo"] || $scope; +// $JoinCats = (int)$attribs["_catinfo"] || $scope; - $TableName = $this->SourceTable; - - $OrderBy = $TableName.".CachedRating DESC"; + $TableName = $this->SourceTable; + $OrderBy = $TableName.".CachedRating DESC"; + if($scope) { - if (!$catid) + if (!$catid) { $catid = $objCatList->CurrentCategoryID(); - } + } $where = "CategoryId =".$catid." AND ((".$TableName.".CachedRating >=".$this->GetHotValue()." AND ".$TableName.".PopItem !=0) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1"; } else { $where = "((".$TableName.".CachedRating >=".$this->GetPopValue()." AND ".$TableName.".PopItem !=0 ) OR ".$TableName.".PopItem=1) AND ".$TableName.".Status=1 "; } - + if($attribs["_today"]) { - $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); + $today = adodb_mktime(0,0,0,adodb_date("m"),adodb_date("d"),adodb_date("Y")); $where .= " AND ($TableName.CreatedOn>=$today)"; - } + } $CategoryTable = GetTablePrefix()."Category"; $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $sql = "SELECT $TableName.*,$CategoryTable.CategoryId,$CategoryTable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavBar FROM $TableName "; $p = $this->BasePermission.".VIEW"; - $CatId = !$scope? NULL : $catid; + $CatId = !$scope? NULL : $catid; $sql .= $this->GetJoinedSQL($p,$CatId,$where); - + if(strlen($OrderBy)) - $sql .= " ORDER BY $OrderBy "; - + $sql .= " ORDER BY $OrderBy "; + return $sql; } - + function LoadHotItems($attribs) { - global $objSession,$objCountCache; - + global $objSession,$objCountCache; + $sql = $this->SqlHotItems($attribs); if($objSession->HasSystemPermission("DEBUG.LIST")) echo htmlentities($sql,ENT_NOQUOTES)."
\n"; - + if($attribs["_shortlist"]) { if ($objConfig->Get($this->PerPageShortVar) > 0) { - $this->PerPageVar = $this->PerPageShortVar; + $this->PerPageVar = $this->PerPageShortVar; } else { $this->PerPageVar = $this->PerPageVarLong; } } - else - $this->PerPageVar = $this->PerPageVarLong; - - $CachedCount = $objCountCache->GetValue($this->CacheListType("hot"),$this->ItemType,$this->CacheListExtraId("hot"),(int)$attribs["_today"], 0); + else + $this->PerPageVar = $this->PerPageVarLong; + + $CachedCount = $objCountCache->GetValue($this->CacheListType("hot"),$this->ItemType,$this->CacheListExtraId("hot"),(int)$attribs["_today"], 0); if(!is_numeric($CachedCount)) { $this->QueryItemCount= QueryCount($sql); $objCountCache->SetValue($this->CacheListType("hot"),$this->ItemType,$this->CacheListExtraId("hot"),(int)$attribs["_today"],$this->QueryItemCount); } else $this->QueryItemCount=$CachedCount; - - return $this->Query_Item($sql); + + return $this->Query_Item($sql); } - + function SqlSearchItems($attribs = array()) { global $objConfig, $objItemTypes, $objSession, $objPermissions, $CountVal; @@ -2907,34 +2907,34 @@ $ptable = GetTablePrefix()."PermCache"; $p = $this->BasePermission.".VIEW"; $i = new $this->classname(); - + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); $sql = "SELECT $cattable.CategoryId,$cattable.".$ml_formatter->LangFieldName('CachedNavbar')." AS CachedNavbar,$ltable.*, Relevance FROM $stable "; $sql .= "INNER JOIN $ltable ON ($stable.ItemId=$ltable.".$i->id_field.") "; - + $where = "ItemType=".$this->ItemType." AND $ltable.Status=1"; - + $load_multiple = $objConfig->Get("Search_ShowMultiple_".$attribs['multiple']); $LoadOnlyPrimary = true; - + if ($load_multiple == 1) { $LoadOnlyPrimary = false; } - - $sql .= $this->GetJoinedSQL($p,NULL,$where, $LoadOnlyPrimary); - $tmp = $this->QueryOrderByClause(FALSE,TRUE,TRUE); + + $sql .= $this->GetJoinedSQL($p,NULL,$where, $LoadOnlyPrimary); + $tmp = $this->QueryOrderByClause(FALSE,TRUE,TRUE); //echo "TMP: $tmp
"; //$tmp = substr($tmp,9); if(strlen($tmp)) { $sql .= $tmp.", "; - } - - $sql .= " EdPick DESC,Relevance DESC "; + } + + $sql .= " EdPick DESC,Relevance DESC "; //echo "SQL Search Items: $sql

"; - return $sql; + return $sql; } - + function LoadSearchItems($attribs = array()) { global $CountVal, $objSession; @@ -2959,9 +2959,9 @@ //echo "SQL: ".$sql."

"; $CountVal[$this->ItemType] = $this->QueryItemCount; } - + } - + /** * Updates count cache for selected ids in list * @@ -2972,18 +2972,18 @@ { $db =& GetADODBConnection(); if(is_array($item_ids)) $item_ids=implode(',',$item_ids); - + $sql = 'SELECT ResourceId FROM '.$this->SourceTable.' WHERE '.$this->GetIDField().' IN ('.$item_ids.')'; $resource_ids=$db->GetCol($sql); $sql='SELECT CategoryId FROM '.GetTablePrefix().'CategoryItems WHERE ItemResourceId IN ('.implode(',',$resource_ids).')'; $cat_ids=$db->GetCol($sql); UpdateCategoryCount($this->ItemType, $cat_ids, $this->GetListTypes()); } - + function PasteFromClipboard($TargetCat,$NameField="") { global $objSession,$objCatList; - + $clip = $objSession->GetVariable("ClipBoard"); if(strlen($clip)) { @@ -2992,40 +2992,40 @@ $item_ids = explode(",",$ClipBoard["ids"]); for($i=0;$iGetItem($item_ids[$i]); if(!$IsCopy) // paste to other category then current - { - $item->MoveToCategory($ClipBoard["source"],$TargetCat); + { + $item->MoveToCategory($ClipBoard["source"],$TargetCat); $clip = str_replace("CUT","COPY",$clip); $objSession->SetVariable("ClipBoard",$clip); } else - { + { $item->CopyToNewResource($TargetCat,$NameField); // create item copy, but with new ResourceId $item->AddToCategory($TargetCat); UpdateCategoryCount($item->type,$TargetCat, $this->GetListTypes() ); - + } } } } - + function AdminPrintItems($template) { // prints item listing for admin (browse/advanced view) tabs $o = ''; - + $i = 1; - + $topleft = 0; $topright = 0; $rightcount = 0; $total_items = $this->NumItems(); $topleft = ceil($total_items / 2); $topright = $total_items - $topleft; - - for($x = 0; $x < $topleft; $x++) + + for($x = 0; $x < $topleft; $x++) { //printingleft $item = $this->Items[$x]; @@ -3036,13 +3036,13 @@ } $o .= $item->AdminParseTemplate($template); $i++; - + //printingright - if ($rightcount < $topright && ( ($x + $topleft) < $total_items) ) + if ($rightcount < $topright && ( ($x + $topleft) < $total_items) ) { $item = $this->Items[ $x + $topleft ]; if ($i > 2) - { + { $o.="\n"; $i = 1; } @@ -3051,73 +3051,73 @@ $rightcount++; } } - $o .= "\n
\n"; + $o .= "\n\n"; return $o; } - + } // -------------- NEW CLASSES ----------------------- class DBList { - + // table related attributes var $db = null; var $table_name = ''; var $LiveTable = ''; var $EditTable = ''; - - + + // record related attributes var $records = Array(); var $record_count = 0; var $cur_rec = -1; // "-1" means no records, or record index otherwise - + // query related attributes var $SelectSQL = "SELECT * FROM %s"; - + function DBList() { // use $this->SetTable('live', 'table name'); // in inherited constructors to set table for list - $this->db =&GetADODBConnection(); + $this->db =&GetADODBConnection(); } - + function SetTable($action, $table_name = null) { // $action = {'live', 'restore','edit'} switch($action) { - case 'live': + case 'live': $this->LiveTable = $table_name; $this->table_name = $this->LiveTable; break; - case 'restore': - $this->table_name = $this->LiveTable; + case 'restore': + $this->table_name = $this->LiveTable; break; case 'edit': global $objSession; $this->table_name = $objSession->GetEditTable($this->LiveTable); break; } } - + function Clear() { // no use of this method at a time :) $this->records = Array(); $this->record_count = 0; - $this->cur_rec = -1; + $this->cur_rec = -1; } - + function Query() { - // query list + // query list $sql = sprintf($this->SelectSQL, $this->table_name); // echo "SQL: $sql
"; $rs =& $this->db->Execute($sql); - + if( $this->db->ErrorNo() == 0 ) { $this->records = $rs->GetRows(); @@ -3127,11 +3127,11 @@ else return false; } - + function ProcessList($callback_method) { // process list using user-defined method called - // with one parameter - current record fields + // with one parameter - current record fields // (associative array) if($this->record_count > 0) { @@ -3140,17 +3140,17 @@ { if( method_exists($this, $callback_method) ) $this->$callback_method( $this->GetCurrent() ); - $this->cur_rec++; + $this->cur_rec++; } } } - + function &GetCurrent() { // return currently processed record (with change ability) return ($this->cur_rec != -1) ? $this->records[$this->cur_rec] : false; } - + function GetDBField($field_name) { $rec =& $this->GetCurrent(); Index: branches/unlabeled/unlabeled-1.4.2/core/units/general/helpers/mod_rewrite_helper.php =================================================================== diff -u -r6031 -r6078 --- branches/unlabeled/unlabeled-1.4.2/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 6031) +++ branches/unlabeled/unlabeled-1.4.2/core/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 6078) @@ -211,6 +211,12 @@ function GetItemTemplate($category, $module_prefix) { + if (!is_array($category)) { + $category = $this->Conn->GetRow(' + SELECT c.ParentPath, c.CategoryId FROM '.TABLE_PREFIX.'Category AS c + WHERE + c.CategoryId = '.$category); + } $parent_path = implode(',',explode('|', substr($category['ParentPath'], 1, -1))); // item template is stored in module' system custom field - need to get that field Id Index: branches/unlabeled/unlabeled-1.4.2/kernel/units/general/helpers/mod_rewrite_helper.php =================================================================== diff -u -r6031 -r6078 --- branches/unlabeled/unlabeled-1.4.2/kernel/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 6031) +++ branches/unlabeled/unlabeled-1.4.2/kernel/units/general/helpers/mod_rewrite_helper.php (.../mod_rewrite_helper.php) (revision 6078) @@ -211,6 +211,12 @@ function GetItemTemplate($category, $module_prefix) { + if (!is_array($category)) { + $category = $this->Conn->GetRow(' + SELECT c.ParentPath, c.CategoryId FROM '.TABLE_PREFIX.'Category AS c + WHERE + c.CategoryId = '.$category); + } $parent_path = implode(',',explode('|', substr($category['ParentPath'], 1, -1))); // item template is stored in module' system custom field - need to get that field Id Index: branches/unlabeled/unlabeled-1.31.2/kernel/include/searchitems.php =================================================================== diff -u -r4690 -r6078 --- branches/unlabeled/unlabeled-1.31.2/kernel/include/searchitems.php (.../searchitems.php) (revision 4690) +++ branches/unlabeled/unlabeled-1.31.2/kernel/include/searchitems.php (.../searchitems.php) (revision 6078) @@ -5,7 +5,7 @@ "word word" : contents between the quotes are treated as a single entity +/-"word word" is supported ignore words are not case sensitive -*/ +*/ class clsSearchLog extends clsItemDB { function clsSearchLog($id=NULL) @@ -21,12 +21,12 @@ function LoadFromDatabase($Id) { global $Errors; - + if(!isset($Id)) { $Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase"); return false; - } + } $sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->IdField()." = '%s'",$Id); $result = $this->adodbConnection->Execute($sql); if ($result === false) @@ -40,7 +40,7 @@ $this->SetFromArray($data); $this->Clean(); return true; - } + } } class clsSearchLogList extends clsItemCollection @@ -105,12 +105,12 @@ function LoadFromDatabase($Id) { global $Errors; - + if(!isset($Id)) { $Errors->AddError("error.AppError",NULL,'Internal error: LoadFromDatabase id',"",get_class($this),"LoadFromDatabase"); return false; - } + } $sql = sprintf("SELECT * FROM ".$this->tablename." WHERE ".$this->IdField()." = '%s'",$Id); $result = $this->adodbConnection->Execute($sql); if ($result === false) @@ -124,7 +124,7 @@ $this->SetFromArray($data); $this->Clean(); return true; - } + } } class clsEmailLogList extends clsItemCollection @@ -183,7 +183,7 @@ var $SourceTable; var $Relationships; var $Ignored_Words; - var $CatClause; + var $CatClause; var $Keywords; var $Phrase = ""; var $SearchType; @@ -226,30 +226,30 @@ { $limit = "LIMIT $Start,$PerPage"; } - $sql = "SELECT * FROM ".$this->ResultTable." ".$limit; + $sql = "SELECT * FROM ".$this->ResultTable." ".$limit; $this->Clear(); $rs = $this->adodbConnection->Execute($sql); return $this->Query_Item($sql); } - + function SetCategoryClause($whereclause) { $this->CatClause=$whereclause; } function AddRelationship($JoinTable,$JoinExpression=NULL) { - - $this->Relationships[$JoinTable]=$JoinExpression; + + $this->Relationships[$JoinTable]=$JoinExpression; } function SetKeywords($keywords) { - $this->Phrase=$keywords; + $this->Phrase=$keywords; $this->keywords = GetKeywords($keywords); } - + function AddSimpleCustomFields($main_prefix) { $table_to_module = Array( 'Category' => 'In-Portal', @@ -258,39 +258,50 @@ 'PortalUser' => 'In-Portal', 'News' => 'In-News'); $module = $table_to_module[$this->SourceTable]; - + $sql = 'SELECT Priority, CustomFieldId FROM '.TABLE_PREFIX.'SearchConfig WHERE ModuleName = '.$this->Conn->qstr($module).' AND SimpleSearch = 1 AND CustomFieldId > 0'; - + $search_config = $this->Conn->GetCol($sql, 'CustomFieldId'); if ($search_config) { $item_table = $this->Application->getUnitOption($main_prefix, 'TableName'); $custom_table = $this->Application->getUnitOption($main_prefix.'-cdata', 'TableName'); $this->AddRelationship($custom_table.' AS '.$main_prefix.'_custom_data', $main_prefix.'_custom_data.ResourceId = '.$item_table.'.ResourceId'); - + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); foreach ($search_config as $custom_id => $custom_priority) { $field_name = $main_prefix.'_custom_data.'.$ml_formatter->LangFieldName('cust_'.$custom_id); $this->FieldList[] = $field_name; $this->FieldWeight[$field_name] = $custom_priority; } } - } + } function AddSimpleFields($main_prefix) { $sql = "SELECT * FROM ".GetTablePrefix()."SearchConfig WHERE TableName='".$this->SourceTable."' AND SimpleSearch=1 AND CustomFieldId IS NULL"; //echo $sql; - foreach($this->Relationships as $Table=>$clause) + foreach($this->Relationships as $Table=>$clause) { if(strlen($Table)>0 && $Table != "Category") $sql .= " OR TableName='".$Table."'"; } $rs = $this->adodbConnection->Execute($sql); - + + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); + $lang = $this->Application->GetVar('m_lang'); while($rs && !$rs->EOF) { - $f = GetTablePrefix().$rs->fields["TableName"].".".$rs->fields["FieldName"]; + $config = $this->Application->getUnitOption($main_prefix, 'Fields'); + if (isset($config[$rs->fields["FieldName"]]) && $config[$rs->fields["FieldName"]]['formatter'] == 'kMultiLanguage') { + $f = GetTablePrefix().$rs->fields["TableName"].".".'l'.$lang.'_'.$rs->fields["FieldName"]; + $f_prim = GetTablePrefix().$rs->fields["TableName"].".".'l'.$this->Application->GetDefaultLanguageId().'_'.$rs->fields["FieldName"]; + $this->FieldList[] = $f_prim; + $this->FieldWeight[$f_prim] = $rs->fields["Priority"]; + } + else { + $f = GetTablePrefix().$rs->fields["TableName"].".".$rs->fields["FieldName"]; + } $this->FieldList[] = $f; $this->FieldWeight[$f] = $rs->fields["Priority"]; $rs->MoveNext(); @@ -304,14 +315,14 @@ /* build required keywords string */ if(count($this->keywords["required"])>0) - { - $required = $this->keywords["required"]; + { + $required = $this->keywords["required"]; for($i=0;$i0) { if($i>0) - { + { $or =" OR "; } else @@ -321,7 +332,7 @@ } } if(strlen($w)>0) - { + { $req_where = "(". $w.")"; } else @@ -330,19 +341,19 @@ $w = ""; $not_where=""; if(count($this->keywords["notallowed"])>0) - { + { $words = $this->keywords["notallowed"]; for($i=0;$i0) { if($i>0) - { + { $or =" AND "; } else $or = ""; - $w .= $or." ".$FieldName." NOT LIKE '%".$words[$i]."%'"; + $w .= $or." ".$FieldName." NOT LIKE '%".$words[$i]."%'"; $this->ExcludeWhereClause[$words[$i]][$FieldName] = '('.$FieldName." NOT LIKE '%".$words[$i]."%'"; if (substr($FieldName, 0, strlen(GetTablePrefix())) == GetTablePrefix()) { @@ -352,33 +363,33 @@ { $this->ExcludeWhereClause[$words[$i]][$FieldName] .= ' OR '.$FieldName.' IS NULL)'; // for custom fields } - } + } } if(strlen($w)>0) - { + { $not_where = "(".$w.")"; } else $not_where = ""; } - + $w=""; $normal = $this->keywords["normal"]; if(count($normal)>0) - { + { for($i=0;$i0) - { + { + if (strlen($normal[$i])>0) + { if($i>0) - { + { $or =" OR "; } else $or = ""; $w .= "$or $FieldName LIKE '%".$normal[$i]."%'"; } - } + } /*if(count($required)>0) $w .= " OR "; for($i=0;$i0) - { + { $where = "(".$w.")"; } else $where = ""; } $complete = BuildWhereClause($where, $req_where, $not_where, $this); - if ($complete) + if ($complete) { $this->WhereClauses[$FieldName]="(".$complete.")"; } - $this->Ignored_Words=$this->keywords["ignored"]; + $this->Ignored_Words=$this->keywords["ignored"]; } - + function PerformSearch($ItemType,$OrderBy=NULL,$InitTable=FALSE, $idlist=NULL) { static $SelectSQL, $OldItemType; @@ -425,15 +436,15 @@ $this->SourceTable = GetTablePrefix().$ctype->Get("SourceTable"); $result=0; $PopField = $ctype->Get("PopField"); - $RateField = $ctype->Get("RateField"); + $RateField = $ctype->Get("RateField"); //print_pre($this->keywords); - + if(!strlen($SelectSQL)) - { + { $typestr = str_pad($ItemType,2,"0",STR_PAD_LEFT); $SelectSQL = "SELECT "; $ifs = array(); - $weightsum = 0; + $weightsum = 0; foreach($this->FieldWeight as $w) { $weightsum += $w; } @@ -445,51 +456,51 @@ $s = array(); if(!$single) - { + { $full = trim(implode(" ",$this->keywords["normal"])); - $s[] = " (IF ($f LIKE '%$full%', ".$weightsum.", 0))"; + $s[] = " (IF ($f LIKE '%$full%', ".$weightsum.", 0))"; } foreach($this->keywords["normal"] as $k) - { + { if($k != $full || $single) - { + { $temp = " (IF ($f LIKE '%$k%', ".$weight.", 0))"; $s[] = $temp; } } - + foreach($this->keywords["required"] as $k) { if($this->RequiredRelevance>0) $weight = $this->FieldWeight[$f] + ($this->FieldWeight[$f]*($this->RequiredRelevance/100)); - + if($k != $full || $single) { $s[] = " (IF ($f LIKE '%$k%', ".$weight.", 0))"; } } - // echo "
";print_r($s); echo "
"; + // echo "
";print_r($s); echo "
"; $txt = implode("+",$s); //echo $txt."
\n"; - $ifs[] = $txt; + $ifs[] = $txt; unset($s); } // echo "
";print_r($ifs); echo "
"; /* add relevance formula for weighting hits & popularity */ - + if($weightsum==0) $weightsum=1; if(strlen($PopField)>0 && $this->PctPop>0) - { + { $popcalc = " + ((($PopField + 1) / (max($PopField)+1)*".$this->PctPop."))"; } else $popcalc = ""; if(strlen($RateField)>0 && $this->PctRating>0) - { + { $ratecalc = " + ((($RateField + 1) / (max($RateField)+1)*".$this->PctRating."))"; } else @@ -503,11 +514,11 @@ $relcalc = "0"; $SelectSQL .= $relcalc.$popcalc.$ratecalc." as Relevance, "; - + $SelectSQL .= $this->SourceTable.".".$idField." as ItemId, ".$this->SourceTable.".ResourceId as ResourceId, CONCAT($typestr) as ItemType, EditorsPick as EdPick FROM ".$this->SourceTable." "; - + foreach($this->Relationships as $JoinTable=>$OnClause) - { + { $SelectSQL .= "LEFT JOIN $JoinTable ON $OnClause "; } $first=1; @@ -523,26 +534,26 @@ } else { $this->AddSearchWhereClause($field); - } + } } if (count($this->WhereClauses)) { - $normal_where = '('; // not - or + + $normal_where = '('; // not - or + $normal_where .= implode(" or ",$this->WhereClauses); $normal_where .= ')'; } else { $normal_where = ''; } - + $where = $normal_where; if (count($this->ExcludeWhereClause)>0) { foreach ($this->ExcludeWhereClause as $section) - { + { foreach ($section as $clause_part) { if (strlen($where)) @@ -553,7 +564,7 @@ } } } - + if (count($this->RequireWhereClause)>0) { $requirewhere .= '('; @@ -569,43 +580,43 @@ $where_add .= $clause_part; } $where_add .= ')'; - if (strlen($requirewhere) > 1) $requirewhere .= ' AND '; + if (strlen($requirewhere) > 1) $requirewhere .= ' AND '; $requirewhere .= $where_add; } $requirewhere .= ')'; - if (strlen($where)) + if (strlen($where)) { $where .= ' AND '; } $where .= $requirewhere; } - - + + if(is_array($idlist)) { if (strlen($where)) { $where .= ' AND '; - } + } $where .= '('.$this->SourceTable.'.ResourceId IN ('.implode(',',$idlist).'))'; } } - + if (!strlen($where)) { $where = '1'; } $SelectSQL .= " WHERE ".$where; - + $SelectSQL .= " GROUP BY $idField "; - + //echo $SelectSQL."

\n"; - + if($InitTable == TRUE) { $this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$this->ResultTable); //$indexSQL = "(INDEX(Relevance), INDEX(ItemId), INDEX(ItemType), INDEX sorting (EdPick,Relevance)) "; - $full_sql = "CREATE TABLE ".$this->ResultTable." ".$indexSQL.$SelectSQL; + $full_sql = "CREATE TABLE ".$this->ResultTable." ".$indexSQL.$SelectSQL; //echo "Full SQL:".$full_sql."
\n"; $this->adodbConnection->Execute($full_sql); //echo $this->adodbConnection->ErrorMsg()."
\n"; @@ -621,7 +632,7 @@ //Here we need to remove found items which was found by HTML tags matching keywords //$this->adodbConnection->Execute("DELETE FROM ".$this->ResultTable." WHERE ItemId = 13 AND ItemType = 4"); } - + function BuildIndexes() { $sql = "ALTER TABLE ".$this->ResultTable." ADD INDEX (Relevance), "; @@ -647,7 +658,7 @@ } } -function count_words($string) +function count_words($string) { // below line added to make contiguous spaces count as one space if(strlen($string)) @@ -662,19 +673,19 @@ function GetKeywords($phrase) { global $KeywordIgnore, $objConfig; - + //echo "Passed Phrase: $phrase
"; if(count($KeywordIgnore)==0) GetIgnoreList(); $keywords["normal"]= array(); $keywords["required"]= array(); $keywords["notallowed"] = array(); - $keywords["ignored"] = array(); + $keywords["ignored"] = array(); $min_length = $objConfig->Get('Search_MinKeyword_Length'); if (!strlen($phrase)) { return $keywords; } - + $w_array = array(); $phrase=trim($phrase); //if(count_words($phrase)>1) @@ -691,30 +702,30 @@ break; $exact_word=substr($phrase, $i+1, ($exact_match_close-$i)-1); $exact_word = str_replace("\\", "", $exact_word); - $exact_word = trim($exact_word); + $exact_word = trim($exact_word); $i=$exact_match_close; if($exact_word) - { + { if(strlen($token)==0) $token="|"; - $w_array[$ce]=$token.addslashes($exact_word); + $w_array[$ce]=$token.addslashes($exact_word); $token=""; $ce++; $exact_word=""; } break; - + case '+': if(strlen($exact_word)==0) - { + { $token = "+"; } else $exact_word .= "+"; break; case '-': if(strlen($exact_word)==0) - { + { $token = "-"; } else @@ -723,7 +734,7 @@ case " ": case ",": if($exact_word) - { + { if(strlen($token)==0) $token="|"; if($token=="|") @@ -734,7 +745,7 @@ $ce++; } else - { + { $w_array[$ce]=$token.addslashes($exact_word); $ce++; } @@ -745,7 +756,7 @@ $ce++; } $token=""; - $exact_word=""; + $exact_word=""; } break; @@ -763,12 +774,12 @@ $ce++; } else - { + { $w_array[$ce]=$token.addslashes($exact_word); $ce++; } } - for ($i=0;$iClear(); - + if ($ItemType == 0) { - $objSearchConfig->Query_Item("SELECT * FROM ".$objSearchConfig->SourceTable." WHERE TableName='$SearchSource' AND AdvancedSearch=1 ORDER BY DisplayOrder"); + $objSearchConfig->Query_Item("SELECT * FROM ".$objSearchConfig->SourceTable." WHERE TableName='$SearchSource' AND AdvancedSearch=1 ORDER BY DisplayOrder"); } else { $tables = Array(1 => 'Category', 2 => 'News', @@ -69,159 +69,162 @@ { $limit = "LIMIT $Start,$PerPage"; } - $sql = "SELECT * FROM ".$this->ResultTable." ".$limit; + $sql = "SELECT * FROM ".$this->ResultTable." ".$limit; $this->Clear(); $rs = $this->adodbConnection->Execute($sql); return $this->Query_Item($sql); } - + function SetCategoryClause($whereclause) { $this->CatClause=$whereclause; } function AddRelationship($JoinTable,$JoinExpression=NULL) { - $this->Relationships[$JoinTable]=$JoinExpression; + $this->Relationships[$JoinTable]=$JoinExpression; } function SetKeywords($keywords) { - $this->Phrase=$keywords; + $this->Phrase=$keywords; $this->keywords = GetKeywords($keywords); } function AddAdvancedField($TableName,$FieldName,$Verb,$Value,$conj, $main_prefix) { global $objSearchConfig, $objConfig; - + static $x = 0, $customs_joined = Array(); - -// echo 'Adding ADVANCED SearchField: ['.$TableName.']; ['.$FieldName.']; ['.$Verb.']; ['.$Value.']; ['.$conj.']
'; - + + // echo 'Adding ADVANCED SearchField: ['.$TableName.']; ['.$FieldName.']; ['.$Verb.']; ['.$Value.']; ['.$conj.']
'; + $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); if(!is_object($objSearchConfig)) - $objSearchConfig = new clsSeachConfigList(); - - if ($TableName == GetTablePrefix().'CustomField') { - // stupid custom fields already have prefix in SearchConfig table (not for in-commerce module :D) - $prefix = ''; - } - else { - $prefix = GetTablePrefix(); - } - $f = $prefix.$TableName.".".$FieldName; - $FieldConfig = $objSearchConfig->GetItemByName($TableName,$FieldName); - if(!is_object($FieldConfig)) { - return false; - } - - if ($FieldConfig->Get('ForeignField')) { - $x++; - $parts = explode(".",$FieldConfig->Get("ForeignField")); - $Table = $parts[0]; - $pseudo = 'c'.$x; - $Table = AddTablePrefix($Table); - $Field = $parts[1]; - $join = $FieldConfig->Get("JoinClause"); - $join = str_replace($Table, $pseudo, $join); - $join = str_replace("{ForeignTable}", $pseudo, $join); - $join = str_replace("{LocalTable}", $TableName, $join); - $join = str_replace("{Table}", AddTablePrefix($this->SourceTable), $join); - $join = '('.$join.' AND '.$pseudo.'.CustomFieldId='.$FieldConfig->Get('CustomFieldId').')'; - $this->AddRelationship($Table.' AS '.$pseudo, $join); + $objSearchConfig = new clsSeachConfigList(); - // for items that does not have appropriate records in CustomMetaData table - if ($Verb == 'notcontains' || $Verb == 'isnot') { - $or_not_null = ' OR '.$pseudo.'.'.$Field.' IS NULL'; - } - else { - $or_not_null = ''; - } + if ($TableName == GetTablePrefix().'CustomField') { + // stupid custom fields already have prefix in SearchConfig table (not for in-commerce module :D) + $prefix = ''; + } + else { + $prefix = GetTablePrefix(); + } + $f = $prefix.$TableName.".".$FieldName; + $FieldConfig = $objSearchConfig->GetItemByName($TableName,$FieldName); + if(!is_object($FieldConfig)) { + return false; + } - $FieldItem["where"] = str_replace('CustomMetaData', $pseudo, $FieldConfig->GetWhereClause($Verb,$Value)).$or_not_null; - $FieldItem["Field"] = $FieldConfig->Get("ForeignField"); - $FieldItem["Table"] = $pseudo; - $FieldItem["conjuction"] = $conj; - $FieldItem["weight"] = $FieldConfig->Get("Priority"); - } - else { - $classes = Array( 'Link' => '_clsLinkList', - 'News' => '_clsNewsList', - 'Topic' => '_clsTopicList', - 'Category' => 'clsCatList'); - $list_class = getArrayValue($classes, $TableName); - if ($list_class) { - $objList =& new $list_class(); - } - - if ($FieldConfig->Get('CustomFieldId')) { - $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - $FieldConfig->Set('FieldName', $ml_formatter->LangFieldName('cust_'.$FieldConfig->Get('CustomFieldId'))); - } - - switch ($FieldName) { - case 'HotItem': - $cutoff = $objList->GetHotValue(); - $Value == 1 ? $not = '' : $not = 'NOT '; - $where_clause = $FieldConfig->GetWhereClause($Verb, $Value); - $where_clause .= ' OR ('.AddTablePrefix($TableName).'.HotItem=2 AND '. - $not.'('.AddTablePrefix($TableName). - '.Hits>='.$cutoff.'))'; - break; - case 'PopItem': - $cutoff = $objList->GetPopValue(); - $Value == 1 ? $not = '' : $not = 'NOT '; - $where_clause = $FieldConfig->GetWhereClause($Verb, $Value); - $where_clause .= ' OR ('.AddTablePrefix($TableName).'.PopItem=2 AND '. - $not.'('.AddTablePrefix($TableName). - '.CachedRating>='.$cutoff.'))'; - break; - case 'NewItem': - $NewTime = $objConfig->Get($TableName.'_NewDays')*3600*24; - $Value == 1 ? $not = '' : $not = 'NOT '; - $where_clause = $FieldConfig->GetWhereClause($Verb, $Value); - $where_clause .= ' OR ('.AddTablePrefix($TableName).'.NewItem=2 AND '. - $not.'('.adodb_mktime().'-'.AddTablePrefix($TableName). - '.CreatedOn<'.$NewTime.'))'; - break; - default: - $where_clause = $FieldConfig->GetWhereClause($Verb, $Value); - break; - } + if ($FieldConfig->Get('ForeignField')) { + $x++; + $parts = explode(".",$FieldConfig->Get("ForeignField")); + $Table = $parts[0]; + $pseudo = 'c'.$x; + $Table = AddTablePrefix($Table); + $Field = $parts[1]; + $join = $FieldConfig->Get("JoinClause"); + $join = str_replace($Table, $pseudo, $join); + $join = str_replace("{ForeignTable}", $pseudo, $join); + $join = str_replace("{LocalTable}", $TableName, $join); + $join = str_replace("{Table}", AddTablePrefix($this->SourceTable), $join); + $join = '('.$join.' AND '.$pseudo.'.CustomFieldId='.$FieldConfig->Get('CustomFieldId').')'; + $this->AddRelationship($Table.' AS '.$pseudo, $join); - $FieldItem = Array(); - if ($FieldConfig->Get('CustomFieldId')) { - if (!getArrayValue($customs_joined, $main_prefix)) { - $item_table = $this->Application->getUnitOption($main_prefix, 'TableName'); - $custom_table = $this->Application->getUnitOption($main_prefix.'-cdata', 'TableName'); - $this->AddRelationship($custom_table.' AS '.$main_prefix.'_custom_data', $main_prefix.'_custom_data.ResourceId = '.$item_table.'.ResourceId'); - $customs_joined[$main_prefix] = true; - } - - $FieldItem['Table'] = $main_prefix.'_custom_data'; - $FieldItem['Field'] = $FieldConfig->Get('FieldName'); - } - else { - $FieldItem['Table'] = AddTablePrefix($TableName); - $FieldItem['Field'] = $FieldName; - } - - $FieldItem['where'] = $FieldItem['Table'].'.'.$where_clause; - $FieldItem['conjuction'] = $conj; - $FieldItem['weight'] = $FieldConfig->Get('Priority'); + // for items that does not have appropriate records in CustomMetaData table + if ($Verb == 'notcontains' || $Verb == 'isnot') { + $or_not_null = ' OR '.$pseudo.'.'.$Field.' IS NULL'; + } + else { + $or_not_null = ''; + } + $FieldItem["where"] = str_replace('CustomMetaData', $pseudo, $FieldConfig->GetWhereClause($Verb,$Value)).$or_not_null; + $FieldItem["Field"] = $FieldConfig->Get("ForeignField"); + $FieldItem["Table"] = $pseudo; + $FieldItem["conjuction"] = $conj; + $FieldItem["weight"] = $FieldConfig->Get("Priority"); + } + else { + $classes = Array( + 'Link' => '_clsLinkList', + 'News' => '_clsNewsList', + 'Topic' => '_clsTopicList', + 'Category' => 'clsCatList'); + $list_class = getArrayValue($classes, $TableName); + if ($list_class) { + $objList =& new $list_class(); + } - } - $this->FieldList[] = $FieldItem; + $prefix_fields = $this->Application->getUnitOption($main_prefix, 'Fields'); + if (isset($prefix_fields[$FieldName]) && $prefix_fields[$FieldName]['formatter'] == 'kMultiLanguage') { + $FieldConfig->Set('FieldName', $ml_formatter->LangFieldName($FieldName)); + } - - // create search record - $this->SearchLogRecord[] = language('la_Field').' "'.$FieldConfig->getHumanField().'" '.$FieldConfig->getHumanVerb($Verb).' '.language('la_Value').' "'.$FieldConfig->getHumanValue($Value).'" '.language('lu_'.$conj); - - unset($FieldItem); - + if ($FieldConfig->Get('CustomFieldId')) { + $FieldConfig->Set('FieldName', $ml_formatter->LangFieldName('cust_'.$FieldConfig->Get('CustomFieldId'))); + } + + switch ($FieldName) { + case 'HotItem': + $cutoff = $objList->GetHotValue(); + $Value == 1 ? $not = '' : $not = 'NOT '; + $where_clause = $FieldConfig->GetWhereClause($Verb, $Value); + $where_clause .= ' OR ('.AddTablePrefix($TableName).'.HotItem=2 AND '. + $not.'('.AddTablePrefix($TableName). + '.Hits>='.$cutoff.'))'; + break; + case 'PopItem': + $cutoff = $objList->GetPopValue(); + $Value == 1 ? $not = '' : $not = 'NOT '; + $where_clause = $FieldConfig->GetWhereClause($Verb, $Value); + $where_clause .= ' OR ('.AddTablePrefix($TableName).'.PopItem=2 AND '. + $not.'('.AddTablePrefix($TableName). + '.CachedRating>='.$cutoff.'))'; + break; + case 'NewItem': + $NewTime = $objConfig->Get($TableName.'_NewDays')*3600*24; + $Value == 1 ? $not = '' : $not = 'NOT '; + $where_clause = $FieldConfig->GetWhereClause($Verb, $Value); + $where_clause .= ' OR ('.AddTablePrefix($TableName).'.NewItem=2 AND '. + $not.'('.adodb_mktime().'-'.AddTablePrefix($TableName). + '.CreatedOn<'.$NewTime.'))'; + break; + default: + $where_clause = $FieldConfig->GetWhereClause($Verb, $Value); + break; + } + + $FieldItem = Array(); + if ($FieldConfig->Get('CustomFieldId')) { + if (!getArrayValue($customs_joined, $main_prefix)) { + $item_table = $this->Application->getUnitOption($main_prefix, 'TableName'); + $custom_table = $this->Application->getUnitOption($main_prefix.'-cdata', 'TableName'); + $this->AddRelationship($custom_table.' AS '.$main_prefix.'_custom_data', $main_prefix.'_custom_data.ResourceId = '.$item_table.'.ResourceId'); + $customs_joined[$main_prefix] = true; + } + + $FieldItem['Table'] = $main_prefix.'_custom_data'; + $FieldItem['Field'] = $FieldConfig->Get('FieldName'); + } + else { + $FieldItem['Table'] = AddTablePrefix($TableName); + $FieldItem['Field'] = $FieldName; + } + + $FieldItem['where'] = $FieldItem['Table'].'.'.$where_clause; + $FieldItem['conjuction'] = $conj; + $FieldItem['weight'] = $FieldConfig->Get('Priority'); + + + } + $this->FieldList[] = $FieldItem; + + // create search record + $this->SearchLogRecord[] = language('la_Field').' "'.$FieldConfig->getHumanField().'" '.$FieldConfig->getHumanVerb($Verb).' '.language('la_Value').' "'.$FieldConfig->getHumanValue($Value).'" '.language('lu_'.$conj); + + unset($FieldItem); } - + function getKeywords(&$FieldConfig) { $ret = implode('
', $this->SearchLogRecord); @@ -232,38 +235,38 @@ { $sql = "SELECT * FROM ".GetTablePrefix()."SearchConfig WHERE TableName='".$this->SourceTable."' AND AdvancedSearch=1 AND CustomFieldId>0"; //echo $sql; - foreach($this->Relationships as $Table=>$clause) + foreach($this->Relationships as $Table=>$clause) { if(strlen($Table)>0 && $Table != "Category") $sql .= " OR TableName='".$Table."'"; } $ctable = GetTablePrefix()."CustomMetaData"; $rs = $this->adodbConnection->Execute($sql); - $CustomJoined = FALSE; + $CustomJoined = FALSE; while($rs && !$rs->EOF) { $x = $rs->fields["CustomFieldId"]; $t = $ctable." as c".$x; - $join = "(c$x.ResourceId=".GetTablePrefix().$this->SourceTable.".ResourceId AND c$x.CustomFieldId=".$rs->fields["CustomFieldId"].")"; + $join = "(c$x.ResourceId=".GetTablePrefix().$this->SourceTable.".ResourceId AND c$x.CustomFieldId=".$rs->fields["CustomFieldId"].")"; $this->AddRelationship($t,$join); - $f = "c".$x.".Value "; + $f = "c".$x.".Value "; $this->FieldList[] = $f; $this->FieldWeight[$f] = $rs->fields["Priority"]; $rs->MoveNext(); } - } + } function AddAdvancedFields() { $sql = "SELECT * FROM ".GetTablePrefix()."SearchConfig WHERE TableName='".$this->SourceTable."' AND AdvancedSearch=1 AND CustomFieldId=0"; //echo $sql; - foreach($this->Relationships as $Table=>$clause) + foreach($this->Relationships as $Table=>$clause) { if(strlen($Table)>0 && $Table != "Category") $sql .= " OR TableName='".$Table."'"; } $rs = $this->adodbConnection->Execute($sql); - + while($rs && !$rs->EOF) { $f = GetTablePrefix().$rs->fields["TableName"].".".$rs->fields["FieldName"]; @@ -273,58 +276,58 @@ } $this->AddAdvancedCustomFields(); }*/ - + /* ready to write the code to build the query and go */ function BuildWhereClause() { - $where = ""; + $where = ""; foreach($this->FieldList as $f) $where .= " (".$f["where"].") ".$f["conjuction"]; - + $cut_length = substr($where, -2) == 'OR' ? 2 : substr($where, -3) == 'AND' ? 3 : 0; $where = substr($where, 0, strlen($where) - $cut_length); return $where; } - + function PerformSearch($ItemType,$OrderBy=NULL,$InitTable=FALSE, $idlist=NULL) { static $SelectSQL, $OldItemType; global $objSession, $objItemTypes; - + // add recrod to log $objSearchList = new clsSearchLogList(); $objSearchList->UpdateKeyword($this->getKeywords(), 1); - + $ctype = $objItemTypes->GetItem($ItemType); $idField = $ctype->Get("SourceTable")."Id"; $this->SourceTable = AddTablePrefix($ctype->Get("SourceTable")); $result=0; $PopField = $ctype->Get("PopField"); - $RateField = $ctype->Get("RateField"); + $RateField = $ctype->Get("RateField"); $typestr = str_pad($ItemType,2,"0",STR_PAD_LEFT); $SelectSQL = "SELECT ".$this->SourceTable.".".$idField." as ItemId, ". $this->SourceTable.".Priority as Relevance, ".$this->SourceTable.".ResourceId, CONCAT($typestr) as ItemType, EditorsPick as EdPick FROM ".$this->SourceTable." "; - + foreach($this->Relationships as $JoinTable=>$OnClause) - { + { $SelectSQL .= "LEFT JOIN $JoinTable ON ($OnClause) "; } $first=1; $WhereClause = $this->BuildWhereClause(); if(strlen($WhereClause)>0) { $SelectSQL .= " WHERE ".$WhereClause; - } + } $SelectSQL .= " GROUP BY $idField "; //echo $SelectSQL; $this->adodbConnection->Execute("DROP TABLE IF EXISTS ".$this->ResultTable); - $full_sql = "CREATE TABLE ".$this->ResultTable." ".$indexSQL.$SelectSQL; + $full_sql = "CREATE TABLE ".$this->ResultTable." ".$indexSQL.$SelectSQL; $this->adodbConnection->Execute($full_sql); // if advanced seaech used, then delete simple search keywords $objSession->SetVariable('Search_Keywords', ''); //print_pre($full_sql); } - + function BuildIndexes() { $sql = "ALTER TABLE ".$this->ResultTable." ADD INDEX (Relevance), "; Index: branches/unlabeled/unlabeled-1.1.2/admin/install/upgrades/changelog_1_2_1.txt =================================================================== diff -u -r6073 -r6078 --- branches/unlabeled/unlabeled-1.1.2/admin/install/upgrades/changelog_1_2_1.txt (.../changelog_1_2_1.txt) (revision 6073) +++ branches/unlabeled/unlabeled-1.1.2/admin/install/upgrades/changelog_1_2_1.txt (.../changelog_1_2_1.txt) (revision 6078) @@ -24,7 +24,7 @@ File in-portal/admin/install/install_lib.php changed File in-portal/admin/install/restore_run.php changed File in-portal/admin/install/langpacks/english.lang changed -File in-portal/admin/install/upgrades/changelog_1_2_1.txt is new; release_1_2_1 revision 1.1.2.5 +File in-portal/admin/install/upgrades/changelog_1_2_1.txt is new; release_1_2_1 revision 1.1.2.6 File in-portal/admin/install/upgrades/inportal_upgrade_v1.2.1.php is new; release_1_2_1 revision 1.4.2.2 File in-portal/admin/install/upgrades/inportal_upgrade_v1.2.1.sql is new; release_1_2_1 revision 1.8.2.3 File in-portal/admin/install/upgrades/readme_1_2_1.txt is new; release_1_2_1 revision 1.1.2.1 @@ -139,6 +139,7 @@ File in-portal/kernel/admin_templates/xml/cache_updater.tpl is new; release_1_2_1 revision 1.1 File in-portal/kernel/admin_templates/xml/categories_list.tpl is new; release_1_2_1 revision 1.15.2.8 File in-portal/kernel/admin_templates/xml/tree_categories.tpl changed +File in-portal/kernel/include/advsearch.php changed File in-portal/kernel/include/category.php changed File in-portal/kernel/include/config.php changed File in-portal/kernel/include/customfield.php changed @@ -147,6 +148,7 @@ File in-portal/kernel/include/item.php changed File in-portal/kernel/include/modules.php changed File in-portal/kernel/include/parseditem.php changed +File in-portal/kernel/include/searchitems.php changed File in-portal/kernel/include/usersession.php changed File in-portal/kernel/include/adodb/adodb.inc.php changed File in-portal/kernel/module_help/categories_custom.txt is new; release_1_2_1 revision 1.1.2.1 Index: branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php =================================================================== diff -u -r6026 -r6078 --- branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6026) +++ branches/unlabeled/unlabeled-1.22.2/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6078) @@ -114,7 +114,7 @@ } $object->addFilter('perm_filter', 'PermId = 1'); // check for CATEGORY.VIEW permission - if ($this->Application->GetVar('u_id') > 0) { + if ($this->Application->GetVar('u_id') != -1) { // apply permission filters to all users except "root" $groups = explode(',',$this->Application->RecallVar('UserGroups')); foreach ($groups as $group) {