Skip to content

Commit

Permalink
Merge pull request #11 from mistergiri/master
Browse files Browse the repository at this point in the history
Members can see other members compliment page? setting - ADDED
  • Loading branch information
NomadDevs authored and NomadDevs committed Jul 20, 2015
2 parents dd709cf + 08aeb3f commit 448f045
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 21 deletions.
11 changes: 10 additions & 1 deletion bp-compliments-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,21 @@ public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
// Need to change the user ID, so if we're not on a member page, $counts variable is still calculated
$user_id = bp_is_user() ? bp_displayed_user_id() : bp_loggedin_user_id();
$counts = bp_compliments_total_counts( array( 'user_id' => $user_id ) );


$bp_compliment_can_see_others_comp_value = esc_attr( get_option('bp_compliment_can_see_others_comp'));
$bp_compliment_can_see_others_comp = $bp_compliment_can_see_others_comp_value ? $bp_compliment_can_see_others_comp_value : 'yes';
if ($bp_compliment_can_see_others_comp == 'yes') {
$show_for_displayed_user = true;
} else {
$show_for_displayed_user = false;
}

bp_core_new_nav_item( array(
'name' => sprintf( __( 'Compliments <span>%d</span>', BP_COMP_TEXTDOMAIN ), $counts['received'] ),
'slug' => $bp->compliments->compliments->slug,
'position' => $this->params['adminbar_myaccount_order'],
'screen_function' => 'bp_compliments_screen_compliments',
'show_for_displayed_user' => $show_for_displayed_user,
'default_subnav_slug' => 'compliments',
'item_css_id' => 'members-compliments'
) );
Expand Down
3 changes: 3 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
v0.0.4
Members can see other members compliment page? setting - ADDED

