Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F1044145
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:28 PM
Size
57 KB
Mime Type
text/x-diff
Expires
Thu, Jun 26, 11:28 PM (4 h, 26 m)
Engine
blob
Format
Raw Data
Handle
675320
Attached To
rINP In-Portal
in-portal
View Options
Index: branches/unlabeled/unlabeled-1.4.2/kernel/units/relationship/relationship_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/kernel/units/relationship/relationship_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/kernel/units/relationship/relationship_event_handler.php (revision 4935)
@@ -0,0 +1,194 @@
+<?php
+
+ class RelationshipEventHandler extends InpDBEventHandler
+ {
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnAddRelation' => Array('subitem' => 'add|edit'),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Add new relation
+ *
+ * @param kEvent $event
+ */
+ function OnAddRelation(&$event)
+ {
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $object =& $event->getObject();
+
+ $table_info = $object->getLinkedInfo();
+ $main_item_type = $this->Application->getUnitOption($table_info['ParentPrefix'],'ItemType');
+
+ $target['id'] = $this->Application->GetVar('TargetId');
+ $target['type'] = $this->Application->GetVar('TargetType');
+
+
+ $object->SetDBField($table_info['ForeignKey'], $table_info['ParentId']);
+ $object->SetDBField('SourceType', $main_item_type);
+ $object->SetDBField('TargetId', $target['id']);
+ $object->SetDBField('TargetType', $target['type']);
+
+ // 1. get item info used in relation
+ $configs = $this->extractModulesInfo();
+ foreach($configs as $prefix => $config_data)
+ {
+ if($config_data['ItemType'] == $target['type']) break;
+ }
+
+ // this forces prepareOptions of kMultiLanguge formatter to substiture title field (if multilingual) of target item
+ // BUT this is not the solution, find out another way to get correct title field here
+
+ $target_object =& $this->Application->recallObject($prefix, null, Array('skip_autoload' => true));
+ $title_field = $this->Application->getUnitOption($prefix, 'TitleField');
+
+ $item['name'] = $this->Conn->GetOne('SELECT '.$title_field.' FROM '.$config_data['TableName'].' WHERE ResourceId = '.$target['id']);
+ $item['type'] = $this->Application->Phrase($config_data['TitlePhrase']);
+ $object->SetDBField('ItemName', $item['name']);
+ $object->SetDBField('ItemType', $item['type']);
+
+ $object->setID(0);
+
+ $event->redirect = false;
+
+ // 2. substitute opener
+ $opener_stack = $this->Application->RecallVar('opener_stack');
+ $opener_stack = $opener_stack ? unserialize($opener_stack) : Array();
+ array_pop($opener_stack);
+
+ $return_template = $this->Application->RecallVar('return_template');
+ $new_level = 'index4.php|'.ltrim($this->Application->BuildEnv($return_template, Array('m_opener'=>'u'),'all'),ENV_VAR_NAME.'=');
+ array_push($opener_stack,$new_level);
+ $this->Application->StoreVar('opener_stack',serialize($opener_stack));
+
+ $this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate');
+ }
+
+ /**
+ * 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)
+ {
+ $sql_parts['ItemName'][] = sprintf($sql_templates['ItemName'], $config_data['TableName'], $config_data['TitleField']);
+ $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;
+ }
+
+ /**
+ * 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'];
+ $configs[$prefix] = $this->Application->getUnitOptions($prefix);
+ if($configs[$prefix] === false) 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.4.2/kernel/units/relationship/relationship_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/kernel/units/reviews/reviews_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/kernel/units/reviews/reviews_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/kernel/units/reviews/reviews_event_handler.php (revision 4935)
@@ -0,0 +1,173 @@
+<?php
+
+ class ReviewsEventHandler extends InpDBEventHandler
+ {
+ /**
+ * Checks permissions of user
+ *
+ * @param kEvent $event
+ */
+ function CheckPermission(&$event)
+ {
+ if ($event->Name == 'OnAddReview') {
+ $item_prefix = $this->getPermPrefix($event);
+ return $this->Application->CheckPermission($item_prefix.'.REVIEW.PENDING', 0) || $this->Application->CheckPermission($item_prefix.'.REVIEW', 0);
+ }
+
+ return parent::CheckPermission($event);
+ }
+
+ /**
+ * Returns prefix for permissions
+ *
+ * @param kEvent $event
+ */
+ function getPermPrefix(&$event)
+ {
+ $main_prefix = $this->Application->GetTopmostPrefix($event->Prefix);
+ // this will return LINK for l, ARTICLE for n, TOPIC for bb, PRODUCT for p
+ $item_prefix = $this->Application->getUnitOption($main_prefix, 'PermItemPrefix');
+
+ return $item_prefix;
+ }
+
+
+ /**
+ * Apply any custom changes to list's sql query
+ *
+ * @param kEvent $event
+ * @access protected
+ * @see OnListBuild
+ */
+ function SetCustomQuery(&$event)
+ {
+ $object =& $event->getObject();
+ switch ($event->Special)
+ {
+ case 'showall':
+ $object->clearFilters();
+ break;
+
+ case 'products':
+ $object->removeFilter('parent_filter'); // this is important
+ $object->addFilter('product_reviews', '%1$s.ItemId = pr.ResourceId');
+ // $object->addFilter('active', '%1$s.Status = 1');
+
+ /*$this->Application->setUnitOption('p', 'AutoLoad', true);
+ $product =& $this->Application->recallObject('p');
+ $object->addFilter('current_product', 'pr.ResourceId = '.$product->GetDBField('ResourceId'));*/
+ break;
+
+ case 'product':
+ $object->clearFilters();
+ $object->addFilter('product_reviews', '%1$s.ItemId = pr.ResourceId');
+ $object->addFilter('active', '%1$s.Status = 1');
+ $this->Application->setUnitOption('p', 'AutoLoad', true);
+ $product =& $this->Application->recallObject('p');
+ $object->addFilter('current_product', 'pr.ResourceId = '.$product->GetDBField('ResourceId'));
+
+ break;
+ }
+
+ if($event->getEventParam('type') == 'current_user')
+ {
+ $user_id = $this->Application->GetVar('u_id') ? $this->Application->GetVar('u_id') : -2;
+ $ip = $_SERVER['REMOTE_ADDR'];
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $object =& $event->getObject();
+ $product_info = $object->getLinkedInfo();
+ $object->addFilter('current_item', '%1$s.ItemId = '.$product_info['ParentId']);
+ $object->addFilter('current_user', '%1$s.CreatedById = '.$user_id);
+ $object->addFilter('current_ip', '%1$s.IPAddress = "'.$ip.'"');
+
+ }
+ }
+
+ /**
+ * Adds review from front in case if user is logged in
+ *
+ * @param kEvent $event
+ */
+ function OnAddReview(&$event)
+ {
+ $user_id = ($this->Application->GetVar('u_id') == 0) ? -2 : $this->Application->GetVar('u_id');
+ $event->redirect_params = Array('pass' => 'all,p');
+
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $object =& $event->getObject();
+ $item_info = $this->Application->GetVar('rev_product');
+ $product_info = $object->getLinkedInfo();
+
+ $sql = ' SELECT * FROM '.TABLE_PREFIX.'SpamControl
+ WHERE ItemResourceId='.$product_info['ParentId'].'
+ AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'"
+ AND PortalUserId='.$user_id.'
+ AND DataType="Review"';
+ $res = $this->Conn->GetRow($sql);
+
+ if( $res && $res['Expire'] < adodb_mktime() )
+ {
+ $sql = ' DELETE FROM '.TABLE_PREFIX.'SpamControl
+ WHERE ItemResourceId='.$product_info['ParentId'].'
+ AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'"
+ AND PortalUserId='.$user_id.'
+ AND DataType="Review"';
+ $this->Conn->Query($sql);
+ unset($res);
+ }
+
+ if(!$res)
+ {
+ $object->SetFieldsFromHash( array_shift($item_info) );
+ $object->SetDBField('CreatedById', $user_id);
+ $object->SetDBField('IPAddress', $_SERVER['REMOTE_ADDR']);
+ $object->SetDBField('CreatedOn', adodb_mktime());
+
+ if( $this->Application->CheckPermission('PRODUCT.REVIEW.PENDING', 0) )
+ {
+ $object->SetDBField('Status', 2);
+ }
+ elseif( $this->Application->CheckPermission('PRODUCT.REVIEW', 0) )
+ {
+ $object->SetDBField('Status', 1);
+ }
+
+ $object->SetDBField('ItemId', $product_info['ParentId']);
+
+ $event->CallSubEvent('OnCreate');
+
+ if($event->status == erSUCCESS)
+ {
+ $product_object =& $this->Application->recallObject('p');
+ $sql = ' SELECT COUNT(ReviewId)
+ FROM '.$object->TableName.'
+ WHERE ItemId='.$product_info['ParentId'];
+ $review_qty = $this->Conn->GetOne($sql);
+ $product_object->SetDBField('CachedReviewsQty', $review_qty);
+ $product_object->Update();
+ $expire = adodb_mktime() + $this->Application->ConfigValue('product_ReviewDelay_Value') * $this->Application->ConfigValue('product_ReviewDelay_Interval');
+ $sql = ' INSERT INTO '.TABLE_PREFIX.'SpamControl
+ (ItemResourceId, IPaddress, PortalUserId, DataType, Expire)
+ VALUES ('.$product_info['ParentId'].',
+ "'.$_SERVER['REMOTE_ADDR'].'",
+ '.$user_id.',
+ "Review",
+ '.$expire.')';
+ $this->Conn->Query($sql);
+
+ $event->redirect_params = Array('pass' => 'all,p');
+ $event->redirect = $this->Application->GetVar('success_template');
+ }
+ }
+ else
+ {
+ $this->Application->removeObject($event->getPrefixSpecial());
+ $event->status == erFAIL;
+ $event->redirect=false;
+ $object->FieldErrors['ReviewText']['pseudo'] = 'too_frequent';
+ $object->ErrorMsgs['too_frequent'] = $this->Application->Phrase('lu_ferror_review_duplicate');
+ }
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.2/kernel/units/reviews/reviews_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/kernel/units/general/xml_helper.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/kernel/units/general/xml_helper.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/kernel/units/general/xml_helper.php (revision 4935)
@@ -0,0 +1,200 @@
+<?php
+
+class kXMLHelper extends kHelper {
+ var $RootElement = null;
+
+ /**
+ * Enter description here...
+ *
+ * @var kXMLNode
+ */
+ var $CurrentElement = null;
+
+ /**
+ * Parses XML data specified and returns root node
+ *
+ * @param string $xml
+ * @return kXMLNode
+ */
+ function &Parse($xml = null)
+ {
+ $xml_parser = xml_parser_create();
+ xml_set_element_handler( $xml_parser, Array(&$this, 'startElement'), Array(&$this, 'endElement') );
+ xml_set_character_data_handler( $xml_parser, Array(&$this, 'characterData') );
+ if (!xml_parse($xml_parser, $xml, 1)) {
+ trigger_error(sprintf('XML error: %s at line %d'),
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser), E_USER_WARNING);
+ }
+ xml_parser_free($xml_parser);
+ return $this->RootElement;
+ }
+
+ function startElement(&$Parser, &$Elem, $Attrs)
+ {
+ $parent =& $this->CurrentElement;
+ $this->CurrentElement =& new kXMLNode($Elem, $Attrs);
+ if (is_null($this->RootElement)) {
+ $this->RootElement =& $this->CurrentElement;
+ }
+ if (!is_null($parent)) {
+ $parent->AddChild($this->CurrentElement);
+ }
+ }
+
+ function characterData($Parser, $Line)
+ {
+ $this->CurrentElement->AppendData($Line);
+ }
+
+ function endElement($Parser, $Elem)
+ {
+ if ($this->CurrentElement->Parent != null) {
+ $this->CurrentElement =& $this->CurrentElement->Parent;
+ }
+ }
+
+ function Clear()
+ {
+ $this->RootElement = null;
+ $this->CurrentElement = null;
+ }
+}
+
+class kXMLNode {
+ var $Name = null;
+ var $Attributes = array();
+ var $Children = array();
+ var $Data = null;
+
+ var $firstChild = null;
+ var $lastChild = null;
+ /**
+ * Parent node
+ *
+ * @var kXMLNode
+ */
+ var $Parent = null;
+ /**
+ * Node position relative to other nodes of it's parent
+ *
+ * @var int
+ */
+ var $Position = 0;
+
+ function kXMLNode($name, $attrs = array())
+ {
+ $this->Name = $name;
+ $this->Attributes = $attrs;
+ }
+
+ function SetParent(&$elem)
+ {
+ $this->Parent =& $elem;
+ }
+
+ /**
+ * Adds new child to current node
+ *
+ * @param kXMLNode $a_child
+ */
+ function AddChild(&$a_child)
+ {
+ $node_count = count($this->Children);
+ $a_child->Position = $node_count;
+
+ if ($node_count == 0) {
+ $this->firstChild =& $a_child;
+ $this->lastChild =& $a_child;
+ }
+ else {
+ $this->lastChild =& $a_child;
+ }
+
+ $this->Children[] =& $a_child;
+ $a_child->SetParent($this);
+ }
+
+ function AppendData($data)
+ {
+ $this->Data .= $data;
+ }
+
+ function &GetChild($path)
+ {
+ $entries = explode('/', strtoupper($path));
+ $cur = array_shift($entries);
+ if ($cur == $this->Name) $cur = array_shift($entries);
+ if (!$cur) return $this;
+ if (!isset($this->Children[$cur])) return false;
+ $left = implode('/', $entries);
+ if (!$left) return $this->Children[$cur];
+ return $this->Children[$cur]->GetChild($left);
+ }
+
+ function GetChildValue($path)
+ {
+ $child =& $this->GetChild($path);
+ if ($child !== false) {
+ return $child->Data;
+ }
+ }
+
+ function &GetChildByPosition($position)
+ {
+ if ($position < count($this->Children) ) {
+ return $this->Children[$position];
+ }
+ else {
+ $false = false;
+ return $false;
+ }
+ }
+
+ function &FindChild($name)
+ {
+ $name = strtoupper($name);
+ if ($this->Name == $name) return $this;
+// if (isset($this->Children[$name])) return $this->Children[$name];
+// $children = array_keys($this->Children);
+ foreach ($this->Children as $elem)
+ {
+ $child =& $elem->FindChild($name);
+ if ($child !== false)
+ {
+ return $child;
+ }
+ }
+ return false;
+ }
+
+ function FindChildValue($name, $attr=null)
+ {
+ $child =& $this->FindChild($name);
+ if ($child !== false) {
+ if (isset($attr)) {
+ return $child->Attributes[strtoupper($attr)];
+ }
+ return $child->Data;
+ }
+ }
+
+ /**
+ * Returns next node to this, false in case of end list
+ *
+ * @return kXMLNode
+ */
+ function &NextSibling()
+ {
+ if (!is_null($this->Parent)) {
+ $ret =& $this->Parent->GetChildByPosition($this->Position + 1);
+ return $ret;
+ }
+ else {
+ $false = false;
+ return $false;
+ }
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.2/kernel/units/general/xml_helper.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/kernel/admin_templates/custom_fields/custom_fields_list.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/kernel/admin_templates/custom_fields/custom_fields_list.tpl (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/kernel/admin_templates/custom_fields/custom_fields_list.tpl (revision 4935)
@@ -0,0 +1,69 @@
+<inp2:m_RequireLogin perm_event="cf:OnLoad" system="1"/>
+<inp2:m_include t="incs/header" nobody="yes"/>
+
+<body topmargin="0" leftmargin="8" marginheight="0" marginwidth="8" bgcolor="#FFFFFF">
+<inp2:m_ParseBlock name="section_header" prefix="cf" icon="icon46_settings_custom" title="!la_tab_ConfigCustom!"/>
+
+<inp2:m_ParseBlock name="blue_bar" prefix="cf" title_preset="custom_fields_list" module="in-portal" icon="icon46_settings_custom"/>
+
+<!-- ToolBar --->
+<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
+<tbody>
+ <tr>
+ <td>
+ <script type="text/javascript">
+ //do not rename - this function is used in default grid for double click!
+ function edit()
+ {
+ std_edit_item('cf', 'custom_fields/custom_fields_edit');
+ }
+
+ var a_toolbar = new ToolBar();
+ a_toolbar.AddButton( new ToolBarButton('new_item', '<inp2:m_phrase label="la_ToolTip_New_CustomField" escape="1"/>',
+ function() {
+ std_precreate_item('cf', 'custom_fields/custom_fields_edit')
+ } ) );
+
+ a_toolbar.AddButton( new ToolBarButton('edit', '<inp2:m_phrase label="la_ToolTip_Edit" escape="1"/>', edit) );
+ a_toolbar.AddButton( new ToolBarButton('delete', '<inp2:m_phrase label="la_ToolTip_Delete" escape="1"/>',
+ function() {
+ std_delete_items('cf')
+ } ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep1') );
+ <inp2:m_if check="m_isDebugMode">
+
+ a_toolbar.AddButton( new ToolBarButton('clone', '<inp2:m_phrase label="la_ToolTip_Clone" escape="1"/>',
+ function() {
+ submit_event('cf', 'OnMassClone')
+ } ) );
+
+ a_toolbar.AddButton( new ToolBarSeparator('sep2') );
+ </inp2:m_if>
+ a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
+ show_viewmenu(a_toolbar,'view');
+ }
+ ) );
+
+ a_toolbar.Render();
+ </script>
+ </td>
+ </tr>
+</tbody>
+</table>
+
+<inp2:m_block name="cf_grid_data_td" />
+ <td valign="top" class="text"><inp2:$PrefixSpecial_field field="$field" grid="$grid" no_special="no_special" as_label="1" /></td>
+<inp2:m_blockend />
+
+
+<inp2:m_block name="preview" />
+ <inp2:m_ParseBlock name="preview_td" PrefixSpecial="$PrefixSpecial" field="$field" type="auto" max_width="100" max_height="100"/>
+<inp2:m_blockend />
+
+<inp2:m_ParseBlock name="grid" PrefixSpecial="cf" IdField="CustomFieldId" grid="Default" header_block="grid_column_title" data_block="grid_data_td" search="on"/>
+<script type="text/javascript">
+ Grids['cf'].SetDependantToolbarButtons( new Array('edit','delete', 'clone') );
+</script>
+
+<inp2:m_include t="incs/footer"/>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.2/kernel/admin_templates/custom_fields/custom_fields_list.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/tools/cron.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/tools/cron.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/tools/cron.php (revision 4935)
@@ -0,0 +1,25 @@
+<?php
+
+define('FULL_PATH', realpath(dirname(__FILE__).'/..'));
+define('REL_PATH', 'tools/');
+define('APPLICATION_CLASS', 'MyApplication');
+define('ADMIN', 1);
+
+include_once(FULL_PATH.'/kernel/kernel4/startup.php');
+
+$application =& kApplication::Instance();
+$application->Init();
+
+$event_manager =& $application->recallObject('EventManager');
+$event_manager->RunRegularEvents(reBEFORE, true);
+$event_manager->RunRegularEvents(reAFTER, true);
+
+echo '<html><body></body></html>';
+
+function getmicrotime()
+{
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.2/tools/cron.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/themes/default/register/register_form.tpl
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/themes/default/register/register_form.tpl (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/themes/default/register/register_form.tpl (revision 4935)
@@ -0,0 +1,178 @@
+ <!-- profile content -->
+ <FORM method="POST" NAME="register" ACTION="<inp:m_form_action _Form="m_register" _ConfirmTemplate="register/register_confirm.tpl" _NotAllowedTemplate="register/register_notallowed.tpl" _PendingTemplate="register/register_pending.tpl" _LoginTemplate="my_account.tpl"/>">
+ <table border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td colspan="4">
+ <table border="0" cellspacing="0" cellpadding="0">
+ <tr>
+ <td><h2><inp:m_language _Phrase="lu_login_information" /></h2></td>
+ <td><img src="img/s.gif" width="10" height="1" alt="" /><br /></td>
+ <td class="tips">(<span class="error">*</span><inp:m_language _Phrase="lu_required_field" />)</td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="4" class="error"><inp:m_form_has_errors _Form="m_register" /></td>
+ </tr>
+ <tr>
+ <td colspan="4" class="bgr-updatefill"><img src="img/s.gif" width="300" height="1" alt="" /><br /></td>
+ </tr>
+ <tr>
+ <td colspan="4"><img src="img/s.gif" width="1" height="5" alt="" /><br /></td>
+ </tr>
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="username" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" _langtext="lu_username" /> <span class="error">*</span></td>
+ <td><img src="img/s.gif" width="5" height="1" alt="" /><br /></td>
+ <td><inp:m_form_input type="text" class="input" style="width:135px;" _field="username" _Form="m_register" _Required="1" /><br /></td>
+ </tr>
+ <inp:m_autopassword _Value="false">
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="password" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" _langtext="lu_password" /> <span class="error">*</span></td>
+ <td> </td>
+ <td><inp:m_form_input type="password" class="input" _field="password" _Form="m_register" _Required="1" style="width:135px;" /><br /></td>
+ </tr>
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="passwordverify" _langtext="lu_password_again" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" /> <span class="error">*</span></td>
+ <td> </td>
+ <td><inp:m_form_input type="password" class="input" _field="passwordverify" _Form="m_register" _Required="1" style="width:135px;" /><br /></td>
+ </tr>
+ </inp>
+ <tr>
+ <td colspan=4><!-- <inp:m_autopassword _Value="true" _LangText="lu_register_autopasswd" /> --></td>
+ </tr>
+ <tr>
+ <td colspan="4"><img src="img/s.gif" width="1" height="20" alt="" /><br /></td>
+ </tr>
+ <tr>
+ <td colspan="4"><h2><inp:m_language _Phrase="lu_contact_information" /></h2></td>
+ <tr>
+ <tr>
+ <td colspan="4" class="error"><img src="img/s.gif" width="1" height="3" alt="" /><br /></td>
+ </tr>
+ <tr>
+ <td colspan="4" class="bgr-updatefill"><img src="img/s.gif" width="300" height="1" alt="" /><br /></td>
+ </tr>
+ <tr>
+ <td colspan="4"><img src="img/s.gif" width="1" height="5" alt="" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="firstname" _langtext="lu_pp_firstname" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" /> <span class="error">*</span></td>
+ <td><img src="img/s.gif" width="5" height="1" alt="" /><br /></td>
+ <td><inp:m_form_input _field="firstname" _Form="m_register" _Required="1" type="text" class="input" style="width:135px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="lastname" _langtext="lu_pp_lastname" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" /></td>
+ <td> </td>
+ <td><inp:m_form_input _field="lastname" _Form="m_register" type="text" class="input" style="width:135px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="company" _langtext="lu_pp_company" _Template="misc/form_prompt" _ErrorTemplate="misc/form_prompt_error" /></td>
+ <td> </td>
+ <td><inp:m_form_input _field="company" _Form="m_register" type="text" class="input" style="width:135px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="phone" _langtext="lu_pp_phone" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" /></td>
+ <td> </td>
+ <td><inp:m_form_input _field="phone" _Form="m_register" type="text" class="input" style="width:135px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="fax" _langtext="lu_pp_fax" _Template="misc/form_prompt" _ErrorTemplate="misc/form_prompt_error" /></td>
+ <td> </td>
+ <td><inp:m_form_input _field="fax" _Form="m_register" type="text" class="input" style="width:135px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="email" _langtext="lu_pp_email" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" /> <span class="error">*</span></td>
+ <td> </td>
+ <td><inp:m_form_input _field="email" _Required="1" _Form="m_register" type="text" class="input" style="width:135px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="dob" _langtext="lu_pp_dob" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" /> <span class="error">*</span> (<inp:m_lang_dateformat />)</td>
+ <td> </td>
+ <td><inp:include _Template="register/register_dob.tpl" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="street" _langtext="lu_pp_street" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt.tpl" /></td>
+ <td><img src="img/s.gif" width="5" height="1" alt="" /><br /></td>
+ <td><inp:m_form_input _field="street" _Form="m_register" type="text" class="input" style="width:135px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="street2" _langtext="lu_pp_street2" _Template="misc/form_prompt" _ErrorTemplate="misc/form_prompt" /></td>
+ <td><img src="img/s.gif" width="5" height="1" alt="" /><br /></td>
+ <td><inp:m_form_input _field="street2" _Form="m_register" type="text" class="input" style="width:135px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="phone" _langtext="lu_pp_city" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" /></td>
+ <td> </td>
+ <td><inp:m_form_input _field="city" _Form="m_register" type="text" class="input" style="width:135px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="state" _langtext="lu_pp_state" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" /></td>
+ <td> </td>
+ <td><inp:m_form_input _field="state" _Form="m_register" type="text" class="input" style="width:50px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="zip" _langtext="lu_pp_zip" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" /></td>
+ <td> </td>
+ <td><inp:m_form_input _field="zip" _Form="m_register" type="text" class="input" style="width:50px;" /><br /></td>
+ </tr>
+
+ <tr>
+ <td><img src="img/s.gif" width="16" height="1" alt="" /><br /></td>
+ <td><inp:m_form_prompt _Form="m_register" _Field="zip" _langtext="lu_pp_country" _Template="misc/form_prompt.tpl" _ErrorTemplate="misc/form_prompt_error.tpl" /></td>
+ <td> </td>
+ <td><SELECT name="country" class="input" style="width:135px;">
+ <inp:lang_include _Language="english" _Template="register/english_countries.tpl" />
+ </SELECT>
+ </td>
+ </tr>
+
+ <tr>
+ <td colspan="4"><img src="img/s.gif" width="1" height="20" alt="" /><br /></td>
+ </tr>
+
+ <!-- buttons -->
+ <tr>
+ <td colspan="4"><img src="img/s.gif" width="1" height="3" alt="" /><br /></td>
+ </tr>
+ <tr>
+ <td colspan="4" class="bgr-updatefill"><img src="img/s.gif" width="300" height="1" alt="" /><br /></td>
+ </tr>
+ <tr>
+ <td colspan="4">
+ <img src="img/s.gif" width="1" height="3" alt="" /><br />
+ <INPUT type="submit" name="buttons[]" value="<inp:m_language _Phrase="lu_register" />" class="button">
+ <INPUT type="submit" name="buttons[]" value="<inp:m_language _Phrase="la_cancel" />" class="button">
+ </td>
+ </tr>
+ <!-- end buttons -->
+ </table>
+ </FORM>
+ <!-- end profile content -->
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.2/themes/default/register/register_form.tpl
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/admin/category/category_items.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/admin/category/category_items.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/admin/category/category_items.php (revision 4935)
@@ -0,0 +1,54 @@
+<?php
+ require_once (FULL_PATH.'/admin/include/elements.php');
+ require_once (FULL_PATH.'/kernel/admin/include/navmenu.php');
+ require_once(FULL_PATH.'/admin/toolbar.php');
+ require_once(FULL_PATH.'/admin/listview/listview.php');
+
+ $objEditItems = new clsCatList();
+ $objEditItems->SourceTable = $objSession->GetEditTable("Category");
+
+ $application->SetVar('c_mode', 't');
+
+ // Multiedit init
+ $en = (int)$_GET['en'];
+ $objEditItems->Query_Item("SELECT * FROM ".$objEditItems->SourceTable);
+
+ $itemcount=$objEditItems->NumItems();
+ $c = $objEditItems->GetItemByIndex($en);
+
+ if ($itemcount > 1) {
+ $en_next = ($en + 1 == $itemcount) ? -1 : $en + 1;
+ $en_prev = ($en == 0) ? -1 : $en - 1;
+ }
+
+ $TitleVerb = prompt_language('la_Text_Editing');
+
+ $envar = 'env='.BuildEnv().'&en='.$en;
+ $section = 'in-portal:editcategory_items';
+
+ $editing_category_title = $c->Get('Name') ? "'".$c->Get('Name')."'" : '';
+ $title = $TitleVerb.' '.prompt_language('la_Text_Category').' '.$editing_category_title.' - '.prompt_language('la_tab_General');
+
+ //$saveURL = $admin."/browse.php";
+ $saveURL = $admin.'/category/category_maint.php';
+ $cancelURL = $admin.'/'.$objSession->GetVariable('ReturnScript');
+
+ //Display header
+ $sec = $objSections->GetSection($section);
+
+ $additional_env = '&t=category/category_items&prefix=c';
+
+ $objCatToolBar = new clsToolBar();
+ $objCatToolBar->Add("img_save", "la_Save","#","swap('img_save','toolbar/tool_select_f2.gif');", "swap('img_save', 'toolbar/tool_select.gif');","edit_submit('category','CatEditStatus','$saveURL',1,'$additional_env');","tool_select.gif");
+ $objCatToolBar->Add("img_cancel", "la_Cancel","#","swap('img_cancel','toolbar/tool_cancel_f2.gif');", "swap('img_cancel', 'toolbar/tool_cancel.gif');","edit_submit('category','CatEditStatus','$cancelURL',2,'$additional_env');","tool_cancel.gif");
+
+ if (isset($en_prev) || isset($en_next)) {
+ $url = 'admin/index4_direct.php';
+ $StatusField = 'CatEditStatus';
+ $form = 'category';
+ MultiEditButtons($objCatToolBar,$en_next,$en_prev,$form,$StatusField,$url,$sec->Get("OnClick"), $additional_env,'la_PrevCategory','la_NextCategory');
+ }
+
+ define('REQUIRED_BASE_HREF', 1);
+ int_header($objCatToolBar,NULL,$title);
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.2/admin/category/category_items.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/core/units/relationship/relationship_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/core/units/relationship/relationship_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/core/units/relationship/relationship_event_handler.php (revision 4935)
@@ -0,0 +1,194 @@
+<?php
+
+ class RelationshipEventHandler extends InpDBEventHandler
+ {
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array(
+ 'OnAddRelation' => Array('subitem' => 'add|edit'),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Add new relation
+ *
+ * @param kEvent $event
+ */
+ function OnAddRelation(&$event)
+ {
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $object =& $event->getObject();
+
+ $table_info = $object->getLinkedInfo();
+ $main_item_type = $this->Application->getUnitOption($table_info['ParentPrefix'],'ItemType');
+
+ $target['id'] = $this->Application->GetVar('TargetId');
+ $target['type'] = $this->Application->GetVar('TargetType');
+
+
+ $object->SetDBField($table_info['ForeignKey'], $table_info['ParentId']);
+ $object->SetDBField('SourceType', $main_item_type);
+ $object->SetDBField('TargetId', $target['id']);
+ $object->SetDBField('TargetType', $target['type']);
+
+ // 1. get item info used in relation
+ $configs = $this->extractModulesInfo();
+ foreach($configs as $prefix => $config_data)
+ {
+ if($config_data['ItemType'] == $target['type']) break;
+ }
+
+ // this forces prepareOptions of kMultiLanguge formatter to substiture title field (if multilingual) of target item
+ // BUT this is not the solution, find out another way to get correct title field here
+
+ $target_object =& $this->Application->recallObject($prefix, null, Array('skip_autoload' => true));
+ $title_field = $this->Application->getUnitOption($prefix, 'TitleField');
+
+ $item['name'] = $this->Conn->GetOne('SELECT '.$title_field.' FROM '.$config_data['TableName'].' WHERE ResourceId = '.$target['id']);
+ $item['type'] = $this->Application->Phrase($config_data['TitlePhrase']);
+ $object->SetDBField('ItemName', $item['name']);
+ $object->SetDBField('ItemType', $item['type']);
+
+ $object->setID(0);
+
+ $event->redirect = false;
+
+ // 2. substitute opener
+ $opener_stack = $this->Application->RecallVar('opener_stack');
+ $opener_stack = $opener_stack ? unserialize($opener_stack) : Array();
+ array_pop($opener_stack);
+
+ $return_template = $this->Application->RecallVar('return_template');
+ $new_level = 'index4.php|'.ltrim($this->Application->BuildEnv($return_template, Array('m_opener'=>'u'),'all'),ENV_VAR_NAME.'=');
+ array_push($opener_stack,$new_level);
+ $this->Application->StoreVar('opener_stack',serialize($opener_stack));
+
+ $this->Application->SetVar($event->Prefix_Special.'_SaveEvent','OnCreate');
+ }
+
+ /**
+ * 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)
+ {
+ $sql_parts['ItemName'][] = sprintf($sql_templates['ItemName'], $config_data['TableName'], $config_data['TitleField']);
+ $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;
+ }
+
+ /**
+ * 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'];
+ $configs[$prefix] = $this->Application->getUnitOptions($prefix);
+ if($configs[$prefix] === false) 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.4.2/core/units/relationship/relationship_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/core/units/reviews/reviews_event_handler.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/core/units/reviews/reviews_event_handler.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/core/units/reviews/reviews_event_handler.php (revision 4935)
@@ -0,0 +1,173 @@
+<?php
+
+ class ReviewsEventHandler extends InpDBEventHandler
+ {
+ /**
+ * Checks permissions of user
+ *
+ * @param kEvent $event
+ */
+ function CheckPermission(&$event)
+ {
+ if ($event->Name == 'OnAddReview') {
+ $item_prefix = $this->getPermPrefix($event);
+ return $this->Application->CheckPermission($item_prefix.'.REVIEW.PENDING', 0) || $this->Application->CheckPermission($item_prefix.'.REVIEW', 0);
+ }
+
+ return parent::CheckPermission($event);
+ }
+
+ /**
+ * Returns prefix for permissions
+ *
+ * @param kEvent $event
+ */
+ function getPermPrefix(&$event)
+ {
+ $main_prefix = $this->Application->GetTopmostPrefix($event->Prefix);
+ // this will return LINK for l, ARTICLE for n, TOPIC for bb, PRODUCT for p
+ $item_prefix = $this->Application->getUnitOption($main_prefix, 'PermItemPrefix');
+
+ return $item_prefix;
+ }
+
+
+ /**
+ * Apply any custom changes to list's sql query
+ *
+ * @param kEvent $event
+ * @access protected
+ * @see OnListBuild
+ */
+ function SetCustomQuery(&$event)
+ {
+ $object =& $event->getObject();
+ switch ($event->Special)
+ {
+ case 'showall':
+ $object->clearFilters();
+ break;
+
+ case 'products':
+ $object->removeFilter('parent_filter'); // this is important
+ $object->addFilter('product_reviews', '%1$s.ItemId = pr.ResourceId');
+ // $object->addFilter('active', '%1$s.Status = 1');
+
+ /*$this->Application->setUnitOption('p', 'AutoLoad', true);
+ $product =& $this->Application->recallObject('p');
+ $object->addFilter('current_product', 'pr.ResourceId = '.$product->GetDBField('ResourceId'));*/
+ break;
+
+ case 'product':
+ $object->clearFilters();
+ $object->addFilter('product_reviews', '%1$s.ItemId = pr.ResourceId');
+ $object->addFilter('active', '%1$s.Status = 1');
+ $this->Application->setUnitOption('p', 'AutoLoad', true);
+ $product =& $this->Application->recallObject('p');
+ $object->addFilter('current_product', 'pr.ResourceId = '.$product->GetDBField('ResourceId'));
+
+ break;
+ }
+
+ if($event->getEventParam('type') == 'current_user')
+ {
+ $user_id = $this->Application->GetVar('u_id') ? $this->Application->GetVar('u_id') : -2;
+ $ip = $_SERVER['REMOTE_ADDR'];
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $object =& $event->getObject();
+ $product_info = $object->getLinkedInfo();
+ $object->addFilter('current_item', '%1$s.ItemId = '.$product_info['ParentId']);
+ $object->addFilter('current_user', '%1$s.CreatedById = '.$user_id);
+ $object->addFilter('current_ip', '%1$s.IPAddress = "'.$ip.'"');
+
+ }
+ }
+
+ /**
+ * Adds review from front in case if user is logged in
+ *
+ * @param kEvent $event
+ */
+ function OnAddReview(&$event)
+ {
+ $user_id = ($this->Application->GetVar('u_id') == 0) ? -2 : $this->Application->GetVar('u_id');
+ $event->redirect_params = Array('pass' => 'all,p');
+
+ $this->Application->setUnitOption($event->Prefix,'AutoLoad',false);
+ $object =& $event->getObject();
+ $item_info = $this->Application->GetVar('rev_product');
+ $product_info = $object->getLinkedInfo();
+
+ $sql = ' SELECT * FROM '.TABLE_PREFIX.'SpamControl
+ WHERE ItemResourceId='.$product_info['ParentId'].'
+ AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'"
+ AND PortalUserId='.$user_id.'
+ AND DataType="Review"';
+ $res = $this->Conn->GetRow($sql);
+
+ if( $res && $res['Expire'] < adodb_mktime() )
+ {
+ $sql = ' DELETE FROM '.TABLE_PREFIX.'SpamControl
+ WHERE ItemResourceId='.$product_info['ParentId'].'
+ AND IPaddress="'.$_SERVER['REMOTE_ADDR'].'"
+ AND PortalUserId='.$user_id.'
+ AND DataType="Review"';
+ $this->Conn->Query($sql);
+ unset($res);
+ }
+
+ if(!$res)
+ {
+ $object->SetFieldsFromHash( array_shift($item_info) );
+ $object->SetDBField('CreatedById', $user_id);
+ $object->SetDBField('IPAddress', $_SERVER['REMOTE_ADDR']);
+ $object->SetDBField('CreatedOn', adodb_mktime());
+
+ if( $this->Application->CheckPermission('PRODUCT.REVIEW.PENDING', 0) )
+ {
+ $object->SetDBField('Status', 2);
+ }
+ elseif( $this->Application->CheckPermission('PRODUCT.REVIEW', 0) )
+ {
+ $object->SetDBField('Status', 1);
+ }
+
+ $object->SetDBField('ItemId', $product_info['ParentId']);
+
+ $event->CallSubEvent('OnCreate');
+
+ if($event->status == erSUCCESS)
+ {
+ $product_object =& $this->Application->recallObject('p');
+ $sql = ' SELECT COUNT(ReviewId)
+ FROM '.$object->TableName.'
+ WHERE ItemId='.$product_info['ParentId'];
+ $review_qty = $this->Conn->GetOne($sql);
+ $product_object->SetDBField('CachedReviewsQty', $review_qty);
+ $product_object->Update();
+ $expire = adodb_mktime() + $this->Application->ConfigValue('product_ReviewDelay_Value') * $this->Application->ConfigValue('product_ReviewDelay_Interval');
+ $sql = ' INSERT INTO '.TABLE_PREFIX.'SpamControl
+ (ItemResourceId, IPaddress, PortalUserId, DataType, Expire)
+ VALUES ('.$product_info['ParentId'].',
+ "'.$_SERVER['REMOTE_ADDR'].'",
+ '.$user_id.',
+ "Review",
+ '.$expire.')';
+ $this->Conn->Query($sql);
+
+ $event->redirect_params = Array('pass' => 'all,p');
+ $event->redirect = $this->Application->GetVar('success_template');
+ }
+ }
+ else
+ {
+ $this->Application->removeObject($event->getPrefixSpecial());
+ $event->status == erFAIL;
+ $event->redirect=false;
+ $object->FieldErrors['ReviewText']['pseudo'] = 'too_frequent';
+ $object->ErrorMsgs['too_frequent'] = $this->Application->Phrase('lu_ferror_review_duplicate');
+ }
+ }
+ }
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.2/core/units/reviews/reviews_event_handler.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/core/units/translator/translator_config.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/core/units/translator/translator_config.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/core/units/translator/translator_config.php (revision 4935)
@@ -0,0 +1,52 @@
+<?php
+
+$config = Array(
+ 'Prefix' => 'trans',
+ 'ItemClass' => Array('class'=>'kDBItem','file'=>'','build_event'=>'OnItemBuild'),
+ 'ListClass' => Array('class'=>'kDBList','file'=>'','build_event'=>'OnListBuild'),
+ 'EventHandlerClass' => Array('class'=>'TranslatorEventHandler','file'=>'translator_event_handler.php','build_event'=>'OnBuild'),
+ 'TagProcessorClass' => Array('class'=>'kDBTagProcessor','file'=>'','build_event'=>'OnBuild'),
+ 'AutoLoad' => false,
+ 'hooks' => Array(),
+ 'QueryString' => Array(
+ 1 => 'prefix',
+ 2 => 'field',
+ 3 => 'multi_line',
+ 4 => 'event',
+ ),
+ 'IDField' => 'N/A',
+
+ 'TitleField' => 'Translator',
+
+ 'TitlePhrase' => 'la_text_Translation',
+
+ 'TitlePresets' => Array(
+ 'default' => Array(
+ 'new_status_labels' => Array('trans'=>'!la_title_Adding_Order!'),
+ 'edit_status_labels' => Array('trans'=>'!la_title_Editing_Order!'),
+ 'new_titlefield' => Array('trans'=>'!la_title_New_Order!'),
+ ),
+
+ 'trans_edit' => Array('prefixes' => Array('trans'), 'format' => '!la_title_EditingTranslation!'),
+
+ ),
+ /*
+ 'TableName' => 'N/A',
+
+ 'ListSQLs' => Array( ''=>'SELECT * FROM %s',),
+
+ 'ItemSQLs' => Array( ''=>'SELECT * FROM %s',),*/
+
+ 'Fields' => Array(
+ ),
+
+ 'VirtualFields' => Array(
+ 'Original' => Array(),
+ 'Language' => Array(),
+ 'SwitchLanguage' => Array('formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'Language', 'option_key_field' => 'LanguageId','option_title_field' => 'PackName'),
+ 'Translation' => Array(),
+ ),
+ 'Grids' => Array(),
+ );
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.2/core/units/translator/translator_config.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: branches/unlabeled/unlabeled-1.4.2/core/units/general/xml_helper.php
===================================================================
--- branches/unlabeled/unlabeled-1.4.2/core/units/general/xml_helper.php (nonexistent)
+++ branches/unlabeled/unlabeled-1.4.2/core/units/general/xml_helper.php (revision 4935)
@@ -0,0 +1,200 @@
+<?php
+
+class kXMLHelper extends kHelper {
+ var $RootElement = null;
+
+ /**
+ * Enter description here...
+ *
+ * @var kXMLNode
+ */
+ var $CurrentElement = null;
+
+ /**
+ * Parses XML data specified and returns root node
+ *
+ * @param string $xml
+ * @return kXMLNode
+ */
+ function &Parse($xml = null)
+ {
+ $xml_parser = xml_parser_create();
+ xml_set_element_handler( $xml_parser, Array(&$this, 'startElement'), Array(&$this, 'endElement') );
+ xml_set_character_data_handler( $xml_parser, Array(&$this, 'characterData') );
+ if (!xml_parse($xml_parser, $xml, 1)) {
+ trigger_error(sprintf('XML error: %s at line %d'),
+ xml_error_string(xml_get_error_code($xml_parser)),
+ xml_get_current_line_number($xml_parser), E_USER_WARNING);
+ }
+ xml_parser_free($xml_parser);
+ return $this->RootElement;
+ }
+
+ function startElement(&$Parser, &$Elem, $Attrs)
+ {
+ $parent =& $this->CurrentElement;
+ $this->CurrentElement =& new kXMLNode($Elem, $Attrs);
+ if (is_null($this->RootElement)) {
+ $this->RootElement =& $this->CurrentElement;
+ }
+ if (!is_null($parent)) {
+ $parent->AddChild($this->CurrentElement);
+ }
+ }
+
+ function characterData($Parser, $Line)
+ {
+ $this->CurrentElement->AppendData($Line);
+ }
+
+ function endElement($Parser, $Elem)
+ {
+ if ($this->CurrentElement->Parent != null) {
+ $this->CurrentElement =& $this->CurrentElement->Parent;
+ }
+ }
+
+ function Clear()
+ {
+ $this->RootElement = null;
+ $this->CurrentElement = null;
+ }
+}
+
+class kXMLNode {
+ var $Name = null;
+ var $Attributes = array();
+ var $Children = array();
+ var $Data = null;
+
+ var $firstChild = null;
+ var $lastChild = null;
+ /**
+ * Parent node
+ *
+ * @var kXMLNode
+ */
+ var $Parent = null;
+ /**
+ * Node position relative to other nodes of it's parent
+ *
+ * @var int
+ */
+ var $Position = 0;
+
+ function kXMLNode($name, $attrs = array())
+ {
+ $this->Name = $name;
+ $this->Attributes = $attrs;
+ }
+
+ function SetParent(&$elem)
+ {
+ $this->Parent =& $elem;
+ }
+
+ /**
+ * Adds new child to current node
+ *
+ * @param kXMLNode $a_child
+ */
+ function AddChild(&$a_child)
+ {
+ $node_count = count($this->Children);
+ $a_child->Position = $node_count;
+
+ if ($node_count == 0) {
+ $this->firstChild =& $a_child;
+ $this->lastChild =& $a_child;
+ }
+ else {
+ $this->lastChild =& $a_child;
+ }
+
+ $this->Children[] =& $a_child;
+ $a_child->SetParent($this);
+ }
+
+ function AppendData($data)
+ {
+ $this->Data .= $data;
+ }
+
+ function &GetChild($path)
+ {
+ $entries = explode('/', strtoupper($path));
+ $cur = array_shift($entries);
+ if ($cur == $this->Name) $cur = array_shift($entries);
+ if (!$cur) return $this;
+ if (!isset($this->Children[$cur])) return false;
+ $left = implode('/', $entries);
+ if (!$left) return $this->Children[$cur];
+ return $this->Children[$cur]->GetChild($left);
+ }
+
+ function GetChildValue($path)
+ {
+ $child =& $this->GetChild($path);
+ if ($child !== false) {
+ return $child->Data;
+ }
+ }
+
+ function &GetChildByPosition($position)
+ {
+ if ($position < count($this->Children) ) {
+ return $this->Children[$position];
+ }
+ else {
+ $false = false;
+ return $false;
+ }
+ }
+
+ function &FindChild($name)
+ {
+ $name = strtoupper($name);
+ if ($this->Name == $name) return $this;
+// if (isset($this->Children[$name])) return $this->Children[$name];
+// $children = array_keys($this->Children);
+ foreach ($this->Children as $elem)
+ {
+ $child =& $elem->FindChild($name);
+ if ($child !== false)
+ {
+ return $child;
+ }
+ }
+ return false;
+ }
+
+ function FindChildValue($name, $attr=null)
+ {
+ $child =& $this->FindChild($name);
+ if ($child !== false) {
+ if (isset($attr)) {
+ return $child->Attributes[strtoupper($attr)];
+ }
+ return $child->Data;
+ }
+ }
+
+ /**
+ * Returns next node to this, false in case of end list
+ *
+ * @return kXMLNode
+ */
+ function &NextSibling()
+ {
+ if (!is_null($this->Parent)) {
+ $ret =& $this->Parent->GetChildByPosition($this->Position + 1);
+ return $ret;
+ }
+ else {
+ $false = false;
+ return $false;
+ }
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: branches/unlabeled/unlabeled-1.4.2/core/units/general/xml_helper.php
___________________________________________________________________
Added: cvs2svn:cvs-rev
## -0,0 +1 ##
+1.4
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Event Timeline
Log In to Comment