oc-content/plugins/favorite_items/functions.php
// SHOW LIST OF MOST FAVORITED LISTINGS
SHOW LIST OF MOST FAVORITED LISTINGS
SHOW LIST OF MOST FAVORITED LISTINGS
function fi_most_favorited_items( $limit = 5 ) {
  $aSearch = new Search();
  $aSearch->addField(sprintf('count(%st_item.pk_i_id) as count_id', DB_TABLE_PREFIX) );
  $aSearch->addConditions(sprintf("%st_favorite_list.list_id = %st_favorite_items.list_id", DB_TABLE_PREFIX, DB_TABLE_PREFIX));
  $aSearch->addConditions(sprintf("%st_favorite_items.item_id = %st_item.pk_i_id", DB_TABLE_PREFIX, DB_TABLE_PREFIX));
  $aSearch->addConditions(sprintf("%st_favorite_list.user_id <> coalesce(%st_item.fk_i_user_id, 0)", DB_TABLE_PREFIX, DB_TABLE_PREFIX));
  $aSearch->addTable(sprintf("%st_favorite_items", DB_TABLE_PREFIX));
  $aSearch->addTable(sprintf("%st_favorite_list", DB_TABLE_PREFIX));
  $aSearch->addGroupBy(DB_TABLE_PREFIX.'t_item.pk_i_id');
  $aSearch->order('count(*)', 'DESC');
  $aSearch->limit( 0, $limit );
  $list_items = $aSearch->doSearch();
  GLOBAL $fi_global_items2;
  $fi_global_items2 = View::newInstance()->_get('items') ;                 
  View::newInstance()->_exportVariableToView('items', $list_items);    
  require_once 'user/most_favorited_items.php';
  GLOBAL $fi_global_items2;                                                
  View::newInstance()->_exportVariableToView('items', $fi_global_items2);  
}
function fi_most_favorited_items ( $ limit = 5 ) { $ aSearch = new Search ( ) ; $ aSearch -> addField ( sprintf ( 'count(%st_item.pk_i_id) as count_id' , DB_TABLE_PREFIX ) ) ; $ aSearch -> addConditions ( sprintf ( " %st_favorite_list.list_id = %st_favorite_items.list_id " , DB_TABLE_PREFIX , DB_TABLE_PREFIX ) ) ; $ aSearch -> addConditions ( sprintf ( " %st_favorite_items.item_id = %st_item.pk_i_id " , DB_TABLE_PREFIX , DB_TABLE_PREFIX ) ) ; $ aSearch -> addConditions ( sprintf ( " %st_favorite_list.user_id <> coalesce(%st_item.fk_i_user_id, 0) " , DB_TABLE_PREFIX , DB_TABLE_PREFIX ) ) ; $ aSearch -> addTable ( sprintf ( " %st_favorite_items " , DB_TABLE_PREFIX ) ) ; $ aSearch -> addTable ( sprintf ( " %st_favorite_list " , DB_TABLE_PREFIX ) ) ; $ aSearch -> addGroupBy ( DB_TABLE_PREFIX . 't_item.pk_i_id' ) ; $ aSearch -> order ( 'count(*)' , 'DESC' ) ; $ aSearch -> limit ( 0 , $ limit ) ; $ list_items = $ aSearch -> doSearch ( ) ; GLOBAL $ fi_global_items2 ; $ fi_global_items2 = View :: newInstance ( ) -> _get ( 'items' ) ; View :: newInstance ( ) -> _exportVariableToView ( 'items' , $ list_items ) ; require_once 'user/most_favorited_items.php' ; GLOBAL $ fi_global_items2 ; View :: newInstance ( ) -> _exportVariableToView ( 'items' , $ fi_global_items2 ) ; }
SHOW LIST OF MOST FAVORITED LISTINGS
SHOW LIST OF MOST FAVORITED LISTINGS
// SEARCH ITEMS IN LIST AND CREATE ITEM ARRAY // EXPORT FAVORITE ITEMS TO VARIABLE //save existing item array //exporting our searched item array //calling stored item array //restore original item array