Ejemplo n.º 1
0
 function forgot_password()
 {
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('i'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     if ($this->input->post('sendnewpass')) {
         $required_fields = array('youremail*EMAILFORMAT');
         $_POST = clean_form_data($_POST);
         $validation_results = validate_form('', $_POST, $required_fields);
         #Only proceed if the validation for required fields passes
         if ($validation_results['bool']) {
             #Check if a user with the specified email exists
             $userdata = $this->Query_reader->get_row_as_array('get_user_by_email_ignore_status', array('emailaddress' => $_POST['youremail']));
             #Active user who just forgot their password
             if (!empty($userdata) && $userdata['isactive'] == 'Y') {
                 $_POST['newpass'] = generate_new_password();
                 $pass_result = $this->db->query($this->Query_reader->get_query_by_code('update_user_password', array('emailaddress' => $_POST['youremail'], 'newpass' => sha1($_POST['newpass']))));
                 $flag_result = $this->db->query($this->Query_reader->get_query_by_code('update_user_changedpassword_flag', array('emailaddress' => $_POST['youremail'], 'flagvalue' => 'N')));
                 if (get_decision(array($pass_result, $flag_result))) {
                     $send_result = $this->sysemail->email_form_data(array('fromemail' => SITE_ADMIN_MAIL), array_merge($userdata, $_POST, get_confirmation_messages($this, array('emailaddress' => $_POST['youremail'], 'newpass' => $_POST['newpass'], 'firstname' => $userdata['firstname']), 'changed_password_notify')));
                     if ($send_result) {
                         $data['msg'] = "Your new password has been sent to your email address.";
                         $data['issuccess'] = 'Y';
                     }
                 }
                 if (empty($send_result) || !empty($send_result) && !$send_result) {
                     $data['msg'] = "ERROR: A new password could not be generated. <a href='javascript:void(0)'>Click here</a> to report this error.";
                 }
             } else {
                 if (!empty($userdata) && $userdata['isactive'] == 'N' && $userdata['forcedclose'] == 'Y') {
                     $data['msg'] = "WARNING: Your account was previously deactivated due to activities contrary <BR>to our terms of use.<BR><BR>Please <a href='javascript:void(0)'>contact us</a> if you want to <BR>reactivate your account.";
                 } else {
                     if (!empty($userdata) && $userdata['isactive'] == 'N' && $userdata['forcedclose'] == 'N') {
                         $_POST['newpass'] = generate_new_password();
                         $reactivate_result = $this->db->query($this->Query_reader->get_query_by_code('reactivate_old_user', array('emailaddress' => $_POST['youremail'], 'password' => sha1($_POST['newpass']), 'enddate' => date('Y-m-d', mktime(0, 0, 0, date("m"), 1, date("y") + 2)))));
                         $flag_result = $this->db->query($this->Query_reader->get_query_by_code('update_user_changedpassword_flag', array('emailaddress' => $_POST['youremail'], 'flagvalue' => 'N')));
                         if (get_decision(array($reactivate_result, $flag_result))) {
                             $send_result = $this->sysemail->email_form_data(array('fromemail' => SITE_ADMIN_MAIL), array_merge($userdata, $_POST, get_confirmation_messages($this, array('emailaddress' => $_POST['youremail'], 'newpass' => $_POST['newpass'], 'firstname' => $userdata['firstname']), 'changed_password_notify')));
                             if ($send_result) {
                                 $data['msg'] = "Your new password has been sent to your email address.";
                                 $data['issuccess'] = 'Y';
                             }
                         }
                         if (empty($send_result) || !empty($send_result) && !$send_result) {
                             $data['msg'] = "ERROR: A new password could not be generated. <a href='javascript:void(0)'>Click here</a> to report this error.";
                         }
                     }
                 }
             }
         }
         if (empty($data['msg'])) {
             $data['msg'] = "WARNING: The highlighted fields are required.";
         }
         $data['requiredfields'] = $validation_results['requiredfields'];
         $data['formdata'] = $_POST;
     }
     $data = add_msg_if_any($this, $data);
     $this->load->view('account/forgot_password', $data);
 }
Ejemplo n.º 2
0
 function save_user()
 {
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'a', 't'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     #check user access
     if (!empty($data['i'])) {
         check_user_access($this, 'edit_user_details', 'redirect');
     } else {
         check_user_access($this, 'add_users', 'redirect');
     }
     if ($this->input->post('cancel')) {
         redirect("admin/manage_users");
     } else {
         if ($this->input->post('save')) {
             $data['userdetails'] = $_POST;
             $required_fields = array('firstname', 'lastname', 'gender', 'emailaddress*EMAILFORMAT', 'telephone', 'username');
             $_POST = clean_form_data($_POST);
             $validation_results = validate_form('', $_POST, $required_fields);
             #Only proceed if the validation for required fields passes
             if ($validation_results['bool']) {
                 #User's added by non admins have PDE of author
                 if ($this->session->userdata('isadmin') == 'N') {
                     #should also NEVER try adding system admins, under any circumstances!
                     if (!empty($_POST['roles']) && $_POST['roles'] == 14) {
                         $this->session->set_userdata('usave', "ERROR: Invalid action");
                         redirect("user/dashboard/m/usave");
                     }
                     $userdata = $this->db->get_where('users', array('userid' => $this->session->userdata('userid')))->result_array();
                     $_POST['pde'] = $userdata[0]['pde'];
                 }
                 if (!empty($data['i'])) {
                     $userid = decryptValue($data['i']);
                     $data['msg'] = '';
                     #test if email is unique to user being edited
                     $user_details = $this->Query_reader->get_row_as_array('search_user_list', array('searchstring' => 'emailaddress="' . $_POST['emailaddress'] . '" AND userid != "' . $userid . '"', 'limittext' => ''));
                     if (!empty($user_details)) {
                         $data['msg'] = "ERROR: A user with the specified email address already exists. <br />";
                     }
                     if (!empty($_POST['password']) || !empty($_POST['repeatpassword'])) {
                         $passwordmsg = $this->user1->check_password_strength($_POST['password']);
                         if (!$passwordmsg['bool']) {
                             $data['msg'] .= "ERROR: " . $passwordmsg['msg'];
                         } elseif ($_POST['password'] == $_POST['repeatpassword']) {
                             $update_string = ", password = '******'password']) . "'";
                         } else {
                             $data['msg'] .= "ERROR: The passwords provided do not match.";
                         }
                     } else {
                         $update_string = "";
                     }
                     if (empty($data['msg'])) {
                         $result = $this->db->query($this->Query_reader->get_query_by_code('update_user_data', array_merge($_POST, array('updatecond' => $update_string, 'editid' => $userid))));
                         #update the user's roles
                         if (empty($_POST['roles'])) {
                             $this->db->update('roles', array('isactive' => 'N'), array('userid' => $userid, 'isactive' => 'Y'));
                         } else {
                             #get the user's current roles
                             $current_user_roles = $this->db->get_where('roles', array('userid' => $userid, 'isactive' => 'Y'))->result_array();
                             foreach ($current_user_roles as $current_user_role) {
                                 if (in_array($current_user_role['groupid'], $_POST['roles'])) {
                                     foreach ($_POST['roles'] as $role_key => $role_value) {
                                         if ($role_value == $current_user_role['groupid']) {
                                             unset($_POST['roles'][$role_key]);
                                             break;
                                         }
                                     }
                                 } else {
                                     $this->db->update('roles', array('isactive' => 'N'), array('id' => $current_user_role['id']));
                                 }
                             }
                             if (!empty($_POST['roles'])) {
                                 $this->db->insert('roles', array('userid' => $userid, 'groupid' => $_POST['roles'], 'author' => $this->session->userdata('userid')));
                             }
                         }
                         #echo $this->Query_reader->get_query_by_code('update_user_data', array_merge($_POST, array('updatecond'=>$update_string, 'editid'=>decryptValue($data['i']))));
                         #exit();
                     }
                 } else {
                     #check if a similar username already exists
                     $username_error = "";
                     $usernames = $this->db->query($this->Query_reader->get_query_by_code('get_existing_usernames', array('searchstring' => ' username = "******"')));
                     #Check if adding a new user and the email added has already been used
                     if (!empty($data['userdetails']['emailaddress']) && empty($data['i'])) {
                         $user_details = $this->Query_reader->get_row_as_array('get_any_user_by_email', array('emailaddress' => $data['userdetails']['emailaddress']));
                     }
                     #determine password strength
                     $passwordmsg = $this->user1->check_password_strength($_POST['password']);
                     if (strlen($_POST['username']) < 5) {
                         $data['msg'] = "ERROR: The username must be at least 5 characters long";
                         $data['errormsgs']['username'] = "******";
                         $data['requiredfields'] = array('username');
                     } elseif (count($usernames->result_array())) {
                         $data['msg'] = "ERROR: The username is already being used by another user.";
                         $data['errormsgs']['username'] = "******";
                         $data['requiredfields'] = array('username');
                     } elseif (!$passwordmsg['bool']) {
                         $data['msg'] = "ERROR: " . $passwordmsg['msg'];
                         $data['errormsgs']['password'] = $passwordmsg['msg'];
                         $data['requiredfields'] = array('password');
                     } elseif ($_POST['password'] == $_POST['repeatpassword'] && !empty($_POST['password'])) {
                         $result = $this->db->query($this->Query_reader->get_query_by_code('add_user_data', array_merge($_POST, array('password' => sha1($_POST['password']), 'author' => $this->session->userdata('userid')))));
                         #exit($this->db->last_query());
                         $last_added_user = $this->db->insert_id();
                         #Add the user roles if specified
                         if (!empty($_POST['roles'])) {
                             $this->db->insert('roles', array('userid' => $last_added_user, 'groupid' => $_POST['roles'], 'author' => $this->session->userdata('userid')));
                         }
                     } else {
                         $data['msg'] = "ERROR: The passwords provided do not match.";
                         $data['errormsgs']['password'] = $data['errormsgs']['repeatpassword'] = "******";
                         $data['requiredfields'] = array('password', 'repeatpassword');
                     }
                 }
                 #Format and send the errors
                 if (!empty($result) && $result) {
                     #Notify user by email on creation of an account
                     if (empty($data['editid'])) {
                         $send_result = $this->sysemail->email_form_data(array('fromemail' => NOREPLY_EMAIL), get_confirmation_messages($this, array('emailaddress' => $_POST['emailaddress'], 'firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'username' => $_POST['username'], 'password' => $_POST['password']), 'registration_confirm'));
                     }
                     $this->session->set_userdata('usave', "The user data has been successfully saved.");
                     redirect("admin/manage_users/m/usave");
                 } else {
                     if (empty($data['msg'])) {
                         $data['msg'] = "ERROR: The user could not be saved or was not saved correctly.";
                     }
                 }
             } else {
                 if (empty($data['i']) && !empty($user_details)) {
                     /*
                     $addn_msg = (!empty($user_details['isactive']) && $user_details['isactive'] == 'N')? "<a href='".base_url()."admin/load_user_form/i/".encryptValue($user_details['id'])."/a/".encryptValue("reactivate")."' style='text-decoration:underline;font-size:17px;'>Click here to  activate and  edit</a>": "<a href='".base_url()."admin/load_user_form/i/".encryptValue($user_details['userid'])."' style='text-decoration:underline;font-size:17px;'>Click here to edit</a>";
                     */
                     $data['msg'] = "ERROR: The emailaddress has already been used by another user";
                     $data['errormsgs']['emailaddress'] = "The emailaddress has already been used by another user";
                     $data['requiredfields'] = array('emailaddress');
                 }
             }
             if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) {
                 if (!empty($validation_results['errormsgs'])) {
                     $data['msg'] = "WARNING: " . end($validation_results['errormsgs']);
                     $data['errormsgs'] = $validation_results['errormsgs'];
                 } else {
                     $data['msg'] = "WARNING: The highlighted fields are required.";
                 }
                 $data['requiredfields'] = $validation_results['requiredfields'];
             }
         }
     }
     $data['page_title'] = !empty($data['i']) ? 'Edit user details' : 'Add user';
     $data['current_menu'] = 'add_users';
     $data['view_to_load'] = 'users/user_form_v';
     $data['view_data']['form_title'] = $data['page_title'];
     $data['view_data']['formdata'] = $_POST;
     #Get access groups
     $data['usergroups'] = $this->db->query($this->Query_reader->get_query_by_code('get_user_group_list', array('searchstring' => 'UG.isactive="Y" ' . ($this->session->userdata('isadmin') == 'N' ? ' AND UG.id != 14 ' : ''), 'orderby' => 'ORDER BY UG.groupname', 'limittext' => '')))->result_array();
     #Get pdes
     $this->db->order_by("pdename", "asc");
     $data['pdes'] = $this->db->get_where('pdes', array('isactive' => 'Y', 'status' => 'in'))->result_array();
     $this->load->view('dashboard_v', $data);
 }
Ejemplo n.º 3
0
 function load_user_form()
 {
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'a'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     #check user access
     if (!empty($data['i'])) {
         check_user_access($this, 'edit_user_details', 'redirect');
     } else {
         check_user_access($this, 'add_users', 'redirect');
     }
     #Get access groups
     $data['usergroups'] = $this->db->query($this->Query_reader->get_query_by_code('get_user_group_list', array('searchstring' => 'UG.isactive="Y" ' . ($this->session->userdata('isadmin') == 'N' ? ' AND UG.id != 14  AND UG.groupname not like "%PPDA Administrator%"' : ''), 'orderby' => 'ORDER BY UG.groupname', 'limittext' => '')))->result_array();
     #Get pdes
     $this->db->order_by("pdename", "asc");
     $data['pdes'] = $this->db->get_where('pdes', array('isactive' => 'Y', 'status' => 'in'))->result_array();
     #user is editing
     if (!empty($data['i'])) {
         $userid = decryptValue($data['i']);
         $data['formdata'] = $this->Query_reader->get_row_as_array('get_user_by_id', array('id' => $userid));
         #get the user's roles
         $user_roles = $this->db->query($this->Query_reader->get_query_by_code('get_roles_by_user', array('userid' => $userid)))->result_array();
         #format role IDs into simple array
         $data['formdata']['roles'] = array();
         foreach ($user_roles as $user_role) {
             array_push($data['formdata']['roles'], $user_role['groupid']);
         }
         #If the user is to be reactivated
         if (!empty($data['a']) && decryptValue($data['a']) == 'reactivate' && $this->session->userdata('isadmin') == 'Y') {
             $result = $this->db->query($this->Query_reader->get_query_by_code('reactivate_user', array('id' => $userid)));
             if ($result) {
                 $send_result = $this->sysemail->email_form_data(array('fromemail' => NOREPLY_EMAIL), get_confirmation_messages($this, $data['userdetails'], 'account_reactivated_notice'));
             } else {
                 $data['msg'] = "ERROR: There was an error activating the user.";
             }
         }
         #Check if the user is simply viewing
         if (!empty($data['a']) && decryptValue($data['a']) == 'view') {
             $data['isview'] = "Y";
             #get the access group name
             $data['access_group_info'] = $this->Query_reader->get_row_as_array('get_group_by_id', array('groupid' => $data['userdetails']['accessgroup']));
         }
     }
     $data['page_title'] = !empty($data['i']) ? 'Edit user details' : 'Add user';
     $data['current_menu'] = 'add_users';
     $data['view_to_load'] = 'users/user_form_v';
     $data['view_data']['form_title'] = $data['page_title'];
     $this->load->view('dashboard_v', $data);
 }
Ejemplo n.º 4
0
 function process_contactus()
 {
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     if ($this->input->post('sendmessage')) {
         $required_fields = array('emailaddress*EMAILFORMAT', 'name');
         #$_POST['attachmenturl'] = !empty($_FILES['attachmenturl']['name'])? $this->sysfile->local_file_upload($_FILES['attachmenturl'], 'Upload_'.strtotime('now'), 'attachments', 'filename'): '';
         $_POST = clean_form_data($_POST);
         $validation_results = validate_form('', $_POST, $required_fields);
         #Only proceed if the validation for required fields passes
         #if($validation_results['bool'] && is_valid_captcha($this, $_POST['captcha']))
         if ($validation_results['bool']) {
             #Send the contact message to the administrator and
             $send_result = $this->sysemail->email_form_data(array('fromemail' => NOREPLY_EMAIL), get_confirmation_messages($this, $_POST, 'website_feedback'));
             if ($send_result) {
                 $data['msg'] = "Your message has been sent. Thank you for your feedback.";
                 $data['successful'] = 'Y';
             } else {
                 $data['msg'] = "ERROR: Your message could not be sent. Please contact us using our phone line.";
             }
         }
         if (!$validation_results['bool']) {
             $data['msg'] = "WARNING: The highlighted fields are required.";
         }
         $data['requiredfields'] = array_merge($validation_results['requiredfields'], array('captcha'));
         $data['formdata'] = $_POST;
     }
     $data['pagedata'] = $this->Query_reader->get_row_as_array('get_page_by_section', array('section' => 'Support', 'subsection' => 'Contact Us'));
     if (count($data['pagedata']) > 0) {
         $data['pagedata']['details'] = str_replace("&amp;gt;", "&gt;", str_replace("&amp;lt;", "&lt;", $data['pagedata']['details']));
         $data['pagedata']['parsedtext'] = $this->wiki_manager->parse_text_to_HTML(htmlspecialchars_decode($data['pagedata']['details'], ENT_QUOTES));
         $result = $this->db->query($this->Query_reader->get_query_by_code('get_subsections_by_section', array('section' => $data['pagedata']['section'])));
         $data['subsections'] = $result->result_array();
     }
     $data = add_msg_if_any($this, $data);
     $this->load->view('page/contact_us_view', $data);
 }
Ejemplo n.º 5
0
 function update_user_location()
 {
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'd'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     #Get default location if none is given
     if (empty($_POST)) {
         $data['default_location'] = $this->user1->get_user_location();
         $this->session->set_userdata('returnurl', base_url() . 'admin/load_dashboard');
     }
     if ($this->input->post('updatelocation')) {
         $required_fields = array('city', 'state', 'zipcode', 'country', 'emailaddress*EMAILFORMAT', 'iagree');
         $_POST = clean_form_data($_POST);
         if (empty($_POST['iagree'])) {
             $_POST['iagree'] = '';
         }
         $validation_results = validate_form('', $_POST, $required_fields);
         if ($validation_results['bool']) {
             if ($this->session->userdata('emailaddress') || !empty($_POST['emailaddress'])) {
                 $emailaddress = $this->session->userdata('emailaddress') ? $this->session->userdata('emailaddress') : $_POST['emailaddress'];
                 $userdetails = $this->Query_reader->get_row_as_array('get_user_by_email_ignore_status', array('emailaddress' => $emailaddress));
             }
             #Get the current location of the user
             $location = $this->user1->get_ip_location($this->input->ip_address());
             #Just update the user location with a custom location if the account exists
             if ($this->session->userdata('emailaddress') && !empty($userdetails)) {
                 $location_result = $this->db->query($this->Query_reader->get_query_by_code('save_user_location', array('useremail' => $_POST['emailaddress'], 'country' => $_POST['country'], 'region' => $_POST['state'], 'city' => $_POST['city'], 'zipcode' => $_POST['zipcode'], 'isp' => $location['isp'], 'latitude' => $location['latitude'], 'longitude' => $location['longitude'])));
             } else {
                 if (!empty($userdetails)) {
                     $data['msg'] = "WARNING: An account with the provided emailaddress already exists. <BR><BR>Please first login and then update this account owner's location.";
                 } else {
                     $_POST['newpass'] = generate_new_password();
                     $result = $this->db->query($this->Query_reader->get_query_by_code('add_user_data', array('firstname' => '', 'lastname' => '', 'username' => $_POST['emailaddress'], 'password' => sha1($_POST['newpass']), 'emailaddress' => $_POST['emailaddress'], 'telephone' => '', 'enddate' => date('Y-m-d', mktime(0, 0, 0, date("m"), 1, date("y") + 2)))));
                     $location_result = $this->db->query($this->Query_reader->get_query_by_code('save_user_location', array('useremail' => $_POST['emailaddress'], 'country' => $_POST['country'], 'zipcode' => $_POST['zipcode'], 'city' => $_POST['city'], 'region' => $_POST['state'], 'isp' => $location['isp'], 'latitude' => $location['latitude'], 'longitude' => $location['longitude'])));
                     #Notify user about creation of their account and new password
                     if ($result && $location_result) {
                         $_POST['step1email'] = $_POST['emailaddress'];
                         $send_result = $this->sysemail->email_form_data(array('fromemail' => SITE_ADMIN_MAIL), array_merge($_POST, get_confirmation_messages($this, $_POST, 'registration_confirm')));
                     }
                 }
             }
             #Check if the location was created
             if (!empty($result) && $result && $location_result) {
                 $data['msg'] = "Your location has been updated.<BR><BR>In addition, an account with your emailaddress has been created. Login using the <BR>password sent to your email address.";
                 $data['area'] = "show_close_btn";
                 #login the new user
                 $userdata = $this->Query_reader->get_row_as_array('get_user_by_email', array('emailaddress' => $_POST['emailaddress'], 'isactive' => 'Y'));
                 $userdata['userid'] = $userdata['id'];
                 $this->user1->populate_user_details(array($userdata));
                 $this->Users->create_new_trust_record(array('useremail' => $_POST['emailaddress']));
                 #Update the location tracker string
                 $this->session->set_userdata('resetlocation', 'Y');
             } else {
                 if (!empty($location_result) && $location_result) {
                     $data['msg'] = "Your location has been updated.";
                     $data['area'] = "show_close_btn";
                     #Update the location tracker string
                     #$this->session->set_userdata('location_string', get_custom_location($this));
                     $this->session->set_userdata('resetlocation', 'Y');
                 } else {
                     if (empty($data['msg'])) {
                         $data['msg'] = "ERROR: Your location could not be updated. Please contact us about this issue.";
                     }
                 }
             }
         } else {
             $data['msg'] = "WARNING: The highlighted fields are required.";
         }
         $data['requiredfields'] = $validation_results['requiredfields'];
         $data['formdata'] = $_POST;
     }
     $data = add_msg_if_any($this, $data);
     $this->load->view('page/update_location', $data);
 }
Ejemplo n.º 6
0
 function send_deal_invitation()
 {
     access_control($this);
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     #Invite the user to participate in the deal
     if (!empty($data['i']) && !empty($data['dealid']) || !empty($data['u']) && !empty($data['d'])) {
         #FROM USER LIST
         if (!empty($data['i']) && !empty($data['dealid'])) {
             $dealid = $data['dealid'];
             $userid = decryptValue($data['i']);
         } else {
             if (!empty($data['u']) && !empty($data['d'])) {
                 $dealid = decryptValue($data['d']);
                 $userid = decryptValue($data['u']);
             }
         }
         $deal_details = $this->Query_reader->get_row_as_array('get_deal_by_id', array('id' => $dealid));
         $user_details = $this->Query_reader->get_row_as_array('get_user_by_id', array('id' => $userid));
         $inv_details = $this->Query_reader->get_row_as_array('check_user_invitation', array('userid' => $userid, 'dealid' => $dealid));
         $invitation_details = array_merge($deal_details, array('firstname' => $user_details['firstname'], 'userid' => $user_details['userid'], 'emailaddress' => $user_details['emailaddress'], 'invitationid' => $inv_details['id']));
         $send_result = $this->sysemail->email_form_data(array('fromemail' => NOREPLY_EMAIL), get_confirmation_messages($this, $invitation_details, 'deal_invitation'));
         if ($send_result) {
             $result = $this->db->query($this->Query_reader->get_query_by_code('update_invitation_sent_status', array('issent' => 'Y', 'userid' => $user_details['userid'], 'dealid' => $deal_details['id'])));
         } else {
             $result = FALSE;
         }
     }
     $data['msg'] = !empty($result) && $result ? "<span class='littlegreentext'>SENT</span>" : "<span class='redtext'><b>NOT SENT</b></span>";
     $data['area'] = "deal_sent_confirmation";
     $this->load->view('incl/addons', $data);
 }
Ejemplo n.º 7
0
 function load_user_form()
 {
     access_control($this, array('admin'));
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'a'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     #Get access groups
     $accessGroupsResult = $this->db->query($this->Query_reader->get_query_by_code('get_user_group_list', array()));
     #user is editing
     if (!empty($data['i'])) {
         $userid = decryptValue($data['i']);
         $data['userdetails'] = $this->Query_reader->get_row_as_array('get_user_by_id', array('id' => $userid));
         #If the user is to be reactivated
         if (!empty($data['a']) && decryptValue($data['a']) == 'reactivate' && $this->session->userdata('isadmin') == 'Y') {
             $result = $this->db->query($this->Query_reader->get_query_by_code('reactivate_user', array('id' => $userid)));
             if ($result) {
                 $send_result = $this->sysemail->email_form_data(array('fromemail' => NOREPLY_EMAIL), get_confirmation_messages($this, $data['userdetails'], 'account_reactivated_notice'));
             } else {
                 $data['msg'] = "ERROR: There was an error activating the user.";
             }
         }
         #Check if the user is simply viewing
         if (!empty($data['a']) && decryptValue($data['a']) == 'view') {
             $data['isview'] = "Y";
             #get the access group name
             $data['access_group_info'] = $this->Query_reader->get_row_as_array('get_group_by_id', array('groupid' => $data['userdetails']['accessgroup']));
         }
     }
     $this->load->view('admin/new_user_view', $data);
 }
Ejemplo n.º 8
0
 function process_message()
 {
     access_control($this);
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'a'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     if ($this->input->post('sendmessage')) {
         $required_fields = array('subject', 'details');
         #Include receipient IDs if no overall receipient id is selected
         if (empty($_POST['sendtoall'])) {
             array_push($required_fields, 'recipientids*CHECKBOXES');
         }
         $_POST = clean_form_data($_POST);
         $validation_results = validate_form('', $_POST, $required_fields);
         #Only proceed if the validation for required fields passes
         if ($validation_results['bool']) {
             $results = array();
             $recipients = !empty($_POST['recipientids']) ? implode(",", $_POST['recipientids']) : "";
             #Save the message before sending it out
             $save_result = $this->db->query($this->Query_reader->get_query_by_code('save_new_message', array('subject' => htmlentities($_POST['subject'], ENT_QUOTES), 'details' => htmlentities($_POST['details'], ENT_QUOTES), 'sentby' => $this->session->userdata('userid'), 'sendingip' => get_ip_address())));
             $_POST['messageid'] = mysql_insert_id();
             array_push($results, $save_result);
             if ($save_result) {
                 if (!empty($_POST['recipientids'])) {
                     #Send the message to each user as given in the list
                     $user_emails = $this->Query_reader->get_row_as_array('get_userlist_emails', array('idlist' => "'" . implode("','", $_POST['recipientids']) . "'"));
                     $_POST['emailaddress'] = $user_emails['emaillist'];
                 } else {
                     $user_emails = $this->Query_reader->get_row_as_array('get_active_user_emails', array('isactive' => "Y"));
                     $_POST['emailaddress'] = $user_emails['emaillist'];
                 }
                 $send_result = $this->sysemail->email_form_data(array('fromemail' => $this->session->userdata('emailaddress')), get_confirmation_messages($this, array_merge($_POST, array('sendername' => $this->session->userdata('names'))), 'send_sys_msg_by_email'));
                 array_push($results, $send_result);
                 #Save the message notice send record for each user
                 $email_list = explode(",", $_POST['emailaddress']);
                 foreach ($email_list as $email) {
                     $userdetails = $this->Query_reader->get_row_as_array('get_user_by_email', array('emailaddress' => $email, 'isactive' => 'Y'));
                     array_push($results, $this->db->query($this->Query_reader->get_query_by_code('add_msg_read_record', array('useremail' => $email, 'messageid' => $_POST['messageid'], 'userid' => $userdetails['id']))));
                 }
             }
             $msg = get_decision($results) ? "The message has been sent." : "WARNING: The message could not be sent.";
             $this->session->unset_userdata(array('exclusers' => ''));
             $this->session->set_userdata('mmsg', $msg);
             redirect(base_url() . "messages/load_inbox/m/mmsg");
         }
         if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) {
             $data['msg'] = "WARNING: The highlighted fields are required.";
         }
         $data['requiredfields'] = $validation_results['requiredfields'];
         $data['formdata'] = $_POST;
     }
     $data = add_msg_if_any($this, $data);
     $this->load->view('messages/send_message_view', $data);
 }