get->keyExists('album')) { $CLEAN['album'] = $superCage->get->getInt('album'); } else { $CLEAN['album'] = 0; } if (!(GALLERY_ADMIN_MODE || (USER_ADMIN_MODE && user_is_allowed(false)))) { cpg_die(ERROR, $lang_errors['access_denied'], __FILE__, __LINE__); } // Type 0 => input // 1 => yes/no // 2 => Category // 3 => Textarea // 4 => Album thumbnail // 5 => Album visibility // add footnote $notice1 = ' *'; $help = array(); $help['table'] = ' '.cpg_display_help('f=albums.htm&as=album_prop&ae=album_prop_end&top=1', '600', '400'); $help['related_tasks'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_related_tasks&ae=album_prop_controls_related_tasks_end', '500', '250'); $help['choose_album'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_album_dropdown&ae=album_prop_controls_album_dropdown_end', '500', '250'); $help['album_title'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_album_title&ae=album_prop_controls_album_title_end', '500', '250'); $help['album_category'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_album_category&ae=album_prop_controls_album_category_end', '500', '250'); $help['album_keywords'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_album_keyword&ae=album_prop_controls_album_keyword_end', '500', '250'); $help['album_thumbnail'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_album_thumbnail&ae=album_prop_controls_album_thumbnail_end', '500', '250'); $help['album_can_be_viewed_by'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_album_can_be_viewed_by&ae=album_prop_controls_album_can_be_viewed_by_end', '500', '250'); $help['album_password'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_password_protection&ae=album_prop_controls_password_protection_end&', '500', '250'); $help['can_upload'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_visitor_upload&ae=album_prop_controls_visitor_upload_end&', '400', '200'); $help['can_post_comments'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_can_post_comment&ae=album_prop_controls_can_post_comment_end&', '400', '200'); $help['can_rate'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_can_rate_files&ae=album_prop_controls_can_rate_files_end&', '400', '200'); $help['can_moderate'] = ' '.cpg_display_help('f=albums.htm&as=album_prop_controls_album_moderation&ae=album_prop_controls_album_moderation_end&', '400', '200'); // Define the icons $icon_array = array( 'album_properties' => cpg_fetch_icon('modifyalb', 2), 'thumbnail' => cpg_fetch_icon('thumbnails', 1), 'album_thumbnail' => cpg_fetch_icon('thumbnails', 2), 'password' => cpg_fetch_icon('key_enter', 2), 'album' => cpg_fetch_icon('alb_mgr', 2), 'upload' => cpg_fetch_icon('upload', 2), 'move' => cpg_fetch_icon('move', 1), 'title' => cpg_fetch_icon('title', 2), 'view' => cpg_fetch_icon('groups_mgr', 2), 'description' => cpg_fetch_icon('text_left', 2), 'keyword' => cpg_fetch_icon('keyword_mgr', 2), 'views' => cpg_fetch_icon('stats', 2), 'ok' => cpg_fetch_icon('ok', 1), 'category' => cpg_fetch_icon('category', 1), 'album_category' => cpg_fetch_icon('category', 2), 'file' => cpg_fetch_icon('file', 2), 'comment' => cpg_fetch_icon('comment', 2), 'rate' => cpg_fetch_icon('top_rated', 2), 'blank' => cpg_fetch_icon('blank', 2), 'edit_files' => cpg_fetch_icon('edit', 1), 'stop' => cpg_fetch_icon('stop', 0, '', '', 'png', 1), // Only get the image path and not the embedding -tag ); $captionLabel = $lang_modifyalb_php['alb_desc']; if ($CONFIG['show_bbcode_help']) { $captionLabel .= ' '. cpg_display_help('f=empty.htm&h=lang_bbcode_help_title&t=lang_bbcode_help', 470, 245); } $data = array($lang_modifyalb_php['general_settings'], array($icon_array['title'].$lang_modifyalb_php['alb_title'].$help['album_title'], 'title', 0), array($icon_array['album_category'].$lang_modifyalb_php['alb_cat'].$help['album_category'], 'category', 2), array($icon_array['description'].$captionLabel, 'description', 3), array($icon_array['keyword'].$lang_modifyalb_php['alb_keyword'].$help['album_keywords'], 'keyword', 0), array($lang_modifyalb_php['alb_thumb'], 'thumb', 4), $lang_modifyalb_php['alb_perm'], array($icon_array['view'].$lang_modifyalb_php['can_view'].$help['album_can_be_viewed_by'], 'visibility', 5), array($icon_array['password'].$lang_modifyalb_php['password_protect'].$help['album_password'], 'password_protect', 9), array($icon_array['blank'].$lang_modifyalb_php['alb_password'], 'alb_password', 6), array($icon_array['blank'].$lang_modifyalb_php['alb_password_hint'], 'alb_password_hint', 7), array($icon_array['upload'].$lang_modifyalb_php['can_upload'].$notice1.$help['can_upload'], 'uploads', 1), array($icon_array['comment'].$lang_modifyalb_php['can_post_comments'].$notice1.$help['can_post_comments'], 'comments', 1), array($icon_array['rate'].$lang_modifyalb_php['can_rate'].$notice1.$help['can_rate'], 'votes', 1), ); /* TODO: re-enable and test feature when it's clear how it should work (see http://forum.coppermine-gallery.net/index.php/topic,64408.0.html) if (GALLERY_ADMIN_MODE) { $data[] = array($lang_modifyalb_php['can_moderate'].$help['can_moderate'], 'moderator_group', 8); } */ function form_label($text) { echo <<< EOT $text EOT; } function form_input($text, $name) { global $ALBUM_DATA, $CONFIG; $value = $ALBUM_DATA[$name]; $disabled = ''; if ($name == 'keyword' && !GALLERY_ADMIN_MODE && $CONFIG['allow_user_album_keyword'] != 1) { $disabled = ' disabled="disabled" style="background-color:InactiveCaptionText;color:GrayText"'; } switch ($name) { case 'title': $maxlength = ' maxlength="255"'; break; case 'keyword': $maxlength = ' maxlength="50"'; break; default: $maxlength = ''; break; } echo <<< EOT $text EOT; } function form_yes_no($text, $name) { global $ALBUM_DATA, $lang_common; if ($name == 'uploads' && USER_ADMIN_MODE) { echo " "; return; } $value = isset($ALBUM_DATA[$name]) ? $ALBUM_DATA[$name] : false; $yes_selected = $value == 'YES' ? 'checked="checked"' : ''; $no_selected = $value == 'NO' ? 'checked="checked"' : ''; echo <<< EOT $text    EOT; } function form_category($text, $name) { global $ALBUM_DATA, $CAT_LIST, $USER_DATA, $lang_modifyalb_php, $CONFIG, $icon_array, $LINEBREAK; //check if users are allowed to move their albums if (!GALLERY_ADMIN_MODE && $CONFIG['allow_user_move_album'] == 0) { //get category name $cat_name = $lang_modifyalb_php['user_gal']; if ($ALBUM_DATA['category'] != (FIRST_USER_CAT + USER_ID)) { $result = cpg_db_query("SELECT name FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '" . $ALBUM_DATA['category'] . "' LIMIT 1"); $cat_name = cpg_db_fetch_row($result); mysql_free_result($result); $cat_name = $cat_name['name']; } echo <<< EOT $text {$cat_name} EOT; return; } $CAT_LIST = array(); //only add 'no category' when user is admin if (GALLERY_ADMIN_MODE) { $CAT_LIST[] = array(0, $lang_modifyalb_php['no_cat']); } //add user catergory $CAT_LIST[] = array((FIRST_USER_CAT + USER_ID), $lang_modifyalb_php['my_gal']); get_cat_data(); echo <<< EOT $text {$icon_array['move']} EOT; } function form_textarea($text, $name) { global $ALBUM_DATA; $value = $ALBUM_DATA[$name]; echo <<< EOT $text EOT; } function form_alb_thumb($text, $name) { global $CONFIG, $ALBUM_DATA, $CLEAN, $lang_modifyalb_php, $USER_DATA, $LINEBREAK, $help, $icon_array; $cpg_nopic_data = cpg_get_system_thumb('nopic.jpg', $USER_DATA['user_id']); $keyword = ''; if ($ALBUM_DATA['keyword']) { $keyword = "OR (keywords LIKE '%{$ALBUM_DATA['keyword']}%')"; } $query = "SELECT pid, filepath, filename, url_prefix FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND (aid = '{$CLEAN['album']}' $keyword ) ORDER BY filename"; $results = cpg_db_query($query); if (mysql_num_rows($results) == 0) { echo <<< EOT {$text} {$lang_modifyalb_php['alb_empty']} EOT; return; } $thumbs = array( 0 => $cpg_nopic_data['thumb'], ); $img_list = array( 0 => $lang_modifyalb_php['last_uploaded'], -1 => $lang_modifyalb_php['random_image'], ); while ($picture = mysql_fetch_assoc($results)) { $thumb_url = get_pic_url($picture, 'thumb'); $thumbs[$picture['pid']] = $thumb_url; if ($picture['pid'] == $ALBUM_DATA[$name]) { $thumbs[0] = $thumb_url; } $img_list[$picture['pid']] = htmlspecialchars($picture['filename']); } mysql_free_result($results); $thumbs_json = json_encode($thumbs); $thumb_cell_height = $CONFIG['thumb_width'] + 17; echo <<< EOT {$icon_array['album_thumbnail']}{$text}{$help['album_thumbnail']} $text
EOT; echo <<< EOT EOT; echo <<< EOT EOT; } function form_password_protect($text, $name) { global $ALBUM_DATA; if (!empty($ALBUM_DATA['alb_password'])) { $checked = ' checked="checked"'; } else { $checked = ''; } echo <<< EOT $text EOT; } function form_password($text, $name) { global $ALBUM_DATA; $value = $ALBUM_DATA[$name]; echo << $text EOT; } function form_password_hint($text, $name) { global $ALBUM_DATA; $value = $ALBUM_DATA[$name]; echo <<< EOT $text EOT; } function form_visibility($text, $name) { global $CONFIG, $USER_DATA, $ALBUM_DATA, $lang_modifyalb_php, $cpg_udb, $LINEBREAK; if (!$CONFIG['allow_private_albums']) { echo ' ' . $LINEBREAK; return; } if (GALLERY_ADMIN_MODE) { $options = array( 0 => $lang_modifyalb_php['public_alb'], FIRST_USER_CAT + USER_ID => $lang_modifyalb_php['me_only'], ); if ($ALBUM_DATA['category'] > FIRST_USER_CAT) { $owner_name = $cpg_udb->get_user_name($ALBUM_DATA['category'] - FIRST_USER_CAT); $options[$ALBUM_DATA['category']] = sprintf($lang_modifyalb_php['owner_only'], $owner_name); } $result = cpg_db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']}"); while ($group = mysql_fetch_assoc($result)) { $options[$group['group_id']] = sprintf($lang_modifyalb_php['group_only'], $group['group_name']); } mysql_free_result($result); } else { $options = array( 0 => $lang_modifyalb_php['public_alb'], FIRST_USER_CAT + USER_ID => $lang_modifyalb_php['me_only'], ); $result = cpg_db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id IN " . USER_GROUP_SET); while ($group = mysql_fetch_assoc($result)) { $options[$group['group_id']] = sprintf($lang_modifyalb_php['group_only'], $group['group_name']); } mysql_free_result($result); } echo <<< EOT $text EOT; } function form_moderator($text, $name) { global $CONFIG, $ALBUM_DATA, $lang_modifyalb_php, $LINEBREAK; $options = array( 0 => $lang_modifyalb_php['admins_only'], ); $result = cpg_db_query("SELECT group_id, group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id > 1"); while ($group = mysql_fetch_assoc($result)) { $options[$group['group_id']] = sprintf($lang_modifyalb_php['group_only'], $group['group_name']); } mysql_free_result($result); echo <<< EOT $text EOT; } function create_form(&$data) { foreach ($data as $element) { if (is_array($element)) { switch ($element[2]) { case 0: form_input($element[0], $element[1]); break; case 1: form_yes_no($element[0], $element[1]); break; case 2: form_category($element[0], $element[1]); break; case 3: form_textarea($element[0], $element[1]); break; case 4: form_alb_thumb($element[0], $element[1]); break; case 5: form_visibility($element[0], $element[1]); break; case 6: form_password($element[0], $element[1]); break; case 7: form_password_hint($element[0], $element[1]); break; case 8: form_moderator($element[0], $element[1]); break; case 9: form_password_protect($element[0], $element[1]); break; default: cpg_die(CRITICAL_ERROR, 'Invalid action for form creation', __FILE__, __LINE__); } } else { form_label($element); } } } function alb_list_box() { global $CONFIG, $CLEAN, $cpg_udb, $CPG_PHP_SELF, $lang_modifyalb_php, $LINEBREAK; $rowset = array(); if (GALLERY_ADMIN_MODE) { $result = cpg_db_query("SELECT a.aid, a.title, c.name FROM {$CONFIG['TABLE_ALBUMS']} AS a INNER JOIN {$CONFIG['TABLE_CATEGORIES']} AS c ON a.category = c.cid WHERE a.category < '" . FIRST_USER_CAT . "'"); while ($row = mysql_fetch_assoc($result)) { // Add to multi-dim array for later sorting $rowset[] = array( 'cat' => $row['name'], 'aid' => $row['aid'], 'title' => $row['title'], ); } mysql_free_result($result); //now we need to select the albums without a category $result = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = 0"); while ($row = mysql_fetch_assoc($result)) { // Add to multi-dim array for later sorting $rowset[] = array( 'cat' => $lang_modifyalb_php['no_cat'], 'aid' => $row['aid'], 'title' => $row['title'], ); } mysql_free_result($result); $sql = $cpg_udb->get_admin_album_list(); $result = cpg_db_query($sql); while ($row = mysql_fetch_assoc($result)) { // Add to multi-dim array for later sorting $rowset[] = array( 'cat' => $lang_modifyalb_php['user_gal'], 'aid' => $row['aid'], 'title' => $row['title'], ); } mysql_free_result($result); } else { //Only list the albums owned by the user //get albums in "my albums" $result = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = ".(USER_ID + FIRST_USER_CAT)." AND owner = ".USER_ID); while ($row = mysql_fetch_assoc($result)) { // Add to multi-dim array for later sorting $rowset[] = array( 'cat' => $lang_modifyalb_php['my_gal'], 'aid' => $row['aid'], 'title' => $row['title'], ); } mysql_free_result($result); //get public albums $result = cpg_db_query("SELECT a.aid, a.title, c.name FROM {$CONFIG['TABLE_ALBUMS']} AS a INNER JOIN {$CONFIG['TABLE_CATEGORIES']} AS c ON a.category = c.cid WHERE a.owner = ".USER_ID); while ($row = mysql_fetch_assoc($result)) { // Add to multi-dim array for later sorting $rowset[] = array( 'cat' => $row['name'], 'aid' => $row['aid'], 'title' => $row['title'], ); } mysql_free_result($result); //now we need to select the albums without a category $result = cpg_db_query("SELECT aid, title FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = 0 AND owner = ".USER_ID); while ($row = mysql_fetch_assoc($result)) { // Add to multi-dim array for later sorting $rowset[] = array( 'cat' => $lang_modifyalb_php['no_cat'], 'aid' => $row['aid'], 'title' => $row['title'], ); } mysql_free_result($result); } // Sort by category and album title $rowset = array_csort($rowset, 'cat', 'title'); if (count($rowset)) { // Create the nicely sorted and formatted drop down list $alb_cat = ''; $select = "' . $LINEBREAK; return $select; } } if (!$CLEAN['album']) { if (GALLERY_ADMIN_MODE) { $results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_ALBUMS']} WHERE 1 LIMIT 1"); } else { $results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = " . (FIRST_USER_CAT + USER_ID) . " OR owner = '" . USER_ID . "' LIMIT 1"); } if (mysql_num_rows($results) == 0) { cpg_die(ERROR, $lang_modifyalb_php['err_no_alb_to_modify'], __FILE__, __LINE__); } $ALBUM_DATA = mysql_fetch_assoc($results); $CLEAN['album'] = $ALBUM_DATA['aid']; } else { $results = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid='{$CLEAN['album']}'"); if (!mysql_num_rows($results)) { cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__); } $ALBUM_DATA = mysql_fetch_assoc($results); } $cat = $ALBUM_DATA['category']; $actual_cat = $cat; //////////// main code start /////////////////// js_include('js/modifyalb.js'); set_js_var('reset_views_confirm', $lang_modifyalb_php['reset_views_confirm']); set_js_var('cursor_stop', $icon_array['stop']); pageheader(sprintf($lang_modifyalb_php['upd_alb_n'], $ALBUM_DATA['title'])); $album_lb = alb_list_box(); echo <<< EOT
EOT; starttable("100%", cpg_fetch_icon('modifyalb', 1) . $lang_common['album_properties'] . ' - ' . $lang_modifyalb_php['update'].$help['table'], 2, 'cpg_zebra'); echo <<< EOT {$lang_modifyalb_php['related_tasks']}{$help['related_tasks']} {$icon_array['edit_files']}{$lang_modifyalb_php['edit_files']}   -   {$icon_array['category']}{$lang_modifyalb_php['parent_category']}   -   {$icon_array['thumbnail']}{$lang_modifyalb_php['thumbnail_view']} {$icon_array['album']}{$lang_modifyalb_php['choose_album']}{$help['choose_album']} $album_lb EOT; create_form($data); echo <<< EOT EOT; if (GALLERY_ADMIN_MODE) { printf($lang_modifyalb_php['notice1'], '', ''); } else { printf($lang_modifyalb_php['notice1'], '', ''); } list($timestamp, $form_token) = getFormToken(); echo <<< EOT EOT; endtable(); echo '
'; if (GALLERY_ADMIN_MODE) { // get the album stats $result = cpg_db_query("SELECT SUM(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE aid='{$CLEAN['album']}'"); $nbEnr = mysql_fetch_array($result); $hits = $nbEnr[0]; if (!$hits) { $hits = 0; } mysql_free_result($result); $result = cpg_db_query("SELECT SUM(votes) FROM {$CONFIG['TABLE_PICTURES']} WHERE aid='{$CLEAN['album']}' AND votes > 0"); $nbEnr = mysql_fetch_array($result); $votes = $nbEnr[0]; if (!$votes) { $votes = 0; } mysql_free_result($result); $result = cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE aid='{$CLEAN['album']}'"); $nbEnr = mysql_fetch_array($result); $files = $nbEnr[0]; if (!$files) { $files = 0; } mysql_free_result($result); $result = cpg_db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_COMMENTS']} AS c INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.pid = c.pid WHERE aid='{$CLEAN['album']}'"); $nbEnr = mysql_fetch_array($result); $comments = $nbEnr[0]; if (!$comments) { $comments = 0; } mysql_free_result($result); echo <<< EOT
EOT; // set up the translation strings $translation_reset_views = sprintf($lang_modifyalb_php['reset_views'], '"'.$ALBUM_DATA['title'].'"'); $translation_reset_rating = sprintf($lang_modifyalb_php['reset_rating'], '"'.$ALBUM_DATA['title'].'"'); $translation_delete_comments = sprintf($lang_modifyalb_php['delete_comments'], '"'.$ALBUM_DATA['title'].'"'); $translation_delete_files = sprintf($lang_modifyalb_php['delete_files'], '', '', '"'.$ALBUM_DATA['title'].'"'); starttable('100%', cpg_fetch_icon('modifyalb', 1) . $lang_common['album_properties'] . ' - ' . $lang_modifyalb_php['reset_album'], 2); echo <<< EOT {$icon_array['views']} $hits {$lang_modifyalb_php['views']} {$icon_array['rate']} $votes {$lang_modifyalb_php['votes']} {$icon_array['comment']} $comments {$lang_modifyalb_php['comments']} {$icon_array['file']} $files {$lang_modifyalb_php['files']} EOT; endtable(); echo <<< EOT
EOT; } pagefooter(); ?>