Dotclear

source: admin/post_media.php @ 2256:d3c3fa1723ab

Revision 2256:d3c3fa1723ab, 2.3 KB checked in by Dsls, 11 years ago (diff)

updated most of notices to new format, should fix #1710 (maintenance and daInstaller still to be updated)

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
7# Licensed under the GPL version 2.0 license.
8# See LICENSE file or
9# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
10#
11# -- END LICENSE BLOCK -----------------------------------------
12
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('usage,contentadmin');
16
17$post_id = !empty($_REQUEST['post_id']) ? (integer) $_REQUEST['post_id'] : null;
18$media_id = !empty($_REQUEST['media_id']) ? (integer) $_REQUEST['media_id'] : null;
19
20if (!$post_id) {
21     exit;
22}
23$rs = $core->blog->getPosts(array('post_id' => $post_id,'post_type'=>''));
24if ($rs->isEmpty()) {
25     exit;
26}
27
28try {
29     if ($post_id && $media_id && !empty($_POST['attach']))
30     {
31          $core->media = new dcMedia($core);
32          $core->media->addPostMedia($post_id,$media_id);
33          http::redirect($core->getPostAdminURL($rs->post_type,$post_id,false));
34     }
35
36     $core->media = new dcMedia($core);
37     $f = $core->media->getPostMedia($post_id,$media_id);
38     if (empty($f)) {
39          $post_id = $media_id = null;
40          throw new Exception(__('This attachment does not exist'));
41     }
42     $f = $f[0];
43} catch (Exception $e) {
44     $core->error->add($e->getMessage());
45}
46
47# Remove a media from en
48if (($post_id && $media_id) || $core->error->flag())
49{
50     if (!empty($_POST['remove']))
51     {
52          $core->media->removePostMedia($post_id,$media_id);
53         
54          dcPage::addSuccessNotice(__('Attachment has been successfully removed.'));
55          http::redirect($core->getPostAdminURL($rs->post_type,$post_id,false));
56     }
57     elseif (isset($_POST['post_id'])) {
58          http::redirect($core->getPostAdminURL($rs->post_type,$post_id,false));
59     }
60     
61     if (!empty($_GET['remove']))
62     {
63          dcPage::open(__('Remove attachment'));
64         
65          echo '<h2>'.__('Attachment').' &rsaquo; <span class="page-title">'.__('confirm removal').'</span></h2>';
66         
67          echo
68          '<form action="post_media.php" method="post">'.
69          '<p>'.__('Are you sure you want to remove this attachment?').'</p>'.
70          '<p><input type="submit" class="reset" value="'.__('Cancel').'" /> '.
71          ' &nbsp; <input type="submit" class="delete" name="remove" value="'.__('Yes').'" />'.
72          form::hidden('post_id',$post_id).
73          form::hidden('media_id',$media_id).
74          $core->formNonce().'</p>'.
75          '</form>';
76         
77          dcPage::close();
78          exit;
79     }
80}
81?>
Note: See TracBrowser for help on using the repository browser.

Sites map