function addFolder($language_text = false) { global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $myts, $smartmedia_folder_handler; include_once XOOPS_ROOT_PATH . "/class/uploader.php"; $max_size = 10000000; $max_imgwidth = 1000; $max_imgheight = 1000; $allowed_mimetypes = smartmedia_getAllowedMimeTypes(); $upload_msgs = array(); $folderid = isset($_POST['folderid']) ? intval($_POST['folderid']) : 0; if (isset($_POST['languageid'])) { $languageid = $_POST['languageid']; } elseif (isset($_POST['default_languageid'])) { $languageid = $_POST['default_languageid']; } else { $languageid = $xoopsModuleConfig['default_language']; } if ($folderid != 0) { $folderObj = $smartmedia_folder_handler->get($folderid, $languageid); } else { $folderObj = $smartmedia_folder_handler->create(); } if (!$language_text) { /* // Upload lr_image if ( $_FILES['lr_image_file']['name'] != "" ) { $filename = $_POST["xoops_upload_file"][0] ; if( !empty( $filename ) || $filename != "" ) { if( $_FILES[$filename]['tmp_name'] == "" || ! is_readable( $_FILES[$filename]['tmp_name'] ) ) { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } else { $uploader = new XoopsMediaUploader(smartmedia_getImageDir('folder'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if( $uploader->fetchMedia( $filename ) && $uploader->upload() ) { $folderObj->setVar('image_lr', $uploader->getSavedFileName()); } else { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } } } } else { $folderObj->setVar('image_lr', $_POST['image_lr']); } */ // Upload hr_image if ($_FILES['hr_image_file']['name'] != "") { $filename = $_POST["xoops_upload_file"][0]; if (!empty($filename) || $filename != "") { if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } else { $uploader = new XoopsMediaUploader(smartmedia_getImageDir('folder'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($filename) && $uploader->upload()) { $folderObj->setVar('image_hr', $uploader->getSavedFileName()); } else { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } } } } else { $folderObj->setVar('image_hr', $_POST['image_hr']); } $folderObj->setVar('statusid', isset($_POST['statusid']) ? intval($_POST['statusid']) : 0); $folderObj->setVar('categoryid', isset($_POST['categoryid']) ? intval($_POST['categoryid']) : 0); $folderObj->setVar('new_category', isset($_POST['category_action']) ? $_POST['category_action'] == 'add' : false); $folderObj->setVar('weight', isset($_POST['weight']) ? intval($_POST['weight']) : 1); $folderObj->setVar('default_languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); $folderObj->setTextVar('languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); } else { $folderObj->setTextVar('languageid', $languageid); } $folderObj->setTextVar('languageid', $languageid); $folderObj->setTextVar('title', $_POST['title']); $folderObj->setTextVar('short_title', $_POST['short_title']); $folderObj->setTextVar('summary', $_POST['summary']); $folderObj->setTextVar('description', $_POST['description']); $folderObj->setTextVar('meta_description', $_POST['meta_description']); if ($folderObj->isNew()) { $redirect_msg = _AM_SMEDIA_FOLDER_CREATED; $redirect_to = 'folder.php'; } else { if ($language_text) { $redirect_to = 'folder.php?op=mod&folderid=' . $folderObj->folderid(); } else { $redirect_to = 'folder.php'; } $redirect_msg = _AM_SMEDIA_FOLDER_MODIFIED; } if (!$folderObj->store()) { redirect_header("javascript:history.go(-1)", 3, _AM_SMEDIA_FOLDER_SAVE_ERROR . smartmedia_formatErrors($folderObj->getErrors())); exit; } redirect_header($redirect_to, 2, $redirect_msg); exit; }
redirect_header("index.php", 3, _NOPERM); exit; } } else { $uid = $xoopsUser->uid(); } // Putting the values about the ITEM in the ITEM object $newItemObj->setVar('categoryid', $_POST['categoryid']); $newItemObj->setVar('uid', $uid); $newItemObj->setVar('title', $_POST['title']); $newItemObj->setVar('summary', $_POST['summary']); $newItemObj->setVar('body', $_POST['body']); $newItemObj->setVar('notifypub', $_POST['notifypub']); // Storing the item object in the database if (!$newItemObj->store()) { redirect_header("javascript:history.go(-1)", 3, _MD_SMEDIA_SUBMIT_ERROR . smartmedia_formatErrors($newItemObj->getErrors())); exit; } // Get the cateopry object related to that item $categoryObj =& $newItemObj->category(); // If autoapprove_submitted if ($xoopsModuleConfig['autoapprove_submitted'] == 1) { // We do not not subscribe user to notification on publish since we publish it right away // Send notifications $newItemObj->sendNotifications(array(_SMEDIA_NOT_ITEM_PUBLISHED)); $redirect_msg = _MD_SMEDIA_ITEM_RECEIVED_AND_PUBLISHED; } else { // Subscribe the user to On Published notification, if requested if ($_POST['notifypub'] == 1) { include_once XOOPS_ROOT_PATH . '/include/notification_constants.php'; $notification_handler =& xoops_gethandler('notification');
function addClip($language_text = false) { global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $myts, $smartmedia_clip_handler; include_once XOOPS_ROOT_PATH . "/class/uploader.php"; $max_size = 10000000; $max_imgwidth = 1000; $max_imgheight = 1000; $allowed_mimetypes = smartmedia_getAllowedMimeTypes(); $upload_msgs = array(); $clipid = isset($_POST['clipid']) ? intval($_POST['clipid']) : 0; if (isset($_POST['languageid'])) { $languageid = $_POST['languageid']; } elseif (isset($_POST['default_languageid'])) { $languageid = $_POST['default_languageid']; } else { $languageid = $xoopsModuleConfig['default_language']; } if ($clipid != 0) { $clipObj = $smartmedia_clip_handler->get($clipid, $languageid); } else { $clipObj = $smartmedia_clip_handler->create(); } if (!$language_text) { /* // Upload lr_image if ( $_FILES['lr_image_file']['name'] != "" ) { $filename = $_POST["xoops_upload_file"][0] ; if( !empty( $filename ) || $filename != "" ) { if( $_FILES[$filename]['tmp_name'] == "" || ! is_readable( $_FILES[$filename]['tmp_name'] ) ) { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } else { $uploader = new XoopsMediaUploader(smartmedia_getImageDir('clip'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if( $uploader->fetchMedia( $filename ) && $uploader->upload() ) { $clipObj->setVar('image_lr', $uploader->getSavedFileName()); } else { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } } } } else { $clipObj->setVar('image_lr', $_POST['image_lr']); } */ // Upload hr_image if ($_FILES['hr_image_file']['name'] != "") { $filename = $_POST["xoops_upload_file"][0]; if (!empty($filename) || $filename != "") { if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } else { $uploader = new XoopsMediaUploader(smartmedia_getImageDir('clip'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($filename) && $uploader->upload()) { $clipObj->setVar('image_hr', $uploader->getSavedFileName()); } else { $upload_msgs[_AM_SMEDIA_FILEUPLOAD_ERROR]; } } } } else { $clipObj->setVar('image_hr', $_POST['image_hr']); } //var_dump($uploader->errors); //exit; $clipObj->setVar('width', isset($_POST['width']) ? intval($_POST['width']) : 320); $clipObj->setVar('height', isset($_POST['height']) ? intval($_POST['height']) : 260); $clipObj->setVar('folderid', isset($_POST['folderid']) ? intval($_POST['folderid']) : 0); $clipObj->setVar('weight', isset($_POST['weight']) ? intval($_POST['weight']) : 1); $clipObj->setVar('file_hr', $_POST['file_hr']); $clipObj->setVar('file_lr', $_POST['file_lr']); $clipObj->setVar('formatid', $_POST['formatid']); $clipObj->setVar('default_languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); $clipObj->setTextVar('languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); } else { $clipObj->setTextVar('languageid', $languageid); } $clipObj->setTextVar('languageid', $languageid); $clipObj->setTextVar('title', $_POST['title']); $clipObj->setTextVar('description', $_POST['description']); $clipObj->setTextVar('meta_description', $_POST['meta_description']); $clipObj->setTextVar('tab_caption_1', $_POST['tab_caption_1']); $clipObj->setTextVar('tab_text_1', $_POST['tab_text_1']); $clipObj->setTextVar('tab_caption_2', $_POST['tab_caption_2']); $clipObj->setTextVar('tab_text_2', $_POST['tab_text_2']); $clipObj->setTextVar('tab_caption_3', $_POST['tab_caption_3']); $clipObj->setTextVar('tab_text_3', $_POST['tab_text_3']); if (!$xoopsUser) { $uid = 0; } else { $uid = $xoopsUser->uid(); } $clipObj->setVar('modified_uid', $uid); if ($clipObj->isNew()) { $clipObj->setVar('created_uid', $uid); $redirect_msg = _AM_SMEDIA_CLIP_CREATED; $redirect_to = 'clip.php'; } else { if ($language_text) { $redirect_to = 'clip.php?op=mod&clipid=' . $clipObj->clipid(); } else { if (isset($_GET['from_within'])) { // To come... } $redirect_to = 'clip.php'; } $redirect_msg = _AM_SMEDIA_CLIP_MODIFIED; } if (!$clipObj->store()) { redirect_header("javascript:history.go(-1)", 3, _AM_SMEDIA_CLIP_SAVE_ERROR . smartmedia_formatErrors($clipObj->getErrors())); exit; } redirect_header($redirect_to, 2, $redirect_msg); exit; }
function addCategory($language_text = false) { global $xoopsUser, $xoopsConfig, $xoopsModule, $xoopsModuleConfig, $myts, $smartmedia_category_handler; $categoryid = isset($_POST['categoryid']) ? intval($_POST['categoryid']) : 0; if (isset($_POST['languageid'])) { $languageid = $_POST['languageid']; } elseif (isset($_POST['default_languageid'])) { $languageid = $_POST['default_languageid']; } else { $languageid = $xoopsModuleConfig['default_language']; } if ($categoryid != 0) { $categoryObj = $smartmedia_category_handler->get($categoryid, $languageid); } else { $categoryObj = $smartmedia_category_handler->create(); } // Uploading the image, if any // Retreive the filename to be uploaded if (!$language_text) { if ($_FILES['image_file']['name'] != "") { $filename = $_POST["xoops_upload_file"][0]; if (!empty($filename) || $filename != "") { global $xoopsModuleConfig; $max_size = 10000000; $max_imgwidth = 1000; $max_imgheight = 1000; $allowed_mimetypes = smartmedia_getAllowedMimeTypes(); include_once XOOPS_ROOT_PATH . "/class/uploader.php"; if ($_FILES[$filename]['tmp_name'] == "" || !is_readable($_FILES[$filename]['tmp_name'])) { redirect_header('javascript:history.go(-1)', 2, _AM_SMEDIA_FILEUPLOAD_ERROR); exit; } $uploader = new XoopsMediaUploader(smartmedia_getImageDir('category'), $allowed_mimetypes, $max_size, $max_imgwidth, $max_imgheight); if ($uploader->fetchMedia($filename) && $uploader->upload()) { $categoryObj->setVar('image', $uploader->getSavedFileName()); } else { redirect_header('javascript:history.go(-1)', 2, _AM_SMEDIA_FILEUPLOAD_ERROR . $uploader->getErrors()); exit; } } } else { $categoryObj->setVar('image', $_POST['image']); } $categoryObj->setVar('parentid', isset($_POST['parentid']) ? intval($_POST['parentid']) : 0); $categoryObj->setVar('weight', isset($_POST['weight']) ? intval($_POST['weight']) : 1); $categoryObj->setVar('default_languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); $categoryObj->setTextVar('languageid', isset($_POST['default_languageid']) ? $_POST['default_languageid'] : $xoopsModuleConfig['default_language']); } else { $categoryObj->setTextVar('languageid', $languageid); } $categoryObj->setTextVar('title', $_POST['title']); $categoryObj->setTextVar('description', $_POST['description']); if ($categoryObj->isNew()) { $redirect_msg = _AM_SMEDIA_CATCREATED; $redirect_to = 'category.php'; } else { if ($language_text) { $redirect_to = 'category.php?op=mod&categoryid=' . $categoryObj->categoryid(); } else { $redirect_to = 'category.php'; } $redirect_msg = _AM_SMEDIA_COLMODIFIED; } if (!$categoryObj->store()) { redirect_header("javascript:history.go(-1)", 3, _AM_SMEDIA_CATEGORY_SAVE_ERROR . smartmedia_formatErrors($categoryObj->getErrors())); exit; } redirect_header($redirect_to, 2, $redirect_msg); exit; }
redirect_header("format.php", 3, $redirect_msgs['error'] . smartmedia_formatErrors($formatObj->getErrors())); exit; } redirect_header("javascript:history.go(-2)", 2, $redirect_msgs['success']); exit; break; case "del": $id = isset($_POST['formatid']) ? intval($_POST['formatid']) : 0; $id = isset($_GET['formatid']) ? intval($_GET['formatid']) : $id; $formatObj = new SmartmediaFormat($id); $confirm = isset($_POST['confirm']) ? $_POST['confirm'] : 0; $title = isset($_POST['format']) ? $_POST['format'] : ''; $redirect_msgs = $formatObj->getRedirectMsg('delete'); if ($confirm) { if (!$smartmedia_format_handler->delete($formatObj)) { redirect_header("format.php", 2, $redirect_msgs['error'] . smartmedia_formatErrors($formatObj->getErrors())); exit; } redirect_header("javascript:history.go(-2)", 2, $redirect_msgs['success']); exit; } else { // no confirm: show deletion condition $id = isset($_GET['formatid']) ? intval($_GET['formatid']) : 0; xoops_cp_header(); xoops_confirm(array('op' => 'del', 'formatid' => $formatObj->formatid(), 'confirm' => 1, 'title' => $formatObj->format()), 'format.php', _AM_SMEDIA_FORMAT_DELETE_CONFIRM . " <br />'" . $formatObj->format() . "' <br /> <br />", _AM_SMEDIA_DELETE); xoops_cp_footer(); } exit; break; case "default": default: