public function validate_group_settings($options, $group)
 {
     if (isset($options['enable-email-verification']) && $options['enable-email-verification'] && get_awpcp_option('requireuserregistration')) {
         $message = __("Email verification was not enabled because Require Registration is on. Registered users don't need to verify the email address used for contact information.", 'AWPCP');
         awpcp_flash($message, 'error');
         $options['enable-email-verification'] = 0;
     }
     return $options;
 }
 public function validate_credit_system_settings($options, $group)
 {
     $credits_is_the_only_accepted_payment_type = $options['accepted-payment-type'] == AWPCP_Payment_Transaction::PAYMENT_TYPE_CREDITS;
     $credit_system_will_be_enabled = $options['enable-credit-system'];
     if ($credits_is_the_only_accepted_payment_type && !$credit_system_will_be_enabled) {
         $options['accepted-payment-type'] = 'both';
         $message = __('You cannot configure Credits as the only accepted payment type unless you unable the Credit System as well. The setting was set to accept both Currency and Credits.', 'AWPCP');
         awpcp_flash($message, array('error'));
     }
     return $options;
 }
 public function prepare_items()
 {
     $search_params = $this->get_listing_search_params();
     $this->load_items_from_query($search_params['query'], $search_params['filters']);
     if (isset($search_params['query']['category_id']) && $search_params['query']['category_id']) {
         $category = AWPCP_Category::find_by_id($search_params['query']['category_id']);
         if (!is_null($category)) {
             awpcp_flash(sprintf(__('Showing Ads from %s category.', 'AWPCP'), "<strong>{$category->name}</strong>"));
         }
     }
     $this->_column_headers = array($this->get_columns(), array(), $this->get_sortable_columns());
 }
 public function validate_group_settings($options, $group)
 {
     // debugp( $options, $group );
     if (isset($options['force-secure-urls']) && $options['force-secure-urls']) {
         if ($this->is_https_disabled()) {
             $message = __("Force Secure URLs was not enabled because your website couldn't be accessed using a secure connection.", 'AWPCP');
             awpcp_flash($message, 'error');
             $options['force-secure-urls'] = 0;
         }
     }
     return $options;
 }
 public function dispatch()
 {
     $action = $this->get_current_action();
     switch ($action) {
         case 'index':
             return $this->index();
             break;
         default:
             awpcp_flash("Unknown action: {$action}", 'error');
             return $this->index();
             break;
     }
 }
 private function show_results()
 {
     if ($this->successful == 0 && $this->failed == 0) {
         awpcp_flash(__('No Ads were selected', 'AWPCP'), 'error');
     } else {
         $success_message = _n('%d Ad was renewed', '%d Ads were renewed', $this->successful, 'AWPCP');
         $success_message = sprintf($success_message, $this->successful);
         $error_message = sprintf(__('there was an error trying to renew %d Ads', 'AWPCP'), $this->failed);
         $this->show_bulk_operation_result_message($this->successful, $this->failed, $success_message, $error_message);
     }
     foreach ($this->errors as $error) {
         awpcp_flash($error, 'error');
     }
 }
 protected function show_bulk_operation_result_message($successful_count, $failed_count, $success_message, $error_message)
 {
     if ($successful_count > 0 && $failed_count > 0) {
         $message = _x('%s and %s.', 'Listing bulk operations: <message-ok> and <message-error>.', 'AWPCP');
         awpcp_flash(sprintf($message, $success_message, $error_message), 'error');
     } else {
         if ($successful_count > 0) {
             awpcp_flash($success_message . '.');
         } else {
             if ($failed_count > 0) {
                 awpcp_flash(ucfirst($error_message . '.'), 'error');
             }
         }
     }
 }
 private function show_results()
 {
     $listings_processed = array_sum($this->successful);
     $listings_failed = array_sum($this->failed);
     if ($listings_processed + $listings_failed == 0) {
         awpcp_flash(__('No Ads were selected', 'AWPCP'), 'error');
     } else {
         $this->show_send_to_facebook_page_results();
         $this->show_send_to_facebook_group_results();
     }
     if ($listings_processed == 0 && $listings_failed > 0 && !empty($this->errors)) {
         $link = '<a href="' . admin_url('admin.php?page=awpcp-admin-settings&g=facebook-settings') . '">';
         $message = __('There were errors trying to Send Ads to Facebook, perhaps your credentials are invalid or have expired. Please check your <a>settings</a>. If your token expired, please try to get a new access token from Facebook using the link in step 2 of the settings.', 'AWPCP');
         $this->errors[] = str_replace('<a>', $link, $message);
     }
     foreach ($this->errors as $error) {
         awpcp_flash($error, 'error');
     }
 }
