Exemple #1
0
 case "modify":
     global $xoopsUser;
     $fileid = isset($_POST['fileid']) ? intval($_POST['fileid']) : 0;
     // Creating the file object
     if ($fileid != 0) {
         $fileObj =& new SmartsectionFile($fileid);
     } else {
         $fileObj = $smartsection_file_handler->create();
     }
     // Putting the values in the file object
     $fileObj->setVar('name', $_POST['name']);
     $fileObj->setVar('description', $_POST['description']);
     $fileObj->setVar('status', intval($_POST['file_status']));
     // Storing the file
     if (!$fileObj->store()) {
         redirect_header("item.php?op=mod&itemid=" . $fileObj->itemid(), 3, _AM_SSECTION_FILE_EDITING_ERROR . smartsection_formatErrors($fileObj->getErrors()));
         exit;
     }
     redirect_header("item.php?op=mod&itemid=" . $fileObj->itemid(), 2, _AM_SSECTION_FILE_EDITING_SUCCESS);
     exit;
     break;
 case "del":
     global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET;
     $module_id = $xoopsModule->getVar('mid');
     $gperm_handler =& xoops_gethandler('groupperm');
     $fileid = isset($_POST['fileid']) ? intval($_POST['fileid']) : 0;
     $fileid = isset($_GET['fileid']) ? intval($_GET['fileid']) : $fileid;
     $fileObj = new SmartsectionFile($fileid);
     $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0;
     $title = isset($_POST['title']) ? $_POST['title'] : '';
     if ($confirm) {
Exemple #2
0
 //smartsection_saveCategory_Permissions($groups_admin, $categoriesObj->categoryid(), 'category_admin');
 if ($applyall) {
     // TODO : put this function in the category class
     smartsection_overrideItemsPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid());
 }
 //Added by fx2024
 $parentCat = $categoryObj->categoryid();
 for ($i = 0; $i < sizeof($_POST['scname']); $i++) {
     if ($_POST['scname'][$i] != '') {
         $categoryObj = $smartsection_category_handler->create();
         $categoryObj->setVar('name', $_POST['scname'][$i]);
         $categoryObj->setVar('parentid', $parentCat);
         $categoryObj->setGroups_read($grpread);
         $categoryObj->setGroups_submit($grpsubmit);
         if (!$categoryObj->store()) {
             redirect_header("javascript:history.go(-1)", 3, _AM_SSECTION_SUBCATEGORY_SAVE_ERROR . smartsection_formatErrors($categoryObj->getErrors()));
             exit;
         }
         // TODO : put this function in the category class
         smartsection_saveCategory_Permissions($categoryObj->getGroups_read(), $categoryObj->categoryid(), 'category_read');
         smartsection_saveCategory_Permissions($categoryObj->getGroups_submit(), $categoryObj->categoryid(), 'item_submit');
         //smartsection_saveCategory_Permissions($groups_admin, $categoriesObj->categoryid(), 'category_admin');
         if ($applyall) {
             // TODO : put this function in the category class
             smartsection_overrideItemsPermissions($categoryObj->getGroups_read(), $categoryObj->categoryid());
         }
     }
 }
 //end of fx2024 code
 redirect_header($redirect_to, 2, $redirect_msg);
 exit;
