Example #1
0
// it under the terms of the GNU General Public License as published by     //
// the Free Software Foundation; either version 2 of the License, or        //
// (at your option) any later version.                                      //
// //
// You may not change or alter any portion of this comment or credits       //
// of supporting developers from this source code or any supporting         //
// source code which is considered copyrighted (c) material of the          //
// original comment or credit authors.                                      //
// //
// This program is distributed in the hope that it will be useful,          //
// but WITHOUT ANY WARRANTY; without even the implied warranty of           //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
// GNU General Public License for more details.                             //
// //
// You should have received a copy of the GNU General Public License        //
// along with this program; if not, write to the Free Software              //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
// ------------------------------------------------------------------------ //
include_once '../../mainfile.php';
include_once XOOPS_ROOT_PATH . "/modules/smartmedia/include/functions.php";
$com_itemid = isset($_GET['com_itemid']) ? intval($_GET['com_itemid']) : 0;
if ($com_itemid > 0) {
    $itemObj = new ssItem($com_itemid);
    $com_replytext = _POSTEDBY . '&nbsp;<b>' . smartmedia_getLinkedUnameFromId($itemObj->uid()) . '</b>&nbsp;' . _DATE . '&nbsp;<b>' . $itemObj->dateSub() . '</b><br /><br />' . $itemObj->summary();
    $bodytext = $itemObj->body();
    if ($bodytext != '') {
        $com_replytext .= '<br /><br />' . $bodytext . '';
    }
    $com_replytitle = $itemObj->title();
    include_once XOOPS_ROOT_PATH . '/include/comment_new.php';
}
Example #2
0
function edititem($showmenu = false, $itemid = 0)
{
    global $smartsection_file_handler, $smartsection_item_handler, $smartsection_category_handler, $xoopsUser, $xoopsModule, $xoopsConfig, $xoopsDB;
    include_once XOOPS_ROOT_PATH . '/class/xoopsformloader.php';
    // If there is a parameter, and the id exists, retrieve data: we're editing a item
    if ($itemid != 0) {
        // Creating the ITEM object
        $itemObj = new ssItem($itemid);
        if ($itemObj->notLoaded()) {
            redirect_header("item.php", 1, _AM_SS_NOITEMSELECTED);
            exit;
        }
        switch ($itemObj->status()) {
            case _SS_STATUS_SUBMITTED:
                $breadcrumb_action1 = _AM_SS_SUBMITTED;
                $breadcrumb_action2 = _AM_SS_APPROVING;
                $page_title = _AM_SS_SUBMITTED_TITLE;
                $page_info = _AM_SS_SUBMITTED_INFO;
                $button_caption = _AM_SS_APPROVE;
                $new_status = _SS_STATUS_PUBLISHED;
                break;
            case _SS_STATUS_PUBLISHED:
                $breadcrumb_action1 = _AM_SS_PUBLISHED;
                $breadcrumb_action2 = _AM_SS_EDITING;
                $page_title = _AM_SS_PUBLISHEDEDITING;
                $page_info = _AM_SS_PUBLISHEDEDITING_INFO;
                $button_caption = _AM_SS_MODIFY;
                $new_status = _SS_STATUS_PUBLISHED;
                break;
            case _SS_STATUS_OFFLINE:
                $breadcrumb_action1 = _AM_SS_OFFLINE;
                $breadcrumb_action2 = _AM_SS_EDITING;
                $page_title = _AM_SS_OFFLINEEDITING;
                $page_info = _AM_SS_OFFLINEEDITING_INFO;
                $button_caption = _AM_SS_MODIFY;
                $new_status = _SS_STATUS_OFFLINE;
                break;
            case "default":
            default:
                break;
        }
        $categoryObj =& $itemObj->category();
        if ($showmenu) {
            ss_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2);
        }
        echo "<br />\n";
        ss_collapsableBar('edititemtable', 'edititemicon', $page_title, $page_info);
    } else {
        // there's no parameter, so we're adding an item
        $itemObj =& $smartsection_item_handler->create();
        $categoryObj =& $smartsection_category_handler->create();
        $breadcrumb_action1 = _AM_SS_ITEMS;
        $breadcrumb_action2 = _AM_SS_CREATINGNEW;
        $button_caption = _AM_SS_CREATE;
        $new_status = _SS_STATUS_PUBLISHED;
        if ($showmenu) {
            ss_adminMenu(2, $breadcrumb_action1 . " > " . $breadcrumb_action2);
        }
        $sel_categoryid = isset($_GET['categoryid']) ? $_GET['categoryid'] : 0;
        $categoryObj->setVar('categoryid', $sel_categoryid);
        ss_collapsableBar('createitemtable', 'createitemicon', _AM_SS_ITEM_CREATING, _AM_SS_ITEM_CREATING_DSC);
    }
    // ITEM FORM
    $sform = new XoopsThemeForm(_AM_SS_ITEMS, "op", xoops_getenv('PHP_SELF'));
    $sform->setExtra('enctype="multipart/form-data"');
    // CATEGORY
    $mytree = new XoopsTree($xoopsDB->prefix("smartsection_categories"), "categoryid", "parentid");
    ob_start();
    $sform->addElement(new XoopsFormHidden('categoryid', $categoryObj->categoryid()));
    $mytree->makeMySelBox("name", "weight", $categoryObj->categoryid());
    $category_label = new XoopsFormLabel(_AM_SS_CATEGORY, ob_get_contents());
    $category_label->setDescription(_AM_SS_CATEGORY_DSC);
    $sform->addElement($category_label);
    ob_end_clean();
    // TITLE
    $title_text = new XoopsFormText(_AM_SS_TITLE, 'title', 50, 255, $itemObj->title(0, 'e'));
    $sform->addElement($title_text, true);
    // SUMMARY
    $summary_text = ss_getEditor(_AM_SS_SUMMARY, 'summary', $itemObj->summary(0, 'e'));
    $summary_text->setDescription(_AM_SS_SUMMARY_DSC);
    $sform->addElement($summary_text, false);
    // DISPLAY_SUMMARY
    $display_summary_radio = new XoopsFormRadioYN(_AM_SS_DISPLAY_SUMMARY, 'display_summary', $itemObj->display_summary(), ' ' . _AM_SS_YES . '', ' ' . _AM_SS_NO . '');
    $sform->addElement($display_summary_radio);
    // BODY
    $body_text = ss_getEditor(_AM_SS_BODY, 'body', $itemObj->body(0, 'e'));
    //$body_text = new XoopsFormDhtmlTextArea(_AM_SS_BODY, 'body', $itemObj->body(0, 'e'), 20, 60);
    $body_text->setDescription(_AM_SS_BODY_DSC);
    $sform->addElement($body_text, true);
    // IMAGE
    $image_array =& XoopsLists::getImgListAsArray(ss_getImageDir('item'));
    $image_select = new XoopsFormSelect('', 'image', $itemObj->image());
    //$image_select -> addOption ('-1', '---------------');
    $image_select->addOptionArray($image_array);
    $image_select->setExtra("onchange='showImgSelected(\"image3\", \"image\", \"" . 'uploads/smartsection/images/item/' . "\", \"\", \"" . XOOPS_URL . "\")'");
    $image_tray = new XoopsFormElementTray(_AM_SS_IMAGE_ITEM, '&nbsp;');
    $image_tray->addElement($image_select);
    $image_tray->addElement(new XoopsFormLabel('', "<br /><br /><img src='" . ss_getImageDir('item', false) . $itemObj->image() . "' name='image3' id='image3' alt='' />"));
    $image_tray->setDescription(_AM_SS_IMAGE_ITEM_DSC);
    $sform->addElement($image_tray);
    // IMAGE UPLOAD
    $max_size = 5000000;
    $file_box = new XoopsFormFile(_AM_SS_IMAGE_UPLOAD, "image_file", $max_size);
    $file_box->setExtra("size ='45'");
    $file_box->setDescription(_AM_SS_IMAGE_UPLOAD_ITEM_DSC);
    $sform->addElement($file_box);
    // Uid
    /*  We need to retreive the users manually because for some reason, on the frxoops.org server,
    	    the method users::getobjects encounters a memory error 
    	*/
    $uid = $itemObj->uid() == 0 ? $xoopsUser->uid() : $itemObj->uid();
    $uid_select = new XoopsFormSelect(_AM_SS_UID, 'uid', $uid, 1, false);
    $uid_select->setDescription(_AM_SS_UID_DSC);
    $sql = "SELECT uid, uname FROM " . $xoopsDB->prefix('users') . " ORDER BY uname ASC";
    $result = $xoopsDB->query($sql);
    $users_array = array();
    while ($myrow = $xoopsDB->fetchArray($result)) {
        $users_array[$myrow['uid']] = $myrow['uname'];
    }
    $uid_select->addOptionArray($users_array);
    $sform->addElement($uid_select);
    // Datesub
    $datesub = $itemObj->getVar('datesub') == 0 ? time() : $itemObj->getVar('datesub');
    $datesub_datetime = new XoopsFormDateTime(_AM_SS_DATESUB, 'datesub', $size = 15, $datesub);
    $datesub_datetime->setDescription(_AM_SS_DATESUB_DSC);
    $sform->addElement($datesub_datetime);
    // STATUS
    $options = array(_SS_STATUS_PUBLISHED => _AM_SS_PUBLISHED, _SS_STATUS_OFFLINE => _AM_SS_OFFLINE);
    $status_select = new XoopsFormSelect(_AM_SS_STATUS, 'status', $new_status);
    $status_select->addOptionArray($options);
    $status_select->setDescription(_AM_SS_STATUS_DSC);
    $sform->addElement($status_select);
    // WEIGHT
    $sform->addElement(new XoopsFormText(_AM_SS_WEIGHT, 'weight', 5, 5, $itemObj->weight()), true);
    // COMMENTS
    $addcomments_radio = new XoopsFormRadioYN(_AM_SS_ALLOWCOMMENTS, 'cancomment', $itemObj->cancomment(), ' ' . _AM_SS_YES . '', ' ' . _AM_SS_NO . '');
    $sform->addElement($addcomments_radio);
    // PER ITEM PERMISSIONS
    $member_handler =& xoops_gethandler('member');
    $group_list =& $member_handler->getGroupList();
    $groups_checkbox = new XoopsFormCheckBox(_AM_SS_PERMISSIONS_ITEM, 'groups[]', $itemObj->getGroups_read());
    $groups_checkbox->setDescription(_AM_SS_PERMISSIONS_ITEM_DSC);
    foreach ($group_list as $group_id => $group_name) {
        if ($group_id != XOOPS_GROUP_ADMIN) {
            $groups_checkbox->addOption($group_id, $group_name);
        }
    }
    $sform->addElement($groups_checkbox);
    // VARIOUS OPTIONS
    $options_tray = new XoopsFormElementTray(_AM_SS_OPTIONS, '<br />');
    $html_checkbox = new XoopsFormCheckBox('', 'dohtml', $itemObj->dohtml());
    $html_checkbox->addOption(1, _AM_SS_DOHTML);
    $options_tray->addElement($html_checkbox);
    $smiley_checkbox = new XoopsFormCheckBox('', 'dosmiley', $itemObj->dosmiley());
    $smiley_checkbox->addOption(1, _AM_SS_DOSMILEY);
    $options_tray->addElement($smiley_checkbox);
    $xcodes_checkbox = new XoopsFormCheckBox('', 'doxcode', $itemObj->doxcode());
    $xcodes_checkbox->addOption(1, _AM_SS_DOXCODE);
    $options_tray->addElement($xcodes_checkbox);
    $images_checkbox = new XoopsFormCheckBox('', 'doimage', $itemObj->doimage());
    $images_checkbox->addOption(1, _AM_SS_DOIMAGE);
    $options_tray->addElement($images_checkbox);
    $linebreak_checkbox = new XoopsFormCheckBox('', 'dobr', $itemObj->dobr());
    $linebreak_checkbox->addOption(1, _AM_SS_DOLINEBREAK);
    $options_tray->addElement($linebreak_checkbox);
    $sform->addElement($options_tray);
    // item ID
    $sform->addElement(new XoopsFormHidden('itemid', $itemObj->itemid()));
    $button_tray = new XoopsFormElementTray('', '');
    $hidden = new XoopsFormHidden('op', 'additem');
    $button_tray->addElement($hidden);
    if (!$itemid) {
        // there's no itemid? Then it's a new item
        // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SS_CREATE, 'submit' ) );
        $butt_create = new XoopsFormButton('', '', _AM_SS_CREATE, 'submit');
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'additem\'"');
        $button_tray->addElement($butt_create);
        $butt_clear = new XoopsFormButton('', '', _AM_SS_CLEAR, 'reset');
        $button_tray->addElement($butt_clear);
        $butt_cancel = new XoopsFormButton('', '', _AM_SS_CANCEL, 'button');
        $butt_cancel->setExtra('onclick="history.go(-1)"');
        $button_tray->addElement($butt_cancel);
        $sform->addElement($button_tray);
        $sform->display();
        ss_close_collapsable('createitemtable', 'createitemicon');
    } else {
        // else, we're editing an existing item
        // $button_tray -> addElement( new XoopsFormButton( '', 'mod', _AM_SS_MODIFY, 'submit' ) );
        $butt_create = new XoopsFormButton('', '', $button_caption, 'submit');
        $butt_create->setExtra('onclick="this.form.elements.op.value=\'additem\'"');
        $button_tray->addElement($butt_create);
        $butt_cancel = new XoopsFormButton('', '', _AM_SS_CANCEL, 'button');
        $butt_cancel->setExtra('onclick="history.go(-1)"');
        $button_tray->addElement($butt_cancel);
        $sform->addElement($button_tray);
        $sform->display();
        ss_close_collapsable('edititemtable', 'edititemicon');
    }
    unset($hidden);
    if ($itemid != 0) {
        showfiles($itemObj);
    }
}
Example #3
0
/**
* $Id: print.php,v 1.2 2005/08/02 03:47:51 mauriciodelima Exp $
* Module: SmartSection
* Author: The SmartFactory <www.smartfactory.ca>
* Licence: GNU
*/
include_once 'header.php';
require_once XOOPS_ROOT_PATH . '/class/template.php';
global $smartsection_item_handler;
$itemid = isset($_GET['itemid']) ? intval($_GET['itemid']) : 0;
if ($itemid == 0) {
    redirect_header("javascript:history.go(-1)", 1, _MD_SS_NOITEMSELECTED);
    exit;
}
// Creating the ITEM object for the selected ITEM
$itemObj = new ssItem($itemid);
// If the selected ITEM was not found, exit
if ($itemObj->notLoaded()) {
    redirect_header("javascript:history.go(-1)", 1, _MD_SS_NOITEMSELECTED);
    exit;
}
// Creating the category object that holds the selected ITEM
$categoryObj =& $itemObj->category();
// Check user permissions to access that category of the selected ITEM
if (!ss_itemAccessGranted($itemObj->getVar('itemid'), $itemObj->getVar('categoryid'))) {
    redirect_header("javascript:history.go(-1)", 1, _NOPERM);
    exit;
}
$xoopsTpl = new XoopsTpl();
global $xoopsConfig, $xoopsDB, $xoopsModule, $myts;
$item = $itemObj->toArray(null, $categoryObj, false);
Example #4
0
/**
* $Id: items_spot.php,v 1.2 2005/08/02 03:47:51 mauriciodelima Exp $
* Module: SmartSection
* Author: The SmartFactory <www.smartfactory.ca>
* Licence: GNU
*/
function b_items_spot_show($options)
{
    include_once XOOPS_ROOT_PATH . "/modules/smartsection/include/common.php";
    $opt_display_last = $options[0];
    $opt_items_count = $options[1];
    $opt_categoryid = $options[2];
    $sel_items = explode(',', $options[3]);
    $opt_display_poster = $options[4];
    $opt_display_comment = $options[5];
    $opt_display_type = $options[6];
    if ($opt_categoryid == 0) {
        $opt_categoryid = -1;
    }
    $block = array();
    $smartsection_item_handler =& ss_gethandler('item');
    if ($opt_display_last == 1) {
        $itemsObj =& $smartsection_item_handler->getAllPublished($opt_items_count, 0, $opt_categoryid, $sort = 'datesub', $order = 'DESC', 'summary');
        $i = 1;
        $itemsCount = count($itemsObj);
        if ($itemsObj) {
            foreach ($itemsObj as $key => $thisitem) {
                $item = array();
                $item = $thisitem->toArray();
                $item['who_when'] = sprintf(_MB_SS_WHO_WHEN, $thisitem->posterName(), $thisitem->datesub());
                if ($i < $itemsCount) {
                    $item['showline'] = true;
                } else {
                    $item['showline'] = false;
                }
                $i++;
                $block['items'][] = $item;
            }
        }
    } else {
        $i = 1;
        $itemsCount = count($sel_items);
        foreach ($sel_items as $item_id) {
            $itemObj = new ssItem($item_id);
            if (!$itemObj->notLoaded()) {
                $categoryObj =& $itemObj->category();
                $item = array();
                $item = $itemObj->toArray();
                $item['who_when'] = sprintf(_MB_SS_WHO_WHEN, $itemObj->posterName(), $itemObj->datesub());
                if ($i < $itemsCount) {
                    $item['showline'] = true;
                } else {
                    $item['showline'] = false;
                }
                $i++;
                $block['items'][] = $item;
            }
        }
    }
    $block['lang_reads'] = _MB_SS_READS;
    $block['lang_comments'] = _MB_SS_COMMENTS;
    $block['lang_readmore'] = _MB_SS_READMORE;
    $block['display_whowhen_link'] = $opt_display_poster;
    $block['display_comment_link'] = $opt_display_comment;
    $block['display_type'] = $opt_display_type;
    return $block;
}
Example #5
0
 function getLastPublishedByCat($status = array(_SS_STATUS_PUBLISHED))
 {
     $ret = array();
     $itemclause = "";
     if (!ss_userIsAdmin()) {
         $smartsectionPermHandler =& xoops_getmodulehandler('permission', 'smartsection');
         $items = $smartsectionPermHandler->getGrantedItems('item');
         $itemclause = " AND itemid IN (" . implode(',', $items) . ")";
     }
     $sql = "CREATE TEMPORARY TABLE tmp (categoryid INT(8) UNSIGNED NOT NULL,datesub int(11) DEFAULT '0' NOT NULL);";
     $sql2 = " LOCK TABLES " . $this->db->prefix('smartsection_items') . " READ;";
     $sql3 = " INSERT INTO tmp SELECT categoryid, MAX(datesub) FROM " . $this->db->prefix('smartsection_items') . " WHERE status IN (" . implode(',', $status) . ") {$itemclause} GROUP BY categoryid;";
     $sql4 = " SELECT " . $this->db->prefix('smartsection_items') . ".categoryid, itemid, title, uid, " . $this->db->prefix('smartsection_items') . ".datesub FROM " . $this->db->prefix('smartsection_items') . ", tmp\n\t                  WHERE " . $this->db->prefix('smartsection_items') . ".categoryid=tmp.categoryid AND " . $this->db->prefix('smartsection_items') . ".datesub=tmp.datesub;";
     /*
     //Old implementation
     $sql = "SELECT categoryid, itemid, question, uid, MAX(datesub) AS datesub FROM ".$this->db->prefix("smartitem_item")." 
            WHERE status IN (". implode(',', $status).")";
     $sql .= " GROUP BY categoryid";
     */
     $this->db->queryF($sql);
     $this->db->queryF($sql2);
     $this->db->queryF($sql3);
     $result = $this->db->query($sql4);
     $error = $this->db->error();
     $this->db->queryF("UNLOCK TABLES;");
     $this->db->queryF("DROP TABLE tmp;");
     if (!$result) {
         trigger_error("Error in getLastPublishedByCat SQL: " . $error);
         return $ret;
     }
     while ($row = $this->db->fetchArray($result)) {
         $item = new ssItem();
         $item->assignVars($row);
         $ret[$row['categoryid']] =& $item;
         unset($item);
     }
     return $ret;
 }
