コード例 #1
0
ファイル: item.php プロジェクト: trabisdementia/publisher
             redirect_header('javascript:history.go(-1)', 3, $file_upload_result);
             //                exit;
         }
     }
     // Send notifications
     if ($notifToDo) {
         $itemObj->sendNotifications($notifToDo);
     }
     redirect_header('item.php', 2, $redirect_msg);
     break;
 case 'del':
     $itemObj =& $publisher->getHandler('item')->get($itemid);
     $confirm = XoopsRequest::getInt('confirm', '', 'POST');
     if ($confirm) {
         if (!$publisher->getHandler('item')->delete($itemObj)) {
             redirect_header('item.php', 2, _AM_PUBLISHER_ITEM_DELETE_ERROR . publisherFormatErrors($itemObj->getErrors()));
             //                exit();
         }
         redirect_header('item.php', 2, sprintf(_AM_PUBLISHER_ITEMISDELETED, $itemObj->getTitle()));
         //            exit();
     } else {
         xoops_cp_header();
         xoops_confirm(array('op' => 'del', 'itemid' => $itemObj->itemid(), 'confirm' => 1, 'name' => $itemObj->getTitle()), 'item.php', _AM_PUBLISHER_DELETETHISITEM . " <br />'" . $itemObj->getTitle() . "'. <br /> <br />", _AM_PUBLISHER_DELETE);
         xoops_cp_footer();
     }
     exit;
     break;
 case 'default':
 default:
     publisherCpHeader();
     //publisher_adminMenu(2, _AM_PUBLISHER_ITEMS);
