2 /****************************************************************************/
\r
4 /****************************************************************************/
\r
5 /* Copyright (c) 2002-2010 */
\r
6 /* Inclusive Design Institute */
\r
7 /* http://atutor.ca */
\r
9 /* This program is free software. You can redistribute it and/or */
\r
10 /* modify it under the terms of the GNU General Public License */
\r
11 /* as published by the Free Software Foundation. */
\r
12 /****************************************************************************/
\r
15 * create an album for photo with the following attributes
\r
17 * album type: course albums
\r
18 * album permission: private
\r
19 * album location: n/a
\r
20 * album description: group description/na
\r
21 * album creator: instructor_id
\r
23 require_once (AT_INCLUDE_PATH.'../mods/_standard/photos/include/lib.inc.php');
\r
24 require_once (AT_INCLUDE_PATH.'../mods/_standard/photos/include/classes/PhotoAlbum.class.php');
\r
25 function photos_create_group($group_id) {
\r
27 $group_id = intval($group_id);
\r
29 $sql = 'SELECT title FROM ' . TABLE_PREFIX . "groups WHERE group_id=$group_id";
\r
30 $result = mysql_query($sql, $db);
\r
31 $group_info = mysql_fetch_assoc($result);
\r
33 $pa = new PhotoAlbum();
\r
34 $album_name = $group_info['title'] . '(' . _AT('group') . ')';
\r
35 $album_location = _AT('na');
\r
36 $album_description = _AT('na');
\r
37 $album_type = AT_PA_TYPE_COURSE_ALBUM;
\r
38 $album_permission = AT_PA_PRIVATE_ALBUM;
\r
40 $album_id = $pa->createAlbum($album_name, $album_location, $album_description, $album_type, $album_permission, $_SESSION['member_id'], 0);
\r
41 if ($album_id === false){
\r
42 //TODO: sql failure.
\r
43 $msg->addError('PA_CREATE_ALBUM_FAILED');
\r
46 $sql = 'INSERT INTO '.TABLE_PREFIX."pa_groups (group_id, album_id) VALUES ($group_id, $album_id)";
\r
47 $result = mysql_query($sql, $db);
\r
52 function photos_delete_group($group_id) {
\r
54 $group_id = intval($group_id);
\r
55 $sql = "SELECT album_id FROM ".TABLE_PREFIX."pa_groups WHERE group_id=$group_id";
\r
56 $result = mysql_query($sql, $db);
\r
57 while ($row = mysql_fetch_assoc($result)) {
\r
58 $pa = new PhotoAlbum($row['album_id']);
\r
62 $sql = "DELETE FROM ".TABLE_PREFIX."pa_groups WHERE group_id=$group_id";
\r
63 $result = mysql_query($sql, $db);
\r