Skip to content

Commit

Permalink
Organisation details
Browse files Browse the repository at this point in the history
Added org details on Opportunity detail page, with setup option to control level of detail
  • Loading branch information
smadds committed Feb 28, 2018
1 parent 08a5d77 commit 6b2e6c8
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 14 deletions.
27 changes: 27 additions & 0 deletions includes/volplus_Functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
<?php

// Display Organisation details

function getOrgDetails($id) {
$organisation = wp_remote_get(API_URL . 'organisations/'.$id, array('headers' => array('Authorization' => 'Bearer '.API_KEY)));
$response_code = wp_remote_retrieve_response_code($organisation);
if($response_code == 200) {
$organisation = json_decode($organisation['body'], true);
return $organisation;
} else {
wp_redirect("/404");
exit;
}
}


// get volunteer details given ID - WITH CORRECTIONS
function get_volunteer_details($id) {
$endpoint = 'volunteers/' . $id;
Expand Down Expand Up @@ -695,6 +710,18 @@ function ajax_addvolunteer(){
die();
}

//AJAX GET PAGE
add_action('wp_ajax_nopriv_volplus_get_legal', 'volplus_get_legal');
add_action('wp_ajax_volplus_get_legal', 'volplus_get_legal');
function volplus_get_page(){
if(null !==(get_option('volplus_compliancepage'))) {
$output = apply_filters('the_content', get_post_field('post_content', get_option('volplus_compliancepage')));
echo json_encode($output);
die;
}
}


//convert dob to age band
function dobToAgeBand($age){
$yourage = (int) DateTime::createFromFormat('Y-m-d', $age)
Expand Down
2 changes: 1 addition & 1 deletion includes/volplus_Opportunities_List_Shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function volplus_list_opportunities_func($atts = [], $content = null, $tag = '')
$opportunities = wp_remote_get(API_URL . 'opportunities?'.$_SERVER['QUERY_STRING'], array('headers' => array('Authorization' => 'Bearer '.API_KEY)));
$response_code = wp_remote_retrieve_response_code($opportunities);
$opportunities = json_decode($opportunities['body'], true);
$location = ["","No Location","Working from home","Specific Address","Specific Address","Multiple Specific Addresses","Countrywide","Regional"];
$location = ["","No Location","Working from home","Specific Address","Specific Address","Multiple Specific Addresses","County-wide","Regional"];

// split query string to array
parse_str($_SERVER['QUERY_STRING'],$querystring);
Expand Down
3 changes: 2 additions & 1 deletion includes/volplus_Opportunities_List_Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function widget( $args, $instance ) {

$response_code = wp_remote_retrieve_response_code($opportunities);
$opportunities = json_decode($opportunities['body'], true);
$location = ["","No Location","Working from home","Organisational Address","Specific Address","Multiple Specific Addresses","Countrywide","Regional"];
$location = ["","No Location","Working from home","Organisational Address","Specific Address","Multiple Specific Addresses","County-
wide","Regional"];

//get_header();

Expand Down
61 changes: 56 additions & 5 deletions includes/volplus_Opportunity_Detail_Shortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function volplus_opportunity_detail_func($atts) {
parse_str($_SERVER['QUERY_STRING'],$querystring);
$opp = $querystring['opp-id'];
setcookie('volplus_opp_id', $opp, 0, COOKIEPATH, COOKIE_DOMAIN );
//Fetch opportunity details
$opportunity = wp_remote_get(API_URL . 'opportunities/'.$opp, array('headers' => array('Authorization' => 'Bearer '.API_KEY)));
$response_code = wp_remote_retrieve_response_code($opportunity);

Expand All @@ -18,9 +19,12 @@ function volplus_opportunity_detail_func($atts) {
wp_redirect("/404");
exit;
}

$organisation = getOrgDetails($opportunity['organisation']['id']);

?>
<div id="opportunity_detail">

<div id='opportunity_detail' class='volplus-col-12'>

<h1><?php echo remove_brackets($opportunity['opportunity']); ?></h1>

Expand Down Expand Up @@ -76,7 +80,52 @@ function volplus_opportunity_detail_func($atts) {

<?php echo $opportunity['skills']; ?>

<p>Posted by <?php echo $opportunity['organisation']['organisation']; ?></p>
<div id=orgDetails class="volplus-col-12">
<h2>Organisation</h2>
<div class="volplus-col-6">
<strong><?php echo remove_brackets($organisation['organisation'])?><br/></strong>
<?php
if(null !== $organisation['address_line_1']) echo stripcslashes(html_entity_decode($organisation['address_line_1'])) . "<br/>";
if(null !== $organisation['address_line_2']) echo stripcslashes(html_entity_decode($organisation['address_line_2'])) . "<br/>";
if(null !== $organisation['address_line_3']) echo stripcslashes(html_entity_decode($organisation['address_line_3'])) . "<br/>";
if(null !== $organisation['town']) echo stripcslashes(html_entity_decode($organisation['town']));
if(null !== $organisation['county']) echo ", " . stripcslashes(html_entity_decode($organisation['county'])) . "<br/>";
if(null !== $organisation['postcode']) echo stripcslashes(html_entity_decode($organisation['postcode']));
?>
</div>
<div class="volplus-col-6">
<?php
$orgStatus = array(
'',
'Registered Charity',
'Charitable Incorporated Organisations (CIO)',
'Unregistered Community Group',
'Community Interest Company (CIC)',
'Company Limited by Guarantee',
'Statutory Organisation',
'Private Business',
'Other'
);
if(null !== $organisation['status']) echo "Org type: <strong>" . $orgStatus[$organisation['status']] . "</strong><br/>";
if(null !== $organisation['website']) echo "Website: <a target=_blank href='" . stripcslashes(html_entity_decode($organisation['website'])) . "'>". stripcslashes(html_entity_decode($organisation['website'])) . "</a><br/>";
if(get_option('volplus_hideorgdirect', 'on') !== 'on') {
if(null !== $organisation['telephone_number']) echo "Tel: <a target=_blank href='tel:" . stripcslashes(html_entity_decode($organisation['telephone_number'])) . "'>" . stripcslashes(html_entity_decode($organisation['telephone_number'])) . "</a><br/>";
if(null !== $organisation['email_address']) echo "Email: <a target=_blank href='mailto:" . stripcslashes(html_entity_decode($organisation['email_address'])) . "'>" . stripcslashes(html_entity_decode($organisation['email_address'])) . "</a><br/>";
if(null !== $organisation['additional_email_address']) echo "2nd email: <a target=_blank href='mailto:" . stripcslashes(html_entity_decode($organisation['additional_email_address'])) . "'>" . stripcslashes(html_entity_decode($organisation['additional_email_address'])) . "</a><br/>";
}
if(null !== $organisation['charity_registration_number']) echo "Charity number: " . stripcslashes(html_entity_decode($organisation['charity_registration_number'])) . "<br/>";
if(null !== $organisation['company_registration_number']) echo "Company number: " . stripcslashes(html_entity_decode($organisation['company_registration_number'])) . "<br/>";
?>
</div>
<?php if(null !== $organisation['about']){
echo "<div class='volplus-col-12'><strong>Organisation Information</strong><br/>";
echo stripslashes( html_entity_decode($organisation['about'])) . "</div>";
} ?>
<?php if(null !== $organisation['mission_statement']){
echo "<div class='volplus-col-12'><strong>Mission Statement</strong><br/>";
echo stripslashes( html_entity_decode($organisation['mission_statement'])) . "</div>";
} ?>
</div>

<?php if($opportunity['interests']) { ?>

Expand Down Expand Up @@ -147,9 +196,9 @@ function volplus_opportunity_detail_func($atts) {
case 3: case 4: case 5:
if($opportunity['location']['address']) {
if(count($opportunity['location']['address']) == 1) {
echo "<h2>Address</h2>";
echo "<h2>Opportunity Address</h2>";
} else {
echo "<h2>Addresses</h2>";
echo "<h2>Opportunity Addresses</h2>";
}
}
foreach($opportunity['location']['address'] as $address) {
Expand Down Expand Up @@ -319,7 +368,9 @@ function initMap() {
<?php } ?>
<?php } ?>
</div>
<!-- <?php var_dump_safe($opportunity);?>-->

<?php var_dump_safe($organisation);?><!-- -->
<?php var_dump_safe($opportunity);?><!-- -->

<?php wp_nonce_field( 'ajax-enquiry-nonce', 'security' ); ?>
</div>
Expand Down
20 changes: 14 additions & 6 deletions includes/volplus_Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function volplus_plugin_settings_page() {
</tr>
<th scope="row">Plugin License Code</th>
<td><input type="password" name="volplus_license_code" size="40" value="<?php echo esc_attr( get_option('volplus_license_code') ); ?>" />
<span class="description">If you have not received your code contact <a href:"mailto:[email protected]">[email protected]</a></span></td>
<span class="description">If you have not received your code email <a href:"mailto:[email protected]">[email protected]</a> with your Domain name as shown above</span></td>
<tr valign="top">
<th scope="row"><h3>Google Maps</h3></th>
</tr>
Expand Down Expand Up @@ -127,24 +127,31 @@ function volplus_plugin_settings_page() {
<td><input type="checkbox" name="volplus_hidebrackets" <?php if(get_option('volplus_hidebrackets') == 'on') echo 'checked'; ?> />
<span class="description">Strips out text within brackets in Opportunity titles & Organisation names</span></td>
</tr>
<tr valign="top">
<th scope="row">Hide Org Direct Contact fields</th>
<td><input type="checkbox" name="volplus_hideorgdirect" <?php if(get_option('volplus_hideorgdirect', 'on') == 'on') echo 'checked'; ?> />
<span class="description">Hides telephone & emails from Organisation details</span></td>
</tr>
<tr valign="top">
<th scope="row">Hide Quality Control item details </th>
<td><input type="checkbox" name="volplus_hideqcdetails" <?php if(get_option('volplus_hideqcdetails', null) == 'on') echo 'checked'; ?> /></td>
<td><input type="checkbox" name="volplus_hideqcdetails" <?php if(get_option('volplus_hideqcdetails', null) == 'on') echo 'checked'; ?> />
<span class="description">Hides 2nd level of details</span></td>
</tr>
<tr valign="top">
<th scope="row">Volunteer login timeout (hours)</th>
<td><input type="number" name="volplus_voltimeout" min="1" max="72" value="<?php echo esc_attr(get_option('volplus_voltimeout', 1)); ?>" /></td>
<th scope="row">Volunteer login timeout</th>
<td><input type="number" name="volplus_voltimeout" min="1" max="72" value="<?php echo esc_attr(get_option('volplus_voltimeout', 1)); ?>" />
<span class="description">Hour(s). Accepts decimal (e.g. 0.5 for 30mins)</span></td>
</tr>
<tr valign="top">
<th scope="row">T&C page (checkbox on registration if selected)</th>
<th scope="row">T&C page</th>
<td><?php
$args= array(
'show_option_none'=>'(Not Used)',
'selected'=> get_option('volplus_compliancepage', null),
'name'=> 'volplus_compliancepage'
);
wp_dropdown_pages($args);?>
</td>
<span class="description"> Shows a mandatory check-box on registration if a page is selected</span></td>
</tr>
</table>
<?php submit_button();?>
Expand Down Expand Up @@ -189,6 +196,7 @@ function volplus_plugin_settings() {
register_setting( 'volplus-plugin-settings-group', 'volplus_agebandmsg' );
register_setting( 'volplus-plugin-settings-group', 'volplus_compliancepage' );
register_setting( 'volplus-plugin-settings-group', 'volplus_hidebrackets' );
register_setting( 'volplus-plugin-settings-group', 'volplus_hideorgdirect' );
register_setting( 'volplus-plugin-settings-group', 'volplus_hideqcdetails' );
register_setting( 'volplus-plugin-settings-group', 'volplus_voltimeout' );
}
Expand Down
2 changes: 1 addition & 1 deletion wp-volunteer-plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: WP Volunteer Plus
* Plugin URI: https://maddox.co.uk/volunteer-plus
* Description: A selection of tools for interacting with the Volunteer Plus Database
* Version: 1.0.6
* Version: 1.0.7
* Author: Simon Maddox
* Author URI: https://maddox.co.uk
*/
Expand Down

0 comments on commit 6b2e6c8

Please sign in to comment.