| Server IP : 103.161.17.216 / Your IP : 216.73.216.1 Web Server : nginx/1.18.0 System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/app.houseland.info/application/libraries/gdpr/ |
Upload File : |
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Gdpr_projects
{
private $ci;
public function __construct()
{
$this->ci = &get_instance();
}
public function export($customer_id, $contact_id)
{
if (!class_exists('projects_model')) {
$this->ci->load->model('projects_model');
}
$valAllowed = get_option('gdpr_contact_data_portability_allowed');
if (empty($valAllowed)) {
$valAllowed = [];
} else {
$valAllowed = unserialize($valAllowed);
}
$this->ci->db->where('clientid', $customer_id);
$projects = $this->ci->db->get(db_prefix() . 'projects')->result_array();
$this->ci->db->where('show_on_client_portal', 1);
$this->ci->db->where('fieldto', 'projects');
$this->ci->db->order_by('field_order', 'asc');
$custom_fields = $this->ci->db->get(db_prefix() . 'customfields')->result_array();
foreach ($projects as $projectsKey => $project) {
if (in_array('related_tasks', $valAllowed)) {
$sql = 'SELECT * FROM ' . db_prefix() . 'tasks WHERE (rel_id="' . $project['id'] . '" AND rel_type="project"';
$sql .= ' AND addedfrom=' . $this->ci->db->escape_str($contact_id) . ' AND is_added_from_contact=1) OR (id IN (SELECT(taskid) FROM ' . db_prefix() . 'task_comments WHERE contact_id=' . $this->ci->db->escape_str($contact_id) . '))';
$tasks = $this->ci->db->query($sql)->result_array();
foreach ($tasks as $taskKey => $task) {
$this->ci->db->where('taskid', $task['id']);
$this->ci->db->where('contact_id', $contact_id);
$tasks[$taskKey]['comments'] = $this->ci->db->get(db_prefix() . 'task_comments')->result_array();
}
$projects[$projectsKey]['tasks'] = $tasks;
}
if (in_array('related_discussions', $valAllowed)) {
$sql = 'SELECT * FROM ' . db_prefix() . 'projectdiscussions WHERE (project_id="' . $project['id'] . '"';
$sql .= ' AND contact_id=' . $this->ci->db->escape_str($contact_id) . ') OR (id IN (SELECT(discussion_id) FROM ' . db_prefix() . 'projectdiscussioncomments WHERE contact_id=' . $this->ci->db->escape_str($contact_id) . ' AND discussion_type="regular"))';
$discussions = $this->ci->db->query($sql)->result_array();
foreach ($discussions as $discussionKey => $discussion) {
$this->ci->db->where('discussion_id', $discussion['id']);
$this->ci->db->where('discussion_type', 'regular');
$this->ci->db->where('contact_id', $contact_id);
$discussions[$discussionKey]['comments'] = $this->ci->db->get(db_prefix() . 'projectdiscussioncomments')->result_array();
}
$projects[$projectsKey]['discussions'] = $discussions;
}
if (in_array('projects_activity_log', $valAllowed)) {
$this->ci->db->where('project_id', $project['id']);
$this->ci->db->where('contact_id', $contact_id);
$projects[$projectsKey]['activity'] = $this->ci->db->get(db_prefix() . 'project_activity')->result_array();
}
$projects[$projectsKey]['additional_fields'] = [];
foreach ($custom_fields as $cf) {
$projects[$projectsKey]['additional_fields'][] = [
'name' => $cf['name'],
'value' => get_custom_field_value($project['id'], $cf['id'], 'projects'),
];
}
}
return $projects;
}
}