AdditionalOptions.class.php
2 months ago
CampaignInfo.class.php
2 months ago
Campaigns.class.php
2 months ago
ClickTracking.class.php
2 months ago
ContactForm7.class.php
2 months ago
Debugging.class.php
4 weeks ago
EDD.class.php
4 weeks ago
General.class.php
4 weeks ago
Integrations.class.php
2 months ago
LifterLMS.class.php
2 months ago
Marketpress.class.php
4 weeks ago
MemberPress.class.php
2 months ago
Membership2.class.php
2 months ago
PMPro.class.php
2 months ago
PPBuyNowButton.class.php
2 months ago
RestrictContentPro.class.php
2 months ago
S2Member.class.php
2 months ago
Signup.class.php
2 months ago
SimplePayPro.class.php
2 months ago
StripePayments.class.php
4 weeks ago
SureCart.class.php
2 months ago
WPEasyCart.class.php
2 months ago
WPPayForms.class.php
2 months ago
WishListMember.class.php
2 months ago
WooComm.class.php
4 weeks ago
Signup.class.php
88 lines
| 1 | <?php |
| 2 | if (!defined('ABSPATH')) exit; |
| 3 | |
| 4 | class postaffiliatepro_Form_Settings_Signup extends postaffiliatepro_Form_Base { |
| 5 | private $campaignHelper = null; |
| 6 | private $isValidSession = true; |
| 7 | |
| 8 | public function __construct() { |
| 9 | parent::__construct(postaffiliatepro::SIGNUP_SETTINGS_PAGE_NAME, 'options.php'); |
| 10 | } |
| 11 | |
| 12 | protected function getTemplateFile() { |
| 13 | return WP_PLUGIN_DIR . '/postaffiliatepro/Template/SignupSettings.xtpl'; |
| 14 | } |
| 15 | |
| 16 | private function getAffiliatesSelectData() { |
| 17 | $data = array('0' => ' ', 'from_cookie' => __('resolve automatically', 'postaffiliatepro')); |
| 18 | |
| 19 | $session = $this->getApiSession(); |
| 20 | if ($session === null || $session === '0') { |
| 21 | $this->_log('Unable to connect to your Post Affiliate Pro installation'); |
| 22 | return $data; |
| 23 | } |
| 24 | $request = new Pap_Api_AffiliatesGrid($session); |
| 25 | $request->addParam('columns', new Gpf_Rpc_Array(array(array('id'), array('username'), array('firstname'), array('lastname')))); |
| 26 | $request->setLimit(0, 5000); |
| 27 | try { |
| 28 | $request->sendNow(); |
| 29 | } catch(Exception $e) { |
| 30 | $this->_log('API call error: ' . $e->getMessage()); |
| 31 | return $data; |
| 32 | } |
| 33 | $grid = $request->getGrid(); |
| 34 | $recordset = $grid->getRecordset(); |
| 35 | foreach($recordset as $rec) { |
| 36 | $data[$rec->get('id')] = $rec->get('username') . ' (' . htmlspecialchars($rec->get('firstname')).' '.htmlspecialchars($rec->get('lastname')).')'; |
| 37 | } |
| 38 | return $data; |
| 39 | } |
| 40 | |
| 41 | protected function initForm() { |
| 42 | if (!$this->isValidSession) { |
| 43 | return; |
| 44 | } |
| 45 | $this->addSelect(postaffiliatepro::SIGNUP_DEFAULT_STATUS_SETTING_NAME, array('' => 'default', 'A' => 'Approved', 'P' => 'Pending', 'D'=>'Declined')); |
| 46 | $this->addSelect(postaffiliatepro::SIGNUP_AFFILIATE_USERNAME, array('email' => __('User email', 'postaffiliatepro'), 'username' => __('Username', 'postaffiliatepro'))); |
| 47 | $this->addSelect(postaffiliatepro::SIGNUP_DEFAULT_PARENT_SETTING_NAME, $this->getAffiliatesSelectData()); |
| 48 | $this->addCheckbox(postaffiliatepro::SIGNUP_INTEGRATION_ENABLED_SETTING_NAME); |
| 49 | $this->addCheckbox(postaffiliatepro::SIGNUP_INTEGRATION_USE_PHOTO); |
| 50 | $this->addSelect(postaffiliatepro::SIGNUP_INTEGRATION_SAVE_LEVEL, $this->getDataFieldsArray()); |
| 51 | $this->addSubmit(); |
| 52 | |
| 53 | $campaignsForm = new postaffiliatepro_Form_Settings_Campaigns($this->getCampaignHelper()); |
| 54 | $this->addHtml('campaigns-content', $campaignsForm->render(true)); |
| 55 | |
| 56 | $this->addTextBox(postaffiliatepro::SIGNUP_INTEGRATION_NO_SAVE_LEVEL, 20,'administrator'); |
| 57 | $this->addHtml('existing-roles', $this->getExistingUserRoles()); |
| 58 | } |
| 59 | |
| 60 | private function getDataFieldsArray() { |
| 61 | $data = array(0 => ''); |
| 62 | for ($i = 1; $i<=25; $i++) { |
| 63 | $data[$i] = 'Data '.$i; |
| 64 | } |
| 65 | return $data; |
| 66 | } |
| 67 | |
| 68 | private function getExistingUserRoles() { |
| 69 | global $wp_roles; |
| 70 | $roles = []; |
| 71 | |
| 72 | foreach ($wp_roles->roles as $role => $details) { |
| 73 | $roles[] = $role; //$name; |
| 74 | } |
| 75 | |
| 76 | return implode(', ',$roles); |
| 77 | } |
| 78 | |
| 79 | public function render($toVar = false, $template = '') { |
| 80 | $session = $this->getApiSession(); |
| 81 | if ($session !== null && $session !== '0') { |
| 82 | parent::render(); |
| 83 | return; |
| 84 | } |
| 85 | $this->isValidSession = false; |
| 86 | parent::render(false, WP_PLUGIN_DIR . '/postaffiliatepro/Template/SignupSettingsNoSession.xtpl'); |
| 87 | } |
| 88 | } |