示例#1
0
function b_recent_partners_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartpartner/include/common.php";
    // Creating the partner handler object
    $smartpartner_partner_handler =& smartpartner_gethandler('partner');
    $smartpartner_category_handler =& smartpartner_gethandler('category');
    // Randomize
    $partnersObj =& $smartpartner_partner_handler->getPartners($options[2], 0, _SPARTNER_STATUS_ACTIVE, 'datesub', 'DESC');
    include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php';
    $smartpermissions_handler = new SmartobjectPermissionHandler($smartpartner_partner_handler);
    $grantedItems = $smartpermissions_handler->getGrantedItems('full_view');
    if ($partnersObj) {
        $block = array();
        foreach ($partnersObj as $partnerObj) {
            if (in_array($partnerObj->id(), $grantedItems)) {
                $block['partners'][] = $partnerObj->toArray();
            }
        }
    }
    if (!empty($block['partners'])) {
        if ($options[0] == 1) {
            $block['insertBr'] = true;
        }
        if ($options[1] == 1) {
            $block['fadeImage'] = 'style="filter:alpha(opacity=20);" onmouseover="nereidFade(this,100,30,5)" onmouseout="nereidFade(this,50,30,5)"';
        }
        //$block['see_all'] = $options[6];
        $block['lang_see_all'] = _MB_SPARTNER_LANG_SEE_ALL;
        $block['smartpartner_url'] = SMARTPARTNER_URL;
    }
    return $block;
}
示例#2
0
/**
 * $Id: random_offer.php,v 1.1 2007/09/18 14:00:53 marcan Exp $
 * Module: SmartPartner
 * Author: The SmartFactory <www.smartfactory.ca>
 * Licence: GNU
 */
function b_random_offer_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartpartner/include/common.php";
    // Creating the partner handler object
    $smartpartner_offer_handler =& smartpartner_gethandler('offer');
    $smartpartner_partner_handler =& smartpartner_gethandler('partner');
    include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php';
    $smartpermissions_handler = new SmartobjectPermissionHandler($smartpartner_partner_handler);
    //var_dump($smartpermissions_handler->handler);exit;
    $grantedItems = $smartpermissions_handler->getGrantedItems('full_view');
    if (!empty($grantedItems)) {
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('partnerid', '(' . implode(', ', $grantedItems) . ')', 'IN'));
        $criteria->add(new Criteria('date_pub', time(), '<'));
        $criteria->add(new Criteria('date_end', time(), '>'));
        $criteria->add(new Criteria('status', _SPARTNER_STATUS_ONLINE));
        // Randomize
        $offersObj =& $smartpartner_offer_handler->getObjects($criteria);
        if (count($offersObj) > 0) {
            $key_arr = array_keys($offersObj);
            $key_rand = array_rand($key_arr, 1);
            $offerObj = $offersObj[$key_rand];
        }
        $block = array();
        if (isset($offerObj) && is_object($offerObj)) {
            $block['offers'][] = $offerObj->toArray('e');
            $smartConfig =& smartpartner_getModuleConfig();
            //$image_info = smartpartner_imageResize($partnerObj->getImagePath(), $smartConfig['img_max_width'], $smartConfig['img_max_height']);
            if ($options[0] == 1) {
                $block['fadeImage'] = 'style="filter:alpha(opacity=20);" onmouseover="nereidFade(this,100,30,5)" onmouseout="nereidFade(this,50,30,5)"';
            }
            $block['see_all'] = $options[2];
            $block['lang_see_all'] = _MB_SPARTNER_LANG_SEE_ALL_OFFERS;
            $block['smartpartner_url'] = SMARTPARTNER_URL;
        }
    }
    return $block;
}
 function setGrantedObjectsCriteria(&$criteria, $perm_name)
 {
     $smartpermissions_handler = new SmartobjectPermissionHandler($this);
     $grantedItems = $smartpermissions_handler->getGrantedItems($perm_name);
     if (count($grantedItems) > 0) {
         $criteria->add(new Criteria($this->keyName, '(' . implode(', ', $grantedItems) . ')', 'IN'));
         return true;
     } else {
         return false;
     }
 }
