Skip to content

Commit

Permalink
Set meta editing capabilities behind a user-activated setting and adm…
Browse files Browse the repository at this point in the history
…in access
  • Loading branch information
AramZS committed Feb 26, 2018
1 parent c566d61 commit dfc251b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
8 changes: 8 additions & 0 deletions Core/Admin/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,14 @@ function pf_options_admin_page_save() {
: 'draft';
update_option( PF_SLUG . '_draft_post_status', $pf_draft_post_status );

if ( isset( $_POST[PF_SLUG.'_advanced_meta_handling'] ) ) {
$meta_handling_check = $_POST[PF_SLUG.'_advanced_meta_handling'];
// print_r($pf_links_opt_check); die();
update_option( PF_SLUG.'_advanced_meta_handling', $meta_handling_check );
} else {
update_option( PF_SLUG.'_advanced_meta_handling', 'no' );
}

if ( class_exists( 'The_Alert_Box' ) ) {
// var_dump($_POST);
if ( empty( $_POST[ pressforward( 'library.alertbox' )->option_name() ] ) ) {
Expand Down
19 changes: 11 additions & 8 deletions Core/Admin/PFTemplater.php
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ public function form_of_an_item( $item, $c, $format = 'standard', $metadata = ar
// var_dump($item);
echo '<article class="feed-item entry nom-container ' . $archived_status_string . ' ' . get_pf_nom_class_tags( array( $metadata['submitters'], $metadata['nom_id'], $metadata['item_author'], $metadata['item_tags'], $metadata['item_id'] ) ) . ' ' . $readClass . '" id="' . $metadata['nom_id'] . '" style="' . $dependent_style . '" tabindex="' . $c . '" pf-post-id="' . $metadata['nom_id'] . '" pf-item-post-id="' . $id_for_comments . '" pf-feed-item-id="' . $metadata['item_id'] . '" pf-schema="read" pf-schema-class="article-read">';
?>
<a style="display:none;" name="modal-<?php echo $metadata['item_id']; ?>"></a>
<a style="display:none;" name="modal-<?php echo $metadata['item_id']; ?>"></a>
<?php
} else {
$id_for_comments = $item['post_id'];
Expand All @@ -438,7 +438,7 @@ public function form_of_an_item( $item, $c, $format = 'standard', $metadata = ar
$readClass = 'article-read'; }
echo '<article class="feed-item entry ' . pf_slugger( get_the_source_title( $id_for_comments ), true, false, true ) . ' ' . $itemTagClassesString . ' ' . $readClass . '" id="' . $item['item_id'] . '" tabindex="' . $c . '" pf-post-id="' . $item['post_id'] . '" pf-feed-item-id="' . $item['item_id'] . '" pf-item-post-id="' . $id_for_comments . '" style="' . $dependent_style . '" >';
?>
<a style="display:none;" name="modal-<?php echo $item['item_id']; ?>"></a>
<a style="display:none;" name="modal-<?php echo $item['item_id']; ?>"></a>
<?php
}

Expand Down Expand Up @@ -469,7 +469,7 @@ public function form_of_an_item( $item, $c, $format = 'standard', $metadata = ar

echo '</div>';
?>
<header>
<header>
<?php
echo '<h1 class="item_title"><a href="#modal-' . $item['item_id'] . '" class="item-expander schema-actor" role="button" data-toggle="modal" data-backdrop="false" pf-schema="read" pf-schema-targets="schema-read">' . self::display_a( $item['item_title'], 'title' ) . '</a></h1>';
echo '<p class="source_title">' . self::display_a( get_the_source_title( $id_for_comments ), 'source' ) . '</p>';
Expand Down Expand Up @@ -558,12 +558,12 @@ public function form_of_an_item( $item, $c, $format = 'standard', $metadata = ar
}

?>
<div style="display:none;">
<div style="display:none;">
<?php
echo '<div class="item_meta item_meta_date">Published on ' . $item['item_date'] . ' by <span class="item-authorship">' . $item['item_author'] . '</span>.</div>';
echo 'Unix timestamp for item date:<span class="sortableitemdate">' . strtotime( $item['item_date'] ) . '</span> and for added to feed date <span class="sortablerssdate">' . strtotime( $item['item_added_date'] ) . '</span>.';
?>
</div>
</div>
<?php

echo '<div class="item_excerpt" id="excerpt' . $c . '">';
Expand Down Expand Up @@ -733,7 +733,7 @@ public function form_of_actions_btns( $item, $c, $modal = false, $format = 'stan
}
?>

<div class="actions pf-btns
<div class="actions pf-btns
<?php
if ( $modal ) {
echo 'modal-btns ';
Expand Down Expand Up @@ -803,8 +803,11 @@ public function form_of_actions_btns( $item, $c, $modal = false, $format = 'stan
$draft_status = 'btn-success';
}
echo '<a href="#nominate" class="btn btn-small nom-to-draft schema-actor ' . $draft_status . '" pf-schema="draft" pf-schema-class="btn-success" form="' . $metadata['item_id'] . '" data-original-title="' . __( 'Draft', 'pf' ) . '"><img src="' . PF_URL . 'assets/images/pressforward-licon.png" /></a>';

echo '<a role="button" class="btn btn-small meta_form_modal-button" data-toggle="modal" href="#meta_form_modal_' . $item['post_id'] . '" data-post-id="' . $item['post_id'] . '" id="meta_form_modal_expander-' . $item['post_id'] . '" data-original-title="Edit Metadata"><i class="icon-meta-form"></i></a>';
$meta_handling = get_option( PF_SLUG . '_advanced_meta_handling', 'no' );
$user_level_check = current_user_can( pressforward( 'controller.users' )->pf_get_defining_capability_by_role( 'administrator' ) );
if ('yes' === $meta_handling && $user_level_check){
echo '<a role="button" class="btn btn-small meta_form_modal-button" data-toggle="modal" href="#meta_form_modal_' . $item['post_id'] . '" data-post-id="' . $item['post_id'] . '" id="meta_form_modal_expander-' . $item['post_id'] . '" data-original-title="Edit Metadata"><i class="icon-meta-form"></i></a>';
}
} else {
// var_dump(pf_get_relationship('nominate', $id_for_comments, $user_id));
if ( ( 1 == pf_get_relationship_value( 'nominate', $id_for_comments, $user_id ) ) || ( 1 == pf_get_relationship_value( 'draft', $id_for_comments, $user_id ) ) ) {
Expand Down
15 changes: 15 additions & 0 deletions parts/settings/tab-site.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,18 @@
<p>
<?php _e( 'Your WordPress site may have more than one Post Type installed, this setting will allow you to send nominations to the post type of your choice.', 'pf' ); ?>
</p>
<hr />
<p>
<?php
$meta_handling = get_option( PF_SLUG . '_advanced_meta_handling', 'no' );

?>
<select id="<?php echo PF_SLUG; ?>_advanced_meta_handling" name="<?php echo PF_SLUG; ?>_advanced_meta_handling">
<option value="yes" <?php if ( $meta_handling == 'yes' ) { echo 'selected="selected"'; }?>>Yes</option>
<option value="no" <?php if ( $meta_handling == 'no' ) { echo 'selected="selected"'; }?>>No</option>
</select>
<label class="description" for="<?php echo PF_SLUG; ?>_advanced_meta_handling"><?php echo __( 'Allow site administrators to fix errors in metadata on the Nomination level.', 'pf' ); ?></label>
</p>
<p>
<?php _e( 'Metadata can have errors or omissions. Activating this setting will allow site administrators to adjust the data at the Nomination stage. This is for advanced users only.', 'pf' ); ?>
</p>

0 comments on commit dfc251b

Please sign in to comment.