function wppa_get_user_create_html($alb, $width, $where = '', $mcr = false) { // Init $result = ''; $mocc = wppa('mocc'); $occur = wppa('occur'); if ($alb < '0') { $alb = '0'; } // Feature enabled ? if (!wppa_switch('user_create_on')) { return ''; } // Have access? if ($alb && !wppa_have_access($alb)) { return ''; } // Can create album? if (!$alb && !wppa_can_create_top_album()) { return ''; } if ($alb && !wppa_can_create_album()) { return ''; } if (!wppa_user_is('administrator') && wppa_switch('owner_only')) { if ($alb) { $album = wppa_cache_album($alb); // Need to be admin to create public subalbums if ($album['owner'] == '--- public ---') { return ''; } } } // In a widget or multi column responsive? $small = wppa_in_widget() == 'upload' || $mcr; // Create the return url $returnurl = wppa_get_permalink(); if ($where == 'cover') { $returnurl .= 'wppa-album=' . $alb . '&wppa-cover=0&wppa-occur=' . $occur; } elseif ($where == 'thumb') { $returnurl .= 'wppa-album=' . $alb . '&wppa-cover=0&wppa-occur=' . $occur; } elseif ($where == 'widget' || $where == 'uploadbox') { } if (wppa('page')) { $returnurl .= '&wppa-page=' . wppa('page'); } $returnurl = trim($returnurl, '?'); $returnurl = wppa_trim_wppa_($returnurl); $t = $mcr ? 'mcr-' : ''; // The links $result .= '<div style="clear:both"></div>' . '<a' . ' id="wppa-cr-' . $alb . '-' . $mocc . '"' . ' class="wppa-create-' . $where . '"' . ' onclick="' . 'jQuery( \'#wppa-create-' . $t . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-cr-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-up-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-ea-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cats-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#_wppa-cr-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . '_wppaDoAutocol( ' . $mocc . ' )' . '"' . ' style="float:left; cursor:pointer;"' . '> ' . __('Create Album', 'wp-photo-album-plus') . '</a>' . '<a' . ' id="_wppa-cr-' . $alb . '-' . $mocc . '"' . ' class="wppa-create-' . $where . '"' . ' onclick="' . 'jQuery( \'#wppa-create-' . $t . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . 'jQuery( \'#wppa-cr-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-up-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-ea-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#wppa-cats-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'block\' );' . 'jQuery( \'#_wppa-cr-' . $alb . '-' . $mocc . '\' ).css( \'display\',\'none\' );' . '_wppaDoAutocol( ' . $mocc . ' )' . '"' . ' style="float:right; cursor:pointer;display:none;"' . ' >' . __(wppa_opt('close_text'), 'wp-photo-album-plus') . '</a>'; // The create form $result .= '<div' . ' id="wppa-create-' . $t . $alb . '-' . $mocc . '"' . ' class="wppa-file-' . $t . $mocc . '"' . ' style="width:' . $width . 'px;text-align:center;display:none;"' . ' >' . '<form' . ' id="wppa-creform-' . $alb . '-' . $mocc . '"' . ' action="' . $returnurl . '"' . ' method="post"' . ' >' . wppa_nonce_field('wppa-album-check', 'wppa-nonce', false, false, $alb) . '<input type="hidden" name="wppa-album-parent" value="' . $alb . '" />' . '<input type="hidden" name="wppa-fe-create" value="yes" />' . '<div' . ' class="wppa-box-text wppa-td"' . ' style="' . 'clear:both;' . 'float:left;' . 'text-align:left;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Enter album name.', 'wp-photo-album-plus') . ' <span style="font-size:10px;" >' . __('Don\'t leave this blank!', 'wp-photo-album-plus') . '</span>' . '</div>' . '<input' . ' type="text"' . ' class="wppa-box-text wppa-file-' . $t . $mocc . '"' . ' style="padding:0; width:' . ($width - 6) . 'px; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-album-name"' . ' />' . '<div' . ' class="wppa-box-text wppa-td"' . ' style="' . 'clear:both;' . 'float:left;' . 'text-align:left;' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' >' . __('Enter album description', 'wp-photo-album-plus') . '</div>' . '<textarea' . ' class="wppa-user-textarea wppa-box-text wppa-file-' . $t . $mocc . '"' . ' style="padding:0;height:120px; width:' . ($width - 6) . 'px; ' . __wcs('wppa-box-text') . '"' . ' name="wppa-album-desc" >' . '</textarea>' . '<div style="float:left; margin: 6px 0;" >' . '<div style="float:left;">' . wppa_make_captcha(wppa_get_randseed('session')) . '</div>' . '<input' . ' type="text"' . ' id="wppa-captcha-' . $mocc . '"' . ' name="wppa-captcha"' . ' style="margin-left: 6px; width:50px; ' . __wcs('wppa-box-text') . __wcs('wppa-td') . '"' . ' />' . '</div>' . '<input' . ' type="submit"' . ' class="wppa-user-submit"' . ' style="margin: 6px 0; float:right; ' . __wcs('wppa-box-text') . '"' . ' value="' . __('Create album', 'wp-photo-album-plus') . '"' . ' />' . '</form>' . '</div>'; return $result; }
function wppa_can_create_top_album() { if (wppa_user_is('administrator')) { return true; } if (!wppa_can_create_album()) { return false; } if (wppa_switch('wppa_grant_an_album') && '0' != wppa_opt('wppa_grant_parent')) { return false; } return true; }
function wppa_do_albumlist($parent, $nestinglevel, $albums, $seq) { global $wpdb; $alt = true; foreach (array_keys($seq) as $s) { // Obey the global sequence $album = $albums[$s]; if ($album['a_parent'] == $parent) { if (wppa_have_access($album)) { $counts = wppa_treecount_a($album['id']); $pendcount = $counts['pendphotos']; $schedulecount = $counts['scheduledphotos']; $haschildren = wppa_have_accessable_children($album); $class = ''; if ($parent != '0' && $parent != '-1') { $class .= 'wppa-alb-on-' . $parent . ' '; $par = $parent; while ($par != '0' && $par != '-1') { $class .= 'wppa-alb-off-' . $par . ' '; $par = wppa_get_parentalbumid($par); } } if ($alt) { $class .= ' alternate'; } $style = ''; if ($pendcount) { $style .= 'background-color:#ffdddd; '; } // if ( $haschildren ) $style .= 'font-weight:bold; '; if ($parent != '0' && $parent != '-1') { $style .= 'display:none; '; } $onclickon = 'jQuery(\'.wppa-alb-on-' . $album['id'] . '\').css(\'display\',\'\'); jQuery(\'#alb-arrow-on-' . $album['id'] . '\').css(\'display\',\'none\'); jQuery(\'#alb-arrow-off-' . $album['id'] . '\').css(\'display\',\'\');'; $onclickoff = 'jQuery(\'.wppa-alb-off-' . $album['id'] . '\').css(\'display\',\'none\'); jQuery(\'#alb-arrow-on-' . $album['id'] . '\').css(\'display\',\'\'); jQuery(\'#alb-arrow-off-' . $album['id'] . '\').css(\'display\',\'none\'); checkArrows();'; $indent = $nestinglevel; if ($indent > '5') { $indent = 5; } ?> <tr class="<?php echo $class; ?> " style="<?php echo $style; ?> " > <?php $i = 0; while ($i < $indent) { echo '<td style="padding:2px;" ></td>'; $i++; } ?> <td style="padding:2px; text-align:center;" ><?php if ($haschildren) { ?> <img id="alb-arrow-off-<?php echo $album['id']; ?> " class="alb-arrow-off" style="height:16px; display:none;" src="<?php echo wppa_get_imgdir() . 'backarrow.gif'; ?> " onclick="<?php echo $onclickoff; ?> " title="<?php _e('Collapse subalbums', 'wp-photo-album-plus'); ?> " /> <img id="alb-arrow-on-<?php echo $album['id']; ?> " class="alb-arrow-on" style="height:16px;" src="<?php echo wppa_get_imgdir() . 'arrow.gif'; ?> " onclick="<?php echo $onclickon; ?> " title="<?php _e('Expand subalbums', 'wp-photo-album-plus'); ?> " /> <?php } ?> </td> <td style="padding:2px;" ><?php echo $album['id']; ?> </td> <?php $i = $indent; while ($i < 5) { echo '<td style="padding:2px;" ></td>'; $i++; } ?> <td><?php echo esc_attr(__(stripslashes($album['name']))); ?> </td> <td><small><?php echo esc_attr(__(stripslashes($album['description']))); ?> </small></td> <?php if (current_user_can('administrator')) { ?> <td><?php echo $album['owner']; ?> </td> <?php } ?> <td><?php echo $album['a_order']; ?> </td> <td><?php echo wppa_get_album_name($album['a_parent'], 'extended'); ?> </td> <?php $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=' . $album['id']); ?> <?php $na = $counts['selfalbums']; ?> <?php $np = $counts['selfphotos']; ?> <?php $nm = $counts['pendphotos']; ?> <?php $ns = $counts['scheduledphotos']; ?> <td><?php echo $na . '/' . $np . '/' . $nm . '/' . $ns; ?> </td> <?php if ($album['owner'] != '--- public ---' || wppa_user_is('administrator')) { ?> <?php $url = wppa_ea_url($album['id']); ?> <td><a href="<?php echo $url; ?> " class="wppaedit"><?php _e('Edit', 'wp-photo-album-plus'); ?> </a></td> <td><a href="<?php echo $url . '&quick'; ?> " class="wppaedit"><?php _e('Quick', 'wp-photo-album-plus'); ?> </a></td> <td><a href="<?php echo $url . '&bulk#manage-photos'; ?> " class="wppaedit"><?php _e('Bulk', 'wp-photo-album-plus'); ?> </a></td> <td><a href="<?php echo $url . '&seq'; ?> " class="wppaedit"><?php _e('Seq', 'wp-photo-album-plus'); ?> </a></td> <?php $url = wppa_ea_url($album['id'], 'del'); ?> <td><a href="<?php echo $url; ?> " class="wppadelete"><?php _e('Delete', 'wp-photo-album-plus'); ?> </a></td> <?php if (wppa_can_create_album()) { $url = wppa_dbg_url(get_admin_url() . 'admin.php?page=wppa_admin_menu&tab=edit&edit_id=new&parent_id=' . $album['id']); if (wppa_switch('confirm_create')) { $onc = 'if (confirm(\'' . __('Are you sure you want to create a subalbum?', 'wp-photo-album-plus') . '\')) document.location=\'' . $url . '\';'; echo '<td><a onclick="' . $onc . '" class="wppacreate">' . __('Create', 'wp-photo-album-plus') . '</a></td>'; } else { echo '<td><a href="' . $url . '" class="wppacreate">' . __('Create', 'wp-photo-album-plus') . '</a></td>'; } } } else { ?> <td></td><td></td><?php if (wppa_can_create_album()) { echo '<td></td'; } ?> <?php } ?> </tr> <?php if ($alt == '') { $alt = ' class="alternate" '; } else { $alt = ''; } if ($haschildren) { wppa_do_albumlist($album['id'], $nestinglevel + '1', $albums, $seq); } } } } }