Convert tabs to spaces in 3 files
Showing
3 changed files
with
323 additions
and
328 deletions
| ... | @@ -17,54 +17,54 @@ const ADMIN_PAGE = "canspam_admin"; | ... | @@ -17,54 +17,54 @@ const ADMIN_PAGE = "canspam_admin"; |
| 17 | $role->add_cap(CAPABILITY); | 17 | $role->add_cap(CAPABILITY); |
| 18 | $role->add_cap(MANAGE_SYSTEM_NOTIFICATIONS); | 18 | $role->add_cap(MANAGE_SYSTEM_NOTIFICATIONS); |
| 19 | //$role->remove_cap(SUB_ADMIN_CAPABILITY); | 19 | //$role->remove_cap(SUB_ADMIN_CAPABILITY); |
| 20 | 20 | ||
| 21 | Vars::$settings = new Tools\WP_Option(SETTING_NS); | 21 | Vars::$settings = new Tools\WP_Option(SETTING_NS); |
| 22 | 22 | ||
| 23 | Tools\add_actions(__NAMESPACE__ . '\Actions'); | 23 | Tools\add_actions(__NAMESPACE__ . '\Actions'); |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | }); | 27 | }); |
| 28 | 28 | ||
| 29 | function display_page() { | 29 | function display_page() { |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | if (isset($_GET['action']) && $_GET['action']=="edit") { | 32 | if (isset($_GET['action']) && $_GET['action']=="edit") { |
| 33 | global $wpdb; | 33 | global $wpdb; |
| 34 | 34 | ||
| 35 | $entry = get_post($_GET['page_id']); | 35 | $entry = get_post($_GET['page_id']); |
| 36 | 36 | ||
| 37 | $id = $entry->ID; | 37 | $id = $entry->ID; |
| 38 | 38 | ||
| 39 | $details = get_post_meta($id,'details',true); | 39 | $details = get_post_meta($id,'details',true); |
| 40 | $email = get_post_meta($id,'email',true); | 40 | $email = get_post_meta($id,'email',true); |
| 41 | $system = get_post_meta($id,'system',true); | 41 | $system = get_post_meta($id,'system',true); |
| 42 | 42 | ||
| 43 | $entry->details = $details; | 43 | $entry->details = $details; |
| 44 | $entry->email = $email; | 44 | $entry->email = $email; |
| 45 | $entry->system = $system; | 45 | $entry->system = $system; |
| 46 | 46 | ||
| 47 | // here | 47 | // here |
| 48 | $validation = new Notifications\Validation; | 48 | $validation = new Notifications\Validation; |
| 49 | 49 | ||
| 50 | $validation->set_rules('type','Notification Type','required'); | 50 | $validation->set_rules('type','Notification Type','required'); |
| 51 | $validation->set_rules('title','Description','trim|required|min_length[4]'); | 51 | $validation->set_rules('title','Description','trim|required|min_length[4]'); |
| 52 | $validation->set_rules('type','Notification Type','required'); | 52 | $validation->set_rules('type','Notification Type','required'); |
| 53 | $validation->set_rules('sendto','Send To','required'); | 53 | $validation->set_rules('sendto','Send To','required'); |
| 54 | 54 | ||
| 55 | $type_val = ($_POST && $_POST['type'] == "scheduled") ? 'required' : ''; | 55 | $type_val = ($_POST && $_POST['type'] == "scheduled") ? 'required' : ''; |
| 56 | $validation->set_rules('execute_date','Execute Date', $type_val); | 56 | $validation->set_rules('execute_date','Execute Date', $type_val); |
| 57 | 57 | ||
| 58 | $trigger_val = ($_POST && $_POST['type'] == "triggered") ? 'required' : ''; | 58 | $trigger_val = ($_POST && $_POST['type'] == "triggered") ? 'required' : ''; |
| 59 | $validation->set_rules('trigger','Trigger',$trigger_val); | 59 | $validation->set_rules('trigger','Trigger',$trigger_val); |
| 60 | 60 | ||
| 61 | $validation->set_rules('subject','Subject','trim'); | 61 | $validation->set_rules('subject','Subject','trim'); |
| 62 | $validation->set_rules('text','Text Version','trim|min_length[16]'); | 62 | $validation->set_rules('text','Text Version','trim|min_length[16]'); |
| 63 | $validation->set_rules('html','HTML Version','trim|min_length[16]'); | 63 | $validation->set_rules('html','HTML Version','trim|min_length[16]'); |
| 64 | 64 | ||
| 65 | $validation->set_rules('system_message_type','System Message Type','trim'); | 65 | $validation->set_rules('system_message_type','System Message Type','trim'); |
| 66 | $validation->set_rules('system','System Message','trim|min_length[16]'); | 66 | $validation->set_rules('system','System Message','trim|min_length[16]'); |
| 67 | 67 | ||
| 68 | 68 | ||
| 69 | //details | 69 | //details |
| 70 | if ($validation->run() == TRUE) { | 70 | if ($validation->run() == TRUE) { |
| ... | @@ -77,7 +77,7 @@ function display_page() { | ... | @@ -77,7 +77,7 @@ function display_page() { |
| 77 | $sendto = $_POST['sendto']; | 77 | $sendto = $_POST['sendto']; |
| 78 | $execute_date = ($type=="scheduled") ? $_POST['execute_date'] : "0000-00-00 00:00:00"; | 78 | $execute_date = ($type=="scheduled") ? $_POST['execute_date'] : "0000-00-00 00:00:00"; |
| 79 | $trigger = ($type=="scheduled") ? "scheduled-cron-job" : $_POST['trigger']; | 79 | $trigger = ($type=="scheduled") ? "scheduled-cron-job" : $_POST['trigger']; |
| 80 | 80 | ||
| 81 | 81 | ||
| 82 | $subject = $_POST['subject']; | 82 | $subject = $_POST['subject']; |
| 83 | $text = $_POST['text']; | 83 | $text = $_POST['text']; |
| ... | @@ -87,22 +87,20 @@ function display_page() { | ... | @@ -87,22 +87,20 @@ function display_page() { |
| 87 | fixFilesArray($_FILES['attachment']); | 87 | fixFilesArray($_FILES['attachment']); |
| 88 | foreach ($_FILES['attachment'] as $position => $file) { | 88 | foreach ($_FILES['attachment'] as $position => $file) { |
| 89 | // should output array with indices name, type, tmp_name, error, size | 89 | // should output array with indices name, type, tmp_name, error, size |
| 90 | if($file['name'] != "") { | 90 | if($file['name'] != "") { |
| 91 | move_uploaded_file($file['tmp_name'],$upload_dir . $file['name']); | 91 | move_uploaded_file($file['tmp_name'],$upload_dir . $file['name']); |
| 92 | $attachments[] = $file['name']; | 92 | $attachments[] = $file['name']; |
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | // system | 96 | // system |
| 97 | $system_message_type = $_POST['system_message_type']; | 97 | $system_message_type = $_POST['system_message_type']; |
| 98 | $system = $_POST['system']; | 98 | $system = $_POST['system']; |
| 99 | 99 | ||
| 100 | |||
| 101 | |||
| 102 | update_post_meta($id, 'notif_type', $type); | 100 | update_post_meta($id, 'notif_type', $type); |
| 103 | update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($execute_date)); | 101 | update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($execute_date)); |
| 104 | update_post_meta($id, 'trigger', $trigger); | 102 | update_post_meta($id, 'trigger', $trigger); |
| 105 | 103 | ||
| 106 | update_post_meta($id, "details", array( | 104 | update_post_meta($id, "details", array( |
| 107 | 'type' => $type | 105 | 'type' => $type |
| 108 | , 'sendto' => $sendto | 106 | , 'sendto' => $sendto |
| ... | @@ -110,13 +108,13 @@ function display_page() { | ... | @@ -110,13 +108,13 @@ function display_page() { |
| 110 | , 'trigger' => $trigger | 108 | , 'trigger' => $trigger |
| 111 | , 'execute_date' => $execute_date | 109 | , 'execute_date' => $execute_date |
| 112 | )); | 110 | )); |
| 113 | 111 | ||
| 114 | update_post_meta($id,'send_status',$entry->details['status']); | 112 | update_post_meta($id,'send_status',$entry->details['status']); |
| 115 | 113 | ||
| 116 | if ( count( $entry->email['attachments'] ) > 0 ) { | 114 | if ( count( $entry->email['attachments'] ) > 0 ) { |
| 117 | $attachments = array_merge($entry->email['attachments'], $attachments); | 115 | $attachments = array_merge($entry->email['attachments'], $attachments); |
| 118 | } | 116 | } |
| 119 | 117 | ||
| 120 | update_post_meta($id, "email", array( | 118 | update_post_meta($id, "email", array( |
| 121 | 'subject' => $subject | 119 | 'subject' => $subject |
| 122 | , 'text' => $text | 120 | , 'text' => $text |
| ... | @@ -127,56 +125,56 @@ function display_page() { | ... | @@ -127,56 +125,56 @@ function display_page() { |
| 127 | 'system_message_type' => $system_message_type | 125 | 'system_message_type' => $system_message_type |
| 128 | , 'message' => $system | 126 | , 'message' => $system |
| 129 | )); | 127 | )); |
| 130 | 128 | ||
| 131 | 129 | ||
| 132 | $update = array(); | 130 | $update = array(); |
| 133 | $update['ID'] = $id; | 131 | $update['ID'] = $id; |
| 134 | $update['post_title'] = $title; | 132 | $update['post_title'] = $title; |
| 135 | wp_update_post($update); | 133 | wp_update_post($update); |
| 136 | 134 | ||
| 137 | $id = $entry->ID; | 135 | $id = $entry->ID; |
| 138 | 136 | ||
| 139 | $details = get_post_meta($id,'details',true); | 137 | $details = get_post_meta($id,'details',true); |
| 140 | $email = get_post_meta($id,'email',true); | 138 | $email = get_post_meta($id,'email',true); |
| 141 | $system = get_post_meta($id,'system',true); | 139 | $system = get_post_meta($id,'system',true); |
| 142 | 140 | ||
| 143 | 141 | ||
| 144 | $entry->details = $details; | 142 | $entry->details = $details; |
| 145 | $entry->email = $email; | 143 | $entry->email = $email; |
| 146 | $entry->system = $system; | 144 | $entry->system = $system; |
| 147 | 145 | ||
| 148 | 146 | ||
| 149 | 147 | ||
| 150 | $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; | 148 | $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; |
| 151 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'form.php'); | 149 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'form.php'); |
| 152 | } else { | 150 | } else { |
| 153 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'form.php'); | 151 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'form.php'); |
| 154 | } | 152 | } |
| 155 | 153 | ||
| 156 | 154 | ||
| 157 | 155 | ||
| 158 | } else { | 156 | } else { |
| 159 | 157 | ||
| 160 | if (isset($_GET['action']) && $_GET['action']=="delete") { | 158 | if (isset($_GET['action']) && $_GET['action']=="delete") { |
| 161 | wp_delete_post($_GET['page_id'],true); | 159 | wp_delete_post($_GET['page_id'],true); |
| 162 | 160 | ||
| 163 | } elseif (isset($_GET['action']) && $_GET['action']=="archive") { | 161 | } elseif (isset($_GET['action']) && $_GET['action']=="archive") { |
| 164 | 162 | ||
| 165 | $id = $_GET['page_id']; | 163 | $id = $_GET['page_id']; |
| 166 | 164 | ||
| 167 | $postdata = get_post_meta($id,'details',true); | 165 | $postdata = get_post_meta($id,'details',true); |
| 168 | $postdata['status'] = "archived"; | 166 | $postdata['status'] = "archived"; |
| 169 | 167 | ||
| 170 | update_post_meta($id,'details',$postdata); | 168 | update_post_meta($id,'details',$postdata); |
| 171 | update_post_meta($id,'send_status',$postdata['status']); | 169 | update_post_meta($id,'send_status',$postdata['status']); |
| 172 | } | 170 | } |
| 173 | 171 | ||
| 174 | 172 | ||
| 175 | // get all the notifications that status != "archived"; | 173 | // get all the notifications that status != "archived"; |
| 176 | $notifications = array(); | 174 | $notifications = array(); |
| 177 | $notifications['triggered'] = array(); | 175 | $notifications['triggered'] = array(); |
| 178 | $notifications['scheduled'] = array(); | 176 | $notifications['scheduled'] = array(); |
| 179 | 177 | ||
| 180 | $args = array( | 178 | $args = array( |
| 181 | 'post_type' => 'notifications' | 179 | 'post_type' => 'notifications' |
| 182 | , 'numberposts' => -1 | 180 | , 'numberposts' => -1 |
| ... | @@ -186,45 +184,45 @@ function display_page() { | ... | @@ -186,45 +184,45 @@ function display_page() { |
| 186 | , 'meta_compare' => '=' | 184 | , 'meta_compare' => '=' |
| 187 | , 'meta_value' => 'pending' | 185 | , 'meta_value' => 'pending' |
| 188 | ); | 186 | ); |
| 189 | 187 | ||
| 190 | $entries = get_posts($args); | 188 | $entries = get_posts($args); |
| 191 | 189 | ||
| 192 | 190 | ||
| 193 | 191 | ||
| 194 | foreach($entries as $entry) { | 192 | foreach($entries as $entry) { |
| 195 | $id = $entry->ID; | 193 | $id = $entry->ID; |
| 196 | 194 | ||
| 197 | $details = get_post_meta($id,'details',true); | 195 | $details = get_post_meta($id,'details',true); |
| 198 | $email = get_post_meta($id,'email',true); | 196 | $email = get_post_meta($id,'email',true); |
| 199 | $system = get_post_meta($id,'system',true); | 197 | $system = get_post_meta($id,'system',true); |
| 200 | 198 | ||
| 201 | 199 | ||
| 202 | $entry->trigger = $details['trigger']; | 200 | $entry->trigger = $details['trigger']; |
| 203 | $entry->status = isset($details['status']) ? $details['status'] : "active"; | 201 | $entry->status = isset($details['status']) ? $details['status'] : "active"; |
| 204 | $entry->type = $details['type']; | 202 | $entry->type = $details['type']; |
| 205 | $entry->sendto = $details['sendto']; | 203 | $entry->sendto = $details['sendto']; |
| 206 | 204 | ||
| 207 | $entry->is_email = (($email['text'] != "" || $email['html'] != "")) ? true : false; | 205 | $entry->is_email = (($email['text'] != "" || $email['html'] != "")) ? true : false; |
| 208 | $entry->is_system = (isset($system['message']) && $system['message'] != "") ? true : false; | 206 | $entry->is_system = (isset($system['message']) && $system['message'] != "") ? true : false; |
| 209 | 207 | ||
| 210 | 208 | ||
| 211 | $entry->execute_date = $details['execute_date']; | 209 | $entry->execute_date = $details['execute_date']; |
| 212 | 210 | ||
| 213 | if ($entry->status != "archived") { | 211 | if ($entry->status != "archived") { |
| 214 | $notifications[$entry->type][] = $entry; | 212 | $notifications[$entry->type][] = $entry; |
| 215 | } | 213 | } |
| 216 | 214 | ||
| 217 | 215 | ||
| 218 | } | 216 | } |
| 219 | 217 | ||
| 220 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin.php'); | 218 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin.php'); |
| 221 | |||
| 222 | |||
| 223 | |||
| 224 | } | ||
| 225 | |||
| 226 | 219 | ||
| 227 | 220 | ||
| 221 | |||
| 222 | } | ||
| 223 | |||
| 224 | |||
| 225 | |||
| 228 | } | 226 | } |
| 229 | 227 | ||
| 230 | function mysqldatetime_to_timestamp($datetime = "") | 228 | function mysqldatetime_to_timestamp($datetime = "") |
| ... | @@ -273,59 +271,59 @@ function fixFilesArray(&$files) | ... | @@ -273,59 +271,59 @@ function fixFilesArray(&$files) |
| 273 | function notification_settings() { | 271 | function notification_settings() { |
| 274 | 272 | ||
| 275 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'settings.php'); | 273 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'settings.php'); |
| 276 | |||
| 277 | 274 | ||
| 278 | 275 | ||
| 276 | |||
| 279 | } | 277 | } |
| 280 | 278 | ||
| 281 | function create_notification() { | 279 | function create_notification() { |
| 282 | 280 | ||
| 283 | global $wpdb; | 281 | global $wpdb; |
| 284 | 282 | ||
| 285 | 283 | ||
| 286 | // here | 284 | // here |
| 287 | $validation = new Notifications\Validation; | 285 | $validation = new Notifications\Validation; |
| 288 | 286 | ||
| 289 | $validation->set_rules('type','Notification Type','required'); | 287 | $validation->set_rules('type','Notification Type','required'); |
| 290 | $validation->set_rules('title','Description','trim|required|min_length[16]'); | 288 | $validation->set_rules('title','Description','trim|required|min_length[16]'); |
| 291 | $validation->set_rules('type','Notification Type','required'); | 289 | $validation->set_rules('type','Notification Type','required'); |
| 292 | $validation->set_rules('sendto','Send To','required'); | 290 | $validation->set_rules('sendto','Send To','required'); |
| 293 | 291 | ||
| 294 | $type_val = ($_POST && $_POST['type'] == "scheduled") ? 'required' : ''; | 292 | $type_val = ($_POST && $_POST['type'] == "scheduled") ? 'required' : ''; |
| 295 | $validation->set_rules('execute_date','Execute Date', $type_val); | 293 | $validation->set_rules('execute_date','Execute Date', $type_val); |
| 296 | 294 | ||
| 297 | $trigger_val = ($_POST && $_POST['type'] == "triggered") ? 'required' : ''; | 295 | $trigger_val = ($_POST && $_POST['type'] == "triggered") ? 'required' : ''; |
| 298 | $validation->set_rules('trigger','Trigger',$trigger_val); | 296 | $validation->set_rules('trigger','Trigger',$trigger_val); |
| 299 | 297 | ||
| 300 | $validation->set_rules('subject','Subject','trim'); | 298 | $validation->set_rules('subject','Subject','trim'); |
| 301 | $validation->set_rules('text','Text Version','trim|min_length[16]'); | 299 | $validation->set_rules('text','Text Version','trim|min_length[16]'); |
| 302 | $validation->set_rules('html','HTML Version','trim|min_length[16]'); | 300 | $validation->set_rules('html','HTML Version','trim|min_length[16]'); |
| 303 | 301 | ||
| 304 | $validation->set_rules('system','System Message','trim|min_length[16]'); | 302 | $validation->set_rules('system','System Message','trim|min_length[16]'); |
| 305 | 303 | ||
| 306 | 304 | ||
| 307 | if ($_POST && ($_POST['subject']=="" && $_POST['system']=="")) { | 305 | if ($_POST && ($_POST['subject']=="" && $_POST['system']=="")) { |
| 308 | $form_error = true; | 306 | $form_error = true; |
| 309 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php'); | 307 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php'); |
| 310 | } else { | 308 | } else { |
| 311 | if ($validation->run() == TRUE) { | 309 | if ($validation->run() == TRUE) { |
| 312 | 310 | ||
| 313 | // ok, so now we need to create the notification. | 311 | // ok, so now we need to create the notification. |
| 314 | class postTemplate { | 312 | class postTemplate { |
| 315 | var $post_title = ''; | 313 | var $post_title = ''; |
| 316 | var $post_content = ''; | 314 | var $post_content = ''; |
| 317 | var $post_status = 'publish'; | 315 | var $post_status = 'publish'; |
| 318 | var $post_type = 'notifications'; | 316 | var $post_type = 'notifications'; |
| 319 | var $comment_status = 'closed'; | 317 | var $comment_status = 'closed'; |
| 320 | } | 318 | } |
| 321 | 319 | ||
| 322 | //details | 320 | //details |
| 323 | $type = $_POST['type']; | 321 | $type = $_POST['type']; |
| 324 | $title = $_POST['title']; | 322 | $title = $_POST['title']; |
| 325 | $sendto = $_POST['sendto']; | 323 | $sendto = $_POST['sendto']; |
| 326 | $execute_date = ($type=="scheduled") ? $_POST['execute_date'] : "0000-00-00 00:00:00"; | 324 | $execute_date = ($type=="scheduled") ? $_POST['execute_date'] : "0000-00-00 00:00:00"; |
| 327 | $trigger = ($type=="scheduled") ? "scheduled-cron-job" : $_POST['trigger']; | 325 | $trigger = ($type=="scheduled") ? "scheduled-cron-job" : $_POST['trigger']; |
| 328 | 326 | ||
| 329 | 327 | ||
| 330 | $subject = $_POST['subject']; | 328 | $subject = $_POST['subject']; |
| 331 | $text = $_POST['text']; | 329 | $text = $_POST['text']; |
| ... | @@ -335,32 +333,32 @@ function create_notification() { | ... | @@ -335,32 +333,32 @@ function create_notification() { |
| 335 | fixFilesArray($_FILES['attachment']); | 333 | fixFilesArray($_FILES['attachment']); |
| 336 | foreach ($_FILES['attachment'] as $position => $file) { | 334 | foreach ($_FILES['attachment'] as $position => $file) { |
| 337 | // should output array with indices name, type, tmp_name, error, size | 335 | // should output array with indices name, type, tmp_name, error, size |
| 338 | if($file['name'] != "") { | 336 | if($file['name'] != "") { |
| 339 | move_uploaded_file($file['tmp_name'],$upload_dir . $file['name']); | 337 | move_uploaded_file($file['tmp_name'],$upload_dir . $file['name']); |
| 340 | $attachments[] = $file['name']; | 338 | $attachments[] = $file['name']; |
| 341 | } | 339 | } |
| 342 | } | 340 | } |
| 343 | 341 | ||
| 344 | // system | 342 | // system |
| 345 | $system_message_type = $_POST['system_message_type']; | 343 | $system_message_type = $_POST['system_message_type']; |
| 346 | $system = $_POST['system']; | 344 | $system = $_POST['system']; |
| 347 | 345 | ||
| 348 | 346 | ||
| 349 | 347 | ||
| 350 | 348 | ||
| 351 | // make post... | 349 | // make post... |
| 352 | 350 | ||
| 353 | $notification = new postTemplate(); | 351 | $notification = new postTemplate(); |
| 354 | $notification->post_title = $title; | 352 | $notification->post_title = $title; |
| 355 | $notification->post_content = "Notification created ".date('Y-m-d H:i:s')." --- to be sent on $execute_date"; | 353 | $notification->post_content = "Notification created ".date('Y-m-d H:i:s')." --- to be sent on $execute_date"; |
| 356 | $notification->post_date_gmt = date("Y-m-d H:i:s",time()); | 354 | $notification->post_date_gmt = date("Y-m-d H:i:s",time()); |
| 357 | 355 | ||
| 358 | $id = wp_insert_post($notification); | 356 | $id = wp_insert_post($notification); |
| 359 | 357 | ||
| 360 | update_post_meta($id, 'notif_type', $type); | 358 | update_post_meta($id, 'notif_type', $type); |
| 361 | update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($execute_date)); | 359 | update_post_meta($id, 'execute_date', mysqldatetime_to_timestamp($execute_date)); |
| 362 | update_post_meta($id, 'trigger', $trigger); | 360 | update_post_meta($id, 'trigger', $trigger); |
| 363 | 361 | ||
| 364 | add_post_meta($id, "details", array( | 362 | add_post_meta($id, "details", array( |
| 365 | 'type' => $type | 363 | 'type' => $type |
| 366 | , 'sendto' => $sendto | 364 | , 'sendto' => $sendto |
| ... | @@ -368,9 +366,9 @@ function create_notification() { | ... | @@ -368,9 +366,9 @@ function create_notification() { |
| 368 | , 'trigger' => $trigger | 366 | , 'trigger' => $trigger |
| 369 | , 'execute_date' => $execute_date | 367 | , 'execute_date' => $execute_date |
| 370 | )); | 368 | )); |
| 371 | 369 | ||
| 372 | update_post_meta($id,'send_status','pending'); | 370 | update_post_meta($id,'send_status','pending'); |
| 373 | 371 | ||
| 374 | add_post_meta($id, "email", array( | 372 | add_post_meta($id, "email", array( |
| 375 | 'subject' => $subject | 373 | 'subject' => $subject |
| 376 | , 'text' => $text | 374 | , 'text' => $text |
| ... | @@ -380,16 +378,16 @@ function create_notification() { | ... | @@ -380,16 +378,16 @@ function create_notification() { |
| 380 | update_post_meta($id, "system", array( | 378 | update_post_meta($id, "system", array( |
| 381 | 'system_message_type' => $system_message_type | 379 | 'system_message_type' => $system_message_type |
| 382 | , 'message' => $system | 380 | , 'message' => $system |
| 383 | )); | 381 | )); |
| 384 | 382 | ||
| 385 | $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; | 383 | $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; |
| 386 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php'); | 384 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php'); |
| 387 | 385 | ||
| 388 | } else { | 386 | } else { |
| 389 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php'); | 387 | require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php'); |
| 390 | } | 388 | } |
| 391 | } | 389 | } |
| 392 | 390 | ||
| 393 | 391 | ||
| 394 | } | 392 | } |
| 395 | 393 | ||
| ... | @@ -398,7 +396,7 @@ class Actions { | ... | @@ -398,7 +396,7 @@ class Actions { |
| 398 | public static function init() { | 396 | public static function init() { |
| 399 | global $wpdb; | 397 | global $wpdb; |
| 400 | $wpdb->show_errors(); | 398 | $wpdb->show_errors(); |
| 401 | 399 | ||
| 402 | register_post_type( 'notifications', array( | 400 | register_post_type( 'notifications', array( |
| 403 | 'label' => __('Notifs') | 401 | 'label' => __('Notifs') |
| 404 | , 'public' => true | 402 | , 'public' => true |
| ... | @@ -406,16 +404,16 @@ class Actions { | ... | @@ -406,16 +404,16 @@ class Actions { |
| 406 | , 'hierarchical' => false | 404 | , 'hierarchical' => false |
| 407 | , 'exclude_from_search' => true | 405 | , 'exclude_from_search' => true |
| 408 | )); | 406 | )); |
| 409 | 407 | ||
| 410 | } | 408 | } |
| 411 | 409 | ||
| 412 | public static function admin_menu() { | 410 | public static function admin_menu() { |
| 413 | add_menu_page('Notifications','Notifications',CAPABILITY,'notifications',__NAMESPACE__ . '\display_page' ); | 411 | add_menu_page('Notifications','Notifications',CAPABILITY,'notifications',__NAMESPACE__ . '\display_page' ); |
| 414 | add_submenu_page('notifications','New Notification', 'New Notification',CAPABILITY,'notifications-create-new',__NAMESPACE__ . '\create_notification'); | 412 | add_submenu_page('notifications','New Notification', 'New Notification',CAPABILITY,'notifications-create-new',__NAMESPACE__ . '\create_notification'); |
| 415 | //add_options_page('CAN-SPAM Settings', 'CAN-SPAM Settings', CAPABILITY, ADMIN_PAGE, __NAMESPACE__ . '\notification_settings'); | 413 | //add_options_page('CAN-SPAM Settings', 'CAN-SPAM Settings', CAPABILITY, ADMIN_PAGE, __NAMESPACE__ . '\notification_settings'); |
| 416 | //add_submenu_page('notifications','CAN-SPAM Settings', 'CAN-SPAM Settings',CAPABILITY,'notifications-settings',__NAMESPACE__ . '\notification_settings'); | 414 | //add_submenu_page('notifications','CAN-SPAM Settings', 'CAN-SPAM Settings',CAPABILITY,'notifications-settings',__NAMESPACE__ . '\notification_settings'); |
| 417 | } | 415 | } |
| 418 | 416 | ||
| 419 | public function admin_init() { | 417 | public function admin_init() { |
| 420 | // register_setting(Notifications\OPTION_NAME, Notifications\OPTION_NAME); | 418 | // register_setting(Notifications\OPTION_NAME, Notifications\OPTION_NAME); |
| 421 | register_setting(SETTING_NS, SETTING_NS); | 419 | register_setting(SETTING_NS, SETTING_NS); | ... | ... |
| ... | @@ -8,22 +8,22 @@ use Tz\WordPress\Tools\Notifications; | ... | @@ -8,22 +8,22 @@ use Tz\WordPress\Tools\Notifications; |
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | class Validation { | 10 | class Validation { |
| 11 | 11 | ||
| 12 | protected $_field_data = array(); | 12 | protected $_field_data = array(); |
| 13 | protected $_config_rules = array(); | 13 | protected $_config_rules = array(); |
| 14 | protected $_error_array = array(); | 14 | protected $_error_array = array(); |
| 15 | protected $_error_messages = array(); | 15 | protected $_error_messages = array(); |
| 16 | protected $_error_prefix = '<div class="lblError">'; | 16 | protected $_error_prefix = '<div class="lblError">'; |
| 17 | protected $_error_suffix = '</div>'; | 17 | protected $_error_suffix = '</div>'; |
| 18 | protected $error_string = ''; | 18 | protected $error_string = ''; |
| 19 | protected $_safe_form_data = FALSE; | 19 | protected $_safe_form_data = FALSE; |
| 20 | 20 | ||
| 21 | function __construct($rules = array()) | 21 | function __construct($rules = array()) |
| 22 | { | 22 | { |
| 23 | // Validation rules can be stored in a config file. | 23 | // Validation rules can be stored in a config file. |
| 24 | $this->_config_rules = $rules; | 24 | $this->_config_rules = $rules; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | public function get_error_message($key) { | 27 | public function get_error_message($key) { |
| 28 | $lang = array(); | 28 | $lang = array(); |
| 29 | $lang['required'] = "The %s field is required."; | 29 | $lang['required'] = "The %s field is required."; |
| ... | @@ -44,19 +44,19 @@ class Validation { | ... | @@ -44,19 +44,19 @@ class Validation { |
| 44 | $lang['matches'] = "The %s field does not match the %s field."; | 44 | $lang['matches'] = "The %s field does not match the %s field."; |
| 45 | $lang['is_natural'] = "The %s field must contain only positive numbers."; | 45 | $lang['is_natural'] = "The %s field must contain only positive numbers."; |
| 46 | $lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero."; | 46 | $lang['is_natural_no_zero'] = "The %s field must contain a number greater than zero."; |
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | if (isset($lang[$key])) { | 49 | if (isset($lang[$key])) { |
| 50 | return $lang[$key]; | 50 | return $lang[$key]; |
| 51 | } else { | 51 | } else { |
| 52 | return FALSE; | 52 | return FALSE; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | 57 | ||
| 58 | // -------------------------------------------------------------------- | 58 | // -------------------------------------------------------------------- |
| 59 | 59 | ||
| 60 | /** | 60 | /** |
| 61 | * Set Rules | 61 | * Set Rules |
| 62 | * | 62 | * |
| ... | @@ -75,7 +75,7 @@ class Validation { | ... | @@ -75,7 +75,7 @@ class Validation { |
| 75 | { | 75 | { |
| 76 | return; | 76 | return; |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | // If an array was passed via the first parameter instead of indidual string | 79 | // If an array was passed via the first parameter instead of indidual string |
| 80 | // values we cycle through it and recursively call this function. | 80 | // values we cycle through it and recursively call this function. |
| 81 | if (is_array($field)) | 81 | if (is_array($field)) |
| ... | @@ -96,7 +96,7 @@ class Validation { | ... | @@ -96,7 +96,7 @@ class Validation { |
| 96 | } | 96 | } |
| 97 | return; | 97 | return; |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | // No fields? Nothing to do... | 100 | // No fields? Nothing to do... |
| 101 | if ( ! is_string($field) OR ! is_string($rules) OR $field == '') | 101 | if ( ! is_string($field) OR ! is_string($rules) OR $field == '') |
| 102 | { | 102 | { |
| ... | @@ -108,9 +108,9 @@ class Validation { | ... | @@ -108,9 +108,9 @@ class Validation { |
| 108 | 108 | ||
| 109 | // Is the field name an array? We test for the existence of a bracket "[" in | 109 | // Is the field name an array? We test for the existence of a bracket "[" in |
| 110 | // the field name to determine this. If it is an array, we break it apart | 110 | // the field name to determine this. If it is an array, we break it apart |
| 111 | // into its components so that we can fetch the corresponding POST data later | 111 | // into its components so that we can fetch the corresponding POST data later |
| 112 | if (strpos($field, '[') !== FALSE AND preg_match_all('/\[(.*?)\]/', $field, $matches)) | 112 | if (strpos($field, '[') !== FALSE AND preg_match_all('/\[(.*?)\]/', $field, $matches)) |
| 113 | { | 113 | { |
| 114 | // Note: Due to a bug in current() that affects some versions | 114 | // Note: Due to a bug in current() that affects some versions |
| 115 | // of PHP we can not pass function call directly into it | 115 | // of PHP we can not pass function call directly into it |
| 116 | $x = explode('[', $field); | 116 | $x = explode('[', $field); |
| ... | @@ -123,19 +123,19 @@ class Validation { | ... | @@ -123,19 +123,19 @@ class Validation { |
| 123 | $indexes[] = $matches['1'][$i]; | 123 | $indexes[] = $matches['1'][$i]; |
| 124 | } | 124 | } |
| 125 | } | 125 | } |
| 126 | 126 | ||
| 127 | $is_array = TRUE; | 127 | $is_array = TRUE; |
| 128 | } | 128 | } |
| 129 | else | 129 | else |
| 130 | { | 130 | { |
| 131 | $indexes = array(); | 131 | $indexes = array(); |
| 132 | $is_array = FALSE; | 132 | $is_array = FALSE; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | // Build our master array | 135 | // Build our master array |
| 136 | $this->_field_data[$field] = array( | 136 | $this->_field_data[$field] = array( |
| 137 | 'field' => $field, | 137 | 'field' => $field, |
| 138 | 'label' => $label, | 138 | 'label' => $label, |
| 139 | 'rules' => $rules, | 139 | 'rules' => $rules, |
| 140 | 'is_array' => $is_array, | 140 | 'is_array' => $is_array, |
| 141 | 'keys' => $indexes, | 141 | 'keys' => $indexes, |
| ... | @@ -145,7 +145,7 @@ class Validation { | ... | @@ -145,7 +145,7 @@ class Validation { |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | // -------------------------------------------------------------------- | 147 | // -------------------------------------------------------------------- |
| 148 | 148 | ||
| 149 | /** | 149 | /** |
| 150 | * Set Error Message | 150 | * Set Error Message |
| 151 | * | 151 | * |
| ... | @@ -163,12 +163,12 @@ class Validation { | ... | @@ -163,12 +163,12 @@ class Validation { |
| 163 | { | 163 | { |
| 164 | $lang = array($lang => $val); | 164 | $lang = array($lang => $val); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | $this->_error_messages = array_merge($this->_error_messages, $lang); | 167 | $this->_error_messages = array_merge($this->_error_messages, $lang); |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | // -------------------------------------------------------------------- | 170 | // -------------------------------------------------------------------- |
| 171 | 171 | ||
| 172 | /** | 172 | /** |
| 173 | * Set The Error Delimiter | 173 | * Set The Error Delimiter |
| 174 | * | 174 | * |
| ... | @@ -178,7 +178,7 @@ class Validation { | ... | @@ -178,7 +178,7 @@ class Validation { |
| 178 | * @param string | 178 | * @param string |
| 179 | * @param string | 179 | * @param string |
| 180 | * @return void | 180 | * @return void |
| 181 | */ | 181 | */ |
| 182 | function set_error_delimiters($prefix = '<p>', $suffix = '</p>') | 182 | function set_error_delimiters($prefix = '<p>', $suffix = '</p>') |
| 183 | { | 183 | { |
| 184 | $this->_error_prefix = $prefix; | 184 | $this->_error_prefix = $prefix; |
| ... | @@ -186,7 +186,7 @@ class Validation { | ... | @@ -186,7 +186,7 @@ class Validation { |
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | // -------------------------------------------------------------------- | 188 | // -------------------------------------------------------------------- |
| 189 | 189 | ||
| 190 | /** | 190 | /** |
| 191 | * Get Error Message | 191 | * Get Error Message |
| 192 | * | 192 | * |
| ... | @@ -195,14 +195,14 @@ class Validation { | ... | @@ -195,14 +195,14 @@ class Validation { |
| 195 | * @access public | 195 | * @access public |
| 196 | * @param string the field name | 196 | * @param string the field name |
| 197 | * @return void | 197 | * @return void |
| 198 | */ | 198 | */ |
| 199 | function error($field = '', $prefix = '', $suffix = '') | 199 | function error($field = '', $prefix = '', $suffix = '') |
| 200 | { | 200 | { |
| 201 | if ( ! isset($this->_field_data[$field]['error']) OR $this->_field_data[$field]['error'] == '') | 201 | if ( ! isset($this->_field_data[$field]['error']) OR $this->_field_data[$field]['error'] == '') |
| 202 | { | 202 | { |
| 203 | return ''; | 203 | return ''; |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | if ($prefix == '') | 206 | if ($prefix == '') |
| 207 | { | 207 | { |
| 208 | $prefix = $this->_error_prefix; | 208 | $prefix = $this->_error_prefix; |
| ... | @@ -217,7 +217,7 @@ class Validation { | ... | @@ -217,7 +217,7 @@ class Validation { |
| 217 | } | 217 | } |
| 218 | 218 | ||
| 219 | // -------------------------------------------------------------------- | 219 | // -------------------------------------------------------------------- |
| 220 | 220 | ||
| 221 | /** | 221 | /** |
| 222 | * Error String | 222 | * Error String |
| 223 | * | 223 | * |
| ... | @@ -227,7 +227,7 @@ class Validation { | ... | @@ -227,7 +227,7 @@ class Validation { |
| 227 | * @param string | 227 | * @param string |
| 228 | * @param string | 228 | * @param string |
| 229 | * @return str | 229 | * @return str |
| 230 | */ | 230 | */ |
| 231 | function error_string($prefix = '', $suffix = '') | 231 | function error_string($prefix = '', $suffix = '') |
| 232 | { | 232 | { |
| 233 | // No errrors, validation passes! | 233 | // No errrors, validation passes! |
| ... | @@ -235,7 +235,7 @@ class Validation { | ... | @@ -235,7 +235,7 @@ class Validation { |
| 235 | { | 235 | { |
| 236 | return ''; | 236 | return ''; |
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | if ($prefix == '') | 239 | if ($prefix == '') |
| 240 | { | 240 | { |
| 241 | $prefix = $this->_error_prefix; | 241 | $prefix = $this->_error_prefix; |
| ... | @@ -245,7 +245,7 @@ class Validation { | ... | @@ -245,7 +245,7 @@ class Validation { |
| 245 | { | 245 | { |
| 246 | $suffix = $this->_error_suffix; | 246 | $suffix = $this->_error_suffix; |
| 247 | } | 247 | } |
| 248 | 248 | ||
| 249 | // Generate the error string | 249 | // Generate the error string |
| 250 | $str = ''; | 250 | $str = ''; |
| 251 | foreach ($this->_error_array as $val) | 251 | foreach ($this->_error_array as $val) |
| ... | @@ -255,12 +255,12 @@ class Validation { | ... | @@ -255,12 +255,12 @@ class Validation { |
| 255 | $str .= $prefix.$val.$suffix."\n"; | 255 | $str .= $prefix.$val.$suffix."\n"; |
| 256 | } | 256 | } |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | return $str; | 259 | return $str; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | // -------------------------------------------------------------------- | 262 | // -------------------------------------------------------------------- |
| 263 | 263 | ||
| 264 | /** | 264 | /** |
| 265 | * Run the Validator | 265 | * Run the Validator |
| 266 | * | 266 | * |
| ... | @@ -268,7 +268,7 @@ class Validation { | ... | @@ -268,7 +268,7 @@ class Validation { |
| 268 | * | 268 | * |
| 269 | * @access public | 269 | * @access public |
| 270 | * @return bool | 270 | * @return bool |
| 271 | */ | 271 | */ |
| 272 | function run($group = '') | 272 | function run($group = '') |
| 273 | { | 273 | { |
| 274 | // Do we even have any data to process? Mm? | 274 | // Do we even have any data to process? Mm? |
| ... | @@ -276,7 +276,7 @@ class Validation { | ... | @@ -276,7 +276,7 @@ class Validation { |
| 276 | { | 276 | { |
| 277 | return FALSE; | 277 | return FALSE; |
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | // Does the _field_data array containing the validation rules exist? | 280 | // Does the _field_data array containing the validation rules exist? |
| 281 | // If not, we look to see if they were assigned via a config file | 281 | // If not, we look to see if they were assigned via a config file |
| 282 | if (count($this->_field_data) == 0) | 282 | if (count($this->_field_data) == 0) |
| ... | @@ -286,10 +286,10 @@ class Validation { | ... | @@ -286,10 +286,10 @@ class Validation { |
| 286 | { | 286 | { |
| 287 | return FALSE; | 287 | return FALSE; |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | // Is there a validation rule for the particular URI being accessed? | 290 | // Is there a validation rule for the particular URI being accessed? |
| 291 | $uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group; | 291 | $uri = ($group == '') ? trim($this->CI->uri->ruri_string(), '/') : $group; |
| 292 | 292 | ||
| 293 | if ($uri != '' AND isset($this->_config_rules[$uri])) | 293 | if ($uri != '' AND isset($this->_config_rules[$uri])) |
| 294 | { | 294 | { |
| 295 | $this->set_rules($this->_config_rules[$uri]); | 295 | $this->set_rules($this->_config_rules[$uri]); |
| ... | @@ -298,21 +298,21 @@ class Validation { | ... | @@ -298,21 +298,21 @@ class Validation { |
| 298 | { | 298 | { |
| 299 | $this->set_rules($this->_config_rules); | 299 | $this->set_rules($this->_config_rules); |
| 300 | } | 300 | } |
| 301 | 301 | ||
| 302 | // We're we able to set the rules correctly? | 302 | // We're we able to set the rules correctly? |
| 303 | if (count($this->_field_data) == 0) | 303 | if (count($this->_field_data) == 0) |
| 304 | { | 304 | { |
| 305 | return FALSE; | 305 | return FALSE; |
| 306 | } | 306 | } |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | // Cycle through the rules for each field, match the | 309 | // Cycle through the rules for each field, match the |
| 310 | // corresponding $_POST item and test for errors | 310 | // corresponding $_POST item and test for errors |
| 311 | foreach ($this->_field_data as $field => $row) | 311 | foreach ($this->_field_data as $field => $row) |
| 312 | { | 312 | { |
| 313 | // Fetch the data from the corresponding $_POST array and cache it in the _field_data array. | 313 | // Fetch the data from the corresponding $_POST array and cache it in the _field_data array. |
| 314 | // Depending on whether the field name is an array or a string will determine where we get it from. | 314 | // Depending on whether the field name is an array or a string will determine where we get it from. |
| 315 | 315 | ||
| 316 | if ($row['is_array'] == TRUE) | 316 | if ($row['is_array'] == TRUE) |
| 317 | { | 317 | { |
| 318 | $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']); | 318 | $this->_field_data[$field]['postdata'] = $this->_reduce_array($_POST, $row['keys']); |
| ... | @@ -324,8 +324,8 @@ class Validation { | ... | @@ -324,8 +324,8 @@ class Validation { |
| 324 | $this->_field_data[$field]['postdata'] = $_POST[$field]; | 324 | $this->_field_data[$field]['postdata'] = $_POST[$field]; |
| 325 | } | 325 | } |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']); | 328 | $this->_execute($row, explode('|', $row['rules']), $this->_field_data[$field]['postdata']); |
| 329 | } | 329 | } |
| 330 | 330 | ||
| 331 | // Did we end up with any errors? | 331 | // Did we end up with any errors? |
| ... | @@ -338,7 +338,7 @@ class Validation { | ... | @@ -338,7 +338,7 @@ class Validation { |
| 338 | 338 | ||
| 339 | // Now we need to re-set the POST data with the new, processed data | 339 | // Now we need to re-set the POST data with the new, processed data |
| 340 | $this->_reset_post_array(); | 340 | $this->_reset_post_array(); |
| 341 | 341 | ||
| 342 | // No errors, validation passes! | 342 | // No errors, validation passes! |
| 343 | if ($total_errors == 0) | 343 | if ($total_errors == 0) |
| 344 | { | 344 | { |
| ... | @@ -350,7 +350,7 @@ class Validation { | ... | @@ -350,7 +350,7 @@ class Validation { |
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | // -------------------------------------------------------------------- | 352 | // -------------------------------------------------------------------- |
| 353 | 353 | ||
| 354 | /** | 354 | /** |
| 355 | * Traverse a multidimensional $_POST array index until the data is found | 355 | * Traverse a multidimensional $_POST array index until the data is found |
| 356 | * | 356 | * |
| ... | @@ -359,7 +359,7 @@ class Validation { | ... | @@ -359,7 +359,7 @@ class Validation { |
| 359 | * @param array | 359 | * @param array |
| 360 | * @param integer | 360 | * @param integer |
| 361 | * @return mixed | 361 | * @return mixed |
| 362 | */ | 362 | */ |
| 363 | function _reduce_array($array, $keys, $i = 0) | 363 | function _reduce_array($array, $keys, $i = 0) |
| 364 | { | 364 | { |
| 365 | if (is_array($array)) | 365 | if (is_array($array)) |
| ... | @@ -380,18 +380,18 @@ class Validation { | ... | @@ -380,18 +380,18 @@ class Validation { |
| 380 | return $array; | 380 | return $array; |
| 381 | } | 381 | } |
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | return $array; | 384 | return $array; |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | // -------------------------------------------------------------------- | 387 | // -------------------------------------------------------------------- |
| 388 | 388 | ||
| 389 | /** | 389 | /** |
| 390 | * Re-populate the _POST array with our finalized and processed data | 390 | * Re-populate the _POST array with our finalized and processed data |
| 391 | * | 391 | * |
| 392 | * @access private | 392 | * @access private |
| 393 | * @return null | 393 | * @return null |
| 394 | */ | 394 | */ |
| 395 | function _reset_post_array() | 395 | function _reset_post_array() |
| 396 | { | 396 | { |
| 397 | foreach ($this->_field_data as $field => $row) | 397 | foreach ($this->_field_data as $field => $row) |
| ... | @@ -409,7 +409,7 @@ class Validation { | ... | @@ -409,7 +409,7 @@ class Validation { |
| 409 | { | 409 | { |
| 410 | // start with a reference | 410 | // start with a reference |
| 411 | $post_ref =& $_POST; | 411 | $post_ref =& $_POST; |
| 412 | 412 | ||
| 413 | // before we assign values, make a reference to the right POST key | 413 | // before we assign values, make a reference to the right POST key |
| 414 | if (count($row['keys']) == 1) | 414 | if (count($row['keys']) == 1) |
| 415 | { | 415 | { |
| ... | @@ -443,7 +443,7 @@ class Validation { | ... | @@ -443,7 +443,7 @@ class Validation { |
| 443 | } | 443 | } |
| 444 | 444 | ||
| 445 | // -------------------------------------------------------------------- | 445 | // -------------------------------------------------------------------- |
| 446 | 446 | ||
| 447 | /** | 447 | /** |
| 448 | * Executes the Validation routines | 448 | * Executes the Validation routines |
| 449 | * | 449 | * |
| ... | @@ -453,21 +453,21 @@ class Validation { | ... | @@ -453,21 +453,21 @@ class Validation { |
| 453 | * @param mixed | 453 | * @param mixed |
| 454 | * @param integer | 454 | * @param integer |
| 455 | * @return mixed | 455 | * @return mixed |
| 456 | */ | 456 | */ |
| 457 | function _execute($row, $rules, $postdata = NULL, $cycles = 0) | 457 | function _execute($row, $rules, $postdata = NULL, $cycles = 0) |
| 458 | { | 458 | { |
| 459 | // If the $_POST data is an array we will run a recursive call | 459 | // If the $_POST data is an array we will run a recursive call |
| 460 | if (is_array($postdata)) | 460 | if (is_array($postdata)) |
| 461 | { | 461 | { |
| 462 | foreach ($postdata as $key => $val) | 462 | foreach ($postdata as $key => $val) |
| 463 | { | 463 | { |
| 464 | $this->_execute($row, $rules, $val, $cycles); | 464 | $this->_execute($row, $rules, $val, $cycles); |
| 465 | $cycles++; | 465 | $cycles++; |
| 466 | } | 466 | } |
| 467 | 467 | ||
| 468 | return; | 468 | return; |
| 469 | } | 469 | } |
| 470 | 470 | ||
| 471 | // -------------------------------------------------------------------- | 471 | // -------------------------------------------------------------------- |
| 472 | 472 | ||
| 473 | // If the field is blank, but NOT required, no further tests are necessary | 473 | // If the field is blank, but NOT required, no further tests are necessary |
| ... | @@ -487,7 +487,7 @@ class Validation { | ... | @@ -487,7 +487,7 @@ class Validation { |
| 487 | } | 487 | } |
| 488 | 488 | ||
| 489 | // -------------------------------------------------------------------- | 489 | // -------------------------------------------------------------------- |
| 490 | 490 | ||
| 491 | // Isset Test. Typically this rule will only apply to checkboxes. | 491 | // Isset Test. Typically this rule will only apply to checkboxes. |
| 492 | if (is_null($postdata) AND $callback == FALSE) | 492 | if (is_null($postdata) AND $callback == FALSE) |
| 493 | { | 493 | { |
| ... | @@ -495,31 +495,31 @@ class Validation { | ... | @@ -495,31 +495,31 @@ class Validation { |
| 495 | { | 495 | { |
| 496 | // Set the message type | 496 | // Set the message type |
| 497 | $type = (in_array('required', $rules)) ? 'required' : 'isset'; | 497 | $type = (in_array('required', $rules)) ? 'required' : 'isset'; |
| 498 | 498 | ||
| 499 | if ( ! isset($this->_error_messages[$type])) | 499 | if ( ! isset($this->_error_messages[$type])) |
| 500 | { | 500 | { |
| 501 | if (FALSE === ($line = $this->get_error_message($type))) | 501 | if (FALSE === ($line = $this->get_error_message($type))) |
| 502 | { | 502 | { |
| 503 | $line = 'The field was not set'; | 503 | $line = 'The field was not set'; |
| 504 | } | 504 | } |
| 505 | } | 505 | } |
| 506 | else | 506 | else |
| 507 | { | 507 | { |
| 508 | $line = $this->_error_messages[$type]; | 508 | $line = $this->_error_messages[$type]; |
| 509 | } | 509 | } |
| 510 | 510 | ||
| 511 | // Build the error message | 511 | // Build the error message |
| 512 | $message = sprintf($line, $this->_translate_fieldname($row['label'])); | 512 | $message = sprintf($line, $this->_translate_fieldname($row['label'])); |
| 513 | 513 | ||
| 514 | // Save the error message | 514 | // Save the error message |
| 515 | $this->_field_data[$row['field']]['error'] = $message; | 515 | $this->_field_data[$row['field']]['error'] = $message; |
| 516 | 516 | ||
| 517 | if ( ! isset($this->_error_array[$row['field']])) | 517 | if ( ! isset($this->_error_array[$row['field']])) |
| 518 | { | 518 | { |
| 519 | $this->_error_array[$row['field']] = $message; | 519 | $this->_error_array[$row['field']] = $message; |
| 520 | } | 520 | } |
| 521 | } | 521 | } |
| 522 | 522 | ||
| 523 | return; | 523 | return; |
| 524 | } | 524 | } |
| 525 | 525 | ||
| ... | @@ -529,7 +529,7 @@ class Validation { | ... | @@ -529,7 +529,7 @@ class Validation { |
| 529 | foreach ($rules As $rule) | 529 | foreach ($rules As $rule) |
| 530 | { | 530 | { |
| 531 | $_in_array = FALSE; | 531 | $_in_array = FALSE; |
| 532 | 532 | ||
| 533 | // We set the $postdata variable with the current data in our master array so that | 533 | // We set the $postdata variable with the current data in our master array so that |
| 534 | // each cycle of the loop is dealing with the processed data from the last cycle | 534 | // each cycle of the loop is dealing with the processed data from the last cycle |
| 535 | if ($row['is_array'] == TRUE AND is_array($this->_field_data[$row['field']]['postdata'])) | 535 | if ($row['is_array'] == TRUE AND is_array($this->_field_data[$row['field']]['postdata'])) |
| ... | @@ -540,7 +540,7 @@ class Validation { | ... | @@ -540,7 +540,7 @@ class Validation { |
| 540 | { | 540 | { |
| 541 | continue; | 541 | continue; |
| 542 | } | 542 | } |
| 543 | 543 | ||
| 544 | $postdata = $this->_field_data[$row['field']]['postdata'][$cycles]; | 544 | $postdata = $this->_field_data[$row['field']]['postdata'][$cycles]; |
| 545 | $_in_array = TRUE; | 545 | $_in_array = TRUE; |
| 546 | } | 546 | } |
| ... | @@ -550,15 +550,15 @@ class Validation { | ... | @@ -550,15 +550,15 @@ class Validation { |
| 550 | } | 550 | } |
| 551 | 551 | ||
| 552 | // -------------------------------------------------------------------- | 552 | // -------------------------------------------------------------------- |
| 553 | 553 | ||
| 554 | // Is the rule a callback? | 554 | // Is the rule a callback? |
| 555 | $callback = FALSE; | 555 | $callback = FALSE; |
| 556 | if (substr($rule, 0, 9) == 'callback_') | 556 | if (substr($rule, 0, 9) == 'callback_') |
| 557 | { | 557 | { |
| 558 | $rule = substr($rule, 9); | 558 | $rule = substr($rule, 9); |
| 559 | $callback = TRUE; | 559 | $callback = TRUE; |
| 560 | } | 560 | } |
| 561 | 561 | ||
| 562 | // Strip the parameter (if exists) from the rule | 562 | // Strip the parameter (if exists) from the rule |
| 563 | // Rules can contain a parameter: max_length[5] | 563 | // Rules can contain a parameter: max_length[5] |
| 564 | $param = FALSE; | 564 | $param = FALSE; |
| ... | @@ -567,15 +567,15 @@ class Validation { | ... | @@ -567,15 +567,15 @@ class Validation { |
| 567 | $rule = $match[1]; | 567 | $rule = $match[1]; |
| 568 | $param = $match[2]; | 568 | $param = $match[2]; |
| 569 | } | 569 | } |
| 570 | 570 | ||
| 571 | // Call the function that corresponds to the rule | 571 | // Call the function that corresponds to the rule |
| 572 | if ($callback === TRUE) | 572 | if ($callback === TRUE) |
| 573 | { | 573 | { |
| 574 | if ( ! method_exists($this->CI, $rule)) | 574 | if ( ! method_exists($this->CI, $rule)) |
| 575 | { | 575 | { |
| 576 | continue; | 576 | continue; |
| 577 | } | 577 | } |
| 578 | 578 | ||
| 579 | // Run the function and grab the result | 579 | // Run the function and grab the result |
| 580 | $result = $this->CI->$rule($postdata, $param); | 580 | $result = $this->CI->$rule($postdata, $param); |
| 581 | 581 | ||
| ... | @@ -588,7 +588,7 @@ class Validation { | ... | @@ -588,7 +588,7 @@ class Validation { |
| 588 | { | 588 | { |
| 589 | $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result; | 589 | $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result; |
| 590 | } | 590 | } |
| 591 | 591 | ||
| 592 | // If the field isn't required and we just processed a callback we'll move on... | 592 | // If the field isn't required and we just processed a callback we'll move on... |
| 593 | if ( ! in_array('required', $rules, TRUE) AND $result !== FALSE) | 593 | if ( ! in_array('required', $rules, TRUE) AND $result !== FALSE) |
| 594 | { | 594 | { |
| ... | @@ -596,15 +596,15 @@ class Validation { | ... | @@ -596,15 +596,15 @@ class Validation { |
| 596 | } | 596 | } |
| 597 | } | 597 | } |
| 598 | else | 598 | else |
| 599 | { | 599 | { |
| 600 | if ( ! method_exists($this, $rule)) | 600 | if ( ! method_exists($this, $rule)) |
| 601 | { | 601 | { |
| 602 | // If our own wrapper function doesn't exist we see if a native PHP function does. | 602 | // If our own wrapper function doesn't exist we see if a native PHP function does. |
| 603 | // Users can use any native PHP function call that has one param. | 603 | // Users can use any native PHP function call that has one param. |
| 604 | if (function_exists($rule)) | 604 | if (function_exists($rule)) |
| 605 | { | 605 | { |
| 606 | $result = $rule($postdata); | 606 | $result = $rule($postdata); |
| 607 | 607 | ||
| 608 | if ($_in_array == TRUE) | 608 | if ($_in_array == TRUE) |
| 609 | { | 609 | { |
| 610 | $this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result; | 610 | $this->_field_data[$row['field']]['postdata'][$cycles] = (is_bool($result)) ? $postdata : $result; |
| ... | @@ -614,7 +614,7 @@ class Validation { | ... | @@ -614,7 +614,7 @@ class Validation { |
| 614 | $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result; | 614 | $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result; |
| 615 | } | 615 | } |
| 616 | } | 616 | } |
| 617 | 617 | ||
| 618 | continue; | 618 | continue; |
| 619 | } | 619 | } |
| 620 | 620 | ||
| ... | @@ -629,40 +629,40 @@ class Validation { | ... | @@ -629,40 +629,40 @@ class Validation { |
| 629 | $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result; | 629 | $this->_field_data[$row['field']]['postdata'] = (is_bool($result)) ? $postdata : $result; |
| 630 | } | 630 | } |
| 631 | } | 631 | } |
| 632 | 632 | ||
| 633 | // Did the rule test negatively? If so, grab the error. | 633 | // Did the rule test negatively? If so, grab the error. |
| 634 | if ($result === FALSE) | 634 | if ($result === FALSE) |
| 635 | { | 635 | { |
| 636 | if ( ! isset($this->_error_messages[$rule])) | 636 | if ( ! isset($this->_error_messages[$rule])) |
| 637 | { | 637 | { |
| 638 | if (FALSE === ($line = $this->get_error_message($rule))) | 638 | if (FALSE === ($line = $this->get_error_message($rule))) |
| 639 | { | 639 | { |
| 640 | $line = 'Unable to access an error message corresponding to your field name.'; | 640 | $line = 'Unable to access an error message corresponding to your field name.'; |
| 641 | } | 641 | } |
| 642 | } | 642 | } |
| 643 | else | 643 | else |
| 644 | { | 644 | { |
| 645 | $line = $this->_error_messages[$rule]; | 645 | $line = $this->_error_messages[$rule]; |
| 646 | } | 646 | } |
| 647 | 647 | ||
| 648 | // Is the parameter we are inserting into the error message the name | 648 | // Is the parameter we are inserting into the error message the name |
| 649 | // of another field? If so we need to grab its "field label" | 649 | // of another field? If so we need to grab its "field label" |
| 650 | if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label'])) | 650 | if (isset($this->_field_data[$param]) AND isset($this->_field_data[$param]['label'])) |
| 651 | { | 651 | { |
| 652 | $param = $this->_field_data[$param]['label']; | 652 | $param = $this->_field_data[$param]['label']; |
| 653 | } | 653 | } |
| 654 | 654 | ||
| 655 | // Build the error message | 655 | // Build the error message |
| 656 | $message = sprintf($line, $this->_translate_fieldname($row['label']), $param); | 656 | $message = sprintf($line, $this->_translate_fieldname($row['label']), $param); |
| 657 | 657 | ||
| 658 | // Save the error message | 658 | // Save the error message |
| 659 | $this->_field_data[$row['field']]['error'] = $message; | 659 | $this->_field_data[$row['field']]['error'] = $message; |
| 660 | 660 | ||
| 661 | if ( ! isset($this->_error_array[$row['field']])) | 661 | if ( ! isset($this->_error_array[$row['field']])) |
| 662 | { | 662 | { |
| 663 | $this->_error_array[$row['field']] = $message; | 663 | $this->_error_array[$row['field']] = $message; |
| 664 | } | 664 | } |
| 665 | 665 | ||
| 666 | return; | 666 | return; |
| 667 | } | 667 | } |
| 668 | } | 668 | } |
| ... | @@ -670,25 +670,25 @@ class Validation { | ... | @@ -670,25 +670,25 @@ class Validation { |
| 670 | 670 | ||
| 671 | function form_error($field = '', $prefix = '', $suffix = '') | 671 | function form_error($field = '', $prefix = '', $suffix = '') |
| 672 | { | 672 | { |
| 673 | 673 | ||
| 674 | 674 | ||
| 675 | return $this->error($field, $prefix, $suffix); | 675 | return $this->error($field, $prefix, $suffix); |
| 676 | } | 676 | } |
| 677 | 677 | ||
| 678 | function validation_errors($prefix = '', $suffix = '') | 678 | function validation_errors($prefix = '', $suffix = '') |
| 679 | { | 679 | { |
| 680 | return $this->error_string($prefix, $suffix); | 680 | return $this->error_string($prefix, $suffix); |
| 681 | } | 681 | } |
| 682 | 682 | ||
| 683 | // -------------------------------------------------------------------- | 683 | // -------------------------------------------------------------------- |
| 684 | 684 | ||
| 685 | /** | 685 | /** |
| 686 | * Translate a field name | 686 | * Translate a field name |
| 687 | * | 687 | * |
| 688 | * @access private | 688 | * @access private |
| 689 | * @param string the field name | 689 | * @param string the field name |
| 690 | * @return string | 690 | * @return string |
| 691 | */ | 691 | */ |
| 692 | function _translate_fieldname($fieldname) | 692 | function _translate_fieldname($fieldname) |
| 693 | { | 693 | { |
| 694 | // Do we need to translate the field name? | 694 | // Do we need to translate the field name? |
| ... | @@ -696,8 +696,8 @@ class Validation { | ... | @@ -696,8 +696,8 @@ class Validation { |
| 696 | if (substr($fieldname, 0, 5) == 'lang:') | 696 | if (substr($fieldname, 0, 5) == 'lang:') |
| 697 | { | 697 | { |
| 698 | // Grab the variable | 698 | // Grab the variable |
| 699 | $line = substr($fieldname, 5); | 699 | $line = substr($fieldname, 5); |
| 700 | 700 | ||
| 701 | // Were we able to translate the field name? If not we use $line | 701 | // Were we able to translate the field name? If not we use $line |
| 702 | if (FALSE === ($fieldname = $this->get_error_message($line))) | 702 | if (FALSE === ($fieldname = $this->get_error_message($line))) |
| 703 | { | 703 | { |
| ... | @@ -709,7 +709,7 @@ class Validation { | ... | @@ -709,7 +709,7 @@ class Validation { |
| 709 | } | 709 | } |
| 710 | 710 | ||
| 711 | // -------------------------------------------------------------------- | 711 | // -------------------------------------------------------------------- |
| 712 | 712 | ||
| 713 | /** | 713 | /** |
| 714 | * Get the value from a form | 714 | * Get the value from a form |
| 715 | * | 715 | * |
| ... | @@ -720,19 +720,19 @@ class Validation { | ... | @@ -720,19 +720,19 @@ class Validation { |
| 720 | * @param string the field name | 720 | * @param string the field name |
| 721 | * @param string | 721 | * @param string |
| 722 | * @return void | 722 | * @return void |
| 723 | */ | 723 | */ |
| 724 | function set_value($field = '', $default = '') | 724 | function set_value($field = '', $default = '') |
| 725 | { | 725 | { |
| 726 | if ( ! isset($this->_field_data[$field])) | 726 | if ( ! isset($this->_field_data[$field])) |
| 727 | { | 727 | { |
| 728 | return $default; | 728 | return $default; |
| 729 | } | 729 | } |
| 730 | 730 | ||
| 731 | return $this->_field_data[$field]['postdata']; | 731 | return $this->_field_data[$field]['postdata']; |
| 732 | } | 732 | } |
| 733 | 733 | ||
| 734 | // -------------------------------------------------------------------- | 734 | // -------------------------------------------------------------------- |
| 735 | 735 | ||
| 736 | /** | 736 | /** |
| 737 | * Set Select | 737 | * Set Select |
| 738 | * | 738 | * |
| ... | @@ -743,9 +743,9 @@ class Validation { | ... | @@ -743,9 +743,9 @@ class Validation { |
| 743 | * @param string | 743 | * @param string |
| 744 | * @param string | 744 | * @param string |
| 745 | * @return string | 745 | * @return string |
| 746 | */ | 746 | */ |
| 747 | function set_select($field = '', $value = '', $default = FALSE) | 747 | function set_select($field = '', $value = '', $default = FALSE) |
| 748 | { | 748 | { |
| 749 | if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) | 749 | if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) |
| 750 | { | 750 | { |
| 751 | if ($default === TRUE AND count($this->_field_data) === 0) | 751 | if ($default === TRUE AND count($this->_field_data) === 0) |
| ... | @@ -754,9 +754,9 @@ class Validation { | ... | @@ -754,9 +754,9 @@ class Validation { |
| 754 | } | 754 | } |
| 755 | return ''; | 755 | return ''; |
| 756 | } | 756 | } |
| 757 | 757 | ||
| 758 | $field = $this->_field_data[$field]['postdata']; | 758 | $field = $this->_field_data[$field]['postdata']; |
| 759 | 759 | ||
| 760 | if (is_array($field)) | 760 | if (is_array($field)) |
| 761 | { | 761 | { |
| 762 | if ( ! in_array($value, $field)) | 762 | if ( ! in_array($value, $field)) |
| ... | @@ -771,12 +771,12 @@ class Validation { | ... | @@ -771,12 +771,12 @@ class Validation { |
| 771 | return ''; | 771 | return ''; |
| 772 | } | 772 | } |
| 773 | } | 773 | } |
| 774 | 774 | ||
| 775 | return ' selected="selected"'; | 775 | return ' selected="selected"'; |
| 776 | } | 776 | } |
| 777 | 777 | ||
| 778 | // -------------------------------------------------------------------- | 778 | // -------------------------------------------------------------------- |
| 779 | 779 | ||
| 780 | /** | 780 | /** |
| 781 | * Set Radio | 781 | * Set Radio |
| 782 | * | 782 | * |
| ... | @@ -787,7 +787,7 @@ class Validation { | ... | @@ -787,7 +787,7 @@ class Validation { |
| 787 | * @param string | 787 | * @param string |
| 788 | * @param string | 788 | * @param string |
| 789 | * @return string | 789 | * @return string |
| 790 | */ | 790 | */ |
| 791 | function set_radio($field = '', $value = '', $default = FALSE) | 791 | function set_radio($field = '', $value = '', $default = FALSE) |
| 792 | { | 792 | { |
| 793 | if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) | 793 | if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) |
| ... | @@ -798,9 +798,9 @@ class Validation { | ... | @@ -798,9 +798,9 @@ class Validation { |
| 798 | } | 798 | } |
| 799 | return ''; | 799 | return ''; |
| 800 | } | 800 | } |
| 801 | 801 | ||
| 802 | $field = $this->_field_data[$field]['postdata']; | 802 | $field = $this->_field_data[$field]['postdata']; |
| 803 | 803 | ||
| 804 | if (is_array($field)) | 804 | if (is_array($field)) |
| 805 | { | 805 | { |
| 806 | if ( ! in_array($value, $field)) | 806 | if ( ! in_array($value, $field)) |
| ... | @@ -815,12 +815,12 @@ class Validation { | ... | @@ -815,12 +815,12 @@ class Validation { |
| 815 | return ''; | 815 | return ''; |
| 816 | } | 816 | } |
| 817 | } | 817 | } |
| 818 | 818 | ||
| 819 | return ' checked="checked"'; | 819 | return ' checked="checked"'; |
| 820 | } | 820 | } |
| 821 | 821 | ||
| 822 | // -------------------------------------------------------------------- | 822 | // -------------------------------------------------------------------- |
| 823 | 823 | ||
| 824 | /** | 824 | /** |
| 825 | * Set Checkbox | 825 | * Set Checkbox |
| 826 | * | 826 | * |
| ... | @@ -831,7 +831,7 @@ class Validation { | ... | @@ -831,7 +831,7 @@ class Validation { |
| 831 | * @param string | 831 | * @param string |
| 832 | * @param string | 832 | * @param string |
| 833 | * @return string | 833 | * @return string |
| 834 | */ | 834 | */ |
| 835 | function set_checkbox($field = '', $value = '', $default = FALSE) | 835 | function set_checkbox($field = '', $value = '', $default = FALSE) |
| 836 | { | 836 | { |
| 837 | if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) | 837 | if ( ! isset($this->_field_data[$field]) OR ! isset($this->_field_data[$field]['postdata'])) |
| ... | @@ -842,9 +842,9 @@ class Validation { | ... | @@ -842,9 +842,9 @@ class Validation { |
| 842 | } | 842 | } |
| 843 | return ''; | 843 | return ''; |
| 844 | } | 844 | } |
| 845 | 845 | ||
| 846 | $field = $this->_field_data[$field]['postdata']; | 846 | $field = $this->_field_data[$field]['postdata']; |
| 847 | 847 | ||
| 848 | if (is_array($field)) | 848 | if (is_array($field)) |
| 849 | { | 849 | { |
| 850 | if ( ! in_array($value, $field)) | 850 | if ( ! in_array($value, $field)) |
| ... | @@ -859,12 +859,12 @@ class Validation { | ... | @@ -859,12 +859,12 @@ class Validation { |
| 859 | return ''; | 859 | return ''; |
| 860 | } | 860 | } |
| 861 | } | 861 | } |
| 862 | 862 | ||
| 863 | return ' checked="checked"'; | 863 | return ' checked="checked"'; |
| 864 | } | 864 | } |
| 865 | 865 | ||
| 866 | // -------------------------------------------------------------------- | 866 | // -------------------------------------------------------------------- |
| 867 | 867 | ||
| 868 | /** | 868 | /** |
| 869 | * Required | 869 | * Required |
| 870 | * | 870 | * |
| ... | @@ -883,9 +883,9 @@ class Validation { | ... | @@ -883,9 +883,9 @@ class Validation { |
| 883 | return ( ! empty($str)); | 883 | return ( ! empty($str)); |
| 884 | } | 884 | } |
| 885 | } | 885 | } |
| 886 | 886 | ||
| 887 | // -------------------------------------------------------------------- | 887 | // -------------------------------------------------------------------- |
| 888 | 888 | ||
| 889 | /** | 889 | /** |
| 890 | * Match one field to another | 890 | * Match one field to another |
| 891 | * | 891 | * |
| ... | @@ -898,16 +898,16 @@ class Validation { | ... | @@ -898,16 +898,16 @@ class Validation { |
| 898 | { | 898 | { |
| 899 | if ( ! isset($_POST[$field])) | 899 | if ( ! isset($_POST[$field])) |
| 900 | { | 900 | { |
| 901 | return FALSE; | 901 | return FALSE; |
| 902 | } | 902 | } |
| 903 | 903 | ||
| 904 | $field = $_POST[$field]; | 904 | $field = $_POST[$field]; |
| 905 | 905 | ||
| 906 | return ($str !== $field) ? FALSE : TRUE; | 906 | return ($str !== $field) ? FALSE : TRUE; |
| 907 | } | 907 | } |
| 908 | 908 | ||
| 909 | // -------------------------------------------------------------------- | 909 | // -------------------------------------------------------------------- |
| 910 | 910 | ||
| 911 | /** | 911 | /** |
| 912 | * Minimum Length | 912 | * Minimum Length |
| 913 | * | 913 | * |
| ... | @@ -915,7 +915,7 @@ class Validation { | ... | @@ -915,7 +915,7 @@ class Validation { |
| 915 | * @param string | 915 | * @param string |
| 916 | * @param value | 916 | * @param value |
| 917 | * @return bool | 917 | * @return bool |
| 918 | */ | 918 | */ |
| 919 | function min_length($str, $val) | 919 | function min_length($str, $val) |
| 920 | { | 920 | { |
| 921 | if (preg_match("/[^0-9]/", $val)) | 921 | if (preg_match("/[^0-9]/", $val)) |
| ... | @@ -925,14 +925,14 @@ class Validation { | ... | @@ -925,14 +925,14 @@ class Validation { |
| 925 | 925 | ||
| 926 | if (function_exists('mb_strlen')) | 926 | if (function_exists('mb_strlen')) |
| 927 | { | 927 | { |
| 928 | return (mb_strlen($str) < $val) ? FALSE : TRUE; | 928 | return (mb_strlen($str) < $val) ? FALSE : TRUE; |
| 929 | } | 929 | } |
| 930 | 930 | ||
| 931 | return (strlen($str) < $val) ? FALSE : TRUE; | 931 | return (strlen($str) < $val) ? FALSE : TRUE; |
| 932 | } | 932 | } |
| 933 | 933 | ||
| 934 | // -------------------------------------------------------------------- | 934 | // -------------------------------------------------------------------- |
| 935 | 935 | ||
| 936 | /** | 936 | /** |
| 937 | * Max Length | 937 | * Max Length |
| 938 | * | 938 | * |
| ... | @@ -940,7 +940,7 @@ class Validation { | ... | @@ -940,7 +940,7 @@ class Validation { |
| 940 | * @param string | 940 | * @param string |
| 941 | * @param value | 941 | * @param value |
| 942 | * @return bool | 942 | * @return bool |
| 943 | */ | 943 | */ |
| 944 | function max_length($str, $val) | 944 | function max_length($str, $val) |
| 945 | { | 945 | { |
| 946 | if (preg_match("/[^0-9]/", $val)) | 946 | if (preg_match("/[^0-9]/", $val)) |
| ... | @@ -950,14 +950,14 @@ class Validation { | ... | @@ -950,14 +950,14 @@ class Validation { |
| 950 | 950 | ||
| 951 | if (function_exists('mb_strlen')) | 951 | if (function_exists('mb_strlen')) |
| 952 | { | 952 | { |
| 953 | return (mb_strlen($str) > $val) ? FALSE : TRUE; | 953 | return (mb_strlen($str) > $val) ? FALSE : TRUE; |
| 954 | } | 954 | } |
| 955 | 955 | ||
| 956 | return (strlen($str) > $val) ? FALSE : TRUE; | 956 | return (strlen($str) > $val) ? FALSE : TRUE; |
| 957 | } | 957 | } |
| 958 | 958 | ||
| 959 | // -------------------------------------------------------------------- | 959 | // -------------------------------------------------------------------- |
| 960 | 960 | ||
| 961 | /** | 961 | /** |
| 962 | * Exact Length | 962 | * Exact Length |
| 963 | * | 963 | * |
| ... | @@ -965,7 +965,7 @@ class Validation { | ... | @@ -965,7 +965,7 @@ class Validation { |
| 965 | * @param string | 965 | * @param string |
| 966 | * @param value | 966 | * @param value |
| 967 | * @return bool | 967 | * @return bool |
| 968 | */ | 968 | */ |
| 969 | function exact_length($str, $val) | 969 | function exact_length($str, $val) |
| 970 | { | 970 | { |
| 971 | if (preg_match("/[^0-9]/", $val)) | 971 | if (preg_match("/[^0-9]/", $val)) |
| ... | @@ -975,42 +975,42 @@ class Validation { | ... | @@ -975,42 +975,42 @@ class Validation { |
| 975 | 975 | ||
| 976 | if (function_exists('mb_strlen')) | 976 | if (function_exists('mb_strlen')) |
| 977 | { | 977 | { |
| 978 | return (mb_strlen($str) != $val) ? FALSE : TRUE; | 978 | return (mb_strlen($str) != $val) ? FALSE : TRUE; |
| 979 | } | 979 | } |
| 980 | 980 | ||
| 981 | return (strlen($str) != $val) ? FALSE : TRUE; | 981 | return (strlen($str) != $val) ? FALSE : TRUE; |
| 982 | } | 982 | } |
| 983 | 983 | ||
| 984 | // -------------------------------------------------------------------- | 984 | // -------------------------------------------------------------------- |
| 985 | 985 | ||
| 986 | /** | 986 | /** |
| 987 | * Valid Email | 987 | * Valid Email |
| 988 | * | 988 | * |
| 989 | * @access public | 989 | * @access public |
| 990 | * @param string | 990 | * @param string |
| 991 | * @return bool | 991 | * @return bool |
| 992 | */ | 992 | */ |
| 993 | function valid_email($str) | 993 | function valid_email($str) |
| 994 | { | 994 | { |
| 995 | return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; | 995 | return ( ! preg_match("/^([a-z0-9\+_\-]+)(\.[a-z0-9\+_\-]+)*@([a-z0-9\-]+\.)+[a-z]{2,6}$/ix", $str)) ? FALSE : TRUE; |
| 996 | } | 996 | } |
| 997 | 997 | ||
| 998 | // -------------------------------------------------------------------- | 998 | // -------------------------------------------------------------------- |
| 999 | 999 | ||
| 1000 | /** | 1000 | /** |
| 1001 | * Valid Emails | 1001 | * Valid Emails |
| 1002 | * | 1002 | * |
| 1003 | * @access public | 1003 | * @access public |
| 1004 | * @param string | 1004 | * @param string |
| 1005 | * @return bool | 1005 | * @return bool |
| 1006 | */ | 1006 | */ |
| 1007 | function valid_emails($str) | 1007 | function valid_emails($str) |
| 1008 | { | 1008 | { |
| 1009 | if (strpos($str, ',') === FALSE) | 1009 | if (strpos($str, ',') === FALSE) |
| 1010 | { | 1010 | { |
| 1011 | return $this->valid_email(trim($str)); | 1011 | return $this->valid_email(trim($str)); |
| 1012 | } | 1012 | } |
| 1013 | 1013 | ||
| 1014 | foreach(explode(',', $str) as $email) | 1014 | foreach(explode(',', $str) as $email) |
| 1015 | { | 1015 | { |
| 1016 | if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE) | 1016 | if (trim($email) != '' && $this->valid_email(trim($email)) === FALSE) |
| ... | @@ -1018,12 +1018,12 @@ class Validation { | ... | @@ -1018,12 +1018,12 @@ class Validation { |
| 1018 | return FALSE; | 1018 | return FALSE; |
| 1019 | } | 1019 | } |
| 1020 | } | 1020 | } |
| 1021 | 1021 | ||
| 1022 | return TRUE; | 1022 | return TRUE; |
| 1023 | } | 1023 | } |
| 1024 | 1024 | ||
| 1025 | // -------------------------------------------------------------------- | 1025 | // -------------------------------------------------------------------- |
| 1026 | 1026 | ||
| 1027 | /** | 1027 | /** |
| 1028 | * Validate IP Address | 1028 | * Validate IP Address |
| 1029 | * | 1029 | * |
| ... | @@ -1037,56 +1037,56 @@ class Validation { | ... | @@ -1037,56 +1037,56 @@ class Validation { |
| 1037 | } | 1037 | } |
| 1038 | 1038 | ||
| 1039 | // -------------------------------------------------------------------- | 1039 | // -------------------------------------------------------------------- |
| 1040 | 1040 | ||
| 1041 | /** | 1041 | /** |
| 1042 | * Alpha | 1042 | * Alpha |
| 1043 | * | 1043 | * |
| 1044 | * @access public | 1044 | * @access public |
| 1045 | * @param string | 1045 | * @param string |
| 1046 | * @return bool | 1046 | * @return bool |
| 1047 | */ | 1047 | */ |
| 1048 | function alpha($str) | 1048 | function alpha($str) |
| 1049 | { | 1049 | { |
| 1050 | return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE; | 1050 | return ( ! preg_match("/^([a-z])+$/i", $str)) ? FALSE : TRUE; |
| 1051 | } | 1051 | } |
| 1052 | 1052 | ||
| 1053 | // -------------------------------------------------------------------- | 1053 | // -------------------------------------------------------------------- |
| 1054 | 1054 | ||
| 1055 | /** | 1055 | /** |
| 1056 | * Alpha-numeric | 1056 | * Alpha-numeric |
| 1057 | * | 1057 | * |
| 1058 | * @access public | 1058 | * @access public |
| 1059 | * @param string | 1059 | * @param string |
| 1060 | * @return bool | 1060 | * @return bool |
| 1061 | */ | 1061 | */ |
| 1062 | function alpha_numeric($str) | 1062 | function alpha_numeric($str) |
| 1063 | { | 1063 | { |
| 1064 | return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE; | 1064 | return ( ! preg_match("/^([a-z0-9])+$/i", $str)) ? FALSE : TRUE; |
| 1065 | } | 1065 | } |
| 1066 | 1066 | ||
| 1067 | // -------------------------------------------------------------------- | 1067 | // -------------------------------------------------------------------- |
| 1068 | 1068 | ||
| 1069 | /** | 1069 | /** |
| 1070 | * Alpha-numeric with underscores and dashes | 1070 | * Alpha-numeric with underscores and dashes |
| 1071 | * | 1071 | * |
| 1072 | * @access public | 1072 | * @access public |
| 1073 | * @param string | 1073 | * @param string |
| 1074 | * @return bool | 1074 | * @return bool |
| 1075 | */ | 1075 | */ |
| 1076 | function alpha_dash($str) | 1076 | function alpha_dash($str) |
| 1077 | { | 1077 | { |
| 1078 | return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE; | 1078 | return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE; |
| 1079 | } | 1079 | } |
| 1080 | 1080 | ||
| 1081 | // -------------------------------------------------------------------- | 1081 | // -------------------------------------------------------------------- |
| 1082 | 1082 | ||
| 1083 | /** | 1083 | /** |
| 1084 | * Numeric | 1084 | * Numeric |
| 1085 | * | 1085 | * |
| 1086 | * @access public | 1086 | * @access public |
| 1087 | * @param string | 1087 | * @param string |
| 1088 | * @return bool | 1088 | * @return bool |
| 1089 | */ | 1089 | */ |
| 1090 | function numeric($str) | 1090 | function numeric($str) |
| 1091 | { | 1091 | { |
| 1092 | return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str); | 1092 | return (bool)preg_match( '/^[\-+]?[0-9]*\.?[0-9]+$/', $str); |
| ... | @@ -1105,22 +1105,22 @@ class Validation { | ... | @@ -1105,22 +1105,22 @@ class Validation { |
| 1105 | function is_numeric($str) | 1105 | function is_numeric($str) |
| 1106 | { | 1106 | { |
| 1107 | return ( ! is_numeric($str)) ? FALSE : TRUE; | 1107 | return ( ! is_numeric($str)) ? FALSE : TRUE; |
| 1108 | } | 1108 | } |
| 1109 | 1109 | ||
| 1110 | // -------------------------------------------------------------------- | 1110 | // -------------------------------------------------------------------- |
| 1111 | 1111 | ||
| 1112 | /** | 1112 | /** |
| 1113 | * Integer | 1113 | * Integer |
| 1114 | * | 1114 | * |
| 1115 | * @access public | 1115 | * @access public |
| 1116 | * @param string | 1116 | * @param string |
| 1117 | * @return bool | 1117 | * @return bool |
| 1118 | */ | 1118 | */ |
| 1119 | function integer($str) | 1119 | function integer($str) |
| 1120 | { | 1120 | { |
| 1121 | return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str); | 1121 | return (bool)preg_match( '/^[\-+]?[0-9]+$/', $str); |
| 1122 | } | 1122 | } |
| 1123 | 1123 | ||
| 1124 | // -------------------------------------------------------------------- | 1124 | // -------------------------------------------------------------------- |
| 1125 | 1125 | ||
| 1126 | /** | 1126 | /** |
| ... | @@ -1131,7 +1131,7 @@ class Validation { | ... | @@ -1131,7 +1131,7 @@ class Validation { |
| 1131 | * @return bool | 1131 | * @return bool |
| 1132 | */ | 1132 | */ |
| 1133 | function is_natural($str) | 1133 | function is_natural($str) |
| 1134 | { | 1134 | { |
| 1135 | return (bool)preg_match( '/^[0-9]+$/', $str); | 1135 | return (bool)preg_match( '/^[0-9]+$/', $str); |
| 1136 | } | 1136 | } |
| 1137 | 1137 | ||
| ... | @@ -1150,17 +1150,17 @@ class Validation { | ... | @@ -1150,17 +1150,17 @@ class Validation { |
| 1150 | { | 1150 | { |
| 1151 | return FALSE; | 1151 | return FALSE; |
| 1152 | } | 1152 | } |
| 1153 | 1153 | ||
| 1154 | if ($str == 0) | 1154 | if ($str == 0) |
| 1155 | { | 1155 | { |
| 1156 | return FALSE; | 1156 | return FALSE; |
| 1157 | } | 1157 | } |
| 1158 | 1158 | ||
| 1159 | return TRUE; | 1159 | return TRUE; |
| 1160 | } | 1160 | } |
| 1161 | 1161 | ||
| 1162 | // -------------------------------------------------------------------- | 1162 | // -------------------------------------------------------------------- |
| 1163 | 1163 | ||
| 1164 | /** | 1164 | /** |
| 1165 | * Valid Base64 | 1165 | * Valid Base64 |
| 1166 | * | 1166 | * |
| ... | @@ -1175,9 +1175,9 @@ class Validation { | ... | @@ -1175,9 +1175,9 @@ class Validation { |
| 1175 | { | 1175 | { |
| 1176 | return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str); | 1176 | return (bool) ! preg_match('/[^a-zA-Z0-9\/\+=]/', $str); |
| 1177 | } | 1177 | } |
| 1178 | 1178 | ||
| 1179 | // -------------------------------------------------------------------- | 1179 | // -------------------------------------------------------------------- |
| 1180 | 1180 | ||
| 1181 | /** | 1181 | /** |
| 1182 | * Prep data for form | 1182 | * Prep data for form |
| 1183 | * | 1183 | * |
| ... | @@ -1196,10 +1196,10 @@ class Validation { | ... | @@ -1196,10 +1196,10 @@ class Validation { |
| 1196 | { | 1196 | { |
| 1197 | $data[$key] = $this->prep_for_form($val); | 1197 | $data[$key] = $this->prep_for_form($val); |
| 1198 | } | 1198 | } |
| 1199 | 1199 | ||
| 1200 | return $data; | 1200 | return $data; |
| 1201 | } | 1201 | } |
| 1202 | 1202 | ||
| 1203 | if ($this->_safe_form_data == FALSE OR $data === '') | 1203 | if ($this->_safe_form_data == FALSE OR $data === '') |
| 1204 | { | 1204 | { |
| 1205 | return $data; | 1205 | return $data; |
| ... | @@ -1207,68 +1207,68 @@ class Validation { | ... | @@ -1207,68 +1207,68 @@ class Validation { |
| 1207 | 1207 | ||
| 1208 | return str_replace(array("'", '"', '<', '>'), array("'", """, '<', '>'), stripslashes($data)); | 1208 | return str_replace(array("'", '"', '<', '>'), array("'", """, '<', '>'), stripslashes($data)); |
| 1209 | } | 1209 | } |
| 1210 | 1210 | ||
| 1211 | // -------------------------------------------------------------------- | 1211 | // -------------------------------------------------------------------- |
| 1212 | 1212 | ||
| 1213 | /** | 1213 | /** |
| 1214 | * Prep URL | 1214 | * Prep URL |
| 1215 | * | 1215 | * |
| 1216 | * @access public | 1216 | * @access public |
| 1217 | * @param string | 1217 | * @param string |
| 1218 | * @return string | 1218 | * @return string |
| 1219 | */ | 1219 | */ |
| 1220 | function prep_url($str = '') | 1220 | function prep_url($str = '') |
| 1221 | { | 1221 | { |
| 1222 | if ($str == 'http://' OR $str == '') | 1222 | if ($str == 'http://' OR $str == '') |
| 1223 | { | 1223 | { |
| 1224 | return ''; | 1224 | return ''; |
| 1225 | } | 1225 | } |
| 1226 | 1226 | ||
| 1227 | if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://') | 1227 | if (substr($str, 0, 7) != 'http://' && substr($str, 0, 8) != 'https://') |
| 1228 | { | 1228 | { |
| 1229 | $str = 'http://'.$str; | 1229 | $str = 'http://'.$str; |
| 1230 | } | 1230 | } |
| 1231 | 1231 | ||
| 1232 | return $str; | 1232 | return $str; |
| 1233 | } | 1233 | } |
| 1234 | 1234 | ||
| 1235 | // -------------------------------------------------------------------- | 1235 | // -------------------------------------------------------------------- |
| 1236 | 1236 | ||
| 1237 | /** | 1237 | /** |
| 1238 | * Strip Image Tags | 1238 | * Strip Image Tags |
| 1239 | * | 1239 | * |
| 1240 | * @access public | 1240 | * @access public |
| 1241 | * @param string | 1241 | * @param string |
| 1242 | * @return string | 1242 | * @return string |
| 1243 | */ | 1243 | */ |
| 1244 | function strip_image_tags($str) | 1244 | function strip_image_tags($str) |
| 1245 | { | 1245 | { |
| 1246 | return $this->CI->input->strip_image_tags($str); | 1246 | return $this->CI->input->strip_image_tags($str); |
| 1247 | } | 1247 | } |
| 1248 | 1248 | ||
| 1249 | // -------------------------------------------------------------------- | 1249 | // -------------------------------------------------------------------- |
| 1250 | 1250 | ||
| 1251 | /** | 1251 | /** |
| 1252 | * XSS Clean | 1252 | * XSS Clean |
| 1253 | * | 1253 | * |
| 1254 | * @access public | 1254 | * @access public |
| 1255 | * @param string | 1255 | * @param string |
| 1256 | * @return string | 1256 | * @return string |
| 1257 | */ | 1257 | */ |
| 1258 | function xss_clean($str) | 1258 | function xss_clean($str) |
| 1259 | { | 1259 | { |
| 1260 | return $this->CI->input->xss_clean($str); | 1260 | return $this->CI->input->xss_clean($str); |
| 1261 | } | 1261 | } |
| 1262 | 1262 | ||
| 1263 | // -------------------------------------------------------------------- | 1263 | // -------------------------------------------------------------------- |
| 1264 | 1264 | ||
| 1265 | /** | 1265 | /** |
| 1266 | * Convert PHP tags to entities | 1266 | * Convert PHP tags to entities |
| 1267 | * | 1267 | * |
| 1268 | * @access public | 1268 | * @access public |
| 1269 | * @param string | 1269 | * @param string |
| 1270 | * @return string | 1270 | * @return string |
| 1271 | */ | 1271 | */ |
| 1272 | function encode_php_tags($str) | 1272 | function encode_php_tags($str) |
| 1273 | { | 1273 | { |
| 1274 | return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('<?php', '<?PHP', '<?', '?>'), $str); | 1274 | return str_replace(array('<?php', '<?PHP', '<?', '?>'), array('<?php', '<?PHP', '<?', '?>'), $str); | ... | ... |
| ... | @@ -4,7 +4,7 @@ use Tz\WordPress\Tools\Notifications; | ... | @@ -4,7 +4,7 @@ use Tz\WordPress\Tools\Notifications; |
| 4 | use Tz\WordPress\Tools; | 4 | use Tz\WordPress\Tools; |
| 5 | ?> | 5 | ?> |
| 6 | 6 | ||
| 7 | <link type="text/css" href="<?php echo Tools\url('assets/css/smoothness/jquery-ui-1.8.4.custom.css', __FILE__)?>" rel="stylesheet" /> | 7 | <link type="text/css" href="<?php echo Tools\url('assets/css/smoothness/jquery-ui-1.8.4.custom.css', __FILE__)?>" rel="stylesheet" /> |
| 8 | <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery-1.4.2.min.js', __FILE__)?>"></script> | 8 | <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery-1.4.2.min.js', __FILE__)?>"></script> |
| 9 | <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery-ui-1.8.4.custom.min.js', __FILE__)?>"></script> | 9 | <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/jquery-ui-1.8.4.custom.min.js', __FILE__)?>"></script> |
| 10 | <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/datetimepicker.js', __FILE__)?>"></script> | 10 | <script type="text/javascript" src="<?php echo Tools\url('assets/scripts/datetimepicker.js', __FILE__)?>"></script> |
| ... | @@ -13,7 +13,7 @@ use Tz\WordPress\Tools; | ... | @@ -13,7 +13,7 @@ use Tz\WordPress\Tools; |
| 13 | <div id="" class="wrap"> | 13 | <div id="" class="wrap"> |
| 14 | 14 | ||
| 15 | <h2>Notifications - Edit</h2> | 15 | <h2>Notifications - Edit</h2> |
| 16 | 16 | ||
| 17 | <?php if (isset($flash) && $flash !=""): ?> | 17 | <?php if (isset($flash) && $flash !=""): ?> |
| 18 | <div class="post-success"> | 18 | <div class="post-success"> |
| 19 | <?php echo $flash; ?> | 19 | <?php echo $flash; ?> |
| ... | @@ -27,15 +27,15 @@ use Tz\WordPress\Tools; | ... | @@ -27,15 +27,15 @@ use Tz\WordPress\Tools; |
| 27 | <?php endif; ?> | 27 | <?php endif; ?> |
| 28 | </div> | 28 | </div> |
| 29 | <?php endif;?> | 29 | <?php endif;?> |
| 30 | 30 | ||
| 31 | 31 | ||
| 32 | 32 | ||
| 33 | 33 | ||
| 34 | 34 | ||
| 35 | <form enctype="multipart/form-data" method="post" action="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $_GET['page_id']?>"> | 35 | <form enctype="multipart/form-data" method="post" action="/wp-admin/admin.php?page=notifications&action=edit&page_id=<?php echo $_GET['page_id']?>"> |
| 36 | 36 | ||
| 37 | <input type="hidden" name="_POSTED_" value="yes" /> | 37 | <input type="hidden" name="_POSTED_" value="yes" /> |
| 38 | 38 | ||
| 39 | <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;"> | 39 | <table cellspacing="0" class="widefat post fixed" style="margin-top:15px;"> |
| 40 | <thead> | 40 | <thead> |
| 41 | <tr> | 41 | <tr> |
| ... | @@ -63,7 +63,7 @@ use Tz\WordPress\Tools; | ... | @@ -63,7 +63,7 @@ use Tz\WordPress\Tools; |
| 63 | <tr class="scheduled_sendto"> | 63 | <tr class="scheduled_sendto"> |
| 64 | <td>Sent To:</td> | 64 | <td>Sent To:</td> |
| 65 | <td> | 65 | <td> |
| 66 | 66 | ||
| 67 | <?php | 67 | <?php |
| 68 | if ($entry->details['sendto'] == "report" ): ?> | 68 | if ($entry->details['sendto'] == "report" ): ?> |
| 69 | <input type="hidden" name="sendto" value="<?php echo $entry->details['sendto']; ?>"/> | 69 | <input type="hidden" name="sendto" value="<?php echo $entry->details['sendto']; ?>"/> |
| ... | @@ -78,25 +78,25 @@ use Tz\WordPress\Tools; | ... | @@ -78,25 +78,25 @@ use Tz\WordPress\Tools; |
| 78 | </optgroup> | 78 | </optgroup> |
| 79 | </select> | 79 | </select> |
| 80 | <?php endif; ?> | 80 | <?php endif; ?> |
| 81 | 81 | ||
| 82 | 82 | ||
| 83 | <?php echo $validation->form_error('sendto');?> | 83 | <?php echo $validation->form_error('sendto');?> |
| 84 | </td> | 84 | </td> |
| 85 | </tr> | 85 | </tr> |
| 86 | 86 | ||
| 87 | <tr class="scheduled-extended"> | 87 | <tr class="scheduled-extended"> |
| 88 | <td>Execute Date / Time</td> | 88 | <td>Execute Date / Time</td> |
| 89 | <td><input type="text" name="execute_date" id="execute_date" class="wide-input-field date-pick" readonly="readonly" value="<?php echo $validation->set_value('execute_date',$entry->details['execute_date']);?>" /><?php echo $validation->form_error('execute_date');?></td> | 89 | <td><input type="text" name="execute_date" id="execute_date" class="wide-input-field date-pick" readonly="readonly" value="<?php echo $validation->set_value('execute_date',$entry->details['execute_date']);?>" /><?php echo $validation->form_error('execute_date');?></td> |
| 90 | </tr> | 90 | </tr> |
| 91 | 91 | ||
| 92 | <tr class="trigger-extended"> | 92 | <tr class="trigger-extended"> |
| 93 | <td>Trigger</td> | 93 | <td>Trigger</td> |
| 94 | <td><input type="text" name="trigger" id="trigger" class="wide-input-field" value="<?php echo $validation->set_value('trigger',$entry->details['trigger']);?>" /><?php echo $validation->form_error('trigger');?></td> | 94 | <td><input type="text" name="trigger" id="trigger" class="wide-input-field" value="<?php echo $validation->set_value('trigger',$entry->details['trigger']);?>" /><?php echo $validation->form_error('trigger');?></td> |
| 95 | </tr> | 95 | </tr> |
| 96 | 96 | ||
| 97 | </tbody> | 97 | </tbody> |
| 98 | </table> | 98 | </table> |
| 99 | 99 | ||
| 100 | <table cellspacing="0" class="widefat post fixed expandable" style="margin-top:15px;"> | 100 | <table cellspacing="0" class="widefat post fixed expandable" style="margin-top:15px;"> |
| 101 | <thead> | 101 | <thead> |
| 102 | <tr> | 102 | <tr> |
| ... | @@ -117,12 +117,12 @@ use Tz\WordPress\Tools; | ... | @@ -117,12 +117,12 @@ use Tz\WordPress\Tools; |
| 117 | <td>HTML Version (optional)</td> | 117 | <td>HTML Version (optional)</td> |
| 118 | <td><textarea name="html" id="htmlversion" class="wide-input-field" rows="10" style="width:100%;"><?php echo $validation->set_value('html',$entry->email['html']);?></textarea><?php echo $validation->form_error('html');?></td> | 118 | <td><textarea name="html" id="htmlversion" class="wide-input-field" rows="10" style="width:100%;"><?php echo $validation->set_value('html',$entry->email['html']);?></textarea><?php echo $validation->form_error('html');?></td> |
| 119 | </tr> | 119 | </tr> |
| 120 | 120 | ||
| 121 | <tr> | 121 | <tr> |
| 122 | <td width="150">Attachments</td> | 122 | <td width="150">Attachments</td> |
| 123 | <td> </td> | 123 | <td> </td> |
| 124 | </tr> | 124 | </tr> |
| 125 | 125 | ||
| 126 | <?php | 126 | <?php |
| 127 | $attachements = $entry->email['attachments']; | 127 | $attachements = $entry->email['attachments']; |
| 128 | $allowed_attachments = 3; | 128 | $allowed_attachments = 3; |
| ... | @@ -132,18 +132,18 @@ use Tz\WordPress\Tools; | ... | @@ -132,18 +132,18 @@ use Tz\WordPress\Tools; |
| 132 | <td><?php echo $attachment; ?> (<a href="#" entry_id="<?php echo $_GET['page_id']?>" class="attachment" rel="<?php echo $attachment; ?>">remove</a>)</td> | 132 | <td><?php echo $attachment; ?> (<a href="#" entry_id="<?php echo $_GET['page_id']?>" class="attachment" rel="<?php echo $attachment; ?>">remove</a>)</td> |
| 133 | </tr> | 133 | </tr> |
| 134 | <?php $allowed_attachments--; endforeach; ?> | 134 | <?php $allowed_attachments--; endforeach; ?> |
| 135 | 135 | ||
| 136 | <?php for($a = 1; $a <= $allowed_attachments; $a++): ?> | 136 | <?php for($a = 1; $a <= $allowed_attachments; $a++): ?> |
| 137 | 137 | ||
| 138 | <tr> | 138 | <tr> |
| 139 | <td> </td> | 139 | <td> </td> |
| 140 | <td><input type="file" name="attachment[]" /></td> | 140 | <td><input type="file" name="attachment[]" /></td> |
| 141 | </tr> | 141 | </tr> |
| 142 | <?php endfor; ?> | 142 | <?php endfor; ?> |
| 143 | 143 | ||
| 144 | </tbody> | 144 | </tbody> |
| 145 | </table> | 145 | </table> |
| 146 | 146 | ||
| 147 | <table cellspacing="0" class="widefat post fixed expandable" style="margin-top:15px;"> | 147 | <table cellspacing="0" class="widefat post fixed expandable" style="margin-top:15px;"> |
| 148 | <thead> | 148 | <thead> |
| 149 | <tr> | 149 | <tr> |
| ... | @@ -169,15 +169,15 @@ use Tz\WordPress\Tools; | ... | @@ -169,15 +169,15 @@ use Tz\WordPress\Tools; |
| 169 | </tr> | 169 | </tr> |
| 170 | </tbody> | 170 | </tbody> |
| 171 | </table> | 171 | </table> |
| 172 | 172 | ||
| 173 | 173 | ||
| 174 | 174 | ||
| 175 | <p> | 175 | <p> |
| 176 | <input type="submit" value=" Update " /><input type="button" value=" Cancel " onclick="document.location.href='/wp-admin/admin.php?page=notifications';" /> | 176 | <input type="submit" value=" Update " /><input type="button" value=" Cancel " onclick="document.location.href='/wp-admin/admin.php?page=notifications';" /> |
| 177 | </p> | 177 | </p> |
| 178 | 178 | ||
| 179 | </form> | 179 | </form> |
| 180 | 180 | ||
| 181 | </div> | 181 | </div> |
| 182 | 182 | ||
| 183 | <script type="text/javascript"> | 183 | <script type="text/javascript"> |
| ... | @@ -190,9 +190,9 @@ jQuery(document).ready(function($) { | ... | @@ -190,9 +190,9 @@ jQuery(document).ready(function($) { |
| 190 | , dateFormat: 'yy-mm-dd' | 190 | , dateFormat: 'yy-mm-dd' |
| 191 | , timeFormat: 'hh:mm:ss' | 191 | , timeFormat: 'hh:mm:ss' |
| 192 | }); | 192 | }); |
| 193 | 193 | ||
| 194 | updateNotificationType(); | 194 | updateNotificationType(); |
| 195 | 195 | ||
| 196 | $('.attachment').live('click', function(e) { | 196 | $('.attachment').live('click', function(e) { |
| 197 | e.preventDefault(); | 197 | e.preventDefault(); |
| 198 | var $link = $(this); | 198 | var $link = $(this); |
| ... | @@ -202,11 +202,11 @@ jQuery(document).ready(function($) { | ... | @@ -202,11 +202,11 @@ jQuery(document).ready(function($) { |
| 202 | , id: $link.attr('entry_id') | 202 | , id: $link.attr('entry_id') |
| 203 | , file: $link.attr('rel') | 203 | , file: $link.attr('rel') |
| 204 | }; | 204 | }; |
| 205 | 205 | ||
| 206 | 206 | ||
| 207 | 207 | ||
| 208 | var file_element = '<input type="file" name="attachment[]" />'; | 208 | var file_element = '<input type="file" name="attachment[]" />'; |
| 209 | 209 | ||
| 210 | var c = confirm('Are you sure you want to remove this attachment?'); | 210 | var c = confirm('Are you sure you want to remove this attachment?'); |
| 211 | if (c) { | 211 | if (c) { |
| 212 | $.ajax({ | 212 | $.ajax({ |
| ... | @@ -221,11 +221,11 @@ jQuery(document).ready(function($) { | ... | @@ -221,11 +221,11 @@ jQuery(document).ready(function($) { |
| 221 | } | 221 | } |
| 222 | }); | 222 | }); |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | return false; | 225 | return false; |
| 226 | }); | 226 | }); |
| 227 | 227 | ||
| 228 | 228 | ||
| 229 | //jQuery('table.expandable tbody').hide(); | 229 | //jQuery('table.expandable tbody').hide(); |
| 230 | jQuery('table.expandable thead th').click(function() { | 230 | jQuery('table.expandable thead th').click(function() { |
| 231 | var $table = jQuery(this).parent().parent().parent(); | 231 | var $table = jQuery(this).parent().parent().parent(); |
| ... | @@ -237,12 +237,12 @@ jQuery(document).ready(function($) { | ... | @@ -237,12 +237,12 @@ jQuery(document).ready(function($) { |
| 237 | jQuery('tbody',$table).fadeIn(); | 237 | jQuery('tbody',$table).fadeIn(); |
| 238 | } | 238 | } |
| 239 | }); | 239 | }); |
| 240 | 240 | ||
| 241 | }); | 241 | }); |
| 242 | 242 | ||
| 243 | function updateNotificationType() { | 243 | function updateNotificationType() { |
| 244 | var type = jQuery('#notif_type').val(); | 244 | var type = jQuery('#notif_type').val(); |
| 245 | 245 | ||
| 246 | if (type=="triggered") { | 246 | if (type=="triggered") { |
| 247 | jQuery('.scheduled-extended').hide(); | 247 | jQuery('.scheduled-extended').hide(); |
| 248 | jQuery('.trigger-extended').show(); | 248 | jQuery('.trigger-extended').show(); |
| ... | @@ -252,9 +252,6 @@ function updateNotificationType() { | ... | @@ -252,9 +252,6 @@ function updateNotificationType() { |
| 252 | jQuery('.trigger-extended').hide(); | 252 | jQuery('.trigger-extended').hide(); |
| 253 | jQuery('.scheduled_sendto').show(); | 253 | jQuery('.scheduled_sendto').show(); |
| 254 | } | 254 | } |
| 255 | |||
| 256 | } | ||
| 257 | |||
| 258 | |||
| 259 | 255 | ||
| 256 | } | ||
| 260 | </script> | 257 | </script> |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment