本文整理汇总了PHP中Extension::editable方法的典型用法代码示例。如果您正苦于以下问题:PHP Extension::editable方法的具体用法?PHP Extension::editable怎么用?PHP Extension::editable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Extension
的用法示例。
在下文中一共展示了Extension::editable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_version
public function add_version()
{
if (empty($_POST['extension_id'])) {
exit;
}
# TODO
$extension = new Extension($_POST['extension_id']);
if (!$extension->editable()) {
show_403(__("Access Denied"), __("You do not have sufficient privileges to edit this extension.", "extend"));
}
if ($_FILES['extension']['error'] == 4) {
Flash::warning(__("You forgot the extension file, silly!", "extend"), $_SESSION['redirect_to']);
}
if (empty($_POST['number'])) {
Flash::warning(__("Please enter a version number.", "extend"), $_SESSION['redirect_to']);
}
if (empty($_POST['compatible'])) {
Flash::warning(__("Please list the Chyrp versions you know to be compatible with this extension.", "extend"), $_SESSION['redirect_to']);
}
$visitor = Visitor::current();
# 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($extension->type->url));
$image = $_FILES['image']['error'] == 0 ? upload($_FILES['image'], null, "previews/" . pluralize($extension->type->url)) : "";
$version = Version::add($_POST['number'], $_POST['description'], comma_sep($_POST['compatible']), comma_sep($_POST['tags']), $filename, $image, 0, 0, $extension);
$files = array();
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);
}
}
Flash::notice(__("Version added.", "extend"), $version->url());
}