Changeset 2012881
- Timestamp:
- 01/15/2019 06:59:22 PM (7 years ago)
- Location:
- wpbooklist/trunk
- Files:
-
- 5 edited
-
includes/class-wpbooklist-ajax-functions.php (modified) (1 diff)
-
includes/class-wpbooklist-general-functions.php (modified) (2 diffs)
-
includes/classes/class-wpbooklist-show-book-in-colorbox.php (modified) (2 diffs)
-
includes/classes/storytime/class-wpbooklist-storytime.php (modified) (1 diff)
-
wpbooklist.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wpbooklist/trunk/includes/class-wpbooklist-ajax-functions.php
r2010771 r2012881 788 788 789 789 // Now delete the associated WordPress user. 790 $wp_delete_result = wp_delete_user( $wpuserid ); 790 $wp_delete_result = 1; 791 // $wp_delete_result = wp_delete_user( $wpuserid ); 791 792 792 793 wp_die( $custom_delete_result . ' ' . $wp_delete_result ); -
wpbooklist/trunk/includes/class-wpbooklist-general-functions.php
r2010783 r2012881 100 100 $this->date = $utilities_date->wpbooklist_get_date_via_current_time( 'mysql' ); 101 101 102 // First let's check and see that we don't already have a user with the SuperAdmin role. 103 $superadmin = $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . "wpbooklist_jre_users_table WHERE role = 'SuperAdmin'" ); 104 105 // If we don't have a user with the 'SuperAdmin' role, create a new user as a SuperAdmin with the logged-in user's info. 106 if ( null === $superadmin ) { 107 if ( is_user_logged_in() ) { 108 109 $current_user = wp_get_current_user(); 110 if ( ! $current_user->exists() ) { 111 return; 102 // Checking if table exists. 103 $test_name = $wpdb->prefix . 'wpbooklist_jre_users_table'; 104 if ( $test_name === $wpdb->get_var( "SHOW TABLES LIKE '$test_name'" ) ) { 105 106 // First let's check and see that we don't already have a user with the SuperAdmin role. 107 $superadmin = $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . "wpbooklist_jre_users_table WHERE role = 'SuperAdmin'" ); 108 109 // If we don't have a user with the 'SuperAdmin' role, create a new user as a SuperAdmin with the logged-in user's info. 110 if ( null === $superadmin ) { 111 if ( is_user_logged_in() ) { 112 113 $current_user = wp_get_current_user(); 114 if ( ! $current_user->exists() ) { 115 return; 116 } 117 118 // Create the permissions string. 119 $permissions = 'Yes-Yes-Yes-Yes-Yes'; 120 121 $users_save_array = array( 122 'firstname' => $current_user->user_firstname, 123 'lastname' => $current_user->user_lastname, 124 'datecreated' => $this->date, 125 'wpuserid' => $current_user->ID, 126 'email' => $current_user->user_email, 127 'username' => $current_user->user_email, 128 'role' => 'SuperAdmin', 129 'permissions' => $permissions, 130 'libraries' => 'alllibraries', 131 'profileimage' => get_avatar_url( $current_user->ID ), 132 ); 133 134 // Requiring & Calling the file/class that will insert or update our data. 135 require_once CLASS_USERS_DIR . 'class-wpbooklist-save-users-data.php'; 136 $save_class = new WPBOOKLIST_Save_Users_Data( $users_save_array ); 137 $db_write_result = $save_class->wpbooklist_jre_save_users_actual(); 112 138 } 113 114 // Create the permissions string. 115 $permissions = 'Yes-Yes-Yes-Yes-Yes'; 116 117 $users_save_array = array( 118 'firstname' => $current_user->user_firstname, 119 'lastname' => $current_user->user_lastname, 120 'datecreated' => $this->date, 121 'wpuserid' => $current_user->ID, 122 'email' => $current_user->user_email, 123 'username' => $current_user->user_email, 124 'role' => 'SuperAdmin', 125 'permissions' => $permissions, 126 'libraries' => 'alllibraries', 127 'profileimage' => get_avatar_url( $current_user->ID ), 128 ); 129 130 // Requiring & Calling the file/class that will insert or update our data. 131 require_once CLASS_USERS_DIR . 'class-wpbooklist-save-users-data.php'; 132 $save_class = new WPBOOKLIST_Save_Users_Data( $users_save_array ); 133 $db_write_result = $save_class->wpbooklist_jre_save_users_actual(); 134 } 135 } else { 136 137 // If we already have a SuperAdmin, then add this user with a role of null, if they don't already exist. 138 $current_user = wp_get_current_user(); 139 if ( ! $current_user->exists() ) { 140 return; 141 } 142 143 $regularadmin = $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . 'wpbooklist_jre_users_table WHERE wpuserid = ' . $current_user->ID ); 144 145 // add this user if they don't already exist. Limit them to the Default Library, and prevent them from making any Display or Setting changes. 146 if ( null === $regularadmin ) { 147 148 // Create the permissions string. 149 $permissions = 'Yes-Yes-Yes-No-No'; 150 151 $users_save_array = array( 152 'firstname' => $current_user->user_firstname, 153 'lastname' => $current_user->user_lastname, 154 'datecreated' => $this->date, 155 'wpuserid' => $current_user->ID, 156 'email' => $current_user->user_email, 157 'username' => $current_user->user_email, 158 'role' => null, 159 'permissions' => $permissions, 160 'libraries' => '-wp_wpbooklist_jre_saved_book_log', 161 'profileimage' => get_avatar_url( $current_user->ID ), 162 ); 163 164 // Requiring & Calling the file/class that will insert or update our data. 165 require_once CLASS_USERS_DIR . 'class-wpbooklist-save-users-data.php'; 166 $save_class = new WPBOOKLIST_Save_Users_Data( $users_save_array ); 167 $db_write_result = $save_class->wpbooklist_jre_save_users_actual(); 168 } 169 } 139 } 140 141 // Now add all WordPress users as basic wpbooklist users. 142 $all_users = get_users(); 143 foreach ( $all_users as $key => $value ) { 144 145 $regularadmin = $wpdb->get_row( 'SELECT * FROM ' . $wpdb->prefix . 'wpbooklist_jre_users_table WHERE wpuserid = ' . $value->ID ); 146 147 // Add this user if they don't already exist. Limit them to the Default Library, and prevent them from making any Display or Setting changes. 148 if ( null === $regularadmin ) { 149 150 // Create the permissions string. 151 $permissions = 'Yes-Yes-Yes-No-No'; 152 153 $users_save_array = array( 154 'firstname' => $value->user_firstname, 155 'lastname' => $value->user_lastname, 156 'datecreated' => $this->date, 157 'wpuserid' => $value->ID, 158 'email' => $value->user_email, 159 'username' => $value->user_email, 160 'role' => null, 161 'permissions' => $permissions, 162 'libraries' => '-wp_wpbooklist_jre_saved_book_log', 163 'profileimage' => get_avatar_url( $value->ID ), 164 ); 165 166 // Requiring & Calling the file/class that will insert or update our data. 167 require_once CLASS_USERS_DIR . 'class-wpbooklist-save-users-data.php'; 168 $save_class = new WPBOOKLIST_Save_Users_Data( $users_save_array ); 169 $db_write_result = $save_class->wpbooklist_jre_save_users_actual(); 170 171 } 172 } 173 } 174 170 175 } 171 176 … … 1008 1013 * Runs once upon plugin activation and creates the Users tables 1009 1014 */ 1010 public function wpbooklist_ jre_create_user_table() {1015 public function wpbooklist_add_user_table() { 1011 1016 require_once ABSPATH . 'wp-admin/includes/upgrade.php'; 1012 1017 global $wpdb; -
wpbooklist/trunk/includes/classes/class-wpbooklist-show-book-in-colorbox.php
r2010771 r2012881 734 734 } 735 735 736 $ebook_upper_string = ''; 737 if ( has_filter( 'wpbooklist_append_to_colorbox_ebook_download' ) && ( '' !== $this->ebook && null !== $this->ebook ) ) { 738 $ebook_upper_string = apply_filters( 'wpbooklist_append_to_colorbox_ebook_download', $this->ebook ); 739 } 740 736 741 $string20 = ''; 737 742 $string21 = ''; … … 1338 1343 } 1339 1344 1340 $this->output = $string1 . $string2 . $string3 . $string4 . $string5 . $string6 . $string7 . $string8 . $string9 . $string10 . $string11 . $string12 . $string13 . $string14 . $string15 . $string16 . $string17 . $string18 . $string19 . $string20 . $string21 . $string22 . $string92 . $string93 . $string94 . $string23 . $string24 . $string25 . $string26 . $string27 . $string28 . $string95 . $string96 . $string97 . $string29 . $string30 . $string31 . $string39 . $string40 . $string41 . $string32 . $string33 . $string34 . $string35 . $string36 . $string37 . $string38 . $ customfields_basic_string . $customfields_text_link_string . $customfields_dropdown_string . $string42 . $string43 . $customfields_image_link_string . $string44 . $string45 . $string46 . $string47 . $string48 . $string49 . $string50 . $string51 . $string52 . $string53 . $string54 . $string55 . $string84 . $string85 . $string86 . $string87 . $string57 . $string58 . $string59 . $string60 . $string61 . $string62 . $string63 . $string64 . $additional_images . $ebook_string . $comments_string . $string65 . $string66 . $string67 . $string68 . $string69 . $customfields_paragraph_string . $string70 . $string71 . $string72 . $string73 . $string74 . $string75 . $string76 . $string77 . $string78 . $string79 . $string80 . $string81 . $string82 . $string83 . $string88 . $string89 . $string90 . $string91;1345 $this->output = $string1 . $string2 . $string3 . $string4 . $string5 . $string6 . $string7 . $string8 . $string9 . $string10 . $string11 . $string12 . $string13 . $string14 . $string15 . $string16 . $string17 . $string18 . $string19 . $string20 . $string21 . $string22 . $string92 . $string93 . $string94 . $string23 . $string24 . $string25 . $string26 . $string27 . $string28 . $string95 . $string96 . $string97 . $string29 . $string30 . $string31 . $string39 . $string40 . $string41 . $string32 . $string33 . $string34 . $string35 . $string36 . $string37 . $string38 . $ebook_upper_string . $customfields_basic_string . $customfields_text_link_string . $customfields_dropdown_string . $string42 . $string43 . $customfields_image_link_string . $string44 . $string45 . $string46 . $string47 . $string48 . $string49 . $string50 . $string51 . $string52 . $string53 . $string54 . $string55 . $string84 . $string85 . $string86 . $string87 . $string57 . $string58 . $string59 . $string60 . $string61 . $string62 . $string63 . $string64 . $additional_images . $ebook_string . $comments_string . $string65 . $string66 . $string67 . $string68 . $string69 . $customfields_paragraph_string . $string70 . $string71 . $string72 . $string73 . $string74 . $string75 . $string76 . $string77 . $string78 . $string79 . $string80 . $string81 . $string82 . $string83 . $string88 . $string89 . $string90 . $string91; 1341 1346 } 1342 1347 -
wpbooklist/trunk/includes/classes/storytime/class-wpbooklist-storytime.php
r2001745 r2012881 47 47 public function __construct( $action, $category = null, $id = null, $incoming_story_data = null ) { 48 48 49 // Default class-wide variables.50 49 global $wpdb; 51 $this->table = $wpdb->prefix . 'wpbooklist_jre_storytime_stories'; 52 $this->stories_db_data = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'wpbooklist_jre_storytime_stories' ); 53 $this->default_mask_array = array( '%s', '%s', '%s', '%s', '%s', '%s' ); 54 $this->category = $category; 55 $this->id = $id; 56 $this->incoming_story_data = $incoming_story_data; 57 58 if ( 'install' === $action ) { 59 $this->create_default_data(); 60 $this->insert_default_data(); 61 } 62 63 if ( 'categorychange' === $action ) { 64 $this->category_change(); 65 } 66 67 if ( 'getcontent' === $action ) { 68 $this->get_content(); 69 } 70 71 if ( 'createpage' === $action ) { 72 $this->post_type = 'page'; 73 $this->create_page_category(); 74 $this->create_page(); 75 } 76 77 if ( 'createpost' === $action ) { 78 $this->post_type = 'post'; 79 $this->create_post_category(); 80 $this->create_post(); 81 } 82 83 if ( 'frontend_shortcode_output' === $action ) { 84 $this->output_storytime_reader(); 50 51 // Checking if table exists. 52 $test_name = $wpdb->prefix . 'wpbooklist_jre_storytime_stories'; 53 if ( $test_name === $wpdb->get_var( "SHOW TABLES LIKE '$test_name'" ) ) { 54 55 // Default class-wide variables. 56 $this->table = $wpdb->prefix . 'wpbooklist_jre_storytime_stories'; 57 $this->stories_db_data = $wpdb->get_results( 'SELECT * FROM ' . $wpdb->prefix . 'wpbooklist_jre_storytime_stories' ); 58 $this->default_mask_array = array( '%s', '%s', '%s', '%s', '%s', '%s' ); 59 $this->category = $category; 60 $this->id = $id; 61 $this->incoming_story_data = $incoming_story_data; 62 63 if ( 'install' === $action ) { 64 $this->create_default_data(); 65 $this->insert_default_data(); 66 } 67 68 if ( 'categorychange' === $action ) { 69 $this->category_change(); 70 } 71 72 if ( 'getcontent' === $action ) { 73 $this->get_content(); 74 } 75 76 if ( 'createpage' === $action ) { 77 $this->post_type = 'page'; 78 $this->create_page_category(); 79 $this->create_page(); 80 } 81 82 if ( 'createpost' === $action ) { 83 $this->post_type = 'post'; 84 $this->create_post_category(); 85 $this->create_post(); 86 } 87 88 if ( 'frontend_shortcode_output' === $action ) { 89 $this->output_storytime_reader(); 90 } 91 85 92 } 86 93 } -
wpbooklist/trunk/wpbooklist.php
r2001748 r2012881 261 261 add_action( 'init', array( $wp_book_list_general_functions, 'wpbooklist_jre_register_table_name' ) ); 262 262 263 // Creates the WPBookList Users table and the default WPBookList User. 264 register_activation_hook( __FILE__, array( $wp_book_list_general_functions, 'wpbooklist_add_user_table' ) ); 265 263 266 // Records the user's url upon activation. 264 267 register_activation_hook( __FILE__, array( $wp_book_list_general_functions, 'wpbooklist_jre_record_user_url' ) ); … … 299 302 // Creates the one master display options table. 300 303 register_activation_hook( __FILE__, array( $wp_book_list_general_functions, 'wpbooklist_jre_create_storytime_stories_settings_table' ) ); 301 302 // Creates the WPBookList Users table and the default WPBookList User.303 register_activation_hook( __FILE__, array( $wp_book_list_general_functions, 'wpbooklist_jre_create_user_table' ) );304 304 305 305 //
Note: See TracChangeset
for help on using the changeset viewer.