function xnppresentationUpdateItem($item_id) { global $xoopsDB; $xnpsid = $_SESSION['XNPSID']; $formdata =& xoonips_getutility('formdata'); $myts =& MyTextSanitizer::getInstance(); // modify BasicInformation, Index, Preview and Attachment. $result = xnpUpdateBasicInformation($item_id); if ($result) { $result = xnpUpdateIndex($item_id); if ($result) { $result = xnpUpdatePreview($item_id); if ($result) { $result = xnpUpdateAttachment($item_id, 'presentation_file'); if ($result) { $result = xnp_insert_change_log($xnpsid, $item_id, $formdata->getValue('post', 'change_log', 's', true)); $result = !$result; if (!$result) { echo ' xnp_insert_change_log failed.'; } } else { echo ' xnpUpdateAttachment failed.'; } } else { echo ' xnpUpdatePreview failed.'; } } else { echo ' xnpUpdateIndex failed.'; } } else { echo ' xnpUpdateBasicInformation failed.'; } if (!$result) { return false; } list($rights, $use_cc, $cc_commercial_use, $cc_modification) = xnpGetRights(); // trim strings $ar = array('presentation_type' => $formdata->getValue('post', 'presentation_type', 's', true), 'readme' => xnpGetTextFile('readme'), 'rights' => $rights); xnpTrimColumn($ar, 'xnppresentation_item_detail', array_keys($ar), _CHARSET); // register detail information $attachment_dl_limit = $formdata->getValue('post', 'attachment_dl_limit', 'i', true); $attachment_dl_notify = $formdata->getValue('post', 'attachment_dl_notify', 'i', true); $sql = implode(',', array('attachment_dl_limit' . '=\'' . $attachment_dl_limit . '\'', 'attachment_dl_notify' . '=\'' . ($attachment_dl_limit ? $attachment_dl_notify : 0) . '\'', 'presentation_type' . '=\'' . addslashes($ar['presentation_type']) . '\'', 'readme' . '=\'' . addslashes($ar['readme']) . '\'', 'rights' . '=\'' . addslashes($ar['rights']) . '\'', 'use_cc' . '=\'' . $use_cc . '\'', 'cc_commercial_use' . '=\'' . $cc_commercial_use . '\'', 'cc_modification' . '=\'' . $cc_modification . '\'')); $result = $xoopsDB->queryF('update ' . $xoopsDB->prefix('xnppresentation_item_detail') . " set {$sql} where presentation_id = {$item_id} "); if ($result == false) { return false; } // insert/update creator $formdata =& xoonips_getutility('formdata'); $creator_handler =& xoonips_getormhandler('xnppresentation', 'creator'); $creator_objs =& $formdata->getObjectArray('post', $creator_handler->getTableName(), $creator_handler, false); if (!$creator_handler->updateAllObjectsByForeignKey('presentation_id', $item_id, $creator_objs)) { return false; } return true; }
function xnpconferenceUpdateItem($item_id) { global $xoopsDB; $formdata =& xoonips_getutility('formdata'); $xnpsid = $_SESSION['XNPSID']; // edit BasicInformation, Index, Preview, Attachment $_POST['publicationDateYear'] = addslashes($formdata->getValue('post', 'conferenceFromYear', 'i', false)); $_POST['publicationDateMonth'] = addslashes($formdata->getValue('post', 'conferenceFromMonth', 'i', false)); $_POST['publicationDateDay'] = addslashes($formdata->getValue('post', 'conferenceFromDay', 'i', false)); $result = xnpUpdateBasicInformation($item_id); if ($result) { $result = xnpUpdateIndex($item_id); if ($result) { $result = xnpUpdatePreview($item_id); if ($result) { $result = xnpUpdateAttachment($item_id, 'conference_file'); if ($result) { $result = xnpUpdateAttachment($item_id, 'conference_paper'); if ($result) { $result = xnp_insert_change_log($xnpsid, $item_id, $formdata->getValue('post', 'change_log', 's', false)); $result = !$result; if (!$result) { echo ' xnp_insert_change_log failed.'; } } } else { echo ' xnpUpdateAttachment failed.'; } } else { echo ' xnpUpdatePreview failed.'; } } else { echo ' xnpUpdateIndex failed.'; } } else { echo ' xnpUpdateBasicInformation failed.'; } if (!$result) { return false; } // register DetailInformation // trim strings $ar = array('presentation_type' => $formdata->getValue('post', 'presentation_type', 's', false), 'conference_title' => $formdata->getValue('post', 'conference_title', 's', false), 'place' => $formdata->getValue('post', 'place', 's', false), 'abstract' => $formdata->getValue('post', 'abstract', 's', false)); xnpTrimColumn($ar, 'xnpconference_item_detail', array_keys($ar), _CHARSET); $attachment_dl_limit = $formdata->getValue('post', 'attachment_dl_limit', 'i', false); $attachment_dl_notify = $formdata->getValue('post', 'attachment_dl_notify', 'i', false); $sql = implode(',', array('attachment_dl_limit' . '=\'' . $attachment_dl_limit . '\'', 'attachment_dl_notify' . '=\'' . ($attachment_dl_limit ? $attachment_dl_notify : 0) . '\'', 'presentation_type' . '=\'' . addslashes($ar['presentation_type']) . '\'', 'conference_title' . '=\'' . addslashes($ar['conference_title']) . '\'', 'place' . '=\'' . addslashes($ar['place']) . '\'', 'abstract' . '=\'' . addslashes($ar['abstract']) . '\'', 'conference_from_year' . '=\'' . addslashes($formdata->getValue('post', 'conferenceFromYear', 'i', false)) . '\'', 'conference_from_month' . '=\'' . addslashes($formdata->getValue('post', 'conferenceFromMonth', 'i', false)) . '\'', 'conference_from_mday' . '=\'' . addslashes($formdata->getValue('post', 'conferenceFromDay', 'i', false)) . '\'', 'conference_to_year' . '=\'' . addslashes($formdata->getValue('post', 'conferenceToYear', 'i', false)) . '\'', 'conference_to_month' . '=\'' . addslashes($formdata->getValue('post', 'conferenceToMonth', 'i', false)) . '\'', 'conference_to_mday' . '=\'' . addslashes($formdata->getValue('post', 'conferenceToDay', 'i', false)) . '\'')); $result = $xoopsDB->queryF('update ' . $xoopsDB->prefix('xnpconference_item_detail') . " set {$sql} where conference_id = {$item_id} "); if ($result == false) { return false; } // insert/update author $author_handler =& xoonips_getormhandler('xnpconference', 'author'); $author_objs =& $formdata->getObjectArray('post', $author_handler->getTableName(), $author_handler, false); if (!$author_handler->updateAllObjectsByForeignKey('conference_id', $item_id, $author_objs)) { return false; } return true; }
function xnpmodelUpdateItem($item_id) { global $xoopsDB; $formdata =& xoonips_getutility('formdata'); $xnpsid = $_SESSION['XNPSID']; // edit BasicInformation, Index, Preview, Attachment $result = xnpUpdateBasicInformation($item_id); if ($result) { $result = xnpUpdateIndex($item_id); if ($result) { $result = xnpUpdatePreview($item_id); if ($result) { $result = xnpUpdateAttachment($item_id, 'model_data'); if ($result) { $result = xnp_insert_change_log($xnpsid, $item_id, $formdata->getValue('post', 'change_log', 's', false)); $result = !$result; if (!$result) { echo ' xnp_insert_change_log failed.'; } } else { echo ' xnpUpdateAttachment failed.'; } } else { echo ' xnpUpdatePreview failed.'; } } else { echo ' xnpUpdateIndex failed.'; } } else { echo ' xnpUpdateBasicInformation failed.'; } if (!$result) { return false; } list($rights, $use_cc, $cc_commercial_use, $cc_modification) = xnpGetRights(); // it makes strings with constant length $ar = array('model_type' => $formdata->getValue('post', 'model_type', 's', false), 'readme' => xnpGetTextFile('readme'), 'rights' => $rights); xnpTrimColumn($ar, 'xnpmodel_item_detail', array_keys($ar), _CHARSET); // insert Detail Information $attachment_dl_limit = $formdata->getValue('post', 'attachment_dl_limit', 'i', false); $attachment_dl_notify = $formdata->getValue('post', 'attachment_dl_notify', 'i', false); $keyval = array('attachment_dl_limit' . '=\'' . $attachment_dl_limit . '\'', 'attachment_dl_notify' . '=\'' . ($attachment_dl_limit ? $attachment_dl_notify : 0) . '\'', 'model_type' . '=\'' . addslashes($ar['model_type']) . '\'', 'readme' . '=\'' . addslashes($ar['readme']) . '\'', 'rights' . '=\'' . addslashes($ar['rights']) . '\'', 'use_cc' . '=\'' . $use_cc . '\'', 'cc_commercial_use' . '=\'' . $cc_commercial_use . '\'', 'cc_modification' . '=\'' . $cc_modification . '\''); // edit DetailInformation $sql = 'update ' . $xoopsDB->prefix('xnpmodel_item_detail') . ' set ' . implode(', ', $keyval) . " where model_id={$item_id}"; $result = $xoopsDB->queryF($sql); if ($result == false) { echo 'cannot update item_detail'; echo "\n{$sql}"; return false; } // insert/update creator $creator_handler =& xoonips_getormhandler('xnpmodel', 'creator'); $creator_objs =& $formdata->getObjectArray('post', $creator_handler->getTableName(), $creator_handler, false); if (!$creator_handler->updateAllObjectsByForeignKey('model_id', $item_id, $creator_objs)) { return false; } return true; }
function xnpfilesUpdateItem($item_id) { global $xoopsDB; $formdata =& xoonips_getutility('formdata'); $xnpsid = $_SESSION['XNPSID']; // edit BasicInformation, Index, Preview, Attachment $result = xnpUpdateBasicInformation($item_id); if ($result) { $result = xnpUpdateIndex($item_id); if ($result) { $result = xnpUpdatePreview($item_id); if ($result) { $result = xnpUpdateAttachment($item_id, 'files_file'); if ($result) { $result = xnp_insert_change_log($xnpsid, $item_id, $formdata->getValue('post', 'change_log', 's', false)); $result = !$result; if (!$result) { echo ' xnp_insert_change_log failed.'; } } else { echo ' xnpUpdateAttachment failed.'; } } else { echo ' xnpUpdatePreview failed.'; } } else { echo ' xnpUpdateIndex failed.'; } } else { echo ' xnpUpdateBasicInformation failed.'; } if (!$result) { return false; } // update item detail information $file_id = $formdata->getValue('post', 'files_fileFileID', 'i', false); $file_handler =& xoonips_getormhandler('xoonips', 'file'); $file_obj =& $file_handler->get($file_id); $file_name = $file_obj->get('original_file_name'); $file_mimetype = $file_obj->get('mime_type'); $file_pathinfo = pathinfo($file_name); $file_type = $file_pathinfo['extension']; $detail_handler =& xoonips_getormhandler('xnpfiles', 'item_detail'); $detail_obj =& $detail_handler->get($item_id); $detail_obj->set('data_file_name', $file_name); $detail_obj->set('data_file_mimetype', $file_mimetype); $detail_obj->set('data_file_filetype', $file_type); if (!$detail_handler->insert($detail_obj)) { echo 'cannot insert item_detail'; return false; } return true; }