*/
require_once AWP_LIB_DIR . '/Plugin.php';
require_once AWP_INC_DIR . '/apptivo_services/Testimonial.php';
/**
* Class AWP_Testimonials
*/
class AWP_Testimonials extends AWP_Base {
var $_plugin_activated = false;
/**
* PHP5 constructor
*/
function __construct() {
$settings = array();
$this->_plugin_activated = false;
$settings = get_option("awp_plugins");
if (get_option("awp_plugins") !== "false") {
if ($settings["testimonials"])
$this->_plugin_activated = true;
}
}
/**
* Returns plugin instance
*
* @return AIP_Plugin_BrowserCache
*/
function &instance() {
static $instances = array();
if (!isset($instances[0])) {
$class = __CLASS__;
$instances[0] = new $class();
}
return $instances[0];
}
/**
* Runs plugin
*/
function run() {
if ($this->_plugin_activated) {
add_action('widgets_init', array(&$this, 'register_widget'));
add_shortcode('apptivo_testimonials_fullview', array(&$this, 'show_testimonials_fullview'));
add_shortcode('apptivo_testimonials_inline', array(&$this, 'show_testimonials_inline'));
add_shortcode('apptivo_testimonials_form', array(&$this, 'testimonialform'));
}
add_action('the_posts', array(&$this, 'check_for_shortcode'));
}
function check_for_shortcode($posts) {
$testimonial_fullView = awp_check_for_shortcode($posts, '[apptivo_testimonials_fullview');
$testimonial_inlineView = awp_check_for_shortcode($posts, '[apptivo_testimonials_inline');
$testimonial_form = awp_check_for_shortcode($posts, '[apptivo_testimonials_form');
if ($testimonial_inlineView) {
// load styles and scripts
$this->loadscripts();
} else if ($testimonial_form) {
$this->testscripts();
}
return $posts;
}
/**
* Load the JS files
*/
function loadscripts()
{
wp_enqueue_script('jquery_cycleslider.js',AWP_PLUGIN_BASEURL. '/assets/js/jquery.cycle.all.latest.js',array('jquery'));
}
function testscripts() {
wp_enqueue_script('jquery_validation', AWP_PLUGIN_BASEURL . '/assets/js/validator-min.js', array('jquery'));
}
/* Form Setting */
function get_master_fields()
{
$fields = array(
array('fieldid' => 'name', 'fieldname' => 'Name', 'defaulttext' => 'First Name', 'showorder' => '1', 'validation' => 'text', 'fieldtype' => 'text'),
array('fieldid' => 'email', 'fieldname' => 'Email', 'defaulttext' => 'Email', 'showorder' => '2', 'validation' => 'email', 'fieldtype' => 'text'),
array('fieldid' => 'captcha', 'fieldname' => 'Captcha', 'defaulttext' => 'Captcha', 'showorder' => '8', 'validation' => 'text', 'fieldtype' => 'captcha'),
// array('fieldid' => 'jobtitle', 'fieldname' => 'Job Title', 'defaulttext' => 'Job Title', 'showorder' => '3', 'validation' => 'text', 'fieldtype' => 'text'),
//array('fieldid' => 'company', 'fieldname' => 'Company', 'defaulttext' => 'Company', 'showorder' => '4', 'validation' => 'text', 'fieldtype' => 'text'),
//array('fieldid' => 'website', 'fieldname' => 'Website', 'defaulttext' => 'Website', 'showorder' => '5', 'validation' => 'text', 'fieldtype' => 'text'),
//array('fieldid' => 'upload', 'fieldname' => 'Upload File', 'defaulttext' => 'Upload File', 'showorder' => '6', 'validation' => 'textarea', 'fieldtype' => 'upload'),
//array('fieldid' => 'imageurl', 'fieldname' => 'Image Url', 'defaulttext' => 'Enter Image Url', 'showorder' => '6', 'validation' => 'text', 'fieldtype' => 'text'),
array('fieldid' => 'comments', 'fieldname' => 'Testimonial', 'defaulttext' => 'Testimonial', 'showorder' => '7', 'validation' => 'textarea', 'fieldtype' => 'textarea')
/* array('fieldid' => 'customfield1','fieldname' => 'Custom Field 1','defaulttext' => 'Custom Field1','showorder' => '18','validation' => '','fieldtype' => 'select'),
array('fieldid' => 'customfield2','fieldname' => 'Custom Field 2','defaulttext' => 'Custom Field2','showorder' => '19','validation' => '','fieldtype' => 'select'),
array('fieldid' => 'customfield3','fieldname' => 'Custom Field 3','defaulttext' => 'Custom Field3','showorder' => '20','validation' => '','fieldtype' => 'select'),
array('fieldid' => 'customfield4','fieldname' => 'Custom Field 4','defaulttext' => 'Custom Field4','showorder' => '21','validation' => '','fieldtype' => 'radio'),
array('fieldid' => 'customfield5','fieldname' => 'Custom Field 5','defaulttext' => 'Custom Field5','showorder' => '22','validation' => '','fieldtype' => 'checkbox') */
);
//For Additional custom fields.
$addtional_custom = get_option('awp_addtional_custom_testimonialform');
if (!empty($addtional_custom)):
$fields = array_merge($fields, $addtional_custom);
endif;
return $fields;
}
/**
* Retrieve list of validations supported by Apptivo hrjobs Form
*
*/
function get_master_validations(){
$validations = array(
array('validationLabel' => 'None','validation' => 'none'),
array('validationLabel' => 'Email ID','validation' => 'email'),
array('validationLabel' => 'Number','validation' => 'number')
);
return $validations;
}
/**
*
* * Retrieve list of Field Types supported by Apptivo hrjobs Form
*/
function get_master_fieldtypes(){
$fieldtypes = array(
array('fieldtypeLabel' => 'Checkbox','fieldtype' => 'checkbox'),
array('fieldtypeLabel' => 'Radio Option','fieldtype' => 'radio'),
array('fieldtypeLabel' => 'Select','fieldtype' => 'select'),
array('fieldtypeLabel' => 'Textbox','fieldtype' => 'text'),
array('fieldtypeLabel' => 'Textarea','fieldtype' => 'textarea')
);
return $fieldtypes;
}
function get_master_fieldtypes_testimonial(){
$fieldtypes = array(
array('fieldtypeLabel' => 'Checkbox','fieldtype' => 'checkbox'),
array('fieldtypeLabel' => 'Select','fieldtype' => 'select')
);
return $fieldtypes;
}
/**
* return array of plugin templates available with Template name and template file name
*/
function get_apptivo_template_data( $apptivo_template_file,$template_filename)
{
$test = array();
$default_headers = array(
'Apptivo Template Name' => 'Apptivo Template Name',
'Version' => 'Version',
'Description' => 'Description',
'Author' => 'Author',
);
$plugin_data = get_file_data( $apptivo_template_file, $default_headers, '' );
if(strlen(trim($plugin_data['Apptivo Template Name'])) != 0 )
{
$test[$plugin_data['Apptivo Template Name']] = $template_filename;
}
}
function createformfield_array($fieldid,$showtext,$required,$type,$validation,$options,$displayorder){
$displayorder = (trim($displayorder)=="")?0:trim($displayorder);
$options = (is_array($options))?$options:stripslashes(str_replace( array('"'), '', strip_tags($options)));
if( trim($type) != 'text' && trim($type) != 'textarea')
{
$pos = strpos(trim($fieldid), 'customfield');
if( $pos !== false )
{
if( !is_array($options) && trim($options) == '')
{
return '';
}
}
}
$testimonialformfield= array(
'fieldid'=>$fieldid,
'showtext' => stripslashes(str_replace( array('"'), '', strip_tags($showtext))),
'required' => $required,
'type' => $type,
'validation' => $validation,
'options' => $options,
'order' => $displayorder
);
return $testimonialformfield;
}
/**
* Get hrjobs form settings by form name to render in Admin
*/
function get_settings($formname,$type){
$formExists="";
$testimonial_forms=array();
$testimonialform=array();
$formname=trim($formname);
if( $type == 'testimonialform')
{
$testimonial_forms=get_option('awp_testimonialforms');
}
if($formname=="")
$formExists="";
else if(!empty($testimonial_forms))
$formExists = awp_recursive_array_search($testimonial_forms,$formname,'name' );
if(trim($formExists)!=="" ){
$testimonialform=$testimonial_forms[$formExists];
}
return $testimonialform;
}
function formsetting()
{
$updatemessage="";
/*if( $Results->numResults != 0) { */
$testimonial_forms=array();
$testimonialformdetails=array();
$testimonial_forms=get_option('awp_testimonialforms');
if(empty($testimonial_forms))
{
$testimonial_array =array("name"=>'testimonialform');
$testimonialform=array($testimonial_array);
update_option('awp_testimonialforms',$testimonialform);
$testimonial_forms=get_option('awp_testimonialforms');
}
/*
* Saving selected form settings
*/
if(isset($_POST['awp_testimonialform_settings'])){
$templatelayout="";
$newformname=$_POST['awp_testimonialform_name'];
$submit_type=$_POST['awp_testimonialform_option_submit_type'];
$submit_val=$_POST['awp_testimonialform_button_val'];
if($_POST['awp_testimonialform_templatetype']=="awp_plugin_template")
$templatelayout=$_POST['awp_testimonialform_plugintemplatelayout'];
else
$templatelayout=$_POST['awp_testimonialform_themetemplatelayout'];
$testimonialformproperties=array(
'tmpltype' =>$_POST['awp_testimonialform_templatetype'],
'layout' =>$templatelayout,
'tmpl_button_type' => $submit_type,
'tmpl_button_val' => $submit_val,
'confmsg' => stripslashes($_POST['awp_testimonialform_confirmationmsg']),
'css' => stripslashes($_POST['awp_testimonialform_customcss']),
'subscribe_option' => $_POST['subscribe_option'],
'submit_button_type' => $_POST['awp_testimonialform_submit_type'],
'submit_button_val' => $_POST['awp_testimonialform_submit_val'],
'testimonialform_page' => $_POST['awp_testimonialform_page'] );
//New custom fields
$stack = array();
$addtional_custom = array();
$addtional_order = 23;
for($i=6;$i<200;$i++)
{
if(isset($_POST['customfield'.$i.'_newest']) )
{
$addtional_custom = array('fieldid' => 'customfield'.$i.'','fieldname' => 'Custom Field '.$i.'',
'defaulttext' => 'Custom Field'.$i.'','showorder' => $addtional_order,'validation' => '',
'fieldtype' => 'select');
$addtional_order++;
array_push($stack, $addtional_custom);
}else {
break;
}
}
if(!empty($stack)) :
update_option('awp_addtional_custom_testimonialform',$stack);
endif;
//General fields
$testimonialformfields=array();
foreach( $this->get_master_fields() as $fieldsmasterproperties )
{
$enabled=0;
$testimonialformfield=array();
$fieldid=$fieldsmasterproperties['fieldid'];
if(!empty ($_POST[$fieldid.'_order'])){
$displayorder = $_POST[$fieldid.'_order'];
}
else{
$displayorder = $fieldsmasterproperties['showorder'];
}
if(!empty ($_POST[$fieldid.'_text'])){
$displaytext = $_POST[$fieldid.'_text'];
}
else{
$displaytext = $fieldsmasterproperties['defaulttext'];
}
if($fieldid=='lastname' || $fieldid=='email' || $fieldid=='firstname' || $fieldid=='country' )
{
$enabled = 1;
$required = 1;
}
else
{
$enabled = $_POST[$fieldid.'_show'];
$required = $_POST[$fieldid.'_require'];
}
if($enabled){
$testimonialformfield=$this->createformfield_array($fieldid,$displaytext,$required,$_POST[$fieldid.'_type'],$_POST[$fieldid.'_validation'],$_POST[$fieldid.'_options'],$displayorder);
array_push($testimonialformfields, $testimonialformfield);
}
}
//usort($testimonialformfields, "awp_sort_by_order");
if(!empty($testimonialformfields)){
$newtestimonialformdetails=array('name'=>$newformname,'properties'=>$testimonialformproperties,'fields'=>$testimonialformfields);
$formExists="";
if(!empty($testimonial_forms))
$formExists = awp_recursive_array_search($testimonial_forms,$newformname,'name' );
if(trim($formExists)!=="" ){
unset($testimonial_forms[$formExists]);
array_push($testimonial_forms, $newtestimonialformdetails);
sort($testimonial_forms);
update_option('awp_testimonialforms',$testimonial_forms);
$testimonial_forms=get_option('awp_testimonialforms');
$updatemessage= "Testimonial Form '".$newformname."' settings updated. Use Short code '[apptivo_testimonials_form name=\"".$newformname."\"]' in your page to use this form.";
}
}else{
$updatemessage="Select atleast one Form field for jobs Form.";
}
$selectedtestimonialform=$newformname;
}
// Now display the settings editing screen
echo '
';
//if updatemessage is not empty display the div
if(trim($updatemessage)!=""){
?>
get_plugin_templates(AWP_TESTIMONIALS_FORM_TEMPLATEPATH); //Testimonial form plugin templates
?>
get_settings($selectedtestimonialform,'testimonialform');
if(count($testimonialformdetails)>0){
$selectedtestimonialform=$testimonialformdetails[name];
$fields=$testimonialformdetails[fields];
$formproperties=$testimonialformdetails[properties];
}
?>
stripslashes($_POST['customerName']),
'customerName' => stripslashes($_POST['customerHid']),
'contactId' => stripslashes($_POST['contactName']),
'contactName' => stripslashes($_POST['contactHid']),
'testimonialscontent'=> stripslashes($_POST['awp_testimonials_cnt'])
);
$awp_testimonials_options= wp_parse_args($awp_testimonials_options,array(
'customerId' => '',
'customerName' => '',
'contactId' => '',
'contactName' => '',
'testimonialscontent'=>''
));
extract($awp_testimonials_options);
$testimonial = apply_filters('the_content', $testimonial);
$response = addTestimonials($customerId,$customerName,$contactId,$contactName,$testimonialscontent);
return $response;
/* $awp_testimonials_options = array(
'name' => stripslashes($_POST['awp_testimonials_name']),
'jobtitle' => stripslashes($_POST['awp_testimonials_jobtitle']),
'company' => stripslashes($_POST['awp_testimonials_company']),
'website' => stripslashes($_POST['awp_testimonials_website']),
'email' => stripslashes($_POST['awp_testimonials_email']),
'imageurl' => stripslashes($_POST['awp_testimonials_imageurl']),
'testimonial' => stripslashes($_POST['awp_testimonials_cnt']),
'order' => stripslashes($_POST['awp_testimonials_order'])
);
$awp_testimonials_options= wp_parse_args($awp_testimonials_options,array(
'name' => '',
'jobtitle' => '',
'company' => '',
'website' => '',
'email' => '',
'imageurl' =>'',
'testimonial' =>'',
'order' => ''
));
extract($awp_testimonials_options);
$testimonial = apply_filters('the_content', $testimonial);
$response = addTestimonials($account, $accountId, $company, $contact, $contactId,$creationDate, $email, $firmId, $images, $jobtitle, $name, $returnStatus, $order, $siteTestimonialId, $testimonial, $imageurl, $testimonialStatus, $website);
return $response;*/
}
//Update Testimonials
function update_testimonials() {
$testimonialId = $_REQUEST['awp_tstid'];
if($_REQUEST['updatecustomerHid']==""){
$customerId = stripslashes($_REQUEST['updateCustomerName']);
$customerName=stripslashes(trim($_POST['awp_tst_accountName']));
}else{
$customerId = stripslashes($_REQUEST['updateCustomerName']);
$customerName = stripslashes(trim($_REQUEST['updatecustomerHid']));
}
if($_REQUEST['updatecontactHid']==""){
$contactId = stripslashes($_REQUEST['updatecontactName']);
$contactName=stripslashes($_POST['awp_tst_contactId']);
}else{
$contactId = stripslashes(trim($_REQUEST['updatecontactName']));
$contactName = stripslashes(trim($_REQUEST['updatecontactHid']));
}
$status = $_REQUEST['awp_tst_status'];
$statusid = $_REQUEST['awp_tst_statusId'];
$testimonial = stripslashes($_POST['awp_testimonials_cnt']);
$awp_testimonials_options = array(
'testimonialId' => $_REQUEST['awp_tstid'],
'customerId' =>$customerId,
'contactId' => $contactId,
'testimonial' => stripslashes($_POST['awp_testimonials_cnt']),
'customerName'=>stripslashes($customerName),
'contactName'=>stripslashes($contactName)
);
$awp_testimonials_options= wp_parse_args($awp_testimonials_options,array(
'testimonialId' => '',
'customerId' => '',
'contactId' => '',
'testimonial' => '',
'customerName' => '',
'contactName' => ''
));
extract($awp_testimonials_options);
$response = updateTestimonials($testimonialId,$customerId,$contactId,$testimonial,$customerName,$contactName,$status,$statusid);
return $response;
/* $awp_testimonials_options = array(
'testimonialId' => $_REQUEST['awp_tstid'],
'accountId' => $_REQUEST['awp_tst_accountId'],
'contactId' => $_REQUEST['awp_tst_contactId'],
'name' => stripslashes($_POST['awp_testimonials_name']),
'jobtitle' => stripslashes($_POST['awp_testimonials_jobtitle']),
'company' => stripslashes($_POST['awp_testimonials_company']),
'website' => stripslashes($_POST['awp_testimonials_website']),
'email' => stripslashes($_POST['awp_testimonials_email']),
'imageurl' => stripslashes($_POST['awp_testimonials_imageurl']),
'testimonial' => stripslashes($_POST['awp_testimonials_cnt']),
'order' => stripslashes($_POST['awp_testimonials_order'])
);
$awp_testimonials_options= wp_parse_args($awp_testimonials_options,array(
'testimonialId' => '',
'accountId' => '',
'contactId' => '',
'name' => '',
'jobtitle' => '',
'company' => '',
'website' => '',
'email' => '',
'imageurl' =>'',
'testimonial' =>'',
'order' => ''
));
extract($awp_testimonials_options);
$testimonial = apply_filters('the_content', $testimonial);
$response = updateTestimonials($account, $accountId, $company, $contact, $contactId, $creationDate, $email, $firmId, $images, $jobtitle, $name, $returnStatus, $order, $testimonialId, $testimonial, $imageurl, $testimonialStatus, $website);
return $response;*/
}
//Delete Testimonials
function delete_testimonials(){
$awp_tstid = $_REQUEST['tstid'];
$response = deleteTestimonialByTestimonialId($awp_tstid);
return $response;
}
function options()
{
?>
For Complete instructions,see the Developer's Guide.
_plugin_activated){
echo "Testiomonials plugin is currently disabled. Please enable this in Apptivo General Settings.";
}else if (isset($_POST['awp_testimonial_add']) && ($_POST['nogdog'] == $_SESSION['apptivo_single_testimonials']) ) { //Add Testimonials.
$addtestimonials_response = $this->add_testimonials();
if(strlen(trim($_POST['customerName'])) == 0 )
{
$_SESSION['awp_testmonials_messge'] = 'Please enter a customer name';
}else if($addtestimonials_response == 'E_100')
{
$_SESSION['awp_testmonials_messge'] = ' Invalid Keys ';
}else if($addtestimonials_response->status == 'SUCCESS' && !empty($addtestimonials_response->data))
{
$_SESSION['awp_testmonials_messge'] = 'Testimonials Added Successfully';
}
}else if ($_POST['awp_testimonial_update'] == 'Update') { //Update Testimonails.
$updatetestimonials_response = $this->update_testimonials();
if($updatetestimonials_response->status == 'SUCCESS')
{
$_SESSION['awp_testmonials_messge'] = 'Testimonials Updated Successfully';
}
}else if ($_REQUEST['tstmode'] == 'delete') { //Delete Testimonails.
$deletetestimonials_response = $this->delete_testimonials();
if($deletetestimonials_response->Status == 'SUCCESS')
{
$_SESSION['awp_testmonials_messge'] = 'Testimonials Deleted Successfully';
}
}else {
$_SESSION['awp_testmonials_messge'] = '';
}
switch($_REQUEST['keys'])
{
case fullviewsetting:
$this->fullViewSettings();
break;
case inlineviewsetting:
$this->inlineViewSettings();
break;
case formsetting:
$this->formsetting();
break;
default :
$this->get_all_testimonials(); //Display All testimonilas Lists.
if ($_REQUEST['tstmode'] == 'edit') //Testimonails Edit.
{
$awp_tstid = $_REQUEST['tstid'];
$all_awp_testimonials = getTestimonialByTestimonialId($awp_tstid);
if($all_awp_testimonials->statusCode != '1000' && isset($all_awp_testimonials->statusCode))
{
echo '
'.$all_awp_testimonials->methodResponse->statusMessage.'
';
}
$this->edit_testimonials($all_awp_testimonials); //Testimonails Edit Form.
} else {
$this->testimonials_form(); //Testimonails Create Form.
}
break;
}
?>
save_testimonials_Settings();
echo '
Full View Settings Saved Successfully.
';
}
$this->fullview_settings();
?>
save_inline_settings();
echo '
Inline View Settings Saved Successfully.
';
}
$this->inlineview_settings();
?>
formsetting();
echo '
Inline View Settings Saved Successfully.
';
}
$this->formsetting();
?>
'.$_SESSION['awp_testmonials_messge'].'
';
endif;
$all_awp_testimonials = $all_awp_testimonials;
$numberofitems = count($all_awp_testimonials);
if($numberofitems>0){
$itemsperpage =5;
$tpages = ceil($numberofitems/$itemsperpage);
$currentpage = intval($_GET['pageno']);
if($currentpage<=0) $currentpage = 1;
if($currentpage>=$tpages) $currentpage = $tpages;
$start = ( $currentpage - 1 ) * $itemsperpage;
$all_awp_testimonials = array_slice( $all_awp_testimonials, $start, $itemsperpage );
$reload = $_SERVER['PHP_SELF'].'?page=awp_testimonials';
if(!empty($all_awp_testimonials)){
?>
$itemsperpage)
{
echo awp_paginate($reload,$currentpage,$tpages,$numberofitems);
}
if($_REQUEST['tstmode']=="reject")
{
echo '
Testimonial Rejected Successfully
';
}
if($_REQUEST['tstmode']=="approve")
{
echo '
Testimonial Approved Successfully
';
}
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
siteTestimonialId && $_GET['tstmode'] =='edit')
{
$class = "active";
}else {
$class = "inactive";
}
$cur_page = intval($_GET['pageno']);
if( $cur_page == '' || $cur_page == 0 || $currentpage == 1)
{
$cur_page = 0;
}else {
$cur_page = $cur_page - 1;
}
//if($_REQUEST['tstmode']=="approve" || $_REQUEST['tstmode'] == "reject" || $_REQUEST['page']== "awp_testimonials")
if($_REQUEST['tstmode']=="approve" || $_REQUEST['tstmode'] == "reject")
{
/*$account=$awp_testimonial->account->accountName;
$contact= $awp_testimonial->contact->companyName;
$website=$awp_testimonial->account->website;
$email =$awp_testimonial->email;
$order =$awp_testimonial->sequenceNumber;
$testimonialId=$awp_testimonial->siteTestimonialId;
$testimonial=$awp_testimonial->testimonial;
$testimonialStatus=$awp_testimonial->testimonialStatus;
$imageurl = $awp_testimonial->testimonialImageUrl;
*/
$account=$awp_testimonial->customerName;
$contact= $awp_testimonial->contactName;
$testimonialId=$awp_testimonial->siteTestimonialId;
$testimonial=$awp_testimonial->testimonial;
$testimonialStatus=$awp_testimonial->statusName;
if($_REQUEST['tstmode']=="reject" && $_REQUEST['tstid'] == $testimonialId)
{
$testimonialStatus = "reject";
}
if($_REQUEST['tstmode']=="approve" && $_REQUEST['tstid'] == $testimonialId)
{
$testimonialStatus="approve";
}
$responseStatus = updateTestimonialStatus($testimonialId,$testimonialStatus);
// updateTestimonials($account, $accountId, $company, $contact, $contactId, $creationDate, $email, $firmId, $images, $jobtitle, $name, $returnStatus, $order, $testimonialId, $testimonial, $imageurl, $testimonialStatus, $website);
}
?>
| customerName; ?> |
contactName; ?> |
testimonial))) < 30)
{
echo strip_tags(html_entity_decode($awp_testimonial->testimonial));
}
else
{
$sub = strip_tags(html_entity_decode($awp_testimonial->testimonial));
echo $sub = substr($sub, 0, 30).'...';
}
?>
|
; ?>) |
; ?>) |
; ?>) |
; ?>) |
statusName;
if($testimonialStatus=="PENDING_APPROVAL")
{
$testimonialStatus="PENDING";
}
?>
|
'Template Name'
);
$templates = array();
$dir_testimonials = AWP_TESTIMONIALS_FORM_TEMPLATEPATH;
// Open a known directory, and proceed to read its contents
if (is_dir($dir_testimonials)) {
if ($dh = opendir($dir_testimonials)) {
while (($file = readdir($dh)) !== false) {
if ( substr( $file, -4 ) == '.php' )
{
$plugin_data = get_file_data( $dir_testimonials."/".$file, $default_headers, '' );
if(strlen(trim($plugin_data['Template Name'])) != 0 )
{
$templates[$plugin_data['Template Name']] = $file;
}
}
}
closedir($dh);
}
}
return $templates;
}
//Inline View Settings form
function inlineview_settings(){
$awp_testimonials_inline_settings = get_option('awp_testimonials_inline_settings');
//Inline theme template.
$awp_tst_themetemplates = get_awpTemplates(TEMPLATEPATH.'/testimonials','Inline');
//Inline plugin template.
$awp_tst_plugintemplates = get_awpTemplates(AWP_TESTIMONIALS_TEMPLATEPATH,'Inline');
ksort($awp_tst_plugintemplates);
if( empty($awp_testimonials_inline_settings) )
{
echo ' Save the below settings to get the Shortcode for inline view. ';
}
?>
getAllTestimonialsForFullView();
$awp_testimonials_settings = get_option('awp_testimonials_settings');
ob_start();
if(empty($awp_testimonials_settings))
{
echo awp_messagelist('testimonialsconfigure-display-page');//Testimonials are not configured in admin page
}else if(empty($awp_testimonials['alltestimonials']))
{
echo awp_messagelist('testimonials-display-page'); //Testimonials are not found.Need to create Testimonials.
}else { include $awp_testimonials['templatefile'];
}
$show_testimonials = ob_get_clean();
return $show_testimonials;
}
/*
* Testimonial For Page View
*/
function testimonialform($atts){
ob_start();
$testimonialidwith_Number = FALSE;
extract(shortcode_atts(array('name'=> ''), $atts));
$formname=trim($name);
$content="";
$successmsg="";
$testimonialform=$this->get_testimonialform_fields($formname);
if(!empty($testimonialform[fields])) {
foreach($testimonialform[fields] as $field){
}
}
$submitformname = $_POST['awp_testimonialformname'];
if(isset($_POST['awp_testimonialformname']) && $submitformname==$formname)
{
if(trim($testId) == '' && isset($_POST['testimonialidwithnumber']))
{
$testimonialid_Number = $_POST['testimonialidwithnumber'];
$testimonialid_No = explode('::',$testimonialid_Number);
$testimonialId = $testimonialid_No[0];
$testimonialNo = $testimonialid_No[1];
$testimonialidwith_Number = TRUE;
}
//$successmsg=$this->save_applicantjobs($submitformname,$testimonialId,$testimonialNo);
}
if($testimonialid_Number)
{
$testimonialId = '';
}
if(!empty($testimonialform)){
include $testimonialform['templatefile'];
echo '';
} else { echo awp_messagelist('testimonials-form-page'); }
$content = ob_get_clean();
return $content;
}
function get_testimonialform_fields($formname){
$formExists="";
$testimonial_forms=array();
$testimonialform=array();
$testimonialformdetails=array();
$formname=trim($formname);
$testimonial_forms=get_option('awp_testimonialforms');
if($formname=="")
$formExists="";
else if(!empty($testimonial_forms))
$formExists = awp_recursive_array_search($testimonial_forms,$formname,'name' );
if(trim($formExists)!=="" ){
$testimonialform=$testimonial_forms[$formExists];
//build hrjobsformdetails array
$testimonialformdetails['name']=$testimonialform['name'];
//add properties
$testimonialformproperties=$testimonialform['properties'];
$testimonialformdetails['tmpltype']=$testimonialformproperties['tmpltype'];
$testimonialformdetails['tmpl_button_type']=$testimonialformproperties['tmpl_button_type'];
$testimonialformdetails['tmpl_button_val']=$testimonialformproperties['tmpl_button_val'];
$testimonialformdetails['layout']=$testimonialformproperties['layout'];
$testimonialformdetails['confmsg']= stripslashes($testimonialformproperties['confmsg']);
$testimonialformdetails['targetlist']=$testimonialformproperties['targetlist'];
$testimonialformdetails['css']=stripslashes($testimonialformproperties['css']);
$testimonialformdetails['submit_button_type']=$testimonialformproperties['submit_button_type'];
$testimonialformdetails['submit_button_val']=$testimonialformproperties['submit_button_val'];
//inclde templates.
if($testimonialformproperties['tmpltype']=="awp_plugin_template") :
$templatefile=AWP_TESTIMONIALS_FORM_TEMPLATEPATH."/".$testimonialformproperties['layout']; // Testimonial form plugin template
else :
$templatefile=AWP_TESTIMONIALS_FORM_TEMPLATEPATH."/".$testimonialformproperties['layout']; // Testimonial form theme template
endif;
$testimonialformdetails['templatefile']=$templatefile;
//add fields
$testimonialformfields=$testimonialform['fields'];
if(!empty($testimonialformfields)){
usort($testimonialformfields, "awp_sort_by_order");
$newtestimonialformfields=$testimonialformfields;
$testimonialformdetails['fields']=$newtestimonialformfields;
echo '';
}
}
return $testimonialformdetails;
}
function display_testimonials()
{
$awp_testimonials = $this->getAllTestimonialsForInline();
$awp_testimonials['alltestimonials'] = array_slice($awp_testimonials['alltestimonials'],0,$awp_testimonials['itemstoshow']);
unset($awp_testimonials['templatefile']);
unset($awp_testimonials['custom_css']);
return $awp_testimonials;
}
//Short code for inline view
function show_testimonials_inline(){
$awp_testimonials_inline_settings = get_option('awp_testimonials_inline_settings');
$awp_testimonials = $this->getAllTestimonialsForInline();
ob_start();
if(empty($awp_testimonials_inline_settings))
{
echo awp_messagelist('testimonialsconfigure-display-page'); //Testimonials are not configured in admin page
}else if(empty($awp_testimonials[alltestimonials]))
{
echo awp_messagelist('testimonials-display-page'); //Testimonials are not found.Need to create Testimonials.
}else { include $awp_testimonials['templatefile']; }
$show_testimonials = ob_get_clean();
return $show_testimonials;
}
/**
* Testimonials Inline View.
*
* @return unknown
*/
function getAllTestimonialsForInline(){
$awp_testimonials_inline_settings = get_option('awp_testimonials_inline_settings');
if($awp_testimonials_inline_settings['template_type']=="awp_plugin_template") :
$templatefile=AWP_TESTIMONIALS_TEMPLATEPATH."/".$awp_testimonials_inline_settings['template_layout']; // Plugin templates
else :
$templatefile=TEMPLATEPATH."/testimonials/".$awp_testimonials_inline_settings['template_layout']; //theme templates
endif;
if (!file_exists($templatefile)) :
$templatefile = AWP_TESTIMONIALS_TEMPLATEPATH."/sliderview1.php";
endif;
$response = getAllTestimonials();
$awp_all_testimonials = $response;
$page_details = get_page($awp_testimonials_inline_settings['page_ID']);
$awp_testimonials = array();
$order=$awp_testimonials_inline_settings['order'];
$awp_testimonials = $this->sortTestimonialByOrder($awp_all_testimonials, $order);
$testimonials = array();
$testimonials['alltestimonials'] = $awp_testimonials;
$testimonials['custom_css'] = $awp_testimonials_inline_settings['custom_css'];
$testimonials['itemstoshow'] = $awp_testimonials_inline_settings['itemstoshow'];
$testimonials['pagelink'] = $page_details->guid;
$testimonials['more_text'] = $awp_testimonials_inline_settings['more_text'];
$testimonials['templatefile'] = $templatefile;
return $testimonials;
}
/**
* Testimonials Full View.
*
* @return unknown
*/
function getAllTestimonialsForFullView(){
$awp_testimonials_settings = get_option('awp_testimonials_settings');
if($awp_testimonials_settings['template_type']=="awp_plugin_template") :
$templatefile=AWP_TESTIMONIALS_TEMPLATEPATH."/".$awp_testimonials_settings['template_layout']; //plugin templates
else :
$templatefile=TEMPLATEPATH."/testimonials/".$awp_testimonials_settings['template_layout']; //theme templates
endif;
if (!file_exists($templatefile)) :
$templatefile = AWP_TESTIMONIALS_TEMPLATEPATH."/".AWP_TESTIMONIALS_DEFAULT_TEMPLATE;
endif;
$response = getAllTestimonials();
//$awp_all_testimonials = awp_convertObjToArray($response->testimonialsList);
$awp_all_testimonials = $response;
$testimonials_pageid = get_option('awp_testimonials_pageid');
if(count($response) == 0 && empty($response) && $testimonials_pageid != '')
{
$awp_all_testimonials = dummy_testimonials();
}
$order=$awp_testimonials_settings['order'];
$awp_testimonials = $this->sortTestimonialByOrder($awp_all_testimonials, $order);
$testimonials = array();
$testimonials['alltestimonials'] = $awp_testimonials;
$testimonials['custom_css'] = $awp_testimonials_settings['custom_css'];
$testimonials['templatefile'] = $templatefile;
return $testimonials;
}
/*
* Testimonial Front Page view
*/
function getTestimonialforPageView()
{
$awp_testimonial_form_settings = get_option('awp_testimonialforms');
if($awp_testimonial_form_settings['tmpl_type']=="awp_plugin_template") :
$templatefile=AWP_TESTIMONIALS_TEMPLATEPATH."/".$awp_testimonial_form_settings['layout']; //plugin templates
exit;
else :
$templatefile=TEMPLATEPATH."/testimonials/templates/frontend/".$awp_testimonial_form_settings['layout']; //theme templates
endif;
if (!file_exists($templatefile)) :
$templatefile = AWP_TESTIMONIALS_TEMPLATEPATH."/".AWP_TESTIMONIALS_DEFAULT_TEMPLATE;
endif;
$response = getAllTestimonials();
$awp_all_testimonials = $response;
//$awp_all_testimonials = awp_convertObjToArray($response->testimonialsList);
$testimonials_pageid = get_option('awp_testimonials_pageid');
if(count($response) == 0 && empty($response) && $testimonials_pageid != '')
{
$awp_all_testimonials = dummy_testimonials();
}
$order=$awp_testimonials_settings['order'];
$awp_testimonials = $this->sortTestimonialByOrder($awp_all_testimonials, $order);
$testimonials = array();
$testimonials['alltestimonials'] = $awp_testimonials;
$testimonials['custom_css'] = $awp_testimonials_settings['custom_css'];
$testimonials['templatefile'] = $templatefile;
return $testimonials;
return;
}
/**
* Sorting Testimonails.
*
* @param unknown_type $awp_testimonials
* @param unknown_type $order
* @return unknown
*/
function sortTestimonialByOrder($awp_testimonials,$order){
if(!empty($awp_testimonials)) {
switch($order){
case '1':
usort($awp_testimonials,'awp_creation_date_compare');
break;
case '2':
usort($awp_testimonials,'awp_creation_date_compare');
$awp_testimonials = array_reverse($awp_testimonials);
break;
case '3':
shuffle($awp_testimonials);
break;
default:
usort($awp_testimonials,'awp_sort_by_sequence');
break;
}
return $awp_testimonials;
}
return false;//No data available.
}
//function is to append page content with shortcode
function update_page_content() {
$awp_testimonials_settings = get_option('awp_testimonials_settings');
$page_details = get_page($awp_testimonials_settings['page_ID']);
$page_content = str_replace('[apptivo_testimonials_fullview]', '', $page_details->post_content) . "[apptivo_testimonials_fullview]";
//Update page
$my_post = array();
$my_post[ID] = $awp_testimonials_settings['page_ID'];
$my_post['post_content'] = $page_content;
//Update the post into the database
wp_update_post($my_post);
}
//Full View Settings Form
function fullview_settings() {
$awp_testimonials_settings = get_option('awp_testimonials_settings');
//Full view theme template
$awp_tst_themetemplates = get_awpTemplates(TEMPLATEPATH.'/testimonials','Plugin');
//Full view Plugin template
$awp_tst_plugintemplates = get_awpTemplates(AWP_TESTIMONIALS_TEMPLATEPATH,'Plugin');
$awp_tst_plugintemplates = get_awpTemplates(AWP_TESTIMONIALS_TEMPLATEPATH,'Plugin');
ksort($awp_tst_plugintemplates);
if( empty($awp_testimonials_settings) ) :
echo ' Save the below settings to get the Shortcode for full view. ';
endif; // if( empty($awp_testimonials_settings) )
?>
$_POST['awp_testimonials_templatetype'],
'template_layout' => $testimonial_layout,
'style' => $_POST['style'],
'custom_css' => stripslashes($_POST['custom_css']),
'order' => $_POST['order'],
'itemstoshow' => $inline_testimonials_itemtoshow,
'more_text' => (trim($_POST['more_text'])!="")?$_POST['more_text']:AWP_DEFAULT_MORE_TEXT,
'page_ID' => $_POST['page_ID'],
);
update_option('awp_testimonials_inline_settings', $awp_testimonials_inline_settings);
}
//Save Testomonials Settings
function save_testimonials_Settings() {
if ($_POST['awp_testimonials_templatetype'] == "awp_plugin_template") :
$testimonial_layout = $_POST['awp_testimonials_plugintemplatelayout'];
else :
$testimonial_layout = $_POST['awp_testimonials_themetemplatelayout'];
endif;
$awp_testimonials_settings = array(
'template_type' => $_POST['awp_testimonials_templatetype'],
'template_layout' => $testimonial_layout,
'custom_css' => stripslashes($_POST['custom_css']),
'order' => $_POST['order'],
'page_ID' => $_POST['page_ID'],
'itemsperpage' => (!empty($_POST['itemsperpage'])) ? $_POST['itemsperpage'] : 5
);
update_option('awp_testimonials_settings', $awp_testimonials_settings);
}
//Testimonials Form
function testimonials_form(){
?>
data->siteTestimonialId;
$testicustomerName = $all_awp_testimonials->data->customerName;
$testicustomerId = $all_awp_testimonials->data->customerId;
$testicontactName = $all_awp_testimonials->data->contactName;
$testicontactId = $all_awp_testimonials->data->contactId;
$testimonial = $all_awp_testimonials->data->testimonial;
$status = $all_awp_testimonials->data->statusName;
$statusId = $all_awp_testimonials->data->statusId;
?>
data;
foreach($records as $record){
$customerObj = new stdClass();
if($record->customerName != ""){
$customerObj->customerName = $record->customerName;
$customerObj->customerId = $record->customerId;
$allRecords[]=$customerObj;
}
}
$total=$getAllRecords->countOfRecords;
if($total > 50){
for($i=2;$i<=$total;$i++){
$i=$i+49;
$getAllbalRecords= getAllCustomers($query,$i,$maxItemCount,$fromIndex);
foreach($getAllbalRecords->data as $record){
$customerObj = new stdClass();
if($record->customerName != ""){
$customerObj->customerName = $record->customerName;
$customerObj->customerId = $record->customerId;
$allRecords[]=$customerObj;
}
}
}
}
return $allRecords;
}
function getAllCustomers($query,$count,$maxItemCount,$fromIndex)
{
$params = array(
"a" => "getAll",
"iDisplayLength"=>50,
"iDisplayStart"=>0,
"numRecords"=>50,
"objectId"=>APPTIVO_CUSTOMER_OBJECT_ID,
"selectedLetter" => "all",
"sortColumn"=>"customerName.sortable",
"startIndex"=>$count,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall('POST', APPTIVO_CUSTOMER_V6_API, $params);
return $response;
}
function getContactsByCustomerIdPHP($customerId){
$params = array(
"a" => "getCustomerContacts",
"customerId" => $customerId,
"iDisplayLength"=>10,
"iDisplayStart"=>0,
"numRecords"=>10,
"sSortDir_0"=> 'asc',
"sortDir"=>'asc',
"startIndex"=>0,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall('POST', APPTIVO_CUSTOMER_V6_API, $params);
//echo json_encode($response);exit;
$contacts = array();
if($response->countOfRecords > 0){
foreach ($response->data as $contact){
$contactObj = new stdClass();
$contactObj->contactId = $contact->contactId;
$contactObj->contactName = $contact->fullName;
$contacts[] = $contactObj;
}
}
return $contacts;
}
add_action( 'wp_ajax_nopriv_getContactsByCustomerId', 'getContactsByCustomerId' );
add_action( 'wp_ajax_getContactsByCustomerId', 'getContactsByCustomerId' );
function getContactsByCustomerId($customerId){
$customerId = $_POST['id'];
$params = array(
"a" => "getCustomerContacts",
"customerId" => $customerId,
"iDisplayLength"=>10,
"iDisplayStart"=>0,
"numRecords"=>10,
"sSortDir_0"=> 'asc',
"sortDir"=>'asc',
"startIndex"=>0,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall('POST', APPTIVO_CUSTOMER_V6_API, $params);
//echo json_encode($response);exit;
$contacts = array();
if($response->countOfRecords > 0){
foreach ($response->data as $contact){
$contactObj = new stdClass();
$contactObj->contactId = $contact->contactId;
$contactObj->contactName = $contact->fullName;
$contacts[] = $contactObj;
}
}
echo json_encode($contacts);exit;
}
/**
* To Add testimonials.
*
* createTestimonial(String siteKey, Testimonial testimonial, List imageDetails)
*/
function addTestimonials ($customerId,$customerName,$contactId,$contactName,$testimonialscontent){
if($contactId == ''){
$contactId = null;
}
$testimonialData = new stdClass();
$testimonialData->statusName="Pending";
$testimonialData->statusId=1;
$testimonialData->customAttributes=array();
$testimonialData->labels=array();
$testimonialData->tags=array();
$testimonialData->isDirtypage=null;
$testimonialData->testimonial=$testimonialscontent;
$testimonialData->customerName=$customerName;
$testimonialData->customerId=$customerId;
$testimonialData->customer_input=$customerId;
$testimonialData->contactName=$contactName;
$testimonialData->contactId=$contactId;
$testimonialData->updateAutocomplete=true;
$param = array(
"a" => "save",
"testimonialData" => json_encode($testimonialData),
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_TESTIMONIALS_V6_API, $param);
return $response;
/*
$testimonial = strip_tags(html_entity_decode(stripslashes(nl2br($testimonial)),ENT_NOQUOTES,"Utf-8"));
$mktg_testimonials = new AWP_MktTestimonial($account, $accountId, $company, $contact, $contactId, $creationDate, $email, $firmId, $images, $jobTitle, $name, $returnStatus, $sequenceNumber, $siteTestimonialId, $testimonial, $testimonialImageUrl, $testimonialStatus, $website);
$params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => $mktg_testimonials,
"arg3" => null
);
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'createTestimonial',$params);
return $response;
*/
}
/**
* @method getAllTestimonials
* @return
*/
function getAllTestimonials()
{
/*$pubdate_params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY
);
$plugin_params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => null
);
$response = get_data(APPTIVO_BUSINESS_SERVICES,'-testimonials-publisheddate','-testimonials-data','getLastPublishDate','getAllTestimonials',$pubdate_params,$plugin_params);
return $response->return;*/
$allRecords=array();
$count=0;
$getAllRecords= getAllTestimonial($count);
$records = $getAllRecords->data;
foreach($records as $record){
$allRecords[] = $record;
}
$total=$getAllRecords->countOfRecords;
if($total > 50){
for($i=2;$i<=$total;$i++){
$i=$i+49;
$getAllbalRecords= getAllTestimonial($i);
foreach($getAllbalRecords->data as $record){
$allRecords[]=$record;
}
}
}
return $allRecords;
}
/**
* @method getAllTestimonials
* @return
*/
function getAllTestimonial()
{
$params = array (
"a" => "getAll",
"iDisplayLength"=>50,
"iDisplayStart"=>0,
"numRecords"=>500,
"sSortDir_0"=>"desc",
"sortColumn"=>"creationDate",
"sortDir"=>"desc",
"startIndex" => 0,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response=getRestAPICall("POST",APPTIVO_TESTIMONIALS_V6_API,$params);
return $response;
/*$pubdate_params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY
);
$plugin_params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => null
);
$response = get_data(APPTIVO_BUSINESS_SERVICES,'-testimonials-publisheddate','-testimonials-data','getLastPublishDate','getAllTestimonials',$pubdate_params,$plugin_params);
return $response->return;*/
}
/**
* @method getAllTestimonials
* @return
*/
function getTestimonialByTestimonialId($awp_tstid)
{
$param = array(
"a" => "getById",
"siteTestimonialId" => $awp_tstid,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_TESTIMONIALS_V6_API, $param);
return $response;
/*$params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => $awp_tstid
);
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'getTestimonialByTestimonialId',$params);
return $response->return;*/
}
/**
* Enter description here...
*
* @param unknown_type $awp_tstid
* @return unknown
*/
function deleteTestimonialByTestimonialId($awp_tstid)
{
$param = array(
"a" => "delete",
"siteTestimonialId" => $awp_tstid,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_TESTIMONIALS_V6_API, $param);
return $response;
/*$params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => $awp_tstid
);
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'deleteTestimonialByTestimonialId',$params);
return $response;*/
}
/* Success Message to Front end Form */
function successMessage($success)
{
$url=SITE_URL.$_SERVER['REQUEST_URI'];
$display_msg = "Testimonial Is awaiting for Moderation";
$actual_link = $_SESSION['request_link'];
if(strpos($actual_link, 'status=Success')!=false)
{
$actual_link= str_replace('?status=Success', '', $actual_link);
if (strpos($actual_link, '?') !== false) {$actual_link= str_replace('&status=Success', '', $actual_link); }
unset($_SESSION['POST_VALUES']);
}
if(strpos($actual_link, 'status=Please%20enter%20correct%20Verification%20code')!=false)
{
$actual_link= str_replace('?status=Please%20enter%20correct%20Verification%20code', '', $actual_link);
if (strpos($actual_link, '?') !== false) {$actual_link= str_replace('&status=Please%20enter%20correct%20Verification%20code', '', $actual_link); }
}
if (strpos($actual_link, '?') !== false) {
header("Location:$actual_link&status=".urlencode($success));
exit;
} else {
header("Location:$actual_link?status=".urlencode($success));
exit;
}
}
function updateTestimonialStatus($testimonialId,$testimonialStatus){
$param = array(
"a" => "updateStatus",
"siteTestimonialId" => $testimonialId,
"updateStatus"=>$testimonialStatus,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_TESTIMONIALS_V6_API, $param);
error_log(json_encode($response));
return $response;
}
/**
* To Update Testimnails.
*
*/
function updateTestimonials($testimonialId,$customerId,$contactId,$testimonial,$customerName,$contactName,$status,$statusId)
{
$testimonialData = new stdClass();
$testimonialData->statusName=$status;
$testimonialData->statusId=$statusId;
$testimonialData->customAttributes=array();
$testimonialData->labels=array();
$testimonialData->tags=array();
$testimonialData->isDirtypage=null;
$testimonialData->testimonial=$testimonial;
$testimonialData->customerName=$customerName;
$testimonialData->customerId=$customerId;
$testimonialData->customer_input=$customerId;
$testimonialData->contactName=$contactName;
$testimonialData->contactId=$contactId;
$testimonialData->updateAutocomplete=true;
$param = array(
"a" => "update",
"testimonialData" => json_encode($testimonialData),
"attributeName"=>'["customerName","contactName","testimonial"]',
"siteTestimonialId"=>$testimonialId,
"apiKey" => APPTIVO_BUSINESS_API_KEY,
"accessKey" => APPTIVO_BUSINESS_ACCESS_KEY
);
$response = getRestAPICall("POST", APPTIVO_TESTIMONIALS_V6_API, $param);
error_log(json_encode($response));
return $response;
/*$testimonial = strip_tags(html_entity_decode(stripslashes(nl2br($testimonial)),ENT_NOQUOTES,"Utf-8"));
$mktg_testimonials = new AWP_MktTestimonial($account, $accountId, $company, $contact, $contactId, $creationDate, $email, $firmId, $images, $jobTitle, $name, $returnStatus, $sequenceNumber, $siteTestimonialId, $testimonial, $testimonialImageUrl, $testimonialStatus, $website);
$params = array (
"arg0" => APPTIVO_BUSINESS_API_KEY,
"arg1" => APPTIVO_BUSINESS_ACCESS_KEY,
"arg2" => $mktg_testimonials,
"arg3" => null
);
$response = getsoapCall(APPTIVO_BUSINESS_SERVICES,'updateTestimonial',$params);
return $response;*/
}
if($_REQUEST['page']=="awp_testimonials" && $_REQUEST['email'] !="")
{
//echo '';print_r($_REQUEST);exit;
$fistName = stripslashes($_POST['name']);
$email = stripslashes($_POST['email']);
$testimonial = stripslashes($_POST['comments']);
$awp_services_obj=new AWPAPIServices();
$assignee = $awp_services_obj->getAssigneeDetails();
$assigneeObjRefName = $assignee->fullName;
$assigneeObjReId = $assignee->employeeId;
$assigneeObjId = "8";
$awp_testimonials_options = array(
'name' => stripslashes($_POST['name']),
'email' => stripslashes($_POST['email']),
'testimonial' => stripslashes($_POST['comments'])
);
$awp_testimonials_options= wp_parse_args($awp_testimonials_options,array(
'name' => '',
'email' => '',
'testimonial' =>''
));
$_SESSION['POST_VALUES'] = $_POST;
extract($awp_testimonials_options);
// $testimonial = apply_filters('the_content', (strip_tags($testimonial)));
if (isset($_POST["g-recaptcha-response"])) {
$response_field = $_POST["g-recaptcha-response"];
$private_key = $option->recaptcha_privatekey;
$captcha_response= captchaValidation($private_key, $response_field);
if($captcha_response !="1")
{
$value_present = true;
$captch_error = awp_messagelist("v2recaptcha_error");
}else {
$awp_services_obj=new AWPAPIServices();
$customer = $awp_services_obj->searchCustomerByemail($email);
if(!empty($customer)){
$customerId = $customer->customerId;
$customerName = $customer->customerName;
}else{
$createCustomerResponse=$awp_services_obj->createCustomer($fistName,$assigneeObjRefName,$assigneeObjId,$assigneeObjReId,"",$email);
$customerId=$createCustomerResponse['leadCustomerId'];
$customerName=$createCustomerResponse['leadCustomer'];
}
$response = addTestimonials($customerId,$customerName,null,"",$testimonial);
if($response->status == "SUCCESS"){
successMessage("Success");
}else{
successMessage("Fail");
}
}
}elseif ($_POST['email'] != "") {
$awp_services_obj=new AWPAPIServices();
$customer = $awp_services_obj->searchCustomerByemail($email);
if(!empty($customer)){
$customerId = $customer->customerId;
$customerName = $customer->customerName;
}else{
$createCustomerResponse=$awp_services_obj->createCustomer($fistName,$assigneeObjRefName,$assigneeObjId,$assigneeObjReId,"",$email);
$customerId=$createCustomerResponse['leadCustomerId'];
$customerName=$createCustomerResponse['leadCustomer'];
}
$response = addTestimonials($customerId,$customerName,null,"",$testimonial);
if($response->status == "SUCCESS"){
successMessage("Success");
}else{
successMessage("Fail");
}
}
}
/*
* To Sort testimonials by siteTestimonialId
*/
function sortTestimonials($a, $b)
{
return strcmp($a->siteTestimonialId, $b->siteTestimonialId);
}
?>