Changeset 2688856
- Timestamp:
- 03/04/2022 11:46:14 AM (4 years ago)
- Location:
- wp-cassify/trunk
- Files:
-
- 3 edited
-
admin/admin-menu.php (modified) (7 diffs)
-
classes/wp_cassify_plugin.php (modified) (10 diffs)
-
classes/wp_cassify_utils.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-cassify/trunk/admin/admin-menu.php
r2287310 r2688856 1226 1226 1227 1227 // General settings 1228 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_base_url', FALSE, $this->wp_cassify_network_activated);1229 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_protocol_version', FALSE, $this->wp_cassify_network_activated);1228 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_base_url', $this->wp_cassify_network_activated, FALSE ); 1229 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_protocol_version', $this->wp_cassify_network_activated, FALSE ); 1230 1230 WP_Cassify_Utils::wp_cassify_update_checkbox( $_POST, 'wp_cassify_disable_authentication', 'disabled', $this->wp_cassify_network_activated ); 1231 1231 WP_Cassify_Utils::wp_cassify_update_checkbox( $_POST, 'wp_cassify_create_user_if_not_exist', 'create_user_if_not_exist', $this->wp_cassify_network_activated ); … … 1236 1236 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_ssl_cipher', TRUE, $this->wp_cassify_network_activated ); 1237 1237 WP_Cassify_Utils::wp_cassify_update_checkbox( $_POST, 'wp_cassify_ssl_check_certificate', 'enabled', $this->wp_cassify_network_activated ); 1238 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_curlopt_cainfo', FALSE, $this->wp_cassify_network_activated);1239 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_curlopt_capath', FALSE, $this->wp_cassify_network_activated);1238 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_curlopt_cainfo', $this->wp_cassify_network_activated, FALSE ); 1239 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_curlopt_capath', $this->wp_cassify_network_activated, FALSE ); 1240 1240 1241 1241 // Url settings 1242 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_redirect_url_after_logout', FALSE, $this->wp_cassify_network_activated);1243 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_override_service_url', FALSE, $this->wp_cassify_network_activated);1244 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_login_servlet', FALSE, $this->wp_cassify_network_activated);1245 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_logout_servlet', FALSE, $this->wp_cassify_network_activated);1242 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_redirect_url_after_logout', $this->wp_cassify_network_activated, FALSE ); 1243 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_override_service_url', $this->wp_cassify_network_activated, FALSE ); 1244 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_login_servlet', $this->wp_cassify_network_activated, FALSE ); 1245 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_logout_servlet', $this->wp_cassify_network_activated, FALSE ); 1246 1246 1247 1247 if ( $_POST[ 'wp_cassify_protocol_version' ] == '3' ) { … … 1261 1261 1262 1262 // Attributes extraction settings 1263 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_xpath_query_to_extact_cas_user', FALSE, $this->wp_cassify_network_activated);1264 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_xpath_query_to_extact_cas_attributes', FALSE, $this->wp_cassify_network_activated);1265 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_attributes_list', FALSE, $this->wp_cassify_network_activated);1263 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_xpath_query_to_extact_cas_user', $this->wp_cassify_network_activated, FALSE ); 1264 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_xpath_query_to_extact_cas_attributes', $this->wp_cassify_network_activated, FALSE ); 1265 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_attributes_list', $this->wp_cassify_network_activated, FALSE ); 1266 1266 1267 1267 // Authorization rules settings 1268 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_allow_deny_order', FALSE, $this->wp_cassify_network_activated);1268 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_allow_deny_order', $this->wp_cassify_network_activated, FALSE ); 1269 1269 WP_Cassify_Utils::wp_cassify_update_multiple_select( $_POST, 'wp_cassify_autorization_rules', $this->wp_cassify_network_activated ); 1270 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_redirect_url_if_not_allowed', FALSE, $this->wp_cassify_network_activated);1271 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_redirect_url_white_list', FALSE, $this->wp_cassify_network_activated);1270 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_redirect_url_if_not_allowed', $this->wp_cassify_network_activated, FALSE ); 1271 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_redirect_url_white_list', $this->wp_cassify_network_activated, FALSE ); 1272 1272 1273 1273 // User roles rules settings … … 1279 1279 1280 1280 // Notification settings 1281 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_smtp_host', FALSE, $this->wp_cassify_network_activated);1282 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_smtp_port', FALSE, $this->wp_cassify_network_activated);1283 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_encryption_type', FALSE, $this->wp_cassify_network_activated);1281 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_smtp_host', $this->wp_cassify_network_activated, FALSE ); 1282 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_smtp_port', $this->wp_cassify_network_activated, FALSE ); 1283 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_encryption_type', $this->wp_cassify_network_activated, FALSE ); 1284 1284 WP_Cassify_Utils::wp_cassify_update_checkbox( $_POST, 'wp_cassify_notifications_smtp_auth', 'enabled', $this->wp_cassify_network_activated ); 1285 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_salt', FALSE, $this->wp_cassify_network_activated);1286 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_priority', FALSE, $this->wp_cassify_network_activated);1287 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_smtp_user', FALSE, $this->wp_cassify_network_activated);1285 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_salt', $this->wp_cassify_network_activated, FALSE ); 1286 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_priority', $this->wp_cassify_network_activated, FALSE ); 1287 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_smtp_user', $this->wp_cassify_network_activated, FALSE ); 1288 1288 1289 1289 // Store smtp password as encrypted string … … 1311 1311 } 1312 1312 1313 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_smtp_from', FALSE, $this->wp_cassify_network_activated);1314 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_smtp_to', FALSE, $this->wp_cassify_network_activated);1315 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_subject_prefix', FALSE, $this->wp_cassify_network_activated);1313 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_smtp_from', $this->wp_cassify_network_activated, FALSE ); 1314 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_smtp_to', $this->wp_cassify_network_activated, FALSE ); 1315 WP_Cassify_Utils::wp_cassify_update_textfield( $_POST, 'wp_cassify_notifications_subject_prefix', $this->wp_cassify_network_activated, FALSE ); 1316 1316 1317 1317 // Notifications rules settings … … 1370 1370 $wp_cassify_notifications_priority, 1371 1371 esc_attr( WP_Cassify_Utils::wp_cassify_get_option( $this->wp_cassify_network_activated, 'wp_cassify_notifications_smtp_host' ) ), 1372 esc_attr( WP_Cassify_Utils::wp_cassify_get_option( $this->wp_cassify_network_activated, 'wp_cassify_notifications_smtp_port' ) ),1373 $wp_cassify_notifications_smtp_auth_enabled,1374 1372 $wp_cassify_notifications_encryption_type, 1375 1373 $wp_cassify_notifications_smtp_user, 1376 $wp_cassify_notifications_smtp_password 1374 $wp_cassify_notifications_smtp_password, 1375 esc_attr( WP_Cassify_Utils::wp_cassify_get_option( $this->wp_cassify_network_activated, 'wp_cassify_notifications_smtp_port' ) ), 1376 $wp_cassify_notifications_smtp_auth_enabled 1377 1377 ); 1378 1378 … … 1509 1509 1510 1510 WP_Cassify_Utils::wp_cassify_import_configuration_options( 1511 $ wp_cassify_import_configuration_options,1512 $ this->wp_cassify_network_activated1511 $this->wp_cassify_network_activated, 1512 $wp_cassify_import_configuration_options 1513 1513 ); 1514 1514 -
wp-cassify/trunk/classes/wp_cassify_plugin.php
r2688825 r2688856 446 446 447 447 // Force logout if user is not allowed. 448 if (! $this->wp_cassify_is_user_allowed( $ cas_user_datas, $wp_cassify_allow_deny_order) ) {448 if (! $this->wp_cassify_is_user_allowed( $wp_cassify_allow_deny_order, $cas_user_datas ) ) { 449 449 $this->wp_cassify_logout_if_not_allowed( 'user_is_not_allowed' ); 450 450 } … … 506 506 507 507 // Set wordpress user roles if defined in plugin admin settings 508 $roles_to_push = $this->wp_cassify_get_roles_to_push( $c as_user_datas, $wp_cassify_user_role_rules, $this->wp_cassify_network_activated, $current_blog_id);508 $roles_to_push = $this->wp_cassify_get_roles_to_push( $current_blog_id, $cas_user_datas, $wp_cassify_user_role_rules, $this->wp_cassify_network_activated ); 509 509 510 510 // Define custom plugin filter to override list roles to push. … … 1148 1148 /** 1149 1149 * Check if user is allow to connect according to autorization rules. 1150 * @param array $cas_user_datas Associative array containing CAS userID and attributes 1151 * @param string $wp_cassify_allow_deny_order Order to process authorization rules. 1152 * @return bool $is_user_allowed Return true if user is allowed to connect. Return false on the other hand. 1153 */ 1154 private function wp_cassify_is_user_allowed( $cas_user_datas = array(), $wp_cassify_allow_deny_order ) { 1150 * 1151 * @param string $wp_cassify_allow_deny_order Order to process authorization rules. 1152 * @param array $cas_user_datas Associative array containing CAS userID and attributes 1153 * 1154 * @return bool $is_user_allowed Return true if user is allowed to connect. Return false on the other hand. 1155 */ 1156 private function wp_cassify_is_user_allowed( $wp_cassify_allow_deny_order, $cas_user_datas = array() ) { 1155 1157 1156 1158 $is_user_allowed = false; … … 1225 1227 /** 1226 1228 * Check if user is matched by Conditionnal Rule 1229 * 1230 * @param string $wp_cassify_rule WP Cassify rule 1227 1231 * @param array $cas_user_datas Associative array containing CAS userID and attributes 1228 * @param string $wp_cassify_rule WP Cassify rule1232 * 1229 1233 * @return bool $rule_matched Return true if WP Cassify rule assertion is verified. Return false on the other hand. 1230 1234 */ 1231 private function wp_cassify_rule_matched( $ cas_user_datas = array(), $wp_cassify_rule) {1235 private function wp_cassify_rule_matched( $wp_cassify_rule, $cas_user_datas = array() ) { 1232 1236 1233 1237 $rule_matched = false; … … 1268 1272 $expiration_rule_value = stripslashes( $expiration_rule_parts[2] ); 1269 1273 1270 if ( $this->wp_cassify_rule_matched( $ cas_user_datas, $expiration_rule_value) ) {1274 if ( $this->wp_cassify_rule_matched( $expiration_rule_value, $cas_user_datas ) ) { 1271 1275 1272 1276 switch( $expiration_rule_type ) { … … 1298 1302 /** 1299 1303 * Check if user is matched by Notification Rule 1304 * 1305 * @param int $current_blog_id The id of the current blog 1300 1306 * @param array $cas_user_datas Associative array containing CAS userID and attributes 1301 1307 * @param array $role_rules Array containing all role rules 1302 1308 * @param bool $network_activated True if plugin is activated over the network 1303 * @param int $current_blog_id The id of the current blog1309 * 1304 1310 * @return array $roles_to_push Array containing roles to push to user 1305 1311 */ 1306 private function wp_cassify_get_roles_to_push( $c as_user_datas = array(), $role_rules = array(), $network_activated = false, $current_blog_id) {1312 private function wp_cassify_get_roles_to_push( $current_blog_id, $cas_user_datas = array(), $role_rules = array(), $network_activated = false ) { 1307 1313 1308 1314 $roles_to_push = array(); … … 1321 1327 // role_rule_blog_id == 0 match "ALL BLOGS" 1322 1328 if ( ( $role_rule_blog_id == $current_blog_id ) || ( $role_rule_blog_id == 0 ) ) { 1323 if ( $this->wp_cassify_rule_matched( $ cas_user_datas, $role_rule_expression) ) {1329 if ( $this->wp_cassify_rule_matched( $role_rule_expression, $cas_user_datas ) ) { 1324 1330 array_push( $roles_to_push, $role_rule_key ); 1325 1331 } … … 1332 1338 $role_rule_expression = stripslashes( $role_rule_parts[1] ); 1333 1339 1334 if ( $this->wp_cassify_rule_matched( $ cas_user_datas, $role_rule_expression) ) {1340 if ( $this->wp_cassify_rule_matched( $role_rule_expression, $cas_user_datas ) ) { 1335 1341 array_push( $roles_to_push, $role_rule_key ); 1336 1342 } … … 1363 1369 1364 1370 if ( $notification_rule_key == $trigger_name ) { 1365 if ( $this->wp_cassify_rule_matched( $ cas_user_datas, $notification_rule_expression) ) {1371 if ( $this->wp_cassify_rule_matched( $notification_rule_expression, $cas_user_datas ) ) { 1366 1372 $notification_rule_matched = true; 1367 1373 } … … 1502 1508 $wp_cassify_notifications_priority, 1503 1509 esc_attr( WP_Cassify_Utils::wp_cassify_get_option( $this->wp_cassify_network_activated, 'wp_cassify_notifications_smtp_host' ) ), 1510 $wp_cassify_notifications_encryption_type, 1511 $wp_cassify_notifications_smtp_user, 1512 $wp_cassify_notifications_smtp_password, 1504 1513 esc_attr( WP_Cassify_Utils::wp_cassify_get_option( $this->wp_cassify_network_activated, 'wp_cassify_notifications_smtp_port' ) ), 1505 1514 $wp_cassify_notifications_smtp_auth_enabled, 1506 $wp_cassify_notifications_encryption_type,1507 $wp_cassify_notifications_smtp_user,1508 $wp_cassify_notifications_smtp_password1509 1515 ); 1510 1516 -
wp-cassify/trunk/classes/wp_cassify_utils.php
r2248092 r2688856 424 424 /** 425 425 * Save plugin options stored in form textfield into database. 426 * 426 427 * @param array $post_array $_POST array passed by reference 427 428 * @param string $field_name Form field name. 429 * @param bool $network_activated TRUE if plugin is activated on network. false if not. 428 430 * @param bool $do_not_check_empty Empty values are accepted. 429 * @param bool $network_activated TRUE if plugin is activated on network. false if not.430 431 */ 431 public static function wp_cassify_update_textfield( &$post_array, $field_name, $ do_not_check_empty = false, $wp_cassify_network_activated) {432 public static function wp_cassify_update_textfield( &$post_array, $field_name, $wp_cassify_network_activated, $do_not_check_empty = false ) { 432 433 433 434 $field_value = ''; … … 595 596 /** 596 597 * Import all plugins configuration options 598 * 599 * @param bool $wp_cassify_network_activated 597 600 * @param array $wp_cassify_import_configuration_options 598 * @param bool $wp_cassify_network_activated599 601 */ 600 public static function wp_cassify_import_configuration_options( $wp_cassify_ import_configuration_options = array(), $wp_cassify_network_activated) {602 public static function wp_cassify_import_configuration_options( $wp_cassify_network_activated, $wp_cassify_import_configuration_options = array() ) { 601 603 602 604 global $wpdb; … … 627 629 /** 628 630 * Function used by plugin to send mail. 631 * 629 632 * @param string $from Sender email address 630 633 * @param string $to Recipient email address … … 632 635 * @param string $body Body message 633 636 * @param string $smtp_host Ip or fqdn of smtp host 637 * @param string $smtp_password Smtp password 638 * @return bool $send_result Return TRUE if mail is sended correctly. FAIL if not. 634 639 * @param string $smtp_port Port used by smtp host 635 640 * @param string $smtp_auth Cipher used if authentication 636 * @param string $smtp_password Smtp password 637 * @return bool $send_result Return TRUE if mail is sended correctly. FAIL if not. 638 */ 639 public static function wp_cassify_sendmail( $from, $to, $subject, $body, $priority, $smtp_host, $smtp_port = 25, $smtp_auth = false, $smtp_encryption_type, $smtp_user, $smtp_password ) { 641 */ 642 public static function wp_cassify_sendmail( $from, $to, $subject, $body, $priority, $smtp_host, $smtp_encryption_type, $smtp_user, $smtp_password, $smtp_port = 25, $smtp_auth = false ) { 640 643 641 644 // Initialize phpmailer class
Note: See TracChangeset
for help on using the changeset viewer.