Esempio n. 9
0
 public function delete()
 {
     $id = awpcp_request_param('id', 0);
     $fee = AWPCP_Fee::find_by_id($id);
     if (is_null($fee)) {
         awpcp_flash(__("The specified Fee doesn't exists.", 'AWPCP'), 'error');
         return $this->index();
     }
     $errors = array();
     if (AWPCP_Fee::delete($fee->id, $errors)) {
         awpcp_flash(__('The Fee was successfully deleted.', 'AWPCP'));
     } else {
         $where = sprintf("adterm_id = %d AND payment_term_type = 'fee'", $fee->id);
         $ads = AWPCP_Ad::find($where);
         if (empty($ads)) {
             foreach ($errors as $error) {
                 awpcp_flash($error, 'error');
             }
         } else {
             $fees = AWPCP_Fee::query();
             if (count($fees) > 1) {
                 $message = __("The Fee couldn't be deleted because there are active Ads in the system that are associated with the Fee ID. You need to switch the Ads to a different Fee before you can delete the plan.", "AWPCP");
                 awpcp_flash($message, 'error');
                 $params = array('fee' => $fee, 'fees' => $fees);
                 $template = AWPCP_DIR . '/admin/templates/admin-panel-fees-delete.tpl.php';
                 echo $this->render($template, $params);
                 return;
             } else {
                 $message = __("The Fee couldn't be deleted because there are active Ads in the system that are associated with the Fee ID. Please create a new Fee and try the delete operation again. AWPCP will help you to switch existing Ads to the new fee.", "AWPCP");
                 awpcp_flash($message, 'error');
             }
         }
     }
     return $this->index();
 }
Esempio n. 10
0
 public function set_transaction_item($transaction, $term = null, $payment_type = null)
 {
     if (is_null($term)) {
         $term = $this->get_payment_term($payment_type, $selected);
     } else {
         if (is_null($payment_type)) {
             $payment_type = AWPCP_Payment_Transaction::PAYMENT_TYPE_MONEY;
         }
         $selected = $this->item_id($term, $payment_type);
     }
     if (!in_array($payment_type, awpcp_payments_api()->get_accepted_payment_types())) {
         awpcp_flash(__("The selected payment type can't be used in this kind of transaction.", 'AWPCP'), 'error');
         return;
     }
     if (!$term->is_suitable_for_transaction($transaction)) {
         awpcp_flash(__("The selected payment term can't be used in this kind of transaction.", 'AWPCP'), 'error');
         return;
     }
     $amount = $payment_type == 'credits' ? $term->credits : $term->price;
     $transaction->add_item($selected, $term->get_name(), $term->description, $payment_type, $amount);
 }
Esempio n. 11
0
 public function deactivate_license($module_name, $module_slug)
 {
     try {
         $response = $this->edd->deactivate_license($module_name, $this->get_module_license($module_slug));
         $this->update_license_status($module_slug, $response->license);
         return $response->license === self::LICENSE_STATUS_DEACTIVATED;
     } catch (AWPCP_Exception $e) {
         $this->drop_license_status($module_slug);
         awpcp_flash($e->format_errors());
         return false;
     }
 }
