--- image_pub.old Thu Jul 13 18:03:08 2006 +++ image_pub.module Thu Jul 13 17:57:21 2006 @@ -103,19 +103,19 @@ return $info; } function _image_pub_album_get($albumid) { - $term = taxonomy_get_term($albumid); if (!$term) { - if ($albumid == 0) - $term = taxonomy_get_term(''); - else - $term = NULL; + if ($albumid == 0) { + $term = taxonomy_get_term('');; + } + else { + $term = NULL; + } } return $term; } function _image_pub_album_enum($albumid = 0, $subalbums = TRUE) { - return taxonomy_get_tree(_image_pub_get_vid(), $albumid, -1, - ($subalbums ? NULL : 1)); + return taxonomy_get_tree(_image_pub_get_vid(), $albumid, -1, ($subalbums ? NULL : 1)); } function _image_pub_album_selector($fname, $showroot = FALSE, $selalbum = NULL) { /* This is mostly redundant with taxonomy_form(). */ @@ -188,7 +188,7 @@ } function _image_pub_album_add($title, $descr, $palbum) { watchdog('image_pub', t('Album added with title %title', array('%title' => $title))); - + if (empty($title)) { $title = 'Untitled album'; } @@ -199,9 +199,11 @@ 'parent' => array(isset($palbum) ? $palbum->tid : 0), 'weight' => 0, ); - $term = taxonomy_save_term($edit); - if (isset($term)) { - return (object)$term; + + taxonomy_save_term($edit); + + if (isset($edit)) { + return $edit; } return NULL; } @@ -220,11 +222,11 @@ } } } - + // move the file into the drupal filesystem $filelocation = $_FILES[$srcfield]['tmp_name']; $filename = basename($_FILES[$srcfield]['name']); - + if (file_exists(file_directory_temp() . '/' . $filename)) { // FIXME either rename or throw an error; } @@ -269,17 +271,21 @@ define('GR_STAT_PASSWD_WRONG', 201); define('GR_STAT_LOGIN_MISSING', 202); define('GR_STAT_UNKNOWN_CMD', 301); +define('GT_STAT_MISSING_ARGUMENTS', 301); define('GR_STAT_NO_ADD_PERMISSION', 401); define('GR_STAT_NO_FILENAME', 402); define('GR_STAT_UPLOAD_PHOTO_FAIL', 403); define('GR_STAT_NO_WRITE_PERMISSION', 404); +define('GR_STAT_NO_VIEW PERMISSION', 405); define('GR_STAT_NO_CREATE_ALBUM_PERMISSION', 501); define('GR_STAT_CREATE_ALBUM_FAILED', 502); +define('GR_STAT_MOVE_ALBUM_FAILED', 503); +define('GR_STAT_ROTATE_IMAGE_FAILED', 504); -define('GR_SERVER_VERSION', '2.15'); +define('GR_SERVER_VERSION', '2.8'); function _image_pub_gr_get_albumname($term) { - return 'Album' . $term->tid; + return 'Album' . $term['tid']; } function _image_pub_gr_get_albumid($albname) { if (!strncmp($albname, 'Album', 5)) { @@ -327,6 +333,7 @@ case 'new-album': _image_pub_gr_add_album($_POST['set_albumName'], + $_POST['newAlbumName'], $_POST['newAlbumTitle'], $_POST['newAlbumDesc']); break; @@ -345,7 +352,8 @@ case '': echo 'For more information about Gallery Remote, see Gallery\'s website located at http://gallery.sourceforge.net'; exit; - + case 'album-properties': + break; default: _image_pub_gr_finish(GR_STAT_UNKNOWN_CMD, '', t('Unknown command "%cmd"', array('%cmd' => theme('placeholder', $cmd)))); break; @@ -418,56 +426,81 @@ $thumb_max = min($thumb_dims[0], $thumb_dims[1]); $preview_dims = _image_get_dimensions('preview'); $preview_max = min($preview_dims[0], $preview_dims[1]); - $nalbums = 0; + $nalbums = 1; + + //Permission for creating images $cperm = 'false'; + + //Permission for administering images $aperm = 'false'; + + //Permission to add to create root album $crperm = 'no'; + if (user_access('create images')) { $cperm = 'true'; } if (user_access('administer images')) { $aperm = 'true'; - $crperm = 'yes'; } $tree = _image_pub_album_enum(); - $aid = 0; + $aid = 1; $aidref = array(); - foreach ($tree as $term) { - if (_image_pub_album_access('view', $term)) { - $aid++; - $aname = _image_pub_gr_get_albumname($term); - $aidref[$aname] = $aid; - - $pname = 0; - if (!empty($term->parents[0])) { - $pterm = _image_pub_album_get($term->parents[0]); - $pname = $pterm->tid; - if ($refnum) { - $pname = $aidref[$pname]; // Guaranteed to exist? - } else { - $pname = _image_pub_gr_get_albumname($pterm); + $body .= "album.name.1=Album0\n"; + $body .= "album.title.1=images\n"; + $body .= "album.summary.1=images and root gallery\n"; + $body .= "album.resize_size.1=\n"; + $body .= "album.max_size.1=\n"; + $body .= "album.thumb_size.1=\n"; + $body .= "album.parent.1=0\n"; + $body .= "album.perms.add.1=true\n"; + $body .= "album.perms.write.1=true\n"; + $body .= "album.perms.del_item.1=true\n"; + $body .= "album.perms.add_item.1=false\n"; + $body .= "album.perms.del_alb.1=false\n"; + $body .= "album.perms.create_sub.1=true\n"; + $body .= "album.extrafields.1=Description\n"; + if($tree) { + foreach ($tree as $term) { + if (_image_pub_album_access('view', $term)) { + $aid++; + $aname = 'Album' . $term->tid; + $aidref[$aname] = $aid; + + $pname = 0; + if (!empty($term->parents[0])) { + $pterm = _image_pub_album_get($term->parents[0]); + $pname = $pterm->tid; + if ($refnum) { + $pname = $aidref[$pname]; // Guaranteed to exist? + } else { + $pname = _image_pub_gr_get_albumname($pterm); + } + } + if (!$pname) { + $pname = 'Album0'; } + + $body .= 'album.name.'.$aid.'='.$aname."\n"; + $body .= 'album.title.'.$aid.'='.$term->name."\n"; + $body .= 'album.summary.'.$aid.'='.$term->description."\n"; + $body .= 'album.parent.'.$aid.'='.$pname."\n"; + $body .= 'album.resize_size.'.$aid.'='.$preview_max."\n"; + $body .= 'album.max_size.'.$aid.'='.'0'."\n"; + $body .= 'album.thumb_size.'.$aid.'='.$thumb_max."\n"; + $body .= 'album.perms.add.'.$aid.'='.$cperm."\n"; + $body .= 'album.perms.write.'.$aid.'='.$aperm."\n"; + $body .= 'album.perms.del_item.'.$aid.'='.$aperm."\n"; + $body .= 'album.perms.del_alb.'.$aid.'='.$aperm."\n"; + $body .= 'album.perms.create_sub.'.$aid.'='.$aperm."\n"; + $body .= 'album.extrafields.'.$aid."=Description\n"; + $nalbums++; } - - $body .= 'album.name.'.$aid.'='.$aname."\n"; - $body .= 'album.title.'.$aid.'='.$term->name."\n"; - $body .= 'album.summary.'.$aid.'='.$term->description."\n"; - $body .= 'album.parent.'.$aid.'='.$pname."\n"; - $body .= 'album.resize_size.'.$aid.'='.$preview_max."\n"; - $body .= 'album.max_size.'.$aid.'='.'0'."\n"; - $body .= 'album.thumb_size.'.$aid.'='.$thumb_max."\n"; - $body .= 'album.perms.add.'.$aid.'='.$cperm."\n"; - $body .= 'album.perms.write.'.$aid.'='.$aperm."\n"; - $body .= 'album.perms.del_item.'.$aid.'='.$aperm."\n"; - $body .= 'album.perms.del_alb.'.$aid.'='.$aperm."\n"; - $body .= 'album.perms.create_sub.'.$aid.'='.$aperm."\n"; - $body .= 'album.extrafields.'.$aid."=Description\n"; - $nalbums++; } } $body .= 'album_count='.$nalbums."\n"; - $body .= 'can_create_root='.$crperm."\n"; - _image_pub_gr_finish(GR_STAT_SUCCESS, $body); + $body .= 'can_create_root=no' . "\n"; + _image_pub_gr_finish(GR_STAT_SUCCESS, $body, NULL); } @@ -536,7 +569,7 @@ } -function _image_pub_gr_add_album($parentaname, $title, $descr) { +function _image_pub_gr_add_album($parentaname, $name, $title, $descr) { $body = ''; $palbum = _image_pub_album_get(_image_pub_gr_get_albumid($parentaname)); @@ -546,12 +579,11 @@ if (!_image_pub_album_access('update', $palbum)) { _image_pub_gr_finish(GR_STAT_NO_CREATE_ALBUM_PERMISSION, $body); } - $term =_image_pub_album_add($title, $descr, $palbum); if (!isset($term)) { _image_pub_gr_finish(GR_STAT_CREATE_ALBUM_FAILED); } else { - $body .= 'album.name='. _image_pub_gr_get_albumname($term)."\n"; + $body .= 'album_name='. _image_pub_gr_get_albumname($term)."\n"; _image_pub_gr_finish(GR_STAT_SUCCESS, $body, 'Album created'); } } @@ -582,7 +614,7 @@ $album->parent = array($dtid); $term = (array)$album; $status = taxonomy_save_term( $term ); - + _image_pub_gr_finish(GR_STAT_SUCCESS, $body, 'Album reparented'); } @@ -606,7 +638,6 @@ } } - /* * Windows Web publishing wizard support * @@ -945,4 +976,4 @@