示例#4
0
global $xoopsUser, $xoopsConfig, $xoopsModuleConfig, $xoopsModule;
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
if ($id == 0) {
    redirect_header("javascript:history.go(-1)", 2, _MD_SPARTNER_NOPARTNERSELECTED);
    exit;
}
// Creating the Partner object for the selected FAQ
$partnerObj = new SmartpartnerPartner($id);
// If the selected partner was not found, exit
if ($partnerObj->notLoaded()) {
    redirect_header("javascript:history.go(-1)", 2, _MD_SPARTNER_NOPARTNERSELECTED);
    exit;
}
include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php';
$smartpermissions_handler = new SmartobjectPermissionHandler($smartpartner_partner_handler);
$grantedItems = $smartpermissions_handler->getGrantedItems('full_view');
$grantedItems = array_merge($grantedItems, $smartpermissions_handler->getGrantedItems('partial_view'));
// Chech the status
if ($partnerObj->status() != _SPARTNER_STATUS_ACTIVE || !in_array($id, $grantedItems)) {
    redirect_header("javascript:history.go(-1)", 2, _NOPERM);
    exit;
}
// Updating the counter
$partnerObj->updateHits_page();
// Populating the smarty variables with informations related to the selected Partner
$partner = $partnerObj->toArray();
// Creating the files object associated with this item
$filesObj = $partnerObj->getFiles();
$files = array();
$embeded_files = array();
foreach ($filesObj as $fileObj) {
示例#5
0
 function getObjectsForUserSide()
 {
     global $xoopsModuleConfig, $smartpartner_category_handler, $smartpartner_partner_handler, $xoopsUser;
     $criteria = new CriteriaCompo();
     $criteria->setSort($xoopsModuleConfig['offer_sort']);
     $criteria->setOrder($xoopsModuleConfig['offer_order']);
     $criteria->add(new Criteria('date_pub', time(), '<'));
     $criteria->add(new Criteria('date_end', time(), '>'));
     $criteria->add(new Criteria('status', _SPARTNER_STATUS_ONLINE));
     $offersObj = $this->getObjects($criteria);
     foreach ($offersObj as $offerObj) {
     }
     $catsObj = $smartpartner_category_handler->getObjects(null, true);
     $partnersObj = $smartpartner_partner_handler->getObjects(null, true);
     include_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartobjectpermission.php';
     $smartpermissions_handler = new SmartobjectPermissionHandler($smartpartner_partner_handler);
     $userGroups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
     $grantedItems = $smartpermissions_handler->getGrantedItems('full_view');
     $relevantCat = array();
     foreach ($offersObj as $offerObj) {
         if (in_array($offerObj->getVar('partnerid', 'e'), $grantedItems)) {
             $categId = $partnersObj[$offerObj->getVar('partnerid', 'e')]->categoryid();
             $parentCatArray = explode('|', $categId);
             $relevantCat = array_merge($relevantCat, $parentCatArray);
             foreach ($parentCatArray as $p_cat) {
                 $parentid = $p_cat;
                 while ($catsObj[$parentid]->parentid() != 0) {
                     $parentid = $catsObj[$parentid]->parentid();
                     $relevantCat[] = $parentid;
                 }
             }
         }
     }
     $relevantCat = array_unique($relevantCat);
     $partnersArray = array();
     foreach ($partnersObj as $partnerObj) {
         $grantedGroups = $smartpermissions_handler->getGrantedGroups('full_view', $partnerObj->id());
         if (array_intersect($userGroups, $grantedGroups)) {
             $partnerArray = array();
             $partnerArray['name'] = $partnerObj->title();
             $partnerArray['offers'] = array();
             foreach ($offersObj as $offerObj) {
                 if ($offerObj->getVar('partnerid', 'e') == $partnerObj->id()) {
                     $partnerArray['offers'][] = $offerObj->toArray();
                 }
             }
             $partnersArray[$partnerObj->id()] = $partnerArray;
             unset($partnerArray);
         }
     }
     $categoriesArray = array();
     foreach ($catsObj as $catObj) {
         if (in_array($catObj->categoryid(), $relevantCat)) {
             $categoryArray = array();
             $categoryArray['parentid'] = $catObj->parentid();
             $categoryArray['categoryid'] = $catObj->categoryid();
             $categoryArray['name'] = $catObj->name();
             $categoryArray['partners'] = array();
             foreach ($partnersObj as $partnerObj) {
                 $catArray = explode('|', $partnerObj->categoryid());
                 if (in_array($catObj->categoryid(), $catArray)) {
                     $categoryArray['partners'][$partnerObj->id()] = $partnersArray[$partnerObj->id()];
                 }
             }
             $categoriesArray[] = $categoryArray;
             unset($categoryArray);
         }
     }
     return $this->hierarchize($categoriesArray);
 }