예제 #1
0
 function wp_new_user_notification($user_id, $deprecated = null, $notify = '')
 {
     global $wp_version, $wp_hasher;
     $bnfw = BNFW::factory();
     $user = get_userdata($user_id);
     if (version_compare($wp_version, '4.3', '>=')) {
         // for WordPress 4.3 and above
         global $wpdb;
         if (version_compare($wp_version, '4.3', '=')) {
             $notify = $deprecated;
         } else {
             if ($deprecated !== null) {
                 _deprecated_argument(__FUNCTION__, '4.3.1');
             }
         }
         // The blogname option is escaped with esc_html on the way into the database in sanitize_option
         // we want to reverse this for the plain text arena of emails.
         $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
         if (!$bnfw->notifier->notification_exists('admin-user')) {
             $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
             $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
             $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
             @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
         }
         if ('admin' === $notify || empty($notify)) {
             return;
         }
         // Generate something random for a password reset key.
         $key = wp_generate_password(20, false);
         /** This action is documented in wp-login.php */
         do_action('retrieve_password_key', $user->user_login, $key);
         // Now insert the key, hashed, into the DB.
         if (empty($wp_hasher)) {
             require_once ABSPATH . WPINC . '/class-phpass.php';
             $wp_hasher = new PasswordHash(8, true);
         }
         $hashed = time() . ':' . $wp_hasher->HashPassword($key);
         $wpdb->update($wpdb->users, array('user_activation_key' => $hashed), array('user_login' => $user->user_login));
         if ($bnfw->notifier->notification_exists('new-user')) {
             $notifications = $bnfw->notifier->get_notifications('new-user');
             $password_url = network_site_url("wp-login.php?action=rp&key=" . $key . "&login="******"\r\n\r\n";
             $message .= __('To set your password, visit the following address:') . "\r\n\r\n";
             $message .= '<' . network_site_url("wp-login.php?action=rp&key={$key}&login="******">\r\n\r\n";
             $message .= wp_login_url() . "\r\n";
             wp_mail($user->user_email, sprintf(__('[%s] Your username and password info'), $blogname), $message);
         }
     } else {
         // for WordPress below 4.3
         $plaintext_pass = $deprecated;
         // The blogname option is escaped with esc_html on the way into the database in sanitize_option
         // we want to reverse this for the plain text arena of emails.
         $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
         if (!$bnfw->notifier->notification_exists('admin-user')) {
             $message = sprintf(__('New user registration on your site %s:'), $blogname) . "\r\n\r\n";
             $message .= sprintf(__('Username: %s'), $user->user_login) . "\r\n\r\n";
             $message .= sprintf(__('E-mail: %s'), $user->user_email) . "\r\n";
             @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration'), $blogname), $message);
         }
         if (empty($plaintext_pass)) {
             return;
         }
         if ($bnfw->notifier->notification_exists('new-user')) {
             $notifications = $bnfw->notifier->get_notifications('new-user');
             foreach ($notifications as $notification) {
                 $bnfw->engine->send_registration_email($bnfw->notifier->read_settings($notification->ID), $user, $plaintext_pass);
             }
         } else {
             $message = sprintf(__('Username: %s'), $user->user_login) . "\r\n";
             $message .= sprintf(__('Password: %s'), $plaintext_pass) . "\r\n";
             $message .= wp_login_url() . "\r\n";
             wp_mail($user->user_email, sprintf(__('[%s] Your username and password'), $blogname), $message);
         }
     }
 }
 /**
  * Save the meta box's post metadata.
  *
  * @since 1.0
  * @param int     $post_id The ID of the post being saved.
  */
 public function save_meta_data($post_id)
 {
     if (self::POST_TYPE !== get_post_type($post_id)) {
         return;
     }
     // Check nonce.
     if (empty($_POST[self::POST_TYPE . '_nonce'])) {
         return;
     }
     // Verify nonce.
     if (!wp_verify_nonce($_POST[self::POST_TYPE . '_nonce'], self::POST_TYPE)) {
         return;
     }
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return;
     }
     if (!current_user_can('manage_options')) {
         return;
     }
     $setting = array('notification' => $_POST['notification'], 'subject' => $_POST['subject'], 'message' => $_POST['notification_message'], 'disabled' => isset($_POST['disabled']) ? sanitize_text_field($_POST['disabled']) : 'false', 'email-formatting' => isset($_POST['email-formatting']) ? sanitize_text_field($_POST['email-formatting']) : 'html', 'disable-current-user' => isset($_POST['disable-current-user']) ? sanitize_text_field($_POST['disable-current-user']) : 'false', 'disable-autop' => isset($_POST['disable-autop']) ? sanitize_text_field($_POST['disable-autop']) : 'false', 'only-post-author' => isset($_POST['only-post-author']) ? sanitize_text_field($_POST['only-post-author']) : 'false', 'users' => array());
     if (isset($_POST['users'])) {
         $setting['users'] = $_POST['users'];
     }
     if (isset($_POST['show-fields']) && 'true' == $_POST['show-fields']) {
         $setting['show-fields'] = 'true';
         $setting['from-name'] = sanitize_text_field($_POST['from-name']);
         $setting['from-email'] = sanitize_email($_POST['from-email']);
         $setting['cc'] = isset($_POST['cc']) ? $_POST['cc'] : '';
         $setting['bcc'] = isset($_POST['bcc']) ? $_POST['bcc'] : '';
     } else {
         $setting['show-fields'] = 'false';
     }
     $setting = apply_filters('bnfw_notification_setting', $setting);
     $this->save_settings($post_id, $setting);
     if (isset($_POST['send-test-email'])) {
         if ('true' == $_POST['send-test-email']) {
             BNFW::factory()->engine->send_test_email($setting);
             add_filter('redirect_post_location', array($this, 'test_mail_sent'));
         }
     }
 }
예제 #3
0
function created_event()
{
    global $wpdb, $table_prefix;
    if ($_GET['status'] == 'added') {
        echo '
            <script>
                  alert("Event added toy your google calendar");
            </script>
            ';
    } else {
        if ($_GET['status'] == 'not') {
            echo '
            <script>
                  alert("Event not available");
            </script>
            ';
        }
    }
    if ($_GET['action'] == 'delete') {
        $eid = $_GET['id'];
        $tablename1 = $table_prefix . 'calendar';
        $data = array('event_status' => 1);
        $formats = array('%d');
        $whe = array('event_id' => $eid);
        //For inserting data in wp_event_users
        $wpdb->update($tablename1, $data, $whe, $formats);
        $result = $wpdb->get_results("SELECT * FROM wp_event_users WHERE Eve_id ='{$eid}'");
        foreach ($result as $row) {
            $uid = $row->Eve_User_Id;
            $result1 = $wpdb->get_row("SELECT user_email FROM wp_users WHERE ID ='{$uid}'");
            $bnfw = BNFW::factory();
            if ($bnfw->notifier->notification_exists('delete-event')) {
                $notifications = $bnfw->notifier->get_notifications('delete-event');
                foreach ($notifications as $notification) {
                    $setting = $bnfw->notifier->read_settings($notification->ID);
                    $to = $result->user_email;
                    $message = 'Event has been cancelled';
                    $subject = $setting['subject'];
                    $headers = "MIME-Version: 1.0\n" . "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
                    wp_mail($to, $subject, wpautop($message), $headers);
                }
            }
        }
        wp_redirect(site_url() . '/index.php/customer-area/events-lists/created-by-me/');
        exit;
    } else {
        $current_user = wp_get_current_user();
        $cuid = $current_user->ID;
        $result = $wpdb->get_results("SELECT * FROM " . $table_prefix . "calendar where event_author='{$cuid}' AND event_status='0' ORDER BY event_datecreated DESC");
        $i = 1;
        if (empty($result)) {
            echo "No events created by you";
        } else {
            echo '
                  <table class="table table-striped table-bordered table-hover" id="data">
                        <thead>
                              <tr>
                                    <th>S.No</th>
                                    <th>Title</th>
                                    <th>Description</th>
                                    <th>Venue</th>
                                    <th>Start Date & Time</th>
                                    <th>End Date & Time</th>
                                    <th>Author</th>
                                    <th>Created On</th>
                                    <th>Edit/Delete</th>
                              </tr>
                        </thead>
                        </tbody>';
            foreach ($result as $row) {
                $start_time = date('h:ia', strtotime($row->event_stime));
                $end_time = date('h:ia', strtotime($row->event_etime));
                $id = $row->event_id;
                echo '
                              <tr class="odd gradeX">
                                    <td>' . $i++ . '</td>
                                    <td>' . $row->event_title . '</td>
                                    <td>' . $row->event_desc . '</td>
                                    <td>' . $row->event_venue . '</td>
                                    <td>Date: ' . $row->event_begin . '<br/>Time: ' . $start_time . '</td>
                                    <td>Date: ' . $row->event_end . '<br/>Time: ' . $end_time . '</td>
                                    <td>';
                $aid = $row->event_author;
                $res = $wpdb->get_row("Select * from " . $table_prefix . "users where ID='{$aid}'");
                echo $res->display_name . '</td>
                                    <td>' . $row->event_datecreated . '</td>
                                    <td><a href="' . site_url() . '/index.php/customer-area/edit-event?eid=' . $id . '">Edit</a>/<a href="' . site_url() . '/index.php/customer-area/events-lists/created-by-me?action=delete&id=' . $id . '">Delete</a></td>
                              </tr>';
            }
            echo '</tbody></table>';
        }
    }
}
<?php

// session_start();
// echo "<pre>";print_r($_SESSION);die;
function mres($value)
{
    $search = array("\\", "", "\n", "\r", "'", '"', "");
    $replace = array("\\\\", "\\0", "\\n", "\\r", "\\'", '\\"', "\\Z");
    return str_replace($search, $replace, $value);
}
if (isset($_POST['submit'])) {
    set_site_message('my-certificates', 'success', "The request for scope extension has been successfully sent.");
    global $wpdb;
    $bnfw = BNFW::factory();
    if ($bnfw->notifier->notification_exists('scope-ext-notifier')) {
        $notifications = $bnfw->notifier->get_notifications('scope-ext-notifier');
        foreach ($notifications as $notification) {
            $sql = "select `first_name`,`last_name` from " . $wpdb->prefix . "users where `ID` = '" . get_current_user_id() . "'";
            $customer_user = $wpdb->get_row($sql);
            $firstname = $customer_user->first_name;
            $lastname = $customer_user->last_name;
            $certificate_name = $_POST['scope_certificate_name'];
            $list_of_standards = $_POST['standards'];
            $scopefilename = $_POST['scope_filename'];
            $scopefilename = explode('~IASfilename~', $scopefilename);
            $scopefilename = array_filter($scopefilename);
            $scopefileurl = $_POST['scope_fileurl'];
            $scopefileurl = explode('~IASurl~', stripslashes($scopefileurl));
            $scopefileurl = array_filter($scopefileurl);
            $date = date('Y-m-d');
            $setting = $bnfw->notifier->read_settings($notification->ID);
function application_add_company()
{
    global $wpdb;
    if (function_exists('start_session')) {
        start_session();
    }
    $_SESSION['wp_page'] = 'my-companies';
    // Create for empty post data
    if (!isset($_REQUEST['submit']) && !isset($_REQUEST['name']) && empty($_REQUEST['name']) && !isset($_REQUEST['firstname']) && empty($_REQUEST['firstname']) && !isset($_REQUEST['lastname']) && empty($_REQUEST['lastname']) && !isset($_REQUEST['email']) && empty($_REQUEST['email']) && !isset($_REQUEST['phone']) && empty($_REQUEST['phone']) && !isset($_REQUEST['preferredcontactmethodcode']) && empty($_REQUEST['preferredcontactmethodcode']) && !isset($_REQUEST['address']) && empty($_REQUEST['address']) && !isset($_REQUEST['city']) && empty($_REQUEST['city']) && !isset($_REQUEST['zipcode']) && empty($_REQUEST['zipcode']) && !isset($_REQUEST['state']) && empty($_REQUEST['state']) && !isset($_REQUEST['country']) && empty($_REQUEST['country'])) {
        if (isset($_SERVER["HTTP_REFERER"]) && !empty($_SERVER["HTTP_REFERER"])) {
            $_SESSION['wp_errors']['company_invalid_post_data'] = __("Mandatory field(s) are required..");
            wp_redirect($_SERVER["HTTP_REFERER"]);
        } else {
            // This case is occur when internet is disconnect and user direct hit the url
            $_SESSION['wp_errors']['company_invalid_post_data'] = __("Something went wrong.Please try again later.");
            wp_redirect(get_permalink(get_page_by_path('listings')) . '?page=my-companies&type=all');
        }
    }
    // Check for unique  company name
    $company_sql = 'SELECT id FROM ' . $wpdb->prefix . 'company where name="' . $_POST['name'] . '"';
    if ($_POST['id'] != 0) {
        $company_sql .= ' AND id != ' . $_POST['id'];
    }
    //echo $company_sql;
    $company_result = $wpdb->get_results($company_sql);
    $company_count = $wpdb->num_rows;
    /*
    if ($company_count > 0) {
        set_site_message('my-companies', 'error', "Company Already exists");
        //$_SESSION['wp_errors']['company_exists'] = __("Company Already exists ");
        wp_redirect($_SERVER["HTTP_REFERER"]);
        exit;
    }
    */
    $roles = get_user_meta(get_current_user_id(), 'wp_capabilities');
    if (!empty($roles) && isset($roles[0]) && array_key_exists('staff', $roles[0])) {
        $isstaff = true;
    }
    //if ($wpdb->num_rows == 0) {
    if ($_POST['id'] == 0) {
        if (email_exists($_REQUEST['email'])) {
            set_site_message('my-companies', 'error', "Email already exists please enter another email");
            wp_redirect(get_permalink(get_page_by_path('listings')) . '?page=my-companies&type=all');
        }
        $company_type = isset($_POST['company_type']) ? $_POST['company_type'] : "Company";
        $table = $wpdb->prefix . "company";
        $data = array('name' => $_POST['name'], 'email' => $_POST['email'], 'created_by' => get_current_user_id(), 'phone' => $_POST['phone'], 'created_on' => date('Y-m-d H:m:s'), 'address' => $_POST['address'], 'fax' => $_POST['fax'], 'country' => $_POST['country'], 'state' => $_POST['state'], 'city' => $_POST['city'], 'zipcode' => $_POST['zipcode'], 'website_url' => $_POST['website_url'], 'status' => "New_company", 'type' => $company_type);
        //print_r($data);die;
        $wpdb->insert($table, $data);
        $company_id = $wpdb->insert_id;
        /* create new contact associated with new inserted company */
        $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
        /* 0846 - 08/06/15 - in place of user_name in below function we take user_email because we change the functionality to take user_name as user_email */
        $user_id = wp_create_user($_REQUEST['email'], $random_password, $_REQUEST['email']);
        $user = get_user_by('id', $user_id);
        /* assign role agent if company is agency */
        if ($isstaff) {
            if ($company_type == 'Agency') {
                $agent_array = get_role("Agent");
                if (empty($agent_array)) {
                    add_role('agent', 'Agent', array('read' => true, 'application-form' => true));
                    $user = new WP_User($user_id);
                    $user->add_cap('Agent');
                } else {
                    $user = new WP_User($user_id);
                    $user->add_cap('Agent');
                }
            } else {
                $user = new WP_User($user_id);
                $user->remove_cap('Agent');
            }
        }
        $wpdb->query("update " . $wpdb->prefix . "users set display_name = '" . $_POST['firstname'] . " " . $_POST['lastname'] . "', first_name = '" . $_POST['firstname'] . "',last_name='" . $_POST['lastname'] . "',salutaions='" . $_POST['salutaions'] . "',preferred_form='" . $_POST['preferredcontactmethodcode'] . "', phone = '" . $_POST['phone'] . "', country=" . $_POST['country'] . ",state=" . $_POST['state'] . ",city='" . $_POST['city'] . "',  address = '" . $_POST['address'] . "', created_by = " . get_current_user_id() . ", created_on = '" . date("Y-m-d H:m:s") . "', company_id = '" . $company_id . "' where ID=" . $user_id);
        $sql = 'SELECT * FROM ' . $wpdb->prefix . 'users where ID=' . get_current_user_id();
        $result = $wpdb->get_results($sql);
        $get_current_user_role_new = get_current_user_role();
        if (strtolower($get_current_user_role_new) != 'staff') {
            $firstname_users = $result[0]->first_name;
            $lastname_users = $result[0]->last_name;
            $link_to_comapnies = get_permalink(get_page_by_path('listings')) . '?page=my-companies&type=all';
            $bnfw = BNFW::factory();
            if ($bnfw->notifier->notification_exists('new-company')) {
                $notifications = $bnfw->notifier->get_notifications('new-company');
                foreach ($notifications as $notification) {
                    $setting = $bnfw->notifier->read_settings($notification->ID);
                    foreach ($setting['users'] as $users_role) {
                        $main_role = strtolower(str_replace('role-', '', $users_role));
                        $sql = "select `user_email`,`display_name` from " . $wpdb->prefix . "users where `user_type` = '" . $main_role . "'";
                        $staff_user = $wpdb->get_results($sql);
                        foreach ($staff_user as $staff_user) {
                            $emailstaff = $staff_user->user_email;
                            $username_staff = ucwords($staff_user->display_name);
                            $subjectstaff = str_replace('New Company Added', 'Existing Company Details Updated', $setting['subject']);
                            $date = date('Y-m-d');
                            $messagestaff = $setting['message'];
                            $messagestaff = str_replace('[firstname]', $firstname_users, $messagestaff);
                            $messagestaff = str_replace('[lastname]', $lastname_users, $messagestaff);
                            $messagestaff = str_replace('[username]', $username_staff, $messagestaff);
                            $messagestaff = str_replace('[date]', $date, $messagestaff);
                            $messagestaff = str_replace('[companyname]', $_POST['name'], $messagestaff);
                            $messagestaff = str_replace('[linkToCompany]', $link_to_comapnies, $messagestaff);
                            $subjectstaff = str_replace('[firstname]', $firstname_users, $subjectstaff);
                            $subjectstaff = str_replace('[lastname]', $lastname_users, $subjectstaff);
                            wp_mail($emailstaff, $subjectstaff, wpautop($messagestaff));
                        }
                    }
                }
            }
        }
        if ($isstaff) {
            try {
                staff_company_approve($company_id, false);
                // approve company
            } catch (Exception $e) {
                $_SESSION['company_error_msg'] = "CRM Approve ERROR: " . $e->getMessage();
                wp_redirect($_SERVER["HTTP_REFERER"]);
                exit;
            }
        }
        /* approve user at the time of company creation */
        if ($isstaff) {
            try {
                approve_user_by_staff($user_id, false);
                // approve user
            } catch (Exception $e) {
                $_SESSION['user_error_msg'] = "CRM Approve ERROR: " . $e->getMessage();
                wp_redirect($_SERVER["HTTP_REFERER"]);
                exit;
            }
        }
        if (isset($_POST['redirect_url']) && !empty($_POST['redirect_url'])) {
            set_site_message('my-companies', 'success', "Company Added Successfully");
            //$_SESSION['wp_notices']['company_added'] = __("Company Added Successfully");
            wp_redirect($_POST['redirect_url']);
        } else {
            set_site_message('my-companies', 'success', "Company Added Successfully");
            //  $_SESSION['wp_notices']['company_added'] = __("Company Added Successfully");
            wp_redirect(admin_url() . 'admin.php?page=' . $_GET['page']);
        }
    } else {
        $status = "Modified";
        $company_result = $wpdb->get_results("SELECT status, crm_id FROM " . $wpdb->prefix . "company where " . $wpdb->prefix . "company.id = " . $_POST['id']);
        $users = $wpdb->get_results("SELECT ID FROM " . $wpdb->prefix . "users where company_id = " . $_POST['id']);
        //Do not update company status until it is approved
        if (!empty($company_result) && $company_result[0]->crm_id == '') {
            $status = $company_result[0]->status;
        }
        if (!empty($users)) {
            $user_id = $users[0]->ID;
        }
        $company_type = isset($_POST['company_type']) ? $_POST['company_type'] : "Company";
        $update_item_sql = 'SELECT ' . $wpdb->prefix . 'users.salutaions,' . $wpdb->prefix . 'users.first_name as firstname,' . $wpdb->prefix . 'users.last_name as lastname,' . $wpdb->prefix . 'company.email,' . $wpdb->prefix . 'company.phone,' . $wpdb->prefix . 'company.fax,' . $wpdb->prefix . 'company.name,' . $wpdb->prefix . 'company.address,' . $wpdb->prefix . 'company.preferredcontactmethodcode,' . $wpdb->prefix . 'company.city,' . $wpdb->prefix . 'company.zipcode,' . $wpdb->prefix . 'company.state,' . $wpdb->prefix . 'company.country,' . $wpdb->prefix . 'company.website_url FROM ' . $wpdb->prefix . 'company JOIN ' . $wpdb->prefix . 'users on ' . $wpdb->prefix . 'users.company_id=' . $wpdb->prefix . 'company.id where ' . $wpdb->prefix . 'company.id=' . $_POST['id'] . ' AND ' . $wpdb->prefix . 'users.ID=' . $_POST['user_id'];
        $update_item_result = $wpdb->get_results($update_item_sql);
        $_POST['preferredcontactmethodcode'] = isset($_POST['preferredcontactmethodcode']) ? $_POST['preferredcontactmethodcode'] : 'Email';
        $post_array = array_slice($_POST, 0, 8, true) + array("preferredcontactmethodcode" => $_POST['preferredcontactmethodcode']) + array_slice($_POST, 3, count($_POST) - 3, true);
        $update_array = json_decode(json_encode($update_item_result), true);
        $diff_array = array_diff($_POST, $update_array[0]);
        $updated_string = '';
        foreach ($diff_array as $key => $value) {
            if (isset($update_array[0][$key]) && isset($diff_array[$key])) {
                switch ($key) {
                    case 'firstname':
                        $label = 'First Name';
                        break;
                    case 'lastname':
                        $label = 'Last Name';
                        break;
                    case 'preferredcontactmethodcode':
                        $label = 'Preferred Contact Method';
                        break;
                    case 'name':
                        $label = 'Company Name';
                        break;
                    default:
                        $label = $key;
                }
                $updated_string .= ucfirst(str_replace("_", ' ', $label)) . " from '" . $update_array[0][$key] . "' to '" . $diff_array[$key] . "'<br/>";
            }
        }
        //Add updated data in logger
        $json_data = json_encode($diff_array);
        $log_data = array();
        //Declare array to stored log data
        $log_data['ref_type'] = "company";
        $log_data['ref_id'] = $_POST['id'];
        $log_data['title'] = "Company Updated";
        $log_data['description'] = "Company Updated From Portal";
        $log_data['content'] = $json_data;
        //Used to log activity
        IB_Logging::ib_log_activity($log_data);
        $wpdb->update($wpdb->prefix . 'company', array('name' => $_POST['name'], 'email' => $_POST['email'], 'address' => $_POST['address'], 'preferredcontactmethodcode' => $_POST['preferredcontactmethodcode'], 'phone' => $_POST['phone'], 'fax' => $_POST['fax'], 'country' => $_POST['country'], 'state' => $_POST['state'], 'city' => $_POST['city'], 'zipcode' => $_POST['zipcode'], 'website_url' => $_POST['website_url'], 'status' => $status, 'modified_by' => get_current_user_id(), 'modified_on' => date('Y-m-d H:m:s'), 'type' => $company_type), array('id' => $_POST['id']));
        /* update user details */
        $wpdb->update($wpdb->prefix . 'users', array('first_name' => $_POST['firstname'], 'last_name' => $_POST['lastname'], 'phone' => $_POST['phone'], 'preferred_form' => $_POST['preferredcontactmethodcode'], 'modified_by' => get_current_user_id(), 'modified_on' => date('Y-m-d H:m:s'), 'country' => $_POST['country'], 'state' => $_POST['state'], 'city' => $_POST['city'], 'zipcode' => $_POST['zipcode'], 'website_url' => $_POST['website_url']), array('ID' => $_POST['user_id']));
        /* update quotation progarm company details*/
        $wpdb->update($wpdb->prefix . 'quotation_program', array('companyname' => $_POST['name']), array('company_id' => $_POST['id']));
        /* assign role agent if company is agency */
        if (isset($isstaff) && $isstaff) {
            if ($company_type == 'Agency') {
                $agent_array = get_role("Agent");
                if (empty($agent_array)) {
                    add_role('agent', 'Agent', array('read' => true, 'application-form' => true));
                    $user = new WP_User($user_id);
                    $user->add_cap('Agent');
                } else {
                    $user = new WP_User($user_id);
                    $user->add_cap('Agent');
                }
            } else {
                $user = new WP_User($user_id);
                $user->remove_cap('Agent');
            }
        }
        if (isset($isstaff) && $isstaff) {
            try {
                $company_sql = 'SELECT crm_id FROM ' . $wpdb->prefix . 'company where id="' . $_POST['id'] . '"';
                $company_result = $wpdb->get_results($company_sql);
                if (!empty($company_result) && !empty($company_result[0]->crm_id)) {
                    staff_company_approve($_POST['id'], true);
                    // approve company
                } else {
                    staff_company_approve($_POST['id'], false);
                    // approve company
                }
            } catch (Exception $e) {
                $_SESSION['company_error_msg'] = "CRM Approve ERROR: " . $e->getMessage();
                wp_redirect($_SERVER["HTTP_REFERER"]);
                exit;
            }
        }
        $sql = 'SELECT * FROM ' . $wpdb->prefix . 'users where ID=' . get_current_user_id();
        $result = $wpdb->get_results($sql);
        $get_current_user_role_new = get_current_user_role();
        if (strtolower($get_current_user_role_new) != 'staff') {
            $firstname_users = $result[0]->first_name;
            $lastname_users = $result[0]->last_name;
            $link_to_comapnies = get_permalink(get_page_by_path('listings')) . '?page=my-companies&type=modified';
            $bnfw = BNFW::factory();
            if ($bnfw->notifier->notification_exists('existing-company-update')) {
                $notifications = $bnfw->notifier->get_notifications('existing-company-update');
                foreach ($notifications as $notification) {
                    $setting = $bnfw->notifier->read_settings($notification->ID);
                    foreach ($setting['users'] as $users_role) {
                        $main_role = strtolower(str_replace('role-', '', $users_role));
                        $sql = "select `user_email`,`display_name` from " . $wpdb->prefix . "users where `user_type` = '" . $main_role . "'";
                        $staff_user = $wpdb->get_results($sql);
                        foreach ($staff_user as $staff_user) {
                            $emailstaff = $staff_user->user_email;
                            $username_staff = ucwords($staff_user->display_name);
                            $subjectstaff = $setting['subject'];
                            $subjectstaff = str_replace("[firstname]", $firstname_users, $subjectstaff);
                            $subjectstaff = str_replace('[lastname]', $lastname_users, $subjectstaff);
                            $date = date('Y-m-d');
                            $messagestaff = $setting['message'];
                            //$messagestaff = str_replace('[common_header]', $common_header, $messagestaff);
                            $messagestaff = str_replace('[firstname]', $firstname_users, $messagestaff);
                            $messagestaff = str_replace('[lastname]', $lastname_users, $messagestaff);
                            $messagestaff = str_replace('[username]', $username_staff, $messagestaff);
                            $messagestaff = str_replace('[date]', $date, $messagestaff);
                            $messagestaff = str_replace('[companyname]', $_POST['name'], $messagestaff);
                            $messagestaff = str_replace('[linkToCompany]', $link_to_comapnies, $messagestaff);
                            $messagestaff = str_replace("[update_fields]", $updated_string, $messagestaff);
                            $subjectstaff = str_replace('[firstname]', $firstname_users, $subjectstaff);
                            $subjectstaff = str_replace('[lastname]', $lastname_users, $subjectstaff);
                            if ($updated_string != '') {
                                wp_mail($emailstaff, $subjectstaff, wpautop($messagestaff));
                            }
                        }
                    }
                }
            }
        }
        if (isset($_POST['redirect_url']) && !empty($_POST['redirect_url'])) {
            set_site_message('my-companies', 'success', "Company Details Updated Successfully");
            // $_SESSION['wp_notices']['company_updated'] = __("Company Updated Successfully");
            wp_redirect($_POST['redirect_url']);
        } else {
            set_site_message('my-companies', 'success', "Company Details Updated Successfully");
            //$_SESSION['wp_notices']['company_updated'] = __("Company Updated Successfully");
            wp_redirect(admin_url() . 'admin.php?page=' . $_GET['page']);
        }
    }
    //}
}
예제 #6
0
     * @param unknown $ref_id
     */
    private function send_notification($type, $ref_id)
    {
        $notifications = $this->notifier->get_notifications($type);
        foreach ($notifications as $notification) {
            $this->engine->send_notification($this->notifier->read_settings($notification->ID), $ref_id);
        }
    }
    /**
     * Can send comment notification or not
     *
     * @since 1.0
     * @param unknown $comment
     * @return unknown
     */
    private function can_send_comment_notification($comment)
    {
        // Returns false if the comment is marked as spam AND admin has enabled suppression of spam
        $suppress_spam = get_option('bnfw_suppress_spam');
        if ('1' === $suppress_spam && 0 === strcmp($comment->comment_approved, 'spam')) {
            return false;
        }
        return true;
    }
}
/* ------------------------------------------------------------------------ *
 * Fire up the plugin
 * ------------------------------------------------------------------------ */
BNFW::factory();
예제 #7
0
function complete_editeve($title, $sdate, $stime, $tdate, $ttime, $repeat, $recur, $venue, $users, $desc, $status)
{
    global $wpdb, $table_prefix, $eventtable, $usertable, $reg_errors;
    $status = 0;
    $active = null;
    $decline = null;
    //To get information about logged in user
    $current_user = wp_get_current_user();
    $cuser = $current_user->user_login;
    $cuid = $current_user->ID;
    //Start and end time converted in 24 hour formate
    $estime = date("H:i", strtotime($stime));
    $ettime = date("H:i", strtotime($ttime));
    if (1 > count($reg_errors->get_error_messages())) {
        //For inserting data in wp_calendar
        //$event_uinfo is for the updated information of event
        $event_uinfo = array('event_begin' => $sdate, 'event_end' => $tdate, 'event_title' => $title, 'event_desc' => $desc, 'event_venue' => $venue, 'event_stime' => $estime, 'event_etime' => $ettime, 'event_recur' => $recur, 'event_repeats' => $repeat, 'event_category' => null, 'event_link' => null);
        //Formate
        $event_uformat = array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s');
        //Where condition for update query
        $whe = array('event_id' => $_POST['event_id']);
        $wpdb->update($eventtable, $event_uinfo, $whe, $event_uformat);
        //For updating wp_event_users table
        $event_users = explode(",", $u);
        $eventid = $_POST['event_id'];
        if ($users != null) {
            for ($i = 0; $i < count($event_users); $i++) {
                $eve_users = $wpdb->get_results("SELECT * FROM" . $usertable . " WHERE Eve_id ='{$eventid}' AND Eve_User_Id='{$event_users[$i]}'");
                if (count($eve_users) == 0) {
                    //$nuser is for the new user invited by the author
                    $nuser = array('Eve_id' => $eventid, 'Eve_User_Id' => $eu[$i], 'Accepted' => $active, 'Declined' => $decline, 'Eve_Status' => $status);
                    $nuser_format = array('%s', '%s', '%d', '%d', '%d');
                    $wpdb->insert($usertable, $nuser, $nuser_format);
                } else {
                    exit;
                }
            }
        }
        $event_user = $wpdb->get_results("SELECT * FROM " . $usertable . " WHERE Eve_id ='{$eventid}'");
        foreach ($event_user as $row) {
            $userid = $row->Eve_User_Id;
            $result1 = $wpdb->get_row("SELECT user_email FROM " . $table_prefix . "users WHERE ID ='{$userid}'");
            $bnfw = BNFW::factory();
            if ($bnfw->notifier->notification_exists('edit-event')) {
                $notifications = $bnfw->notifier->get_notifications('edit-event');
                foreach ($notifications as $notification) {
                    $setting = $bnfw->notifier->read_settings($notification->ID);
                    $to = $result->user_email;
                    $message = '
                              <div id="email_container" style="background:#444">
                                    <div style="width:570px; padding:0 0 0 20px; margin:50px auto 12px auto" id="email_header">
                                          <span style="background:#585858; color:#fff; padding:12px;font-family:trebuchet ms; letter-spacing:1px; 
                                                -moz-border-radius-topleft:5px; -webkit-border-top-left-radius:5px; 
                                                border-top-left-radius:5px;moz-border-radius-topright:5px; -webkit-border-top-right-radius:5px; 
                                                border-top-right-radius:5px;">
                                                Updation in Event Information
                                          </div>
                                    </div>
                              
                              
                                    <div style="width:550px; padding:0 20px 20px 20px; background:#fff; margin:0 auto; border:3px #000 solid;
                                          moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; color:#454545;line-height:1.5em; " id="email_content">
                                          
                                          <h1 style="padding:5px 0 0 0; font-family:georgia;font-weight:500;font-size:24px;color:#000;border-bottom:1px solid #bbb">
                                                 ' . $title . ' Information updated
                                          </h1>
                                          
                                          <p>
                                                This event is organized by ' . $cuser . '. Updation in informations <br/>Venue: ' . $venue . '<br/>Event Starts at: ' . $sdate . ' ' . $stime . '<br/>Event ends at: ' . $tdate . ' ' . $ttime . '<br/>Event description: ' . $desc . '
                                          </p>
                                          <p>
                                                <a href="' . site_url() . '/index.php/customer-area/pages/pending-invitations?status=yes&id=' . $eventid . '&uid=' . $cuid . '"><span class="myButton" id="myButton" style="box-shadow: rgb(207, 134, 108) 0px 1px 0px 0px inset; border-radius: 3px; border: 1px solid rgb(148, 41, 17); display: inline-block; cursor: pointer; color: rgb(255, 255, 255); font-family: Arial; font-size: 13px; padding: 6px 24px; text-decoration: none; text-shadow: rgb(133, 70, 41) 0px 1px 0px; background: linear-gradient(rgb(208, 69, 27) 5%, rgb(188, 51, 21) 100%) rgb(208, 69, 27);">Accept</span></a>
                                                 
                                                <a href="' . site_url() . '/index.php/customer-area/pages/pending-invitations?status=no&id=' . $eid . '&uid=' . $cuid . '"><span class="myButton" id="myButton" style="box-shadow: rgb(207, 134, 108) 0px 1px 0px 0px inset; border-radius: 3px; border: 1px solid rgb(148, 41, 17); display: inline-block; cursor: pointer; color: rgb(255, 255, 255); font-family: Arial; font-size: 13px; padding: 6px 24px; text-decoration: none; text-shadow: rgb(133, 70, 41) 0px 1px 0px; background: linear-gradient(rgb(208, 69, 27) 5%, rgb(188, 51, 21) 100%) rgb(208, 69, 27);">Decline</span></a>
                                          </p> 				
                                    </div>
                              </div>';
                    $subject = $setting['subject'];
                    $headers = "MIME-Version: 1.0\n" . "Content-Type: text/html; charset=\"" . get_option('blog_charset') . "\"\n";
                    wp_mail($to, $subject, wpautop($message), $headers);
                }
            }
        }
        wp_redirect(site_url() . '/index.php/customer-area/events-lists/created-by-me/');
        exit;
    }
}