v0.0.3
Validation added when adding compliment, icon required - FIXED
Some strings are not translatable - FIXED
Expand Down
27 changes: 25 additions & 2 deletions includes/bp-compliments-activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,13 +140,25 @@ function compliments_register_activity_actions() {
*/
function compliments_format_activity_action_compliment_received( $action, $activity ) {
global $bp;

$receiver_link = bp_core_get_userlink( $activity->user_id );
$sender_link = bp_core_get_userlink( $activity->secondary_item_id );
$receiver_url = bp_core_get_userlink( $activity->user_id, false, true );
$compliment_url = $receiver_url . $bp->compliments->id . '/?c_id='.$activity->item_id;
$compliment_link = '<a href="'.$compliment_url.'">'.__("compliment", BP_COMP_TEXTDOMAIN).'</a>';

$action = sprintf( __( '%1$s has received a %2$s from %3$s', BP_COMP_TEXTDOMAIN ), $receiver_link, $compliment_link, $sender_link );
$bp_compliment_can_see_others_comp_value = esc_attr( get_option('bp_compliment_can_see_others_comp'));
$bp_compliment_can_see_others_comp = $bp_compliment_can_see_others_comp_value ? $bp_compliment_can_see_others_comp_value : 'yes';

if ($bp->loggedin_user->id == $bp->displayed_user->id) {
$bp_compliment_can_see_others_comp = 'yes';
}

if ($bp_compliment_can_see_others_comp == 'yes') {
$action = sprintf( __( '%1$s has received a %2$s from %3$s', BP_COMP_TEXTDOMAIN ), $receiver_link, $compliment_link, $sender_link );
} else {
$action = sprintf( __( '%1$s has received a compliment from %2$s', BP_COMP_TEXTDOMAIN ), $receiver_link, $sender_link );
}


/**
Expand Down Expand Up @@ -179,7 +191,18 @@ function compliments_format_activity_action_compliment_sent( $action, $activity
$compliment_url = $receiver_url . $bp->compliments->id . '/?c_id='.$activity->item_id;
$compliment_link = '<a href="'.$compliment_url.'">'.__("compliment", BP_COMP_TEXTDOMAIN).'</a>';

$action = sprintf( __( '%1$s has sent a %2$s to %3$s', BP_COMP_TEXTDOMAIN ), $sender_link, $compliment_link, $receiver_link );
$bp_compliment_can_see_others_comp_value = esc_attr( get_option('bp_compliment_can_see_others_comp'));
$bp_compliment_can_see_others_comp = $bp_compliment_can_see_others_comp_value ? $bp_compliment_can_see_others_comp_value : 'yes';

if ($bp->loggedin_user->id == $bp->displayed_user->id) {
$bp_compliment_can_see_others_comp = 'yes';
}

if ($bp_compliment_can_see_others_comp == 'yes') {
$action = sprintf( __( '%1$s has sent a %2$s to %3$s', BP_COMP_TEXTDOMAIN ), $sender_link, $compliment_link, $receiver_link );
} else {
$action = sprintf( __( '%1$s has sent a compliment to %2$s', BP_COMP_TEXTDOMAIN ), $sender_link, $receiver_link );
}

/**
* Filters the 'compliment_sent' activity action format.
Expand Down
15 changes: 15 additions & 0 deletions includes/bp-compliments-taxonomies.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ function compliment_remove_parent_dropdown()

add_action( 'admin_init', 'bp_compliments_register_settings' );
function bp_compliments_register_settings() {
register_setting( 'bp-compliment-settings', 'bp_compliment_can_see_others_comp' );
register_setting( 'bp-compliment-settings', 'bp_compliment_can_delete' );
register_setting( 'bp-compliment-settings', 'bp_comp_per_page' );
register_setting( 'bp-compliment-settings', 'bp_comp_custom_css' );
Expand All @@ -249,6 +250,10 @@ function bp_compliments_settings_page() {
<form method="post" action="options.php">
<?php settings_fields( 'bp-compliment-settings' ); ?>
<?php do_settings_sections( 'bp-compliment-settings' );

$bp_compliment_can_see_others_comp_value = esc_attr( get_option('bp_compliment_can_see_others_comp'));
$bp_compliment_can_see_others_comp = $bp_compliment_can_see_others_comp_value ? $bp_compliment_can_see_others_comp_value : 'yes';

$bp_compliment_can_delete_value = esc_attr( get_option('bp_compliment_can_delete'));
$bp_compliment_can_delete = $bp_compliment_can_delete_value ? $bp_compliment_can_delete_value : 'yes';

Expand All @@ -259,13 +264,23 @@ function bp_compliments_settings_page() {
$comp_custom_css = $comp_custom_css_value ? $comp_custom_css_value : '';
?>
<table class="widefat fixed" style="padding:10px;margin-top: 10px;">
<tr valign="top">
<th scope="row"><?php echo __( 'Members can see other members compliment page?', BP_COMP_TEXTDOMAIN ); ?></th>
<td>
<select id="bp_compliment_can_see_others_comp" name="bp_compliment_can_see_others_comp">
<option value="yes" <?php selected( $bp_compliment_can_see_others_comp, 'yes' ); ?>><?php echo __( 'Yes', BP_COMP_TEXTDOMAIN ); ?></option>
<option value="no" <?php selected( $bp_compliment_can_see_others_comp, 'no' ); ?>><?php echo __( 'No', BP_COMP_TEXTDOMAIN ); ?></option>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo __( 'Members can delete compliments received?', BP_COMP_TEXTDOMAIN ); ?></th>
<td>
<select id="bp_compliment_can_delete" name="bp_compliment_can_delete">
<option value="yes" <?php selected( $bp_compliment_can_delete, 'yes' ); ?>><?php echo __( 'Yes', BP_COMP_TEXTDOMAIN ); ?></option>
<option value="no" <?php selected( $bp_compliment_can_delete, 'no' ); ?>><?php echo __( 'No', BP_COMP_TEXTDOMAIN ); ?></option>
</select>
</td>
</tr>
<tr valign="top">
<th scope="row"><?php echo __( 'Number of Compliments to display per page?', BP_COMP_TEXTDOMAIN ); ?></th>
Expand Down
24 changes: 23 additions & 1 deletion includes/templates/buddypress/members/single/compliments.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@
$comp_per_page_value = esc_attr( get_option('bp_comp_per_page'));
$items_per_page = $comp_per_page_value ? (int) $comp_per_page_value : 5;

$bp_compliment_can_see_others_comp_value = esc_attr( get_option('bp_compliment_can_see_others_comp'));
$bp_compliment_can_see_others_comp = $bp_compliment_can_see_others_comp_value ? $bp_compliment_can_see_others_comp_value : 'yes';
if (bp_displayed_user_id() == bp_loggedin_user_id()) {
$bp_compliment_can_see_others_comp = 'yes';
}

$page = isset($_GET['cpage']) ? abs((int)$_GET['cpage']) : 1;
$offset = ($page * $items_per_page) - $items_per_page;
$args = array(
Expand All @@ -38,7 +44,17 @@
$start = $offset ? $offset : 1;
$end = $offset + $items_per_page;
$end = ($end > $total) ? $total : $end;
if ($compliments) {

if (isset($_GET['c_id'])) {
foreach ($compliments as $comp) {
$author_id = $comp->sender_id;
if ($author_id == bp_loggedin_user_id()) {
$bp_compliment_can_see_others_comp = 'yes';
}
}
}

if ($compliments && ($bp_compliment_can_see_others_comp == 'yes')) {
?>
<div class="comp-user-content">
<ul class="comp-user-ul">
Expand Down Expand Up @@ -115,6 +131,12 @@ class='preview-upload'/>
</div>
</div>
<?php }
} elseif($bp_compliment_can_see_others_comp == 'no') {
?>
<div id="message" class="bp-no-compliments info">
<p><?php echo __('You don\'t have permission to access this page.', BP_COMP_TEXTDOMAIN); ?></p>
</div>
<?php
} else {
if (bp_displayed_user_id() == bp_loggedin_user_id()) {
?>
Expand Down
Binary file modified languages/bp-compliments-en_US.mo
Binary file not shown.
58 changes: 41 additions & 17 deletions languages/bp-compliments-en_US.po
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: BuddyPress Compliments 0.0.2\n"
"POT-Creation-Date: 2015-07-14 13:48+0530\n"
"PO-Revision-Date: 2015-07-14 13:49+0530\n"
"POT-Creation-Date: 2015-07-20 14:19+0530\n"
"PO-Revision-Date: 2015-07-20 14:20+0530\n"
"Last-Translator: \n"
"Language-Team: GeoDirectory <[email protected]>\n"
"Language: en_US\n"
Expand All @@ -24,7 +24,7 @@ msgstr ""
msgid "Compliments"
msgstr ""

#: bp-compliments-core.php:171
#: bp-compliments-core.php:179
#, php-format
msgid "Compliments <span>%d</span>"
msgstr ""
Expand Down Expand Up @@ -53,21 +53,31 @@ msgstr ""
msgid "Compliment Sent"
msgstr ""

#: includes/bp-compliments-activity.php:147
#: includes/bp-compliments-activity.php:180
#: includes/bp-compliments-activity.php:148
#: includes/bp-compliments-activity.php:192
msgid "compliment"
msgstr ""

#: includes/bp-compliments-activity.php:149
#: includes/bp-compliments-activity.php:158
#, php-format
msgid "%1$s has received a %2$s from %3$s"
msgstr ""

#: includes/bp-compliments-activity.php:182
#: includes/bp-compliments-activity.php:160
#, php-format
msgid "%1$s has received a compliment from %2$s"
msgstr ""

#: includes/bp-compliments-activity.php:202
#, php-format
msgid "%1$s has sent a %2$s to %3$s"
msgstr ""

#: includes/bp-compliments-activity.php:204
#, php-format
msgid "%1$s has sent a compliment to %2$s"
msgstr ""

#: includes/bp-compliments-forms.php:23
msgid "Choose Your Compliment Type:"
msgstr ""
Expand Down Expand Up @@ -105,12 +115,14 @@ msgid ""
msgstr ""

#: includes/bp-compliments-notifications.php:278
#: includes/bp-compliments-taxonomies.php:262
#: includes/bp-compliments-taxonomies.php:271
#: includes/bp-compliments-taxonomies.php:280
msgid "Yes"
msgstr ""

#: includes/bp-compliments-notifications.php:279
#: includes/bp-compliments-taxonomies.php:263
#: includes/bp-compliments-taxonomies.php:272
#: includes/bp-compliments-taxonomies.php:281
msgid "No"
msgstr ""

Expand Down Expand Up @@ -198,43 +210,55 @@ msgstr ""
msgid "Icon"
msgstr ""

#: includes/bp-compliments-taxonomies.php:246
#: includes/bp-compliments-taxonomies.php:248
msgid "BuddyPress Compliments - Settings"
msgstr ""

#: includes/bp-compliments-taxonomies.php:259
#: includes/bp-compliments-taxonomies.php:268
msgid "Members can see other members compliment page?"
msgstr ""

#: includes/bp-compliments-taxonomies.php:277
msgid "Members can delete compliments received?"
msgstr ""

#: includes/bp-compliments-taxonomies.php:267
#: includes/bp-compliments-taxonomies.php:286
msgid "Number of Compliments to display per page?"
msgstr ""

#: includes/bp-compliments-taxonomies.php:290
msgid "Custom CSS styles"
msgstr ""

#: includes/bp-compliments-templatetags.php:83
msgid "Send Compliment"
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:70
#: includes/templates/buddypress/members/single/compliments.php:86
msgid "Delete"
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:102
#: includes/templates/buddypress/members/single/compliments.php:118
#, php-format
msgid "1 of 1"
msgid_plural "%1$s to %2$s of %3$s"
msgstr[0] ""
msgstr[1] ""

#: includes/templates/buddypress/members/single/compliments.php:105
#: includes/templates/buddypress/members/single/compliments.php:121
msgid "Go to Page"
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:122
#: includes/templates/buddypress/members/single/compliments.php:137
msgid "You don't have permission to access this page."
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:144
msgid ""
"Aw, you have no compliments yet. To get some try sending compliments to "
"others."
msgstr ""

#: includes/templates/buddypress/members/single/compliments.php:128
#: includes/templates/buddypress/members/single/compliments.php:150
msgid "Sorry, no compliments just yet."
msgstr ""

0 comments on commit 448f045

Please sign in to comment.