| 2 |
/* ex: set syntax=php tabstop=4 expandtab shiftwidth=4 softtabstop=4: */ |
/* ex: set syntax=php tabstop=4 expandtab shiftwidth=4 softtabstop=4: */ |
| 3 |
/* |
/* |
| 4 |
Acidfree Photo Albums for Drupal |
Acidfree Photo Albums for Drupal |
| 5 |
Copyright (C) 2005 Vernon Mauery |
Copyright (C) 2005, 2006, 2007, 2008 Vernon Mauery |
| 6 |
|
|
| 7 |
This program is free software; you can redistribute it and/or modify |
This program is free software; you can redistribute it and/or modify |
| 8 |
it under the terms of the GNU General Public License as published by |
it under the terms of the GNU General Public License as published by |
| 103 |
|
|
| 104 |
function acidfree_theme() { |
function acidfree_theme() { |
| 105 |
$items = array( |
$items = array( |
| 106 |
|
/* NO_ALBUM_CONTENTS |
| 107 |
'acidfree_album_contents' => array('form'), |
'acidfree_album_contents' => array('form'), |
| 108 |
|
*/ |
| 109 |
'album_grid_view' => array('tid', 'nodes', 'teasers', 'links'), |
'album_grid_view' => array('tid', 'nodes', 'teasers', 'links'), |
| 110 |
'album_list_view' => array('tid', 'nodes', 'teasers', 'links'), |
'album_list_view' => array('tid', 'nodes', 'teasers', 'links'), |
| 111 |
'acidfree_print_thumb_acidfree' => array('node'), |
'acidfree_print_thumb_acidfree' => array('node'), |
| 126 |
} |
} |
| 127 |
|
|
| 128 |
function acidfree_insert(&$node) { |
function acidfree_insert(&$node) { |
|
dm($node); |
|
| 129 |
$vocab = acidfree_get_vocab_id(); |
$vocab = acidfree_get_vocab_id(); |
| 130 |
$term = array( |
$term = array( |
| 131 |
'vid' => $vocab, |
'vid' => $vocab, |
| 375 |
} |
} |
| 376 |
} |
} |
| 377 |
|
|
| 378 |
|
/* NO_ALBUM_CONTENTS |
| 379 |
function acidfree_album_contents_access($node) { |
function acidfree_album_contents_access($node) { |
| 380 |
return node_access('update', $node) && $node->type == 'acidfree'; |
return node_access('update', $node) && $node->type == 'acidfree'; |
| 381 |
} |
} |
| 382 |
|
*/ |
| 383 |
function acidfree_album_view_access($view, $node) { |
function acidfree_album_view_access($view, $node) { |
| 384 |
return node_access('view', $node) && |
return node_access('view', $node) && |
| 385 |
variable_get('acidfree_show_alternate_view', true) && |
variable_get('acidfree_show_alternate_view', true) && |
| 391 |
} |
} |
| 392 |
function acidfree_menu() { |
function acidfree_menu() { |
| 393 |
$items = array(); |
$items = array(); |
|
here(); |
|
|
|
|
| 394 |
$items['admin/settings/acidfree'] = array( |
$items['admin/settings/acidfree'] = array( |
| 395 |
'title' => 'Acidfree settings', |
'title' => 'Acidfree settings', |
| 396 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 421 |
'access callback' => 'node_access', |
'access callback' => 'node_access', |
| 422 |
'access arguments' => array('view', 2), |
'access arguments' => array('view', 2), |
| 423 |
); |
); |
| 424 |
|
/* NO_ALBUM_CONTENTS |
| 425 |
$items['node/%acidfree_album/contents'] = array( |
$items['node/%acidfree_album/contents'] = array( |
| 426 |
'page callback' => 'drupal_get_form', |
'page callback' => 'drupal_get_form', |
| 427 |
'page arguments' => array('acidfree_album_contents', 1), |
'page arguments' => array('acidfree_album_contents', 1), |
| 430 |
'access callback' => 'acidfree_album_contents_access', |
'access callback' => 'acidfree_album_contents_access', |
| 431 |
'access arguments' => array(1), |
'access arguments' => array(1), |
| 432 |
); |
); |
| 433 |
|
*/ |
| 434 |
foreach (array('list'=>'List view', 'grid'=>'Grid view') as $k=>$v) { |
foreach (array('list'=>'List view', 'grid'=>'Grid view') as $k=>$v) { |
| 435 |
$items["node/%acidfree_album/$k"] = array( |
$items["node/%acidfree_album/$k"] = array( |
| 436 |
'page callback' => 'acidfree_album_view', |
'page callback' => 'acidfree_album_view', |
| 611 |
if (!is_numeric($nid)) { |
if (!is_numeric($nid)) { |
| 612 |
return $node; |
return $node; |
| 613 |
} |
} |
| 614 |
if (!$nid && function_exists('trace_msg')) { |
if (!$nid) { |
| 615 |
trace_msg(); |
if (function_exists('trace_msg')) { |
| 616 |
|
trace_msg(); |
| 617 |
|
} |
| 618 |
return $node; |
return $node; |
| 619 |
} |
} |
| 620 |
$node = node_load(array('nid' => $nid)); |
$node = node_load(array('nid' => $nid)); |
| 912 |
if (function_exists('_class_video_manipulation_options')) |
if (function_exists('_class_video_manipulation_options')) |
| 913 |
$form = array_merge($form, acidfree_call('_class_video_manipulation_options')); |
$form = array_merge($form, acidfree_call('_class_video_manipulation_options')); |
| 914 |
|
|
| 915 |
|
/* NO_ALBUM_CONTENTS |
| 916 |
$form['album_contents'] = array( |
$form['album_contents'] = array( |
| 917 |
'#type' => 'fieldset', |
'#type' => 'fieldset', |
| 918 |
'#title' => t('Album Contents'), |
'#title' => t('Album Contents'), |
| 929 |
$form['album_contents']['fields']['#collapsed'] = variable_get('acidfree_content_fields_all', true); |
$form['album_contents']['fields']['#collapsed'] = variable_get('acidfree_content_fields_all', true); |
| 930 |
$form['album_contents']['fields']['#description'] = t('The album contents view gets very cluttered. To remedy this, you may pick and choose which field elements appear on the form and what column they appear in. The form will render with two columns and you may put any item in either column.'); |
$form['album_contents']['fields']['#description'] = t('The album contents view gets very cluttered. To remedy this, you may pick and choose which field elements appear on the form and what column they appear in. The form will render with two columns and you may put any item in either column.'); |
| 931 |
$form['album_contents']['fields']['acidfree_content_fields'] = _album_contents_available_fields(); |
$form['album_contents']['fields']['acidfree_content_fields'] = _album_contents_available_fields(); |
| 932 |
|
*/ |
| 933 |
drupal_set_title(t('Acidfree settings')); |
drupal_set_title(t('Acidfree settings')); |
| 934 |
|
|
| 935 |
return system_settings_form($form); |
return system_settings_form($form); |
| 971 |
$perms[] = 'edit own acidfree albums'; |
$perms[] = 'edit own acidfree albums'; |
| 972 |
$perms[] = 'acidfree mass import'; |
$perms[] = 'acidfree mass import'; |
| 973 |
$perms[] = 'can upload to any album'; |
$perms[] = 'can upload to any album'; |
| 974 |
|
/* NO_ALBUM_CONTENTS |
| 975 |
$perms[] = 'use album contents mode'; |
$perms[] = 'use album contents mode'; |
| 976 |
|
*/ |
| 977 |
if (variable_get('acidfree_per_user_albums', 0)) { |
if (variable_get('acidfree_per_user_albums', 0)) { |
| 978 |
$perms[] = 'get a per-user album'; |
$perms[] = 'get a per-user album'; |
| 979 |
} |
} |
| 1373 |
$nid = _nid_from_tid($tid); |
$nid = _nid_from_tid($tid); |
| 1374 |
drupal_goto("node/{$nid}"); |
drupal_goto("node/{$nid}"); |
| 1375 |
} elseif ($argv[0] == 'version') { |
} elseif ($argv[0] == 'version') { |
| 1376 |
$version = '$Id: acidfree.module 597 2008-12-15 06:13:49Z vhmauery $'; |
$version = '$Id: acidfree.module 598 2008-12-15 15:09:07Z vhmauery $'; |
| 1377 |
return $version; |
return $version; |
| 1378 |
} elseif ($argv[0] == 'test') { |
} elseif ($argv[0] == 'test') { |
| 1379 |
if (user_access('site administration')) { |
if (user_access('site administration')) { |
| 1401 |
static $recursion_level = 0; |
static $recursion_level = 0; |
| 1402 |
if ($reset) $recursion_level = 0; |
if ($reset) $recursion_level = 0; |
| 1403 |
if ($recursion_level++ > 2) { |
if ($recursion_level++ > 2) { |
| 1404 |
trace(); |
//trace(); |
| 1405 |
exit(1); |
exit(1); |
| 1406 |
} |
} |
| 1407 |
if ($title === NULL) { |
if ($title === NULL) { |
| 1448 |
static $root_term_id = -1; |
static $root_term_id = -1; |
| 1449 |
if ($reset) $recursion_level = 0; |
if ($reset) $recursion_level = 0; |
| 1450 |
if ($recursion_level++ > 2) { |
if ($recursion_level++ > 2) { |
| 1451 |
trace(); |
//trace(); |
| 1452 |
exit(1); |
exit(1); |
| 1453 |
} |
} |
| 1454 |
if ($uid != -1) { |
if ($uid != -1) { |
| 2846 |
} |
} |
| 2847 |
|
|
| 2848 |
|
|
| 2849 |
// require the views file until we can convince them to take it |
/* |
| 2850 |
$acidfree_base = dirname(drupal_get_filename('module', 'acidfree')); |
----------------------------------------------------- |
| 2851 |
require_once($acidfree_base.DIRECTORY_SEPARATOR.'class_album.inc'); |
class album stuff |
| 2852 |
|
since we include it every time, we might as well just |
| 2853 |
|
keep it in this file. Especially since it is hard to |
| 2854 |
|
tell where to draw the line of what goes in acidfree |
| 2855 |
|
and what goes in album.inc. |
| 2856 |
|
*/ |
| 2857 |
|
function acidfree_af_info() { |
| 2858 |
|
$class = new stdClass(); |
| 2859 |
|
$class->class = 'acidfree'; |
| 2860 |
|
$class->name = t('album'); |
| 2861 |
|
$class->addme = t('Add an album'); |
| 2862 |
|
$class->mime_ext = Array(); |
| 2863 |
|
$class->access = 'create acidfree albums'; |
| 2864 |
|
$class->import = 'acidfree_import_album'; |
| 2865 |
|
return array($class->class => $class); |
| 2866 |
|
} |
| 2867 |
|
|
| 2868 |
|
/* this function is called by _acidfree_node_from_file with |
| 2869 |
|
* the corresponding $node structure filled out as well as |
| 2870 |
|
* that function could do. The $file structure is also passed |
| 2871 |
|
* which is what the $node was built from. |
| 2872 |
|
*/ |
| 2873 |
|
function acidfree_import_album($node, $file) { |
| 2874 |
|
return acidfree_create_album($node->title, $node->taxonomy); |
| 2875 |
|
} |
| 2876 |
|
|
| 2877 |
|
function acidfree_create_album($title, $taxonomy, $body='', $uid=null, $weight=0, $order=null, $view=null, $share=null) { |
| 2878 |
|
$node = new stdClass(); |
| 2879 |
|
$node->type = 'acidfree'; |
| 2880 |
|
_acidfree_set_node_defaults($node); |
| 2881 |
|
$node->created = $node->updated = time(); |
| 2882 |
|
$node->title = $title; |
| 2883 |
|
$node->taxonomy = $taxonomy; |
| 2884 |
|
$node->body = $body; |
| 2885 |
|
$node->thumb = ''; |
| 2886 |
|
$node->weight = $weight; |
| 2887 |
|
if (isset($uid)) { |
| 2888 |
|
$user = user_load(array('uid'=>$uid)); |
| 2889 |
|
if ($user) { |
| 2890 |
|
$node->uid = $uid; |
| 2891 |
|
$node->name = $user->name; |
| 2892 |
|
} |
| 2893 |
|
} |
| 2894 |
|
if (isset($order)) { |
| 2895 |
|
$node->order_by = $order; |
| 2896 |
|
} |
| 2897 |
|
if (isset($view)) { |
| 2898 |
|
$node->view = $view; |
| 2899 |
|
} |
| 2900 |
|
if (isset($share)) { |
| 2901 |
|
$node->share = $share; |
| 2902 |
|
} |
| 2903 |
|
node_invoke_nodeapi($node, 'prepare'); |
| 2904 |
|
node_invoke_nodeapi($node, 'presave'); |
| 2905 |
|
node_save($node); |
| 2906 |
|
return $node; |
| 2907 |
|
} |
| 2908 |
|
|
| 2909 |
|
function _acidfree_get_album_thumb(&$node) { |
| 2910 |
|
if ($node->thumb) { |
| 2911 |
|
return acidfree_node_load($node->thumb); |
| 2912 |
|
} |
| 2913 |
|
$child = _acidfree_get_children($node->tid, 1, -1, false, 'RAND()'); |
| 2914 |
|
|
| 2915 |
|
if (!$child) { |
| 2916 |
|
$child = _acidfree_get_children($node->tid, 1, -1, true, 'RAND()'); |
| 2917 |
|
if (!$child) { |
| 2918 |
|
return ''; |
| 2919 |
|
} |
| 2920 |
|
$child = acidfree_node_load($child[0]); |
| 2921 |
|
return _acidfree_get_album_thumb($child); |
| 2922 |
|
} else { |
| 2923 |
|
$thumb = acidfree_node_load($child[0]); |
| 2924 |
|
} |
| 2925 |
|
if ($thumb->type == 'video') { |
| 2926 |
|
if (isset($thumb->iid)) { |
| 2927 |
|
$thumb = acidfree_node_load($thumb->iid); |
| 2928 |
|
if (!$thumb) { |
| 2929 |
|
$thumb = _class_video_fake_thumb(); |
| 2930 |
|
} |
| 2931 |
|
} else { |
| 2932 |
|
$thumb = _class_video_fake_thumb(); |
| 2933 |
|
} |
| 2934 |
|
} |
| 2935 |
|
return $thumb; |
| 2936 |
|
} |
| 2937 |
|
|
| 2938 |
|
/** |
| 2939 |
|
* This views generates the customized acidfree views based on the standard view |
| 2940 |
|
* |
| 2941 |
|
* @param $album |
| 2942 |
|
* The node object of the album to display |
| 2943 |
|
* |
| 2944 |
|
* @return |
| 2945 |
|
* The view page. |
| 2946 |
|
*/ |
| 2947 |
|
function acidfree_album_view(&$album, $view=null) { |
| 2948 |
|
$tid = $album->tid; |
| 2949 |
|
$album = _album_from_tid($tid); |
| 2950 |
|
if (!$album->order_by || $album->order_by == '<default>') { |
| 2951 |
|
$order = variable_get('acidfree_order', 'node.nid DESC'); |
| 2952 |
|
} else { |
| 2953 |
|
$order = $album->order_by; |
| 2954 |
|
} |
| 2955 |
|
$order = preg_replace('/node\./', 'n.', $order); |
| 2956 |
|
if (($node_count = variable_get('acidfree_num_thumbs', 15)) <= 0) { |
| 2957 |
|
$nodes_per_page = -1; |
| 2958 |
|
} else { |
| 2959 |
|
$nodes_per_page = $node_count; |
| 2960 |
|
} |
| 2961 |
|
|
| 2962 |
|
if (!isset($view)) { |
| 2963 |
|
$view = "album_{$album->view}_view"; |
| 2964 |
|
} |
| 2965 |
|
$items = _acidfree_get_children($tid, $nodes_per_page, 0, true, "n.sticky DESC, $order"); |
| 2966 |
|
$output = theme($view, $tid, $items); |
| 2967 |
|
if ($output === FALSE) { |
| 2968 |
|
drupal_not_found(); |
| 2969 |
|
exit; |
| 2970 |
|
} |
| 2971 |
|
|
| 2972 |
|
$size = _acidfree_get_sizes('thumbnail'); |
| 2973 |
|
// 5px padding + 1px border on both sides of image + |
| 2974 |
|
// 5px padding and 2px border on both sides of acidfree-item |
| 2975 |
|
// gives 26. Height needs more because it contains text underneath. |
| 2976 |
|
$style = '<style type="text/css" media="all">'; |
| 2977 |
|
$style .= '.acidfree-cell{width:' . ($size['width'] + 26) . 'px;}'; |
| 2978 |
|
$style .= '.acidfree .acidfree-cell{height:' . ($size['height'] + 45) . 'px;}'; |
| 2979 |
|
$style .= '</style>'; |
| 2980 |
|
drupal_set_html_head($style); |
| 2981 |
|
|
| 2982 |
|
return $output; |
| 2983 |
|
} |
| 2984 |
|
|
| 2985 |
|
function theme_album_grid_view($tid, $nodes, $teasers = false, $links = true) { |
| 2986 |
|
$term = taxonomy_get_term($tid); |
| 2987 |
|
drupal_set_breadcrumb(acidfree_make_breadcrumbs($term)); |
| 2988 |
|
$offset = _acidfree_get_pager_offset_from_path(ALBUM_PAGER); |
| 2989 |
|
if ($offset) { |
| 2990 |
|
$offset = " - ".t('Page !page', array('!page' => "".($offset+1))); |
| 2991 |
|
} |
| 2992 |
|
drupal_set_title($term->name.$offset); |
| 2993 |
|
if (count($nodes) == 0) { |
| 2994 |
|
return "<p>".t('This album is empty')."</p>"; |
| 2995 |
|
} |
| 2996 |
|
$output = "\n<p class=\"acidfree-center\">".check_markup($term->description)."</p>\n"; |
| 2997 |
|
$output .= theme('pager', NULL, 1, ALBUM_PAGER); |
| 2998 |
|
$output .= '<div class="clear-block acidfree">' . "\n"; |
| 2999 |
|
foreach ($nodes as $node) { |
| 3000 |
|
$node = node_load(array('nid' => $node)); |
| 3001 |
|
$output .= theme("acidfree_print_thumb_{$node->type}", $node, $term)."\n"; |
| 3002 |
|
} |
| 3003 |
|
$output .= "</div>\n"; |
| 3004 |
|
return $output; |
| 3005 |
|
} |
| 3006 |
|
|
| 3007 |
|
function theme_album_list_view($tid, $nodes, $teasers = false, $links = true) { |
| 3008 |
|
$term = taxonomy_get_term($tid); |
| 3009 |
|
drupal_set_breadcrumb(acidfree_make_breadcrumbs($term)); |
| 3010 |
|
$offset = _acidfree_get_pager_offset_from_path(ALBUM_PAGER); |
| 3011 |
|
if ($offset) { |
| 3012 |
|
$offset = " - ".t('Page !page', array('!page' => "".($offset+1))); |
| 3013 |
|
} |
| 3014 |
|
drupal_set_title($term->name.$offset); |
| 3015 |
|
if (count($nodes) == 0) { |
| 3016 |
|
return "<p>".t('This album is empty')."</p>"; |
| 3017 |
|
} |
| 3018 |
|
$output = "\n<p class=\"acidfree-center\">".check_markup($term->description)."</p>\n"; |
| 3019 |
|
$output .= theme('pager', NULL, 1, ALBUM_PAGER); |
| 3020 |
|
$output .= "\n<div class='acidfree-list'>\n"; |
| 3021 |
|
|
| 3022 |
|
$nodes_per_page = variable_get('acidfree_num_thumbs', 15); |
| 3023 |
|
$i = _acidfree_get_pager_offset_from_path(ALBUM_PAGER) * $nodes_per_page; |
| 3024 |
|
foreach ($nodes as $node) { |
| 3025 |
|
$node = node_load(array('nid' => $node)); |
| 3026 |
|
$row_class = "acidfree-list-".($i & 0x1 ? "even" : "odd"); |
| 3027 |
|
$output .= '<div class="clear-block acidfree-list-row ' . $row_class . '">'; |
| 3028 |
|
$output .= '<div class="acidfree-list-number">'.(++$i)."</div>"; |
| 3029 |
|
$output .= theme("acidfree_print_thumb_{$node->type}", $node, $term); |
| 3030 |
|
$output .= '<div class="acidfree-list-body">'.check_markup($node->body)."</div>"; |
| 3031 |
|
$output .= "</div>\n"; |
| 3032 |
|
} |
| 3033 |
|
$output .= "</div>"; |
| 3034 |
|
return $output; |
| 3035 |
|
} |
| 3036 |
|
|
| 3037 |
|
function theme_acidfree_print_thumb_acidfree(&$node) { |
| 3038 |
|
$album_info = _album_get_info($node); |
| 3039 |
|
$image_node = _acidfree_get_album_thumb($node); |
| 3040 |
|
|
| 3041 |
|
if (is_object($image_node) && !$image_node->images) { |
| 3042 |
|
$info = $image_node->info; |
| 3043 |
|
$image = _acidfree_image_display($image_node, 'thumbnail', array('id' => "acidfree-thumb{$node->nid}", 'title' => $album_info, 'width' => $info['width'], 'height' => $info['height'])); |
| 3044 |
|
} |
| 3045 |
|
else if ($image_node != '') { |
| 3046 |
|
$info = image_get_info(file_create_path($image_node->images['thumbnail'])); |
| 3047 |
|
$image = _acidfree_image_display($image_node, 'thumbnail', array('id' => "acidfree-thumb{$node->nid}", 'title' => $album_info, 'width' => $info['width'], 'height' => $info['height'])); |
| 3048 |
|
} |
| 3049 |
|
else { |
| 3050 |
|
$info = _acidfree_get_sizes('thumbnail'); |
| 3051 |
|
$info['height'] = $info['width'] * 3/4; |
| 3052 |
|
$image = '<div class="acidfree-empty">'.t('Empty').'</div>'; |
| 3053 |
|
} |
| 3054 |
|
|
| 3055 |
|
$info['height'] += variable_get('acidfree_extra_length',12); |
| 3056 |
|
$info['width'] += variable_get('acidfree_extra_length',12); |
| 3057 |
|
|
| 3058 |
|
$overlay = l('', "node/{$node->nid}", array('attributes' => array('title' => $album_info), 'absolute' => true, 'html' => true)); |
| 3059 |
|
$image = l($image, "node/{$node->nid}", array('attributes' => array('title' => $album_info), 'absolute' => true, 'html' => true)); |
| 3060 |
|
$title = l($node->title, "node/{$node->nid}", array('attributes' => array('title' => $album_info), 'absolute' => true, 'html' => true)); |
| 3061 |
|
|
| 3062 |
|
$thumbnail = '<div class="acidfree-thumbnail" style="width: ' . $info['width'] . 'px; height: ' . $info['height'] . 'px;">'; |
| 3063 |
|
$thumbnail .= $image . '<div class="acidfree-overlay">' . $overlay . '</div></div>'; |
| 3064 |
|
$folderdiv = '<div class="acidfree-item acidfree-folder">' . $thumbnail . "<p>$title</p></div>"; |
| 3065 |
|
return '<div class="acidfree-cell">' . $folderdiv . "</div>"; |
| 3066 |
|
} |
| 3067 |
|
|
| 3068 |
|
function _album_get_info(&$node) { |
| 3069 |
|
$albums = count(taxonomy_get_tree(acidfree_get_vocab_id(), $node->tid)); |
| 3070 |
|
$children = taxonomy_term_count_nodes($node->tid); |
| 3071 |
|
if ($children == 0) { |
| 3072 |
|
return $node->title . ": " . t('Empty'); |
| 3073 |
|
} |
| 3074 |
|
// album nodes count as children too, so get rid of those |
| 3075 |
|
$children -= $albums; |
| 3076 |
|
if ($children > 0) { |
| 3077 |
|
$tag[] = "$children " . ($children == 1 ? t('Item') : t('Items')); |
| 3078 |
|
} |
| 3079 |
|
if ($albums > 0) { |
| 3080 |
|
$tag[] = "$albums " . ($albums == 1 ? t('Albums') : t('Albums')); |
| 3081 |
|
} |
| 3082 |
|
// this entire string gets check_plain'd so no need to check the title |
| 3083 |
|
return $node->title . ": " . implode(' & ', $tag); |
| 3084 |
|
} |
| 3085 |
|
|
| 3086 |
|
function _album_from_tid($tid) { |
| 3087 |
|
$nid = _nid_from_tid($tid); |
| 3088 |
|
if (!$nid) { |
| 3089 |
|
//here(); |
| 3090 |
|
return null; |
| 3091 |
|
} |
| 3092 |
|
return acidfree_node_load($nid); |
| 3093 |
|
} |
| 3094 |
|
|
| 3095 |
|
function _nid_from_tid($tid) { |
| 3096 |
|
$nid = db_result(db_query("SELECT aid FROM {acidfree_album} WHERE tid=%d", $tid)); |
| 3097 |
|
return $nid; |
| 3098 |
|
} |
| 3099 |
|
|
| 3100 |
|
function _class_album_alter_parent(&$form) { |
| 3101 |
|
//dump_msg($form['parent']); |
| 3102 |
|
$form['parent']['#title'] = t('Parent album'); |
| 3103 |
|
$form['parent']['#multiple'] = 0; |
| 3104 |
|
$form['parent']['#size'] = 0; |
| 3105 |
|
$form['parent']['#required'] = 1; |
| 3106 |
|
if (($arg = _path_match('node', 'add', 'acidfree', '%d'))) { |
| 3107 |
|
$album = acidfree_node_load($arg[0]); |
| 3108 |
|
$form['taxonomy'][$vid]['#default_value'] = array($album->tid); |
| 3109 |
|
} |
| 3110 |
|
unset($form['parent']['#description']); |
| 3111 |
|
if (is_array($form['parent']['#options'])) { |
| 3112 |
|
foreach ($form['parent']['#options'] as $key => $value) { |
| 3113 |
|
if ($value == '<'. t('root') .'>' && count($form['parent']['#default_value'])) { |
| 3114 |
|
unset($form['parent']['#options'][$key]); |
| 3115 |
|
continue; |
| 3116 |
|
} |
| 3117 |
|
if (is_array($value)) { |
| 3118 |
|
} |
| 3119 |
|
if (user_access('can upload to any album')) { |
| 3120 |
|
continue; |
| 3121 |
|
} |
| 3122 |
|
$node = _album_from_tid($key); |
| 3123 |
|
if ($node->share) { |
| 3124 |
|
continue; |
| 3125 |
|
} |
| 3126 |
|
if (!node_access($node)) { |
| 3127 |
|
unset($form['parent']['#options'][$key]); |
| 3128 |
|
continue; |
| 3129 |
|
} |
| 3130 |
|
} |
| 3131 |
|
} |
| 3132 |
|
} |
| 3133 |
|
|
| 3134 |
|
function _acidfree_node_form_alter(&$form, &$form_state) { |
| 3135 |
|
$vid = acidfree_get_vocab_id(); |
| 3136 |
|
if (isset($form['taxonomy'])) { |
| 3137 |
|
$form['taxonomy'][$vid] = $form['parent'][$vid]; |
| 3138 |
|
} else { |
| 3139 |
|
// special case the root album |
| 3140 |
|
// it uses a hidden field rather than a select box |
| 3141 |
|
if (isset($form['parent']['#value'])) { |
| 3142 |
|
$form['parent'] = array($vid=>$form['parent']); |
| 3143 |
|
} |
| 3144 |
|
$form['taxonomy'] = $form['parent']; |
| 3145 |
|
} |
| 3146 |
|
unset($form['parent']); |
| 3147 |
|
_acidfree_filter_taxonomy($form['taxonomy'][$vid]); |
| 3148 |
|
} |
| 3149 |
|
|
| 3150 |
?> |
?> |