Index: trunk/core/kernel/db/dbitem.php
===================================================================
diff -u -r8358 -r8428
--- trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 8358)
+++ trunk/core/kernel/db/dbitem.php (.../dbitem.php) (revision 8428)
@@ -73,7 +73,7 @@
* Set's default values for all fields
*
* @param bool $populate_ml_fields create all ml fields from db in config or not
- *
+ *
* @access public
*/
function SetDefaultValues($populate_ml_fields = false)
@@ -82,7 +82,7 @@
if ($populate_ml_fields) {
$this->PopulateMultiLangFields();
}
-
+
foreach ($this->Fields as $field => $params) {
if ( isset($params['default']) ) {
$this->SetDBField($field, $params['default']);
@@ -986,6 +986,18 @@
return $ret;
}
+
+ /**
+ * Returns specified field value from all selected rows.
+ * Don't affect current record index
+ *
+ * @param string $field
+ * @return Array
+ */
+ function GetCol($field)
+ {
+ return Array (0 => $this->GetDBField($field));
+ }
}
Index: trunk/core/units/users/users_event_handler.php
===================================================================
diff -u -r8420 -r8428
--- trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 8420)
+++ trunk/core/units/users/users_event_handler.php (.../users_event_handler.php) (revision 8428)
@@ -900,24 +900,19 @@
*
* @param kEvent $event
*/
- function OnResetPassword(&$event){
+ function OnResetPassword(&$event)
+ {
+ $user_object =& $this->Application->recallObject('u.forgot');
- $user_object = &$this->Application->recallObject('u.forgot');
-
if($user_object->Load($this->Application->RecallVar('tmp_user_id'))){
$this->Application->EmailEventUser('INCOMMERCEUSER.PSWDC', $user_object->GetDBField("PortalUserId"));
$event->redirect = $this->Application->GetVar('template_success');
- $mod_object =& $this->Application->recallObject('mod.'.'In-Commerce');
- $m_cat_id = $mod_object->GetDBField('RootCat');
- $event->SetRedirectParam('pass', 'm');
- //$event->SetRedirectParam('m_cat_id', $m_cat_id);
+ $m_cat_id = $this->Application->findModule('Name', 'In-Commerce', 'RootCat');
$this->Application->SetVar('m_cat_id', $m_cat_id);
-
-
+ $event->SetRedirectParam('pass', 'm');
}
-
}
function OnResetPasswordConfirmed(&$event)
Index: trunk/themes/default2007/platform/my_account/my_favorites.tpl
===================================================================
diff -u
--- trunk/themes/default2007/platform/my_account/my_favorites.tpl (revision 0)
+++ trunk/themes/default2007/platform/my_account/my_favorites.tpl (revision 8428)
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: trunk/themes/default2007/index.tpl
===================================================================
diff -u -r8358 -r8428
--- trunk/themes/default2007/index.tpl (.../index.tpl) (revision 8358)
+++ trunk/themes/default2007/index.tpl (.../index.tpl) (revision 8428)
@@ -1,5 +1,5 @@
-
Index Page
-
\ No newline at end of file
Index: trunk/core/kernel/db/dblist.php
===================================================================
diff -u -r8402 -r8428
--- trunk/core/kernel/db/dblist.php (.../dblist.php) (revision 8402)
+++ trunk/core/kernel/db/dblist.php (.../dblist.php) (revision 8428)
@@ -220,7 +220,7 @@
$filter =& $filter[$filter_scope];
return $filter->getFilter($name);
}
-
+
/**
* Removes specified filter from filters list
*
@@ -350,14 +350,14 @@
$sql = $q.' '.$this->Conn->getLimitClause($this->Offset,$limit);
$this->Records = $this->Conn->Query($sql);
-
+
if (!$this->Records && ($this->Page > 1)) {
// no records & page > 1, try to reset to 1st page (works only when list in not counted before)
$this->Application->StoreVar($this->getPrefixSpecial().'_Page', 1);
$this->SetPage(1);
$this->Query($force);
}
-
+
$this->SelectedCount = count($this->Records);
if (!$this->Counted) $this->RecordsCount = $this->SelectedCount;
if (!$this->Counted && $this->SelectedCount > $this->PerPage && $this->PerPage != -1) $this->SelectedCount--;
@@ -875,7 +875,7 @@
$this->addFilter('parent_filter', '`'.$this->TableName.'`.`'.$foreign_key_field.'` = '.$parent_id); // only for list in this case
}
}
-
+
/**
* Returns true if list was queried (same name as for kDBItem for easy usage)
*
@@ -885,6 +885,25 @@
{
return $this->Queried;
}
+
+ /**
+ * Returns specified field value from all selected rows.
+ * Don't affect current record index
+ *
+ * @param string $field
+ * @return Array
+ */
+ function GetCol($field)
+ {
+ $i = 0;
+ $ret = Array ();
+ while ($i < $this->SelectedCount) {
+ $ret[] = $this->Records[$i][$field];
+ $i++;
+ }
+
+ return $ret;
+ }
}
?>
\ No newline at end of file
Index: trunk/themes/default2007/error_notfound.tpl
===================================================================
diff -u -r8369 -r8428
--- trunk/themes/default2007/error_notfound.tpl (.../error_notfound.tpl) (revision 8369)
+++ trunk/themes/default2007/error_notfound.tpl (.../error_notfound.tpl) (revision 8428)
@@ -1,5 +1,5 @@
-
-
+
@@ -18,9 +18,9 @@
-
+
-
+
\ No newline at end of file
Index: trunk/core/units/categories/categories_event_handler.php
===================================================================
diff -u -r8104 -r8428
--- trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 8104)
+++ trunk/core/units/categories/categories_event_handler.php (.../categories_event_handler.php) (revision 8428)
@@ -89,10 +89,10 @@
{
$category_id = $this->Application->GetVar($event->getPrefixSpecial().'_id');
$this->Application->StoreVar('IsRootCategory_'.$this->Application->GetVar('m_wid'), $category_id === '0');
-
+
parent::OnEdit($event);
}
-
+
/**
* Apply system filter to categories list
*
@@ -118,8 +118,7 @@
if ($parent_cat_id == 'Root') {
$module_name = $event->getEventParam('module') ? $event->getEventParam('module') : 'In-Commerce';
- $module =& $this->Application->recallObject('mod.'.$module_name);
- $parent_cat_id = $module->GetDBField('RootCat');
+ $parent_cat_id = $this->Application->findModule('Name', $module_name, 'RootCat');
}
}
@@ -403,10 +402,10 @@
function OnPreCreate(&$event)
{
$this->Application->RemoveVar('IsRootCategory_'.$this->Application->GetVar('m_wid'));
-
+
parent::OnPreCreate($event);
}
-
+
/**
* Checks cache update mark and redirect to cache if needed
*
@@ -426,7 +425,7 @@
$wid = $this->Application->GetVar('m_wid');
$stack_name = rtrim('opener_stack_'.$wid, '_');
$this->Application->RemoveVar('IsRootCategory_'.$wid);
-
+
$opener_stack = unserialize($this->Application->RecallVar($stack_name));
$opener_stack[0] = str_replace('catalog', 'categories/cache_updater', $opener_stack[0]);
$this->Application->StoreVar($stack_name, serialize($opener_stack));
@@ -444,15 +443,15 @@
{
$object =& $event->getObject( Array('skip_autoload' => true) );
/* @var $object CategoriesItem */
-
+
if ($object->IsRoot()) {
// don't create root category while saving permissions
return ;
}
-
+
parent::OnPreSaveCreated($event);
}
-
+
/**
* Deletes all selected items.
* Automatically recurse into sub-items using temp handler, and deletes sub-items
Index: trunk/core/units/general/cat_event_handler.php
===================================================================
diff -u -r8422 -r8428
--- trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 8422)
+++ trunk/core/units/general/cat_event_handler.php (.../cat_event_handler.php) (revision 8428)
@@ -180,7 +180,11 @@
function getTypeClauses(&$event)
{
$types = $event->getEventParam('types');
+ $types = $types ? explode(',', $types) : Array ();
+
$except_types = $event->getEventParam('except');
+ $except_types = $except_types ? explode(',', $except_types) : Array ();
+
$type_clauses = Array();
$user_id = $this->Application->RecallVar('user_id');
@@ -215,7 +219,7 @@
}
$type_clauses['displayed']['having_filter'] = false;
- if (strpos($types, 'search') !== false || strpos($except_types, 'search') !== false) {
+ if (in_array('search', $types) || in_array('search', $except_types)) {
$event_mapping = Array(
'simple' => 'OnSimpleSearch',
'subsearch' => 'OnSubSearch',
@@ -253,7 +257,7 @@
$type_clauses['search']['having_filter'] = false;
}
- if (strpos($types, 'related') !== false || strpos($except_types, 'related') !== false) {
+ if (in_array('related', $types) || in_array('related', $except_types)) {
$related_to = $event->getEventParam('related_to');
if (!$related_to) {
@@ -307,6 +311,22 @@
$type_clauses['related']['having_filter'] = false;
}
+ if (in_array('favorites', $types) || in_array('favorites', $except_types)) {
+ $sql = 'SELECT ResourceId
+ FROM '.$this->Application->getUnitOption('fav', 'TableName').'
+ WHERE PortalUserId = '.$this->Application->RecallVar('user_id');
+ $favorite_ids = $this->Conn->GetCol($sql);
+ if ($favorite_ids) {
+ $type_clauses['favorites']['include'] = '%1$s.ResourceId IN ('.implode(',', $favorite_ids).') AND PrimaryCat = 1';
+ $type_clauses['favorites']['except'] = '%1$s.ResourceId NOT IN ('.implode(',', $favorite_ids).') AND PrimaryCat = 1';
+ }
+ else {
+ $type_clauses['favorites']['include'] = 0;
+ $type_clauses['favorites']['except'] = 1;
+ }
+ $type_clauses['favorites']['having_filter'] = false;
+ }
+
return $type_clauses;
}
Index: trunk/core/units/favorites/favorites_config.php
===================================================================
diff -u
--- trunk/core/units/favorites/favorites_config.php (revision 0)
+++ trunk/core/units/favorites/favorites_config.php (revision 8428)
@@ -0,0 +1,85 @@
+ 'fav',
+ 'ItemClass' => Array('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
+ 'ListClass' => Array('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
+ 'EventHandlerClass' => Array('class' => 'FavoritesEventHandler', 'file' => 'favorites_eh.php', 'build_event' => 'OnBuild'),
+ 'TagProcessorClass' => Array('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
+
+ 'AutoLoad' => true,
+
+ 'Clones' => Array (
+ 'l-fav' => Array(
+ 'ParentPrefix' => 'l',
+ 'ParentTableKey' => 'ResourceId',
+ 'ForeignKey' => 'ResourceId',
+ ),
+
+ 'n-fav' => Array (
+ 'ParentPrefix' => 'n',
+ 'ParentTableKey' => 'ResourceId',
+ 'ForeignKey' => 'ResourceId',
+ ),
+
+ 'bb-fav' => Array(
+ 'ParentPrefix' => 'bb',
+ 'ParentTableKey' => 'ResourceId',
+ 'ForeignKey' => 'ResourceId',
+ ),
+
+ 'p-fav' => Array(
+ 'ParentPrefix' => 'p',
+ 'ParentTableKey' => 'ResourceId',
+ 'ForeignKey' => 'ResourceId',
+ ),
+ ),
+
+ 'Hooks' => Array (
+ Array(
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => '#PARENT#',
+ 'HookToSpecial' => '-item', // from OnMassDelete event
+ 'HookToEvent' => Array('OnAfterItemDelete'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '',
+ 'DoEvent' => 'OnDeleteFavoriteItem',
+ ),
+ ),
+
+ 'QueryString' => Array (
+ 1 => 'id',
+ 2 => 'page',
+ 3 => 'event',
+ ),
+
+ 'IDField' => 'FavoriteId',
+ 'TableName' => TABLE_PREFIX.'Favorites',
+
+ 'ParentTableKey' => 'PortalUserId',
+ 'ForeignKey' => 'PortalUserId',
+ 'ParentPrefix' => 'u',
+
+ 'AutoDelete' => true,
+ 'AutoClone' => true,
+
+ 'ListSQLs' => Array ('' => 'SELECT * FROM %s'),
+ 'ItemSQLs' => Array ('' => 'SELECT * FROM %s'),
+
+ 'ListSortings' => Array (
+ '' => Array(
+ 'Sorting' => Array('Modified' => 'desc'),
+ )
+ ),
+
+ 'Fields' => Array (
+ 'FavoriteId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0,),
+ 'PortalUserId' => Array('type' => 'int','not_null' => 1, 'default' => 0),
+ 'ResourceId' => Array('type' => 'int','not_null' => 1, 'default' => 0),
+ 'ItemTypeId' => Array('type' => 'int','not_null' => 1, 'default' => 0),
+ 'Modified' => Array('type' => 'int','not_null' => 1, 'default' => '#NOW#'),
+ ),
+ );
+
+?>
\ No newline at end of file
Index: trunk/core/units/favorites/favorites_eh.php
===================================================================
diff -u
--- trunk/core/units/favorites/favorites_eh.php (revision 0)
+++ trunk/core/units/favorites/favorites_eh.php (revision 8428)
@@ -0,0 +1,91 @@
+ Array('subitem' => true),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Adds/removes item from favorites
+ *
+ * @param kEvent $event
+ */
+ function OnFavoriteToggle(&$event)
+ {
+ $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $parent_object =& $this->Application->recallObject($parent_prefix);
+ /* @var $parent_object kDBItem */
+
+ if (!$parent_object->isLoaded() || !$this->Application->CheckPermission('FAVORITES', 0, $parent_object->GetDBField('ParentPath'))) {
+ $event->status = erFAIL;
+ return ;
+ }
+
+ $user_id = $this->Application->RecallVar('user_id');
+ $sql = 'SELECT FavoriteId
+ FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
+ WHERE (PortalUserId = '.$user_id.') AND (ResourceId = '.$parent_object->GetDBField('ResourceId').')';
+ $favorite_id = $this->Conn->GetOne($sql);
+
+ $object =& $event->getObject(Array('skip_autoload' => true));
+ /* @var $object kDBItem */
+
+ if ($favorite_id) {
+ $object->Delete($favorite_id);
+ }
+ else {
+ $object->Create();
+ }
+
+ $event->SetRedirectParam('pass', 'm');
+ }
+
+ /**
+ * Prepares Favorite record fields
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeItemCreate(&$event)
+ {
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $user_id = $this->Application->RecallVar('user_id');
+ $object->SetDBField('PortalUserId', $user_id);
+
+ $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $parent_object =& $this->Application->recallObject($parent_prefix);
+ /* @var $parent_object kDBItem */
+
+ $object->SetDBField('ResourceId', $parent_object->GetDBField('ResourceId'));
+ $object->SetDBField('ItemTypeId', $this->Application->getUnitOption($parent_prefix, 'ItemType'));
+ }
+
+ /**
+ * [HOOK] Deletes favorite record to item, that is beeing deleted
+ *
+ * @param kEvent $event
+ */
+ function OnDeleteFavoriteItem(&$event)
+ {
+ $main_object =& $event->MasterEvent->getObject();
+
+ $sql = 'DELETE FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
+ WHERE ResourceId = '.$main_object->GetDBField('ResourceId');
+ $this->Conn->Query($sql);
+ }
+
+}
+
+
+?>
\ No newline at end of file
Index: trunk/core/kernel/db/db_event_handler.php
===================================================================
diff -u -r8420 -r8428
--- trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 8420)
+++ trunk/core/kernel/db/db_event_handler.php (.../db_event_handler.php) (revision 8428)
@@ -425,6 +425,9 @@
if (!$perm_status) {
// when no permission to view item -> redirect to no pemrission template
+ if ($this->Application->isDebugMode()) {
+ $this->Application->Debugger->appendTrace();
+ }
trigger_error('ItemLoad Permission Failed for prefix ['.$event->getPrefixSpecial().']', E_USER_WARNING);
$next_template = $this->Application->IsAdmin() ? 'no_permission' : $this->Application->ConfigValue('NoPermissionTemplate');
$this->Application->Redirect($next_template, Array('next_template' => $this->Application->GetVar('t')));
Index: trunk/kernel/units/favorites/favorites_config.php
===================================================================
diff -u
--- trunk/kernel/units/favorites/favorites_config.php (revision 0)
+++ trunk/kernel/units/favorites/favorites_config.php (revision 8428)
@@ -0,0 +1,85 @@
+ 'fav',
+ 'ItemClass' => Array('class' => 'kDBItem', 'file' => '', 'build_event' => 'OnItemBuild'),
+ 'ListClass' => Array('class' => 'kDBList', 'file' => '', 'build_event' => 'OnListBuild'),
+ 'EventHandlerClass' => Array('class' => 'FavoritesEventHandler', 'file' => 'favorites_eh.php', 'build_event' => 'OnBuild'),
+ 'TagProcessorClass' => Array('class' => 'kDBTagProcessor', 'file' => '', 'build_event' => 'OnBuild'),
+
+ 'AutoLoad' => true,
+
+ 'Clones' => Array (
+ 'l-fav' => Array(
+ 'ParentPrefix' => 'l',
+ 'ParentTableKey' => 'ResourceId',
+ 'ForeignKey' => 'ResourceId',
+ ),
+
+ 'n-fav' => Array (
+ 'ParentPrefix' => 'n',
+ 'ParentTableKey' => 'ResourceId',
+ 'ForeignKey' => 'ResourceId',
+ ),
+
+ 'bb-fav' => Array(
+ 'ParentPrefix' => 'bb',
+ 'ParentTableKey' => 'ResourceId',
+ 'ForeignKey' => 'ResourceId',
+ ),
+
+ 'p-fav' => Array(
+ 'ParentPrefix' => 'p',
+ 'ParentTableKey' => 'ResourceId',
+ 'ForeignKey' => 'ResourceId',
+ ),
+ ),
+
+ 'Hooks' => Array (
+ Array(
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => '#PARENT#',
+ 'HookToSpecial' => '-item', // from OnMassDelete event
+ 'HookToEvent' => Array('OnAfterItemDelete'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '',
+ 'DoEvent' => 'OnDeleteFavoriteItem',
+ ),
+ ),
+
+ 'QueryString' => Array (
+ 1 => 'id',
+ 2 => 'page',
+ 3 => 'event',
+ ),
+
+ 'IDField' => 'FavoriteId',
+ 'TableName' => TABLE_PREFIX.'Favorites',
+
+ 'ParentTableKey' => 'PortalUserId',
+ 'ForeignKey' => 'PortalUserId',
+ 'ParentPrefix' => 'u',
+
+ 'AutoDelete' => true,
+ 'AutoClone' => true,
+
+ 'ListSQLs' => Array ('' => 'SELECT * FROM %s'),
+ 'ItemSQLs' => Array ('' => 'SELECT * FROM %s'),
+
+ 'ListSortings' => Array (
+ '' => Array(
+ 'Sorting' => Array('Modified' => 'desc'),
+ )
+ ),
+
+ 'Fields' => Array (
+ 'FavoriteId' => Array('type' => 'int', 'not_null' => 1, 'default' => 0,),
+ 'PortalUserId' => Array('type' => 'int','not_null' => 1, 'default' => 0),
+ 'ResourceId' => Array('type' => 'int','not_null' => 1, 'default' => 0),
+ 'ItemTypeId' => Array('type' => 'int','not_null' => 1, 'default' => 0),
+ 'Modified' => Array('type' => 'int','not_null' => 1, 'default' => '#NOW#'),
+ ),
+ );
+
+?>
\ No newline at end of file
Index: trunk/kernel/units/favorites/favorites_eh.php
===================================================================
diff -u
--- trunk/kernel/units/favorites/favorites_eh.php (revision 0)
+++ trunk/kernel/units/favorites/favorites_eh.php (revision 8428)
@@ -0,0 +1,91 @@
+ Array('subitem' => true),
+ );
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
+ /**
+ * Adds/removes item from favorites
+ *
+ * @param kEvent $event
+ */
+ function OnFavoriteToggle(&$event)
+ {
+ $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $parent_object =& $this->Application->recallObject($parent_prefix);
+ /* @var $parent_object kDBItem */
+
+ if (!$parent_object->isLoaded() || !$this->Application->CheckPermission('FAVORITES', 0, $parent_object->GetDBField('ParentPath'))) {
+ $event->status = erFAIL;
+ return ;
+ }
+
+ $user_id = $this->Application->RecallVar('user_id');
+ $sql = 'SELECT FavoriteId
+ FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
+ WHERE (PortalUserId = '.$user_id.') AND (ResourceId = '.$parent_object->GetDBField('ResourceId').')';
+ $favorite_id = $this->Conn->GetOne($sql);
+
+ $object =& $event->getObject(Array('skip_autoload' => true));
+ /* @var $object kDBItem */
+
+ if ($favorite_id) {
+ $object->Delete($favorite_id);
+ }
+ else {
+ $object->Create();
+ }
+
+ $event->SetRedirectParam('pass', 'm');
+ }
+
+ /**
+ * Prepares Favorite record fields
+ *
+ * @param kEvent $event
+ */
+ function OnBeforeItemCreate(&$event)
+ {
+ $object =& $event->getObject();
+ /* @var $object kDBItem */
+
+ $user_id = $this->Application->RecallVar('user_id');
+ $object->SetDBField('PortalUserId', $user_id);
+
+ $parent_prefix = $this->Application->getUnitOption($event->Prefix, 'ParentPrefix');
+ $parent_object =& $this->Application->recallObject($parent_prefix);
+ /* @var $parent_object kDBItem */
+
+ $object->SetDBField('ResourceId', $parent_object->GetDBField('ResourceId'));
+ $object->SetDBField('ItemTypeId', $this->Application->getUnitOption($parent_prefix, 'ItemType'));
+ }
+
+ /**
+ * [HOOK] Deletes favorite record to item, that is beeing deleted
+ *
+ * @param kEvent $event
+ */
+ function OnDeleteFavoriteItem(&$event)
+ {
+ $main_object =& $event->MasterEvent->getObject();
+
+ $sql = 'DELETE FROM '.$this->Application->getUnitOption($event->Prefix, 'TableName').'
+ WHERE ResourceId = '.$main_object->GetDBField('ResourceId');
+ $this->Conn->Query($sql);
+ }
+
+}
+
+
+?>
\ No newline at end of file
Index: trunk/themes/default2007/platform/my_account/my_profile.tpl
===================================================================
diff -u -r8368 -r8428
--- trunk/themes/default2007/platform/my_account/my_profile.tpl (.../my_profile.tpl) (revision 8368)
+++ trunk/themes/default2007/platform/my_account/my_profile.tpl (.../my_profile.tpl) (revision 8428)
@@ -1,19 +1,19 @@
-
-
+
-
+
There is a problem with the form, please check the error messages below.
@@ -22,12 +22,12 @@
-
+
-
+
\ No newline at end of file
Index: trunk/core/units/general/cat_tag_processor.php
===================================================================
diff -u -r8415 -r8428
--- trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 8415)
+++ trunk/core/units/general/cat_tag_processor.php (.../cat_tag_processor.php) (revision 8428)
@@ -261,6 +261,34 @@
return in_array($object->GetDBField('Status'), $pending_status);
}
+ function IsFavorite($params)
+ {
+ static $favorite_status = null;
+
+ $object =& $this->getObject($params);
+ /* @var $object kDBList */
+
+ if (!isset($favorite_status)) {
+ $resource_ids = $object->GetCol('ResourceId');
+
+ $user_id = $this->Application->RecallVar('user_id');
+ $sql = 'SELECT FavoriteId, ResourceId
+ FROM '.$this->Application->getUnitOption('fav', 'TableName').'
+ WHERE (PortalUserId = '.$user_id.') AND (ResourceId IN ('.implode(',', $resource_ids).'))';
+ $favorite_status = $this->Conn->GetCol($sql, 'ResourceId');
+ }
+
+ return isset($favorite_status[$object->GetDBField('ResourceId')]);
+ }
+
+ function FavoriteToggleLink($params)
+ {
+ $fav_prefix = $this->Prefix.'-fav';
+ $params['pass'] = implode(',', Array('m', $this->Prefix, $fav_prefix));
+ $params[$fav_prefix.'_event'] = 'OnFavoriteToggle';
+ return $this->Application->ProcessParsedTag('m', 'Link', $params);
+ }
+
}
?>
\ No newline at end of file
Index: trunk/core/units/categories/categories_tag_processor.php
===================================================================
diff -u -r8402 -r8428
--- trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 8402)
+++ trunk/core/units/categories/categories_tag_processor.php (.../categories_tag_processor.php) (revision 8428)
@@ -5,16 +5,16 @@
function SubCatCount($params)
{
$object =& $this->getObject($params);
-
+
if (isset($params['today']) && $params['today']) {
$sql = 'SELECT COUNT(*)
FROM '.$object->TableName.'
WHERE (ParentPath LIKE "'.$object->GetDBField('ParentPath').'%") AND (CreatedOn > '.(adodb_mktime() - 86400).')';
return $this->Conn->GetOne($sql) - 1;
}
-
+
return $object->GetDBField('CachedDescendantCatsQty');
-
+
}
function IsNew($params)
@@ -78,8 +78,7 @@
function CheckModuleRoot($params)
{
$module_name = getArrayValue($params, 'module') ? $params['module'] : 'In-Commerce';
- $module =& $this->Application->recallObject('mod.'.$module_name);
- $module_root_cat = $module->GetDBField('RootCat');
+ $module_root_cat = $this->Application->findModule('Name', $module_name, 'RootCat');
$additional_cats = $this->SelectParam($params, 'add_cats');
if ($additional_cats) {
@@ -195,7 +194,7 @@
unset($params['cat_id']);
$params['pass_category'] = 1;
-
+
return $this->Application->ProcessParsedTag('m', 't', $params);
}
Index: trunk/core/kernel/processors/main_processor.php
===================================================================
diff -u -r8397 -r8428
--- trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 8397)
+++ trunk/core/kernel/processors/main_processor.php (.../main_processor.php) (revision 8428)
@@ -43,7 +43,7 @@
else {
$path = substr(THEMES_PATH, 1);
$module = isset($params['module']) ? $params['module'] : 'core';
-
+
if (strtolower($module) == 'in-portal') {
$module_folder = 'platform';
}
@@ -141,7 +141,7 @@
{
$params['pass'] = 'all,m';
$params['pass_category'] = 1;
-
+
return $this->Application->HREF('', '', $params);
}
@@ -444,7 +444,7 @@
// m:phrase name="phrase_name" default="Tr-alala" updated="2004-01-29 12:49"
if (array_key_exists('default', $params)) return $params['default']; //backward compatibility
$translation = $this->Application->Phrase($this->SelectParam($params, 'label,name,title'));
-
+
if (getArrayValue($params, 'escape')) {
$translation = htmlspecialchars($translation, ENT_QUOTES);
$translation = addslashes($translation);
@@ -542,7 +542,7 @@
{
$BlockParser =& $this->Application->makeClass('TemplateParser');
/* @var $BlockParser TemplateParser */
-
+
// $BlockParser->SetParams($params);
$parser =& $this->Application->Parser;
$this->Application->Parser =& $BlockParser;
@@ -566,7 +566,7 @@
else {
$res = $BlockParser->ParseTemplate($t, 1, $params, isset($params['is_silent']) ? 1 : 0 );
}
-
+
if (!$BlockParser->DataExists && ((isset($params['data_exists']) && $params['data_exists']) || isset($params['block_no_data']))) {
if ($block_no_data = getArrayValue($params, 'block_no_data')) {
if (isset($this->Application->PreParsedBlocks[$block_no_data]) ) {
@@ -585,12 +585,12 @@
$this->Application->Parser =& $parser;
$this->Application->Parser->DataExists = $this->Application->Parser->DataExists || $BlockParser->DataExists;
-
+
if (isset($params['return_params']) && $params['return_params']) {
$new_params = array_merge($this->Application->Parser->Params, $BlockParser->ParamsStack[0]);
$this->Application->Parser->SetParams($new_params, false);
}
-
+
return $res;
}
@@ -711,21 +711,21 @@
$block_params['return_params'] = 1;
$block_params['strip_nl'] = 2;
$block_content = $this->MyInclude($block_params);
-
+
if (isset($params['data_exists']) && $params['data_exists'] && !$block_content) {
return '';
}
-
+
// prepare design
$block_params = Array (
'content' => $block_content,
);
}
-
+
$block_params['name'] = $params['design'];
return $this->Application->ParseBlock($block_params, 1);
}
-
+
return $this->ParseBlock($params);
}
@@ -964,9 +964,8 @@
function SetDefaultCategory($params)
{
- $module_name = $params['module'];
- $module =& $this->Application->recallObject('mod.'.$module_name);
- $this->Application->SetVar('m_cat_id', $module->GetDBField('RootCat') );
+ $category_id = $this->Application->findModule('Name', $params['module'], 'RootCat');
+ $this->Application->SetVar('m_cat_id', $category_id);
}
function XMLTemplate($params)
Index: trunk/core/kernel/kbase.php
===================================================================
diff -u -r8369 -r8428
--- trunk/core/kernel/kbase.php (.../kbase.php) (revision 8369)
+++ trunk/core/kernel/kbase.php (.../kbase.php) (revision 8428)
@@ -377,7 +377,7 @@
$this->ApplyFieldModifiers(); // should be called only after all fields definitions been set
$this->prepareConfigOptions(); // this should go last, but before setDefaultValues, order is significant!
-
+
$this->SetDefaultValues($populate_ml_fields);
}
@@ -652,6 +652,18 @@
{
return false;
}
+
+ /**
+ * Returns specified field value from all selected rows.
+ * Don't affect current record index
+ *
+ * @param string $field
+ * @return Array
+ */
+ function GetCol($field)
+ {
+ return Array ();
+ }
}
?>
\ No newline at end of file