Exemple #3
0
function smartsection_upload_file($another = false, $withRedirect = true, &$itemObj)
{
    include_once SMARTSECTION_ROOT_PATH . "class/uploader.php";
    global $smartsection_isAdmin, $xoopsModuleConfig, $smartsection_item_handler, $smartsection_file_handler, $xoopsUser;
    $itemid = isset($_POST['itemid']) ? intval($_POST['itemid']) : 0;
    $uid = is_object($xoopsUser) ? $xoopsUser->uid() : 0;
    $session = SmartsectionSession::singleton();
    $session->set('smartsection_file_filename', isset($_POST['name']) ? $_POST['name'] : '');
    $session->set('smartsection_file_description', isset($_POST['description']) ? $_POST['description'] : '');
    $session->set('smartsection_file_status', $_POST['status']);
    $session->set('smartsection_file_uid', $uid);
    $session->set('smartsection_file_itemid', $itemid);
    if (!is_object($itemObj)) {
        $itemObj = $smartsection_item_handler->get($itemid);
    }
    $max_size = $xoopsModuleConfig['maximum_filesize'];
    $max_imgwidth = $xoopsModuleConfig['maximum_image_width'];
    $max_imgheight = $xoopsModuleConfig['maximum_image_height'];
    $fileObj = $smartsection_file_handler->create();
    $fileObj->setVar('name', isset($_POST['name']) ? $_POST['name'] : '');
    $fileObj->setVar('description', isset($_POST['description']) ? $_POST['description'] : '');
    $fileObj->setVar('status', isset($_POST['file_status']) ? intval($_POST['file_status']) : 1);
    $fileObj->setVar('uid', $uid);
    $fileObj->setVar('itemid', $itemObj->getVar('itemid'));
    // Get available mimetypes for file uploading
    /*    $hMime =& xoops_getmodulehandler('mimetype');
        if ($smartsection_isAdmin) {
            $crit = new Criteria('mime_admin', 1);
        } else {
            $crit = new Criteria('mime_user', 1);
        }
        $mimetypes =& $hMime->getObjects($crit);
        // TODO : display the available mimetypes to the user
    	*/
    if ($xoopsModuleConfig['allowupload'] && is_uploaded_file($_FILES['userfile']['tmp_name'])) {
        if (!($ret = $fileObj->checkUpload('userfile', $allowed_mimetypes, $errors))) {
            $errorstxt = implode('<br />', $errors);
            $message = sprintf(_SMARTSECTION_MESSAGE_FILE_ERROR, $errorstxt);
            if ($withRedirect) {
                redirect_header("file.php?op=mod&itemid=" . $itemid, 5, $message);
            } else {
                return $message;
            }
        }
    }
    // Storing the file
    if (!$fileObj->store($allowed_mimetypes)) {
        if ($withRedirect) {
            redirect_header("file.php?op=mod&itemid=" . $fileObj->itemid(), 3, _AM_SSECTION_FILEUPLOAD_ERROR . smartsection_formatErrors($fileObj->getErrors()));
            exit;
        } else {
            return _AM_SSECTION_FILEUPLOAD_ERROR . smartsection_formatErrors($fileObj->getErrors());
        }
    }
    if ($withRedirect) {
        $redirect_page = $another ? 'file.php' : 'item.php';
        redirect_header($redirect_page . "?op=mod&itemid=" . $fileObj->itemid(), 2, _AM_SSECTION_FILEUPLOAD_SUCCESS);
    } else {
        return true;
    }
}
Exemple #4
0
         $itemObj->sendNotifications($notifToDo);
     }
     redirect_header("item.php", 2, $redirect_msg);
     break;
 case "del":
     global $xoopsUser, $xoopsUser, $xoopsConfig, $xoopsDB, $_GET;
     $module_id = $xoopsModule->getVar('mid');
     $gperm_handler =& xoops_gethandler('groupperm');
     $itemid = isset($_POST['itemid']) ? intval($_POST['itemid']) : 0;
     $itemid = isset($_GET['itemid']) ? intval($_GET['itemid']) : $itemid;
     $itemObj = new SmartsectionItem($itemid);
     $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0;
     $title = isset($_POST['title']) ? $_POST['title'] : '';
     if ($confirm) {
         if (!$smartsection_item_handler->delete($itemObj)) {
             redirect_header("item.php", 2, _AM_SSECTION_ITEM_DELETE_ERROR . smartsection_formatErrors($itemObj->getErrors()));
             exit;
         }
         // Removing tags information
         if (smartsection_tag_module_included()) {
             $tag_handler = xoops_getmodulehandler('tag', 'tag');
             $tag_handler->updateByItem('', $itemid, 'smartsection', 0);
         }
         redirect_header("item.php", 2, sprintf(_AM_SSECTION_ITEMISDELETED, $itemObj->title()));
         exit;
     } else {
         // no confirm: show deletion condition
         $itemid = isset($_GET['itemid']) ? intval($_GET['itemid']) : 0;
         xoops_cp_header();
         xoops_confirm(array('op' => 'del', 'itemid' => $itemObj->itemid(), 'confirm' => 1, 'name' => $itemObj->title()), 'item.php', _AM_SSECTION_DELETETHISITEM . " <br />'" . $itemObj->title() . "'. <br /> <br />", _AM_SSECTION_DELETE);
         xoops_cp_footer();