Skip to content

Commit

Permalink
Merge branch '1.3.61'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steven Mathias committed Jul 17, 2013
2 parents 6478115 + ab8ca8f commit c014ed4
Show file tree
Hide file tree
Showing 63 changed files with 2,944 additions and 5,403 deletions.
2 changes: 0 additions & 2 deletions admin/about.php
Expand Up @@ -45,8 +45,6 @@ function agp_is_ie6() {
echo '</li><li>';
printf(__('French by %s', 'scoper'), "<a href='http://chryjs.free.fr' target='_blank'>Chryjs</a>");
echo '</li><li>';
printf(__('Italian by %s', 'scoper' ), "<a href='http://obertfsp.com' target='_blank'>Alberto Ramacciotti</a>");
echo '</li></ul><p>';
_e( 'I do try to be translator-friendly, but any untranslated captions are likely due to a flurry of recent additions and changes by the plugin developer. Now there must be someone else who wants Role Scoper in their language...', 'scoper');
echo '</p><p>';
printf(__( 'Role Scoper is open source software released under the %1$s General Public License (GPL)%2$s. Due to limitations, obligations and non-technical aspirations common to most human beings, I will probably never again pursue uncommissioned plugin development on the scale Role Scoper has required. However, I do plan to provide some free support, correct bugs which emerge and revise the plugin for future WordPress versions. If it adds value to your website or saves you time and money, you can express appreciation in several ways:', 'scoper'), '<a href="http://www.opensource.org/licenses/gpl-license.php">', '</a>');
Expand Down
23 changes: 14 additions & 9 deletions admin/admin-bulk_rs.php
Expand Up @@ -128,7 +128,7 @@ function display_inputs($mode, $assignment_modes, $args = array()) {
$retain_value = ( isset($_POST["max_scope"]) ) ? $_POST["max_scope"] : '';

foreach($max_scopes as $max_scope => $caption) {
$selected = ( $status_id === $retain_value ) ? 'selected="selected"' : '';
$selected = ( ! empty($status_id) && $status_id === $retain_value ) ? 'selected="selected"' : '';
echo "<option value='$max_scope' $selected>$caption</option>";
}
echo '</select></li>';
Expand Down Expand Up @@ -177,6 +177,7 @@ function display_inputs($mode, $assignment_modes, $args = array()) {
echo '</h3>';

ScoperAdminBulkLib::display_date_limit_inputs( $duration_limits_enabled, $content_date_limits_enabled );
echo '<div style="clear:both"></div>';
}

if ( ROLE_ASSIGNMENT_RS == $mode ) {
Expand Down Expand Up @@ -687,7 +688,7 @@ function item_tree($scope, $mode, $src, $otype_or_tx, $all_items, $assigned_role
}

static $prevtext, $nexttext, $is_administrator, $role_header, $agents_header;
if ( empty($prevtext) ) {
if ( empty($prevtext) || $single_item ) {
// buffer prev/next caption for display with each term
//$prevtext = _ x('prev', '|abbreviated link to previous item', 'scoper');
//$nexttext = _ x('next', '|abbreviated link to next item', 'scoper');
Expand Down Expand Up @@ -1045,12 +1046,14 @@ function item_tree($scope, $mode, $src, $otype_or_tx, $all_items, $assigned_role

$class = ($classes) ? " class='" . implode(' ', $classes) . "'" : '';

echo "\r\n"
. "<tr{$class}>"
. "<td>$checkbox</td>"
. "<td>$label</td>"
. "<td>{$open_brace}$setting_display{$close_brace}</td>"
. "</tr>";
if ( $setting_display || ! $single_item ) {
echo "\r\n"
. "<tr{$class}>"
. "<td>$checkbox</td>"
. "<td>$label</td>"
. "<td>{$open_brace}$setting_display{$close_brace}</td>"
. "</tr>";
}
} // end foreach role

} // end foreach object_type
Expand All @@ -1064,10 +1067,12 @@ function item_tree($scope, $mode, $src, $otype_or_tx, $all_items, $assigned_role
}

echo '</li>';
echo '</ul><br /><ul>';
echo '</ul><br />';

// now display "select all" checkboxes for all terms in this taxonomy
if ( empty( $single_item ) ) {
echo '<ul>';

if ( defined('SCOPER_EXTRA_SUBMIT_BUTTON') ) {
echo '<li class="alignright"><span class="submit" style="border:none;"><input type="submit" name="rs_submit" value="'
. __('Update &raquo;', 'scoper')
Expand Down
2 changes: 1 addition & 1 deletion admin/admin_lib-bulk_rs.php
Expand Up @@ -225,7 +225,7 @@ function display_date_limit_inputs( $role_duration = true, $content_date_limits
}

$js_call = "agp_display_if('role_duration_inputs', 'set_role_duration')";
echo "<label for='set_role_duration'><input type='checkbox' id='set_role_duration' name='set_role_duration' value='1' $checked onclick=\"$js_call\" /><strong>";
echo "<label for='set_role_duration'><input type='checkbox' id='set_role_duration' name='set_role_duration' value='1' $checked onclick=\"$js_call\" /> <strong>";
_e( 'Modify Role Duration', 'scoper' );
echo '</strong></label><br />';

Expand Down
10 changes: 8 additions & 2 deletions admin/admin_lib-mu_rs.php
Expand Up @@ -60,10 +60,16 @@ function scoper_get_blog_list( $start = 0, $num = 10 ) {
global $wpdb;

$blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );

$blog_list = array();

foreach ( (array) $blogs as $details ) {
$table_name = ( $details['blog_id'] > 1 ) ? $wpdb->base_prefix . $details['blog_id'] . "_posts" : $wpdb->base_prefix . 'posts';

if ( ! $wpdb->get_results( "SHOW TABLES LIKE '$table_name'" ) )
continue;

$blog_list[ $details['blog_id'] ] = $details;
$blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM " . $wpdb->base_prefix . $details['blog_id'] . "_posts WHERE post_status='publish' AND post_type='post'" );
$blog_list[ $details['blog_id'] ]['postcount'] = $wpdb->get_var( "SELECT COUNT(ID) FROM $table_name WHERE post_status='publish' AND post_type='post'" );
}
unset( $blogs );
$blogs = $blog_list;
Expand Down
9 changes: 7 additions & 2 deletions admin/admin_lib_rs.php
Expand Up @@ -20,7 +20,6 @@
if ( strpos( $_SERVER['REQUEST_URI'], 'nggallery' ) ) // Role Scoping for NGG calls ScoperAdminUI::dropdown_pages
require_once( dirname(__FILE__).'/admin_ui_lib_rs.php' );


class ScoperAdminLib {
// filter page dropdown contents for Page Parent controls; leave others alone
function flt_dropdown_pages($orig_options_html) {
Expand Down Expand Up @@ -462,8 +461,14 @@ function delete_users( $user_ids, $blog_id_arg = 0 ) {

$user_clause = "user_id IN ('" . implode("', '", $user_ids) . "')";

$table_name = ( $blog_id_arg ) ? $wpdb->base_prefix . $blog_id_arg . '_' . 'user2role2object_rs' : $wpdb->user2role2object_rs;
if ( $blog_id_arg )
$table_name = ( $blog_id_arg > 1 ) ? $wpdb->base_prefix . $blog_id_arg . '_' . 'user2role2object_rs' : $wpdb->base_prefix . 'user2role2object_rs';
else
$table_name = $wpdb->user2role2object_rs;

if ( ! $wpdb->get_results( "SHOW TABLES LIKE '$table_name'" ) )
return;

scoper_query("DELETE FROM $table_name WHERE $user_clause");

foreach ( $user_ids as $user_id ) {
Expand Down
37 changes: 28 additions & 9 deletions admin/admin_rs.php
Expand Up @@ -67,6 +67,22 @@ function ScoperAdmin() {

add_action( 'admin_notices', array( &$this, 'dashboard_notice' ) );
}

if ( in_array( $pagenow, array( 'edit.php', 'post.php' ) ) && awp_ver( '3.5-beta' ) ) {
add_action( 'admin_menu', array( &$this, 'reinstate_solo_submenus' ) );
add_action( 'network_admin_menu', array( &$this, 'reinstate_solo_submenus' ) );
}
}

function reinstate_solo_submenus() {
global $submenu;

// Add a dummy submenu item to prevent WP from stripping out solitary submenus. Otherwise menu access loses type sensitivity and requires "edit_posts" cap for all types.
foreach( $submenu as $key => $data ) {
if ( 1 == count( $submenu[$key] ) && ( 0 === strpos( $key, 'edit.php' ) ) ) {
$submenu[$key][999] = array( '', 'read', $key );
}
}
}

function dashboard_notice() {
Expand Down Expand Up @@ -212,23 +228,26 @@ function admin_head() {
$otype_def = $this->scoper->data_sources->member_property($src_name, 'object_types', $object_type);

if ( ! empty($src) && ! empty($src->cols->parent) && empty($otype_def->ignore_object_hierarchy) ) {
$obj_title = sprintf( __('assign role for this %s', 'scoper'), agp_strtolower( $otype_def->labels->singular_name ) );
$child_title = sprintf( __('assign role for sub-%s', 'scoper'), agp_strtolower( $otype_def->labels->name ) );
if ( ! empty( $otype_def->labels ) ) {
$obj_title = sprintf( __('assign role for this %s', 'scoper'), agp_strtolower( $otype_def->labels->singular_name ) );
$child_title = sprintf( __('assign role for sub-%s', 'scoper'), agp_strtolower( $otype_def->labels->name ) );

$js_params = "var role_for_object_title = '$obj_title';"
. "var role_for_children_title = '$child_title';";

// TODO: replace some of this JS with equivalent JQuery
echo "\n" . '<script type="text/javascript">' . $js_params . '</script>';
echo "\n" . "<script type='text/javascript' src='" . SCOPER_URLPATH . "/admin/rs-objrole-cbox-maint.js'></script>";
$js_params = "var role_for_object_title = '$obj_title';"
. "var role_for_children_title = '$child_title';";

// TODO: replace some of this JS with equivalent JQuery
echo "\n" . '<script type="text/javascript">' . $js_params . '</script>';
echo "\n" . "<script type='text/javascript' src='" . SCOPER_URLPATH . "/admin/rs-objrole-cbox-maint.js'></script>";
}
}
}

add_filter( 'contextual_help_list', array(&$this, 'flt_contextual_help_list'), 10, 2 );

if ( ( 0 === strpos( $plugin_page_cr, 'rs-' ) ) && strpos( $plugin_page_cr, 'roles' ) ) {
// add Ajax goodies we need for role duration/content date limit editing Bulk Role Admin
wp_print_scripts( array( 'page' ) );
if ( ! awp_ver('3.4') )
wp_print_scripts( array( 'page' ) );

require_once( dirname(__FILE__).'/admin_lib-bulk_rs.php' );
ScoperAdminBulkLib::date_limits_js();
Expand Down
13 changes: 11 additions & 2 deletions admin/admin_ui_lib_rs.php
Expand Up @@ -137,7 +137,7 @@ function restriction_captions( $scope, $tx = '', $item_label_singular = '', $ite

function role_owners_key($tx_or_otype, $args = array()) {
$defaults = array( 'display_links' => true, 'display_restriction_key' => true, 'restriction_caption' => '',
'role_basis' => '', 'agent_caption' => '' );
'role_basis' => '', 'agent_caption' => '', 'single_item' => false );
$args = array_merge( $defaults, (array) $args);
extract($args);

Expand All @@ -153,7 +153,12 @@ function role_owners_key($tx_or_otype, $args = array()) {

$agent_caption = agp_strtolower($agent_caption);

echo '<h4 style="margin-bottom:0.1em"><a name="scoper_key"></a>' . __("Users / Groups Key", 'scoper') . ':</h4><ul class="rs-agents_key">';
if ( $single_item ) {
echo '<div id="single_item_roles_key" style="display:none">';
echo '<div style="margin-bottom:0.1em;margin-top:0"><strong><a name="scoper_key"></a>' . __("Users / Groups Key", 'scoper') . ':</strong></div><ul class="rs-agents_key">';
} else {
echo '<h4 style="margin-bottom:0.1em"><a name="scoper_key"></a>' . __("Users / Groups Key", 'scoper') . ':</h4><ul class="rs-agents_key">';
}

$link_open = ( $display_links ) ? "<a class='rs-link_plain' href='javascript:void(0)'>" : '';
$link_close = ( $display_links ) ? '</a>' : '';
Expand Down Expand Up @@ -186,6 +191,10 @@ function role_owners_key($tx_or_otype, $args = array()) {
}

echo '</ul>';

if ( $single_item ) {
echo '</div><br />';
}
}

// Role Scoping for NGG calls ScoperAdminUI::dropdown_pages
Expand Down
2 changes: 2 additions & 0 deletions admin/attachments_utility.php
Expand Up @@ -239,6 +239,8 @@ function scoper_attach_linked_uploads( $echo = false ) {

$search_replace_url = awp_plugin_search_url('replace');

$upload_path = $uploads['baseurl'];

if ( false !== strpos( $upload_path, 'http://www.' ) )
$www_msg = __('Note that to be detected as attachments, your file references must <strong>include www.</strong>');
else
Expand Down
43 changes: 29 additions & 14 deletions admin/filters-admin-save_rs.php
Expand Up @@ -69,9 +69,9 @@ function scoper_mnt_save_object($src_name, $args, $object_id, $object = '') {
$args = array_merge( $defaults, (array) $args );
extract($args);

if ( 'post' == $src_name ) {
global $scoper_admin_filters;
$is_new_object = empty($scoper_admin_filters->last_post_status[$object_id]) || ( 'new' == $scoper_admin_filters->last_post_status[$object_id] ) || ( 'auto-draft' == $scoper_admin_filters->last_post_status[$object_id] );
if ( 'post' == $src_name ) {
global $wpdb;
$is_new_object = ! get_post_meta($object_id, '_scoper_custom', true) && ! $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->user2role2object_rs WHERE scope = 'object' AND src_or_tx_name = 'post' AND obj_or_term_id = '$object_id'" );
} else
$is_new_object = true; // for other data sources, we have to assume object is new unless it has a role or restriction stored already.

Expand All @@ -85,7 +85,7 @@ function scoper_mnt_save_object($src_name, $args, $object_id, $object = '') {
$set_parent = 0;

if ( $col_parent = $scoper->data_sources->member_property($src_name, 'cols', 'parent') ) {
if ( in_array( $GLOBALS['pagenow'], array( 'post.php', 'post-new.php' ) ) ) {
if ( in_array( $GLOBALS['pagenow'], array( 'post.php', 'post-new.php', 'press-this.php' ) ) ) {
if ( isset($_POST[$col_parent]) )
$set_parent = $_POST[$col_parent];
} else {
Expand Down Expand Up @@ -430,18 +430,28 @@ function scoper_flt_post_status ($status) {

// Enforce any page parent filtering which may have been dictated by the flt_post_status filter, which executes earlier.
function scoper_flt_page_parent ($parent_id) {
if ( ! empty( $_POST['post_ID'] ) )
if ( $parent_id == $_POST['post_ID'] ) // normal revision save
return $parent_id;
if ( 'no_parent_filter' == scoper_get_option( 'lock_top_pages' ) )
return (int) $parent_id;

if ( ! empty($_REQUEST['post_ID']) )
$post_id = $_REQUEST['post_ID'];
elseif ( ! empty($_REQUEST['post_id']) )
$post_id = $_REQUEST['post_id'];
else
return (int) $parent_id;

if ( ! empty( $post_id ) )
if ( $parent_id == $post_id ) // normal revision save
return (int) $parent_id;

if ( defined( 'RVY_VERSION' ) ) {
global $revisionary;
if ( ! empty($revisionary->admin->revision_save_in_progress) )
return $parent_id;
return (int) $parent_id;
}

if ( empty($_POST['post_type']) )
return $parent_id;
return (int) $parent_id;

// Make sure the selected parent is valid. Merely an anti-hacking precaution to deal with manually fudged POST data
global $scoper, $wpdb;
Expand All @@ -452,7 +462,7 @@ function scoper_flt_page_parent ($parent_id) {
$args = array();
$args['alternate_reqd_caps'][0] = array("create_child_{$plural_name}");

if ( $descendant_ids = scoper_get_page_descendant_ids( $_POST['post_ID'] ) )
if ( $descendant_ids = scoper_get_page_descendant_ids( $post_id ) )
$exclusion_clause = "AND ID NOT IN('" . implode( "','", $descendant_ids ) . "')";
else
$exclusion_clause = '';
Expand All @@ -461,7 +471,7 @@ function scoper_flt_page_parent ($parent_id) {
$qry_parents = apply_filters('objects_request_rs', $qry_parents, 'post', $post_type, $args);
$valid_parents = scoper_get_col($qry_parents);

$post = get_post( $_POST['post_ID'] );
$post = get_post( $post_id );

if ( $parent_id ) {
if ( $post && ! in_array($parent_id, $valid_parents) ) {
Expand All @@ -481,13 +491,13 @@ function scoper_flt_page_parent ($parent_id) {
} elseif ( $valid_parents ) {
// otherwise default to a valid parent
sort( $valid_parents );
$parent_id = current($valid_parents);
$_POST['parent_id'] = $parent_id; // for subsequent post_status filter
$parent_id = reset($valid_parents);
$_POST['parent_id'] = (int) $parent_id; // for subsequent post_status filter
}
}
}

return $parent_id;
return (int) $parent_id;
}

function scoper_get_page_descendant_ids($page_id, $pages = '' ) {
Expand Down Expand Up @@ -827,6 +837,11 @@ function scoper_inherit_parent_roles($obj_or_term_id, $scope, $src_or_tx_name, $
}

function cr_get_posted_object_terms( $taxonomy ) {
if ( defined('XMLRPC_REQUEST') ) {
require_once( dirname(__FILE__).'/filters-admin-xmlrpc_rs.php' );
return _rs_get_posted_xmlrpc_terms( $taxonomy );
}

if ( 'category' == $taxonomy ) {
if ( ! empty($_POST['post_category']) )
return $_POST['post_category'];
Expand Down
13 changes: 5 additions & 8 deletions admin/filters-admin-term-selection_rs.php
Expand Up @@ -3,7 +3,7 @@
// Removes terms for which the user has edit cap, but not edit_[status] cap
// If the removed terms are already stored to the post (by a user who does have edit_[status] cap), they will be reinstated by reinstate_hidden_terms
function scoper_filter_terms_for_status($taxonomy, $selected_terms, &$user_terms, $args = array() ) {
if ( defined( 'DISABLE_QUERYFILTERS_RS' ) || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) )
if ( defined( 'DISABLE_QUERYFILTERS_RS' ) ) // || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) )
return $selected_terms;

global $scoper;
Expand All @@ -17,7 +17,7 @@ function scoper_filter_terms_for_status($taxonomy, $selected_terms, &$user_terms

if ( ! $src = $scoper->data_sources->get($tx->object_source) )
return $selected_terms;

if ( ! isset($src->statuses) || (count($src->statuses) < 2) )
return $selected_terms;

Expand All @@ -26,12 +26,9 @@ function scoper_filter_terms_for_status($taxonomy, $selected_terms, &$user_terms

if ( ! $status ) {
// determine current post status
if ( defined( 'XMLRPC_REQUEST' ) && ! empty($GLOBALS['scoper_xmlrpc_post_status'] ) ) {
$status = $GLOBALS['scoper_xmlrpc_post_status'];
} else {
if ( ! $status = $scoper->data_sources->get_from_http_post('status', $src) )
if ( $object_id )
$status = $scoper->data_sources->get_from_db('status', $src, $object_id);
if ( ! $status = $scoper->data_sources->get_from_http_post('status', $src) ) {
if ( $object_id )
$status = $scoper->data_sources->get_from_db('status', $src, $object_id);
}
}

Expand Down
17 changes: 16 additions & 1 deletion admin/filters-admin-ui-item_rs.php
Expand Up @@ -29,8 +29,24 @@ function ScoperAdminFiltersItemUI () {
add_action('admin_head', array(&$this, 'sync_private_js') );

add_action( 'admin_head', array(&$this, 'deactive_term_checkboxes') );
add_action( 'admin_print_footer_scripts', array(&$this, 'force_autosave_before_upload') );
}

function force_autosave_before_upload() { // under some configuration, it is necessary to pre-assign categories. Autosave accomplishes this by triggering save_post action handlers.
if ( ! is_content_administrator_rs() ) : ?>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready( function($) {
$( '#wp-content-media-buttons a').click( function() {
if ( $('#post-status-info span.autosave-message').html() == '&nbsp;' ) {
autosave();
}
});
});
/* ]]> */
</script>
<?php endif;
}

function deactive_term_checkboxes() {
if ( is_content_administrator_rs() )
Expand Down Expand Up @@ -73,7 +89,6 @@ function deactive_term_checkboxes() {
<?php
}


function default_private_js() {
global $post;

Expand Down

0 comments on commit c014ed4

Please sign in to comment.