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

« back to all changes in this revision

Viewing changes to modules/useralbum/classes/UserAlbumHelper.class

  • 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: UserAlbumHelper.class,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
21
21
 */
22
22
/**
23
23
 * @package UserAlbum
24
 
 * @version $Revision: 1.8 $ $Date: 2005/08/23 03:49:57 $
 
24
 * @version $Revision: 1.9 $ $Date: 2006/01/10 04:43:20 $
25
25
 * @author Alan Harder <alan.harder@sun.com>
26
26
 */
27
27
 
42
42
     */
43
43
    function createUserAlbum($user) {
44
44
        list ($ret, $core) = GalleryCoreApi::fetchAllPluginParameters('module', 'core');
45
 
        if ($ret->isError()) {
 
45
        if ($ret) {
46
46
            return $ret->wrap(__FILE__, __LINE__);
47
47
        }
48
48
        list ($ret, $module) = GalleryCoreApi::fetchAllPluginParameters('module', 'useralbum');
49
 
        if ($ret->isError()) {
 
49
        if ($ret) {
50
50
            return $ret->wrap(__FILE__, __LINE__);
51
51
        }
52
52
 
59
59
        while (true) {
60
60
            list ($ret, $album) = GalleryCoreApi::createAlbum(
61
61
                $module['targetLocation'], $albumName, $albumTitle, '', '', '');
62
 
            if ($ret->isSuccess()) {
 
62
            if (!$ret) {
63
63
                break;
64
64
            }
65
65
            if ($ret->getErrorCode() & ERROR_COLLISION) {
70
70
        }
71
71
 
72
72
        list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock($album->getId());
73
 
        if ($ret->isError()) {
 
73
        if ($ret) {
74
74
            return $ret->wrap(__FILE__, __LINE__);
75
75
        }
76
76
 
77
77
        /* Set owner.. */
78
78
        $album->setOwnerId($user->getId());
79
79
        $ret = $album->save();
80
 
        if ($ret->isError()) {
 
80
        if ($ret) {
81
81
            GalleryCoreApi::releaseLocks($lockId);
82
82
            return $ret->wrap(__FILE__, __LINE__);
83
83
        }
85
85
 
86
86
        /* Set permissions.. */
87
87
        $ret = GalleryCoreApi::removeItemPermissions($albumId);
88
 
        if ($ret->isError()) {
 
88
        if ($ret) {
89
89
            GalleryCoreApi::releaseLocks($lockId);
90
90
            return $ret->wrap(__FILE__, __LINE__);
91
91
        }
92
92
        $ret = GalleryCoreApi::addGroupPermission($albumId, $core['id.adminGroup'], 'core.all');
93
 
        if ($ret->isError()) {
 
93
        if ($ret) {
94
94
            GalleryCoreApi::releaseLocks($lockId);
95
95
            return $ret->wrap(__FILE__, __LINE__);
96
96
        }
97
97
        $ret = GalleryCoreApi::addUserPermission($albumId, $user->getId(), 'core.all');
98
 
        if ($ret->isError()) {
 
98
        if ($ret) {
99
99
            GalleryCoreApi::releaseLocks($lockId);
100
100
            return $ret->wrap(__FILE__, __LINE__);
101
101
        }
113
113
        if (isset($groupId)) {
114
114
            foreach ($viewPermissions as $permission) {
115
115
                $ret = GalleryCoreApi::addGroupPermission($albumId, $groupId, $permission);
116
 
                if ($ret->isError()) {
 
116
                if ($ret) {
117
117
                    GalleryCoreApi::releaseLocks($lockId);
118
118
                    return $ret->wrap(__FILE__, __LINE__);
119
119
                }
121
121
        }
122
122
 
123
123
        $ret = GalleryCoreApi::releaseLocks($lockId);
124
 
        if ($ret->isError()) {
 
124
        if ($ret) {
125
125
            return $ret->wrap(__FILE__, __LINE__);
126
126
        }
127
127
 
128
128
        /* Record id of album */
129
129
        $ret = GalleryCoreApi::setPluginParameter(
130
130
                               'module', 'useralbum', 'albumId', $albumId, $user->getId());
131
 
        if ($ret->isError()) {
 
131
        if ($ret) {
132
132
            return $ret->wrap(__FILE__, __LINE__);
133
133
        }
134
134
 
135
 
        return GalleryStatus::success();
 
135
        return null;
136
136
    }
137
137
}
138
138
?>