コード例 #2
0
ファイル: file.php プロジェクト: trabisdementia/publisher
     break;
 case 'modify':
     $fileid = XoopsRequest::getInt('fileid', 0, 'POST');
     // Creating the file object
     if ($fileid != 0) {
         $fileObj =& $publisher->getHandler('file')->get($fileid);
     } else {
         $fileObj =& $publisher->getHandler('file')->create();
     }
     // Putting the values in the file object
     $fileObj->setVar('name', XoopsRequest::getString('name', '', 'POST'));
     $fileObj->setVar('description', XoopsRequest::getString('description', '', 'POST'));
     $fileObj->setVar('status', XoopsRequest::getInt('status', 0, 'POST'));
     // Storing the file
     if (!$fileObj->store()) {
         redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 3, _AM_PUBLISHER_FILE_EDITING_ERROR . publisherFormatErrors($fileObj->getErrors()));
         //            exit;
     }
     redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 2, _AM_PUBLISHER_FILE_EDITING_SUCCESS);
     //        exit();
     break;
 case 'del':
     $fileid = XoopsRequest::getInt('fileid', 0, 'POST');
     $fileid = XoopsRequest::getInt('fileid', $fileid, 'GET');
     $fileObj =& $publisher->getHandler('file')->get($fileid);
     $confirm = XoopsRequest::getInt('confirm', 0, 'POST');
     $title = XoopsRequest::getString('title', '', 'POST');
     if ($confirm) {
         if (!$publisher->getHandler('file')->delete($fileObj)) {
             redirect_header('item.php?op=mod&itemid=' . $fileObj->itemid() . '#tab_2', 2, _AM_PUBLISHER_FILE_DELETE_ERROR);
             //                exit;
コード例 #3
0
/**
 * @param  bool        $another
 * @param  bool        $withRedirect
 * @param              $itemObj
 * @return bool|string
 */
function publisherUploadFile($another = false, $withRedirect = true, &$itemObj)
{
    include_once PUBLISHER_ROOT_PATH . '/class/uploader.php';
    //    global $publisherIsAdmin;
    $publisher =& PublisherPublisher::getInstance();
    $itemId = XoopsRequest::getInt('itemid', 0, 'POST');
    $uid = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->uid() : 0;
    $session =& PublisherSession::getInstance();
    $session->set('publisher_file_filename', XoopsRequest::getString('item_file_name', '', 'POST'));
    $session->set('publisher_file_description', XoopsRequest::getString('item_file_description', '', 'POST'));
    $session->set('publisher_file_status', XoopsRequest::getInt('item_file_status', 1, 'POST'));
    $session->set('publisher_file_uid', $uid);
    $session->set('publisher_file_itemid', $itemId);
    if (!is_object($itemObj)) {
        $itemObj =& $publisher->getHandler('item')->get($itemId);
    }
    $fileObj =& $publisher->getHandler('file')->create();
    $fileObj->setVar('name', XoopsRequest::getString('item_file_name', '', 'POST'));
    $fileObj->setVar('description', XoopsRequest::getString('item_file_description', '', 'POST'));
    $fileObj->setVar('status', XoopsRequest::getInt('item_file_status', 1, 'POST'));
    $fileObj->setVar('uid', $uid);
    $fileObj->setVar('itemid', $itemObj->getVar('itemid'));
    $fileObj->setVar('datesub', time());
    // Get available mimetypes for file uploading
    $allowedMimetypes =& $publisher->getHandler('mimetype')->getArrayByType();
    // TODO : display the available mimetypes to the user
    $errors = array();
    if ($publisher->getConfig('perm_upload') && is_uploaded_file($_FILES['item_upload_file']['tmp_name'])) {
        if (!($ret = $fileObj->checkUpload('item_upload_file', $allowedMimetypes, $errors))) {
            $errorstxt = implode('<br />', $errors);
            $message = sprintf(_CO_PUBLISHER_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($allowedMimetypes)) {
        //        if ($withRedirect) {
        //            redirect_header("file.php?op=mod&itemid=" . $fileObj->itemid(), 3, _CO_PUBLISHER_FILEUPLOAD_ERROR . publisherFormatErrors($fileObj->getErrors()));
        //            exit;
        //        }
        try {
            if ($withRedirect) {
                throw new Exception(_CO_PUBLISHER_FILEUPLOAD_ERROR . publisherFormatErrors($fileObj->getErrors()));
            }
        } catch (Exception $e) {
            redirect_header('file.php?op=mod&itemid=' . $fileObj->itemid(), 3, _CO_PUBLISHER_FILEUPLOAD_ERROR . publisherFormatErrors($fileObj->getErrors()));
        }
        //    } else {
        //        return _CO_PUBLISHER_FILEUPLOAD_ERROR . publisherFormatErrors($fileObj->getErrors());
    }
    if ($withRedirect) {
        $redirectPage = $another ? 'file.php' : 'item.php';
        redirect_header($redirectPage . '?op=mod&itemid=' . $fileObj->itemid(), 2, _CO_PUBLISHER_FILEUPLOAD_SUCCESS);
    } else {
        return true;
    }
    return null;
}
コード例 #4
0
ファイル: category.php プロジェクト: trabisdementia/publisher
     // TODO : put this function in the category class
     publisherSaveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
     publisherSaveCategoryPermissions($grpsubmit, $categoryObj->categoryid(), 'item_submit');
     publisherSaveCategoryPermissions($grpmoderation, $categoryObj->categoryid(), 'category_moderation');
     //Added by fx2024
     $parentCat = $categoryObj->categoryid();
     $sizeof = count(XoopsRequest::getString('scname', '', 'POST'));
     for ($i = 0; $i < $sizeof; ++$i) {
         $temp = XoopsRequest::getArray('scname', array(), 'POST');
         if ($temp[$i] != '') {
             $categoryObj =& $publisher->getHandler('category')->create();
             $temp2 = XoopsRequest::getArray('scname', array(), 'POST');
             $categoryObj->setVar('name', $temp2[$i]);
             $categoryObj->setVar('parentid', $parentCat);
             if (!$categoryObj->store()) {
                 redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_SUBCATEGORY_SAVE_ERROR . publisherFormatErrors($categoryObj->getErrors()));
                 //                    exit;
             }
             // TODO : put this function in the category class
             publisherSaveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
             publisherSaveCategoryPermissions($grpsubmit, $categoryObj->categoryid(), 'item_submit');
             publisherSaveCategoryPermissions($grpmoderation, $categoryObj->categoryid(), 'category_moderation');
         }
     }
     //end of fx2024 code
     redirect_header($redirect_to, 2, $redirect_msg);
     //        exit();
     break;
     //Added by fx2024
 //Added by fx2024
 case 'addsubcats':