Page MenuHomeIn-Portal Phabricator

in-portal
No OneTemporary

File Metadata

Created
Mon, Jun 16, 12:03 AM

in-portal

Index: branches/unlabeled/unlabeled-1.25.2/admin/help/manual.pdf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/unlabeled/unlabeled-1.25.2/admin/help/manual.pdf
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.25
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.25.2/admin/index.php
===================================================================
--- branches/unlabeled/unlabeled-1.25.2/admin/index.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.25.2/admin/index.php (revision 6649)
@@ -0,0 +1,39 @@
+<?php
+
+$start = getmicrotime();
+
+define('ADMIN', 1);
+define('FULL_PATH', realpath(dirname(__FILE__).'/..') );
+include_once(FULL_PATH.'/core/kernel/startup.php');
+
+/*
+ kApplication $application
+*/
+$application =& kApplication::Instance();
+$application->Init();
+$application->Run();
+$application->Done();
+
+$end = getmicrotime();
+
+function getmicrotime()
+{
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+}
+
+//update_memory_check_script();
+
+function update_memory_check_script() {
+ $files = get_included_files();
+ $script = '$files = Array('."\n";
+ foreach ($files as $file_name) {
+ $script .= "\t\t'".str_replace(FULL_PATH, '', $file_name)."',\n";
+ }
+ $script .= ");\n";
+ echo "<pre>";
+ echo $script;
+ echo "</pre>";
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.25.2/admin/index.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.25
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.25.2/core/units/categories/categories_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.25.2/core/units/categories/categories_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.25.2/core/units/categories/categories_event_handler.php (revision 6649)
@@ -0,0 +1,504 @@
+<?php
+
+class CategoriesEventHandler extends kDBEventHandler {
+
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnRebuildCache' => Array('self' => 'add|edit'),
+// 'OnSave' => Array('self' => 'add|edit')
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Checks permissions of user
+ *
+ * @param kEvent $event
+ */
+ function CheckPermission(&$event)
+ {
+ if (!$this->Application->IsAdmin()) {
+ if ($event->Name == 'OnSetSortingDirect') {
+ // allow sorting on front event without view permission
+ return true;
+ }
+ }
+
+ if ($event->Name == 'OnEdit' || $event->Name == 'OnSave') {
+ // check each id from selected individually and only if all are allowed proceed next
+ if ($event->Name == 'OnEdit') {
+ $selected_ids = implode(',', $this->StoreSelectedIDs($event));
+ }
+ else {
+ $selected_ids = $this->Application->RecallVar($event->getPrefixSpecial().'_selected_ids');
+ }
+
+ $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $sql = 'SELECT '.$id_field.', CreatedById
+ FROM '.$table_name.' item_table
+ WHERE '.$id_field.' IN ('.$selected_ids.')';
+ $items = $this->Conn->Query($sql, $id_field);
+
+ $perm_value = true;
+ $perm_helper =& $this->Application->recallObject('PermissionsHelper');
+ foreach ($items as $item_id => $item_data) {
+ if ($perm_helper->ModifyCheckPermission($item_data['CreatedById'], $item_data[$id_field], $event->Prefix) == 0) {
+ // one of items selected has no permission
+ $perm_value = false;
+ break;
+ }
+ }
+
+ if (!$perm_value) {
+ $event->status = erPERM_FAIL;
+ }
+
+ return $perm_value;
+ }
+
+ return parent::CheckPermission($event);
+ }
+
+ /**
+ * Apply system filter to categories list
+ *
+ * @param kEvent $event
+ */
+ function SetCustomQuery(&$event)
+ {
+ parent::SetCustomQuery($event);
+
+ $types=$event->getEventParam('types');
+ $except_types=$event->getEventParam('except');
+ $object =& $event->getObject();
+ $type_clauses = Array();
+
+ $object =& $event->getObject();
+
+ if ( $event->getEventParam('parent_cat_id') ) {
+ $parent_cat_id = $event->getEventParam('parent_cat_id');
+
+ if ($parent_cat_id == 'Root') {
+ $module_name = $event->getEventParam('module') ? $event->getEventParam('module') : 'In-Commerce';
+ $module =& $this->Application->recallObject('mod.'.$module_name);
+ $parent_cat_id = $module->GetDBField('RootCat');
+ }
+
+ }
+ else {
+ $parent_cat_id = $this->Application->GetVar('c_id');
+ if (!$parent_cat_id) {
+ $parent_cat_id = $this->Application->GetVar('m_cat_id');
+ }
+ if (!$parent_cat_id) {
+ $parent_cat_id = 0;
+ }
+ }
+
+ if ("$parent_cat_id" != 'any') {
+ if ($event->getEventParam('recursive')) {
+ $current_path = $this->Conn->GetOne('SELECT ParentPath FROM '.TABLE_PREFIX.'Category WHERE CategoryId='.$parent_cat_id);
+ $subcats = $this->Conn->GetCol('SELECT CategoryId FROM '.TABLE_PREFIX.'Category WHERE ParentPath LIKE "'.$current_path.'%" ');
+ $object->addFilter('parent_filter', 'ParentId IN ('.implode(', ', $subcats).')');
+ }
+ else {
+ $object->addFilter('parent_filter', 'ParentId = '.$parent_cat_id);
+ }
+ }
+
+ $object->addFilter('perm_filter', 'PermId = 1'); // check for CATEGORY.VIEW permission
+ if ($this->Application->GetVar('u_id') != -1) {
+ // apply permission filters to all users except "root"
+ $groups = explode(',',$this->Application->RecallVar('UserGroups'));
+ foreach ($groups as $group) {
+ $view_filters[] = 'FIND_IN_SET('.$group.', acl)';
+ }
+ $view_filter = implode(' OR ', $view_filters);
+ $object->addFilter('perm_filter2', $view_filter);
+ }
+
+ if (!$this->Application->IsAdmin()) {
+ // apply status filter only on front
+ $object->addFilter('status_filter', $object->TableName.'.Status = 1');
+ }
+
+ if(strpos($types, 'category_related') !== false)
+ {
+ $object->removeFilter('parent_filter');
+ $resource_id = $this->Conn->GetOne('
+ SELECT ResourceId FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
+ WHERE CategoryId = '.$parent_cat_id
+ );
+
+ $sql = 'SELECT DISTINCT(TargetId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE SourceId = '.$resource_id.' AND SourceType = 1';
+ $related_cats = $this->Conn->GetCol($sql);
+ $related_cats = is_array($related_cats) ? $related_cats : Array();
+ $sql = 'SELECT DISTINCT(SourceId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE TargetId = '.$resource_id.' AND TargetType = 1 AND Type = 1';
+ $related_cats2 = $this->Conn->GetCol($sql);
+ $related_cats2 = is_array($related_cats2) ? $related_cats2 : Array();
+ $related_cats = array_unique( array_merge( $related_cats2, $related_cats ) );
+
+ if($related_cats)
+ {
+ $type_clauses['category_related']['include'] = '%1$s.ResourceId IN ('.implode(',', $related_cats).')';
+ $type_clauses['category_related']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $related_cats).')';
+ }
+ else
+ {
+ $type_clauses['category_related']['include'] = '0';
+ $type_clauses['category_related']['except'] = '1';
+ }
+ $type_clauses['category_related']['having_filter'] = false;
+ }
+
+ if(strpos($types, 'product_related') !== false)
+ {
+ $object->removeFilter('parent_filter');
+
+ $product_id = $event->getEventParam('product_id') ? $event->getEventParam('product_id') : $this->Application->GetVar('p_id');
+ $resource_id = $this->Conn->GetOne('
+ SELECT ResourceId FROM '.$this->Application->getUnitOption('p', 'TableName').'
+ WHERE ProductId = '.$product_id
+ );
+
+ $sql = 'SELECT DISTINCT(TargetId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE SourceId = '.$resource_id.' AND TargetType = 1';
+ $related_cats = $this->Conn->GetCol($sql);
+ $related_cats = is_array($related_cats) ? $related_cats : Array();
+ $sql = 'SELECT DISTINCT(SourceId) FROM '.TABLE_PREFIX.'Relationship
+ WHERE TargetId = '.$resource_id.' AND SourceType = 1 AND Type = 1';
+ $related_cats2 = $this->Conn->GetCol($sql);
+ $related_cats2 = is_array($related_cats2) ? $related_cats2 : Array();
+ $related_cats = array_unique( array_merge( $related_cats2, $related_cats ) );
+
+ if($related_cats)
+ {
+ $type_clauses['product_related']['include'] = '%1$s.ResourceId IN ('.implode(',', $related_cats).')';
+ $type_clauses['product_related']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $related_cats).')';
+ }
+ else
+ {
+ $type_clauses['product_related']['include'] = '0';
+ $type_clauses['product_related']['except'] = '1';
+ }
+ $type_clauses['product_related']['having_filter'] = false;
+ }
+
+ /********************************************/
+
+ $includes_or_filter =& $this->Application->makeClass('kMultipleFilter');
+ $includes_or_filter->setType(FLT_TYPE_OR);
+
+ $excepts_and_filter =& $this->Application->makeClass('kMultipleFilter');
+ $excepts_and_filter->setType(FLT_TYPE_AND);
+
+ $includes_or_filter_h =& $this->Application->makeClass('kMultipleFilter');
+ $includes_or_filter_h->setType(FLT_TYPE_OR);
+
+ $excepts_and_filter_h =& $this->Application->makeClass('kMultipleFilter');
+ $excepts_and_filter_h->setType(FLT_TYPE_AND);
+
+ $except_types_array=explode(',', $types);
+
+ if ($types){
+ $types_array=explode(',', $types);
+ for ($i=0; $i<sizeof($types_array); $i++){
+ $type=trim($types_array[$i]);
+ if (isset($type_clauses[$type])){
+ if ($type_clauses[$type]['having_filter']){
+ $includes_or_filter_h->removeFilter('filter_'.$type);
+ $includes_or_filter_h->addFilter('filter_'.$type, $type_clauses[$type]['include']);
+ }else{
+ $includes_or_filter->removeFilter('filter_'.$type);
+ $includes_or_filter->addFilter('filter_'.$type, $type_clauses[$type]['include']);
+ }
+ }
+ }
+ }
+
+ if ($except_types){
+ $except_types_array=explode(',', $except_types);
+ for ($i=0; $i<sizeof($except_types_array); $i++){
+ $type=trim($except_types_array[$i]);
+ if (isset($type_clauses[$type])){
+ if ($type_clauses[$type]['having_filter']){
+ $excepts_and_filter_h->removeFilter('filter_'.$type);
+ $excepts_and_filter_h->addFilter('filter_'.$type, $type_clauses[$type]['except']);
+ }else{
+ $excepts_and_filter->removeFilter('filter_'.$type);
+ $excepts_and_filter->addFilter('filter_'.$type, $type_clauses[$type]['except']);
+ }
+ }
+ }
+ }
+
+ $object->addFilter('includes_filter', $includes_or_filter);
+ $object->addFilter('excepts_filter', $excepts_and_filter);
+
+ $object->addFilter('includes_filter_h', $includes_or_filter_h, HAVING_FILTER);
+ $object->addFilter('excepts_filter_h', $excepts_and_filter_h, HAVING_FILTER);
+ }
+
+ function GetPassedId(&$event)
+ {
+ if ( $this->Application->IsAdmin() ) {
+ return parent::getPassedID($event);
+ }
+
+ return $this->Application->GetVar('m_cat_id');
+ }
+
+ /**
+ * Adds calculates fields for item statuses
+ *
+ * @param kCatDBItem $object
+ * @param kEvent $event
+ */
+ function prepareObject(&$object, &$event)
+ {
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $object->addCalculatedField('IsNew', ' IF(%1$s.NewItem = 2,
+ IF(%1$s.CreatedOn >= (UNIX_TIMESTAMP() - '.
+ $this->Application->ConfigValue('Category_DaysNew').
+ '*3600*24), 1, 0),
+ %1$s.NewItem
+ )');
+ }
+
+ /**
+ * Set correct parent path for newly created categories
+ *
+ * @param kEvent $event
+ */
+ function OnAfterCopyToLive(&$event)
+ {
+ if ($event->getEventParam('temp_id') == 0) {
+ $object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('skip_autoload' => true, 'live_table' => true));
+ $object->Load($event->getEventParam('id'));
+ if ($object->isLoaded()) {
+ // update path only for real categories (not including "Home" root category)
+ $fields_hash = Array('ParentPath' => $object->buildParentPath());
+ $this->Conn->doUpdate($fields_hash, $object->TableName, 'CategoryId = '.$object->GetID());
+ }
+ }
+ }
+
+ /**
+ * Set cache modification mark if needed
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeDeleteFromLive(&$event)
+ {
+ $id = $event->getEventParam('id');
+
+ // loding anyway, because this object is needed by "c-perm:OnBeforeDeleteFromLive" event
+ $temp_object =& $event->getObject( Array('skip_autoload' => true) );
+ $temp_object->Load($id);
+
+ if ($id == 0) {
+ if ($temp_object->isLoaded()) {
+ // new category -> update chache (not loaded when "Home" category)
+ $this->Application->StoreVar('PermCache_UpdateRequired', 1);
+ }
+ return ;
+ }
+
+ // existing category was edited, check if in-cache fields are modified
+ $live_object =& $this->Application->recallObject($event->Prefix.'.-item', null, Array('live_table' => true, 'skip_autoload' => true));
+ $live_object->Load($id);
+
+ $cached_fields = Array('Name', 'Filename', 'CategoryTemplate');
+
+ foreach ($cached_fields as $cached_field) {
+ if ($live_object->GetDBField($cached_field) != $temp_object->GetDBField($cached_field)) {
+ // use session instead of REQUEST because of permission editing in category can contain
+ // multiple submits, that changes data before OnSave event occurs
+ $this->Application->StoreVar('PermCache_UpdateRequired', 1);
+ break;
+ }
+ }
+ }
+
+ /**
+ * Checks cache update mark and redirect to cache if needed
+ *
+ * @param kEvent $event
+ */
+ function OnSave(&$event)
+ {
+ $object =& $event->getObject();
+ if ($object->IsRoot()) {
+ $event->setEventParam('master_ids', Array(0));
+ }
+
+ parent::OnSave($event);
+ if ($event->status == erSUCCESS && $this->Application->RecallVar('PermCache_UpdateRequired')) {
+ // "catalog" should be in opener stack by now
+ $opener_stack = unserialize($this->Application->RecallVar('opener_stack'));
+ $opener_stack[0] = str_replace('catalog', 'categories/cache_updater', $opener_stack[0]);
+ $this->Application->StoreVar('opener_stack', serialize($opener_stack));
+ $this->Application->RemoveVar('PermCache_UpdateRequired');
+ }
+ }
+
+ /**
+ * Deletes all selected items.
+ * Automatically recurse into sub-items using temp handler, and deletes sub-items
+ * by calling its Delete method if sub-item has AutoDelete set to true in its config file
+ *
+ * @param kEvent $event
+ */
+ function OnMassDelete(&$event)
+ {
+ if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
+ return;
+ }
+
+// $event->status = erSUCCESS;
+
+ $ids = $this->StoreSelectedIDs($event);
+ if ($ids) {
+ $recursive_helper =& $this->Application->recallObject('RecursiveHelper');
+ foreach ($ids as $id) {
+ $recursive_helper->DeleteCategory($id);
+ }
+ }
+ $this->clearSelectedIDs($event);
+ }
+
+ /**
+ * Add selected items to clipboard with mode = COPY (CLONE)
+ *
+ * @param kEvent $event
+ */
+ function OnCopy(&$event)
+ {
+ $this->Application->RemoveVar('clipboard');
+ $clipboard_helper =& $this->Application->recallObject('ClipboardHelper');
+ $clipboard_helper->setClipboard($event, 'copy', $this->StoreSelectedIDs($event));
+ }
+
+ /**
+ * Add selected items to clipboard with mode = CUT
+ *
+ * @param kEvent $event
+ */
+ function OnCut(&$event)
+ {
+ $this->Application->RemoveVar('clipboard');
+ $clipboard_helper =& $this->Application->recallObject('ClipboardHelper');
+ $clipboard_helper->setClipboard($event, 'cut', $this->StoreSelectedIDs($event));
+ }
+
+ /**
+ * Controls all item paste operations. Can occur only with filled clipbord.
+ *
+ * @param kEvent $event
+ */
+ function OnPasteClipboard(&$event)
+ {
+ $clipboard = unserialize( $this->Application->RecallVar('clipboard') );
+ foreach ($clipboard as $prefix => $clipboard_data) {
+ $paste_event = new kEvent($prefix.':OnPaste', Array('clipboard_data' => $clipboard_data));
+ $this->Application->HandleEvent($paste_event);
+
+ $event->redirect = $paste_event->redirect;
+ $event->redirect_params = $paste_event->redirect_params;
+ $event->status = $paste_event->status;
+ }
+ }
+
+ /**
+ * Paste categories with subitems from clipboard
+ *
+ * @param kEvent $event
+ */
+ function OnPaste(&$event)
+ {
+ if ($this->Application->CheckPermission('SYSTEM_ACCESS.READONLY', 1)) {
+ return;
+ }
+
+ $clipboard_data = $event->getEventParam('clipboard_data');
+
+ if (!$clipboard_data['cut'] && !$clipboard_data['copy']) {
+ return false;
+ }
+
+ $recursive_helper =& $this->Application->recallObject('RecursiveHelper');
+ if ($clipboard_data['cut']) {
+ $recursive_helper->MoveCategories($clipboard_data['cut'], $this->Application->GetVar('m_cat_id'));
+ }
+
+ if ($clipboard_data['copy']) {
+ foreach ($clipboard_data['copy'] as $id) {
+ $recursive_helper->PasteCategory($id);
+ }
+ }
+
+ if ($clipboard_data['cut'] || $clipboard_data['copy']) {
+ $event->redirect = 'categories/cache_updater';
+ }
+ }
+
+ /**
+ * Occurs when pasting category
+ *
+ * @param kEvent $event
+ */
+ /*function OnCatPaste(&$event)
+ {
+ $inp_clipboard = $this->Application->RecallVar('ClipBoard');
+ $inp_clipboard = explode('-', $inp_clipboard, 2);
+
+ if($inp_clipboard[0] == 'COPY')
+ {
+ $saved_cat_id = $this->Application->GetVar('m_cat_id');
+ $cat_ids = $event->getEventParam('cat_ids');
+
+ $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField');
+ $table = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $ids_sql = 'SELECT '.$id_field.' FROM '.$table.' WHERE ResourceId IN (%s)';
+ $resource_ids_sql = 'SELECT ItemResourceId FROM '.TABLE_PREFIX.'CategoryItems WHERE CategoryId = %s AND PrimaryCat = 1';
+
+ $object =& $this->Application->recallObject($event->Prefix.'.item', $event->Prefix, Array('skip_autoload' => true));
+
+ foreach($cat_ids as $source_cat => $dest_cat)
+ {
+ $item_resource_ids = $this->Conn->GetCol( sprintf($resource_ids_sql, $source_cat) );
+ if(!$item_resource_ids) continue;
+
+ $this->Application->SetVar('m_cat_id', $dest_cat);
+ $item_ids = $this->Conn->GetCol( sprintf($ids_sql, implode(',', $item_resource_ids) ) );
+
+ $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
+ if($item_ids) $temp->CloneItems($event->Prefix, $event->Special, $item_ids);
+ }
+
+ $this->Application->SetVar('m_cat_id', $saved_cat_id);
+ }
+ }*/
+
+ /**
+ * Cleares clipboard content
+ *
+ * @param kEvent $event
+ */
+ function OnClearClipboard(&$event)
+ {
+ $this->Application->RemoveVar('clipboard');
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.25.2/core/units/categories/categories_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.25
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property

Event Timeline