function settings($data) { # a) save the main record $result = $this->_query_reader->run('update_organization_settings', array('logo_url' => $data['logo_url'], 'name' => htmlentities($data['name'], ENT_QUOTES), 'description' => htmlentities($data['description'], ENT_QUOTES), 'contact_address' => $data['address'], 'contact_city' => $data['city'], 'contact_region' => $data['region'], 'contact_zipcode' => $data['zipcode'], 'contact_country_id' => $data['contact__countries'], 'date_established' => !empty($data['registrationdate']) ? $data['registrationdate'] : '', 'registration_number' => $data['registrationno'], 'registration_country_id' => !empty($data['registration__countries']) ? $data['registration__countries'] : '', 'user_id' => $this->native_session->get('__user_id'), 'organization_id' => $this->native_session->get('__organization_id'))); # d) log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'updated_organization_settings', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "organization_id=" . $this->native_session->get('__organization_id') . "|device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => $result, 'reason' => ''); }
function update_status($newStatus, $linkIds) { $msg = ''; $links = implode("','", $linkIds); $status = array('archive' => 'inactive', 'reactivate' => 'active'); # Remove the link record completely if ($newStatus == 'delete') { $result = $this->_query_reader->run('delete_link_record', array('link_ids' => $links)); } else { $result = $this->_query_reader->run('update_link_status', array('new_status' => $status[$newStatus], 'link_ids' => $links, 'user_id' => $this->native_session->get('__user_id'))); } # log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'link_status_change', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "newstatus=" . $newStatus . "|device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => $result, 'reason' => $msg); }
function update_status($newStatus, $groupIds) { $msg = ''; $result = FALSE; $groups = implode("','", $groupIds); # Remove the document record completely if ($newStatus == 'delete') { $result = $this->_query_reader->run('delete_group_mapping', array('group_ids' => $groups)); if ($result) { $result = $this->_query_reader->run('delete_permission_group', array('group_ids' => $groups)); } } # log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'permission_group_status_change', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "newstatus=" . $newStatus . "|device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => $result, 'reason' => $msg); }
function update_status($newStatus, $idList) { $result = FALSE; # use appropriate DB status $organizationStatus = array('activate' => 'active', 'deactivate' => 'inactive', 'suspend' => 'suspended'); $userStatus = array('activate' => 'active', 'deactivate' => 'inactive', 'suspend' => 'inactive'); if (!empty($organizationStatus[$newStatus])) { $result = $this->_query_reader->run('update_organization_status', array('new_status' => $organizationStatus[$newStatus], 'id_list' => implode("','", $idList), 'user_id' => $this->native_session->get('__user_id'))); if ($result) { $result = $this->record_registration_track(array('status' => $organizationStatus[$newStatus], 'idlist' => implode(",", $idList), 'reason' => '')); } } if (!empty($userStatus[$newStatus]) && $result) { $result = $this->_query_reader->run('update_user_status_by_organization_ids', array('new_status' => $userStatus[$newStatus], 'id_list' => implode("','", $idList), 'user_id' => $this->native_session->get('__user_id'))); } # log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'update_provider_status', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => $result); }
function update_status($newStatus, $documentIds) { $msg = ''; $documents = implode("','", $documentIds); $status = array('archive' => 'inactive', 'reactivate' => 'active'); # Remove the document record completely if ($newStatus == 'delete') { foreach ($documentIds as $id) { $document = $this->details($id); if (!empty($document['url'])) { @unlink(UPLOAD_DIRECTORY . $document['url']); } } $result = $this->_query_reader->run('delete_document_record', array('document_ids' => $documents)); } else { $result = $this->_query_reader->run('update_document_status', array('new_status' => $status[$newStatus], 'document_ids' => $documents, 'user_id' => $this->native_session->get('__user_id'))); } # log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'document_status_change', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "newstatus=" . $newStatus . "|device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => $result, 'reason' => $msg); }
function invite($data) { $data['note'] = !empty($data['note']) ? $data['note'] : 'NONE'; # a) send invitation message $tender = $this->details($data['tender_id']); $users = $this->_query_reader->get_list('get_users_in_organizations', array('organization_ids' => $data['provider_id'])); $message = array('code' => 'invitation_to_bid', 'tendersubject' => $tender['subject'], 'method' => ucwords(str_replace('_', ' ', $tender['method'])), 'referencenumber' => $tender['reference_number'], 'deadline' => date(FULL_DATE_FORMAT, strtotime($tender['deadline'])), 'note' => htmlentities($data['note'], ENT_QUOTES), 'pde' => $tender['pde']); $sent = array(); foreach ($users as $row) { $result = $this->_messenger->send($row['user_id'], $message, array('email'), TRUE); if ($result) { array_push($sent, $row['email_address']); } } $result = !empty($sent); # b) add bidder record if successful if ($result) { $result = $this->_query_reader->run('add_tender_bidder', array('provider_id' => $data['provider_id'], 'tender_id' => $data['tender_id'], 'status' => 'active', 'note' => htmlentities($data['note'], ENT_QUOTES), 'user_id' => $this->native_session->get('__user_id'))); } # log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'invite_tender_bidder', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => $result); }
function remove_comment($id) { $comment = $this->_query_reader->get_query_by_code('get_forum_comment_by_id', array('comment_id' => $id)); if (!empty($comment)) { $result = $this->_query_reader->run('remove_forum_comment', array('comment_id' => $id)); } # log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'forum_comment_removal', 'result' => !empty($result) && $result ? 'SUCCESS' : 'FAIL', 'log_details' => (!empty($comment['comment']) ? "comment=" . $comment['comment'] . "|" : "") . "device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => !empty($result) && $result); }
function add($data) { $result = FALSE; $reason = ''; # add the user record if ($this->_query_reader->get_count('check_user_name', array('user_name' => $data['newusername'])) == 0 && empty($data['user_id']) || !empty($data['user_id'])) { $thisUser = $this->details(); # a) add/update the user database record $userId = $this->_query_reader->add_data((!empty($data['user_id']) ? 'edit' : 'add') . '_organization_user', array('first_name' => htmlentities($data['firstname'], ENT_QUOTES), 'last_name' => htmlentities($data['lastname'], ENT_QUOTES), 'email_address' => $data['emailaddress'], 'telephone' => $data['telephone'], 'country' => $thisUser['country_id'], 'user_name' => $data['newusername'], 'password' => sha1($data['newpassword']), 'permission_group_id' => $data['user__' . $this->native_session->get('__user_type') . 'groups'], 'status' => $data['user__userstatus'], 'organization_id' => $this->native_session->get('__organization_id'), 'user_id' => $this->native_session->get('__user_id'), 'edit_id' => !empty($data['user_id']) ? $data['user_id'] : '')); # b) notify the user about the changes if (empty($data['user_id']) && !empty($userId) || !empty($data['user_id'])) { $message = array('first_name' => htmlentities($data['firstname'], ENT_QUOTES), 'last_name' => htmlentities($data['lastname'], ENT_QUOTES), 'email_address' => $data['emailaddress'], 'telephone' => $data['telephone'], 'user_name' => $data['newusername'], 'password' => $data['newpassword'], 'status' => strtoupper($data['user__userstatus'])); $detailString = ''; foreach ($message as $key => $value) { $detailString .= '<BR><b>' . ucwords(str_replace('_', ' ', $key)) . ':</b> ' . $value; } $result = $this->_messenger->send(!empty($data['user_id']) ? $data['user_id'] : $userId, array('code' => 'your_user_profile_details', 'madeby' => $thisUser['first_name'] . ' ' . $thisUser['last_name'], 'organization' => $thisUser['organization_name'], 'newdetails' => $detailString), array('email'), TRUE); if (!$result) { $reason = "ERROR: The user notification could not be sent."; } } else { $reason = "ERROR: The user record could not be saved."; $result = FALSE; } } else { $reason = "WARNING: The user name is already in use."; } # remove the user record if this is a new addition and the commit failed if (empty($data['user_id']) && !$result && !empty($userId)) { $this->_query_reader->run('remove_temp_user', array('user_id' => $userId)); } # c) log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => (!empty($data['user_id']) ? 'edit' : 'add') . '_user', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => $result, 'reason' => $reason); }
function update_status($newStatus, $idList) { $result = FALSE; # use appropriate DB status $planStatus = array('publish' => 'published', 'deactivate' => 'archived'); if (!empty($planStatus[$newStatus])) { $result = $this->_query_reader->run('update_procurement_plan_status', array('new_status' => $planStatus[$newStatus], 'id_list' => implode("','", $idList), 'user_id' => $this->native_session->get('__user_id'))); } # log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'update_procurement_plan_status', 'result' => !empty($result) && $result ? 'SUCCESS' : 'FAIL', 'log_details' => "device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => $result); }
function update_status($newStatus, $bidIds) { $msg = ''; $bids = implode("','", $bidIds); # map the status to the action name $status = array('under_review' => 'under_review', 'short_list' => 'short_list', 'mark_as_won' => 'won', 'retract_win' => 'under_review', 'mark_as_awarded' => 'awarded', 'reject_bid' => 'rejected', 'retract_award' => 'under_review', 'submit_bid' => 'submitted', 'mark_as_archived' => 'archived', 'mark_as_completed' => 'complete'); # update status trail $result = $this->_query_reader->run('update_status_trail', array('bid_ids' => $bids)); # add the new status to the bid status trail if ($result) { $result = $this->_query_reader->run('add_status_trail', array('new_status' => $status[$newStatus], 'bid_ids' => $bids, 'user_id' => $this->native_session->get('__user_id'))); } # update the actual bid record status if ($result) { $result = $this->_query_reader->run('update_bid_status', array('new_status' => $status[$newStatus], 'bid_ids' => $bids, 'user_id' => $this->native_session->get('__user_id'))); } # submit bid - if the new status is submitted if ($result && $status[$newStatus] == 'submitted') { $result = $this->_query_reader->run('submit_provider_bid', array('bid_ids' => $bids, 'user_id' => $this->native_session->get('__user_id'))); } # notify provider about change of status, if not made by them if ($this->native_session->get('__user_type') != 'provider') { $sent = array(); foreach ($bidIds as $bidId) { $providerUserIds = $this->_query_reader->get_single_column_as_array('get_bid_provider_users', 'user_id', array('bid_id' => $bidId)); $bid = $this->details(array('bid_id' => $bidId)); if (!empty($providerUserIds) && !empty($bid)) { $sentResult = $this->_messenger->send($providerUserIds, array('code' => 'bid_status_changed', 'newstatus' => $status[$newStatus], 'pde' => $bid['pde'], 'summary' => $bid['summary'], 'tendernotice' => $bid['tender_notice'], 'datesubmitted' => $bid['date_submitted'] == '0000-00-00 00:00:00' ? date(SHORT_DATE_FORMAT, strtotime($bid['date_submitted'])) : 'NONE')); array_push($sent, $sentResult); } } if (!get_decision($sent)) { $msg = 'Status change notification could not be sent.'; } } else { $sent = array(TRUE); } if (!$result) { $msg = 'Data commit coult not be completed.'; } $finalResult = $result && get_decision($sent); # log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'bid_status_change', 'result' => $finalResult ? 'SUCCESS' : 'FAIL', 'log_details' => "newstatus=" . $status[$newStatus] . "|device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => $finalResult, 'reason' => $msg); }
function update_status($newStatus, $idList) { $result = FALSE; # use appropriate DB status $contractStatus = array('mark_as_cancelled' => 'cancelled', 'mark_as_endorsed' => 'endorsed', 'mark_as_complete' => 'complete', 'mark_as_terminated' => 'terminated', 'mark_as_archived' => 'archived'); if (!empty($contractStatus[$newStatus])) { # update contract status $result = $this->_query_reader->run('update_contract_status', array('new_status' => $contractStatus[$newStatus], 'id_list' => implode("','", $idList), 'user_id' => $this->native_session->get('__user_id'))); # add the contract status tracking if ($result) { $result = $this->_query_reader->run('add_automatic_contract_status', array('id_list' => implode("','", $idList), 'new_status' => $contractStatus[$newStatus], 'user_id' => $this->native_session->get('__user_id'), 'organization_id' => $this->native_session->get('__organization_id'))); } /*# notify associated provider about new status if($result){ $sent = array(); foreach($bidIds AS $bidId) { $providerUserIds = $this->_query_reader->get_single_column_as_array('get_bid_provider_users', 'user_id', array('bid_id'=>$bidId)); $bid = $this->details(array('bid_id'=>$bidId)); if(!empty($providerUserIds) && !empty($bid)){ $sentResult = $this->_messenger->send($providerUserIds, array( 'code'=>'bid_status_changed', 'newstatus'=>$status[$newStatus], 'pde'=>$bid['pde'], 'summary'=>$bid['summary'], 'tendernotice'=>$bid['tender_notice'], 'datesubmitted'=>date(SHORT_DATE_FORMAT, strtotime($bid['date_submitted'])) )); array_push($sent, $sentResult); } } }*/ } # log action $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'update_contract_status', 'result' => !empty($result) && $result ? 'SUCCESS' : 'FAIL', 'log_details' => "device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address())); return array('boolean' => !empty($result) && $result); }
function login() { $data = filter_forwarded_data($this); # The user wants to proceed to login if (!empty($_POST)) { if (!empty($_POST['verified'])) { $response = $this->_account->login($_POST['loginusername'], $_POST['loginpassword'], array('uri' => uri_string(), 'ip_address' => get_ip_address(), 'device' => get_user_device(), 'browser' => $this->agent->browser())); # Proceed based on the login response from the API if (!empty($response['result']) && $response['result'] == 'SUCCESS' && !empty($response['default_view'])) { add_to_user_session($this, $response['user_details']); $this->native_session->set('__default_view', $response['default_view']); if (!empty($response['permissions'])) { $this->native_session->set('__permissions', $response['permissions']); } if (!empty($response['default_view']) && !empty($response['permissions'])) { if (!empty($_POST['redirect'])) { redirect(base_url() . get_redirect_url($_POST['redirect'])); } else { redirect(base_url() . $response['default_view']); } } else { $data['msg'] = "ERROR: No permissions could be resolved for your account."; } } else { $data['msg'] = "ERROR: The user name and password do not match a registered user. Please check and try again."; } } else { $data['msg'] = "ERROR: Your login could not be verified."; } } $this->load->view('accounts/login', $data); }