Example #1
0
function smartsection_items_tree_show($options)
{
    /*
    	options(
    		[0] => category (-1: current; 0: all)
    		[1] => sort
    		[2] => order
    		[3] => maxlevel (-1: all)
    		[4] => show items
    	);
    */
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $block = array();
    switch ($options[0]) {
        case -1:
            global $xoopsModule;
            $smartModule =& smartsection_getModuleInfo();
            echo $xoopsModule->dirname() . "<br>";
            echo $smartModule->dirname();
            if ($xoopsModule->dirname() == $smartModule->dirname()) {
                if (isset($_GET['categoryid'])) {
                    $cat2show = $_GET['categoryid'];
                } else {
                    if (isset($_GET['itemid'])) {
                        $itemObj = new SmartsectionItem($_GET['itemid']);
                        $cat2show = $itemObj->categoryid();
                    } else {
                        $cat2show = 0;
                    }
                    //itemid
                }
                //categoryid
            }
            //dirname
            break;
        case 0:
            $cat2show = 0;
            break;
        default:
            $cat2show = $options[0];
            break;
    }
    $sort = $options[1];
    //$order = smartsection_getOrderBy($sort);
    $order = $options[2];
    $maxlevel = $options[3];
    $showItems = $options[4];
    $arrayTree = smartsection_tree($cat2show, 0, $sort, $order, $maxlevel, $showItems);
    $block["arrayTree"] = $arrayTree;
    return $block;
}
Example #2
0
function smartsection_items_recent_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $myts =& MyTextSanitizer::getInstance();
    $smartModule =& smartsection_getModuleInfo();
    $block = array();
    $selectedcatids = explode(',', $options[0]);
    if (in_array(0, $selectedcatids)) {
        $allcats = true;
    } else {
        $allcats = false;
    }
    $sort = $options[1];
    $order = smartsection_getOrderBy($sort);
    $limit = $options[2];
    $smartsection_item_handler =& smartsection_gethandler('item');
    // creating the ITEM objects that belong to the selected category
    if ($allcats) {
        $criteria = null;
    } else {
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('categoryid', '(' . $options[0] . ')', 'IN'));
    }
    $itemsObj = $smartsection_item_handler->getItems($limit, $start, array(_SSECTION_STATUS_PUBLISHED), -1, $sort, $order, '', true, $criteria, true);
    $totalItems = count($itemsObj);
    if ($itemsObj) {
        for ($i = 0; $i < $totalItems; $i++) {
            $newItems['itemid'] = $itemsObj[$i]->itemid();
            $newItems['title'] = $itemsObj[$i]->title();
            $newItems['categoryname'] = $itemsObj[$i]->getCategoryName();
            $newItems['categoryid'] = $itemsObj[$i]->categoryid();
            $newItems['date'] = $itemsObj[$i]->datesub();
            $newItems['poster'] = xoops_getLinkedUnameFromId($itemsObj[$i]->uid());
            $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65);
            $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink();
            $block['items'][] = $newItems;
        }
        $block['lang_title'] = _MB_SSECTION_ITEMS;
        $block['lang_category'] = _MB_SSECTION_CATEGORY;
        $block['lang_poster'] = _MB_SSECTION_POSTEDBY;
        $block['lang_date'] = _MB_SSECTION_DATE;
        $modulename = $myts->makeTboxData4Show($smartModule->getVar('name'));
        $block['lang_visitItem'] = _MB_SSECTION_VISITITEM . " " . $modulename;
    }
    return $block;
}
Example #3
0
function smartsection_date_to_date_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $myts =& MyTextSanitizer::getInstance();
    $smartModule =& smartsection_getModuleInfo();
    $block = array();
    $fromArray = explode('/', $options[0]);
    //month, day, year
    $fromStamp = mktime(0, 0, 0, $fromArray[0], $fromArray[1], $fromArray[2]);
    $untilArray = explode('/', $options[1]);
    $untilStamp = mktime(0, 0, 0, $untilArray[0], $untilArray[1], $untilArray[2]);
    $criteria = new CriteriaCompo();
    $criteria->add(new Criteria('datesub', $fromStamp, '>'));
    $criteria->add(new Criteria('datesub', $untilStamp, '<'));
    $criteria->setSort('datesub');
    $criteria->setOrder('DESC');
    $smartsection_item_handler =& smartsection_gethandler('item');
    // creating the ITEM objects that belong to the selected category
    $itemsObj = $smartsection_item_handler->getObjects($criteria);
    $totalItems = count($itemsObj);
    if ($itemsObj) {
        for ($i = 0; $i < $totalItems; $i++) {
            $newItems['itemid'] = $itemsObj[$i]->itemid();
            $newItems['title'] = $itemsObj[$i]->title();
            $newItems['categoryname'] = $itemsObj[$i]->getCategoryName();
            $newItems['categoryid'] = $itemsObj[$i]->categoryid();
            $newItems['date'] = $itemsObj[$i]->datesub();
            $newItems['poster'] = xoops_getLinkedUnameFromId($itemsObj[$i]->uid());
            $newItems['itemlink'] = $itemsObj[$i]->getItemLink(false, isset($options[3]) ? $options[3] : 65);
            $newItems['categorylink'] = $itemsObj[$i]->getCategoryLink();
            $block['items'][] = $newItems;
        }
        $block['lang_title'] = _MB_SSECTION_ITEMS;
        $block['lang_category'] = _MB_SSECTION_CATEGORY;
        $block['lang_poster'] = _MB_SSECTION_POSTEDBY;
        $block['lang_date'] = _MB_SSECTION_DATE;
        $modulename = $myts->makeTboxData4Show($smartModule->getVar('name'));
        $block['lang_visitItem'] = _MB_SSECTION_VISITITEM . " " . $modulename;
        $block['lang_articles_from_to'] = sprintf(_MB_SSECTION_ARTICLES_FROM_TO, $options[0], $options[1]);
    }
    return $block;
}
function b_marquee_smartsection($limit, $dateformat, $itemssize)
{
    include_once XOOPS_ROOT_PATH . '/modules/smartsection/include/common.php';
    $myts =& MyTextSanitizer::getInstance();
    $smartModule =& smartsection_getModuleInfo();
    $block = array();
    $categoryid = -1;
    $sort = 'datesub';
    $order = smartsection_getOrderBy($sort);
    $smartsection_item_handler =& smartsection_gethandler('item');
    $itemsObj = $smartsection_item_handler->getAllPublished($limit, 0, $categoryid, $sort, $order);
    $totalItems = count($itemsObj);
    if ($itemsObj) {
        for ($i = 0; $i < $totalItems; $i++) {
            if ($itemssize > 0) {
                $title = xoops_substr($itemsObj[$i]->title(), 0, $itemssize + 3);
            } else {
                $title = $itemsObj[$i]->title();
            }
            $block[] = array('date' => $itemsObj[$i]->datesub(), 'category' => $itemsObj[$i]->getCategoryName(), 'author' => xoops_getLinkedUnameFromId($itemsObj[$i]->uid()), 'title' => $title, 'link' => "<a href='" . XOOPS_URL . '/modules/smartsection/item.php?itemid=' . $itemsObj[$i]->itemid() . "'>" . $title . '</a>');
        }
    }
    return $block;
}
Example #5
0
 function getAdminLinks()
 {
     // include language file
     global $xoopsConfig, $smartModule, $smartConfig, $xoopsUser;
     $filePath = XOOPS_ROOT_PATH . "/modules/smartsection/language/" . $xoopsConfig['language'] . "/main.php";
     if (file_exists($filePath)) {
         include_once XOOPS_ROOT_PATH . "/modules/smartsection/language/" . $xoopsConfig['language'] . "/main.php";
     } else {
         include_once XOOPS_ROOT_PATH . "/modules/smartsection/language/english/main.php";
     }
     $adminLinks = '';
     // Find if the user is admin of the module
     $isAdmin = smartsection_userIsAdmin();
     $groups = $xoopsUser ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
     $gperm_handler =& xoops_gethandler('groupperm');
     $smartModule = smartsection_getModuleInfo();
     $module_id = $smartModule->getVar('mid');
     $uploadLink = '';
     // Do we have access to the parent category
     if (is_object($xoopsUser) && ($isAdmin || $xoopsUser->uid() == $this->uid() || $gperm_handler->checkRight('item_submit', $this->categoryid(), $groups, $module_id))) {
         if (!$isAdmin) {
             if ($xoopsUser->uid() == $this->uid()) {
                 // Edit button
                 $adminLinks .= "<a href='" . SMARTSECTION_URL . "submit.php?itemid=" . $this->itemid() . "'><img src='" . SMARTSECTION_URL . "images/links/edit.gif'" . " title='" . _MD_SSECTION_EDIT . "' alt='" . _MD_SSECTION_EDIT . "'/></a>";
                 $adminLinks .= " ";
             }
             if (SMARTSECTION_LEVEL > 0) {
                 if ($smartConfig['allowclone']) {
                     // Dupplicate button
                     $adminLinks .= "<a href='" . SMARTSECTION_URL . "submit.php?op=clone&itemid=" . $this->itemid() . "'><img src='" . SMARTSECTION_URL . "images/links/clone.gif'" . " title='" . _MD_SSECTION_CLONE . "' alt='" . _MD_SSECTION_CLONE . "'/></a>";
                     $adminLinks .= " ";
                 }
                 // upload a file linked this article
                 if ($smartConfig['allowupload']) {
                     $uploadLink = "<a href='" . SMARTSECTION_URL . "addfile.php?itemid=" . $this->itemid() . "'><img src='" . SMARTSECTION_URL . "images/icon/file.gif' title='" . _MD_SSECTION_ADD_FILE . "' alt='" . _MD_SSECTION_ADD_FILE . "'/></a>";
                 }
             }
         } else {
             // Edit button
             $adminLinks .= "<a href='" . SMARTSECTION_URL . "admin/item.php?op=mod&itemid=" . $this->itemid() . "'><img src='" . SMARTSECTION_URL . "images/links/edit.gif'" . " title='" . _MD_SSECTION_EDIT . "' alt='" . _MD_SSECTION_EDIT . "'/></a>";
             $adminLinks .= " ";
             if (SMARTSECTION_LEVEL > 0) {
                 // Dupplicate button
                 $adminLinks .= "<a href='" . SMARTSECTION_URL . "admin/item.php?op=clone&itemid=" . $this->itemid() . "'><img src='" . SMARTSECTION_URL . "images/links/clone.gif'" . " title='" . _MD_SSECTION_CLONE . "' alt='" . _MD_SSECTION_CLONE . "'/></a>";
                 $adminLinks .= " ";
             }
             // Delete button
             $adminLinks .= "<a href='" . SMARTSECTION_URL . "admin/item.php?op=del&itemid=" . $this->itemid() . "'><img src='" . SMARTSECTION_URL . "images/links/delete.gif'" . " title='" . _MD_SSECTION_DELETE . "' alt='" . _MD_SSECTION_DELETE . "'/></a>";
             $adminLinks .= " ";
             if (SMARTSECTION_LEVEL > 0) {
                 // upload a file linked this article
                 $uploadLink = "<a href='" . SMARTSECTION_URL . "addfile.php?itemid=" . $this->itemid() . "'><img src='" . SMARTSECTION_URL . "images/icon/file.gif' title='" . _MD_SSECTION_ADD_FILE . "' alt='" . _MD_SSECTION_ADD_FILE . "'/></a>";
             }
         }
     }
     /*		if (SMARTSECTION_LEVEL > 0) {
     			// PDF button
     			$adminLinks .= "<a href='" . SMARTSECTION_URL . "makepdf.php?itemid=" . $this->itemid() . "'><img src='" . SMARTSECTION_URL . "images/links/pdf.gif' title='" . _MD_SSECTION_PDF . "' alt='" . _MD_SSECTION_PDF . "'/></a>";
     			$adminLinks .= " ";
     		}
     
     		// Print button
     		$adminLinks .= '<a href="' . smartsection_seo_genUrl("print", $this->itemid(), $this->short_url()) . '"><img src="' . SMARTSECTION_URL . 'images/links/print.gif" title="' . _MD_SSECTION_PRINT . '" alt="' . _MD_SSECTION_PRINT . '"/></a>';
     		$adminLinks .= " ";
     */
     // Email button
     $maillink = "mailto:?subject=" . sprintf(_MD_SSECTION_INTITEM, $xoopsConfig['sitename']) . "&amp;body=" . sprintf(_MD_SSECTION_INTITEMFOUND, $xoopsConfig['sitename']) . ": " . $this->getItemUrl();
     $adminLinks .= '<a href="' . $maillink . '"><img src="' . SMARTSECTION_URL . 'images/links/friend.gif" title="' . _MD_SSECTION_MAIL . '" alt="' . _MD_SSECTION_MAIL . '"/></a>';
     $adminLinks .= " ";
     if (SMARTSECTION_LEVEL > 0) {
         // upload a file linked this article
         // Add a file button
         $adminLinks .= $uploadLink;
         $adminLinks .= " ";
     }
     return $adminLinks;
 }
