Index: trunk/kernel/units/languages/languages_item.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/languages/languages_item.php (.../languages_item.php) (revision 6093) +++ trunk/kernel/units/languages/languages_item.php (.../languages_item.php) (revision 6583) @@ -31,6 +31,9 @@ */ function formatNumber($number, $precision = null) { + if (is_null($precision)) { + $precision = preg_match('/[\.,]+/', $number) ? strlen(preg_replace('/^.*[\.,]+/', '', $number)) : 0; + } return number_format($number, $precision, $this->GetDBField('DecimalPoint'), $this->GetDBField('ThousandSep')); } Index: trunk/kernel/units/users/users_event_handler.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/kernel/units/users/users_event_handler.php (.../users_event_handler.php) (revision 6428) +++ trunk/kernel/units/users/users_event_handler.php (.../users_event_handler.php) (revision 6583) @@ -641,7 +641,7 @@ function OnSubscribeUser(&$event){ - $object = &$this->Application->recallObject($this->Prefix.'.subscriber', Array('skip_autoload' => true)); + $object = &$this->Application->recallObject($this->Prefix.'.subscriber', null, Array('skip_autoload' => true)); $user_email = $this->Application->RecallVar('SubscriberEmail'); Index: trunk/core/kernel/db/dbitem.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 6093) +++ trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 6583) @@ -100,7 +100,9 @@ { $options = $this->GetFieldOptions($name); $parsed = $value; - if ($value == '') $parsed = NULL; + if ($value == '') { + $parsed = NULL; + } if (isset($options['formatter'])) { $formatter =& $this->Application->recallObject($options['formatter']); // $parsed = $formatter->Parse($value, $options, $err); @@ -781,13 +783,13 @@ if( !isset($id) ) $id = $this->GetID(); $event = new kEvent( Array('name'=>$name,'prefix'=>$this->Prefix,'special'=>$this->Special) ); $event->setEventParam('id', $id); - + if ($additional_params) { foreach ($additional_params as $ap_name => $ap_value) { $event->setEventParam($ap_name, $ap_value); } } - + $this->Application->HandleEvent($event); return $event->status == erSUCCESS ? true : false; } @@ -921,15 +923,15 @@ foreach ($this->customFields as $custom_id => $custom_name) { $cdata->SetDBField($ml_formatter->LangFieldName('cust_'.$custom_id), $this->GetDBField('cust_'.$custom_name)); } - + if ($cdata->isLoaded()) { $ret = $cdata->Update(); } else { $ret = $cdata->Create(); if ($cdata->mode == 't') $cdata->setTempID(); } - + return $ret; } } Index: trunk/core/units/general/helpers/filenames_helper.php =================================================================== diff -u -N -r5509 -r6583 --- trunk/core/units/general/helpers/filenames_helper.php (.../filenames_helper.php) (revision 5509) +++ trunk/core/units/general/helpers/filenames_helper.php (.../filenames_helper.php) (revision 6583) @@ -11,7 +11,7 @@ { $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`', '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '~', - '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ','); + '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ',', "\r", "\n"); $filename = str_replace($not_allowed, '_', $filename); $filename = preg_replace('/(_+)/', '_', $filename); Index: trunk/core/units/categories/categories_config.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 6093) +++ trunk/core/units/categories/categories_config.php (.../categories_config.php) (revision 6583) @@ -41,8 +41,8 @@ 'pending' => Array( 'icon' => 'icon16_cat_pending.gif', 'label' => 'la_tab_Categories', - 'js_url' => "set_persistant_var('Category_View', 41, 'advanced_view', '#url#')", - 'url' => Array('t' => 'advanced_view', 'index_file' => 'advanced_view.php', 'SetTab' => 'category', 'pass' => 'm'), + 'js_url' => '#url#', + 'url' => Array('t' => 'advanced_view', 'SetTab' => 'c', 'pass' => 'm,c.showall', 'c.showall_event' => 'OnSetFilterPattern', 'c.showall_filters' => 'show_active=0,show_pending=1,show_disabled=0,show_new=1,show_pick=1'), 'status' => STATUS_PENDING, ), ), Index: trunk/core/units/phrases/phrases_event_handler.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 6093) +++ trunk/core/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 6583) @@ -3,14 +3,20 @@ class PhrasesEventHandler extends InpDBEventHandler { + /** + * Allow to create phrases from front end in debug mode with DBG_PHRASES constant set + * + * @param kEvent $event + */ function CheckPermission(&$event) { - if (!$this->Application->IsAdmin() && $event->Name == 'OnCreate' && $this->Application->isDebugMode() && constOn('DBG_PHRASES')) { - if ($event->Name == 'OnCreate') { - // allow create phrases from front end in debug mode with DBG_PHRASES + if (!$this->Application->IsAdmin() && $this->Application->isDebugMode() && constOn('DBG_PHRASES')) { + if ($event->Name == 'OnNew' || $event->Name == 'OnCreate') { return true; } } + + return parent::CheckPermission($event); } /** Index: trunk/core/units/languages/languages_config.php =================================================================== diff -u -N -r5110 -r6583 --- trunk/core/units/languages/languages_config.php (.../languages_config.php) (revision 5110) +++ trunk/core/units/languages/languages_config.php (.../languages_config.php) (revision 6583) @@ -140,7 +140,7 @@ 'DateFormat' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'TimeFormat' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'InputDateFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('m/d/Y' => 'm/d/Y'), 'not_null' => '1','default' => 'm/d/Y', 'required' => 1), - 'InputTimeFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('g:i:s A' => 'g:i:s A'), 'not_null' => '1','default' => 'g:i:s A', 'required' => 1), + 'InputTimeFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('g:i:s A' => 'g:i:s A'), 'not_null' => '1','default' => 'g:i:s A', 'required' => 1), 'DecimalPoint' => Array('type' => 'string','not_null' => '1','default' => ''), 'ThousandSep' => Array('type' => 'string','not_null' => '1','default' => ''), 'Charset' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), Index: trunk/kernel/admin_templates/incs/custom_blocks.tpl =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 6093) +++ trunk/kernel/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 6583) @@ -1,5 +1,5 @@ - " /> + " /> @@ -73,11 +73,11 @@ " > - + -   +   @@ -90,6 +90,11 @@ + + + + + Index: trunk/kernel/admin_templates/incs/ajax.js =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 6093) +++ trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 6583) @@ -14,7 +14,7 @@ //p_errorCallBack: callback function for erroneous response //p_pass: string of params to pass to callback functions //p_object: object of params to pass to callback functions - + if (p_busyReq) return; var req = Request.getRequest(); if (req != null) { @@ -34,15 +34,15 @@ } var $ajax_mark = (p_url.indexOf('?') ? '&' : '?') + 'ajax=yes'; req.open(Request.method, p_url + $ajax_mark, true); - + if (Request.method == 'POST') { Request.headers['Content-type'] = 'application/x-www-form-urlencoded'; Request.headers['referer'] = p_url; } else { Request.headers['If-Modified-Since'] = 'Sat, 1 Jan 2000 00:00:00 GMT'; } - + Request.sendHeaders(req); if (Request.method == 'POST') { req.send(Request.params); @@ -51,7 +51,7 @@ else { req.send(null); } - + var toId = window.setTimeout( function() {if (p_busyReq) req.abort();}, Request.timeout ); } } @@ -74,7 +74,7 @@ Request.showProgress = function(p_id) { if (p_id != '') { Request.setOpacity(20, p_id); - + if (!document.getElementById(p_id + '_progress')) { document.body.appendChild(Request.getProgressObject(p_id)); } @@ -100,7 +100,7 @@ object.opacity = (opacity / 100); object.MozOpacity = (opacity / 100); object.KhtmlOpacity = (opacity / 100); - object.filter = "alpha(opacity=" + opacity + ")"; + object.filter = "alpha(opacity=" + opacity + ")"; } Request.getProgressHtml = function() { @@ -110,15 +110,15 @@ Request.getProgressObject = function($id) { var $div = document.createElement('DIV'); var $parent_div = document.getElementById($id); - + $div.id = $id + '_progress'; - + $div.style.width = $parent_div.clientWidth + 'px'; $div.style.height = '150px'; // default height if div is empty (first ajax request for div) - $div.style.left = getRealLeft($parent_div) + 'px'; + $div.style.left = getRealLeft($parent_div) + 'px'; $div.style.top = getRealTop($parent_div) + 'px'; $div.style.position = 'absolute'; - + /*$div.style.border = '1px solid green'; $div.style.backgroundColor = '#FF0000';*/ @@ -135,41 +135,41 @@ if (typeof(theform) == 'string') { theform = document.getElementById(theform); } - + var els = theform.elements; var len = els.length; var queryString = ''; - - Request.addField = function(name, value) { + + Request.addField = function(name, value) { if (queryString.length > 0) queryString += '&'; queryString += encodeURIComponent(name) + '=' + encodeURIComponent(value); }; - + for (var i = 0; i= 0) { Request.addField(el.name, el.options[el.selectedIndex].value); } break; - + case 'select-multiple': for (var j = 0; j < el.options.length; j++) { if (!el.options[j].selected) continue; Request.addField(el.name, el.options[j].value); } break; - + case 'checkbox': case 'radio': if (!el.checked) continue; @@ -218,7 +218,7 @@ window.location.href = $match_redirect[1]; return false; } - + if ($object.showProgress($responce)) { $object.Query(); } @@ -230,12 +230,12 @@ AjaxProgressBar.prototype.FormatTime = function ($seconds) { $seconds = parseInt($seconds); - + var $minutes = Math.floor($seconds / 60); if ($minutes < 10) $minutes = '0' + $minutes; $seconds = $seconds % 60; if ($seconds < 10) $seconds = '0' + $seconds; - + return $minutes + ':' + $seconds; } @@ -244,13 +244,13 @@ var $now = this.GetMicroTime(); this.ProgressTime[this.ProgressTime.length] = $now - this.LastResponceTime; this.LastResponceTime = $now; - + var $display_progress = parseInt(this.ProgressPercent); this.GetWindow().document.title = $display_progress + '% - ' + this.WindowTitle; document.getElementById('progress_display[percents_completed]').innerHTML = $display_progress + '%'; document.getElementById('progress_display[elapsed_time]').innerHTML = this.FormatTime( Math.sum(this.ProgressTime) ); document.getElementById('progress_display[Estimated_time]').innerHTML = this.FormatTime( this.GetEstimatedTime() ); - + document.getElementById('progress_bar[done]').style.width = $display_progress + '%'; document.getElementById('progress_bar[left]').style.width = (100 - $display_progress) + '%'; return $percent < 100 ? true : false; Index: trunk/core/units/general/cat_dbitem_export.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 6093) +++ trunk/core/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 6583) @@ -364,34 +364,86 @@ function getCustomSQL() { $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - + $custom_sql = ''; foreach ($this->customFields as $custom_id => $custom_name) { $custom_sql .= 'custom_data.'.$ml_formatter->LangFieldName('cust_'.$custom_id).' AS cust_'.$custom_name.', '; } - + return preg_replace('/(.*), /', '\\1', $custom_sql); } - + + function getPlainExportSQL($count_only = false) { + if ($count_only && isset($this->exportOptions['ForceCountSQL'])) return $this->exportOptions['ForceCountSQL']; + if (!$count_only && isset($this->exportOptions['ForceSelectSQL'])) return $this->exportOptions['ForceSelectSQL']; + + $items_list =& $this->Application->recallObject($this->curItem->Prefix.'.export-items-list', $this->curItem->Prefix.'_List'); + $items_list->SetPerPage(-1); + return $items_list->GetSelectSQL($count_only); + + + if ($this->exportOptions['export_ids'] === false) + { + // get links from current category & all it's subcategories + $join_clauses = Array(); + + $custom_sql = $this->getCustomSQL(); + if ($custom_sql) { + $custom_table = $this->Application->getUnitOption($this->curItem->Prefix.'-cdata', 'TableName'); + $join_clauses[$custom_table.' custom_data'] = 'custom_data.ResourceId = item_table.ResourceId'; + } + + $sql = 'SELECT item_table.*'.($custom_sql ? ', '.$custom_sql : '').' + FROM '.$this->curItem->TableName.' item_table'; + + foreach ($join_clauses as $table_name => $join_expression) { + $sql .= ' LEFT JOIN '.$table_name.' ON '.$join_expression; + } + $sql .= ' WHERE 1'; + + $sql .= ' ORDER BY item_table.'.$this->curItem->IDField.' ASC'; // NEW + } + else { + // get only selected links + $sql = 'SELECT item_table.* + FROM '.$this->curItem->TableName.' item_table + WHERE '.$this->curItem->IDField.' IN ('.implode(',', $this->exportOptions['export_ids']).')'; + } + + if (!$count_only) + { + $sql .= ' LIMIT '.$this->exportOptions['start_from'].','.EXPORT_STEP; + } + else { + $sql = preg_replace("/^.*SELECT(.*?)FROM(?!_)/is", "SELECT COUNT(*) AS count FROM ", $sql); + } + + return $sql; + } + function getExportSQL($count_only = false) { + if (!$this->Application->getUnitOption($this->curItem->Prefix, 'CatalogItem')) { + return $this->GetPlainExportSQL($count_only); // in case this is not a CategoryItem + } + if ($this->exportOptions['export_ids'] === false) { // get links from current category & all it's subcategories $join_clauses = Array(); - + $custom_sql = $this->getCustomSQL(); if ($custom_sql) { $custom_table = $this->Application->getUnitOption($this->curItem->Prefix.'-cdata', 'TableName'); $join_clauses[$custom_table.' custom_data'] = 'custom_data.ResourceId = item_table.ResourceId'; } - + $join_clauses[TABLE_PREFIX.'CategoryItems ci'] = 'ci.ItemResourceId = item_table.ResourceId'; $join_clauses[TABLE_PREFIX.'Category c'] = 'c.CategoryId = ci.CategoryId'; - + $sql = 'SELECT item_table.*, ci.CategoryId'.($custom_sql ? ', '.$custom_sql : '').' FROM '.$this->curItem->TableName.' item_table'; - + foreach ($join_clauses as $table_name => $join_expression) { $sql .= ' LEFT JOIN '.$table_name.' ON '.$join_expression; } @@ -475,7 +527,7 @@ $this->curItem->SetDBFieldsFromHash($record_info); $this->setCurrentID(); $this->curItem->raiseEvent('OnAfterItemLoad', $this->curItem->GetID() ); - + $data_array = Array(); foreach ($this->exportFields as $export_field) { @@ -650,7 +702,7 @@ } $this->curItem->Clear(); $this->customFields = $this->Application->getUnitOption($event->Prefix, 'CustomFields'); - + if (isset($record_data)) { $this->setImportData($record_data); } @@ -679,7 +731,7 @@ if (is_null($lang_prefix)) { $lang_prefix = 'l'.$this->Application->GetVar('m_lang').'_'; } - + foreach ($this->curItem->CategoryPath as $category_index => $category_name) { if (!$category_name) continue; $category_key = crc32( implode(':', array_slice($this->curItem->CategoryPath, 0, $category_index + 1) ) ); @@ -766,7 +818,7 @@ else { $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND '; } - + } $where_clause = preg_replace('/(.*) AND $/', '\\1', $where_clause); @@ -777,7 +829,7 @@ $parent_path = $this->getParentPath($category_id); $where_clause = '(c.ParentPath LIKE "'.$parent_path.'%") AND '.$where_clause; } - + $cdata_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName'); $sql = 'SELECT '.$this->curItem->IDField.' FROM '.$this->curItem->TableName.' item_table @@ -828,11 +880,11 @@ /*function saveLog($msg) { static $first_time = true; - + $fp = fopen(FULL_PATH.'/sqls.log', $first_time ? 'w' : 'a'); fwrite($fp, $msg."\n"); fclose($fp); - + $first_time = false; }*/ @@ -1069,6 +1121,277 @@ { return unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); } + + /** + * Sets correct available & export fields + * + * @param kEvent $event + */ + function prepareExportColumns(&$event) + { + $object =& $event->getObject( Array('skip_autoload' => true) ); + + $available_columns = Array(); + + if ($this->Application->getUnitOption($event->Prefix, 'CatalogItem')) { + // category field (mixed) + $available_columns['__CATEGORY__CategoryPath'] = 'CategoryPath'; + + if ($event->Special == 'import') { + // category field (separated fields) + $max_level = $this->Application->ConfigValue('MaxImportCategoryLevels'); + $i = 0; + while ($i < $max_level) { + $available_columns['__CATEGORY__Category'.($i + 1)] = 'Category'.($i + 1); + $i++; + } + } + } + + // db fields + foreach ($object->Fields as $field_name => $field_options) + { + if (!$object->SkipField($field_name)) + { + $available_columns[$field_name] = $field_name.(getArrayValue($field_options, 'required') ? '*' : ''); + } + } + + $handler =& $this->Application->recallObject($event->Prefix.'_EventHandler'); + $available_columns = array_merge_recursive2($available_columns, $handler->getCustomExportColumns($event)); + + // custom fields + foreach ($object->customFields as $custom_id => $custom_name) + { + $available_columns['__CUSTOM__'.$custom_name] = $custom_name; + } + + // columns already in use + $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); + if ($items_info) + { + list($item_id, $field_values) = each($items_info); + $export_keys = $field_values['ExportColumns']; + $export_keys = $export_keys ? explode('|', substr($export_keys, 1, -1) ) : Array(); + } + else { + $export_keys = Array(); + } + + $export_columns = Array(); + foreach ($export_keys as $field_key) + { + $field_name = $this->getExportField($field_key); + $export_columns[$field_key] = $field_name; + unset($available_columns[$field_key]); + } + + $options = $object->GetFieldOptions('ExportColumns'); + $options['options'] = $export_columns; + $object->SetFieldOptions('ExportColumns', $options); + + $options = $object->GetFieldOptions('AvailableColumns'); + $options['options'] = $available_columns; + $object->SetFieldOptions('AvailableColumns', $options); + + $this->updateImportFiles($event); + $this->PrepareExportPresets($event); + } + + function PrepareExportPresets(&$event) + { + $object =& $event->getObject( Array('skip_autoload' => true) ); + $options = $object->GetFieldOptions('ExportPresets'); + + $user =& $this->Application->recallObject('u'); + $export_settings = $user->getPersistantVar('export_settings'); + if (!$export_settings) return ; + $export_settings = unserialize($export_settings); + + if (!isset($export_settings[$event->Prefix])) return ; + + + $export_presets = array(''=>''); + foreach ($export_settings[$event->Prefix] as $key => $val) { + $export_presets[implode('|', $val['ExportColumns'])] = $key; + } + + $options['options'] = $export_presets; + $object->SetFieldOptions('ExportPresets', $options); + } + + function getExportField($field_key) + { + $prepends = Array('__CUSTOM__', '__CATEGORY__'); + foreach ($prepends as $prepend) + { + if (substr($field_key, 0, strlen($prepend) ) == $prepend) + { + $field_key = substr($field_key, strlen($prepend), strlen($field_key) ); + break; + } + } + return $field_key; + } + + /** + * Updates uploaded files list + * + * @param kEvent $event + */ + function updateImportFiles(&$event) + { + if ($event->Special != 'import') { + return false; + } + + $object =& $event->getObject(); + + $import_filenames = Array(); + + if ($folder_handle = opendir(EXPORT_PATH)) { + while (false !== ($file = readdir($folder_handle))) { + if (is_dir(EXPORT_PATH.'/'.$file) || substr($file, 0, 1) == '.' || strtolower($file) == 'cvs' || strtolower($file) == 'dummy' || filesize(EXPORT_PATH.'/'.$file) == 0) continue; + + $file_size = formatSize( filesize(EXPORT_PATH.'/'.$file) ); + $import_filenames[$file] = $file.' ('.$file_size.')'; + } + closedir($folder_handle); + } + + $options = $object->GetFieldOptions('ImportLocalFilename'); + $options['options'] = $import_filenames; + $object->SetFieldOptions('ImportLocalFilename', $options); + } + + /** + * Returns module folder + * + * @param kEvent $event + * @return string + */ + function getModuleFolder(&$event) + { + return $this->Application->getUnitOption($event->Prefix, 'ModuleFolder'); + } + + /** + * Export form validation & processing + * + * @param kEvent $event + */ + function OnExportBegin(&$event) + { + $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); + if (!$items_info) + { + $items_info = unserialize( $this->Application->RecallVar($event->getPrefixSpecial().'_ItemsInfo') ); + $this->Application->SetVar($event->getPrefixSpecial(true), $items_info); + } + + list($item_id, $field_values) = each($items_info); + + $object =& $event->getObject( Array('skip_autoload' => true) ); + $object->SetFieldsFromHash($field_values); + $field_values['ImportFilename'] = $object->GetDBField('ImportFilename'); //if upload formatter has renamed the file during moving !!! + + $object->setID($item_id); + $this->setRequiredFields($event); + + $export_object =& $this->Application->recallObject('CatItemExportHelper'); + + // save export/import options + if ($event->Special == 'export') + { + $export_ids = $this->Application->RecallVar($event->Prefix.'_export_ids'); + $export_cats_ids = $this->Application->RecallVar($event->Prefix.'_export_cats_ids'); + + // used for multistep export + $field_values['export_ids'] = $export_ids ? explode(',', $export_ids) : false; + $field_values['export_cats_ids'] = $export_cats_ids ? explode(',', $export_cats_ids) : Array( $this->Application->GetVar('m_cat_id') ); + } + + $field_values['ExportColumns'] = $field_values['ExportColumns'] ? explode('|', substr($field_values['ExportColumns'], 1, -1) ) : Array(); + $field_values['start_from'] = 0; + + $this->Application->HandleEvent($nevent, $event->Prefix.':OnBeforeExportBegin', array('options'=>$field_values)); + $field_values = $nevent->getEventParam('options'); + + $export_object->saveOptions($event, $field_values); + + if( $export_object->verifyOptions($event) ) + { + if ($object->GetDBField('ExportSavePreset')) { + $name = $object->GetDBField('ExportPresetName'); + $user =& $this->Application->recallObject('u'); + $export_settings = $user->getPersistantVar('export_settings'); + $export_settings = $export_settings ? unserialize($export_settings) : array(); + $export_settings[$event->Prefix][$name] = $field_values; + $user->setPersistantVar('export_settings', serialize($export_settings)); + } + + $progress_t = $this->Application->RecallVar('export_progress_t'); + if ($progress_t) { + $this->Application->RemoveVar('export_progress_t'); + } + else { + $progress_t = $export_object->getModuleFolder($event).'/'.$event->Special.'_progress'; + } + $event->redirect = $progress_t; + } + else + { + // make uploaded file local & change source selection + $filename = getArrayValue($field_values, 'ImportFilename'); + if ($filename) { + $export_object->updateImportFiles($event); + $object->SetDBField('ImportSource', 2); + $field_values['ImportSource'] = 2; + $object->SetDBField('ImportLocalFilename', $filename); + $field_values['ImportLocalFilename'] = $filename; + $export_object->saveOptions($event, $field_values); + } + + $event->status = erFAIL; + $event->redirect = false; + } + } + + /** + * set required fields based on import or export params + * + * @param kEvent $event + */ + function setRequiredFields(&$event) + { + $required_fields['common'] = Array('FieldsSeparatedBy', 'LineEndings', 'CategoryFormat'); + + $required_fields['export'] = Array('ExportFormat', 'ExportFilename','ExportColumns'); + + $object =& $event->getObject(); + if ($object->GetDBField('ExportSavePreset')) { + $required_fields['export'][] = 'ExportPresetName'; + } + + $required_fields['import'] = Array('FieldTitles', 'ImportSource', 'CheckDuplicatesMethod'); // ImportFilename, ImportLocalFilename + + if ($event->Special == 'import') + { + $import_source = Array(1 => 'ImportFilename', 2 => 'ImportLocalFilename'); + $used_field = $import_source[ $object->GetDBField('ImportSource') ]; + + $required_fields[$event->Special][] = $used_field; + $object->Fields[$used_field]['error_field'] = 'ImportSource'; + + if ($object->GetDBField('FieldTitles') == 2) $required_fields[$event->Special][] = 'ExportColumns'; // manual field titles + } + + $required_fields = array_merge($required_fields['common'], $required_fields[$event->Special]); + foreach ($required_fields as $required_field) { + $object->setRequired($required_field, true); + } + } + } ?> Index: trunk/kernel/admin_templates/advanced_view.tpl =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/admin_templates/advanced_view.tpl (.../advanced_view.tpl) (revision 6093) +++ trunk/kernel/admin_templates/advanced_view.tpl (.../advanced_view.tpl) (revision 6583) @@ -19,60 +19,60 @@ @@ -103,7 +103,7 @@ - + @@ -115,4 +115,10 @@ + + + + \ No newline at end of file Index: trunk/kernel/units/email_messages/email_messages_event_handler.php =================================================================== diff -u -N -r1718 -r6583 --- trunk/kernel/units/email_messages/email_messages_event_handler.php (.../email_messages_event_handler.php) (revision 1718) +++ trunk/kernel/units/email_messages/email_messages_event_handler.php (.../email_messages_event_handler.php) (revision 6583) @@ -1,8 +1,8 @@ getEmailEventId(); $object =& $event->getObject(); - + $parent_info = $object->getLinkedInfo(); - + $sql = 'SELECT '.$object->IDField.' FROM '.$object->TableName.' WHERE ('.$parent_info['ForeignKey'].' = '.$parent_info['ParentId'].') AND (EventId = '.$email_event_id.')'; - + $id = (int)$this->Conn->GetOne($sql); if(!$id) { @@ -25,12 +25,12 @@ } return $id; } - + function getEmailEventId() { return parent::getPassedID( new kEvent('emailevents:OnDummy') ); } - + /** * If loading empty item, then set parent id * @@ -44,8 +44,7 @@ $event->status = erFATAL; } } - - + /** * Parse message template (split into header, subject & body) * @@ -54,15 +53,15 @@ function OnAfterItemLoad(&$event) { $object =& $event->getObject(); - + $lines = explode("\n", $object->GetDBField('Template') ); - + $headers = Array(); - + foreach($lines as $line) { if( strlen(trim($line)) == 0 || ($line == '.') ) break; - + $parts = explode(':', $line, 2); if(strtolower($parts[0]) == 'subject') { @@ -74,15 +73,15 @@ } } $object->SetDBField('Headers', implode("\n", $headers) ); - + $message_body = ''; while( (list($line_id,$line) = each($lines)) ) { $message_body .= $line; } $object->SetDBField('Body', $message_body); } - + /** * Merge body+subject+headers into message template * @@ -92,7 +91,7 @@ { $this->parseVirtualFields($event); } - + /** * Merge body+subject+headers into message template * @@ -102,7 +101,7 @@ { $this->parseVirtualFields($event); } - + /** * Merge body+subject+headers into message template * @@ -122,7 +121,7 @@ $object->SetDBField('Template', $ret); } } - + /** * Remove trailing CR/LF chars from string * Index: trunk/core/units/categories/categories_event_handler.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6093) +++ trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6583) @@ -250,12 +250,11 @@ function GetPassedId(&$event) { - if ( $this->Application->IsAdmin() ) return parent::getPassedID($event); - - $ret = $this->Application->GetVar('m_cat_id'); - if($ret) return $ret; - + if ( $this->Application->IsAdmin() ) { return parent::getPassedID($event); + } + + return $this->Application->GetVar('m_cat_id'); } /** Index: trunk/core/units/general/cat_event_handler.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 6428) +++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 6583) @@ -129,6 +129,7 @@ if ($clipboard_data['copy']) { $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); + $this->Application->SetVar('ResetCatBeforeClone', 1); $temp->CloneItems($event->Prefix, $event->Special, $clipboard_data['copy']); } @@ -460,7 +461,8 @@ if ($event->Special == 'export' || $event->Special == 'import') { - $this->prepareExportColumns($event); + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $export_helper->prepareExportColumns($event); } } @@ -1329,17 +1331,6 @@ /* === RELATED TO IMPORT/EXPORT: BEGIN === */ /** - * Returns module folder - * - * @param kEvent $event - * @return string - */ - function getModuleFolder(&$event) - { - return $this->Application->getUnitOption($event->Prefix, 'ModuleFolder'); - } - - /** * Shows export dialog * * @param kEvent $event @@ -1366,7 +1357,8 @@ $this->Application->StoreVar($event->Prefix.'_export_ids', $selected_ids ? implode(',', $selected_ids) : '' ); $this->Application->StoreVar($event->Prefix.'_export_cats_ids', $selected_cats_ids); - $event->redirect = $this->getModuleFolder($event).'/export'; + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $event->redirect = $export_helper->getModuleFolder($event).'/export'; $redirect_params = Array( 'm_opener' => 'd', $this->Prefix.'.export_event' => 'OnNew', @@ -1376,181 +1368,6 @@ } /** - * Export form validation & processing - * - * @param kEvent $event - */ - function OnExportBegin(&$event) - { - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - if (!$items_info) - { - $items_info = unserialize( $this->Application->RecallVar($event->getPrefixSpecial().'_ItemsInfo') ); - $this->Application->SetVar($event->getPrefixSpecial(true), $items_info); - } - - list($item_id, $field_values) = each($items_info); - - $object =& $event->getObject( Array('skip_autoload' => true) ); - $object->SetFieldsFromHash($field_values); - $field_values['ImportFilename'] = $object->GetDBField('ImportFilename'); //if upload formatter has renamed the file during moving !!! - - $object->setID($item_id); - $this->setRequiredFields($event); - - $export_object =& $this->Application->recallObject('CatItemExportHelper'); - - // save export/import options - if ($event->Special == 'export') - { - $export_ids = $this->Application->RecallVar($event->Prefix.'_export_ids'); - $export_cats_ids = $this->Application->RecallVar($event->Prefix.'_export_cats_ids'); - - // used for multistep export - $field_values['export_ids'] = $export_ids ? explode(',', $export_ids) : false; - $field_values['export_cats_ids'] = $export_cats_ids ? explode(',', $export_cats_ids) : Array( $this->Application->GetVar('m_cat_id') ); - } - - $field_values['ExportColumns'] = $field_values['ExportColumns'] ? explode('|', substr($field_values['ExportColumns'], 1, -1) ) : Array(); - $field_values['start_from'] = 0; - $export_object->saveOptions($event, $field_values); - - if( $export_object->verifyOptions($event) ) - { - $event->redirect = $this->getModuleFolder($event).'/'.$event->Special.'_progress'; - - } - else - { - // make uploaded file local & change source selection - $filename = getArrayValue($field_values, 'ImportFilename'); - if ($filename) { - $this->updateImportFiles($event); - $object->SetDBField('ImportSource', 2); - $field_values['ImportSource'] = 2; - $object->SetDBField('ImportLocalFilename', $filename); - $field_values['ImportLocalFilename'] = $filename; - $export_object->saveOptions($event, $field_values); - } - - $event->status = erFAIL; - $event->redirect = false; - } - } - - /** - * Enter description here... - * - * @param kEvent $event - */ - function OnExportCancel(&$event) - { - $this->OnGoBack($event); - } - - /** - * Sets correct available & export fields - * - * @param kEvent $event - */ - function prepareExportColumns(&$event) - { - $object =& $event->getObject( Array('skip_autoload' => true) ); - - $available_columns = Array(); - - // category field (mixed) - $available_columns['__CATEGORY__CategoryPath'] = 'CategoryPath'; - - if ($event->Special == 'import') { - // category field (separated fields) - $max_level = $this->Application->ConfigValue('MaxImportCategoryLevels'); - $i = 0; - while ($i < $max_level) { - $available_columns['__CATEGORY__Category'.($i + 1)] = 'Category'.($i + 1); - $i++; - } - } - - // db fields - foreach ($object->Fields as $field_name => $field_options) - { - if (!$object->SkipField($field_name)) - { - $available_columns[$field_name] = $field_name.(getArrayValue($field_options, 'required') ? '*' : ''); - } - } - - $available_columns = array_merge_recursive2($available_columns, $this->getCustomExportColumns($event)); - - // custom fields - foreach ($object->customFields as $custom_id => $custom_name) - { - $available_columns['__CUSTOM__'.$custom_name] = $custom_name; - } - - // columns already in use - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - if ($items_info) - { - list($item_id, $field_values) = each($items_info); - $export_keys = $field_values['ExportColumns']; - $export_keys = $export_keys ? explode('|', substr($export_keys, 1, -1) ) : Array(); - } - else { - $export_keys = Array(); - } - - $export_columns = Array(); - foreach ($export_keys as $field_key) - { - $field_name = $this->getExportField($field_key); - $export_columns[$field_key] = $field_name; - unset($available_columns[$field_key]); - } - - $options = $object->GetFieldOptions('ExportColumns'); - $options['options'] = $export_columns; - $object->SetFieldOptions('ExportColumns', $options); - - $options = $object->GetFieldOptions('AvailableColumns'); - $options['options'] = $available_columns; - $object->SetFieldOptions('AvailableColumns', $options); - - $this->updateImportFiles($event); - } - - /** - * Updates uploaded files list - * - * @param kEvent $event - */ - function updateImportFiles(&$event) - { - if ($event->Special != 'import') { - return false; - } - - $object =& $event->getObject(); - - $import_filenames = Array(); - - if ($folder_handle = opendir(EXPORT_PATH)) { - while (false !== ($file = readdir($folder_handle))) { - if (is_dir(EXPORT_PATH.'/'.$file) || substr($file, 0, 1) == '.' || strtolower($file) == 'cvs' || strtolower($file) == 'dummy' || filesize(EXPORT_PATH.'/'.$file) == 0) continue; - - $file_size = formatSize( filesize(EXPORT_PATH.'/'.$file) ); - $import_filenames[$file] = $file.' ('.$file_size.')'; - } - closedir($folder_handle); - } - - $options = $object->GetFieldOptions('ImportLocalFilename'); - $options['options'] = $import_filenames; - $object->SetFieldOptions('ImportLocalFilename', $options); - } - - /** * Returns specific to each item type columns only * * @param kEvent $event @@ -1631,22 +1448,6 @@ return preg_match('#(http|https)://(.*)#', $path); } -// ImportLocalFilename - - function getExportField($field_key) - { - $prepends = Array('__CUSTOM__', '__CATEGORY__'); - foreach ($prepends as $prepend) - { - if (substr($field_key, 0, strlen($prepend) ) == $prepend) - { - $field_key = substr($field_key, strlen($prepend), strlen($field_key) ); - break; - } - } - return $field_key; - } - /** * Prepares item for import/export operations * @@ -1657,41 +1458,12 @@ parent::OnNew($event); if ($event->Special != 'import' && $event->Special != 'export') return ; - $this->setRequiredFields($event); + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $export_helper->setRequiredFields($event); $this->Application->StoreVar('ImportCategory', 0); } /** - * set required fields based on import or export params - * - * @param kEvent $event - */ - function setRequiredFields(&$event) - { - $required_fields['common'] = Array('FieldsSeparatedBy', 'LineEndings', 'CategoryFormat'); - - $required_fields['export'] = Array('ExportFormat', 'ExportFilename','ExportColumns'); - $required_fields['import'] = Array('FieldTitles', 'ImportSource', 'CheckDuplicatesMethod'); // ImportFilename, ImportLocalFilename - - $object =& $event->getObject(); - if ($event->Special == 'import') - { - $import_source = Array(1 => 'ImportFilename', 2 => 'ImportLocalFilename'); - $used_field = $import_source[ $object->GetDBField('ImportSource') ]; - - $required_fields[$event->Special][] = $used_field; - $object->Fields[$used_field]['error_field'] = 'ImportSource'; - - if ($object->GetDBField('FieldTitles') == 2) $required_fields[$event->Special][] = 'ExportColumns'; // manual field titles - } - - $required_fields = array_merge($required_fields['common'], $required_fields[$event->Special]); - foreach ($required_fields as $required_field) { - $object->setRequired($required_field, true); - } - } - - /** * Process items selected in item_selector * * @param kEvent $event @@ -1871,6 +1643,21 @@ } /** + * Occures before an item is cloneded + * Id of ORIGINAL item is passed as event' 'id' param + * Do not call object' Update method in this event, just set needed fields! + * + * @param kEvent $event + */ + function OnBeforeClone(&$event) + { + if ($this->Application->GetVar('ResetCatBeforeClone')) { + $object =& $event->getObject(); + $object->SetDBField('CategoryId', null); + } + } + + /** * Apply same processing to each item beeing selected in grid * * @param kEvent $event Index: trunk/admin/install/upgrades/inportal_upgrade_v1.3.1.sql =================================================================== diff -u -N --- trunk/admin/install/upgrades/inportal_upgrade_v1.3.1.sql (revision 0) +++ trunk/admin/install/upgrades/inportal_upgrade_v1.3.1.sql (revision 6583) @@ -0,0 +1,12 @@ +UPDATE StatItem SET ValueSQL = REPLACE(ValueSQL, 'Topic_VotesToHot', 'Topic_MaxHotNumber'); +UPDATE StatItem SET ValueSQL = REPLACE(ValueSQL, 'Link_VotesToHot', 'Link_MaxHotNumber'); +UPDATE StatItem SET ValueSQL = REPLACE(ValueSQL, 'News_VotesToHot', 'News_MaxHotNumber'); + +ALTER TABLE Language CHANGE ThousandSep ThousandSep TINYTEXT NULL; + +UPDATE Phrase SET Translation = TRIM(TRAILING CHAR(10) FROM Translation); +UPDATE Phrase SET Translation = TRIM(TRAILING CHAR(13) FROM Translation); +UPDATE Phrase SET Translation = TRIM(TRAILING CHAR(10) FROM Translation); +UPDATE Phrase SET Translation = TRIM(TRAILING CHAR(13) FROM Translation); + +UPDATE Modules SET Version = '1.3.1' WHERE Name = 'In-Portal'; \ No newline at end of file Index: trunk/admin/install/inportal_schema.sql =================================================================== diff -u -N -r6093 -r6583 --- trunk/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 6093) +++ trunk/admin/install/inportal_schema.sql (.../inportal_schema.sql) (revision 6583) @@ -291,7 +291,7 @@ InputDateFormat varchar(50) NOT NULL default '', InputTimeFormat varchar(50) NOT NULL default '', DecimalPoint char(2) NOT NULL default '.', - ThousandSep char(1) NOT NULL default ',', + ThousandSep tinytext NULL, Charset varchar(20) NOT NULL default '', UnitSystem tinyint(4) NOT NULL default '1', PRIMARY KEY (LanguageId) Index: trunk/kernel/units/general/general_config.php =================================================================== diff -u -N -r5272 -r6583 --- trunk/kernel/units/general/general_config.php (.../general_config.php) (revision 5272) +++ trunk/kernel/units/general/general_config.php (.../general_config.php) (revision 6583) @@ -15,8 +15,10 @@ 'TitleField' => 'CachedNavbar', 'TitlePhrase' => 'la_Text_Category', 'ItemType' => 1, - 'TableName' => TABLE_PREFIX.'Category', - + 'TableName' => TABLE_PREFIX.'Category', + + 'CatalogItem' => true, + 'PortalStyleEnv' => true, 'PermTabText' => 'In-Portal', Index: trunk/kernel/admin_templates/xml/categories_list.tpl =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/admin_templates/xml/categories_list.tpl (.../categories_list.tpl) (revision 6093) +++ trunk/kernel/admin_templates/xml/categories_list.tpl (.../categories_list.tpl) (revision 6583) @@ -1,3 +1,5 @@ + + Index: trunk/core/kernel/db/db_event_handler.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 6428) +++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 6583) @@ -116,9 +116,10 @@ 'OnPreCreate' => Array('self' => 'add|add.pending'), 'OnEdit' => Array('self' => 'edit|edit.pending'), + 'OnExport' => Array('self' => 'view|advanced:export'), + 'OnExportBegin' => Array('self' => 'view|advanced:export'), - // theese event do not harm, but just in case check them too :) 'OnCancelEdit' => Array('self' => true, 'subitem' => true), 'OnCancel' => Array('self' => true, 'subitem' => true), @@ -1659,6 +1660,23 @@ $this->Application->StoreVar( $event->getPrefixSpecial().'_view_filter', serialize($view_filter) ); } + function OnSetFilterPattern(&$event) + { + $filters = $this->Application->GetVar($event->getPrefixSpecial(true).'_filters'); + if (!$filters) return ; + + $view_filter = $this->Application->RecallVar($event->getPrefixSpecial().'_view_filter'); + $view_filter = $view_filter ? unserialize($view_filter) : Array(); + + $filters = explode(',', $filters); + foreach ($filters as $a_filter) { + list($id, $value) = explode('=', $a_filter); + $view_filter[$id] = $value; + } + $this->Application->StoreVar( $event->getPrefixSpecial().'_view_filter', serialize($view_filter) ); + $event->redirect = false; + } + /** * Add/Remove all filters applied to list from "View" menu * @@ -1778,7 +1796,7 @@ $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); // 3. create virtual & calculated fields (for main item) - $calculated_fields = $this->Application->getUnitOption($main_prefix.'.', 'CalculatedFields', Array()); + $calculated_fields = Array(); $virtual_fields = $this->Application->getUnitOption($main_prefix, 'VirtualFields', Array()); $cf_helper =& $this->Application->recallObject('InpCustomFieldsHelper'); @@ -1814,8 +1832,14 @@ $virtual_fields['cust_'.$custom_name] = array_merge_recursive2($field_options, $virtual_fields['cust_'.$custom_name]); $custom_fields[$custom_id] = $custom_name; } + + $config_calculated_fields = $this->Application->getUnitOption($main_prefix, 'CalculatedFields', Array()); + foreach ($config_calculated_fields as $special => $special_fields) { + $config_calculated_fields[$special] = array_merge_recursive2($config_calculated_fields[$special], $calculated_fields); + } + $this->Application->setUnitOption($main_prefix, 'CalculatedFields', $config_calculated_fields); + $this->Application->setUnitOption($main_prefix, 'CustomFields', $custom_fields); - $this->Application->setUnitOption($main_prefix.'.', 'CalculatedFields', $calculated_fields); $this->Application->setUnitOption($main_prefix, 'VirtualFields', $virtual_fields); } @@ -1858,6 +1882,131 @@ $this->finalizePopup($event); } + +/** EXPORT RELATED **/ + + /** + * Shows export dialog + * + * @param kEvent $event + */ + function OnExport(&$event) + { + $this->StoreSelectedIDs($event); + $selected_ids = $this->getSelectedIDs($event); + + if (implode(',', $selected_ids) == '') { + // K4 fix when no ids found bad selected ids array is formed + $selected_ids = false; + } + + $this->Application->StoreVar($event->Prefix.'_export_ids', $selected_ids ? implode(',', $selected_ids) : '' ); + + $export_t = $this->Application->GetVar('export_template'); + $this->Application->LinkVar('export_finish_t'); + $this->Application->LinkVar('export_progress_t'); + $this->Application->StoreVar('export_oroginal_special', $event->Special); + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $event->redirect = $export_t ? $export_t : $export_helper->getModuleFolder($event).'/export'; + + $redirect_params = Array( 'm_opener' => 'd', + $this->Prefix.'.export_event' => 'OnNew', + 'pass' => 'all,'.$this->Prefix.'.export'); + + $event->setRedirectParams($redirect_params); + } + + /** + * Apply some special processing to + * object beeing recalled before using + * it in other events that call prepareObject + * + * @param Object $object + * @param kEvent $event + * @access protected + */ + function prepareObject(&$object, &$event) + { + if ($event->Special == 'export' || $event->Special == 'import') + { + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $export_helper->prepareExportColumns($event); + } + } + + /** + * Returns specific to each item type columns only + * + * @param kEvent $event + * @return Array + */ + function getCustomExportColumns(&$event) + { + return Array(); + } + + /** + * Export form validation & processing + * + * @param kEvent $event + */ + function OnExportBegin(&$event) + { + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $export_helper->OnExportBegin($event); + } + + /** + * Enter description here... + * + * @param kEvent $event + */ + function OnExportCancel(&$event) + { + $this->OnGoBack($event); + } + + /** + * Allows configuring export options + * + * @param kEvent $event + */ + function OnBeforeExportBegin(&$event) + { + + } + + function OnDeleteExportPreset(&$event) + { + $object =& $event->GetObject(); + + $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); + if($items_info) + { + list($id,$field_values) = each($items_info); + $preset_key = $field_values['ExportPresets']; + + $user =& $this->Application->recallObject('u'); + $export_settings = $user->getPersistantVar('export_settings'); + if (!$export_settings) return ; + $export_settings = unserialize($export_settings); + if (!isset($export_settings[$event->Prefix])) return ; + + $to_delete = ''; + $export_presets = array(''=>''); + foreach ($export_settings[$event->Prefix] as $key => $val) { + if (implode('|', $val['ExportColumns']) == $preset_key) { + $to_delete = $key; + break; + } + } + if ($to_delete) { + unset($export_settings[$event->Prefix][$to_delete]); + $user->setPersistantVar('export_settings', serialize($export_settings)); + } + } + } + } Index: trunk/core/kernel/utility/formatters/formatter.php =================================================================== diff -u -N -r4758 -r6583 --- trunk/core/kernel/utility/formatters/formatter.php (.../formatter.php) (revision 4758) +++ trunk/core/kernel/utility/formatters/formatter.php (.../formatter.php) (revision 6583) @@ -20,6 +20,17 @@ $type_ok = preg_match('#int|integer|double|float|real|numeric|string#', $field_type); if($field_type == 'string') return $value; + static $comma = null; + static $thousands = null; + if (is_null($comma) || is_null($thousands)) { + $lang =& $this->Application->recallObject('lang.current'); + $comma = $lang->GetDBField('DecimalPoint'); + $thousands = $lang->GetDBField('ThousandSep'); + } + + $value = str_replace($thousands, '', $value); + $value = str_replace($comma, '.', $value); + if ($value != '' && $type_ok) { $ret = is_numeric($value); @@ -43,10 +54,17 @@ $options = $object->GetFieldOptions($field_name); if ( isset($format) ) $options['format'] = $format; $tc_value = $this->TypeCast($value,$options); - if( ($tc_value === false) || ($tc_value != $value) ) return $value; // for leaving badly formatted date on the form + if( ($tc_value === false) || ("$tc_value" != "$value") ) return $value; // for leaving badly formatted date on the form - if (isset($options['format'])) return sprintf($options['format'], $tc_value); + if (isset($options['format'])) { + $tc_value = sprintf($options['format'], $tc_value); + } + if (preg_match('#int|integer|double|float|real|numeric#', $options['type'])) { + $lang =& $this->Application->recallObject('lang.current'); + return $lang->formatNumber($tc_value); + } + return $tc_value; } Index: trunk/kernel/units/custom_fields/custom_fields_config.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/custom_fields/custom_fields_config.php (.../custom_fields_config.php) (revision 6093) +++ trunk/kernel/units/custom_fields/custom_fields_config.php (.../custom_fields_config.php) (revision 6583) @@ -88,6 +88,7 @@ 'VirtualFields' => Array( 'Value' => Array('type' => 'string', 'default' => ''), 'OriginalValue' => Array('type' => 'string', 'default' => ''), + 'Error' => Array('type' => 'string', 'default' => ''), ), @@ -108,6 +109,7 @@ 'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_icon_td'), 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td', 'ElementTypeField' => 'ElementType'), 'Value' => Array( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td'), + 'Error' => Array( 'title'=>'la_col_Error', 'data_block' => 'custom_error_td'), ), ), Index: trunk/core/units/general/cat_tag_processor.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 6428) +++ trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 6583) @@ -63,26 +63,6 @@ return $this->Application->ProcessParsedTag('m', 't', $params); } - /** - * Returns path where exported category items should be saved - * - * @param Array $params - */ - function ExportPath($params) - { - $ret = EXPORT_PATH.'/'; - - if( getArrayValue($params, 'as_url') ) - { - $ret = str_replace( FULL_PATH.'/', $this->Application->BaseURL(), $ret); - } - - $export_options = unserialize($this->Application->RecallVar($this->getPrefixSpecial().'_options')); - $ret .= $export_options['ExportFilename'].'.'.($export_options['ExportFormat'] == 1 ? 'csv' : 'xml'); - - return $ret; - } - function CategoryPath($params) { if (!isset($params['cat_id'])) { Index: trunk/kernel/admin_templates/incs/form_blocks.tpl =================================================================== diff -u -N -r6428 -r6583 --- trunk/kernel/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 6428) +++ trunk/kernel/admin_templates/incs/form_blocks.tpl (.../form_blocks.tpl) (revision 6583) @@ -297,7 +297,7 @@ " name="" value=""> - " type="checkbox" id="_cb_" name="_cb_" class="" onchange="update_checkbox(this, document.getElementById(''));"> + " type="checkbox" id="_cb_" name="_cb_" class="" onchange="update_checkbox(this, document.getElementById(''));" onclick="">   Index: trunk/core/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 6428) +++ trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 6583) @@ -280,7 +280,13 @@ function IsCurrent($params) { - return false; + $object =& $this->getObject($params); + if ($object->GetID() == $this->Application->GetVar('m_cat_id')) { + return true; + } + else { + return false; + } } /** Index: trunk/kernel/admin_templates/catalog_tab.tpl =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/admin_templates/catalog_tab.tpl (.../catalog_tab.tpl) (revision 6093) +++ trunk/kernel/admin_templates/catalog_tab.tpl (.../catalog_tab.tpl) (revision 6583) @@ -2,6 +2,8 @@
+ + @@ -19,9 +21,9 @@ #separator# - + - + _" width="50%"> radiocheckbox" name="" id=""> @@ -39,7 +41,7 @@ - + @@ -50,7 +52,7 @@
- +
Index: trunk/core/units/languages/languages_item.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/units/languages/languages_item.php (.../languages_item.php) (revision 6093) +++ trunk/core/units/languages/languages_item.php (.../languages_item.php) (revision 6583) @@ -31,6 +31,9 @@ */ function formatNumber($number, $precision = null) { + if (is_null($precision)) { + $precision = preg_match('/[\.,]+/', $number) ? strlen(preg_replace('/^.*[\.,]+/', '', $number)) : 0; + } return number_format($number, $precision, $this->GetDBField('DecimalPoint'), $this->GetDBField('ThousandSep')); } Index: trunk/kernel/admin_templates/summary/root.tpl =================================================================== diff -u -N -r4651 -r6583 --- trunk/kernel/admin_templates/summary/root.tpl (.../root.tpl) (revision 4651) +++ trunk/kernel/admin_templates/summary/root.tpl (.../root.tpl) (revision 6583) @@ -11,13 +11,13 @@   - + - + - +
- +
oInfooValue" align="center"> @@ -32,15 +32,15 @@
- + - + @@ -49,7 +49,7 @@ - +
- +
- + - + - + @@ -115,4 +115,10 @@ + + + + \ No newline at end of file Index: trunk/core/admin_templates/summary/root.tpl =================================================================== diff -u -N -r4651 -r6583 --- trunk/core/admin_templates/summary/root.tpl (.../root.tpl) (revision 4651) +++ trunk/core/admin_templates/summary/root.tpl (.../root.tpl) (revision 6583) @@ -11,13 +11,13 @@ -
()
@@ -94,7 +94,7 @@ - +
"> " border="0" alt="" title="" /> " class="userslink"> () @@ -106,7 +106,7 @@
- + @@ -115,19 +115,19 @@ - + " > - + - + @@ -90,6 +90,11 @@ + + + Index: trunk/kernel/units/general/helpers/permissions_helper.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/kernel/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6428) +++ trunk/kernel/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6583) @@ -216,6 +216,7 @@ function showDebug($text, $params) { + return ; $is_ajax = $this->Application->GetVar('ajax') == 'yes' || isset($params['ajax']) || isset($params['tab_init']); if (!$this->Application->isDebugMode() || $is_ajax) return true; echo $text.'
'; Index: trunk/kernel/units/relationship/relationship_event_handler.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 6093) +++ trunk/kernel/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 6583) @@ -22,7 +22,7 @@ */ function OnNew(&$event) { - parent::OnNew(&$event); + parent::OnNew($event); $object =& $event->getObject(); $table_info = $object->getLinkedInfo(); Index: trunk/core/units/email_messages/email_messages_event_handler.php =================================================================== diff -u -N -r1718 -r6583 --- trunk/core/units/email_messages/email_messages_event_handler.php (.../email_messages_event_handler.php) (revision 1718) +++ trunk/core/units/email_messages/email_messages_event_handler.php (.../email_messages_event_handler.php) (revision 6583) @@ -1,8 +1,8 @@ getEmailEventId(); $object =& $event->getObject(); - + $parent_info = $object->getLinkedInfo(); - + $sql = 'SELECT '.$object->IDField.' FROM '.$object->TableName.' WHERE ('.$parent_info['ForeignKey'].' = '.$parent_info['ParentId'].') AND (EventId = '.$email_event_id.')'; - + $id = (int)$this->Conn->GetOne($sql); if(!$id) { @@ -25,12 +25,12 @@ } return $id; } - + function getEmailEventId() { return parent::getPassedID( new kEvent('emailevents:OnDummy') ); } - + /** * If loading empty item, then set parent id * @@ -44,8 +44,7 @@ $event->status = erFATAL; } } - - + /** * Parse message template (split into header, subject & body) * @@ -54,15 +53,15 @@ function OnAfterItemLoad(&$event) { $object =& $event->getObject(); - + $lines = explode("\n", $object->GetDBField('Template') ); - + $headers = Array(); - + foreach($lines as $line) { if( strlen(trim($line)) == 0 || ($line == '.') ) break; - + $parts = explode(':', $line, 2); if(strtolower($parts[0]) == 'subject') { @@ -74,15 +73,15 @@ } } $object->SetDBField('Headers', implode("\n", $headers) ); - + $message_body = ''; while( (list($line_id,$line) = each($lines)) ) { $message_body .= $line; } $object->SetDBField('Body', $message_body); } - + /** * Merge body+subject+headers into message template * @@ -92,7 +91,7 @@ { $this->parseVirtualFields($event); } - + /** * Merge body+subject+headers into message template * @@ -102,7 +101,7 @@ { $this->parseVirtualFields($event); } - + /** * Merge body+subject+headers into message template * @@ -122,7 +121,7 @@ $object->SetDBField('Template', $ret); } } - + /** * Remove trailing CR/LF chars from string * Index: trunk/core/kernel/parser/construct_tags.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/kernel/parser/construct_tags.php (.../construct_tags.php) (revision 6093) +++ trunk/core/kernel/parser/construct_tags.php (.../construct_tags.php) (revision 6583) @@ -39,7 +39,7 @@ function GetLogic() { - if ($this->SkipMode != parse) { + if ($this->Parser->SkipMode != parse) { $this->Logic = false; return; } Index: trunk/core/units/general/general_config.php =================================================================== diff -u -N -r5272 -r6583 --- trunk/core/units/general/general_config.php (.../general_config.php) (revision 5272) +++ trunk/core/units/general/general_config.php (.../general_config.php) (revision 6583) @@ -15,8 +15,10 @@ 'TitleField' => 'CachedNavbar', 'TitlePhrase' => 'la_Text_Category', 'ItemType' => 1, - 'TableName' => TABLE_PREFIX.'Category', - + 'TableName' => TABLE_PREFIX.'Category', + + 'CatalogItem' => true, + 'PortalStyleEnv' => true, 'PermTabText' => 'In-Portal', Index: trunk/core/units/custom_fields/custom_fields_config.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/units/custom_fields/custom_fields_config.php (.../custom_fields_config.php) (revision 6093) +++ trunk/core/units/custom_fields/custom_fields_config.php (.../custom_fields_config.php) (revision 6583) @@ -88,6 +88,7 @@ 'VirtualFields' => Array( 'Value' => Array('type' => 'string', 'default' => ''), 'OriginalValue' => Array('type' => 'string', 'default' => ''), + 'Error' => Array('type' => 'string', 'default' => ''), ), @@ -108,6 +109,7 @@ 'FieldName' => Array( 'title'=>'la_col_FieldName', 'data_block' => 'grid_icon_td'), 'Prompt' => Array( 'title'=>'la_col_Prompt', 'data_block' => 'grid_data_label_ml_td', 'ElementTypeField' => 'ElementType'), 'Value' => Array( 'title'=>'la_col_Value', 'data_block' => 'edit_custom_td'), + 'Error' => Array( 'title'=>'la_col_Error', 'data_block' => 'custom_error_td'), ), ), Index: trunk/kernel/units/general/cat_dbitem.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 6093) +++ trunk/kernel/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 6583) @@ -60,8 +60,9 @@ $ret = parent::Create(); if ($ret) { + $primary_category = $this->GetDBField('CategoryId') > 0 ? $this->GetDBField('CategoryId') : $this->Application->GetVar('m_cat_id'); $fields_hash = Array( - 'CategoryId' => $this->Application->GetVar('m_cat_id'), + 'CategoryId' => $primary_category, 'ItemResourceId' => $this->GetField('ResourceId'), 'PrimaryCat' => 1, 'ItemPrefix' => $this->Prefix, Index: trunk/core/admin_templates/catalog/advanced_view.tpl =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/admin_templates/catalog/advanced_view.tpl (.../advanced_view.tpl) (revision 6093) +++ trunk/core/admin_templates/catalog/advanced_view.tpl (.../advanced_view.tpl) (revision 6583) @@ -19,60 +19,60 @@ @@ -103,7 +103,7 @@ +
- +
- "> + ">
"> @@ -141,15 +141,14 @@
- - - - - - - - - - - \ No newline at end of file + + + + + + + + + + Index: trunk/core/kernel/db/db_tag_processor.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 6428) +++ trunk/core/kernel/db/db_tag_processor.php (.../db_tag_processor.php) (revision 6583) @@ -1587,6 +1587,53 @@ return $ret; } + function ExportStatus($params) + { + $export_object =& $this->Application->recallObject('CatItemExportHelper'); + + $event = new kEvent($this->getPrefixSpecial().':OnDummy'); + + $action_method = 'perform'.ucfirst($this->Special); + $field_values = $export_object->$action_method($event); + + // finish code is done from JS now + if ($field_values['start_from'] == $field_values['total_records']) + { + if ($this->Special == 'import') { + $this->Application->StoreVar('PermCache_UpdateRequired', 1); + $this->Application->Redirect('categories/cache_updater', Array('m_opener' => 'r', 'pass' => 'm', 'continue' => 1, 'no_amp' => 1)); + } + elseif ($this->Special == 'export') { + $finish_t = $this->Application->RecallVar('export_finish_t'); + $this->Application->Redirect($finish_t, Array('pass' => 'all')); + $this->Application->RemoveVar('export_finish_t'); + } + } + + $export_options = $export_object->loadOptions($event); + return $export_options['start_from'] * 100 / $export_options['total_records']; + } + + /** + * Returns path where exported category items should be saved + * + * @param Array $params + */ + function ExportPath($params) + { + $ret = EXPORT_PATH.'/'; + + if( getArrayValue($params, 'as_url') ) + { + $ret = str_replace( FULL_PATH.'/', $this->Application->BaseURL(), $ret); + } + + $export_options = unserialize($this->Application->RecallVar($this->getPrefixSpecial().'_options')); + $ret .= $export_options['ExportFilename'].'.'.($export_options['ExportFormat'] == 1 ? 'csv' : 'xml'); + + return $ret; + } + } ?> \ No newline at end of file Index: trunk/core/units/users/users_event_handler.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 6428) +++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 6583) @@ -641,7 +641,7 @@ function OnSubscribeUser(&$event){ - $object = &$this->Application->recallObject($this->Prefix.'.subscriber', Array('skip_autoload' => true)); + $object = &$this->Application->recallObject($this->Prefix.'.subscriber', null, Array('skip_autoload' => true)); $user_email = $this->Application->RecallVar('SubscriberEmail'); Index: trunk/kernel/units/users/users_item.php =================================================================== diff -u -N -r4758 -r6583 --- trunk/kernel/units/users/users_item.php (.../users_item.php) (revision 4758) +++ trunk/kernel/units/users/users_item.php (.../users_item.php) (revision 6583) @@ -2,20 +2,22 @@ class UsersItem extends kDBItem { var $persistantVars = Array(); - - function LoadPersistantVars() + + function LoadPersistantVars($id=null) { + $id = $id == -1 ? -1 : $this->GetID(); + if (!$id) return ; $sql = 'SELECT VariableValue, VariableName FROM '.TABLE_PREFIX.'PersistantSessionData - WHERE PortalUserId = '.$this->GetID(); + WHERE PortalUserId = '.$id; $this->persistantVars = $this->Conn->GetCol($sql, 'VariableName'); } - + function setPersistantVar($var_name, $var_value) { $this->persistantVars[$var_name] = $var_value; - - if ($this->GetID() > 0) { + + if ($this->GetID() > 0 || $this->GetID() == -1) { $replace_hash = Array( 'PortalUserId' => $this->GetID(), 'VariableName' => $var_name, 'VariableValue' => $var_value @@ -26,21 +28,21 @@ $this->Application->StoreVar($var_name, $var_value); } } - + function getPersistantVar($var_name) { return getArrayValue($this->persistantVars, $var_name); } - + function Load($id, $id_field_name = null) { $ret = parent::Load($id, $id_field_name); - if ($ret) { - $this->LoadPersistantVars(); + if ($ret || $id == -1) { + $this->LoadPersistantVars($id); } return $ret; } - + /** * Returns IDs of groups to which user belongs and membership is not expired * @@ -61,7 +63,7 @@ return explode(',', $user_groups); } } - + /** * Set's Login from Email if required by configuration settings * @@ -70,10 +72,10 @@ { if( $this->Application->ConfigValue('Email_As_Login') ) { - $this->SetDBField('Login', $this->GetDBField('Email') ); + $this->SetDBField('Login', $this->GetDBField('Email') ); } } - + function SendEmailEvents() { switch( $this->GetDBField('Status') ) @@ -82,25 +84,25 @@ $this->Application->EmailEventAdmin('USER.ADD', $this->GetID() ); $this->Application->EmailEventUser('USER.ADD', $this->GetID() ); break; - + case 2: $this->Application->EmailEventAdmin('USER.ADD.PENDING', $this->GetID() ); $this->Application->EmailEventUser('USER.ADD.PENDING', $this->GetID() ); break; } } - + function isSubscriberOnly() { $subscribers_group_id = $this->Application->ConfigValue('User_SubscriberGroup'); $sql = 'SELECT PortalUserId FROM '.TABLE_PREFIX.'UserGroup - WHERE GroupId = '.$subscribers_group_id.' AND - PortalUserId = '.$this->GetDBField('PortalUserId').' AND + WHERE GroupId = '.$subscribers_group_id.' AND + PortalUserId = '.$this->GetDBField('PortalUserId').' AND PrimaryGroup = 1'; return $this->Conn->GetOne($sql) == $this->GetDBField('PortalUserId'); } - + function Create($force_id=false, $system_create=false) { $ret = parent::Create($force_id, $system_create); @@ -111,8 +113,8 @@ } return $ret; } - - + + function Update($id=null, $system_update=false) { $ret = parent::Update($id, $system_update); @@ -123,7 +125,7 @@ } return $ret; } - + /** * Deletes the record from databse * @@ -137,14 +139,14 @@ $sync_manager =& $this->Application->recallObjectP('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); $sync_manager->performAction('deleteUser', $this->FieldValues); } - + return $ret; } - + function setName($full_name) { $full_name = explode(' ', $full_name); - + if (count($full_name) > 2) { $last_name = array_pop($full_name); $first_name = implode(' ', $full_name); @@ -153,11 +155,11 @@ $last_name = $full_name[1]; $first_name = $full_name[0]; } - + $this->SetDBField('FirstName', $first_name); $this->SetDBField('LastName', $last_name); } - - + + } ?> \ No newline at end of file Index: trunk/kernel/units/email_events/email_events_config.php =================================================================== diff -u -N -r3348 -r6583 --- trunk/kernel/units/email_events/email_events_config.php (.../email_events_config.php) (revision 3348) +++ trunk/kernel/units/email_events/email_events_config.php (.../email_events_config.php) (revision 6583) @@ -7,23 +7,23 @@ 'EventHandlerClass' => Array('class'=>'EmailEventsEventsHandler','file'=>'email_events_event_handler.php','build_event'=>'OnBuild'), 'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'), 'AutoLoad' => true, - + 'QueryString' => Array( 1 => 'id', 2 => 'page', 3 => 'event', ), - + 'IDField' => 'EventId', - + 'StatusField' => Array('Enabled'), - + 'TitleField' => 'Event', - + 'TitlePresets' => Array( 'email_settings_list' => Array('prefixes' => Array('emailevents.module_List'), 'format' => '!la_title_EmailSettings! (#emailevents.module_recordcount#)'), ), - + 'FilterMenu' => Array( 'Groups' => Array( Array('mode' => 'AND', 'filters' => Array('show_enabled','show_disabled','show_frontonly'), 'type' => WHERE_FILTER), @@ -34,28 +34,28 @@ 'show_frontonly' => Array('label' => 'la_Text_FrontOnly', 'on_sql' => '', 'off_sql' => '%1$s.Enabled != 2' ), ) ), - + 'TableName' => TABLE_PREFIX.'Events', 'CalculatedFields' => Array( '' => Array ( 'FromUser' => 'u.Login', ) ), - + 'ListSQLs' => Array( ''=>' SELECT %1$s.* %2$s FROM %1$s LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON %1$s.FromUserId = u.PortalUserId', ), // key - special, value - list select sql), - + 'ItemSQLs' => Array( ''=>'SELECT * FROM %s'), - + 'ListSortings' => Array( '' => Array('Sorting' => Array('Module' => 'asc', 'Description' => 'asc') ), - + 'module' => Array('Sorting' => Array('Description' => 'asc') ), ), - + 'Fields' => Array( 'EventId' => Array(), 'Event' => Array('type' => 'string','not_null' => '1','default' => ''), @@ -68,7 +68,7 @@ 'VirtualFields' => Array( 'FromUser' => Array(), ), - + 'Grids' => Array( 'Default' => Array( 'Icons' => Array('default'=>'icon16_custom.gif'), @@ -79,9 +79,9 @@ 'Type' => Array( 'title'=>'la_col_Type'), 'Enabled' => Array( 'title'=>'la_col_Status'), ), - + ), - + 'EmailSettings' => Array( 'Icons' => Array('default'=>'icon16_custom.gif'), 'Fields' => Array( @@ -90,9 +90,13 @@ 'Enabled' => Array('title'=>'la_col_Status'), 'FromUser' => Array('title'=>'la_col_FromToUser'), ), - + ), ), ); + if (defined('DEBUG_MODE') && DEBUG_MODE) { + $config['Grids']['EmailSettings']['Fields']['EventId'] = Array('title' => 'la_col_Id'); + } + ?> \ No newline at end of file Index: trunk/core/admin_templates/incs/custom_blocks.tpl =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 6093) +++ trunk/core/admin_templates/incs/custom_blocks.tpl (.../custom_blocks.tpl) (revision 6583) @@ -1,5 +1,5 @@ - " /> + " /> @@ -73,11 +73,11 @@
   + + -
 
+ - + - +
- +
oInfooValue" align="center"> @@ -32,15 +32,15 @@
- + - + @@ -49,7 +49,7 @@ - +
- +
- + - + - + -
()
@@ -94,7 +94,7 @@ - +
"> " border="0" alt="" title="" /> " class="userslink"> () @@ -106,7 +106,7 @@
- + @@ -115,19 +115,19 @@ - + - +
- +
- "> + ">
"> @@ -141,15 +141,14 @@
- - - - - - - - - - - \ No newline at end of file + + + + + + + + + + Index: trunk/core/admin_templates/catalog_tab.tpl =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/admin_templates/catalog_tab.tpl (.../catalog_tab.tpl) (revision 6093) +++ trunk/core/admin_templates/catalog_tab.tpl (.../catalog_tab.tpl) (revision 6583) @@ -2,6 +2,8 @@
+ + @@ -19,9 +21,9 @@ #separator# - + - +
_" width="50%"> radiocheckbox" name="" id=""> @@ -39,7 +41,7 @@
@@ -50,7 +52,7 @@
- +
Index: trunk/kernel/admin_templates/incs/script.js =================================================================== diff -u -N -r6428 -r6583 --- trunk/kernel/admin_templates/incs/script.js (.../script.js) (revision 6428) +++ trunk/kernel/admin_templates/incs/script.js (.../script.js) (revision 6583) @@ -758,10 +758,10 @@ function string_to_selected($str, $aSelect) { var $cur = null; - for (var $i = 0; i < $aSelect.length; $i++) + for (var $i = 0; $i < $aSelect.length; $i++) { $cur = $aSelect.options[$i]; - $aSelect.options[$i].selected = $str.match(',' + $cur.value + ',') ? true : false; + $aSelect.options[$i].selected = $str.match('\\|' + $cur.value + '\\|') ? true : false; } } Index: trunk/core/units/users/users_item.php =================================================================== diff -u -N -r4758 -r6583 --- trunk/core/units/users/users_item.php (.../users_item.php) (revision 4758) +++ trunk/core/units/users/users_item.php (.../users_item.php) (revision 6583) @@ -2,20 +2,22 @@ class UsersItem extends kDBItem { var $persistantVars = Array(); - - function LoadPersistantVars() + + function LoadPersistantVars($id=null) { + $id = $id == -1 ? -1 : $this->GetID(); + if (!$id) return ; $sql = 'SELECT VariableValue, VariableName FROM '.TABLE_PREFIX.'PersistantSessionData - WHERE PortalUserId = '.$this->GetID(); + WHERE PortalUserId = '.$id; $this->persistantVars = $this->Conn->GetCol($sql, 'VariableName'); } - + function setPersistantVar($var_name, $var_value) { $this->persistantVars[$var_name] = $var_value; - - if ($this->GetID() > 0) { + + if ($this->GetID() > 0 || $this->GetID() == -1) { $replace_hash = Array( 'PortalUserId' => $this->GetID(), 'VariableName' => $var_name, 'VariableValue' => $var_value @@ -26,21 +28,21 @@ $this->Application->StoreVar($var_name, $var_value); } } - + function getPersistantVar($var_name) { return getArrayValue($this->persistantVars, $var_name); } - + function Load($id, $id_field_name = null) { $ret = parent::Load($id, $id_field_name); - if ($ret) { - $this->LoadPersistantVars(); + if ($ret || $id == -1) { + $this->LoadPersistantVars($id); } return $ret; } - + /** * Returns IDs of groups to which user belongs and membership is not expired * @@ -61,7 +63,7 @@ return explode(',', $user_groups); } } - + /** * Set's Login from Email if required by configuration settings * @@ -70,10 +72,10 @@ { if( $this->Application->ConfigValue('Email_As_Login') ) { - $this->SetDBField('Login', $this->GetDBField('Email') ); + $this->SetDBField('Login', $this->GetDBField('Email') ); } } - + function SendEmailEvents() { switch( $this->GetDBField('Status') ) @@ -82,25 +84,25 @@ $this->Application->EmailEventAdmin('USER.ADD', $this->GetID() ); $this->Application->EmailEventUser('USER.ADD', $this->GetID() ); break; - + case 2: $this->Application->EmailEventAdmin('USER.ADD.PENDING', $this->GetID() ); $this->Application->EmailEventUser('USER.ADD.PENDING', $this->GetID() ); break; } } - + function isSubscriberOnly() { $subscribers_group_id = $this->Application->ConfigValue('User_SubscriberGroup'); $sql = 'SELECT PortalUserId FROM '.TABLE_PREFIX.'UserGroup - WHERE GroupId = '.$subscribers_group_id.' AND - PortalUserId = '.$this->GetDBField('PortalUserId').' AND + WHERE GroupId = '.$subscribers_group_id.' AND + PortalUserId = '.$this->GetDBField('PortalUserId').' AND PrimaryGroup = 1'; return $this->Conn->GetOne($sql) == $this->GetDBField('PortalUserId'); } - + function Create($force_id=false, $system_create=false) { $ret = parent::Create($force_id, $system_create); @@ -111,8 +113,8 @@ } return $ret; } - - + + function Update($id=null, $system_update=false) { $ret = parent::Update($id, $system_update); @@ -123,7 +125,7 @@ } return $ret; } - + /** * Deletes the record from databse * @@ -137,14 +139,14 @@ $sync_manager =& $this->Application->recallObjectP('UsersSyncronizeManager', null, Array(), 'InPortalSyncronize'); $sync_manager->performAction('deleteUser', $this->FieldValues); } - + return $ret; } - + function setName($full_name) { $full_name = explode(' ', $full_name); - + if (count($full_name) > 2) { $last_name = array_pop($full_name); $first_name = implode(' ', $full_name); @@ -153,11 +155,11 @@ $last_name = $full_name[1]; $first_name = $full_name[0]; } - + $this->SetDBField('FirstName', $first_name); $this->SetDBField('LastName', $last_name); } - - + + } ?> \ No newline at end of file Index: trunk/core/units/email_events/email_events_config.php =================================================================== diff -u -N -r3348 -r6583 --- trunk/core/units/email_events/email_events_config.php (.../email_events_config.php) (revision 3348) +++ trunk/core/units/email_events/email_events_config.php (.../email_events_config.php) (revision 6583) @@ -7,23 +7,23 @@ 'EventHandlerClass' => Array('class'=>'EmailEventsEventsHandler','file'=>'email_events_event_handler.php','build_event'=>'OnBuild'), 'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'), 'AutoLoad' => true, - + 'QueryString' => Array( 1 => 'id', 2 => 'page', 3 => 'event', ), - + 'IDField' => 'EventId', - + 'StatusField' => Array('Enabled'), - + 'TitleField' => 'Event', - + 'TitlePresets' => Array( 'email_settings_list' => Array('prefixes' => Array('emailevents.module_List'), 'format' => '!la_title_EmailSettings! (#emailevents.module_recordcount#)'), ), - + 'FilterMenu' => Array( 'Groups' => Array( Array('mode' => 'AND', 'filters' => Array('show_enabled','show_disabled','show_frontonly'), 'type' => WHERE_FILTER), @@ -34,28 +34,28 @@ 'show_frontonly' => Array('label' => 'la_Text_FrontOnly', 'on_sql' => '', 'off_sql' => '%1$s.Enabled != 2' ), ) ), - + 'TableName' => TABLE_PREFIX.'Events', 'CalculatedFields' => Array( '' => Array ( 'FromUser' => 'u.Login', ) ), - + 'ListSQLs' => Array( ''=>' SELECT %1$s.* %2$s FROM %1$s LEFT JOIN '.TABLE_PREFIX.'PortalUser u ON %1$s.FromUserId = u.PortalUserId', ), // key - special, value - list select sql), - + 'ItemSQLs' => Array( ''=>'SELECT * FROM %s'), - + 'ListSortings' => Array( '' => Array('Sorting' => Array('Module' => 'asc', 'Description' => 'asc') ), - + 'module' => Array('Sorting' => Array('Description' => 'asc') ), ), - + 'Fields' => Array( 'EventId' => Array(), 'Event' => Array('type' => 'string','not_null' => '1','default' => ''), @@ -68,7 +68,7 @@ 'VirtualFields' => Array( 'FromUser' => Array(), ), - + 'Grids' => Array( 'Default' => Array( 'Icons' => Array('default'=>'icon16_custom.gif'), @@ -79,9 +79,9 @@ 'Type' => Array( 'title'=>'la_col_Type'), 'Enabled' => Array( 'title'=>'la_col_Status'), ), - + ), - + 'EmailSettings' => Array( 'Icons' => Array('default'=>'icon16_custom.gif'), 'Fields' => Array( @@ -90,9 +90,13 @@ 'Enabled' => Array('title'=>'la_col_Status'), 'FromUser' => Array('title'=>'la_col_FromToUser'), ), - + ), ), ); + if (defined('DEBUG_MODE') && DEBUG_MODE) { + $config['Grids']['EmailSettings']['Fields']['EventId'] = Array('title' => 'la_col_Id'); + } + ?> \ No newline at end of file Index: trunk/kernel/admin_templates/catalog.tpl =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/admin_templates/catalog.tpl (.../catalog.tpl) (revision 6093) +++ trunk/kernel/admin_templates/catalog.tpl (.../catalog.tpl) (revision 6583) @@ -21,26 +21,26 @@ Request.progressText = ''; var $is_catalog = true; var $Catalog = new Catalog('', 'catalog_'); - var a_toolbar = new ToolBar(); - + var a_toolbar = new ToolBar(); + a_toolbar.AddButton( new ToolBarButton('upcat', '', function() { $Catalog.go_to_cat($Catalog.ParentCategoryID); } ) ); - + a_toolbar.AddButton( new ToolBarButton('homecat', '', function() { $Catalog.go_to_cat(0); } - ) ); - + ) ); + a_toolbar.AddButton( new ToolBarSeparator('sep1') ); - + a_toolbar.AddButton( new ToolBarButton('new_cat', '', function() { std_precreate_item('c', 'categories/categories_edit'); } - ) ); - - + ) ); + + a_toolbar.AddButton( new ToolBarButton('editcat', '', function() { var $edit_url = ''; var $category_id = get_hidden_field('m_cat_id'); @@ -49,33 +49,33 @@ redirect($redirect_url); } ) ); - + - - + + a_toolbar.AddButton( new ToolBarButton('edit', '', edit) ); - + a_toolbar.AddButton( new ToolBarButton('delete', '', function() { var $template = $Catalog.queryTabRegistry('prefix', $Catalog.getCurrentPrefix(), 'view_template'); std_delete_items($Catalog.getCurrentPrefix(), $template, 1); - } ) ); - - + } ) ); + + a_toolbar.AddButton( new ToolBarSeparator('sep2') ); - + a_toolbar.AddButton( new ToolBarButton('approve', '', function() { $Catalog.submit_event(null, 'OnMassApprove'); } ) ); - + a_toolbar.AddButton( new ToolBarButton('decline', '', function() { $Catalog.submit_event(null, 'OnMassDecline'); } - ) ); - + ) ); + a_toolbar.AddButton( new ToolBarSeparator('sep3') ); - + a_toolbar.AddButton( new ToolBarButton('export', '', function() { var $export_prefixes = new Array('l', 'p'); if (in_array($Catalog.ActivePrefix, $export_prefixes)) { @@ -86,65 +86,65 @@ } } ) ); - + a_toolbar.AddButton( new ToolBarButton('rebuild_cache', '', function() { redirect(''); } ) ); - + a_toolbar.AddButton( new ToolBarSeparator('sep4') ); - - + + a_toolbar.AddButton( new ToolBarButton('cut', '', function() { $Catalog.submit_event(null, 'OnCut'); } ) ); - + a_toolbar.AddButton( new ToolBarButton('copy', '', function() { $Catalog.submit_event(null, 'OnCopy'); } ) ); - - + + a_toolbar.AddButton( new ToolBarButton('paste', '', function() { - $Catalog.submit_event('c', 'OnPasteClipboard', null, function($object) { + $Catalog.submit_event('c', 'OnPasteClipboard', null, function($object) { $object.resetTabs(true); - $object.switchTab(); + $object.switchTab(); } ); } ) ); - + /*a_toolbar.AddButton( new ToolBarButton('clear_clipboard', '', function() { if (confirm('')) { - $Catalog.submit_event('c', 'OnClearClipboard', null, function($object) { + $Catalog.submit_event('c', 'OnClearClipboard', null, function($object) { $GridManager.CheckDependencies($object.ActivePrefix); } ); } } ) );*/ - + a_toolbar.AddButton( new ToolBarSeparator('sep5') ); - + a_toolbar.AddButton( new ToolBarButton('move_up', '', function() { $Catalog.submit_event(null, 'OnMassMoveUp'); } ) ); - - + + a_toolbar.AddButton( new ToolBarButton('move_down', '', function() { $Catalog.submit_event(null, 'OnMassMoveDown'); } ) ); - + a_toolbar.AddButton( new ToolBarSeparator('sep6') ); - + a_toolbar.AddButton( new ToolBarButton('view', '', function() { show_viewmenu(a_toolbar, 'view'); } ) ); - - a_toolbar.Render(); - + + a_toolbar.Render(); + function edit() { var $current_prefix = $Catalog.getCurrentPrefix(); @@ -189,7 +189,7 @@
+ @@ -218,10 +218,10 @@ - + - + Index: trunk/admin/install/langpacks/english.lang =================================================================== diff -u -N -r6428 -r6583 --- trunk/admin/install/langpacks/english.lang (.../english.lang) (revision 6428) +++ trunk/admin/install/langpacks/english.lang (.../english.lang) (revision 6583) @@ -5,6 +5,7 @@ QWN0aXZl QWRkZWQ= QWRkIFRv + QWx3YXlz YW5k QWN0aXZl QXV0aG9y @@ -77,15 +78,22 @@ QWNjZXNz QWRkaXRpb25hbA== QmFzZWQgT24= + Q2F0ZWdvcnk= + Q2F0ZWdvcnkgTmFtZQ== + Q3JlYXRlZCBPbg== RGVzY3JpcHRpb24= RHVyYXRpb24= RHVyYXRpb24gVHlwZQ== RWZmZWN0aXZl RW1haWw= RXZlbnQ= + RmllbGQgTmFtZQ== Rmlyc3QgTmFtZQ== R3JvdXAgTmFtZQ== SUQ= + U3RhdHVz + SW1hZ2U= + VVJM SW5oZXJpdGVk SW5oZXJpdGVkIEZyb20= U3lzdGVt @@ -105,13 +113,22 @@ QWNjZXNz Vmlldw== VHlwZQ== + UHJldmlldw== UHJpbWFyeSBHcm91cA== UHJpbWFyeSBWYWx1ZQ== + RmllbGQgUHJvbXB0 + UmVsYXRpb24gVHlwZQ== + UmV2aWV3ZWQgQnk= + UmV2aWV3IFRleHQ= U2VsZWN0b3I= U3RhdHVz + SXRlbQ== + SXRlbSBUeXBl + VGl0bGU= VmFsdWU= VHlwZQ== VXNlciBDb3VudA== + RmllbGQgVmFsdWU= VmlzaXQgRGF0ZQ== QXNjZW5kaW5n RGF0ZQ== @@ -126,6 +143,7 @@ TmFtZQ== SW5zdWZmaWNlbnQgcGVybWlzc2lvbnMgdGVtcGxhdGU= R1pJUCBjb21wcmVzc2lvbiBsZXZlbCAwLTk= + UmV2aWV3cyBwZXIgcGFnZQ== UmVnaXN0cmF0aW9uIE51bWJlcg== UmVxdWlyZSBTU0wgZm9yIGxvZ2luICYgY2hlY2tvdXQ= U2VydmVyIE5hbWU= @@ -220,6 +238,7 @@ RmlsZSBpcyB0b28gbGFyZ2U= SW52YWxpZCBGaWxlIEZvcm1hdA== RXJyb3IgbW92aW5nIHN1YmNhdGVnb3J5 + UGFzc3dvcmRzIGRvIG5vdCBtYXRjaCE= cmVxdWlyZWQgY29sdW1ucyBtaXNzaW5n Q2F0ZWdvcnkgZmllbGQgbm90IHVuaXF1ZQ== VW5rbm93biBjYXRlZ29yeQ== @@ -280,6 +299,7 @@ RGlzcGxheSBPcmRlcg== QWRkcmVzcyBMaW5l QWR2YW5jZWQgQ1NT + QWx0IFZhbHVl QXV0b21hdGljIEZpbGVuYW1l QXZhaWxhYmxlIENvbHVtbnM= QmFja2dyb3VuZA== @@ -304,6 +324,8 @@ Q2hlY2sgRHVwbGljYXRlcyBieQ== Q29tcGFueQ== Q29weSBMYWJlbHMgZnJvbSB0aGlzIExhbmd1YWdl + Q3JlYXRlZCBCeQ== + Q3JlYXRlZCBPbg== Q3Vyc29y RGF0ZSBGb3JtYXQ= RGVjaW1hbCBQb2ludA== @@ -315,6 +337,7 @@ RWxhcHNlZCBUaW1l RW5hYmxlZA== RXN0aW1hdGVkIFRpbWU= + RXhwaXJl RXhwb3J0IGNvbHVtbnM= RXhwb3J0IEZpbGVuYW1l RXhwb3J0IGZvcm1hdA== @@ -335,9 +358,11 @@ SUQ= R3JvdXAgTmFtZQ== SGVpZ2h0 + SGl0cw== SG90 SWNvbiBVUkw= SUQ= + SW1hZ2UgSUQ= SW1wb3J0IENhdGVnb3J5 SW1wb3J0IEZpbGVuYW1l SW5jbHVkZSBmaWVsZCB0aXRsZXM= @@ -346,6 +371,7 @@ SW5zdGFsbCBNb2R1bGVz SW5zdGFsbCBQaHJhc2UgVHlwZXM= VXNlIGN1cnJlbnQgY2F0ZWdvcnkgYXMgcm9vdCBmb3IgdGhlIGV4cG9ydA== + UHJpbWFyeQ== SXMgU3lzdGVt SXRlbSBUZW1wbGF0ZQ== TGFuZ3VhZ2UgRmlsZQ== @@ -354,6 +380,7 @@ TGluZSBlbmRpbmdz TGluZSBFbmRpbmdzIEluc2lkZSBGaWVsZHM= TG9jYWwgTmFtZQ== + TG9jYXRpb24= TWFyZ2luIEJvdHRvbQ== TWFyZ2luIExlZnQ= TWFyZ2luIFJpZ2h0 @@ -378,10 +405,18 @@ UGhyYXNlIFR5cGU= UG9w UG9zaXRpb24= + UHJpbWFyeQ== UHJpbWFyeQ== UHJpbWFyeSBUcmFuc2xhdGlvbg== UHJpb3JpdHk= + UmF0aW5n + UmVsYXRpb24gSUQ= + VHlwZQ== + UmVtb3RlIFVSTA== UmVwbGFjZSBEdXBsaWNhdGVz + UmV2aWV3IElE + UmV2aWV3IFRleHQ= + U2FtZSBBcyBUaHVtYg== QmFzZWQgT24= U3R5bGU= U2VsZWN0b3IgSUQ= @@ -390,14 +425,19 @@ U3RhdHVz U3R5bGVzaGVldCBJRA== U3ViamVjdA== + SXRlbQ== VGV4dCBBbGlnbg== VGV4dCBEZWNvcmF0aW9u VGhvdXNhbmRzIFNlcGFyYXRvcg== VGltZSBGb3JtYXQ= + VGl0bGU= VG9w VmFsdWU= TWVhc3VyZXMgU3lzdGVt + VXBsb2FkIEZpbGUgRnJvbSBMb2NhbCBQQw== + VVJM VmlzaWJpbGl0eQ== + Vm90ZXM= V2lkdGg= Wi1JbmRleA== Rm9udCBQcm9wZXJ0aWVz @@ -442,6 +482,7 @@ U29ydCByZXZpZXdzIGJ5 VVJM RGlzcGxheSBsaW5rIFVSTCBpbiBzdGF0dXMgYmFy + TG9jYWwgSW1hZ2U= TG9nZ2VkIGluIGFz TG9naW4= KEdNVCk= @@ -466,6 +507,7 @@ Q2F0ZWdvcnkgcGF0aCBpbiBvbmUgZmllbGQ= TW9kdWxlIG5vdCBsaWNlbnNlZA== TW9uZGF5 + TmV2ZXI= TmV2ZXIgRXhwaXJlcw== TmV3 TnVtYmVyIG9mIGRheXMgdG8gYXJjaGl2ZSBhcnRpY2xlcyBhdXRvbWF0aWNhbGx5 @@ -488,6 +530,7 @@ b2Y= T2Zm T24= + T25lIFdheQ== ZGF5KHMp aG91cihzKQ== bWludXRlKHMp @@ -544,6 +587,7 @@ UHJldmlvdXMgY2F0ZWdvcnk= UHJldmlvdXMgZ3JvdXA= UHJldmlvdXMgVXNlcg== + UHJpbWFyeQ== QWN0aXZlIEFydGljbGVz QWN0aXZlIENhdGVnb3JpZXM= QWN0aXZlIExpbmtz @@ -887,6 +931,7 @@ U2Vzc2lvbiBSZWZlcnJlciBDaGVja2luZw== bGFfUmF0aW5n QWxyZWFkeSB2b3RlZA== + UmVjaXByb2NhbA== UmVtb3ZlIEZyb20= Tm90IGFsbCByZXF1aXJlZCBmaWVsZHMgYXJlIGZpbGxlZC4gUGxlYXNlIGZpbGwgdGhlbSBmaXJzdC4= QWNjZXNzIGRlbmllZA== @@ -915,13 +960,18 @@ TmV3IFNlYXJjaA== TUVUQSBJbmZvcm1hdGlvbg== Q2F0ZWdvcnk= + Q291bnRlcnM= Q3VzdG9tIEZpZWxkcw== + RnVsbCBTaXplIEltYWdl R2VuZXJhbA== + SW1hZ2U= TWVzc2FnZQ== U2VjdGlvbiBPdmVydmlldw== UHJvcGVydGllcw== UXVpY2sgTGlua3M= + UmVsYXRpb24= VGVtcGxhdGVz + VGh1bWJuYWlsIEltYWdl VHJhbnNsYXRpb24= U2VhcmNoIFVzZXJz U2VsZWN0aW5nIENhdGVnb3JpZXM= @@ -959,6 +1009,7 @@ U21pbGV5cw== R2VuZXJhbCBTZXR0aW5ncw== Q3VzdG9t + RWRpdGluZyBSZXZpZXc= RW1haWwgRXZlbnRz RW1haWwgTG9n RW1haWwgTWVzc2FnZQ== @@ -1253,8 +1304,11 @@ QWRkaW5nIEJsb2NrIFN0eWxl QWRkaW5nIENhdGVnb3J5 QWRkaW5nIEdyb3Vw + QWRkaW5nIEltYWdl QWRkaW5nIExhbmd1YWdl QWRkaW5nIFBocmFzZQ== + QWRkaW5nIFJlbGF0aW9uc2hpcA== + QWRkaW5nIFJldmlldw== QWRkaW5nIFN0eWxlc2hlZXQ= QWRkaXRpb25hbCBQZXJtaXNzaW9ucw== QWRkIE1vZHVsZQ== @@ -1281,8 +1335,11 @@ RWRpdGluZyBDYXRlZ29yeQ== RWRpdGluZyBDdXN0b20gRmllbGQ= RWRpdGluZyBHcm91cA== + RWRpdGluZyBJbWFnZQ== RWRpdGluZyBMYW5ndWFnZQ== RWRpdGluZyBQaHJhc2U= + RWRpdGluZyBSZWxhdGlvbnNoaXA= + RWRpdGluZyBSZXZpZXc= RWRpdGluZyBTdHlsZXNoZWV0 U2l0ZSBTdHJ1Y3R1cmU= RWRpdCBDYXRlZ29yeQ== @@ -1301,6 +1358,7 @@ R3JvdXBz U2VsZWN0IGdyb3Vw SGVscA== + SW1hZ2Vz SW1wb3J0IERhdGE= SW1wb3J0IExhbmd1YWdlIFBhY2s= SW4tYnVsbGV0aW4= @@ -1321,8 +1379,11 @@ TmV3IEJsb2NrIFN0eWxl TmV3IENhdGVnb3J5 TmV3IEdyb3Vw + TmV3IEltYWdl TmV3IExhbmd1YWdl TmV3IFBocmFzZQ== + TmV3IFJlbGF0aW9uc2hpcA== + TmV3IFJldmlldw== TmV3IFN0eWxlc2hlZXQ= Tm8gUGVybWlzc2lvbnM= UGVybWlzc2lvbnM= @@ -1398,6 +1459,7 @@ TmV3IEdyb3Vw TmV3IGxhYmVs TmV3IExhbmd1YWdl + TmV3IFJldmlldw== TmV3IFN0eWxlc2hlZXQ= U3RhcnQgTmV3IFZhbGlkYXRpb24= TmV3IENhdGVnb3J5 @@ -1407,6 +1469,7 @@ TmV3IERpc2NvdW50 TmV3IEVtb3Rpb24gSWNvbg== TmV3IEltYWdl + TmV3IEltYWdlcw== QWRkIG5ldyBsYWJlbA== TmV3IExhbmd1YWdlIFBhY2s= TmV3IFBlcm1pc3Npb24= @@ -1441,6 +1504,7 @@ U2VuZCBFLW1haWw= U2VuZCBFLW1haWw= U2V0IFByaW1hcnk= + U2V0IFByaW1hcnkgQ2F0ZWdvcnk= U2V0IFByaW1hcnkgTGFuZ3VhZ2U= Q2FuY2Vs VXAgYSBDYXRlZ29yeQ== @@ -1462,6 +1526,7 @@ VG9waWMgVGV4dA== Vmlld3M= VG8gRGF0ZQ== + VHJhbnNsYXRl Q2hlY2tib3hlcw== RGF0ZQ== RGF0ZSAmIFRpbWU= @@ -1509,6 +1574,8 @@ QSBzZWFyY2ggb3IgYSBmaWx0ZXIgaXMgaW4gZWZmZWN0LiBZb3UgbWF5IG5vdCBiZSBzZWVpbmcgYWxsIG9mIHRoZSBkYXRhLg== WW91IGFyZSBhYm91dCB0byBkZWxldGUgdGhlIHByaW1hcnkgdGhlbWUuIENvbnRpbnVlPw== TW9kaWZpY2F0aW9ucyB3aWxsIG5vdCB0YWtlIGVmZmVjdCB1bnRpbCB5b3UgY2xpY2sgdGhlIFNhdmUgYnV0dG9uIQ== + d2Vlaw== + eWVhcg== WWVz WW91IGRvIG5vdCBoYXZlIGFjY2VzcyB0byBwZXJmb3JtIHRoaXMgb3BlcmF0aW9u QWNjb3VudCBJbmZvcm1hdGlvbg== @@ -1596,6 +1663,8 @@ UGFzc3dvcmQgcmVzZXQgY29kZSBpcyBub3QgdmFsaWQ= UHJpY2VzIG9mIG9uZSBvciBtb3JlIGl0ZW1zIGluIHlvdXIgc2hvcHBpbmcgY2FydCBoYXZlIGJlZW4gY2hhbmdlZCBkdWUgdG8geW91ciBsb2dpbiwgcGxlYXNlIHJldmlldyBjaGFuZ2VzLg== RW1haWxBZGRyZXNz + QWRkaXRpb25hbCBJbWFnZXM= + QURESVRJT05BTCBJTUFHRVM= Tm8gUGVybWlzc2lvbnM= UHJvZHVjdCBEZXNjcmlwdGlvbg== Q29tcGFueQ== Index: trunk/kernel/units/languages/import_xml.php =================================================================== diff -u -N -r5431 -r6583 --- trunk/kernel/units/languages/import_xml.php (.../import_xml.php) (revision 5431) +++ trunk/kernel/units/languages/import_xml.php (.../import_xml.php) (revision 6583) @@ -157,6 +157,9 @@ $path = implode(' ',$this->path); //check what path we are in + $this->LastLine = xml_get_current_line_number($parser); + $this->SecondData = false; + switch($path) { case 'LANGUAGES LANGUAGE': @@ -255,7 +258,14 @@ break; case 'LANGUAGES LANGUAGE EVENTS EVENT': + $cur_line = xml_get_current_line_number($parser); + if ($cur_line != $this->LastLine) { + $this->current_event['Template'] .= str_repeat("\r\n", ($cur_line - $this->LastLine) ); + $this->LastLine = $cur_line; + } $this->current_event['Template'] .= $line; + + $this->SecondData = true; break; } } @@ -282,6 +292,7 @@ case 'LANGUAGES LANGUAGE EVENTS EVENT': if ($this->current_language['Encoding'] == 'plain') { + $this->current_event['Template'] = rtrim($this->current_event['Template']); // nothing to decode! } else { Index: trunk/core/admin_templates/categories/xml/categories_list.tpl =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/admin_templates/categories/xml/categories_list.tpl (.../categories_list.tpl) (revision 6093) +++ trunk/core/admin_templates/categories/xml/categories_list.tpl (.../categories_list.tpl) (revision 6583) @@ -1,3 +1,5 @@ + + Index: trunk/kernel/units/custom_fields/custom_fields_tag_processor.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/custom_fields/custom_fields_tag_processor.php (.../custom_fields_tag_processor.php) (revision 6093) +++ trunk/kernel/units/custom_fields/custom_fields_tag_processor.php (.../custom_fields_tag_processor.php) (revision 6583) @@ -36,13 +36,6 @@ return $this->Application->ProcessParsedTag($source_prefix, 'InputName', $params); } - function CustomError($params) - { - $params['name'] = $this->GetMainField($params); - $source_prefix = $this->Application->Parser->GetParam('SourcePrefix'); - return $this->Application->ProcessParsedTag($source_prefix, 'Error', $params); - } - function setParamValue(&$params, $param_name) { // $deep_level if GetParam = 1 used in case if PrintList is called during parsing "grid" block (=> +1 to deep_level) @@ -103,7 +96,7 @@ if ($display_original) { $list->SetDBField('OriginalValue', $original_object->GetField('cust_'.$list->GetDBField('FieldName'))); } - $block_params['field'] = 'cust_'.$list->GetDBField('FieldName'); + $block_params['field'] = $block_params['virtual_field'] = 'cust_'.$list->GetDBField('FieldName'); $block_params['show_heading'] = ($prev_heading != $list->GetDBField('Heading') ) ? 1 : 0; } Index: trunk/core/units/general/helpers/permissions_helper.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6428) +++ trunk/core/units/general/helpers/permissions_helper.php (.../permissions_helper.php) (revision 6583) @@ -216,6 +216,7 @@ function showDebug($text, $params) { + return ; $is_ajax = $this->Application->GetVar('ajax') == 'yes' || isset($params['ajax']) || isset($params['tab_init']); if (!$this->Application->isDebugMode() || $is_ajax) return true; echo $text.'
'; Index: trunk/core/kernel/utility/formatters/upload_formatter.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/kernel/utility/formatters/upload_formatter.php (.../upload_formatter.php) (revision 6093) +++ trunk/core/kernel/utility/formatters/upload_formatter.php (.../upload_formatter.php) (revision 6583) @@ -72,6 +72,12 @@ $object->SetDBField($options['content_type_field'], $value['type']); } $ret = getArrayValue($options, 'upload_dir') ? $real_name : $this->DestinationPath.$real_name; + + // delete previous file, when new file is uploaded under same field + $previous_file = isset($value['upload']) ? $value['upload'] : false; + if ($previous_file && file_exists($this->FullPath.$previous_file)) { + unlink($this->FullPath.$previous_file); + } } } } @@ -158,7 +164,7 @@ function GetFormatted($tc_value, &$options) { - if ($options['format'] == 'img_size') { + if (isset($options['format']) && ($options['format'] == 'img_size')) { $upload_dir = isset($options['upload_dir']) ? $options['upload_dir'] : $this->DestinationPath; $img_path = FULL_PATH.'/'.$upload_dir.$tc_value; Index: trunk/core/kernel/application.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/core/kernel/application.php (.../application.php) (revision 6428) +++ trunk/core/kernel/application.php (.../application.php) (revision 6583) @@ -71,6 +71,13 @@ var $ConfigCacheIds = array(); /** + * Template names, that will be used instead of regular templates + * + * @var Array + */ + var $ReplacementTemplates = Array (); + + /** * Reference to debugger * * @var Debugger @@ -1160,7 +1167,7 @@ */ function getPassInfo($pass = 'all') { - $pass = trim(str_replace('all', trim($this->GetVar('passed'), ','), $pass), ','); + $pass = trim(preg_replace('/(?<=,|\\A)all(?=,|\\z)/', trim($this->GetVar('passed'), ','), trim($pass, ',')), ','); if (!$pass) { return Array(); Index: trunk/core/admin_templates/js/catalog.js =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/admin_templates/js/catalog.js (.../catalog.js) (revision 6093) +++ trunk/core/admin_templates/js/catalog.js (.../catalog.js) (revision 6583) @@ -6,7 +6,7 @@ this.ParentCategoryID = 0; this.OnResponceMethod = null; this.TabShift = isset($tab_shift) ? $tab_shift : 1; // start from 2nd tab (index starting from 0) - + this.TabRegistry = new Array(); this.ActivePrefix = getCookie(this.CookiePrefix + 'active_prefix'); this.PreviousPrefix = this.ActivePrefix; @@ -49,13 +49,13 @@ Catalog.prototype.submit_kernel_form = function($tab_id) { var $prefix = 'dummy'; var $result_div = ''; - + if (isset($tab_id)) { // responce result + progress are required $prefix = this.queryTabRegistry('tab_id', $tab_id, 'prefix'); $result_div = $tab_id + '_div'; } - + var $kf = document.getElementById($form_name); Request.params = Request.serializeForm($kf); @@ -75,11 +75,12 @@ window.location.href = $match_redirect[1]; return false; } - + $params = $params.split(','); - - + + var $js_end = $text.indexOf($object.Separator); +// alert($text.substring(0, $js_end)); if ($js_end != -1) { // allow to detect if output is permitted by ajax request parameters var $request_visible = '$request_visible = ' + ($params[0].length ? 'true' : 'false') + "\n"; @@ -95,12 +96,12 @@ else if ($params[0].length) { document.getElementById($params[0]).innerHTML = $text; } - + if (typeof($object.OnResponceMethod) == 'function') { $object.OnResponceMethod($object); $object.OnResponceMethod = null; } - + if (typeof($Debugger) != 'undefined') { $Debugger.Clear(); } @@ -115,7 +116,7 @@ if (typeof($OnResponceMethod) == 'function') { this.OnResponceMethod = $OnResponceMethod; } - + var $prev_template = get_hidden_field('t'); if (!isset($prefix_special)) $prefix_special = this.getCurrentPrefix(); var $tab_id = this.queryTabRegistry('prefix', $prefix_special, 'tab_id'); @@ -165,7 +166,7 @@ this.setItemCount(this.TabRegistry[$i]['prefix'], '?'); $i++; } - + if ($reset_content) { // set category for all tabs to -1 (forces reload next time) $i = this.TabShift; @@ -181,7 +182,7 @@ // active prefix is not registred -> cookie left, but not modules installed/enabled at the moment return false; } - + if (!isset($prefix)) $prefix = this.ActivePrefix; if (this.BusyRequest[$prefix]) { @@ -204,7 +205,7 @@ this.ShowDependentButtons(this.ActivePrefix); this.setViewMenu(this.ActivePrefix); setCookie(this.CookiePrefix + 'active_prefix', this.ActivePrefix); - + this.refreshTab($prefix, $div_id, $force); } @@ -267,7 +268,7 @@ else { alert('has form: ['+$tab_id + '_form'+']'); }*/ - + var $dep_buttons = this.queryTabRegistry('prefix', $prefix, 'dep_buttons'); var $i = 0; while ($i < $dep_buttons.length) { Index: trunk/core/units/relationship/relationship_event_handler.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 6093) +++ trunk/core/units/relationship/relationship_event_handler.php (.../relationship_event_handler.php) (revision 6583) @@ -22,7 +22,7 @@ */ function OnNew(&$event) { - parent::OnNew(&$event); + parent::OnNew($event); $object =& $event->getObject(); $table_info = $object->getLinkedInfo(); Index: trunk/core/units/general/cat_dbitem.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 6093) +++ trunk/core/units/general/cat_dbitem.php (.../cat_dbitem.php) (revision 6583) @@ -60,8 +60,9 @@ $ret = parent::Create(); if ($ret) { + $primary_category = $this->GetDBField('CategoryId') > 0 ? $this->GetDBField('CategoryId') : $this->Application->GetVar('m_cat_id'); $fields_hash = Array( - 'CategoryId' => $this->Application->GetVar('m_cat_id'), + 'CategoryId' => $primary_category, 'ItemResourceId' => $this->GetField('ResourceId'), 'PrimaryCat' => 1, 'ItemPrefix' => $this->Prefix, Index: trunk/core/kernel/utility/unit_config_reader.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 6093) +++ trunk/core/kernel/utility/unit_config_reader.php (.../unit_config_reader.php) (revision 6583) @@ -70,6 +70,7 @@ 'Application.Caches.ConfigVariables' => $this->Application->Caches['ConfigVariables'], 'Application.ConfigCacheIds' => $this->Application->ConfigCacheIds, 'Application.ConfigHash' => $this->Application->ConfigHash, + 'Application.ReplacementTemplates' => $this->Application->ReplacementTemplates, 'Application.ModuleInfo' => $this->Application->ModuleInfo, ); @@ -105,6 +106,8 @@ $this->Application->Caches['ConfigVariables'] = $cache['Application.ConfigCacheIds']; $this->Application->ConfigCacheIds = $cache['Application.ConfigCacheIds']; + $this->Application->ReplacementTemplates = $cache['Application.ReplacementTemplates']; + $this->Application->ModuleInfo = $cache['Application.ModuleInfo']; return true; @@ -338,6 +341,11 @@ } } + if (isset($config['ReplacementTemplates']) && $config['ReplacementTemplates']) { + // replacement templates defined in this config + $this->Application->ReplacementTemplates = array_merge_recursive2($this->Application->ReplacementTemplates, $config['ReplacementTemplates']); + } + if ( $this->Application->isDebugMode() && constOn('DBG_VALIDATE_CONFIGS') && isset($config['TableName']) ) { global $debugger; @@ -623,6 +631,8 @@ $module_found = false; if (!$this->Application->ModuleInfo) return false; + if (preg_match('/\/plugins\//', $config_path)) return true; + foreach($this->Application->ModuleInfo as $module_name => $module_info) { $module_path = '/'.$module_info['Path']; Index: trunk/kernel/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 6093) +++ trunk/kernel/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 6583) @@ -319,7 +319,7 @@ ksort($section_data['children'], SORT_NUMERIC); foreach ($section_data['children'] as $priority => $section_name) { if (!$this->Application->CheckPermission($section_name.'.view', 1)) continue; - + $tab_data =& $sections_helper->getSectionData($section_name); $block_params['t'] = $tab_data['url']['t']; $block_params['title'] = $tab_data['label']; @@ -345,7 +345,8 @@ $block_params = Array('name' => $params['render_as']); foreach ($this->Application->ModuleInfo as $module_name => $module_info) { $prefix = $module_info['Var']; - if (in_array($prefix, $skip_prefixes)) continue; + + if (in_array($prefix, $skip_prefixes) || !$this->Application->getUnitOption($prefix, 'CatalogItem')) continue; if ($prefix == 'm' && $replace_main) $prefix = 'c'; $label = $this->Application->getUnitOption($prefix, $params['title_property']); $block_params['title'] = $label; @@ -376,7 +377,7 @@ return $oFCKeditor->CreateHtml(); } - + /** * Allows to construct link for opening any type of catalog item selector * @@ -390,39 +391,102 @@ $mode = $params['mode']; unset($params['mode']); } - + $params['t'] = 'item_selector/item_selector_'.$mode; - + $default_params = Array('no_amp' => 1, 'pass' => 'all,'.$params['prefix']); unset($params['prefix']); - + $pass_through = Array(); if (isset($params['tabs_dependant'])) { // {yes, no} $pass_through['td'] = $params['tabs_dependant']; unset($params['tabs_dependant']); } - + if (isset($params['selection_mode'])) { // {single, multi} $pass_through['tm'] = $params['selection_mode']; unset($params['selection_mode']); } - + if (isset($params['tab_prefixes'])) { // {all, none, Application->ProcessParsedTag('m', 't', $params); } + + function TimeFrame($params) + { + $w = adodb_date('w'); + $m = adodb_date('m'); + $y = adodb_date('Y'); + //FirstDayOfWeek is 0 for Sunday and 1 for Monday + $fdow = $this->Application->ConfigValue('FirstDayOfWeek'); + if ($fdow && $w == 0) $w = 7; + $today_start = adodb_mktime(0,0,0,adodb_date('m'),adodb_date('d'),$y); + $first_day_of_this_week = $today_start - ($w - $fdow)*86400; + $first_day_of_this_month = adodb_mktime(0,0,0,$m,1,$y); + $this_quater = ceil($m/3); + $this_quater_start = adodb_mktime(0,0,0,$this_quater*3-2,1,$y); + + switch ($params['type']) { + case 'last_week_start': + $timestamp = $first_day_of_this_week - 86400*7; + break; + case 'last_week_end': + $timestamp = $first_day_of_this_week - 1; + break; + + case 'last_month_start': + $timestamp = $m == 1 ? adodb_mktime(0,0,0,12,1,$y-1) : adodb_mktime(0,0,0,$m-1,1,$y); + break; + case 'last_month_end': + $timestamp = $first_day_of_this_month = adodb_mktime(0,0,0,$m,1,$y) - 1; + break; + + case 'last_quater_start': + $timestamp = $this_quater == 1 ? adodb_mktime(0,0,0,10,1,$y-1) : adodb_mktime(0,0,0,($this_quater-1)*3-2,1,$y); + break; + case 'last_quater_end': + $timestamp = $this_quater_start - 1; + break; + + case 'last_6_months_start': + $timestamp = $m <= 6 ? adodb_mktime(0,0,0,$m+6,1,$y-1) : adodb_mktime(0,0,0,$m-6,1,$y); + break; + + case 'last_year_start': + $timestamp = adodb_mktime(0,0,0,1,1,$y-1); + break; + case 'last_year_end': + $timestamp = adodb_mktime(23,59,59,12,31,$y-1); + break; + } + + + if (isset($params['format'])) { + $format = $params['format']; + if(preg_match("/_regional_(.*)/", $format, $regs)) + { + $lang =& $this->Application->recallObject('lang.current'); + $format = $lang->GetDBField($regs[1]); + } + return adodb_date($format, $timestamp); + } + + return $timestamp; + + } } ?> \ No newline at end of file Index: trunk/kernel/admin_templates/incs/grid_blocks.tpl =================================================================== diff -u -N -r6428 -r6583 --- trunk/kernel/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 6428) +++ trunk/kernel/admin_templates/incs/grid_blocks.tpl (.../grid_blocks.tpl) (revision 6583) @@ -175,7 +175,9 @@ - :
+ error"> + + *:
,-cdata', '-cdata:cust_', 'popups/translator', , 1);" title=""> Index: trunk/kernel/units/general/my_application.php =================================================================== diff -u -N -r5547 -r6583 --- trunk/kernel/units/general/my_application.php (.../my_application.php) (revision 5547) +++ trunk/kernel/units/general/my_application.php (.../my_application.php) (revision 6583) @@ -26,20 +26,6 @@ $this->registerClass('kXMLHelper',MODULES_PATH.'/kernel/units/general/xml_helper.php','kXMLHelper'); $this->registerClass('kModulesHelper', MODULES_PATH.'/kernel/units/general/helpers/modules.php', 'ModulesHelper'); - - /*$this->registerClass('kMultiLanguageHelper',MODULES_PATH.'/kernel/units/general/helpers/multilanguage.php','kMultiLanguageHelper'); - $this->registerClass('kSearchHelper', MODULES_PATH.'/kernel/units/general/helpers/search_helper.php', 'SearchHelper'); - $this->registerClass('kSectionsHelper', MODULES_PATH.'/kernel/units/general/helpers/sections_helper.php', 'SectionsHelper'); - $this->registerClass('kPermissionsHelper', MODULES_PATH.'/kernel/units/general/helpers/permissions_helper.php', 'PermissionsHelper'); - - - $this->registerClass('kModRewriteHelper', MODULES_PATH.'/kernel/units/general/helpers/mod_rewrite_helper.php', 'ModRewriteHelper'); - $this->registerClass('kRecursiveHelper', MODULES_PATH.'/kernel/units/general/helpers/recursive_helper.php', 'RecursiveHelper'); - $this->registerClass('kFilenamesHelper', MODULES_PATH.'/kernel/units/general/helpers/filenames_helper.php', 'kFilenamesHelper'); - - $this->registerClass('kPDFHelper', MODULES_PATH.'/kernel/units/general/helpers/pdf_helper.php', 'kPDFHelper'); - */ - } function getUserGroups($user_id) Index: trunk/admin/install/inportal_data.sql =================================================================== diff -u -N -r6428 -r6583 --- trunk/admin/install/inportal_data.sql (.../inportal_data.sql) (revision 6428) +++ trunk/admin/install/inportal_data.sql (.../inportal_data.sql) (revision 6583) @@ -239,7 +239,7 @@ INSERT INTO ItemTypes VALUES (1, 'In-Portal', 'c', 'Category', 'Name', 'CreatedById', NULL, NULL, 'la_ItemTab_Categories', 1, 'admin/category/addcategory.php', 'clsCategory', 'Category'); INSERT INTO ItemTypes VALUES (6, 'In-Portal', 'u', 'PortalUser', 'Login', 'PortalUserId', NULL, NULL, '', 0, '', 'clsPortalUser', 'User'); -INSERT INTO Modules (Name, Path, Var, Version, Loaded, LoadOrder, TemplatePath, RootCat, BuildDate) VALUES ('In-Portal', 'kernel/', 'm', '1.3.0', 1, 0, '', 0, '1054738405'); +INSERT INTO Modules (Name, Path, Var, Version, Loaded, LoadOrder, TemplatePath, RootCat, BuildDate) VALUES ('In-Portal', 'kernel/', 'm', '1.3.1', 1, 0, '', 0, '1054738405'); INSERT INTO PermissionConfig (PermissionName, Description, ErrorMessage, ModuleId) VALUES ('CATEGORY.VIEW', 'lu_PermName_Category.View_desc', 'lu_PermName_Category.View_error', 'In-Portal'); INSERT INTO PermissionConfig (PermissionName, Description, ErrorMessage, ModuleId) VALUES ('CATEGORY.ADD', 'lu_PermName_Category.Add_desc', 'lu_PermName_Category.Add_error', 'In-Portal'); Index: trunk/kernel/admin_templates/incs/catalog.js =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 6093) +++ trunk/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 6583) @@ -6,7 +6,7 @@ this.ParentCategoryID = 0; this.OnResponceMethod = null; this.TabShift = isset($tab_shift) ? $tab_shift : 1; // start from 2nd tab (index starting from 0) - + this.TabRegistry = new Array(); this.ActivePrefix = getCookie(this.CookiePrefix + 'active_prefix'); this.PreviousPrefix = this.ActivePrefix; @@ -49,13 +49,13 @@ Catalog.prototype.submit_kernel_form = function($tab_id) { var $prefix = 'dummy'; var $result_div = ''; - + if (isset($tab_id)) { // responce result + progress are required $prefix = this.queryTabRegistry('tab_id', $tab_id, 'prefix'); $result_div = $tab_id + '_div'; } - + var $kf = document.getElementById($form_name); Request.params = Request.serializeForm($kf); @@ -75,11 +75,12 @@ window.location.href = $match_redirect[1]; return false; } - + $params = $params.split(','); - - + + var $js_end = $text.indexOf($object.Separator); +// alert($text.substring(0, $js_end)); if ($js_end != -1) { // allow to detect if output is permitted by ajax request parameters var $request_visible = '$request_visible = ' + ($params[0].length ? 'true' : 'false') + "\n"; @@ -95,12 +96,12 @@ else if ($params[0].length) { document.getElementById($params[0]).innerHTML = $text; } - + if (typeof($object.OnResponceMethod) == 'function') { $object.OnResponceMethod($object); $object.OnResponceMethod = null; } - + if (typeof($Debugger) != 'undefined') { $Debugger.Clear(); } @@ -115,7 +116,7 @@ if (typeof($OnResponceMethod) == 'function') { this.OnResponceMethod = $OnResponceMethod; } - + var $prev_template = get_hidden_field('t'); if (!isset($prefix_special)) $prefix_special = this.getCurrentPrefix(); var $tab_id = this.queryTabRegistry('prefix', $prefix_special, 'tab_id'); @@ -165,7 +166,7 @@ this.setItemCount(this.TabRegistry[$i]['prefix'], '?'); $i++; } - + if ($reset_content) { // set category for all tabs to -1 (forces reload next time) $i = this.TabShift; @@ -181,7 +182,7 @@ // active prefix is not registred -> cookie left, but not modules installed/enabled at the moment return false; } - + if (!isset($prefix)) $prefix = this.ActivePrefix; if (this.BusyRequest[$prefix]) { @@ -204,7 +205,7 @@ this.ShowDependentButtons(this.ActivePrefix); this.setViewMenu(this.ActivePrefix); setCookie(this.CookiePrefix + 'active_prefix', this.ActivePrefix); - + this.refreshTab($prefix, $div_id, $force); } @@ -267,7 +268,7 @@ else { alert('has form: ['+$tab_id + '_form'+']'); }*/ - + var $dep_buttons = this.queryTabRegistry('prefix', $prefix, 'dep_buttons'); var $i = 0; while ($i < $dep_buttons.length) { Index: trunk/kernel/include/statitem.php =================================================================== diff -u -N -r3282 -r6583 --- trunk/kernel/include/statitem.php (.../statitem.php) (revision 3282) +++ trunk/kernel/include/statitem.php (.../statitem.php) (revision 6583) @@ -3,7 +3,7 @@ { var $GotValue; var $TagCache = Array(); // parsed tag (in sql queries only) values are cached - + var $CurrentSQL = ''; // sql query being currently processed var $PostFormatting = false; // apply formatting to sql query results var $PostFormattingParams = Array(); // post formatting params if any @@ -14,21 +14,21 @@ $this->id_field = "StatItemId"; $this->NoResourceId = 1; $this->GotValue = FALSE; - + if($id) $this->LoadFromDatabase($id); } - - + + 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) @@ -41,7 +41,7 @@ $this->SetFromArray($data); return true; - } + } function ExecuteResetSQL() { @@ -53,29 +53,29 @@ function ExecuteValueSQL() { global $ADODB_FETCH_MODE; - - $ADODB_FETCH_MODE = 3; + + $ADODB_FETCH_MODE = 3; $this->CurrentSQL = $this->Get("ValueSQL"); - + // 1. replace prefix to actual one $this->CurrentSQL = str_replace("<%prefix%>", GetTablePrefix(), $this->CurrentSQL); - - // 2. replace config variable to it's value - while( ($tag = $this->FindTag()) != false ) - { - if( !array_key_exists( trim($tag), $this->TagCache ) ) - { - // unprocessed tag -> parse it to get result - $this->TagCache[ trim($tag) ] = $this->ProcessTag($tag); - } - - $tagResult = $this->TagCache[ trim($tag) ]; // return result from cache - $this->CurrentSQL = str_replace('<%'.$tag.'%>', $tagResult, $this->CurrentSQL); - } - + + // 2. replace config variable to it's value + while( ($tag = $this->FindTag()) != false ) + { + if( !array_key_exists( trim($tag), $this->TagCache ) ) + { + // unprocessed tag -> parse it to get result + $this->TagCache[ trim($tag) ] = $this->ProcessTag($tag); + } + + $tagResult = $this->TagCache[ trim($tag) ]; // return result from cache + $this->CurrentSQL = str_replace('<%'.$tag.'%>', $tagResult, $this->CurrentSQL); + } + $values = array(); $rs = $this->adodbConnection->Execute($this->CurrentSQL); - if($rs && !$rs->EOF) + if($rs && !$rs->EOF) { $value = $rs->fields[0]; if($this->PostFormatting) @@ -85,7 +85,7 @@ case 'number': // simple-specific postformatting $value = LangNumber($value, $this->PostFormattingParams['precision']); break; - + // extended postformatting case 'COUNT': $value = $rs->RecordCount(); @@ -96,7 +96,7 @@ while(!$rs->EOF) { $field_sum += $rs->fields[ $this->PostFormattingParams['field'] ]; - $rs->MoveNext(); + $rs->MoveNext(); } $value = $field_sum; if($this->PostFormattingParams['format_as'] == 'file') $value = size($value); @@ -105,7 +105,7 @@ case 'SysFileSize': $value = size( dir_size($GLOBALS['pathtoroot']) ); break; - + default: // simple-default postformatting $value = adodb_date($this->PostFormatting, $value); break; @@ -115,7 +115,7 @@ } $this->Set("Value", $value); } - $ADODB_FETCH_MODE = 2; + $ADODB_FETCH_MODE = 2; $this->GotValue=TRUE; } @@ -132,7 +132,7 @@ } return false; } - + function ProcessTag($tag) { $db =& $this->adodbConnection; @@ -151,90 +151,90 @@ $sql = 'SELECT VariableValue FROM '.GetTablePrefix()."ConfigurationValues WHERE VariableName = '%s'"; return $db->GetOne( sprintf($sql, $tag_params['name']) ); break; - + case 'm:post_format': switch($tag_params['type']) { case 'date': $this->PostFormatting = GetDateFormat(); break; case 'time': $this->PostFormatting = GetTimeFormat(); break; - case 'currency': + case 'currency': $this->PostFormatting = 'number'; $this->PostFormattingParams['precision'] = $tag_params['precision']; break; } return $tag_params['field']; break; - + case 'm:custom_action': $this->PostFormatting = $tag_params['action']; return ($tag_params['sql'] == 'empty') ? 'SELECT 1' : $tag_params['sql']; break; - + //m:sql_action sql="SHOW TABLES" action="COUNT" field="*" case 'm:sql_action': $this->PostFormatting = $tag_params['action']; $this->PostFormattingParams = $tag_params; return $tag_params['sql']; break; - + case 'link:hit_count': $type = $tag_params['type']; $sql = 'SELECT Hits FROM '.GetTablePrefix().'Link '; if($type == 'top') // by now only top is supported - { - $top_links_count = $this->ProcessTag('m:config name="Link_TopCount"'); // 5 - default + { + $top_links_count = $this->ProcessTag('m:config name="Link_MinPopRating"'); // 5 - default $sql .= 'ORDER BY Hits DESC LIMIT 0,'.$top_links_count; - + $rs = $db->Execute($sql); if($rs->RecordCount() > 0) { $rs->MoveLast(); - return $rs->fields['Hits']; + return $rs->fields['Hits']; } else return 0; } break; - + case 'article:hit_count': $type = $tag_params['type']; $sql = 'SELECT CachedRating FROM '.GetTablePrefix().'News '; if($type == 'top') // by now only top is supported - { - $top_articles_count = $this->ProcessTag('m:config name="News_VotesToHot"'); - $min_votes = $this->ProcessTag('m:config name="News_MinVotes"'); + { + $top_articles_count = $this->ProcessTag('m:config name="News_MaxHotNumber"'); + $min_votes = $this->ProcessTag('m:config name="News_MinPopVotes"'); $sql .= 'WHERE CachedVotesQty > '.$min_votes.' ORDER BY CachedRating DESC LIMIT 0,'.$top_articles_count; - + $rs = $db->Execute($sql); if($rs->RecordCount() > 0) { $rs->MoveLast(); - return $rs->fields['CachedRating']; + return $rs->fields['CachedRating']; } else return 0; } - break; - + break; + case 'topic:hit_count': $type = $tag_params['type']; $sql = 'SELECT Views FROM '.GetTablePrefix().'Topic '; if($type == 'top') // by now only top is supported - { - $top_posts_count = $this->ProcessTag('m:config name="Topic_PostsToPop"'); + { + $top_posts_count = $this->ProcessTag('m:config name="Topic_MinPopRating"'); $sql .= ' ORDER BY Views DESC LIMIT 0,'.$top_posts_count; - + $rs = $db->Execute($sql); if($rs->RecordCount() > 0) { $rs->MoveLast(); - return $rs->fields['Views']; + return $rs->fields['Views']; } else return 0; } break; - + case 'modules:get_current': return $this->Get('Module'); break; @@ -253,11 +253,11 @@ { return $this->parsetag($element->name); } - + function parsetag($tag) { if(is_object($tag)) - { + { $tagname = $tag->name; } else @@ -300,7 +300,7 @@ { // fills list with data $this->LoadStatItems($where,$orderBy, $use_limit ); - + for($i=0; $i < $this->NumItems(); $i++) { $s =& $this->GetItemRefByIndex($i); @@ -314,14 +314,14 @@ for($i=0;$i<$this->NumItems();$i++) { $s =& $this->GetItemRefByIndex($i); - $s->ExecuteValueSQL(); + $s->ExecuteValueSQL(); } if($this->debuglevel) echo "LastSQL: ".$s->CurrentSQL.'
'; } function ExecuteResetSQL() { - foreach($this->Items as $s) $s->ExecuteResetSQL(); + foreach($this->Items as $s) $s->ExecuteResetSQL(); } function LoadStatItems($where=NULL,$orderBy, $use_limit = false) @@ -333,10 +333,10 @@ $sql .= " WHERE ".$where; if(strlen(trim($orderBy))) $sql .= " ORDER BY ".$orderBy; - + if($use_limit) $sql .= " ".GetLimitSQL($this->Page,$objConfig->Get($this->PerPageVar)); - + if($this->debuglevel) echo "StatGetSQL: $sql
"; $this->Query_Item($sql); } Index: trunk/core/units/languages/import_xml.php =================================================================== diff -u -N -r5431 -r6583 --- trunk/core/units/languages/import_xml.php (.../import_xml.php) (revision 5431) +++ trunk/core/units/languages/import_xml.php (.../import_xml.php) (revision 6583) @@ -157,6 +157,9 @@ $path = implode(' ',$this->path); //check what path we are in + $this->LastLine = xml_get_current_line_number($parser); + $this->SecondData = false; + switch($path) { case 'LANGUAGES LANGUAGE': @@ -255,7 +258,14 @@ break; case 'LANGUAGES LANGUAGE EVENTS EVENT': + $cur_line = xml_get_current_line_number($parser); + if ($cur_line != $this->LastLine) { + $this->current_event['Template'] .= str_repeat("\r\n", ($cur_line - $this->LastLine) ); + $this->LastLine = $cur_line; + } $this->current_event['Template'] .= $line; + + $this->SecondData = true; break; } } @@ -282,6 +292,7 @@ case 'LANGUAGES LANGUAGE EVENTS EVENT': if ($this->current_language['Encoding'] == 'plain') { + $this->current_event['Template'] = rtrim($this->current_event['Template']); // nothing to decode! } else { Index: trunk/kernel/units/phrases/phrases_event_handler.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 6093) +++ trunk/kernel/units/phrases/phrases_event_handler.php (.../phrases_event_handler.php) (revision 6583) @@ -3,14 +3,20 @@ class PhrasesEventHandler extends InpDBEventHandler { + /** + * Allow to create phrases from front end in debug mode with DBG_PHRASES constant set + * + * @param kEvent $event + */ function CheckPermission(&$event) { - if (!$this->Application->IsAdmin() && $event->Name == 'OnCreate' && $this->Application->isDebugMode() && constOn('DBG_PHRASES')) { - if ($event->Name == 'OnCreate') { - // allow create phrases from front end in debug mode with DBG_PHRASES + if (!$this->Application->IsAdmin() && $this->Application->isDebugMode() && constOn('DBG_PHRASES')) { + if ($event->Name == 'OnNew' || $event->Name == 'OnCreate') { return true; } } + + return parent::CheckPermission($event); } /** Index: trunk/kernel/units/categories/categories_config.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 6093) +++ trunk/kernel/units/categories/categories_config.php (.../categories_config.php) (revision 6583) @@ -41,8 +41,8 @@ 'pending' => Array( 'icon' => 'icon16_cat_pending.gif', 'label' => 'la_tab_Categories', - 'js_url' => "set_persistant_var('Category_View', 41, 'advanced_view', '#url#')", - 'url' => Array('t' => 'advanced_view', 'index_file' => 'advanced_view.php', 'SetTab' => 'category', 'pass' => 'm'), + 'js_url' => '#url#', + 'url' => Array('t' => 'advanced_view', 'SetTab' => 'c', 'pass' => 'm,c.showall', 'c.showall_event' => 'OnSetFilterPattern', 'c.showall_filters' => 'show_active=0,show_pending=1,show_disabled=0,show_new=1,show_pick=1'), 'status' => STATUS_PENDING, ), ), Index: trunk/kernel/units/general/helpers/filenames_helper.php =================================================================== diff -u -N -r5509 -r6583 --- trunk/kernel/units/general/helpers/filenames_helper.php (.../filenames_helper.php) (revision 5509) +++ trunk/kernel/units/general/helpers/filenames_helper.php (.../filenames_helper.php) (revision 6583) @@ -11,7 +11,7 @@ { $not_allowed = Array( ' ', '\\', '/', ':', '*', '?', '"', '<', '>', '|', '`', '~', '!', '@', '#', '$', '%', '^', '&', '(', ')', '~', - '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ','); + '+', '=', '-', '{', '}', ']', '[', "'", ';', '.', ',', "\r", "\n"); $filename = str_replace($not_allowed, '_', $filename); $filename = preg_replace('/(_+)/', '_', $filename); Index: trunk/core/units/custom_fields/custom_fields_tag_processor.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/units/custom_fields/custom_fields_tag_processor.php (.../custom_fields_tag_processor.php) (revision 6093) +++ trunk/core/units/custom_fields/custom_fields_tag_processor.php (.../custom_fields_tag_processor.php) (revision 6583) @@ -36,13 +36,6 @@ return $this->Application->ProcessParsedTag($source_prefix, 'InputName', $params); } - function CustomError($params) - { - $params['name'] = $this->GetMainField($params); - $source_prefix = $this->Application->Parser->GetParam('SourcePrefix'); - return $this->Application->ProcessParsedTag($source_prefix, 'Error', $params); - } - function setParamValue(&$params, $param_name) { // $deep_level if GetParam = 1 used in case if PrintList is called during parsing "grid" block (=> +1 to deep_level) @@ -103,7 +96,7 @@ if ($display_original) { $list->SetDBField('OriginalValue', $original_object->GetField('cust_'.$list->GetDBField('FieldName'))); } - $block_params['field'] = 'cust_'.$list->GetDBField('FieldName'); + $block_params['field'] = $block_params['virtual_field'] = 'cust_'.$list->GetDBField('FieldName'); $block_params['show_heading'] = ($prev_heading != $list->GetDBField('Heading') ) ? 1 : 0; } Index: trunk/core/kernel/parser/template.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/kernel/parser/template.php (.../template.php) (revision 6093) +++ trunk/core/kernel/parser/template.php (.../template.php) (revision 6583) @@ -87,8 +87,18 @@ $conn =& $this->Application->GetADODBConnection(); } - function LoadTemplate($filename, $title=NULL, $silent=0) + /** + * Based on template name gets it's location on disk and owner module + * + * @param string $filename + * @return Array 0 - path on disk, 1 - template name + */ + function GetTemplatePaths($filename) { + if (isset($this->Application->ReplacementTemplates[$filename])) { + $filename = $this->Application->ReplacementTemplates[$filename]; + } + if (preg_match('#^[\/]{0,1}([^\/]*)\/(.*)#', $filename, $regs)) { $module_filename = $regs[2]; $first_dir = $regs[1]; @@ -106,28 +116,21 @@ $module_filename = $first_dir.'/'.$module_filename; } + return Array ($path, $module_filename); + } + + function LoadTemplate($filename, $title=NULL, $silent=0) + { + list ($path, $module_filename) = $this->GetTemplatePaths($filename); + $template =& new Template($path, $module_filename, $silent); if (!isset($title)) $title = $filename; $this->SetTemplate($title, $template); } - function GetRealFilename($filename, $base=null) { - if (preg_match('#^[\/]{0,1}([^\/]*)\/(.*)#', $filename, $regs)) { - $module_filename = $regs[2]; - $first_dir = $regs[1]; - } - else { - $first_dir = ''; - $module_filename = $filename; - } - - if ( $this->Application->IsAdmin() && $this->Application->findModule('Name', $first_dir)) { - $path = MODULES_PATH.'/'.strtolower($first_dir).'/admin_templates'; - } - else { - $path = isset($base) ? $base : $this->BasePath; - $module_filename = $first_dir.'/'.$module_filename; - } + function GetRealFilename($filename) + { + list ($path, $module_filename) = $this->GetTemplatePaths($filename); return $path.'/'.trim($module_filename, '/'); } @@ -175,8 +178,10 @@ function TemplateExists($filename) { - if (!preg_match("/\.tpl$/", $filename)) $filename .= '.tpl'; $real_file = $this->GetRealFilename($filename); + if (!preg_match('/\.tpl$/', $real_file)) { + $real_file .= '.tpl'; + } return file_exists($real_file); } Index: trunk/admin/install/upgrades/changelog_1_3_1.txt =================================================================== diff -u -N --- trunk/admin/install/upgrades/changelog_1_3_1.txt (revision 0) +++ trunk/admin/install/upgrades/changelog_1_3_1.txt (revision 6583) @@ -0,0 +1,50 @@ +File in-portal/admin/install/inportal_data.sql changed +File in-portal/admin/install/inportal_schema.sql changed +File in-portal/admin/install/langpacks/english.lang changed +File in-portal/admin/install/upgrades/changelog_1_3_1.txt is new; release_1_3_1 revision 1.1.2.1 +File in-portal/admin/install/upgrades/inportal_upgrade_v1.3.1.sql is new; release_1_3_1 revision 1.1.2.1 +File in-portal/kernel/admin_templates/advanced_view.tpl changed +File in-portal/kernel/admin_templates/catalog.tpl changed +File in-portal/kernel/admin_templates/catalog_tab.tpl changed +File in-portal/kernel/admin_templates/incs/catalog.js changed +File in-portal/kernel/admin_templates/incs/custom_blocks.tpl changed +File in-portal/kernel/admin_templates/incs/grid_blocks.tpl changed +File in-portal/kernel/admin_templates/summary/root.tpl changed +File in-portal/kernel/admin_templates/xml/categories_list.tpl changed +File in-portal/kernel/include/category.php changed +File in-portal/kernel/include/statitem.php changed +File in-portal/kernel/units/admin/admin_tag_processor.php changed +File in-portal/kernel/units/categories/categories_config.php changed +File in-portal/kernel/units/custom_fields/custom_fields_config.php changed +File in-portal/kernel/units/custom_fields/custom_fields_tag_processor.php changed +File in-portal/kernel/units/email_events/email_events_config.php changed +File in-portal/kernel/units/email_messages/email_messages_event_handler.php changed +File in-portal/kernel/units/general/cat_dbitem.php changed +File in-portal/kernel/units/general/cat_event_handler.php changed +File in-portal/kernel/units/general/general_config.php changed +File in-portal/kernel/units/general/my_application.php changed +File in-portal/kernel/units/languages/import_xml.php changed +File in-portal/kernel/units/languages/languages_config.php changed +File in-portal/kernel/units/languages/languages_item.php changed +File in-portal/kernel/units/phrases/phrases_event_handler.php changed +File in-portal/kernel/units/relationship/relationship_event_handler.php changed +File in-portal/kernel/units/users/users_event_handler.php changed +File kernel4_dev/kernel4/application.php changed +File kernel4_dev/kernel4/db/db_event_handler.php changed +File kernel4_dev/kernel4/db/dbitem.php changed +File kernel4_dev/kernel4/parser/template.php changed +File kernel4_dev/kernel4/utility/params.php changed +File kernel4_dev/kernel4/utility/unit_config_reader.php changed +File kernel4_dev/kernel4/utility/formatters/formatter.php changed +File kernel4_dev/kernel4/utility/formatters/upload_formatter.php changed +File cmseditor/editor/dialog/fck_link.html changed +File cmseditor/editor/dialog/fckblank.html is new; release_1_3_1 revision 1.1 +File cmseditor/editor/filemanager/browser/default/browser.html changed +File cmseditor/editor/filemanager/browser/default/fckblank.html is new; release_1_3_1 revision 1.1 +File cmseditor/editor/filemanager/browser/default/connectors/php/commands.php changed +File cmseditor/editor/images/dot.gif is new; release_1_3_1 revision 1.1 + + +Changes in phrases and events: + + Index: trunk/kernel/units/general/cat_dbitem_export.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 6093) +++ trunk/kernel/units/general/cat_dbitem_export.php (.../cat_dbitem_export.php) (revision 6583) @@ -364,34 +364,86 @@ function getCustomSQL() { $ml_formatter =& $this->Application->recallObject('kMultiLanguage'); - + $custom_sql = ''; foreach ($this->customFields as $custom_id => $custom_name) { $custom_sql .= 'custom_data.'.$ml_formatter->LangFieldName('cust_'.$custom_id).' AS cust_'.$custom_name.', '; } - + return preg_replace('/(.*), /', '\\1', $custom_sql); } - + + function getPlainExportSQL($count_only = false) { + if ($count_only && isset($this->exportOptions['ForceCountSQL'])) return $this->exportOptions['ForceCountSQL']; + if (!$count_only && isset($this->exportOptions['ForceSelectSQL'])) return $this->exportOptions['ForceSelectSQL']; + + $items_list =& $this->Application->recallObject($this->curItem->Prefix.'.export-items-list', $this->curItem->Prefix.'_List'); + $items_list->SetPerPage(-1); + return $items_list->GetSelectSQL($count_only); + + + if ($this->exportOptions['export_ids'] === false) + { + // get links from current category & all it's subcategories + $join_clauses = Array(); + + $custom_sql = $this->getCustomSQL(); + if ($custom_sql) { + $custom_table = $this->Application->getUnitOption($this->curItem->Prefix.'-cdata', 'TableName'); + $join_clauses[$custom_table.' custom_data'] = 'custom_data.ResourceId = item_table.ResourceId'; + } + + $sql = 'SELECT item_table.*'.($custom_sql ? ', '.$custom_sql : '').' + FROM '.$this->curItem->TableName.' item_table'; + + foreach ($join_clauses as $table_name => $join_expression) { + $sql .= ' LEFT JOIN '.$table_name.' ON '.$join_expression; + } + $sql .= ' WHERE 1'; + + $sql .= ' ORDER BY item_table.'.$this->curItem->IDField.' ASC'; // NEW + } + else { + // get only selected links + $sql = 'SELECT item_table.* + FROM '.$this->curItem->TableName.' item_table + WHERE '.$this->curItem->IDField.' IN ('.implode(',', $this->exportOptions['export_ids']).')'; + } + + if (!$count_only) + { + $sql .= ' LIMIT '.$this->exportOptions['start_from'].','.EXPORT_STEP; + } + else { + $sql = preg_replace("/^.*SELECT(.*?)FROM(?!_)/is", "SELECT COUNT(*) AS count FROM ", $sql); + } + + return $sql; + } + function getExportSQL($count_only = false) { + if (!$this->Application->getUnitOption($this->curItem->Prefix, 'CatalogItem')) { + return $this->GetPlainExportSQL($count_only); // in case this is not a CategoryItem + } + if ($this->exportOptions['export_ids'] === false) { // get links from current category & all it's subcategories $join_clauses = Array(); - + $custom_sql = $this->getCustomSQL(); if ($custom_sql) { $custom_table = $this->Application->getUnitOption($this->curItem->Prefix.'-cdata', 'TableName'); $join_clauses[$custom_table.' custom_data'] = 'custom_data.ResourceId = item_table.ResourceId'; } - + $join_clauses[TABLE_PREFIX.'CategoryItems ci'] = 'ci.ItemResourceId = item_table.ResourceId'; $join_clauses[TABLE_PREFIX.'Category c'] = 'c.CategoryId = ci.CategoryId'; - + $sql = 'SELECT item_table.*, ci.CategoryId'.($custom_sql ? ', '.$custom_sql : '').' FROM '.$this->curItem->TableName.' item_table'; - + foreach ($join_clauses as $table_name => $join_expression) { $sql .= ' LEFT JOIN '.$table_name.' ON '.$join_expression; } @@ -475,7 +527,7 @@ $this->curItem->SetDBFieldsFromHash($record_info); $this->setCurrentID(); $this->curItem->raiseEvent('OnAfterItemLoad', $this->curItem->GetID() ); - + $data_array = Array(); foreach ($this->exportFields as $export_field) { @@ -650,7 +702,7 @@ } $this->curItem->Clear(); $this->customFields = $this->Application->getUnitOption($event->Prefix, 'CustomFields'); - + if (isset($record_data)) { $this->setImportData($record_data); } @@ -679,7 +731,7 @@ if (is_null($lang_prefix)) { $lang_prefix = 'l'.$this->Application->GetVar('m_lang').'_'; } - + foreach ($this->curItem->CategoryPath as $category_index => $category_name) { if (!$category_name) continue; $category_key = crc32( implode(':', array_slice($this->curItem->CategoryPath, 0, $category_index + 1) ) ); @@ -766,7 +818,7 @@ else { $where_clause .= '(item_table.`'.$field_name.'` = '.$this->Conn->qstr($field_value).') AND '; } - + } $where_clause = preg_replace('/(.*) AND $/', '\\1', $where_clause); @@ -777,7 +829,7 @@ $parent_path = $this->getParentPath($category_id); $where_clause = '(c.ParentPath LIKE "'.$parent_path.'%") AND '.$where_clause; } - + $cdata_table = $this->Application->getUnitOption($event->Prefix.'-cdata', 'TableName'); $sql = 'SELECT '.$this->curItem->IDField.' FROM '.$this->curItem->TableName.' item_table @@ -828,11 +880,11 @@ /*function saveLog($msg) { static $first_time = true; - + $fp = fopen(FULL_PATH.'/sqls.log', $first_time ? 'w' : 'a'); fwrite($fp, $msg."\n"); fclose($fp); - + $first_time = false; }*/ @@ -1069,6 +1121,277 @@ { return unserialize($this->Application->RecallVar($event->getPrefixSpecial().'_options')); } + + /** + * Sets correct available & export fields + * + * @param kEvent $event + */ + function prepareExportColumns(&$event) + { + $object =& $event->getObject( Array('skip_autoload' => true) ); + + $available_columns = Array(); + + if ($this->Application->getUnitOption($event->Prefix, 'CatalogItem')) { + // category field (mixed) + $available_columns['__CATEGORY__CategoryPath'] = 'CategoryPath'; + + if ($event->Special == 'import') { + // category field (separated fields) + $max_level = $this->Application->ConfigValue('MaxImportCategoryLevels'); + $i = 0; + while ($i < $max_level) { + $available_columns['__CATEGORY__Category'.($i + 1)] = 'Category'.($i + 1); + $i++; + } + } + } + + // db fields + foreach ($object->Fields as $field_name => $field_options) + { + if (!$object->SkipField($field_name)) + { + $available_columns[$field_name] = $field_name.(getArrayValue($field_options, 'required') ? '*' : ''); + } + } + + $handler =& $this->Application->recallObject($event->Prefix.'_EventHandler'); + $available_columns = array_merge_recursive2($available_columns, $handler->getCustomExportColumns($event)); + + // custom fields + foreach ($object->customFields as $custom_id => $custom_name) + { + $available_columns['__CUSTOM__'.$custom_name] = $custom_name; + } + + // columns already in use + $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); + if ($items_info) + { + list($item_id, $field_values) = each($items_info); + $export_keys = $field_values['ExportColumns']; + $export_keys = $export_keys ? explode('|', substr($export_keys, 1, -1) ) : Array(); + } + else { + $export_keys = Array(); + } + + $export_columns = Array(); + foreach ($export_keys as $field_key) + { + $field_name = $this->getExportField($field_key); + $export_columns[$field_key] = $field_name; + unset($available_columns[$field_key]); + } + + $options = $object->GetFieldOptions('ExportColumns'); + $options['options'] = $export_columns; + $object->SetFieldOptions('ExportColumns', $options); + + $options = $object->GetFieldOptions('AvailableColumns'); + $options['options'] = $available_columns; + $object->SetFieldOptions('AvailableColumns', $options); + + $this->updateImportFiles($event); + $this->PrepareExportPresets($event); + } + + function PrepareExportPresets(&$event) + { + $object =& $event->getObject( Array('skip_autoload' => true) ); + $options = $object->GetFieldOptions('ExportPresets'); + + $user =& $this->Application->recallObject('u'); + $export_settings = $user->getPersistantVar('export_settings'); + if (!$export_settings) return ; + $export_settings = unserialize($export_settings); + + if (!isset($export_settings[$event->Prefix])) return ; + + + $export_presets = array(''=>''); + foreach ($export_settings[$event->Prefix] as $key => $val) { + $export_presets[implode('|', $val['ExportColumns'])] = $key; + } + + $options['options'] = $export_presets; + $object->SetFieldOptions('ExportPresets', $options); + } + + function getExportField($field_key) + { + $prepends = Array('__CUSTOM__', '__CATEGORY__'); + foreach ($prepends as $prepend) + { + if (substr($field_key, 0, strlen($prepend) ) == $prepend) + { + $field_key = substr($field_key, strlen($prepend), strlen($field_key) ); + break; + } + } + return $field_key; + } + + /** + * Updates uploaded files list + * + * @param kEvent $event + */ + function updateImportFiles(&$event) + { + if ($event->Special != 'import') { + return false; + } + + $object =& $event->getObject(); + + $import_filenames = Array(); + + if ($folder_handle = opendir(EXPORT_PATH)) { + while (false !== ($file = readdir($folder_handle))) { + if (is_dir(EXPORT_PATH.'/'.$file) || substr($file, 0, 1) == '.' || strtolower($file) == 'cvs' || strtolower($file) == 'dummy' || filesize(EXPORT_PATH.'/'.$file) == 0) continue; + + $file_size = formatSize( filesize(EXPORT_PATH.'/'.$file) ); + $import_filenames[$file] = $file.' ('.$file_size.')'; + } + closedir($folder_handle); + } + + $options = $object->GetFieldOptions('ImportLocalFilename'); + $options['options'] = $import_filenames; + $object->SetFieldOptions('ImportLocalFilename', $options); + } + + /** + * Returns module folder + * + * @param kEvent $event + * @return string + */ + function getModuleFolder(&$event) + { + return $this->Application->getUnitOption($event->Prefix, 'ModuleFolder'); + } + + /** + * Export form validation & processing + * + * @param kEvent $event + */ + function OnExportBegin(&$event) + { + $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); + if (!$items_info) + { + $items_info = unserialize( $this->Application->RecallVar($event->getPrefixSpecial().'_ItemsInfo') ); + $this->Application->SetVar($event->getPrefixSpecial(true), $items_info); + } + + list($item_id, $field_values) = each($items_info); + + $object =& $event->getObject( Array('skip_autoload' => true) ); + $object->SetFieldsFromHash($field_values); + $field_values['ImportFilename'] = $object->GetDBField('ImportFilename'); //if upload formatter has renamed the file during moving !!! + + $object->setID($item_id); + $this->setRequiredFields($event); + + $export_object =& $this->Application->recallObject('CatItemExportHelper'); + + // save export/import options + if ($event->Special == 'export') + { + $export_ids = $this->Application->RecallVar($event->Prefix.'_export_ids'); + $export_cats_ids = $this->Application->RecallVar($event->Prefix.'_export_cats_ids'); + + // used for multistep export + $field_values['export_ids'] = $export_ids ? explode(',', $export_ids) : false; + $field_values['export_cats_ids'] = $export_cats_ids ? explode(',', $export_cats_ids) : Array( $this->Application->GetVar('m_cat_id') ); + } + + $field_values['ExportColumns'] = $field_values['ExportColumns'] ? explode('|', substr($field_values['ExportColumns'], 1, -1) ) : Array(); + $field_values['start_from'] = 0; + + $this->Application->HandleEvent($nevent, $event->Prefix.':OnBeforeExportBegin', array('options'=>$field_values)); + $field_values = $nevent->getEventParam('options'); + + $export_object->saveOptions($event, $field_values); + + if( $export_object->verifyOptions($event) ) + { + if ($object->GetDBField('ExportSavePreset')) { + $name = $object->GetDBField('ExportPresetName'); + $user =& $this->Application->recallObject('u'); + $export_settings = $user->getPersistantVar('export_settings'); + $export_settings = $export_settings ? unserialize($export_settings) : array(); + $export_settings[$event->Prefix][$name] = $field_values; + $user->setPersistantVar('export_settings', serialize($export_settings)); + } + + $progress_t = $this->Application->RecallVar('export_progress_t'); + if ($progress_t) { + $this->Application->RemoveVar('export_progress_t'); + } + else { + $progress_t = $export_object->getModuleFolder($event).'/'.$event->Special.'_progress'; + } + $event->redirect = $progress_t; + } + else + { + // make uploaded file local & change source selection + $filename = getArrayValue($field_values, 'ImportFilename'); + if ($filename) { + $export_object->updateImportFiles($event); + $object->SetDBField('ImportSource', 2); + $field_values['ImportSource'] = 2; + $object->SetDBField('ImportLocalFilename', $filename); + $field_values['ImportLocalFilename'] = $filename; + $export_object->saveOptions($event, $field_values); + } + + $event->status = erFAIL; + $event->redirect = false; + } + } + + /** + * set required fields based on import or export params + * + * @param kEvent $event + */ + function setRequiredFields(&$event) + { + $required_fields['common'] = Array('FieldsSeparatedBy', 'LineEndings', 'CategoryFormat'); + + $required_fields['export'] = Array('ExportFormat', 'ExportFilename','ExportColumns'); + + $object =& $event->getObject(); + if ($object->GetDBField('ExportSavePreset')) { + $required_fields['export'][] = 'ExportPresetName'; + } + + $required_fields['import'] = Array('FieldTitles', 'ImportSource', 'CheckDuplicatesMethod'); // ImportFilename, ImportLocalFilename + + if ($event->Special == 'import') + { + $import_source = Array(1 => 'ImportFilename', 2 => 'ImportLocalFilename'); + $used_field = $import_source[ $object->GetDBField('ImportSource') ]; + + $required_fields[$event->Special][] = $used_field; + $object->Fields[$used_field]['error_field'] = 'ImportSource'; + + if ($object->GetDBField('FieldTitles') == 2) $required_fields[$event->Special][] = 'ExportColumns'; // manual field titles + } + + $required_fields = array_merge($required_fields['common'], $required_fields[$event->Special]); + foreach ($required_fields as $required_field) { + $object->setRequired($required_field, true); + } + } + } ?> Index: trunk/core/kernel/processors/tag_processor.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 6093) +++ trunk/core/kernel/processors/tag_processor.php (.../tag_processor.php) (revision 6583) @@ -49,27 +49,39 @@ $this->Application->Debugger->appendHTML('Processing PreParsed Tag '.$Method.' in '.$this->Prefix); } + $backup_prefix = $this->Prefix; + $backup_special = $this->Special; + + // process all possible flags: begin + $flags = Array('js_escape', 'result_to_var', 'pass_params'); + $flag_values = Array(); + + foreach ($flags as $flag_name) { + $flag_values[$flag_name] = false; + if (isset($params[$flag_name])) { + $flag_values[$flag_name] = $params[$flag_name]; + unset($params[$flag_name]); + } + } + // process all possible flags: end + // pass_params for non ParseBlock tags :) - if (isset($params['pass_params']) && $params['pass_params']) { + if ($flag_values['pass_params']) { $params = array_merge_recursive2($this->Application->Parser->Params, $params); - unset($params['pass_params']); } - $backup_prefix = $this->Prefix; - $backup_special = $this->Special; - $ret = $this->$Method($params); $this->Prefix = $backup_prefix; $this->Special = $backup_special; - if (isset($params['js_escape']) && $params['js_escape']) { + if ($flag_values['js_escape']) { $ret = str_replace('\'', ''', $ret); $ret = addslashes($ret); $ret = str_replace(Array("\r", "\n"), Array('\r', '\n'), $ret); } - if (isset($params['result_to_var'])) { - $this->Application->Parser->SetParam($params['result_to_var'], $ret); + if ($flag_values['result_to_var']) { + $this->Application->Parser->SetParam($flag_values['result_to_var'], $ret); $ret = ''; } return $ret; Index: trunk/kernel/units/languages/languages_config.php =================================================================== diff -u -N -r5110 -r6583 --- trunk/kernel/units/languages/languages_config.php (.../languages_config.php) (revision 5110) +++ trunk/kernel/units/languages/languages_config.php (.../languages_config.php) (revision 6583) @@ -140,7 +140,7 @@ 'DateFormat' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'TimeFormat' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), 'InputDateFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('m/d/Y' => 'm/d/Y'), 'not_null' => '1','default' => 'm/d/Y', 'required' => 1), - 'InputTimeFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('g:i:s A' => 'g:i:s A'), 'not_null' => '1','default' => 'g:i:s A', 'required' => 1), + 'InputTimeFormat' => Array('type' => 'string', 'formatter' => 'kOptionsFormatter', 'options' => Array('g:i:s A' => 'g:i:s A'), 'not_null' => '1','default' => 'g:i:s A', 'required' => 1), 'DecimalPoint' => Array('type' => 'string','not_null' => '1','default' => ''), 'ThousandSep' => Array('type' => 'string','not_null' => '1','default' => ''), 'Charset' => Array('type' => 'string','not_null' => '1','default' => '','required'=>1), Index: trunk/kernel/units/general/cat_event_handler.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 6428) +++ trunk/kernel/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 6583) @@ -129,6 +129,7 @@ if ($clipboard_data['copy']) { $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler'); + $this->Application->SetVar('ResetCatBeforeClone', 1); $temp->CloneItems($event->Prefix, $event->Special, $clipboard_data['copy']); } @@ -460,7 +461,8 @@ if ($event->Special == 'export' || $event->Special == 'import') { - $this->prepareExportColumns($event); + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $export_helper->prepareExportColumns($event); } } @@ -1329,17 +1331,6 @@ /* === RELATED TO IMPORT/EXPORT: BEGIN === */ /** - * Returns module folder - * - * @param kEvent $event - * @return string - */ - function getModuleFolder(&$event) - { - return $this->Application->getUnitOption($event->Prefix, 'ModuleFolder'); - } - - /** * Shows export dialog * * @param kEvent $event @@ -1366,7 +1357,8 @@ $this->Application->StoreVar($event->Prefix.'_export_ids', $selected_ids ? implode(',', $selected_ids) : '' ); $this->Application->StoreVar($event->Prefix.'_export_cats_ids', $selected_cats_ids); - $event->redirect = $this->getModuleFolder($event).'/export'; + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $event->redirect = $export_helper->getModuleFolder($event).'/export'; $redirect_params = Array( 'm_opener' => 'd', $this->Prefix.'.export_event' => 'OnNew', @@ -1376,181 +1368,6 @@ } /** - * Export form validation & processing - * - * @param kEvent $event - */ - function OnExportBegin(&$event) - { - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - if (!$items_info) - { - $items_info = unserialize( $this->Application->RecallVar($event->getPrefixSpecial().'_ItemsInfo') ); - $this->Application->SetVar($event->getPrefixSpecial(true), $items_info); - } - - list($item_id, $field_values) = each($items_info); - - $object =& $event->getObject( Array('skip_autoload' => true) ); - $object->SetFieldsFromHash($field_values); - $field_values['ImportFilename'] = $object->GetDBField('ImportFilename'); //if upload formatter has renamed the file during moving !!! - - $object->setID($item_id); - $this->setRequiredFields($event); - - $export_object =& $this->Application->recallObject('CatItemExportHelper'); - - // save export/import options - if ($event->Special == 'export') - { - $export_ids = $this->Application->RecallVar($event->Prefix.'_export_ids'); - $export_cats_ids = $this->Application->RecallVar($event->Prefix.'_export_cats_ids'); - - // used for multistep export - $field_values['export_ids'] = $export_ids ? explode(',', $export_ids) : false; - $field_values['export_cats_ids'] = $export_cats_ids ? explode(',', $export_cats_ids) : Array( $this->Application->GetVar('m_cat_id') ); - } - - $field_values['ExportColumns'] = $field_values['ExportColumns'] ? explode('|', substr($field_values['ExportColumns'], 1, -1) ) : Array(); - $field_values['start_from'] = 0; - $export_object->saveOptions($event, $field_values); - - if( $export_object->verifyOptions($event) ) - { - $event->redirect = $this->getModuleFolder($event).'/'.$event->Special.'_progress'; - - } - else - { - // make uploaded file local & change source selection - $filename = getArrayValue($field_values, 'ImportFilename'); - if ($filename) { - $this->updateImportFiles($event); - $object->SetDBField('ImportSource', 2); - $field_values['ImportSource'] = 2; - $object->SetDBField('ImportLocalFilename', $filename); - $field_values['ImportLocalFilename'] = $filename; - $export_object->saveOptions($event, $field_values); - } - - $event->status = erFAIL; - $event->redirect = false; - } - } - - /** - * Enter description here... - * - * @param kEvent $event - */ - function OnExportCancel(&$event) - { - $this->OnGoBack($event); - } - - /** - * Sets correct available & export fields - * - * @param kEvent $event - */ - function prepareExportColumns(&$event) - { - $object =& $event->getObject( Array('skip_autoload' => true) ); - - $available_columns = Array(); - - // category field (mixed) - $available_columns['__CATEGORY__CategoryPath'] = 'CategoryPath'; - - if ($event->Special == 'import') { - // category field (separated fields) - $max_level = $this->Application->ConfigValue('MaxImportCategoryLevels'); - $i = 0; - while ($i < $max_level) { - $available_columns['__CATEGORY__Category'.($i + 1)] = 'Category'.($i + 1); - $i++; - } - } - - // db fields - foreach ($object->Fields as $field_name => $field_options) - { - if (!$object->SkipField($field_name)) - { - $available_columns[$field_name] = $field_name.(getArrayValue($field_options, 'required') ? '*' : ''); - } - } - - $available_columns = array_merge_recursive2($available_columns, $this->getCustomExportColumns($event)); - - // custom fields - foreach ($object->customFields as $custom_id => $custom_name) - { - $available_columns['__CUSTOM__'.$custom_name] = $custom_name; - } - - // columns already in use - $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) ); - if ($items_info) - { - list($item_id, $field_values) = each($items_info); - $export_keys = $field_values['ExportColumns']; - $export_keys = $export_keys ? explode('|', substr($export_keys, 1, -1) ) : Array(); - } - else { - $export_keys = Array(); - } - - $export_columns = Array(); - foreach ($export_keys as $field_key) - { - $field_name = $this->getExportField($field_key); - $export_columns[$field_key] = $field_name; - unset($available_columns[$field_key]); - } - - $options = $object->GetFieldOptions('ExportColumns'); - $options['options'] = $export_columns; - $object->SetFieldOptions('ExportColumns', $options); - - $options = $object->GetFieldOptions('AvailableColumns'); - $options['options'] = $available_columns; - $object->SetFieldOptions('AvailableColumns', $options); - - $this->updateImportFiles($event); - } - - /** - * Updates uploaded files list - * - * @param kEvent $event - */ - function updateImportFiles(&$event) - { - if ($event->Special != 'import') { - return false; - } - - $object =& $event->getObject(); - - $import_filenames = Array(); - - if ($folder_handle = opendir(EXPORT_PATH)) { - while (false !== ($file = readdir($folder_handle))) { - if (is_dir(EXPORT_PATH.'/'.$file) || substr($file, 0, 1) == '.' || strtolower($file) == 'cvs' || strtolower($file) == 'dummy' || filesize(EXPORT_PATH.'/'.$file) == 0) continue; - - $file_size = formatSize( filesize(EXPORT_PATH.'/'.$file) ); - $import_filenames[$file] = $file.' ('.$file_size.')'; - } - closedir($folder_handle); - } - - $options = $object->GetFieldOptions('ImportLocalFilename'); - $options['options'] = $import_filenames; - $object->SetFieldOptions('ImportLocalFilename', $options); - } - - /** * Returns specific to each item type columns only * * @param kEvent $event @@ -1631,22 +1448,6 @@ return preg_match('#(http|https)://(.*)#', $path); } -// ImportLocalFilename - - function getExportField($field_key) - { - $prepends = Array('__CUSTOM__', '__CATEGORY__'); - foreach ($prepends as $prepend) - { - if (substr($field_key, 0, strlen($prepend) ) == $prepend) - { - $field_key = substr($field_key, strlen($prepend), strlen($field_key) ); - break; - } - } - return $field_key; - } - /** * Prepares item for import/export operations * @@ -1657,41 +1458,12 @@ parent::OnNew($event); if ($event->Special != 'import' && $event->Special != 'export') return ; - $this->setRequiredFields($event); + $export_helper =& $this->Application->recallObject('CatItemExportHelper'); + $export_helper->setRequiredFields($event); $this->Application->StoreVar('ImportCategory', 0); } /** - * set required fields based on import or export params - * - * @param kEvent $event - */ - function setRequiredFields(&$event) - { - $required_fields['common'] = Array('FieldsSeparatedBy', 'LineEndings', 'CategoryFormat'); - - $required_fields['export'] = Array('ExportFormat', 'ExportFilename','ExportColumns'); - $required_fields['import'] = Array('FieldTitles', 'ImportSource', 'CheckDuplicatesMethod'); // ImportFilename, ImportLocalFilename - - $object =& $event->getObject(); - if ($event->Special == 'import') - { - $import_source = Array(1 => 'ImportFilename', 2 => 'ImportLocalFilename'); - $used_field = $import_source[ $object->GetDBField('ImportSource') ]; - - $required_fields[$event->Special][] = $used_field; - $object->Fields[$used_field]['error_field'] = 'ImportSource'; - - if ($object->GetDBField('FieldTitles') == 2) $required_fields[$event->Special][] = 'ExportColumns'; // manual field titles - } - - $required_fields = array_merge($required_fields['common'], $required_fields[$event->Special]); - foreach ($required_fields as $required_field) { - $object->setRequired($required_field, true); - } - } - - /** * Process items selected in item_selector * * @param kEvent $event @@ -1871,6 +1643,21 @@ } /** + * Occures before an item is cloneded + * Id of ORIGINAL item is passed as event' 'id' param + * Do not call object' Update method in this event, just set needed fields! + * + * @param kEvent $event + */ + function OnBeforeClone(&$event) + { + if ($this->Application->GetVar('ResetCatBeforeClone')) { + $object =& $event->getObject(); + $object->SetDBField('CategoryId', null); + } + } + + /** * Apply same processing to each item beeing selected in grid * * @param kEvent $event Index: trunk/kernel/units/categories/categories_event_handler.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6093) +++ trunk/kernel/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 6583) @@ -250,12 +250,11 @@ function GetPassedId(&$event) { - if ( $this->Application->IsAdmin() ) return parent::getPassedID($event); - - $ret = $this->Application->GetVar('m_cat_id'); - if($ret) return $ret; - + if ( $this->Application->IsAdmin() ) { return parent::getPassedID($event); + } + + return $this->Application->GetVar('m_cat_id'); } /** Index: trunk/core/admin_templates/catalog/catalog.tpl =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 6093) +++ trunk/core/admin_templates/catalog/catalog.tpl (.../catalog.tpl) (revision 6583) @@ -21,26 +21,26 @@ Request.progressText = ''; var $is_catalog = true; var $Catalog = new Catalog('', 'catalog_'); - var a_toolbar = new ToolBar(); - + var a_toolbar = new ToolBar(); + a_toolbar.AddButton( new ToolBarButton('upcat', '', function() { $Catalog.go_to_cat($Catalog.ParentCategoryID); } ) ); - + a_toolbar.AddButton( new ToolBarButton('homecat', '', function() { $Catalog.go_to_cat(0); } - ) ); - + ) ); + a_toolbar.AddButton( new ToolBarSeparator('sep1') ); - + a_toolbar.AddButton( new ToolBarButton('new_cat', '', function() { std_precreate_item('c', 'categories/categories_edit'); } - ) ); - - + ) ); + + a_toolbar.AddButton( new ToolBarButton('editcat', '', function() { var $edit_url = ''; var $category_id = get_hidden_field('m_cat_id'); @@ -49,33 +49,33 @@ redirect($redirect_url); } ) ); - + - - + + a_toolbar.AddButton( new ToolBarButton('edit', '', edit) ); - + a_toolbar.AddButton( new ToolBarButton('delete', '', function() { var $template = $Catalog.queryTabRegistry('prefix', $Catalog.getCurrentPrefix(), 'view_template'); std_delete_items($Catalog.getCurrentPrefix(), $template, 1); - } ) ); - - + } ) ); + + a_toolbar.AddButton( new ToolBarSeparator('sep2') ); - + a_toolbar.AddButton( new ToolBarButton('approve', '', function() { $Catalog.submit_event(null, 'OnMassApprove'); } ) ); - + a_toolbar.AddButton( new ToolBarButton('decline', '', function() { $Catalog.submit_event(null, 'OnMassDecline'); } - ) ); - + ) ); + a_toolbar.AddButton( new ToolBarSeparator('sep3') ); - + a_toolbar.AddButton( new ToolBarButton('export', '', function() { var $export_prefixes = new Array('l', 'p'); if (in_array($Catalog.ActivePrefix, $export_prefixes)) { @@ -86,65 +86,65 @@ } } ) ); - + a_toolbar.AddButton( new ToolBarButton('rebuild_cache', '', function() { redirect(''); } ) ); - + a_toolbar.AddButton( new ToolBarSeparator('sep4') ); - - + + a_toolbar.AddButton( new ToolBarButton('cut', '', function() { $Catalog.submit_event(null, 'OnCut'); } ) ); - + a_toolbar.AddButton( new ToolBarButton('copy', '', function() { $Catalog.submit_event(null, 'OnCopy'); } ) ); - - + + a_toolbar.AddButton( new ToolBarButton('paste', '', function() { - $Catalog.submit_event('c', 'OnPasteClipboard', null, function($object) { + $Catalog.submit_event('c', 'OnPasteClipboard', null, function($object) { $object.resetTabs(true); - $object.switchTab(); + $object.switchTab(); } ); } ) ); - + /*a_toolbar.AddButton( new ToolBarButton('clear_clipboard', '', function() { if (confirm('')) { - $Catalog.submit_event('c', 'OnClearClipboard', null, function($object) { + $Catalog.submit_event('c', 'OnClearClipboard', null, function($object) { $GridManager.CheckDependencies($object.ActivePrefix); } ); } } ) );*/ - + a_toolbar.AddButton( new ToolBarSeparator('sep5') ); - + a_toolbar.AddButton( new ToolBarButton('move_up', '', function() { $Catalog.submit_event(null, 'OnMassMoveUp'); } ) ); - - + + a_toolbar.AddButton( new ToolBarButton('move_down', '', function() { $Catalog.submit_event(null, 'OnMassMoveDown'); } ) ); - + a_toolbar.AddButton( new ToolBarSeparator('sep6') ); - + a_toolbar.AddButton( new ToolBarButton('view', '', function() { show_viewmenu(a_toolbar, 'view'); } ) ); - - a_toolbar.Render(); - + + a_toolbar.Render(); + function edit() { var $current_prefix = $Catalog.getCurrentPrefix(); @@ -189,7 +189,7 @@ - + @@ -218,10 +218,10 @@ - + - + Index: trunk/core/units/general/my_application.php =================================================================== diff -u -N -r5547 -r6583 --- trunk/core/units/general/my_application.php (.../my_application.php) (revision 5547) +++ trunk/core/units/general/my_application.php (.../my_application.php) (revision 6583) @@ -26,20 +26,6 @@ $this->registerClass('kXMLHelper',MODULES_PATH.'/kernel/units/general/xml_helper.php','kXMLHelper'); $this->registerClass('kModulesHelper', MODULES_PATH.'/kernel/units/general/helpers/modules.php', 'ModulesHelper'); - - /*$this->registerClass('kMultiLanguageHelper',MODULES_PATH.'/kernel/units/general/helpers/multilanguage.php','kMultiLanguageHelper'); - $this->registerClass('kSearchHelper', MODULES_PATH.'/kernel/units/general/helpers/search_helper.php', 'SearchHelper'); - $this->registerClass('kSectionsHelper', MODULES_PATH.'/kernel/units/general/helpers/sections_helper.php', 'SectionsHelper'); - $this->registerClass('kPermissionsHelper', MODULES_PATH.'/kernel/units/general/helpers/permissions_helper.php', 'PermissionsHelper'); - - - $this->registerClass('kModRewriteHelper', MODULES_PATH.'/kernel/units/general/helpers/mod_rewrite_helper.php', 'ModRewriteHelper'); - $this->registerClass('kRecursiveHelper', MODULES_PATH.'/kernel/units/general/helpers/recursive_helper.php', 'RecursiveHelper'); - $this->registerClass('kFilenamesHelper', MODULES_PATH.'/kernel/units/general/helpers/filenames_helper.php', 'kFilenamesHelper'); - - $this->registerClass('kPDFHelper', MODULES_PATH.'/kernel/units/general/helpers/pdf_helper.php', 'kPDFHelper'); - */ - } function getUserGroups($user_id) Index: trunk/kernel/units/categories/categories_tag_processor.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 6428) +++ trunk/kernel/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 6583) @@ -280,7 +280,13 @@ function IsCurrent($params) { - return false; + $object =& $this->getObject($params); + if ($object->GetID() == $this->Application->GetVar('m_cat_id')) { + return true; + } + else { + return false; + } } /** Index: trunk/core/kernel/utility/params.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/kernel/utility/params.php (.../params.php) (revision 6093) +++ trunk/core/kernel/utility/params.php (.../params.php) (revision 6583) @@ -19,7 +19,7 @@ { // $re = preg_quote('([\${}a-zA-Z0-9_.-#\[\]]+)=(["\']{1,1})(.*?)(? $val){ Index: trunk/kernel/units/general/cat_tag_processor.php =================================================================== diff -u -N -r6428 -r6583 --- trunk/kernel/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 6428) +++ trunk/kernel/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 6583) @@ -63,26 +63,6 @@ return $this->Application->ProcessParsedTag('m', 't', $params); } - /** - * Returns path where exported category items should be saved - * - * @param Array $params - */ - function ExportPath($params) - { - $ret = EXPORT_PATH.'/'; - - if( getArrayValue($params, 'as_url') ) - { - $ret = str_replace( FULL_PATH.'/', $this->Application->BaseURL(), $ret); - } - - $export_options = unserialize($this->Application->RecallVar($this->getPrefixSpecial().'_options')); - $ret .= $export_options['ExportFilename'].'.'.($export_options['ExportFormat'] == 1 ? 'csv' : 'xml'); - - return $ret; - } - function CategoryPath($params) { if (!isset($params['cat_id'])) { Index: trunk/core/units/admin/admin_tag_processor.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 6093) +++ trunk/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 6583) @@ -319,7 +319,7 @@ ksort($section_data['children'], SORT_NUMERIC); foreach ($section_data['children'] as $priority => $section_name) { if (!$this->Application->CheckPermission($section_name.'.view', 1)) continue; - + $tab_data =& $sections_helper->getSectionData($section_name); $block_params['t'] = $tab_data['url']['t']; $block_params['title'] = $tab_data['label']; @@ -345,7 +345,8 @@ $block_params = Array('name' => $params['render_as']); foreach ($this->Application->ModuleInfo as $module_name => $module_info) { $prefix = $module_info['Var']; - if (in_array($prefix, $skip_prefixes)) continue; + + if (in_array($prefix, $skip_prefixes) || !$this->Application->getUnitOption($prefix, 'CatalogItem')) continue; if ($prefix == 'm' && $replace_main) $prefix = 'c'; $label = $this->Application->getUnitOption($prefix, $params['title_property']); $block_params['title'] = $label; @@ -376,7 +377,7 @@ return $oFCKeditor->CreateHtml(); } - + /** * Allows to construct link for opening any type of catalog item selector * @@ -390,39 +391,102 @@ $mode = $params['mode']; unset($params['mode']); } - + $params['t'] = 'item_selector/item_selector_'.$mode; - + $default_params = Array('no_amp' => 1, 'pass' => 'all,'.$params['prefix']); unset($params['prefix']); - + $pass_through = Array(); if (isset($params['tabs_dependant'])) { // {yes, no} $pass_through['td'] = $params['tabs_dependant']; unset($params['tabs_dependant']); } - + if (isset($params['selection_mode'])) { // {single, multi} $pass_through['tm'] = $params['selection_mode']; unset($params['selection_mode']); } - + if (isset($params['tab_prefixes'])) { // {all, none, Application->ProcessParsedTag('m', 't', $params); } + + function TimeFrame($params) + { + $w = adodb_date('w'); + $m = adodb_date('m'); + $y = adodb_date('Y'); + //FirstDayOfWeek is 0 for Sunday and 1 for Monday + $fdow = $this->Application->ConfigValue('FirstDayOfWeek'); + if ($fdow && $w == 0) $w = 7; + $today_start = adodb_mktime(0,0,0,adodb_date('m'),adodb_date('d'),$y); + $first_day_of_this_week = $today_start - ($w - $fdow)*86400; + $first_day_of_this_month = adodb_mktime(0,0,0,$m,1,$y); + $this_quater = ceil($m/3); + $this_quater_start = adodb_mktime(0,0,0,$this_quater*3-2,1,$y); + + switch ($params['type']) { + case 'last_week_start': + $timestamp = $first_day_of_this_week - 86400*7; + break; + case 'last_week_end': + $timestamp = $first_day_of_this_week - 1; + break; + + case 'last_month_start': + $timestamp = $m == 1 ? adodb_mktime(0,0,0,12,1,$y-1) : adodb_mktime(0,0,0,$m-1,1,$y); + break; + case 'last_month_end': + $timestamp = $first_day_of_this_month = adodb_mktime(0,0,0,$m,1,$y) - 1; + break; + + case 'last_quater_start': + $timestamp = $this_quater == 1 ? adodb_mktime(0,0,0,10,1,$y-1) : adodb_mktime(0,0,0,($this_quater-1)*3-2,1,$y); + break; + case 'last_quater_end': + $timestamp = $this_quater_start - 1; + break; + + case 'last_6_months_start': + $timestamp = $m <= 6 ? adodb_mktime(0,0,0,$m+6,1,$y-1) : adodb_mktime(0,0,0,$m-6,1,$y); + break; + + case 'last_year_start': + $timestamp = adodb_mktime(0,0,0,1,1,$y-1); + break; + case 'last_year_end': + $timestamp = adodb_mktime(23,59,59,12,31,$y-1); + break; + } + + + if (isset($params['format'])) { + $format = $params['format']; + if(preg_match("/_regional_(.*)/", $format, $regs)) + { + $lang =& $this->Application->recallObject('lang.current'); + $format = $lang->GetDBField($regs[1]); + } + return adodb_date($format, $timestamp); + } + + return $timestamp; + + } } ?> \ No newline at end of file Index: trunk/kernel/include/category.php =================================================================== diff -u -N -r6093 -r6583 --- trunk/kernel/include/category.php (.../category.php) (revision 6093) +++ trunk/kernel/include/category.php (.../category.php) (revision 6583) @@ -691,17 +691,11 @@ function UpdateACL() { - global $objGroups, $objPermCache; - - $glist = $objGroups->GetAllGroupList(); - - $ViewList = $this->Permissions->GetGroupPermList($this,"CATEGORY.VIEW",$glist); - $perms = $this->Permissions->GetAllViewPermGroups($this,$glist); - //echo "
";print_r($perms); echo "
"; - foreach($perms as $PermName => $l) - { - $this->SetViewPerms($PermName,$l,$glist); - } + $q = 'INSERT INTO '.TABLE_PREFIX.'PermCache (CategoryId, PermId, ACL, DACL) + SELECT '.$this->UniqueId().', PermId, ACL, DACL + FROM '.TABLE_PREFIX.'PermCache + WHERE CategoryId = '.$this->Get('ParentId'); + $this->Conn->Query($q); } function Cat_Link()