Пример #1
0
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;
}
Пример #2
0
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;
}