Example #6
0
/**
 * $Id: print.php,v 1.1 2005/05/13 18:21:55 malanciault Exp $
 * Module: SmartMedia
 * Author: The SmartFactory <www.smartfactory.ca>
 * Licence: GNU
 */
include_once 'header.php';
global $smartmedia_item_handler;
$itemid = isset($_GET['itemid']) ? intval($_GET['itemid']) : 0;
if ($itemid == 0) {
    redirect_header("javascript:history.go(-1)", 1, _MD_SMEDIA_NOITEMSELECTED);
    exit;
}
// Creating the ITEM object for the selected ITEM
$itemObj = new ssItem($itemid);
// If the selected ITEM was not found, exit
if ($itemObj->notLoaded()) {
    redirect_header("javascript:history.go(-1)", 1, _MD_SMEDIA_NOITEMSELECTED);
    exit;
}
// Creating the category object that holds the selected ITEM
$categoryObj =& $itemObj->category();
// Check user permissions to access that category of the selected ITEM
if (!smartmedia_itemAccessGranted($itemObj->getVar('itemid'), $itemObj->getVar('categoryid'))) {
    redirect_header("javascript:history.go(-1)", 1, _NOPERM);
    exit;
}
global $xoopsConfig, $xoopsDB, $xoopsModule, $myts;
$who_where = sprintf(_MD_SMEDIA_WHO_WHEN, $itemObj->posterName(), $itemObj->datesub());
echo "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>\n";