当前位置: 首页>>代码示例>>PHP>>正文


PHP Version::update方法代码示例

本文整理汇总了PHP中Version::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Version::update方法的具体用法?PHP Version::update怎么用?PHP Version::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Version的用法示例。


在下文中一共展示了Version::update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update_version

    public function update_version()
    {
        if (!isset($_POST['version_id'])) {
            error(__("Error"), __("No version ID specified.", "extend"));
        }
        $version = new Version($_POST['version_id'], array("filter" => false));
        if ($version->no_results) {
            error(__("Error"), __("Invalid version ID specified.", "extend"));
        }
        if (!$version->editable()) {
            show_403(__("Access Denied"), __("You do not have sufficient privileges to edit this version.", "extend"));
        }
        $files = array();
        if (!empty($_FILES['attachment'])) {
            foreach ($_FILES['attachment'] as $key => $val) {
                foreach ($val as $file => $attr) {
                    $files[$file][$key] = $attr;
                }
            }
        }
        foreach ($files as $attachment) {
            if ($attachment['error'] != 4) {
                $path = upload($attachment, null, "attachments");
                Attachment::add(basename($path), $path, "version", $version->id);
            }
        }
        $version->extension->update($_POST['name']);
        if ($_FILES['extension']['error'] == 0) {
            @unlink(uploaded($version->filename, true));
            # Add the MIT license if no license is specified
            $zip = new ZipArchive();
            if ($zip->open($_FILES['extension']['tmp_name']) === true and $zip->locateName("LICENSE") === false) {
                $header = "Copyright (c) " . date("Y") . " " . oneof($visitor->full_name, $visitor->login);
                $mit = <<<EOF
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name(s) of the above
copyright holders shall not be used in advertising or otherwise
to promote the sale, use or other dealings in this Software
without prior written authorization.
EOF;
                $zip->addFromString("LICENSE", $header . "\n\n" . $mit . "\n");
                $zip->close();
            }
            $filename = upload($_FILES['extension'], "zip", "extension/" . pluralize($version->extension->type->url));
        } else {
            $filename = $version->filename;
        }
        if ($_FILES['image']['error'] == 0) {
            @unlink(uploaded($version->image, true));
            $image = upload($_FILES['image'], null, "previews/" . pluralize($version->extension->type->url));
        } else {
            $image = $version->image;
        }
        $version->update($_POST['number'], $_POST['description'], comma_sep($_POST['compatible']), comma_sep($_POST['tags']), $filename, $image);
        Flash::notice(__("Version updated.", "extend"), $version->url());
    }
开发者ID:vito,项目名称:chyrp-site,代码行数:76,代码来源:controller.Extend.php

示例2: redirect

        $hasData = true;
    }
    if (!empty($_POST['url'])) {
        $v->url = $_POST['url'];
        $hasData = true;
    }
    if (!empty($_POST['signature'])) {
        $v->signature = $_POST['signature'];
        $hasData = true;
    }
    if (!empty($_POST['filesize'])) {
        $v->filesize = $_POST['filesize'];
        $hasData = true;
    }
    if ($hasData) {
        $v->update();
    }
    redirect('version-edit.php?id=' . $v->id);
}
// END adib 7-Apr-2010 18:53
if (isset($_POST['btnDelete'])) {
    $v->delete();
    redirect('versions.php?id=' . $app->id);
}
$version_number = $v->version_number;
$human_version = $v->human_version;
$release_notes = $v->release_notes;
$url = $v->url;
$signature = $v->signature;
$filesize = $v->filesize;
?>
开发者ID:adib,项目名称:Shine,代码行数:31,代码来源:version-edit.php


注:本文中的Version::update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。