Skip to content

Commit

Permalink
release version 2.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
techjewel committed May 7, 2021
1 parent 9dc94e8 commit c8d4607
Show file tree
Hide file tree
Showing 144 changed files with 16,160 additions and 2,676 deletions.
Binary file modified .DS_Store
Binary file not shown.
12 changes: 10 additions & 2 deletions app/Api/Classes/Contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,23 @@ public function createOrUpdate($data, $forceUpdate = false, $deleteOtherValues =
return $this->instance->updateOrCreate($data, $forceUpdate, $deleteOtherValues, $sync);
}

public function getCurrentContact()
public function getCurrentContact($cached = true)
{
static $currentContact;

if($cached && $currentContact) {
return $currentContact;
}

$userId = get_current_user_id();
if(!$userId) {
return false;
}

$user = get_user_by('ID', $userId);
return $this->instance->where('user_id', $user->ID)->orWhere('email', $user->user_email)->first();
$currentContact = $this->instance->where('user_id', $user->ID)->orWhere('email', $user->user_email)->first();

return $currentContact;
}

public function getInstance()
Expand Down
82 changes: 59 additions & 23 deletions app/Functions/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,29 +347,29 @@ function fluentcrm_subscriber_editable_statuses()
function fluentcrm_contact_types()
{
return apply_filters('fluentcrm_contact_types', [
'lead',
'customer'
'lead' => __('Lead', 'fluent-crm'),
'customer' => __('Customer', 'fluent-crm')
]);
}

function fluentcrm_activity_types()
{
return apply_filters('fluentcrm_contact_activity_types', [
'note' => 'Note',
'call' => 'Call',
'email' => 'Email',
'meeting' => 'Meeting',
'quote_sent' => 'Quote: Sent',
'quote_accepted' => 'Quote: Accepted',
'quote_refused' => 'Quote: Refused',
'invoice_sent' => 'Invoice: Sent',
'invoice_part_paid' => 'Invoice: Part Paid',
'invoice_paid' => 'Invoice: Paid',
'invoice_refunded' => 'Invoice: Refunded',
'transaction' => 'Transaction',
'feedback' => 'Feedback',
'tweet' => 'Tweet',
'facebook_post' => 'Facebook Post'
'note' => __('Note', 'fluent-crm'),
'call' => __('Call', 'fluent-crm'),
'email' => __('Email', 'fluent-crm'),
'meeting' => __('Meeting', 'fluent-crm'),
'quote_sent' => __('Quote: Sent', 'fluent-crm'),
'quote_accepted' => __('Quote: Accepted', 'fluent-crm'),
'quote_refused' => __('Quote: Refused', 'fluent-crm'),
'invoice_sent' => __('Invoice: Sent', 'fluent-crm'),
'invoice_part_paid' => __('Invoice: Part Paid', 'fluent-crm'),
'invoice_paid' => __('Invoice: Paid', 'fluent-crm'),
'invoice_refunded' => __('Invoice: Refunded', 'fluent-crm'),
'transaction' => __('Transaction', 'fluent-crm'),
'feedback' => __('Feedback', 'fluent-crm'),
'tweet' => __('Tweet', 'fluent-crm'),
'facebook_post' => __('Facebook Post', 'fluent-crm')
]);
}

Expand Down Expand Up @@ -495,6 +495,9 @@ function fluentcrm_contact_removed_from_lists($detachedListIds, Subscriber $subs
);
}

/*
* @return object \FluentCrm\App\Models\Subscriber
*/
function fluentcrm_get_current_contact()
{
$subscriber = false;
Expand All @@ -507,10 +510,17 @@ function fluentcrm_get_current_contact()
$subscriber = Subscriber::where('email', $user->user_email)->first();
}
} else {
$subscriberId = intval(FluentCrm\Includes\Helpers\Arr::get($_COOKIE, 'fc_sid'));
if ($subscriberId) {
$subscriber = Subscriber::where('id', $subscriberId)->first();
$fcSubscriberHash = FluentCrm\Includes\Helpers\Arr::get($_COOKIE, 'fc_s_hash');
if($fcSubscriberHash) {
$subscriber = Subscriber::where('hash', $fcSubscriberHash)->first();
} else {
// @todo: We will remove this after february
$subscriberId = intval(FluentCrm\Includes\Helpers\Arr::get($_COOKIE, 'fc_sid'));
if ($subscriberId) {
$subscriber = Subscriber::where('id', $subscriberId)->first();
}
}

}

return $subscriber;
Expand All @@ -522,8 +532,8 @@ function fluentcrm_get_crm_profile_html($userIdOrEmail, $checkPermission = true,
return '';
}
if ($checkPermission) {
$contactPermission = apply_filters('fluentcrm_permission', 'manage_options', 'contacts', 'admin_menu');
if (!current_user_can($contactPermission)) {
$contactPermission = \FluentCrm\App\Services\PermissionManager::currentUserCan('fcrm_read_contacts');
if (!$contactPermission) {
return '';
}
}
Expand Down Expand Up @@ -657,4 +667,30 @@ function fluentcrm_get_crm_profile_html($userIdOrEmail, $checkPermission = true,
<?php endif; ?>
<?php
return ob_get_clean();
}
}


function fluentcrm_maybe_disable_fsmtp_log($status, $settings)
{
if(!$status) {
return $status;
}

if(isset($settings['disable_fluentcrm_logs']) && $settings['disable_fluentcrm_logs'] == 'yes') {
return false;
}

return $status;
}


function fluentcrm_get_custom_contact_fields()
{
static $fields;
if($fields) {
return $fields;
}
$fields = fluentcrm_get_option('contact_custom_fields', []);

return $fields;
}
17 changes: 13 additions & 4 deletions app/Hooks/Handlers/AdminBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
namespace FluentCrm\App\Hooks\Handlers;

use FluentCrm\App\Models\Subscriber;
use FluentCrm\App\Services\PermissionManager;
use FluentCrm\App\Services\Stats;
use FluentCrm\Includes\Helpers\Arr;

class AdminBar
{
public function init()
{
$contactPermission = apply_filters('fluentcrm_permission', 'manage_options', 'contacts', 'admin_menu');
$contactPermission = PermissionManager::currentUserCan('fcrm_read_contacts');

if (!is_admin() || !$contactPermission || !current_user_can($contactPermission)) {
if ( !is_admin() || !$contactPermission ) {
return;
}

Expand Down Expand Up @@ -59,13 +60,21 @@ public function addGlobalSearch($adminBar)
'rest' => $this->getRestInfo(),
'links' => (new Stats)->getQuickLinks(),
'subscriber_base' => $urlBase . 'subscribers/',
'edit_user_vars' => $editingUserVars
'edit_user_vars' => $editingUserVars,
'trans' => [
'Search Contacts' => __('Search Contacts', 'fluent-crm'),
'Type and press enter' => __('Type and press enter', 'fluent-crm'),
'Type to search contacts' => __('Type to search contacts', 'fluent-crm'),
'Quick Links' => __('Quick Links', 'fluent-crm'),
'Sorry no contact found' => __('Sorry no contact found', 'fluent-crm'),
'Load More' => __('Load More', 'fluent-crm')
]
]);

$args = [
'parent' => 'top-secondary',
'id' => 'fc_global_search',
'title' => 'Search Contacts',
'title' => __('Search Contacts', 'fluent-crm'),
'href' => '#',
'meta' => false
];
Expand Down
Loading

0 comments on commit c8d4607

Please sign in to comment.