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

« back to all changes in this revision

Viewing changes to modules/imageblock/module.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:
3
3
 * $RCSfile: module.inc,v $
4
4
 *
5
5
 * Gallery - a web based photo album viewer and editor
6
 
 * Copyright (C) 2000-2005 Bharat Mediratta
 
6
 * Copyright (C) 2000-2006 Bharat Mediratta
7
7
 *
8
8
 * This program is free software; you can redistribute it and/or modify
9
9
 * it under the terms of the GNU General Public License as published by
20
20
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
21
21
 */
22
22
/**
23
 
 * @version $Revision: 1.57 $ $Date: 2005/09/10 20:28:13 $
 
23
 * @version $Revision: 1.65.2.1 $ $Date: 2006/04/16 07:06:44 $
24
24
 * @package ImageBlock
25
25
 * @author Alan Harder <alan.harder@sun.com>
26
26
 */
37
37
        $this->setId('imageblock');
38
38
        $this->setName($gallery->i18n('Image Block'));
39
39
        $this->setDescription($gallery->i18n('Random, Most Recent or Most Viewed Photo or Album'));
40
 
        $this->setVersion('1.0.0');
41
 
        $this->setGroup('blocks', $this->translate('Blocks'));
 
40
        $this->setVersion('1.0.8');
 
41
        $this->setGroup('blocks', $gallery->i18n('Blocks'));
42
42
        $this->setCallbacks('registerEventListeners|getSiteAdminViews');
43
 
        $this->setRequiredCoreApi(array(6, 0));
44
 
        $this->setRequiredModuleApi(array(2, 0));
 
43
        $this->setRequiredCoreApi(array(7, 0));
 
44
        $this->setRequiredModuleApi(array(3, 0));
45
45
    }
46
46
 
47
47
    /**
48
48
     * @see GalleryModule::registerEventListeners()
49
49
     */
50
50
    function registerEventListeners() {
51
 
        GalleryCoreApi::relativeRequireOnce('modules/imageblock/classes/ImageBlockHelper.class');
 
51
        GalleryCoreApi::requireOnce('modules/imageblock/classes/ImageBlockHelper.class');
52
52
        $listener = new ImageBlockHelper();
53
53
        GalleryCoreApi::registerEventListener('Gallery::ViewableTreeChange', $listener);
54
54
        GalleryCoreApi::registerEventListener('GalleryEntity::save', $listener, true);
59
59
     * @see GalleryModule::upgrade()
60
60
     */
61
61
    function upgrade($currentVersion) {
 
62
        global $gallery;
 
63
 
 
64
        if (!empty($currentVersion) && version_compare($currentVersion, '1.0.1', '<')) {
 
65
            $storage =& $gallery->getStorage();
 
66
            $ret = $storage->configureStore($this->getId(), array('ImageBlockCacheMap:1.0'));
 
67
            if ($ret) {
 
68
                return $ret->wrap(__FILE__, __LINE__);
 
69
            }
 
70
        }
 
71
 
62
72
        list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'imageblock');
63
 
        if ($ret->isError()) {
 
73
        if ($ret) {
64
74
            return $ret->wrap(__FILE__, __LINE__);
65
75
        }
66
76
        foreach (array('show' => 'heading|title|date|views', 'albumFrame' => '', 'itemFrame' => '')
67
77
                as $key => $value) {
68
78
            if (!isset($params[$key])) {
69
79
                $ret = $this->setParameter($key, $value);
70
 
                if ($ret->isError()) {
 
80
                if ($ret) {
71
81
                    return $ret->wrap(__FILE__, __LINE__);
72
82
                }
73
83
            }
74
84
        }
75
85
 
76
 
        return GalleryStatus::success();
 
86
        /* Remove the blocks parameter if necessary, we forgot to remove it in beta 4 */
 
87
        if (isset($params['blocks'])) {
 
88
            $ret = GalleryCoreApi::removePluginParameter('module', 'imageblock', 'blocks');
 
89
            if ($ret) {
 
90
                return $ret->wrap(__FILE__, __LINE__);
 
91
            }
 
92
        }
 
93
 
 
94
        return null;
77
95
    }
78
96
 
79
97
    /**
83
101
        $ret = GalleryCoreApi::registerFactoryImplementation(
84
102
           'ItemEditOption', 'ImageBlockOption', 'ImageBlockOption',
85
103
           'modules/imageblock/ImageBlockOption.inc', 'imageblock', array('ItemEditAlbum'));
86
 
        if ($ret->isError()) {
 
104
        if ($ret) {
87
105
            return $ret->wrap(__FILE__, __LINE__);
88
106
        }
89
107
 
90
 
        return GalleryStatus::success();
91
 
    }
92
 
 
93
 
    /**
94
 
     * @see GalleryModule::isRecommendedDuringInstall()
95
 
     */
96
 
    function isRecommendedDuringInstall() {
97
 
        return false;
98
 
    }
99
 
 
100
 
    /**
101
 
     * @see GalleryModule::autoConfigure()
102
 
     */
103
 
    function autoConfigure() {
104
 
        /* We don't require any special configuration */
105
 
        return array(GalleryStatus::success(), true);
 
108
        return null;
106
109
    }
107
110
 
108
111
    /**
109
112
     * @see GalleryModule::getSiteAdminViews()
110
113
     */
111
114
    function getSiteAdminViews() {
112
 
        return array(GalleryStatus::success(),
 
115
        return array(null,
113
116
                     array(array('name' => $this->translate('Image Block'),
114
117
                                 'view' => 'imageblock.ImageBlockSiteAdmin')));
115
118
    }