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 xnpbookUpdateItem($book_id) { // set fixed value for month and day $_POST['publicationDateMonth'] = 1; $_POST['publicationDateDay'] = 1; $formdata =& xoonips_getutility('formdata'); // edit BasicInformation, Index, Preview, Attachment $result = xnpUpdateBasicInformation($book_id); if ($result) { $result = xnpUpdateIndex($book_id); if ($result) { $result = xnpUpdateAttachment($book_id, 'book_pdf'); if ($result) { $result = xnp_insert_change_log($_SESSION['XNPSID'], $book_id, $formdata->getValue('post', 'change_log', 's', false)); $result = !$result; if (!$result) { error_log('xnp_insert_change_log failed.'); } } else { error_log('xnpUpdateAttachment failed.'); } } else { error_log('xnpUpdateIndex failed.'); } } else { error_log('xnpUpdateBasicInformation failed.'); } if (!$result) { return false; } // limit length $ar = _xnpbook_get_detail_request(); xnpTrimColumn($ar, 'xnpbook_item_detail', array_keys($ar), _CHARSET); $hItemDetail =& xoonips_getormhandler('xnpbook', 'item_detail'); $oItemDetail =& $hItemDetail->get($book_id); $oItemDetail->setVars($ar, true); // not gpc if (!$hItemDetail->insert($oItemDetail)) { error_log('xnpbook: cannot update item_detail - ' . implode(', ', $oItemDetail->getErrors())); return false; } // insert/update author $formdata =& xoonips_getutility('formdata'); $author_handler =& xoonips_getormhandler('xnpbook', 'author'); $author_objs =& $formdata->getObjectArray('post', $author_handler->getTableName(), $author_handler, false); if (!$author_handler->updateAllObjectsByForeignKey('book_id', $book_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 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 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; }
function xnppaperUpdateItem($item_id) { global $xoopsDB; $formdata =& xoonips_getutility('formdata'); $xnpsid = $_SESSION['XNPSID']; // modify BasicInformation, Index, Attachment $result = xnpUpdateBasicInformation($item_id); if ($result) { $result = xnpUpdateIndex($item_id); if ($result) { $result = xnpUpdateAttachment($item_id, 'paper_pdf_reprint'); if ($result) { $result = xnp_insert_change_log($xnpsid, $item_id, $formdata->getValue('post', 'change_log', 's', false)); $result = !$result; if (!$result) { error_log('xnp_insert_change_log failed.'); } } else { error_log('xnpUpdateAttachment failed.'); } } else { error_log('xnpUpdateIndex failed.'); } } else { error_log('xnpUpdateBasicInformation failed.'); } if (!$result) { return false; } // trim strings $journal = $formdata->getValue('post', 'journal', 's', false); $volume = $formdata->getValue('post', 'volume', 's', false); $number = $formdata->getValue('post', 'number', 's', false); $page = $formdata->getValue('post', 'page', 's', false); $abstract = $formdata->getValue('post', 'abstract', 's', false); $pubmed_id = $formdata->getValue('post', 'pubmed_id', 's', false); $ar = array('journal' => $journal, 'page' => $page, 'abstract' => $abstract, 'pubmed_id' => $pubmed_id); xnpTrimColumn($ar, 'xnppaper_item_detail', array_keys($ar), _CHARSET); // register detail information $sql = implode(',', array('journal' . '=\'' . addslashes($ar['journal']) . '\'', 'volume' . '=' . (strlen($volume) == 0 ? 'null' : (int) $volume), 'number' . '=' . (strlen($number) == 0 ? 'null' : (int) $number), 'page' . '=' . (strlen($page) == 0 ? 'null' : '\'' . addslashes($ar['page']) . '\''), 'abstract' . '=' . (strlen($abstract) == 0 ? 'null' : '\'' . addslashes($ar['abstract']) . '\''), 'pubmed_id' . '=' . (strlen($pubmed_id) == 0 ? 'null' : '\'' . addslashes($ar['pubmed_id']) . '\''))); $result = $xoopsDB->queryF('update ' . $xoopsDB->prefix('xnppaper_item_detail') . " set {$sql} where paper_id = {$item_id} "); if ($result == false) { return false; } // insert/update author $author_handler =& xoonips_getormhandler('xnppaper', 'author'); $author_objs =& $formdata->getObjectArray('post', $author_handler->getTableName(), $author_handler, false); if (!$author_handler->updateAllObjectsByForeignKey('paper_id', $item_id, $author_objs)) { return false; } return true; }
function xnpmemoUpdateItem($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 = xnpUpdateAttachment($item_id, 'memo_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 ' xnpUpdateIndex failed.'; } } else { echo ' xnpUpdateBasicInformation failed.'; } if (!$result) { return false; } $ar = array('item_link' => preg_replace('/javascript:/i', '', preg_replace('/[\\x00-\\x20\\x22\\x27]/', '', $formdata->getValue('post', 'item_link', 's', false)))); xnpTrimColumn($ar, 'xnpmemo_item_detail', array_keys($ar), _CHARSET); // register DetailInformation $sql = implode(',', array('item_link' . '=\'' . addslashes($ar['item_link']) . '\'')); $result = $xoopsDB->queryF('update ' . $xoopsDB->prefix('xnpmemo_item_detail') . " set {$sql} where memo_id = {$item_id} "); if ($result == false) { return false; } return true; }