~ubuntu-branches/ubuntu/hardy/gallery2/hardy-security

« back to all changes in this revision

Viewing changes to modules/linkitem/LinkItemOption.inc

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2006-04-16 16:42:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060416164235-8uy0u4bfjdxpge2o
Tags: 2.1.1-1
* New upstream release (Closes: #362936)
  + Bugfixes for Postgres7 (Closes: #359000, #362152)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * $RCSfile: LinkItemOption.inc,v $
 
4
 *
 
5
 * Gallery - a web based photo album viewer and editor
 
6
 * Copyright (C) 2000-2006 Bharat Mediratta
 
7
 *
 
8
 * This program is free software; you can redistribute it and/or modify
 
9
 * it under the terms of the GNU General Public License as published by
 
10
 * the Free Software Foundation; either version 2 of the License, or (at
 
11
 * your option) any later version.
 
12
 *
 
13
 * This program is distributed in the hope that it will be useful, but
 
14
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
16
 * General Public License for more details.
 
17
 *
 
18
 * You should have received a copy of the GNU General Public License
 
19
 * along with this program; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 
21
 */
 
22
 
 
23
/**
 
24
 * @version $Revision: 1.2 $ $Date: 2006/01/10 04:40:35 $
 
25
 * @package LinkItem
 
26
 * @subpackage UserInterface
 
27
 * @author Alan Harder <alan.harder@sun.com>
 
28
 */
 
29
 
 
30
/**
 
31
 * ItemEditOption for editing the target of a LinkItem
 
32
 *
 
33
 * @package LinkItem
 
34
 * @subpackage UserInterface
 
35
 *
 
36
 */
 
37
class LinkItemOption extends ItemEditOption {
 
38
 
 
39
    /**
 
40
     * @see ItemEditOption::isAppropriate
 
41
     */
 
42
    function isAppropriate($item, $thumbnail) {
 
43
        return array(null,
 
44
            GalleryUtilities::isA($item, 'GalleryLinkItem') && !is_numeric($item->getLink()));
 
45
    }
 
46
 
 
47
    /**
 
48
     * @see ItemEditOption::loadTemplate
 
49
     */
 
50
    function loadTemplate(&$template, &$form, $item, $thumbnail) {
 
51
        if (!isset($form['LinkItemOption'])) {
 
52
            $form['LinkItemOption']['link'] = $item->getLink();
 
53
        }
 
54
 
 
55
        return array(null,
 
56
                    'modules/linkitem/templates/LinkItemOption.tpl',
 
57
                    'modules_linkitem');
 
58
    }
 
59
 
 
60
    /**
 
61
     * @see ItemEditOption::handleRequestAfterEdit
 
62
     */
 
63
    function handleRequestAfterEdit($form, &$item, &$preferred) {
 
64
        $error = $warning = array();
 
65
        if (empty($form['LinkItemOption']['link'])) {
 
66
            $error[] = 'form[LinkItemOption][error][link][missing]';
 
67
        } else {
 
68
            list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock(array($item->getId()));
 
69
            if ($ret) {
 
70
                return array($ret->wrap(__FILE__, __LINE__), null, null);
 
71
            }
 
72
 
 
73
            $item->setLink($form['LinkItemOption']['link']);
 
74
            $ret = $item->save();
 
75
            if ($ret) {
 
76
                GalleryCoreApi::releaseLocks($lockId);
 
77
                return array($ret->wrap(__FILE__, __LINE__), null, null);
 
78
            }
 
79
 
 
80
            $ret = GalleryCoreApi::releaseLocks($lockId);
 
81
            if ($ret) {
 
82
                return array($ret->wrap(__FILE__, __LINE__), null, null);
 
83
            }
 
84
        }
 
85
 
 
86
        return array(null, $error, $warning);
 
87
    }
 
88
}
 
89
?>