Esempio n. 12
0
 public function add_image($ad, $media)
 {
     $action = awpcp_post_param('awpcp_action', false);
     $errors = array();
     if ($action !== 'add_image' || is_null($ad)) {
         return $this->show_images($ad);
     }
     if ($_FILES['awpcp_add_file']['error'] !== 0) {
         $message = awpcp_uploaded_file_error($_FILES['awpcp_add_file']);
         awpcp_flash(end($message), 'error');
     } else {
         if (wp_verify_nonce($_POST['_wpnonce'], 'awpcp_upload_image')) {
             $files = array('awpcp_add_file' => $_FILES['awpcp_add_file']);
             $uploaded = awpcp_upload_files($ad, $files, $errors);
             if (empty($uploaded)) {
                 $message = _x('There was an error trying to upload your file.', 'media manager', 'AWPCP');
                 awpcp_flash(awpcp_array_data('awpcp_add_file', $message, $errors), 'error');
             } else {
                 $admin_must_approve = get_awpcp_option('imagesapprove');
                 $is_admin_user = awpcp_current_user_is_admin();
                 if (!$is_admin_user && $admin_must_approve) {
                     awpcp_ad_awaiting_approval_email($ad, false, true);
                 }
                 awpcp_flash(_x('The file was properly uploaded.', 'media manager', 'AWPCP'));
             }
         }
     }
     return $this->show_images($ad);
 }
Esempio n. 13
0
 private function handle_custom_listing_actions($action)
 {
     try {
         $listing = awpcp_listings_collection()->get($this->id);
     } catch (AWPCP_Exception $e) {
         awpcp_flash(__("The specified listing doesn't exists.", 'AWPCP'), 'error');
         return $this->index();
     }
     $output = apply_filters("awpcp-custom-admin-listings-table-action-{$action}", null, $listing);
     if (is_null($output)) {
         awpcp_flash("Unknown action: {$action}", 'error');
         return $this->index();
     } else {
         if (is_array($output) && isset($output['redirect'])) {
             return $this->render_page($output['redirect']);
         } else {
             return $output;
         }
     }
 }
Esempio n. 14
0
 public function filter_detailed_plugin_information($response, $action, $args)
 {
     if ($action != 'plugin_information' || !isset($this->modules[$args->slug])) {
         return $response;
     }
     try {
         $information = $this->get_information_for_module($this->modules[$args->slug]);
     } catch (AWPCP_Exception $e) {
         awpcp_flash($e->format_errors());
         return $response;
     }
     return $information;
 }
Esempio n. 15
0
 /**
  * Payment Settings checks
  * XXX: Referenced in FAQ: http://awpcp.com/forum/faq/why-doesnt-my-currency-code-change-when-i-set-it/
  */
 public function validate_payment_settings($options, $group)
 {
     $setting = 'paypalcurrencycode';
     if (isset($options[$setting]) && !awpcp_paypal_supports_currency($options[$setting])) {
         $currency_codes = awpcp_paypal_supported_currencies();
         $message = __('There is a problem with the PayPal Currency Code you have entered. It does not match any of the codes in our list of curencies supported by PayPal.', 'AWPCP');
         $message .= '<br/><br/><strong>' . __('The available currency codes are', 'AWPCP') . '</strong>:<br/>';
         $message .= join(' | ', $currency_codes);
         awpcp_flash($message);
         $options[$setting] = 'USD';
     }
     $setting = 'enable-credit-system';
     if (isset($options[$setting]) && $options[$setting] == 1 && !get_awpcp_option('requireuserregistration')) {
         awpcp_flash(__('Require Registration setting was enabled automatically because you activated the Credit System.', 'AWPCP'));
         $options['requireuserregistration'] = 1;
     }
     if (isset($options[$setting]) && $options[$setting] == 1 && !get_awpcp_option('freepay')) {
         awpcp_flash(__('Charge Listing Fee setting was enabled automatically because you activated the Credit System.', 'AWPCP'));
         $options['freepay'] = 1;
     }
     $setting = 'freepay';
     if (isset($options[$setting]) && $options[$setting] == 0 && get_awpcp_option('enable-credit-system')) {
         awpcp_flash(__('Credit System was disabled automatically because you disabled Charge Listing Fee.', 'AWPCP'));
         $options['enable-credit-system'] = 0;
     }
     return $options;
 }