Changeset 1699501
- Timestamp:
- 07/20/2017 09:49:33 AM (9 years ago)
- Location:
- wp-chatbull
- Files:
-
- 6 edited
-
tags/1.0/admin/js/wpcbcp-settings.js (modified) (4 diffs)
-
tags/1.0/files/application/controllers/visitors/Chatbox.php (modified) (2 diffs)
-
tags/1.0/includes/wpcbcp_settings.php (modified) (5 diffs)
-
trunk/admin/js/wpcbcp-settings.js (modified) (4 diffs)
-
trunk/files/application/controllers/visitors/Chatbox.php (modified) (2 diffs)
-
trunk/includes/wpcbcp_settings.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-chatbull/tags/1.0/admin/js/wpcbcp-settings.js
r1688359 r1699501 99 99 100 100 var data = { 101 action: ' install_plugin',101 action: 'wpcbcp_install_plugin', 102 102 settings: $scope.settings 103 103 } … … 125 125 126 126 var data = { 127 action: ' check_n_save',127 action: 'wpcbcp_check_n_save', 128 128 settings: $scope.settings 129 129 } … … 149 149 150 150 var data = { 151 action: ' chack_status',151 action: 'wpcbcp_chack_status', 152 152 settings: $scope.settings 153 153 } … … 179 179 180 180 var data = { 181 action: ' save_settings',181 action: 'wpcbcp_save_settings', 182 182 settings: $scope.settings 183 183 } -
wp-chatbull/tags/1.0/files/application/controllers/visitors/Chatbox.php
r1693664 r1699501 70 70 exit(); 71 71 } 72 72 73 73 /* 74 74 * To check plugin installed and validated. 75 75 */ 76 76 77 function is_installed() { 77 78 $response = array('result' => 'failed'); … … 80 81 $return_token = ($this->input->get('token')) ? $this->input->get('token') : 'no'; 81 82 82 if ($this->config->item('installed') == 'yes' and $this->config->item('validated_code') == 'yes') { 83 if (empty($domain_name)) { 84 $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created for your domain. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>"; 83 if ($this->config->item('installed') == 'yes') { 84 if ($this->config->item('validated_code') == 'yes') { 85 if (empty($domain_name)) { 86 $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created for your domain. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>"; 87 } else { 88 $this->db->like('site_url', $domain_name); 89 $query = $this->db->get($this->token->table); 90 $token = $query->row(); 91 92 if ($token) { 93 $response['result'] = 'success'; 94 $response['message'] = 'Plugin is configured and ready to use.'; 95 if ($return_token == 'yes') { 96 $response['token'] = $token; 97 } 98 } else { 99 $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created yet. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>"; 100 } 101 } 85 102 } else { 86 $this->db->like('site_url', $domain_name); 87 $query = $this->db->get($this->token->table); 88 $token = $query->row(); 89 90 if ($token) { 91 $response['result'] = 'success'; 92 $response['message'] = 'Plugin is configured and ready to use.'; 93 if ($return_token == 'yes') { 94 $response['token'] = $token; 95 } 96 } else { 97 $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created yet. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>"; 98 } 103 $response['errors']['not-validated'] = "Plugin is installed but not validated yet. To validate plugin <a target='_new' href='" . site_url('c=settings') . "'>click here</a>"; 99 104 } 100 105 } else { -
wp-chatbull/tags/1.0/includes/wpcbcp_settings.php
r1688359 r1699501 17 17 public function __construct() { 18 18 if (is_admin()) { 19 add_action('wp_ajax_ install_plugin', array($this, 'install_plugin'));20 add_action('wp_ajax_ check_n_save', array($this, 'check_n_save'));21 add_action('wp_ajax_ chack_status', array($this, 'chack_status'));22 add_action('wp_ajax_ save_settings', array($this, 'save_settings'));19 add_action('wp_ajax_wpcbcp_install_plugin', array($this, 'install_plugin')); 20 add_action('wp_ajax_wpcbcp_check_n_save', array($this, 'check_n_save')); 21 add_action('wp_ajax_wpcbcp_chack_status', array($this, 'chack_status')); 22 add_action('wp_ajax_wpcbcp_save_settings', array($this, 'save_settings')); 23 23 } 24 24 } … … 123 123 if (wp_verify_nonce($data['settings_nonce'], 'settings_nonce_save')) { 124 124 if (empty($gaxon_wpcbcp_chatbull_dir)) { 125 $this->errors['gaxon_wpcbcp_chatbull_dir'] = __('Chatbull Directory field is required.', $this->plugin_domain); 126 } 127 128 if (is_dir($plugin_path)) { 125 $this->errors['directory_name_missing'] = __('Chatbull Directory field is required.', $this->plugin_domain); 126 } elseif (is_dir($plugin_path)) { 129 127 $this->errors['dir-exists'] = __('A directory with name "' . $gaxon_wpcbcp_chatbull_dir . '" already exists. Please remove it or change name.', $this->plugin_domain); 130 128 } else { 129 // Connecting to the filesystem. 130 WP_Filesystem(); 131 132 global $wp_filesystem; 133 131 134 // creating directory 132 $created = wp_mkdir_p($plugin_path);135 $created = $wp_filesystem->mkdir($plugin_path); 133 136 if ($created) { 134 // Connecting to the filesystem.135 WP_Filesystem();136 137 global $wp_filesystem;138 139 137 // Now copy all the files in the source directory to the target directory. 140 if (copy_dir($plugin_files, $plugin_path)) { 138 $copied = copy_dir($plugin_files, $plugin_path); 139 if (is_wp_error($copied)) { 140 $this->errors['gaxon_wpcbcp_chatbull_dir'] = $copied->get_error_message(); 141 } else { 141 142 $this->response['result'] = 'success'; 142 143 $this->response['message'] = __('Chatbull plugin files copied and redirecting you...', $this->plugin_domain); … … 148 149 update_option('gaxon_wpcbcp_chatbull_dir', $gaxon_wpcbcp_chatbull_dir); 149 150 } 151 } else { 152 $this->errors['directory_not_created'] = __('Unable to copy Chatbull files.', $this->plugin_domain); 150 153 } 151 154 } … … 167 170 if (wp_verify_nonce($data['settings_nonce'], 'settings_nonce_save')) { 168 171 if (empty($gaxon_wpcbcp_chatbull_dir)) { 169 $this->errors['gaxon_wpcbcp_chatbull_dir'] = __('Chatbull Directory field is required.', $this->plugin_domain); 170 } 171 172 if (is_dir($plugin_path)) { 172 $this->errors['directory_name_missing'] = __('Chatbull Directory field is required.', $this->plugin_domain); 173 } elseif (is_dir($plugin_path)) { 173 174 $request_url = site_url($gaxon_wpcbcp_chatbull_dir . '/index.php?d=visitors&c=chat&m=get_server_time'); 174 175 $response = wp_remote_get($request_url); … … 186 187 update_option('gaxon_wpcbcp_chatbull_dir', $gaxon_wpcbcp_chatbull_dir); 187 188 } else { 188 $this->errors['invalid-plugin'] = __('Invalid plugin directory .', $this->plugin_domain);189 $this->errors['invalid-plugin'] = __('Invalid plugin directory or invalid response.', $this->plugin_domain); 189 190 } 190 191 } else { -
wp-chatbull/trunk/admin/js/wpcbcp-settings.js
r1688359 r1699501 99 99 100 100 var data = { 101 action: ' install_plugin',101 action: 'wpcbcp_install_plugin', 102 102 settings: $scope.settings 103 103 } … … 125 125 126 126 var data = { 127 action: ' check_n_save',127 action: 'wpcbcp_check_n_save', 128 128 settings: $scope.settings 129 129 } … … 149 149 150 150 var data = { 151 action: ' chack_status',151 action: 'wpcbcp_chack_status', 152 152 settings: $scope.settings 153 153 } … … 179 179 180 180 var data = { 181 action: ' save_settings',181 action: 'wpcbcp_save_settings', 182 182 settings: $scope.settings 183 183 } -
wp-chatbull/trunk/files/application/controllers/visitors/Chatbox.php
r1693664 r1699501 70 70 exit(); 71 71 } 72 72 73 73 /* 74 74 * To check plugin installed and validated. 75 75 */ 76 76 77 function is_installed() { 77 78 $response = array('result' => 'failed'); … … 80 81 $return_token = ($this->input->get('token')) ? $this->input->get('token') : 'no'; 81 82 82 if ($this->config->item('installed') == 'yes' and $this->config->item('validated_code') == 'yes') { 83 if (empty($domain_name)) { 84 $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created for your domain. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>"; 83 if ($this->config->item('installed') == 'yes') { 84 if ($this->config->item('validated_code') == 'yes') { 85 if (empty($domain_name)) { 86 $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created for your domain. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>"; 87 } else { 88 $this->db->like('site_url', $domain_name); 89 $query = $this->db->get($this->token->table); 90 $token = $query->row(); 91 92 if ($token) { 93 $response['result'] = 'success'; 94 $response['message'] = 'Plugin is configured and ready to use.'; 95 if ($return_token == 'yes') { 96 $response['token'] = $token; 97 } 98 } else { 99 $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created yet. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>"; 100 } 101 } 85 102 } else { 86 $this->db->like('site_url', $domain_name); 87 $query = $this->db->get($this->token->table); 88 $token = $query->row(); 89 90 if ($token) { 91 $response['result'] = 'success'; 92 $response['message'] = 'Plugin is configured and ready to use.'; 93 if ($return_token == 'yes') { 94 $response['token'] = $token; 95 } 96 } else { 97 $response['errors']['widget-not-created'] = "Plugin is installed but chatbox widget is not created yet. To create chatbox widget <a target='_new' href='" . site_url('c=settings') . "'>click here</a>"; 98 } 103 $response['errors']['not-validated'] = "Plugin is installed but not validated yet. To validate plugin <a target='_new' href='" . site_url('c=settings') . "'>click here</a>"; 99 104 } 100 105 } else { -
wp-chatbull/trunk/includes/wpcbcp_settings.php
r1688359 r1699501 17 17 public function __construct() { 18 18 if (is_admin()) { 19 add_action('wp_ajax_ install_plugin', array($this, 'install_plugin'));20 add_action('wp_ajax_ check_n_save', array($this, 'check_n_save'));21 add_action('wp_ajax_ chack_status', array($this, 'chack_status'));22 add_action('wp_ajax_ save_settings', array($this, 'save_settings'));19 add_action('wp_ajax_wpcbcp_install_plugin', array($this, 'install_plugin')); 20 add_action('wp_ajax_wpcbcp_check_n_save', array($this, 'check_n_save')); 21 add_action('wp_ajax_wpcbcp_chack_status', array($this, 'chack_status')); 22 add_action('wp_ajax_wpcbcp_save_settings', array($this, 'save_settings')); 23 23 } 24 24 } … … 123 123 if (wp_verify_nonce($data['settings_nonce'], 'settings_nonce_save')) { 124 124 if (empty($gaxon_wpcbcp_chatbull_dir)) { 125 $this->errors['gaxon_wpcbcp_chatbull_dir'] = __('Chatbull Directory field is required.', $this->plugin_domain); 126 } 127 128 if (is_dir($plugin_path)) { 125 $this->errors['directory_name_missing'] = __('Chatbull Directory field is required.', $this->plugin_domain); 126 } elseif (is_dir($plugin_path)) { 129 127 $this->errors['dir-exists'] = __('A directory with name "' . $gaxon_wpcbcp_chatbull_dir . '" already exists. Please remove it or change name.', $this->plugin_domain); 130 128 } else { 129 // Connecting to the filesystem. 130 WP_Filesystem(); 131 132 global $wp_filesystem; 133 131 134 // creating directory 132 $created = wp_mkdir_p($plugin_path);135 $created = $wp_filesystem->mkdir($plugin_path); 133 136 if ($created) { 134 // Connecting to the filesystem.135 WP_Filesystem();136 137 global $wp_filesystem;138 139 137 // Now copy all the files in the source directory to the target directory. 140 if (copy_dir($plugin_files, $plugin_path)) { 138 $copied = copy_dir($plugin_files, $plugin_path); 139 if (is_wp_error($copied)) { 140 $this->errors['gaxon_wpcbcp_chatbull_dir'] = $copied->get_error_message(); 141 } else { 141 142 $this->response['result'] = 'success'; 142 143 $this->response['message'] = __('Chatbull plugin files copied and redirecting you...', $this->plugin_domain); … … 148 149 update_option('gaxon_wpcbcp_chatbull_dir', $gaxon_wpcbcp_chatbull_dir); 149 150 } 151 } else { 152 $this->errors['directory_not_created'] = __('Unable to copy Chatbull files.', $this->plugin_domain); 150 153 } 151 154 } … … 167 170 if (wp_verify_nonce($data['settings_nonce'], 'settings_nonce_save')) { 168 171 if (empty($gaxon_wpcbcp_chatbull_dir)) { 169 $this->errors['gaxon_wpcbcp_chatbull_dir'] = __('Chatbull Directory field is required.', $this->plugin_domain); 170 } 171 172 if (is_dir($plugin_path)) { 172 $this->errors['directory_name_missing'] = __('Chatbull Directory field is required.', $this->plugin_domain); 173 } elseif (is_dir($plugin_path)) { 173 174 $request_url = site_url($gaxon_wpcbcp_chatbull_dir . '/index.php?d=visitors&c=chat&m=get_server_time'); 174 175 $response = wp_remote_get($request_url); … … 186 187 update_option('gaxon_wpcbcp_chatbull_dir', $gaxon_wpcbcp_chatbull_dir); 187 188 } else { 188 $this->errors['invalid-plugin'] = __('Invalid plugin directory .', $this->plugin_domain);189 $this->errors['invalid-plugin'] = __('Invalid plugin directory or invalid response.', $this->plugin_domain); 189 190 } 190 191 } else {
Note: See TracChangeset
for help on using the changeset viewer.