Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1044106
in-portal
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Jun 24, 11:27 PM
Size
71 KB
Mime Type
text/x-diff
Expires
Thu, Jun 26, 11:27 PM (7 h, 53 m)
Engine
blob
Format
Raw Data
Handle
675291
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/unlabeled/unlabeled-1.7.2/kernel/units/relationship/relationship_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/kernel/units/relationship/relationship_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.7.2/kernel/units/relationship/relationship_event_handler.php (revision 6142)
@@ -0,0 +1,261 @@
+<?php
+
+ class RelationshipEventHandler extends InpDBEventHandler
+ {
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnProcessSelected' => Array('subitem' => 'add|edit'),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Initializes new relation
+ *
+ * @param kEvent $event
+ */
+ function OnNew(&$event)
+ {
+ parent::OnNew(&$event);
+
+ $object =& $event->getObject();
+ $table_info = $object->getLinkedInfo();
+
+ $object->SetDBField('SourceId', $table_info['ParentId']);
+ $source_itemtype = $this->Application->getUnitOption($table_info['ParentPrefix'], 'ItemType');
+ $object->SetDBField('SourceType', $source_itemtype);
+
+ $object->SetDBField('TargetId', $this->Application->GetVar('target_id'));
+ $object->SetDBField('TargetType', $this->Application->GetVar('target_type'));
+
+ $this->OnAfterItemLoad($event);
+ }
+
+ /**
+ * Add new relation
+ *
+ * @param kEvent $event
+ */
+ function OnProcessSelected(&$event)
+ {
+ $dst_field = $this->Application->RecallVar('dst_field');
+ if ($dst_field == 'TargetId') {
+ // prepare target_id & target_type
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $selected_ids = $this->Application->GetVar('selected_ids');
+ $target_prefix = false;
+ foreach ($selected_ids as $selected_prefix => $target_id) {
+ if ($target_id > 0) {
+ $target_prefix = $selected_prefix;
+ break;
+ }
+ }
+
+ if (!$target_prefix) {
+ $this->finalizePopup($event);
+ return;
+ }
+
+ $sql = 'SELECT ResourceId
+ FROM '.$this->Application->getUnitOption($target_prefix, 'TableName').'
+ WHERE '.$this->Application->getUnitOption($target_prefix, 'IDField').' = '.$target_id;
+ $target_id = $this->Conn->GetOne($sql);
+ $target_type = $this->Application->getUnitOption($target_prefix, 'ItemType');
+
+ // don't add same relation twice
+ $table_info = $object->getLinkedInfo();
+ $sql = 'SELECT TargetId
+ FROM '.$object->TableName.'
+ WHERE (SourceId = '.$table_info['ParentId'].') AND (TargetId = '.$target_id.')';
+ $duplicate_relation = $this->Conn->GetOne($sql) == $target_id;
+
+ $this->finalizePopup($event);
+
+ if (!$duplicate_relation) {
+ // place correct template in opener stack
+ $source_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $template = $this->Application->getUnitOption($source_prefix, 'AdminTemplatePath').'/relations_edit';
+ $redirect_params = Array($event->Prefix.'_event' => 'OnNew', 'target_id' => $target_id, 'target_type' => $target_type);
+ $this->Application->EventManager->openerStackPush($template, $redirect_params, 'all,'.$event->Prefix);
+ }
+ }
+ else {
+ $this->finalizePopup($event);
+ }
+ }
+
+ /**
+ * Set ItemName & ItemType virtual fields based on loaded item data
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemLoad(&$event)
+ {
+ $object =& $event->getObject();
+
+ $sql = 'SELECT Prefix
+ FROM '.TABLE_PREFIX.'ItemTypes
+ WHERE ItemType = '.$object->GetDBField('TargetType');
+ $target_prefix = $this->Conn->GetOne($sql);
+
+ $title_field = $this->getTitleField($target_prefix);
+ $title_phrase = $this->Application->getUnitOption($target_prefix, 'TitlePhrase');
+
+ $sql = 'SELECT '.$title_field.'
+ FROM '.$this->Application->getUnitOption($target_prefix, 'TableName').'
+ WHERE ResourceId = '.$object->GetDBField('TargetId');
+
+ $object->SetDBField('ItemName', $this->Conn->GetOne($sql));
+ $object->SetDBField('ItemType', $this->Application->Phrase($title_phrase));
+ }
+
+ /**
+ * Creates needed sql query to load list,
+ * if no query is defined in config for
+ * special requested, then use default
+ * query
+ *
+ * @param kEvent $event
+ * @access protected
+ */
+ function ListPrepareQuery(&$event)
+ {
+ return $this->BaseQuery($event, 'ListSQLs');
+ }
+
+ /**
+ * Creates needed sql query to load item,
+ * if no query is defined in config for
+ * special requested, then use default
+ * query
+ *
+ * @param kEvent $event
+ * @access protected
+ */
+ function ItemPrepareQuery(&$event)
+ {
+ return $this->BaseQuery($event, 'ItemSQLs');
+ }
+
+
+ /**
+ * Get item name & type based on relation type & modules installed
+ *
+ * @param kEvent $event
+ * @param string $sql_field
+ */
+ function BaseQuery(&$event, $sql_field)
+ {
+ $sqls = $this->Application->getUnitOption($event->Prefix,$sql_field);
+ $sql = isset($sqls[$event->Special]) ? $sqls[$event->Special] : $sqls[''];
+
+ $configs = $this->extractModulesInfo();
+
+ // 2. build sql based on information queried
+ $sql_templates['ItemName'] = 'IFNULL(%s.%s,\' \')';
+ $sql_templates['TableJoin'] = 'LEFT JOIN %1$s ON %1$s.ResourceId = rel.TargetId';
+ $sql_templates['TargetName'] = 'IF(rel.TargetType = %s, \'%s\', %s)';
+
+ $sql_parts = Array();
+ $sql_parts['TargetName'] = "''";
+ foreach ($configs as $prefix => $config_data) {
+ $title_field = $this->getTitleField($prefix);
+
+ $sql_parts['ItemName'][] = sprintf($sql_templates['ItemName'], $config_data['TableName'], $title_field);
+ $sql_parts['TableJoin'][] = sprintf($sql_templates['TableJoin'], $config_data['TableName']);
+
+ $sql_parts['TargetName'] = sprintf( $sql_templates['TargetName'],
+ $config_data['ItemType'],
+ '!'.$config_data['TitlePhrase'].'!',
+ $sql_parts['TargetName']);
+ $sql_parts['TargetName'] = str_replace('rel','%1$s',$sql_parts['TargetName']);
+ }
+
+ $object =& $event->getObject();
+
+ $vars = Array('#ITEM_NAMES#', '#ITEM_TYPES#');
+ $replacements = Array( implode(', ',$sql_parts['ItemName']), $sql_parts['TargetName'] );
+
+ $calculated_fields =& $object->getProperty('CalculatedFields');
+ foreach ($calculated_fields as $field_name => $field_expression) {
+ $calculated_fields[$field_name] = str_replace($vars, $replacements, $field_expression);
+ }
+
+ $object->setProperty('CalculatedFields', $calculated_fields);
+
+ $sql = str_replace('#ITEM_JOIN#', implode(' ',$sql_parts['TableJoin']), $sql);
+ $sql = str_replace('rel.','%1$s.',$sql);
+
+ return $sql;
+ }
+
+ /**
+ * Convert TitleField field of kMultiLanguage formatter used for it
+ *
+ * @param string $prefix
+ * @return string
+ */
+ function getTitleField($prefix)
+ {
+ $lang_prefix = 'l'.$this->Application->GetVar('m_lang').'_';
+
+ $title_field = $this->Application->getUnitOption($prefix, 'TitleField');
+ $field_options = $this->Application->getUnitOption($prefix.'.'.$title_field, 'Fields');
+
+ $formatter_class = isset($field_options['formatter']) ? $field_options['formatter'] : '';
+ if ($formatter_class == 'kMultiLanguage' && !isset($field_options['master_field'])) {
+ $title_field = $lang_prefix.$title_field;
+ }
+ return $title_field;
+ }
+
+ /**
+ * Get configs from modules installed
+ *
+ * @return Array
+ * @access private
+ */
+ function extractModulesInfo()
+ {
+ // get installed modules & their config info
+ // maybe we should leave only prefixes, that have "view" permission
+ $configs = Array();
+ foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
+ $prefix = $module_data['Var'];
+ if ($prefix == 'm') {
+ $prefix = 'c';
+ }
+ $configs[$prefix] = $this->Application->getUnitOptions($prefix);
+ if($configs[$prefix] === false) unset($configs[$prefix]);
+ if(!isset($configs[$prefix]['CatalogItem']) || !$configs[$prefix]['CatalogItem']) unset($configs[$prefix]);
+ }
+ return $configs;
+ }
+
+ /**
+ * Deletes relations to hooked item from other items
+ *
+ * @param kEvent $event
+ */
+ function OnDeleteForeignRelations(&$event)
+ {
+ $main_object =& $event->MasterEvent->getObject();
+ $resource_id = $main_object->GetDBField('ResourceId');
+
+ $table = $this->Application->getUnitOption($event->Prefix,'TableName');
+ $sql = 'DELETE FROM '.$table.' WHERE TargetId = '.$resource_id;
+ $this->Conn->Query($sql);
+ }
+
+
+ }
+
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.7.2/kernel/units/relationship/relationship_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.7
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.7.2/kernel/units/categories/cache_updater.php
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/kernel/units/categories/cache_updater.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.7.2/kernel/units/categories/cache_updater.php (revision 6142)
@@ -0,0 +1,371 @@
+<?php
+class clsRecursionStack
+{
+ var $Stack;
+
+ function clsRecursionStack()
+ {
+ $this->Stack = Array();
+ }
+
+ function Push($values)
+ {
+ array_push($this->Stack, $values);
+ }
+
+ function Pop()
+ {
+ if ($this->Count() > 0) {
+ return array_pop($this->Stack);
+ }
+ else {
+ return false;
+ }
+ }
+
+ function Get()
+ {
+ if ($this->Count() > 0) {
+// return end($this->Stack);
+ return $this->Stack[count($this->Stack)-1];
+ }
+ else {
+ return false;
+ }
+ }
+
+ function Update($values)
+ {
+ $this->Stack[count($this->Stack)-1] = $values;
+ }
+
+ function Count()
+ {
+ return count($this->Stack);
+ }
+}
+
+
+class clsCachedPermissions
+{
+ var $Allow = Array();
+ var $Deny = Array();
+ var $CatId;
+
+ function clsCachedPermissions($CatId)
+ {
+ $this->CatId = $CatId;
+ }
+
+ function SetCatId($CatId)
+ {
+ $this->CatId = $CatId;
+ }
+
+ function CheckPermArray($Perm)
+ {
+ if (!isset($this->Allow[$Perm])) {
+ $this->Allow[$Perm] = array();
+ $this->Deny[$Perm] = array();
+ }
+ }
+
+ function AddAllow($Perm, $GroupId)
+ {
+ $this->CheckPermArray($Perm);
+ if (!in_array($GroupId, $this->Allow[$Perm])) {
+ array_push($this->Allow[$Perm], $GroupId);
+ $this->RemoveDeny($Perm, $GroupId);
+ }
+ }
+
+ function AddDeny($Perm, $GroupId)
+ {
+ $this->CheckPermArray($Perm);
+ if (!in_array($GroupId, $this->Deny[$Perm])) {
+ array_push($this->Deny[$Perm], $GroupId);
+ $this->RemoveAllow($Perm, $GroupId);
+ }
+ }
+
+ function RemoveDeny($Perm, $GroupId)
+ {
+ if (in_array($GroupId, $this->Deny[$Perm])) {
+ array_splice($this->Deny[$Perm], array_search($GroupId, $this->Deny[$Perm]), 1);
+ }
+ }
+
+ function RemoveAllow($Perm, $GroupId)
+ {
+ if (in_array($GroupId, $this->Allow[$Perm])) {
+ array_splice($this->Allow[$Perm], array_search($GroupId, $this->Allow[$Perm]), 1);
+ }
+ }
+
+ function GetInsertSQL()
+ {
+ $values = array();
+
+ $has_deny = array();
+
+ // don't write DACL at all
+ /*foreach ($this->Deny as $perm => $groups) {
+ if (count($groups) > 0) {
+ $values[] = '('.$this->CatId.', '.$perm.', "", "'.join(',', $groups).'")';
+ $has_deny[] = $perm;
+ }
+ }*/
+
+ foreach ($this->Allow as $perm => $groups) {
+// if (in_array($perm, $has_deny)) continue;
+ if (count($groups) > 0) {
+ $values[] = '(' .$this->CatId. ', ' .$perm. ', "' .join(',', $groups). '", "")';
+ }
+ }
+ if (!$values) return '';
+ $sql = 'INSERT INTO '.TABLE_PREFIX.'PermCache (CategoryId, PermId, ACL, DACL) VALUES '.join(',', $values);
+ return $sql;
+ }
+}
+
+class kPermCacheUpdater extends kHelper
+{
+ var $Stack;
+ var $iteration;
+ var $totalCats;
+ var $doneCats;
+ var $table;
+
+ var $primaryLanguageId = 0;
+ var $languageCount = 0;
+ var $root_prefixes = Array();
+
+ function Init($prefix, $special, $event_params = null)
+ {
+ parent::Init($prefix, $special, $event_params);
+
+ $continuing = $event_params['continue'];
+
+ // cache widely used values to speed up process: begin
+ $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
+ $this->languageCount = $ml_helper->getLanguageCount();
+ $this->primaryLanguageId = $this->Application->GetDefaultLanguageId();
+ // cache widely used values to speed up process: end
+
+ foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
+ $this->root_prefixes[ $module_info['RootCat'] ] = $module_info['Var'];
+ }
+
+ $this->iteration = 0;
+ $this->table = $this->Application->GetTempName('permCacheUpdate');
+
+ if ($continuing == 1) {
+ $this->InitUpdater();
+ }
+ elseif ($continuing == 2) {
+ $this->getData();
+ }
+ }
+
+ function InitUpdater()
+ {
+ $this->Stack =& new clsRecursionStack();
+ $sql = 'DELETE FROM '.TABLE_PREFIX.'PermCache';
+ $this->Conn->Query($sql);
+ $this->initData();
+ }
+
+ function getDonePercent()
+ {
+ if(!$this->totalCats)return 0;
+ return min(100, intval( round( $this->doneCats / $this->totalCats * 100 ) ));
+ }
+
+ function getData()
+ {
+ $tmp = $this->Conn->GetOne('SELECT data FROM '.$this->table);
+ if ($tmp) $tmp = unserialize($tmp);
+
+ $this->totalCats = isset($tmp['totalCats']) ? $tmp['totalCats'] : 0;
+ $this->doneCats = isset($tmp['doneCats']) ? $tmp['doneCats'] : 0;
+ if (isset($tmp['stack'])) {
+ $this->Stack = $tmp['stack'];
+ }
+ else {
+ $this->Stack = & new clsRecursionStack();
+ }
+ }
+
+ function setData()
+ {
+ $tmp = Array (
+ 'totalCats' => $this->totalCats,
+ 'doneCats' => $this->doneCats,
+ 'stack' => $this->Stack,
+ );
+
+ $this->Conn->Query('DELETE FROM '.$this->table);
+
+ $fields_hash = Array('data' => serialize($tmp));
+ $this->Conn->doInsert($fields_hash, $this->table);
+ }
+
+ function initData()
+ {
+ $this->clearData(); // drop table before starting anyway
+
+ $this->Conn->Query('CREATE TABLE '.$this->table.'(data LONGTEXT)');
+
+ $this->totalCats = (int)$this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Category');
+ $this->doneCats = 0;
+ }
+
+ function clearData()
+ {
+ $this->Conn->Query('DROP TABLE IF EXISTS '.$this->table);
+ }
+
+ function DoTheJob()
+ {
+ $data = $this->Stack->Get();
+ if ($data === false) { //If Stack is empty
+ $data['current_id'] = 0;
+ $data['titles'] = Array();
+ $data['parent_path'] = Array();
+ $data['named_path'] = Array();
+ $data['category_template'] = '';
+ $data['item_template'] = '';
+ $this->Stack->Push($data);
+ }
+
+ if (!isset($data['queried'])) {
+ $this->QueryTitle($data);
+ $this->QueryChildren($data);
+ $this->QueryPermissions($data);
+ $data['queried'] = 1;
+
+ if ($sql = $data['perms']->GetInsertSQL()) {
+ $this->Conn->Query($sql);
+ // $this->doneCats++; // moved to the place where it pops out of the stack by Kostja
+ }
+ $this->iteration++;
+ }
+
+ // start with first child if we haven't started yet
+ if (!isset($data['current_child'])) $data['current_child'] = 0;
+
+ // if we have more children
+ if (isset($data['children'][$data['current_child']])) {
+ $next_data = Array();
+ $next_data['titles'] = $data['titles'];
+ $next_data['parent_path'] = $data['parent_path'];
+ $next_data['named_path'] = $data['named_path'];
+ $next_data['category_template'] = $data['category_template'];
+ $next_data['item_template'] = $data['item_template'];
+ $next_data['current_id'] = $data['children'][ $data['current_child'] ]; //next iteration should process child
+ $next_data['perms'] = $data['perms']; //we should copy our permissions to child - inheritance
+ $next_data['perms']->SetCatId($next_data['current_id']);
+ $data['current_child']++;
+ $this->Stack->Update($data); //we need to update ourself for the iteration after the next (or further) return to next child
+ $this->Stack->Push($next_data); //next iteration should process this child
+ return true;
+ }
+ else {
+ $this->UpdateCachedPath($data);
+ $this->Stack->Pop(); //remove ourself from stack if we have finished all the childs (or there are none)
+ // we are getting here if we finished with current level, so check if it's first level - then bail out.
+
+ $this->doneCats++; // moved by Kostja from above, seems to fix the prob
+ return $this->Stack->Count() > 0;
+ }
+ }
+
+ function UpdateCachedPath(&$data)
+ {
+ $fields_hash = Array (
+ 'ParentPath' => '|'.implode('|', $data['parent_path']).'|',
+ 'NamedParentPath' => implode('/', $data['named_path'] ),
+ 'CachedCategoryTemplate' => $data['category_template'],
+ );
+
+ $i = 1;
+ while ($i <= $this->languageCount) {
+ $fields_hash['l'.$i.'_CachedNavbar'] = implode('&|&', $data['titles'][$i]);
+ $i++;
+ }
+
+ $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$data['current_id']);
+ }
+
+ function QueryTitle(&$data)
+ {
+ $category_id = $data['current_id'];
+ $sql = 'SELECT *
+ FROM '.TABLE_PREFIX.'Category
+ WHERE CategoryId = '.$category_id;
+
+ $record = $this->Conn->GetRow($sql);
+ if ($record) {
+ $i = 1;
+ while ($i <= $this->languageCount) {
+ $data['titles'][$i][] = $record['l'.$i.'_Name'] ? $record['l'.$i.'_Name'] : $record['l'.$this->primaryLanguageId.'_Name'];
+ $i++;
+ }
+
+ $data['parent_path'][] = $category_id;
+ $data['named_path'][] = $record['Filename'];
+
+ // it is one of the modules root category
+ $root_prefix = isset($this->root_prefixes[$category_id]) ? $this->root_prefixes[$category_id] : false;
+ if ($root_prefix) {
+ $fields_hash = Array();
+ if (!$record['CategoryTemplate']) {
+ $record['CategoryTemplate'] = $this->Application->ConfigValue($root_prefix.'_CategoryTemplate');
+ $fields_hash['CategoryTemplate'] = $record['CategoryTemplate'];
+ }
+
+ $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$category_id);
+ }
+
+ // if explicitly set, then use it; use parent template otherwise
+ if ($record['CategoryTemplate']) {
+ $data['category_template'] = $record['CategoryTemplate'];
+ }
+ }
+
+ }
+
+ function QueryChildren(&$data)
+ {
+ $sql = 'SELECT CategoryId
+ FROM '.TABLE_PREFIX.'Category
+ WHERE ParentId = '.$data['current_id'];
+ $data['children'] = $this->Conn->GetCol($sql);
+ }
+
+ function QueryPermissions(&$data)
+ {
+ // don't search for section "view" permissions here :)
+ $sql = 'SELECT ipc.PermissionConfigId, ip.GroupId, ip.PermissionValue
+ FROM '.TABLE_PREFIX.'Permissions AS ip
+ LEFT JOIN '.TABLE_PREFIX.'PermissionConfig AS ipc ON ipc.PermissionName = ip.Permission
+ WHERE (CatId = '.$data['current_id'].') AND (Permission LIKE "%.VIEW") AND (ip.Type = 0)';
+
+ $records = $this->Conn->Query($sql);
+
+ //create permissions array only if we don't have it yet (set by parent)
+ if (!isset($data['perms'])) {
+ $data['perms'] = new clsCachedPermissions($data['current_id']);
+ }
+
+ foreach ($records as $record) {
+ if ($record['PermissionValue'] == 1) {
+ $data['perms']->AddAllow($record['PermissionConfigId'], $record['GroupId']);
+ }
+ else {
+ $data['perms']->AddDeny($record['PermissionConfigId'], $record['GroupId']);
+ }
+ }
+ }
+}
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.7.2/kernel/units/categories/cache_updater.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.7
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/categories/permissions_tab.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/categories/permissions_tab.tpl (nonexistent)
+++ branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/categories/permissions_tab.tpl (revision 6142)
@@ -0,0 +1,72 @@
+<inp2:m_if check="m_ParamEquals" name="tab_init" value="1">
+ <div id="<inp2:m_param name="item_prefix"/>_div" prefix="<inp2:m_param name="item_prefix"/>" group_id="-1" class="catalog-tab"></div>
+ <script type="text/javascript">$PermManager.registerTab('<inp2:m_param name="item_prefix"/>');</script>
+<inp2:m_else/>
+ if ($request_visible) {
+ document.getElementById('<inp2:m_get name="item_prefix"/>_div').setAttribute('group_id', <inp2:m_get name="group_id"/>);
+ }
+ <inp2:m_if check="c_SaveWarning">
+ document.getElementById('save_warning').style.display = 'block';
+ $edit_mode = true;
+ </inp2:m_if>
+ #separator#
+ <inp2:m_DefineElement name="permission_element">
+ <tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
+ <td>
+ <inp2:m_phrase name="$Description"/> [<inp2:m_param name="PermissionName"/>]
+ </td>
+
+ <td>
+ <!-- Inherited checkbox -->
+ <input
+ type="hidden"
+ id="<inp2:PermInputName sub_key="inherited"/>"
+ name="<inp2:PermInputName sub_key="inherited"/>"
+ value="<inp2:m_if check="m_ParamEquals" name="Inherited" value="1">1<inp2:m_else/>0</inp2:m_if>" />
+
+ <input
+ type="checkbox"
+ id="_cb_<inp2:PermInputName sub_key="inherited"/>"
+ <inp2:m_if check="m_ParamEquals" name="Inherited" value="1">checked</inp2:m_if>
+ onchange="update_checkbox(this, document.getElementById('<inp2:PermInputName sub_key="inherited"/>'));"
+ onclick="inherited_click('<inp2:m_param name="PermissionName"/>', <inp2:m_param name="InheritedValue"/>, this.checked, '_cb_<inp2:PermInputName sub_key="value"/>')" />
+ </td>
+
+ <td>
+ <inp2:CategoryPath cat_id="$InheritedFrom"/>
+ </td>
+
+ <td>
+ <!-- Access checkbox -->
+ <input
+ type="hidden"
+ id="<inp2:PermInputName sub_key="value"/>"
+ name="<inp2:PermInputName sub_key="value"/>"
+ value="<inp2:m_if check="m_ParamEquals" name="Value" value="1">1<inp2:m_else/>0</inp2:m_if>" />
+
+ <input
+ type="checkbox"
+ id="_cb_<inp2:PermInputName sub_key="value"/>"
+ <inp2:m_if check="m_ParamEquals" name="Inherited" value="1">disabled="disabled"</inp2:m_if>
+ <inp2:m_if check="m_ParamEquals" name="Value" value="1">checked</inp2:m_if>
+ onchange="update_checkbox(this, document.getElementById('<inp2:PermInputName sub_key="value"/>'));"
+ onclick="update_light('<inp2:m_param name="PermissionName"/>', this.checked)" />
+ </td>
+
+ <td>
+ <img id="light_<inp2:m_param name="PermissionName"/>" src="img/perm_<inp2:m_if check="m_ParamEquals" name="Value" value="1">green<inp2:m_else/>red</inp2:m_if>.gif"/>
+ </td>
+ </tr>
+ </inp2:m_DefineElement>
+ <table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder_full">
+ <inp2:m_set odd_even="table_color1"/>
+ <thead class="subsectiontitle">
+ <td><inp2:m_phrase name="la_col_Description"/></td>
+ <td><inp2:m_phrase name="la_col_Inherited"/></td>
+ <td><inp2:m_phrase name="la_col_InheritedFrom"/></td>
+ <td><inp2:m_phrase name="la_col_Access"/></td>
+ <td><inp2:m_phrase name="la_col_Effective"/></td>
+ </thead>
+ <inp2:c-perm_PrintPermissions render_as="permission_element"/>
+ </table>
+</inp2:m_if>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.7.2/kernel/admin_templates/categories/permissions_tab.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.7
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.7.2/kernel/admin/include/toolbar/editcategory_relationselect.php
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/kernel/admin/include/toolbar/editcategory_relationselect.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.7.2/kernel/admin/include/toolbar/editcategory_relationselect.php (revision 6142)
@@ -0,0 +1,799 @@
+<?php
+global $objConfig,$objSections,$section, $rootURL,$adminURL,$imagesURL,$envar,
+ $m_var_list_update,$objCatList, $homeURL, $upURL, $objSession,$CatScopeClause,$DefaultTab;
+
+global $CategoryFilter,$TotalItemCount;
+
+global $Bit_All,$Bit_Pending,$Bit_Disabled,$Bit_New,$Bit_Pop,$Bit_Hot,$Bit_Ed;
+
+global $hideSelectAll;
+
+
+/* bit place holders for category view menu */
+$Bit_Active=64;
+$Bit_Pending=32;
+$Bit_Disabled=16;
+$Bit_New=8;
+$Bit_Pop=4;
+$Bit_Hot=2;
+$Bit_Ed=1;
+
+if(strlen($_GET["SetTab"]))
+{
+ if($_GET["SetTab"] != "categories")
+ {
+ $m_tab_CatTab_Hide = 1;
+ $DefaultTab = $_GET["SetTab"];
+ }
+ else
+ {
+ $DefaultTab="categories";
+ $m_tab_CatTab_Hide = 0;
+ }
+}
+else
+ $m_tab_CatTab_Hide = (int)$objConfig->Get("CatTab_Hide");
+
+$CategoryView = $objConfig->Get("Category_View");
+if(!is_numeric($CategoryView))
+{
+ $CategoryView = 127;
+}
+
+$Category_Sortfield = $objConfig->Get("Category_Sortfield");
+if(!strlen($Category_Sortfield))
+ $Category_Sortfield = "Name";
+
+$Category_Sortorder = $objConfig->Get("Category_Sortorder");
+if(!strlen($Category_Sortorder))
+ $Category_Sortorder = "desc";
+
+$Perpage_Category = (int)$objConfig->Get("Perpage_Category");
+if(!$Perpage_Category)
+ $Perpage_Category="'all'";
+
+
+if($CategoryView == 127)
+{
+ $Category_ShowAll = 1;
+}
+else
+{
+ $Category_ShowAll=0;
+ $Status = array();
+ $Mod = array();
+ if($CategoryView & $Bit_Pending)
+ $Status[] = STATUS_PENDING;
+
+ if($CategoryView & $Bit_Active)
+ $Status[] = STATUS_ACTIVE;
+
+
+ if($CategoryView & $Bit_Disabled)
+ $Status[] = STATUS_DISABLED;
+
+ if(count($Status))
+ {
+ $CategoryFilter .= " AND (Status IN (".implode(",",$Status).") ";
+ }
+ else
+ $CategoryFilter .= " AND ((Status=-1) ";
+
+ if($CategoryView & $Bit_Ed)
+ {
+ $CategoryFilter .= " OR (EditorsPick=1) ";
+ }
+
+ if($CategoryView & $Bit_New)
+ {
+ $cutoff = adodb_date("U") - ($objConfig->Get("Category_DaysNew") * 86400);
+ $CategoryFilter .= " OR (CreatedOn > ".$cutoff.") ";
+ }
+ $CategoryFilter .= ")";
+}
+
+$list = $objSession->GetVariable("SearchWord");
+if(strlen($list))
+{
+ $CatScope = $objSession->GetVariable("SearchScope");
+ switch($CatScope)
+ {
+ case 0 :
+ $CatScopeClause = "";
+ break;
+ case 1:
+ $cat = $objCatList->CurrentCategoryID();
+ if($cat>0)
+ {
+ $allcats = $objCatList->AllSubCats($cat);
+ if(count($allcats)>0)
+ {
+ $catlist = implode(",",$allcats);
+ $CatScopeClause = " CategoryId IN ($catlist) ";
+ }
+ }
+ break;
+ case 2:
+ $CatScopeClause = "CategoryId=".$objCatList->CurrentCategoryID();
+ break;
+ }
+}
+else
+ $CatScopeClause="";
+
+$mnuClearSearch = language("la_SearchMenu_Clear");
+$mnuNewSearch = language("la_SearchMenu_New");
+$mnuSearchCategory = language("la_SearchMenu_Categories");
+
+$lang_New = language("la_Text_New");
+$lang_Hot = language("la_Text_Hot");
+$lang_EdPick = language("la_prompt_EditorsPick");
+$lang_Pop = language("la_Text_Pop");
+
+$lang_Rating = language("la_prompt_Rating");
+$lang_Hits = language("la_prompt_Hits");
+$lang_Votes = language("la_prompt_Votes");
+$lang_Name = language("la_prompt_Name");
+
+$lang_Categories = language("la_ItemTab_Categories");
+$lang_Description = language("la_prompt_Description");
+$lang_MetaKeywords = language("la_prompt_MetaKeywords");
+$lang_SubSearch = language("la_prompt_SubSearch");
+$lang_Within = language("la_Text_Within");
+$lang_Current = language("la_Text_Current");
+$lang_Active = language("la_Text_Active");
+$lang_SubCats = language("la_Text_SubCats");
+$lang_SubItems = language("la_Text_Subitems");
+
+$selector = isset($_GET['Selector']) ? '&Selector='.$_GET['Selector'] : '';
+$destform = GetVar('destform');
+print <<<END
+
+<script language="JavaScript">
+var Category_Sortfield = '$Category_Sortfield';
+var Category_Sortorder = '$Category_Sortorder';
+var Category_Perpage = $Perpage_Category;
+var Category_ShowAll = $Category_ShowAll;
+var CategoryView = $CategoryView;
+var default_tab = "$DefaultTab";
+
+//JS Language variables
+var lang_New = "$lang_New";
+var lang_Hot = "$lang_Hot";
+var lang_EdPick = "$lang_EdPick";
+
+var lang_Pop = "$lang_Pop";
+var lang_Rating = "$lang_Rating";
+var lang_Hits = "$lang_Hits";
+var lang_Votes = "$lang_Votes";
+var lang_Name = "$lang_Name";
+var lang_Categories = "$lang_Categories";
+var lang_Description = "$lang_Description";
+var lang_MetaKeywords = "$lang_MetaKeywords";
+var lang_SubSearch = "$lang_SubSearch";
+var lang_Within="$lang_Within";
+var lang_Current = "$lang_Current";
+var lang_Active = "$lang_Active";
+var lang_SubCats = "$lang_SubCats";
+var lang_SubItems = "$lang_SubItems";
+
+var m_tab_CatTab_hide = $m_tab_CatTab_Hide;
+var hostname = '$rootURL';
+var env = '$envar';
+var actionlist = new Array();
+var homeURL = "$homeURL$selector&destform=$destform";
+var upURL = "$upURL$selector&destform=$destform";
+var Categories_Paste = false;
+
+ // K4 code for handling toolbar operations: begin
+ var \$TabRegistry = Array();
+
+ function InpGrid(tab)
+ {
+ this.TabId = tab;
+ }
+
+ InpGrid.prototype.ClearSelection = function(force,called_from)
+ {
+ unselectAll(this.TabId, 1); //1 means don't upate toolbar
+ }
+
+ function registerTab(\$tab_id)
+ {
+ var \$tab = document.getElementById(\$tab_id);
+ var \$index = \$TabRegistry.length;
+
+ \$TabRegistry[\$index] = new Array();
+ \$TabRegistry[\$index]['tab_id'] = \$tab_id;
+ \$TabRegistry[\$index]['prefix_special'] = \$tab.getAttribute('PrefixSpecial');
+ \$TabRegistry[\$index]['edit_template'] = \$tab.getAttribute('EditURL');
+ }
+
+ function queryTabRegistry(\$search_key, \$search_value, \$return_key)
+ {
+ var \$i = 0;
+ while(\$i < \$TabRegistry.length)
+ {
+ if(\$TabRegistry[\$i][\$search_key] == \$search_value)
+ {
+ return \$TabRegistry[\$i][\$return_key];
+ break;
+ }
+ \$i++;
+ }
+ return '<'+\$search_key+'='+\$search_value+'>';
+ }
+
+ function k4_actionHandler(action, prefix_special)
+ {
+ var k4_action = '';
+ switch (action)
+ {
+ case 'edit':
+ k4_action = 'edit_item("'+prefix_special+'")';
+ break;
+ case 'delete':
+ k4_action = 'delete_items("'+prefix_special+'")';
+ break;
+ case 'unselect':
+ k4_action = 'unselect("'+prefix_special+'")';
+ break;
+ case 'approve':
+ k4_action = 'approve_items("'+prefix_special+'")';
+ break;
+ case 'decline':
+ k4_action = 'decine_items("'+prefix_special+'")';
+ break;
+
+ case 'copy':
+ k4_action = 'copy_items("'+prefix_special+'")';
+ break;
+ case 'cut':
+ k4_action = 'cut_items("'+prefix_special+'")';
+ break;
+ case 'move_up':
+ k4_action = 'move_up("'+prefix_special+'")';
+ break;
+ case 'move_down':
+ k4_action = 'move_down("'+prefix_special+'")';
+ break;
+ }
+
+ if (k4_action != '')
+ {
+ \$form_name = queryTabRegistry('prefix_special', prefix_special, 'tab_id') + '_form';
+ eval(k4_action);
+ }
+ else alert(action+' not implemented');
+
+ }
+
+ function approve_items(prefix_special)
+ {
+ set_hidden_field('remove_specials['+prefix_special+']',1);
+ submit_event(prefix_special,'OnMassApprove','')
+ }
+
+ function decine_items(prefix_special)
+ {
+ set_hidden_field('remove_specials['+prefix_special+']',1);
+ submit_event(prefix_special,'OnMassDecline','')
+ }
+
+ function edit()
+ {
+ edit_item( queryTabRegistry('tab_id', activeTab.id, 'prefix_special') );
+ }
+
+ function edit_item(prefix_special)
+ {
+ opener_action('d');
+ set_hidden_field(prefix_special+'_mode', 't');
+ submit_event(prefix_special, 'OnEdit', queryTabRegistry('prefix_special', prefix_special, 'edit_template'), '../../admin/index.php');
+ }
+
+ function delete_items(prefix_special)
+ {
+ set_hidden_field('remove_specials['+prefix_special+']',1);
+ submit_event(prefix_special,'OnMassDelete','')
+ }
+
+ function copy_items(prefix_special)
+ {
+ submit_event(prefix_special,'OnCopy','')
+ }
+
+ function cut_items(prefix_special)
+ {
+ submit_event(prefix_special,'OnCut','')
+ }
+
+ function move_up(prefix_special)
+ {
+ submit_event(prefix_special,'OnMassMoveUp','')
+ }
+
+ function move_down(prefix_special)
+ {
+ submit_event(prefix_special,'OnMassMoveDown','')
+ }
+
+ function unselect(prefix_special)
+ {
+ Grids[prefix_special].ClearSelection(null,'Inp_AdvancedView.Unselect');
+ }
+ // K4 code for handling toolbar operations: end
+
+ function InitPage()
+ {
+ var main_form='kernel_form';
+ if('$destform') main_form='$destform';
+ addCommonActions(main_form);
+ initToolbar('mainToolBar', actionHandler);
+ initCheckBoxes();
+ //toggleMenu();
+ }
+
+ function AddButtonAction(actionname,actionval)
+ {
+ var item = new Array(actionname,actionval);
+ actionlist[actionlist.length] = item;
+ }
+
+ function actionHandler(button)
+ {
+ //alert('a button has been pressed!');
+ for(i=0; i<actionlist.length;i++)
+ {
+
+ a = actionlist[i];
+ if(button.action==a[0])
+ {
+ //alert('Button action '+a[0]+' is '+a[1]);
+ eval(a[1]);
+ break;
+ }
+ }
+ }
+
+ function addCommonActions(main_form)
+ {
+ AddButtonAction('upcat',"get_to_server(upURL,'');");// UP
+ AddButtonAction('homecat',"get_to_server(homeURL,'');"); //home
+ AddButtonAction('select',"check_submit('"+main_form+"');"); //edit
+ AddButtonAction('stop',"window.close();"); //delete
+ AddButtonAction('view',"toggleMenu(); window.FW_showMenu(window.cat_menu,getRealLeft(button) - ((document.all) ? 6 : -2),getRealTop(button)+32);");
+ //AddButtonAction('search_a',"setSearchMenu(); window.FW_showMenu(window.SearchMenu,getRealLeft(button)-134 - ((document.all) ? 8 : -1),getRealTop(button)+22);");
+ AddButtonAction('search_b',"search_submit();");
+ AddButtonAction('search_c',"ClearSearch();");
+ }
+
+ function AdminCatNav(url)
+ {
+ f = document.getElementById("admin_search");
+ if(f)
+ {
+ f.action = url;
+ new_search_submit();
+ }
+ }
+
+ function search_submit()
+ {
+ f = document.getElementById("admin_search");
+ if(f)
+ {
+ //alert('Setting SearchWord to ' + f.value);
+ f.Action.value = "m_SearchWord";
+ f.submit();
+ }
+ }
+ function new_search_submit()
+ {
+ var newSearchInput = document.getElementById("NewSearch");
+ if (newSearchInput) newSearchInput.value = 1;
+ search_submit();
+ }
+
+ function ClearSearch()
+ {
+ //alert('Clearing Search');
+ f = document.getElementById("admin_search");
+ if(f)
+ {
+ f.Action.value = "m_ClearSearch";
+ f.submit();
+ }
+ }
+
+ function SetSearchType(value)
+ {
+ f = document.getElementById("admin_search");
+ if(f)
+ {
+ f.SearchType.value = value;
+ }
+ }
+
+ function SetSearchScope(value)
+ {
+ f = document.getElementById("admin_search");
+ if(f)
+ {
+ f.SearchScope.value = value;
+ }
+ }
+
+ function ToggleNewSearch()
+ {
+ f = document.getElementById("admin_search");
+ if(f)
+ {
+ value = f.NewSearch.value;
+ if(value==1)
+ {
+ f.NewSearch.value=0;
+ }
+ else
+ f.NewSearch.value=1;
+ }
+ }
+ function isNewSearch()
+ {
+ f = document.getElementById("admin_search");
+ if(f)
+ {
+ return f.NewSearch.value;
+ }
+ else return 0;
+ }
+
+
+ function get_to_server(path,attr)
+ {
+ if(attr.length>0)
+ path = path + '?'+attr;
+
+ //alert(path);
+ window.location.href=path;
+ return true;
+ }
+
+ function check_submit(main_form)
+ {
+ var formname = '';
+
+ if ((activeTab) && (!isAnyChecked('categories')))
+ {
+ form_name = activeTab.id;
+ }
+ else
+ {
+ form_name = 'categories';
+ }
+ var f = document.getElementsByName(form_name+'_form')[0];
+ var bf = window.opener.document.getElementById(main_form);
+
+ if(bf)
+ {
+ if(typeof(LastCheckedItem.value) != 'undefined')
+ {
+ try{
+ item_id = LastCheckedItem.value;
+ item_type = LastCheckedItem.ItemType;
+ }
+ catch(err)
+ {
+ }
+ bf.TargetId.value = item_id;
+ bf.TargetType.value = item_type;
+ bf.submit();
+ window.close();
+ }
+ else {
+ theMainScript.Alert(lang_Selection_Empty);
+ }
+ }
+ } // check submit
+
+ function flip_current(field_suffix)
+ {
+ if(activeTab)
+ {
+ field = activeTab.getAttribute("tabTitle")+field_suffix;
+ return flip(eval(field));
+ }
+ }
+
+ function config_current(field_suffix,value)
+ {
+ if(activeTab)
+ {
+ field = activeTab.getAttribute("tabTitle")+field_suffix;
+ config_val(field,value);
+ }
+ }
+
+ function getSType(type,value)
+ {
+ f = document.getElementById("admin_search");
+ if(f)
+ {
+ if (f.SearchType.value == type) return 2; else return 0;
+ } else return 0;
+
+ }
+
+ function getSScope(scope)
+ {
+ f = document.getElementById("admin_search");
+ if(f)
+ {
+ if (f.SearchScope.value == scope) return 2; else return 0;
+ } else return 0;
+
+ }
+
+// function setSearchMenu()
+// {
+//
+// window.SearchMenu = new Menu("search");
+// SearchMenu.addMenuItem(lang_All,"SetSearchType('all');",getSType('all'));
+// SearchMenu.addMenuSeparator()
+//
+// SearchMenu.addMenuItem(lang_Categories, "SetSearchType('categories');",getSType('categories'));
+// param = "";
+//
+// for (var i = 0; i < tabIDs.length; i++)
+// {
+// d = document.getElementById(tabIDs[i]);
+// if(d)
+// {
+// tabname = d.getAttribute("tabTitle");
+// param = "SetSearchType('"+tabname+"');";
+//
+// SearchMenu.addMenuItem(tabname,param,getSType(tabname));
+// }
+// }
+//
+// SearchMenu.addMenuSeparator();
+// SearchMenu.addMenuItem(lang_All+' '+lang_Categories,"SetSearchScope('0');",getSScope(0));
+// SearchMenu.addMenuItem(lang_SubSearch,"ToggleNewSearch();",isNewSearch());
+// SearchMenu.addMenuItem(lang_Current+' '+lang_Categories,"SetSearchScope('2');",getSScope(2));
+// SearchMenu.addMenuItem(lang_Within+' '+lang_Categories,"SetSearchScope('1');",getSScope(1));
+//
+// SearchMenu.addMenuSeparator();
+//
+// window.SearchMenu.addMenuItem('$mnuClearSearch',"ClearSearch();","");
+// window.triedToWriteMenus = false;
+// window.SearchMenu.writeMenus();
+// }
+
+ function Category_SortMenu(caption)
+ {
+ menu_sorting = new Menu(caption);
+
+ menu_sorting.addMenuItem(lang_Asc,"config_val('Category_Sortorder','asc');",RadioIsSelected(Category_Sortorder,'asc'));
+ menu_sorting.addMenuItem(lang_Desc,"config_val('Category_Sortorder','desc');",RadioIsSelected(Category_Sortorder,'desc'));
+ menu_sorting.addMenuSeparator();
+
+ menu_sorting.addMenuItem(lang_Default,"config_val('Category_Sortfield','Name');","");
+ menu_sorting.addMenuItem(lang_Name,"config_val('Category_Sortfield','Name');",RadioIsSelected(Category_Sortfield,'Name'));
+ menu_sorting.addMenuItem(lang_Description,"config_val('Category_Sortfield','Description');",RadioIsSelected(Category_Sortfield,'Description'));
+
+ menu_sorting.addMenuItem(lang_CreatedOn,"config_val('Category_Sortfield','CreatedOn');",RadioIsSelected(Category_Sortfield,'CreatedOn'));
+ menu_sorting.addMenuItem(lang_SubCats,"config_val('Category_Sortfield','CachedDescendantCatsQty');",RadioIsSelected(Category_Sortfield,'CachedDescendantCatsQty'));
+ menu_sorting.addMenuItem(lang_SubItems,"config_val('Category_Sortfield','SubItems');",RadioIsSelected(Category_Sortfield,'SubItems'));
+
+ return menu_sorting;
+
+ }
+
+
+ function Category_FilterMenu(caption)
+ {
+ menu_filter = new Menu(caption);
+ menu_filter.addMenuItem(lang_All,"config_val('Category_View', 127);",CategoryView==127);
+ menu_filter.addMenuSeparator();
+ menu_filter.addMenuItem(lang_Active,"FlipBit('Category_View',CategoryView,6);",BitStatus(CategoryView,6));
+ menu_filter.addMenuItem(lang_Pending,"FlipBit('Category_View',CategoryView,5);", BitStatus(CategoryView,5));
+ menu_filter.addMenuItem(lang_Disabled,"FlipBit('Category_View',CategoryView,4);",BitStatus(CategoryView,4));
+
+ menu_filter.addMenuSeparator();
+ menu_filter.addMenuItem(lang_New,"FlipBit('Category_View',CategoryView,3);",BitStatus(CategoryView,3));
+ menu_filter.addMenuItem(lang_EdPick,"FlipBit('Category_View',CategoryView,0);",BitStatus(CategoryView,0));
+
+ return menu_filter;
+ }
+
+ function toggleMenu()
+ {
+ //var tab_title = GetTabTitle(activeTab.id);
+ //alert(tab_title);
+ if ((document.getElementById('categories').active) && (activeTab))
+ {
+ filterfunc = activeTab.getAttribute("tabTitle")+'_FilterMenu();';
+
+ window.cat_menu_filter_sub = Category_FilterMenu(lang_Categories);
+ window.sub_menu_filter_sub = eval(filterfunc);
+
+ window.cat_menu_filter = new Menu(lang_View);
+ cat_menu_filter.addMenuItem(cat_menu_filter_sub);
+ cat_menu_filter.addMenuItem(sub_menu_filter_sub);
+ }
+ else
+ {
+ if (document.getElementById('categories').active)
+ {
+ window.cat_menu_filter = Category_FilterMenu(lang_View);
+ }
+ if (activeTab)
+ {
+ filterfunc = activeTab.getAttribute("tabTitle")+'_FilterMenu();';
+ window.cat_menu_filter = eval(filterfunc);
+ }
+ } // Filter
+
+ //Sorting
+ if ((document.getElementById('categories').active) && (activeTab))
+ {
+ //Sort->Categories
+ sortfunc = activeTab.getAttribute("tabTitle")+'_SortMenu();';
+
+ window.cat_menu_sorting_sub = Category_SortMenu(lang_Categories);
+ window.sub_menu_sorting_sub = eval(sortfunc);
+
+ window.cat_menu_sorting = new Menu(lang_Sort);
+ cat_menu_sorting.addMenuItem(cat_menu_sorting_sub);
+ cat_menu_sorting.addMenuItem(sub_menu_sorting_sub);
+ }
+ else
+ {
+ if (document.getElementById('categories').active)
+ {
+ window.cat_menu_sorting = Category_SortMenu(lang_Sort);
+
+ } // categories
+ if (activeTab)
+ {
+ window.cat_menu_sorting = Category_SortMenu(lang_Sort);
+ }
+
+ } // && Sorting
+ if ((document.getElementById('categories').active) && (activeTab))
+ {
+ window.cat_menu_select_sub = new Menu(lang_Categories);
+ cat_menu_select_sub.addMenuItem(lang_All,"javascript:selectAll('categories');","");
+ cat_menu_select_sub.addMenuItem(lang_Unselect,"javascript:unselectAll('categories');","");
+ cat_menu_select_sub.addMenuItem(lang_Invert,"javascript:invert('categories');","");
+
+ selectfunc = activeTab.getAttribute("tabTitle")+"_SelectMenu();";
+
+ window.sub_menu_select_sub = eval(selectfunc);
+// sub_menu_select_sub.addMenuItem(lang_All,"javascript:selectAll('"+activeTab.id+"');","");
+// sub_menu_select_sub.addMenuItem(lang_Unselect,"javascript:unselectAll('"+activeTab.id+"');","");
+// sub_menu_select_sub.addMenuItem(lang_Invert,"javascript:invert('"+activeTab.id+"');","");
+
+END;
+if (!$hideSelectAll) {
+echo "
+ window.cat_menu_select = new Menu(lang_Select);
+ cat_menu_select.addMenuItem(cat_menu_select_sub);
+ cat_menu_select.addMenuItem(sub_menu_select_sub);";
+}
+print <<<END
+ }
+ else
+ {
+END;
+if (!$hideSelectAll) {
+echo '
+ if (document.getElementById(\'categories\').active)
+ {
+ window.cat_menu_select = new Menu(lang_Select);
+ cat_menu_select.addMenuItem(lang_All,"javascript:selectAll(\'categories\');","");
+ cat_menu_select.addMenuItem(lang_Unselect,"javascript:unselectAll(\'categories\');","");
+ cat_menu_select.addMenuItem(lang_Invert,"javascript:invert(\'categories\');","");
+ } ';
+
+echo ' if (activeTab)
+ {
+
+ window.cat_menu_select = new Menu(lang_Select);
+ cat_menu_select.addMenuItem(lang_All,"javascript:selectAllC(\'"+activeTab.id+"\');","");
+ cat_menu_select.addMenuItem(lang_Unselect,"javascript:unselectAll(\'"+activeTab.id+"\');","");
+ cat_menu_select.addMenuItem(lang_Invert,"javascript:invert(\'"+activeTab.id+"\');","");
+ } ';
+}
+print <<<END
+ }
+ if(activeTab)
+ {
+ pagefunc = activeTab.getAttribute("tabTitle")+"_PerPageMenu();";
+ window.PerPageMenu = eval(pagefunc);
+ }
+ window.cat_menu = new Menu("root");
+ if ((document.getElementById('categories').active) || (activeTab)) window.cat_menu.addMenuItem(cat_menu_filter);
+ if ((document.getElementById('categories').active) || (activeTab)) window.cat_menu.addMenuItem(cat_menu_sorting);
+ if(activeTab) window.cat_menu.addMenuItem(PerPageMenu);
+
+END;
+if (!$hideSelectAll) {
+echo '
+ if ((document.getElementById(\'categories\').active) || (activeTab)) window.cat_menu.addMenuItem(cat_menu_select);
+';
+}
+print <<<END
+
+ window.triedToWriteMenus = false;
+ window.cat_menu.writeMenus();
+
+ }
+
+function toggleCategoriesA(tabHeader)
+{
+ var categories = document.getElementById('categories');
+ if (!categories) return;
+ toggleCategories();
+ tabHeader.setAttribute("background", '$imagesURL'+'/itemtabs/' + ((categories.active) ? "tab_active" : "tab_inactive") + ".gif")
+ var images = tabHeader.getElementsByTagName("IMG");
+ if (images.length < 1) return;
+ images[0].src = '$imagesURL'+'/itemtabs/' + ((categories.active) ? "divider_up" : "divider_dn") + ".gif";
+}
+
+function toggleTabA(tabId, atm)
+{
+ var hl = document.getElementById("hidden_line");
+ var activeTabId;
+ if (activeTab) activeTabId = activeTab.id;
+ if (activeTabId == tabId)
+ {
+ var devider = document.getElementById("tabsDevider");
+ devider.style.display = "";
+
+ unselectAll(tabId);
+ var tab = document.getElementById(tabId);
+ tab.active = false;
+ activeTab = null;
+ collapseTab = tab;
+ toolbar.setTab(null);
+ showTab();
+ }
+
+ else
+ {
+ if (activeTab) toggleTab(tabId, true)
+ else toggleTab(tabId, atm)
+
+ if (hl) hl.style.display = "none";
+ }
+ tab_hdr = document.getElementById('tab_headers');
+ if (!tab_hdr) return;
+ for (var i = 0; i < tabIDs.length; i++)
+ {
+ var tabHeader;
+ TDs = tab_hdr.getElementsByTagName("TD");
+ for (var j = 0; j < TDs.length; j++)
+ if (TDs[j].getAttribute("tabHeaderOf") == tabIDs[i])
+ {
+ tabHeader = TDs[j];
+ break;
+ }
+ if (!tabHeader) continue;
+
+ var tab = document.getElementById(tabIDs[i]);
+ if (!tab) continue;
+
+ tabHeader.setAttribute("background", "$imagesURL/itemtabs/" + ((tab.active) ? "tab_active" : "tab_inactive") + ".gif")
+
+ var images = tabHeader.getElementsByTagName("IMG");
+ if (images.length < 1) continue;
+
+ images[0].src = "$imagesURL/itemtabs/" + ((tab.active) ? "divider_up" : "divider_empty") + ".gif";
+ }
+}
+
+</script>
+
+END;
+?>
Property changes on: branches/unlabeled/unlabeled-1.7.2/kernel/admin/include/toolbar/editcategory_relationselect.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.7
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.7.2/core/units/relationship/relationship_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/core/units/relationship/relationship_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.7.2/core/units/relationship/relationship_event_handler.php (revision 6142)
@@ -0,0 +1,261 @@
+<?php
+
+ class RelationshipEventHandler extends InpDBEventHandler
+ {
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnProcessSelected' => Array('subitem' => 'add|edit'),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Initializes new relation
+ *
+ * @param kEvent $event
+ */
+ function OnNew(&$event)
+ {
+ parent::OnNew(&$event);
+
+ $object =& $event->getObject();
+ $table_info = $object->getLinkedInfo();
+
+ $object->SetDBField('SourceId', $table_info['ParentId']);
+ $source_itemtype = $this->Application->getUnitOption($table_info['ParentPrefix'], 'ItemType');
+ $object->SetDBField('SourceType', $source_itemtype);
+
+ $object->SetDBField('TargetId', $this->Application->GetVar('target_id'));
+ $object->SetDBField('TargetType', $this->Application->GetVar('target_type'));
+
+ $this->OnAfterItemLoad($event);
+ }
+
+ /**
+ * Add new relation
+ *
+ * @param kEvent $event
+ */
+ function OnProcessSelected(&$event)
+ {
+ $dst_field = $this->Application->RecallVar('dst_field');
+ if ($dst_field == 'TargetId') {
+ // prepare target_id & target_type
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $selected_ids = $this->Application->GetVar('selected_ids');
+ $target_prefix = false;
+ foreach ($selected_ids as $selected_prefix => $target_id) {
+ if ($target_id > 0) {
+ $target_prefix = $selected_prefix;
+ break;
+ }
+ }
+
+ if (!$target_prefix) {
+ $this->finalizePopup($event);
+ return;
+ }
+
+ $sql = 'SELECT ResourceId
+ FROM '.$this->Application->getUnitOption($target_prefix, 'TableName').'
+ WHERE '.$this->Application->getUnitOption($target_prefix, 'IDField').' = '.$target_id;
+ $target_id = $this->Conn->GetOne($sql);
+ $target_type = $this->Application->getUnitOption($target_prefix, 'ItemType');
+
+ // don't add same relation twice
+ $table_info = $object->getLinkedInfo();
+ $sql = 'SELECT TargetId
+ FROM '.$object->TableName.'
+ WHERE (SourceId = '.$table_info['ParentId'].') AND (TargetId = '.$target_id.')';
+ $duplicate_relation = $this->Conn->GetOne($sql) == $target_id;
+
+ $this->finalizePopup($event);
+
+ if (!$duplicate_relation) {
+ // place correct template in opener stack
+ $source_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $template = $this->Application->getUnitOption($source_prefix, 'AdminTemplatePath').'/relations_edit';
+ $redirect_params = Array($event->Prefix.'_event' => 'OnNew', 'target_id' => $target_id, 'target_type' => $target_type);
+ $this->Application->EventManager->openerStackPush($template, $redirect_params, 'all,'.$event->Prefix);
+ }
+ }
+ else {
+ $this->finalizePopup($event);
+ }
+ }
+
+ /**
+ * Set ItemName & ItemType virtual fields based on loaded item data
+ *
+ * @param kEvent $event
+ */
+ function OnAfterItemLoad(&$event)
+ {
+ $object =& $event->getObject();
+
+ $sql = 'SELECT Prefix
+ FROM '.TABLE_PREFIX.'ItemTypes
+ WHERE ItemType = '.$object->GetDBField('TargetType');
+ $target_prefix = $this->Conn->GetOne($sql);
+
+ $title_field = $this->getTitleField($target_prefix);
+ $title_phrase = $this->Application->getUnitOption($target_prefix, 'TitlePhrase');
+
+ $sql = 'SELECT '.$title_field.'
+ FROM '.$this->Application->getUnitOption($target_prefix, 'TableName').'
+ WHERE ResourceId = '.$object->GetDBField('TargetId');
+
+ $object->SetDBField('ItemName', $this->Conn->GetOne($sql));
+ $object->SetDBField('ItemType', $this->Application->Phrase($title_phrase));
+ }
+
+ /**
+ * Creates needed sql query to load list,
+ * if no query is defined in config for
+ * special requested, then use default
+ * query
+ *
+ * @param kEvent $event
+ * @access protected
+ */
+ function ListPrepareQuery(&$event)
+ {
+ return $this->BaseQuery($event, 'ListSQLs');
+ }
+
+ /**
+ * Creates needed sql query to load item,
+ * if no query is defined in config for
+ * special requested, then use default
+ * query
+ *
+ * @param kEvent $event
+ * @access protected
+ */
+ function ItemPrepareQuery(&$event)
+ {
+ return $this->BaseQuery($event, 'ItemSQLs');
+ }
+
+
+ /**
+ * Get item name & type based on relation type & modules installed
+ *
+ * @param kEvent $event
+ * @param string $sql_field
+ */
+ function BaseQuery(&$event, $sql_field)
+ {
+ $sqls = $this->Application->getUnitOption($event->Prefix,$sql_field);
+ $sql = isset($sqls[$event->Special]) ? $sqls[$event->Special] : $sqls[''];
+
+ $configs = $this->extractModulesInfo();
+
+ // 2. build sql based on information queried
+ $sql_templates['ItemName'] = 'IFNULL(%s.%s,\' \')';
+ $sql_templates['TableJoin'] = 'LEFT JOIN %1$s ON %1$s.ResourceId = rel.TargetId';
+ $sql_templates['TargetName'] = 'IF(rel.TargetType = %s, \'%s\', %s)';
+
+ $sql_parts = Array();
+ $sql_parts['TargetName'] = "''";
+ foreach ($configs as $prefix => $config_data) {
+ $title_field = $this->getTitleField($prefix);
+
+ $sql_parts['ItemName'][] = sprintf($sql_templates['ItemName'], $config_data['TableName'], $title_field);
+ $sql_parts['TableJoin'][] = sprintf($sql_templates['TableJoin'], $config_data['TableName']);
+
+ $sql_parts['TargetName'] = sprintf( $sql_templates['TargetName'],
+ $config_data['ItemType'],
+ '!'.$config_data['TitlePhrase'].'!',
+ $sql_parts['TargetName']);
+ $sql_parts['TargetName'] = str_replace('rel','%1$s',$sql_parts['TargetName']);
+ }
+
+ $object =& $event->getObject();
+
+ $vars = Array('#ITEM_NAMES#', '#ITEM_TYPES#');
+ $replacements = Array( implode(', ',$sql_parts['ItemName']), $sql_parts['TargetName'] );
+
+ $calculated_fields =& $object->getProperty('CalculatedFields');
+ foreach ($calculated_fields as $field_name => $field_expression) {
+ $calculated_fields[$field_name] = str_replace($vars, $replacements, $field_expression);
+ }
+
+ $object->setProperty('CalculatedFields', $calculated_fields);
+
+ $sql = str_replace('#ITEM_JOIN#', implode(' ',$sql_parts['TableJoin']), $sql);
+ $sql = str_replace('rel.','%1$s.',$sql);
+
+ return $sql;
+ }
+
+ /**
+ * Convert TitleField field of kMultiLanguage formatter used for it
+ *
+ * @param string $prefix
+ * @return string
+ */
+ function getTitleField($prefix)
+ {
+ $lang_prefix = 'l'.$this->Application->GetVar('m_lang').'_';
+
+ $title_field = $this->Application->getUnitOption($prefix, 'TitleField');
+ $field_options = $this->Application->getUnitOption($prefix.'.'.$title_field, 'Fields');
+
+ $formatter_class = isset($field_options['formatter']) ? $field_options['formatter'] : '';
+ if ($formatter_class == 'kMultiLanguage' && !isset($field_options['master_field'])) {
+ $title_field = $lang_prefix.$title_field;
+ }
+ return $title_field;
+ }
+
+ /**
+ * Get configs from modules installed
+ *
+ * @return Array
+ * @access private
+ */
+ function extractModulesInfo()
+ {
+ // get installed modules & their config info
+ // maybe we should leave only prefixes, that have "view" permission
+ $configs = Array();
+ foreach ($this->Application->ModuleInfo as $module_name => $module_data) {
+ $prefix = $module_data['Var'];
+ if ($prefix == 'm') {
+ $prefix = 'c';
+ }
+ $configs[$prefix] = $this->Application->getUnitOptions($prefix);
+ if($configs[$prefix] === false) unset($configs[$prefix]);
+ if(!isset($configs[$prefix]['CatalogItem']) || !$configs[$prefix]['CatalogItem']) unset($configs[$prefix]);
+ }
+ return $configs;
+ }
+
+ /**
+ * Deletes relations to hooked item from other items
+ *
+ * @param kEvent $event
+ */
+ function OnDeleteForeignRelations(&$event)
+ {
+ $main_object =& $event->MasterEvent->getObject();
+ $resource_id = $main_object->GetDBField('ResourceId');
+
+ $table = $this->Application->getUnitOption($event->Prefix,'TableName');
+ $sql = 'DELETE FROM '.$table.' WHERE TargetId = '.$resource_id;
+ $this->Conn->Query($sql);
+ }
+
+
+ }
+
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.7.2/core/units/relationship/relationship_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.7
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.7.2/core/units/categories/cache_updater.php
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/core/units/categories/cache_updater.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.7.2/core/units/categories/cache_updater.php (revision 6142)
@@ -0,0 +1,371 @@
+<?php
+class clsRecursionStack
+{
+ var $Stack;
+
+ function clsRecursionStack()
+ {
+ $this->Stack = Array();
+ }
+
+ function Push($values)
+ {
+ array_push($this->Stack, $values);
+ }
+
+ function Pop()
+ {
+ if ($this->Count() > 0) {
+ return array_pop($this->Stack);
+ }
+ else {
+ return false;
+ }
+ }
+
+ function Get()
+ {
+ if ($this->Count() > 0) {
+// return end($this->Stack);
+ return $this->Stack[count($this->Stack)-1];
+ }
+ else {
+ return false;
+ }
+ }
+
+ function Update($values)
+ {
+ $this->Stack[count($this->Stack)-1] = $values;
+ }
+
+ function Count()
+ {
+ return count($this->Stack);
+ }
+}
+
+
+class clsCachedPermissions
+{
+ var $Allow = Array();
+ var $Deny = Array();
+ var $CatId;
+
+ function clsCachedPermissions($CatId)
+ {
+ $this->CatId = $CatId;
+ }
+
+ function SetCatId($CatId)
+ {
+ $this->CatId = $CatId;
+ }
+
+ function CheckPermArray($Perm)
+ {
+ if (!isset($this->Allow[$Perm])) {
+ $this->Allow[$Perm] = array();
+ $this->Deny[$Perm] = array();
+ }
+ }
+
+ function AddAllow($Perm, $GroupId)
+ {
+ $this->CheckPermArray($Perm);
+ if (!in_array($GroupId, $this->Allow[$Perm])) {
+ array_push($this->Allow[$Perm], $GroupId);
+ $this->RemoveDeny($Perm, $GroupId);
+ }
+ }
+
+ function AddDeny($Perm, $GroupId)
+ {
+ $this->CheckPermArray($Perm);
+ if (!in_array($GroupId, $this->Deny[$Perm])) {
+ array_push($this->Deny[$Perm], $GroupId);
+ $this->RemoveAllow($Perm, $GroupId);
+ }
+ }
+
+ function RemoveDeny($Perm, $GroupId)
+ {
+ if (in_array($GroupId, $this->Deny[$Perm])) {
+ array_splice($this->Deny[$Perm], array_search($GroupId, $this->Deny[$Perm]), 1);
+ }
+ }
+
+ function RemoveAllow($Perm, $GroupId)
+ {
+ if (in_array($GroupId, $this->Allow[$Perm])) {
+ array_splice($this->Allow[$Perm], array_search($GroupId, $this->Allow[$Perm]), 1);
+ }
+ }
+
+ function GetInsertSQL()
+ {
+ $values = array();
+
+ $has_deny = array();
+
+ // don't write DACL at all
+ /*foreach ($this->Deny as $perm => $groups) {
+ if (count($groups) > 0) {
+ $values[] = '('.$this->CatId.', '.$perm.', "", "'.join(',', $groups).'")';
+ $has_deny[] = $perm;
+ }
+ }*/
+
+ foreach ($this->Allow as $perm => $groups) {
+// if (in_array($perm, $has_deny)) continue;
+ if (count($groups) > 0) {
+ $values[] = '(' .$this->CatId. ', ' .$perm. ', "' .join(',', $groups). '", "")';
+ }
+ }
+ if (!$values) return '';
+ $sql = 'INSERT INTO '.TABLE_PREFIX.'PermCache (CategoryId, PermId, ACL, DACL) VALUES '.join(',', $values);
+ return $sql;
+ }
+}
+
+class kPermCacheUpdater extends kHelper
+{
+ var $Stack;
+ var $iteration;
+ var $totalCats;
+ var $doneCats;
+ var $table;
+
+ var $primaryLanguageId = 0;
+ var $languageCount = 0;
+ var $root_prefixes = Array();
+
+ function Init($prefix, $special, $event_params = null)
+ {
+ parent::Init($prefix, $special, $event_params);
+
+ $continuing = $event_params['continue'];
+
+ // cache widely used values to speed up process: begin
+ $ml_helper =& $this->Application->recallObject('kMultiLanguageHelper');
+ $this->languageCount = $ml_helper->getLanguageCount();
+ $this->primaryLanguageId = $this->Application->GetDefaultLanguageId();
+ // cache widely used values to speed up process: end
+
+ foreach ($this->Application->ModuleInfo as $module_name => $module_info) {
+ $this->root_prefixes[ $module_info['RootCat'] ] = $module_info['Var'];
+ }
+
+ $this->iteration = 0;
+ $this->table = $this->Application->GetTempName('permCacheUpdate');
+
+ if ($continuing == 1) {
+ $this->InitUpdater();
+ }
+ elseif ($continuing == 2) {
+ $this->getData();
+ }
+ }
+
+ function InitUpdater()
+ {
+ $this->Stack =& new clsRecursionStack();
+ $sql = 'DELETE FROM '.TABLE_PREFIX.'PermCache';
+ $this->Conn->Query($sql);
+ $this->initData();
+ }
+
+ function getDonePercent()
+ {
+ if(!$this->totalCats)return 0;
+ return min(100, intval( round( $this->doneCats / $this->totalCats * 100 ) ));
+ }
+
+ function getData()
+ {
+ $tmp = $this->Conn->GetOne('SELECT data FROM '.$this->table);
+ if ($tmp) $tmp = unserialize($tmp);
+
+ $this->totalCats = isset($tmp['totalCats']) ? $tmp['totalCats'] : 0;
+ $this->doneCats = isset($tmp['doneCats']) ? $tmp['doneCats'] : 0;
+ if (isset($tmp['stack'])) {
+ $this->Stack = $tmp['stack'];
+ }
+ else {
+ $this->Stack = & new clsRecursionStack();
+ }
+ }
+
+ function setData()
+ {
+ $tmp = Array (
+ 'totalCats' => $this->totalCats,
+ 'doneCats' => $this->doneCats,
+ 'stack' => $this->Stack,
+ );
+
+ $this->Conn->Query('DELETE FROM '.$this->table);
+
+ $fields_hash = Array('data' => serialize($tmp));
+ $this->Conn->doInsert($fields_hash, $this->table);
+ }
+
+ function initData()
+ {
+ $this->clearData(); // drop table before starting anyway
+
+ $this->Conn->Query('CREATE TABLE '.$this->table.'(data LONGTEXT)');
+
+ $this->totalCats = (int)$this->Conn->GetOne('SELECT COUNT(*) FROM '.TABLE_PREFIX.'Category');
+ $this->doneCats = 0;
+ }
+
+ function clearData()
+ {
+ $this->Conn->Query('DROP TABLE IF EXISTS '.$this->table);
+ }
+
+ function DoTheJob()
+ {
+ $data = $this->Stack->Get();
+ if ($data === false) { //If Stack is empty
+ $data['current_id'] = 0;
+ $data['titles'] = Array();
+ $data['parent_path'] = Array();
+ $data['named_path'] = Array();
+ $data['category_template'] = '';
+ $data['item_template'] = '';
+ $this->Stack->Push($data);
+ }
+
+ if (!isset($data['queried'])) {
+ $this->QueryTitle($data);
+ $this->QueryChildren($data);
+ $this->QueryPermissions($data);
+ $data['queried'] = 1;
+
+ if ($sql = $data['perms']->GetInsertSQL()) {
+ $this->Conn->Query($sql);
+ // $this->doneCats++; // moved to the place where it pops out of the stack by Kostja
+ }
+ $this->iteration++;
+ }
+
+ // start with first child if we haven't started yet
+ if (!isset($data['current_child'])) $data['current_child'] = 0;
+
+ // if we have more children
+ if (isset($data['children'][$data['current_child']])) {
+ $next_data = Array();
+ $next_data['titles'] = $data['titles'];
+ $next_data['parent_path'] = $data['parent_path'];
+ $next_data['named_path'] = $data['named_path'];
+ $next_data['category_template'] = $data['category_template'];
+ $next_data['item_template'] = $data['item_template'];
+ $next_data['current_id'] = $data['children'][ $data['current_child'] ]; //next iteration should process child
+ $next_data['perms'] = $data['perms']; //we should copy our permissions to child - inheritance
+ $next_data['perms']->SetCatId($next_data['current_id']);
+ $data['current_child']++;
+ $this->Stack->Update($data); //we need to update ourself for the iteration after the next (or further) return to next child
+ $this->Stack->Push($next_data); //next iteration should process this child
+ return true;
+ }
+ else {
+ $this->UpdateCachedPath($data);
+ $this->Stack->Pop(); //remove ourself from stack if we have finished all the childs (or there are none)
+ // we are getting here if we finished with current level, so check if it's first level - then bail out.
+
+ $this->doneCats++; // moved by Kostja from above, seems to fix the prob
+ return $this->Stack->Count() > 0;
+ }
+ }
+
+ function UpdateCachedPath(&$data)
+ {
+ $fields_hash = Array (
+ 'ParentPath' => '|'.implode('|', $data['parent_path']).'|',
+ 'NamedParentPath' => implode('/', $data['named_path'] ),
+ 'CachedCategoryTemplate' => $data['category_template'],
+ );
+
+ $i = 1;
+ while ($i <= $this->languageCount) {
+ $fields_hash['l'.$i.'_CachedNavbar'] = implode('&|&', $data['titles'][$i]);
+ $i++;
+ }
+
+ $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$data['current_id']);
+ }
+
+ function QueryTitle(&$data)
+ {
+ $category_id = $data['current_id'];
+ $sql = 'SELECT *
+ FROM '.TABLE_PREFIX.'Category
+ WHERE CategoryId = '.$category_id;
+
+ $record = $this->Conn->GetRow($sql);
+ if ($record) {
+ $i = 1;
+ while ($i <= $this->languageCount) {
+ $data['titles'][$i][] = $record['l'.$i.'_Name'] ? $record['l'.$i.'_Name'] : $record['l'.$this->primaryLanguageId.'_Name'];
+ $i++;
+ }
+
+ $data['parent_path'][] = $category_id;
+ $data['named_path'][] = $record['Filename'];
+
+ // it is one of the modules root category
+ $root_prefix = isset($this->root_prefixes[$category_id]) ? $this->root_prefixes[$category_id] : false;
+ if ($root_prefix) {
+ $fields_hash = Array();
+ if (!$record['CategoryTemplate']) {
+ $record['CategoryTemplate'] = $this->Application->ConfigValue($root_prefix.'_CategoryTemplate');
+ $fields_hash['CategoryTemplate'] = $record['CategoryTemplate'];
+ }
+
+ $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'Category', 'CategoryId = '.$category_id);
+ }
+
+ // if explicitly set, then use it; use parent template otherwise
+ if ($record['CategoryTemplate']) {
+ $data['category_template'] = $record['CategoryTemplate'];
+ }
+ }
+
+ }
+
+ function QueryChildren(&$data)
+ {
+ $sql = 'SELECT CategoryId
+ FROM '.TABLE_PREFIX.'Category
+ WHERE ParentId = '.$data['current_id'];
+ $data['children'] = $this->Conn->GetCol($sql);
+ }
+
+ function QueryPermissions(&$data)
+ {
+ // don't search for section "view" permissions here :)
+ $sql = 'SELECT ipc.PermissionConfigId, ip.GroupId, ip.PermissionValue
+ FROM '.TABLE_PREFIX.'Permissions AS ip
+ LEFT JOIN '.TABLE_PREFIX.'PermissionConfig AS ipc ON ipc.PermissionName = ip.Permission
+ WHERE (CatId = '.$data['current_id'].') AND (Permission LIKE "%.VIEW") AND (ip.Type = 0)';
+
+ $records = $this->Conn->Query($sql);
+
+ //create permissions array only if we don't have it yet (set by parent)
+ if (!isset($data['perms'])) {
+ $data['perms'] = new clsCachedPermissions($data['current_id']);
+ }
+
+ foreach ($records as $record) {
+ if ($record['PermissionValue'] == 1) {
+ $data['perms']->AddAllow($record['PermissionConfigId'], $record['GroupId']);
+ }
+ else {
+ $data['perms']->AddDeny($record['PermissionConfigId'], $record['GroupId']);
+ }
+ }
+ }
+}
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.7.2/core/units/categories/cache_updater.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.7
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.7.2/core/admin_templates/categories/permissions_tab.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.7.2/core/admin_templates/categories/permissions_tab.tpl (nonexistent)
+++ branches/unlabeled/unlabeled-1.7.2/core/admin_templates/categories/permissions_tab.tpl (revision 6142)
@@ -0,0 +1,72 @@
+<inp2:m_if check="m_ParamEquals" name="tab_init" value="1">
+ <div id="<inp2:m_param name="item_prefix"/>_div" prefix="<inp2:m_param name="item_prefix"/>" group_id="-1" class="catalog-tab"></div>
+ <script type="text/javascript">$PermManager.registerTab('<inp2:m_param name="item_prefix"/>');</script>
+<inp2:m_else/>
+ if ($request_visible) {
+ document.getElementById('<inp2:m_get name="item_prefix"/>_div').setAttribute('group_id', <inp2:m_get name="group_id"/>);
+ }
+ <inp2:m_if check="c_SaveWarning">
+ document.getElementById('save_warning').style.display = 'block';
+ $edit_mode = true;
+ </inp2:m_if>
+ #separator#
+ <inp2:m_DefineElement name="permission_element">
+ <tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
+ <td>
+ <inp2:m_phrase name="$Description"/> [<inp2:m_param name="PermissionName"/>]
+ </td>
+
+ <td>
+ <!-- Inherited checkbox -->
+ <input
+ type="hidden"
+ id="<inp2:PermInputName sub_key="inherited"/>"
+ name="<inp2:PermInputName sub_key="inherited"/>"
+ value="<inp2:m_if check="m_ParamEquals" name="Inherited" value="1">1<inp2:m_else/>0</inp2:m_if>" />
+
+ <input
+ type="checkbox"
+ id="_cb_<inp2:PermInputName sub_key="inherited"/>"
+ <inp2:m_if check="m_ParamEquals" name="Inherited" value="1">checked</inp2:m_if>
+ onchange="update_checkbox(this, document.getElementById('<inp2:PermInputName sub_key="inherited"/>'));"
+ onclick="inherited_click('<inp2:m_param name="PermissionName"/>', <inp2:m_param name="InheritedValue"/>, this.checked, '_cb_<inp2:PermInputName sub_key="value"/>')" />
+ </td>
+
+ <td>
+ <inp2:CategoryPath cat_id="$InheritedFrom"/>
+ </td>
+
+ <td>
+ <!-- Access checkbox -->
+ <input
+ type="hidden"
+ id="<inp2:PermInputName sub_key="value"/>"
+ name="<inp2:PermInputName sub_key="value"/>"
+ value="<inp2:m_if check="m_ParamEquals" name="Value" value="1">1<inp2:m_else/>0</inp2:m_if>" />
+
+ <input
+ type="checkbox"
+ id="_cb_<inp2:PermInputName sub_key="value"/>"
+ <inp2:m_if check="m_ParamEquals" name="Inherited" value="1">disabled="disabled"</inp2:m_if>
+ <inp2:m_if check="m_ParamEquals" name="Value" value="1">checked</inp2:m_if>
+ onchange="update_checkbox(this, document.getElementById('<inp2:PermInputName sub_key="value"/>'));"
+ onclick="update_light('<inp2:m_param name="PermissionName"/>', this.checked)" />
+ </td>
+
+ <td>
+ <img id="light_<inp2:m_param name="PermissionName"/>" src="img/perm_<inp2:m_if check="m_ParamEquals" name="Value" value="1">green<inp2:m_else/>red</inp2:m_if>.gif"/>
+ </td>
+ </tr>
+ </inp2:m_DefineElement>
+ <table width="100%" border="0" cellspacing="0" cellpadding="4" class="tableborder_full">
+ <inp2:m_set odd_even="table_color1"/>
+ <thead class="subsectiontitle">
+ <td><inp2:m_phrase name="la_col_Description"/></td>
+ <td><inp2:m_phrase name="la_col_Inherited"/></td>
+ <td><inp2:m_phrase name="la_col_InheritedFrom"/></td>
+ <td><inp2:m_phrase name="la_col_Access"/></td>
+ <td><inp2:m_phrase name="la_col_Effective"/></td>
+ </thead>
+ <inp2:c-perm_PrintPermissions render_as="permission_element"/>
+ </table>
+</inp2:m_if>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.7.2/core/admin_templates/categories/permissions_tab.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.7
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Event Timeline
Log In to Comment