Example #6
0
 /**
  * Delete all permission for a specific item
  *
  *  deletePermissions()
  *
  * @param integer $itemid : id of the item for which to delete the permissions
  * @return boolean : TRUE if the no errors occured
  **/
 function deletePermissions($itemid, $gperm_name)
 {
     global $xoopsModule;
     $smartModule =& smartsection_getModuleInfo();
     $result = true;
     $module_id = $smartModule->getVar('mid');
     $gperm_handler =& xoops_gethandler('groupperm');
     $gperm_handler->deleteByModule($module_id, $gperm_name, $itemid);
     return $result;
 }
Example #7
0
if (!file_exists($common_lang_file)) {
    $common_lang_file = SMARTSECTION_ROOT_PATH . "language/english/common.php";
}
include_once $common_lang_file;
// include smartobject framework
if (!file_exists(XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php')) {
    trigger_error('SmartObject Framework not found.', E_USER_ERROR);
}
include_once XOOPS_ROOT_PATH . '/modules/smartobject/include/common.php';
include_once SMARTSECTION_ROOT_PATH . "include/functions.php";
// Check XOOPS version to see if we are on XOOPS 2.2.x plateform
$xoops22 = smartsection_isXoops22();
include_once SMARTSECTION_ROOT_PATH . "include/seo_functions.php";
include_once SMARTSECTION_ROOT_PATH . "class/keyhighlighter.class.php";
// Creating the SmartModule object
$smartModule =& smartsection_getModuleInfo();
// Find if the user is admin of the module
$smartsection_isAdmin = smartsection_userIsAdmin();
$smartsection_moduleName = $smartModule->getVar('name');
// Creating the SmartModule config Object
$smartConfig =& smartsection_getModuleConfig();
include_once SMARTSECTION_ROOT_PATH . "class/smartmetagen.php";
include_once SMARTSECTION_ROOT_PATH . "class/permission.php";
include_once SMARTSECTION_ROOT_PATH . "class/category.php";
include_once SMARTSECTION_ROOT_PATH . "class/item.php";
include_once SMARTSECTION_ROOT_PATH . "class/file.php";
include_once SMARTSECTION_ROOT_PATH . "class/session.php";
// Creating the item handler object
$smartsection_item_handler =& xoops_getmodulehandler('item', SMARTSECTION_DIRNAME);
// Creating the category handler object
$smartsection_category_handler =& xoops_getmodulehandler('category', SMARTSECTION_DIRNAME);
Example #8
0
/**
* Checks if a user is admin of SmartSection
*
* smartsection_userIsAdmin()
*
* @return boolean : array with userids and uname
*/
function smartsection_userIsAdmin()
{
    global $xoopsUser;
    static $smartsection_isAdmin;
    if (isset($smartsection_isAdmin)) {
        return $smartsection_isAdmin;
    }
    if (!$xoopsUser) {
        $smartsection_isAdmin = false;
        return $smartsection_isAdmin;
    }
    $smartsection_isAdmin = false;
    $smartModule = smartsection_getModuleInfo();
    $module_id = $smartModule->getVar('mid');
    $smartsection_isAdmin = $xoopsUser->isAdmin($module_id);
    return $smartsection_isAdmin;
}