| 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/merge_fields/ |
Upload File : |
<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Staff_merge_fields extends App_merge_fields
{
public function build()
{
return [
[
'name' => 'Staff Firstname',
'key' => '{staff_firstname}',
'available' => [
'staff',
'gdpr',
],
'templates' => [
'task-status-change-to-staff',
'task-commented',
'task-deadline-notification',
'task-added-attachment',
'task-added-as-follower',
'task-assigned',
'new-project-discussion-created-to-staff',
'new-project-file-uploaded-to-staff',
'new-project-discussion-comment-to-staff',
'staff-added-as-project-member',
'contract-expiration-to-staff',
'contract-signed-to-staff',
'contract-comment-to-admin',
'non-billed-tasks-reminder',
],
],
[
'name' => 'Staff Lastname',
'key' => '{staff_lastname}',
'available' => [
'staff',
'gdpr',
],
'templates' => [
'task-status-change-to-staff',
'task-commented',
'task-deadline-notification',
'task-added-attachment',
'task-added-as-follower',
'task-assigned',
'new-project-discussion-created-to-staff',
'new-project-file-uploaded-to-staff',
'new-project-discussion-comment-to-staff',
'staff-added-as-project-member',
'contract-expiration-to-staff',
'contract-signed-to-staff',
'contract-comment-to-admin',
],
],
[
'name' => 'Staff Email',
'key' => '{staff_email}',
'available' => [
'staff',
],
'templates' => [
'new-project-discussion-created-to-staff',
'new-project-file-uploaded-to-staff',
'new-project-discussion-comment-to-staff',
'staff-added-as-project-member',
],
],
[
'name' => 'Staff Date Created',
'key' => '{staff_datecreated}',
'available' => [
'staff',
],
],
[
'name' => 'Reset Password Url',
'key' => '{reset_password_url}',
'available' => [
],
'templates' => [
'staff-forgot-password',
],
],
[
'name' => 'Reminder Text',
'key' => '{staff_reminder_description}',
'available' => [
],
'templates' => [
'reminder-email-staff',
],
],
[
'name' => 'Reminder Date',
'key' => '{staff_reminder_date}',
'available' => [
],
'templates' => [
'reminder-email-staff',
],
],
[
'name' => 'Reminder Relation Name',
'key' => '{staff_reminder_relation_name}',
'available' => [
],
'templates' => [
'reminder-email-staff',
],
],
[
'name' => 'Reminder Relation Link',
'key' => '{staff_reminder_relation_link}',
'available' => [
],
'templates' => [
'reminder-email-staff',
],
],
[
'name' => 'Two Factor Authentication Code',
'key' => '{two_factor_auth_code}',
'available' => [
],
'templates' => [
'two-factor-authentication',
],
],
[
'name' => 'Password',
'key' => '{password}',
'available' => [
],
'templates' => [
'new-staff-created',
],
],
];
}
/**
* Merge field for staff members
* @param mixed $staff_id staff id
* @param string $password password is used only when sending welcome email, 1 time
* @return array
*/
public function format($staff_id, $password = '')
{
$fields = [];
$this->ci->db->where('staffid', $staff_id);
$staff = $this->ci->db->get(db_prefix().'staff')->row();
$fields['{password}'] = '';
$fields['{staff_firstname}'] = '';
$fields['{staff_lastname}'] = '';
$fields['{staff_email}'] = '';
$fields['{staff_datecreated}'] = '';
if (!$staff) {
return $fields;
}
if ($password != '') {
$fields['{password}'] = htmlentities($password);
}
if ($staff->two_factor_auth_code) {
$fields['{two_factor_auth_code}'] = $staff->two_factor_auth_code;
}
$fields['{staff_firstname}'] = e($staff->firstname);
$fields['{staff_lastname}'] = e($staff->lastname);
$fields['{staff_email}'] = e($staff->email);
$fields['{staff_datecreated}'] = e($staff->datecreated);
$custom_fields = get_custom_fields('staff');
foreach ($custom_fields as $field) {
$fields['{' . $field['slug'] . '}'] = get_custom_field_value($staff_id, $field['id'], 'staff');
}
return hooks()->apply_filters('staff_merge_fields', $fields, [
'id' => $staff_id,
'staff' => $staff,
]);
}
/**
* Merge fields for staff reminders
* @param object $reminder reminder from database
* @return array
*/
public function reminder($reminder)
{
$reminder = (object) $reminder;
$rel_data = get_relation_data($reminder->rel_type, $reminder->rel_id);
$rel_values = get_relation_values($rel_data, $reminder->rel_type);
$fields['{staff_reminder_description}'] = $reminder->description;
$fields['{staff_reminder_date}'] = _dt($reminder->date);
$fields['{staff_reminder_relation_name}'] = $rel_values['name'];
$fields['{staff_reminder_relation_link}'] = $rel_values['link'];
return hooks()->apply_filters('staff_reminder_merge_fields', $fields, [
'reminder' => $reminder,
]);
}
public function password($data, $type)
{
$fields['{reset_password_url}'] = '';
$fields['{set_password_url}'] = '';
if ($type == 'forgot') {
$fields['{reset_password_url}'] = admin_url('authentication/reset_password/1/' . $data['userid'] . '/' . $data['new_pass_key']);
}
return $fields;
}
}