Example #1
0
 public function __construct()
 {
     parent::__construct();
     $this->authenticate->redirect_except();
     reset_language(current_language());
     $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
 }
 public function __construct()
 {
     parent::__construct();
     $this->authenticate->redirect_except();
     reset_language(current_language());
     $this->form_validation->set_error_delimiters('<label class="error">', '</label>');
     // Uploading experiment attachments
     $config['upload_path'] = './uploads/';
     $config['allowed_types'] = 'pdf';
     $this->load->library('upload', $config);
 }
 public function __construct()
 {
     parent::__construct();
     reset_language(L::Dutch);
     $this->load->model('NCDICheckModel');
     $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
     $config['upload_path'] = './uploads/';
     $config['max_size'] = '100';
     $config['allowed_types'] = '*';
     $this->load->library('upload', $config);
 }
Example #4
0
 /** 
  * Sends out reminders for callers. 
  */
 public function callers()
 {
     if (!$this->input->is_cli_request()) {
         echo "This script can only be accessed via the command line" . PHP_EOL;
         return;
     }
     $users = $this->userModel->get_all_callers();
     foreach ($users as $user) {
         reset_language(user_language($user));
         $this->email->clear();
         $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME);
         $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $user->email);
         $this->email->subject(lang('rem_subject'));
         $call_messages = array();
         $experiments = $this->callerModel->get_experiments_by_caller($user->id);
         foreach ($experiments as $experiment) {
             if ($experiment->archived != 1) {
                 $count = count($this->participantModel->find_participants($experiment));
                 if ($count > 0) {
                     array_push($call_messages, sprintf(lang('rem_exp_call'), $experiment->name, $count));
                 }
             }
         }
         if ($call_messages) {
             $message = sprintf(lang('mail_heading'), $user->username);
             $message .= br(2);
             $message .= lang('rem_body');
             $message .= br(1);
             $message .= ul($call_messages);
             $message .= lang('mail_ending');
             $message .= br(2);
             $message .= lang('mail_disclaimer');
             $this->email->message($message);
             $this->email->send();
             // DEBUG: echo $this->email->print_debugger();
         }
     }
 }
Example #5
0
 /**
  *
  * Submits the password reset request
  * @param $language
  */
 public function forgot_password_submit($language = L::English)
 {
     reset_language($language);
     // Validation rules
     $this->form_validation->set_rules('email', lang('email'), 'trim|required|valid_email|callback_email_exists|callback_reset_request_sent');
     // Run validation
     if ($this->form_validation->run() == FALSE) {
         // If not succeeded, show form again with error messages
         $this->forgot_password();
     } else {
         // If succeeded, lookup user by e-mail address and send password reset e-mail.
         $user = $this->userModel->get_user_by_email($this->input->post('email'));
         $url = bin2hex(openssl_random_pseudo_bytes(8));
         $reset_request = array('activated' => NULL, 'resetrequeststring' => $url, 'resetrequesttime' => input_datetime());
         $this->userModel->update_user($user->id, $reset_request);
         // Send out reset e-mail
         reset_language(user_language($user));
         $this->email->clear();
         $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME);
         $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $user->email);
         $this->email->subject(lang('resetpw_subject'));
         $message = sprintf(lang('mail_heading'), $user->username);
         $message .= br(2);
         $message .= sprintf(lang('resetpw_body'), anchor(base_url() . 'resetpw/' . $url));
         $message .= br(2);
         $message .= lang('mail_ending');
         $message .= br(2);
         $message .= lang('mail_disclaimer');
         $this->email->message($message);
         $this->email->send();
         // Show success
         flashdata(sprintf(lang('forgot_pw_sent'), $user->email));
         redirect('login', 'refresh');
     }
 }
 /** Deactivates the specified participant */
 public function deactivate($participant_id)
 {
     $this->participantModel->deactivate($participant_id, DeactivateReason::Manual);
     $p = $this->participantModel->get_participant_by_id($participant_id);
     // Inform all admins of this deactivation
     $url = $this->config->site_url() . 'participant/get/' . $participant_id;
     $users = $this->userModel->get_all_admins();
     foreach ($users as $user) {
         reset_language(user_language($user));
         $this->email->clear();
         $this->email->from(FROM_EMAIL, FROM_EMAIL_NAME);
         $this->email->to(in_development() ? TO_EMAIL_OVERRIDE : $user->email);
         $this->email->subject(lang('dereg_pp_subject'));
         $message = sprintf(lang('mail_heading'), $user->username);
         $message .= br(2);
         $message .= sprintf(lang('deac_pp_body'), name($p), $p->phone, current_username(), $url, $url);
         $message .= br(2);
         $message .= lang('mail_ending');
         $message .= br(2);
         $message .= lang('mail_disclaimer');
         $this->email->message($message);
         $this->email->send();
     }
     flashdata(sprintf(lang('p_deactivated'), name($p)));
     redirect($this->agent->referrer(), 'refresh');
 }
 /**
  * This method creates an e-mail by referring to a view and replacing the variables. 
  * TODO: refactor to use less parameters (all in one array)?
  */
 function email_replace($view, $participant = NULL, $participation = NULL, $experiment = NULL, $testinvite = NULL, $comb_experiment = NULL, $auto = FALSE, $message = "", $language = L::Dutch)
 {
     $CI =& get_instance();
     $user = $CI->userModel->get_user_by_id(current_user_id());
     reset_language($language);
     $message_data = array();
     $message_data['auto'] = $auto;
     $message_data['message'] = $message;
     $message_data['combination'] = FALSE;
     $message_data['longitudinal'] = FALSE;
     $message_data['survey_link'] = FALSE;
     if ($user) {
         $message_data['user_username'] = $user->username;
         $message_data['user_email'] = $user->email;
     }
     if ($participant) {
         $message_data['name'] = name($participant);
         $message_data['name_first'] = $participant->firstname;
         $message_data['name_parent'] = parent_name($participant);
         $message_data['gender'] = gender_child($participant->gender);
         $message_data['gender_pos'] = gender_pos($participant->gender);
         $message_data['gender_plural'] = gender_sex($participant->gender) . 's';
         $message_data['phone'] = $participant->phone;
     }
     if ($participation) {
         $leader = $CI->userModel->get_user_by_id($participation->user_id_leader);
         $message_data['appointment'] = format_datetime($participation->appointment);
         if ($leader) {
             $message_data['leader_name'] = $leader->firstname;
         }
     }
     if ($experiment) {
         $location = $CI->locationModel->get_location_by_experiment($experiment);
         $message_data['exp_name'] = $experiment->name;
         $message_data['type'] = $experiment->type;
         $message_data['duration'] = $experiment->duration;
         $message_data['duration_total'] = $experiment->duration + INSTRUCTION_DURATION;
         $message_data['description'] = $experiment->description;
         $message_data['location'] = sprintf('%s (%s)', $location->name, $location->roomnumber);
         $message_data['caller_contacts'] = extract_callers($experiment, $comb_experiment);
     }
     if ($comb_experiment) {
         $location = $CI->locationModel->get_location_by_experiment($comb_experiment);
         $comb_participation = $CI->participationModel->get_participation($comb_experiment->id, $participant->id);
         $relation = $CI->relationModel->get_relation_by_experiments($experiment->id, $comb_experiment->id);
         $message_data['combination'] = $relation->relation === RelationType::Combination;
         $message_data['longitudinal'] = $relation->relation === RelationType::Prerequisite;
         $message_data['comb_exp_name'] = $comb_experiment->name;
         $message_data['comb_type'] = $comb_experiment->type;
         $message_data['comb_duration'] = $comb_experiment->duration;
         $message_data['comb_duration_total'] = $comb_experiment->duration + INSTRUCTION_DURATION;
         $message_data['comb_description'] = $comb_experiment->description;
         $message_data['comb_location'] = sprintf('%s (%s)', $location->name, $location->roomnumber);
         $message_data['comb_appointment'] = format_datetime($comb_participation->appointment);
     }
     if ($participant && $experiment) {
         $data = get_min_max_days($participant, $experiment);
         $message_data['min_date'] = format_date($data['min_date_js']);
         $message_data['max_date'] = format_date($data['max_date_js']);
     }
     if ($testinvite) {
         $test = $CI->testInviteModel->get_test_by_testinvite($testinvite);
         $testsurvey = $CI->testInviteModel->get_testsurvey_by_testinvite($testinvite);
         $message_data['survey_name'] = testsurvey_name($testsurvey);
         $message_data['survey_link'] = survey_link($testsurvey->limesurvey_id, $testinvite->token);
         $message_data['results_link'] = results_link($test->code, $testinvite->token);
         $message_data['whennr'] = $testsurvey->whennr;
     }
     return $CI->load->view($view, $message_data, TRUE);
 }
function load_user_preferences($guest = '')
{
    global $ALLOW_COLOR_CUSTOMIZATION, $browser, $DATE_FORMAT, $DATE_FORMAT_MD, $DATE_FORMAT_MY, $DATE_FORMAT_TASK, $has_boss, $is_assistant, $is_nonuser, $is_nonuser_admin, $lang_file, $LANGUAGE, $login, $prefarray, $user, $views;
    $browser = get_web_browser();
    $browser_lang = get_browser_language();
    $colors = array('BGCOLOR' => 1, 'CELLBG' => 1, 'H2COLOR' => 1, 'HASEVENTSBG' => 1, 'MYEVENTS' => 1, 'OTHERMONTHBG' => 1, 'POPUP_BG' => 1, 'POPUP_FG' => 1, 'TABLEBG' => 1, 'TEXTCOLOR' => 1, 'THBG' => 1, 'THFG' => 1, 'TODAYCELLBG' => 1, 'WEEKENDBG' => 1, 'WEEKNUMBER' => 1);
    $lang_found = false;
    $prefarray = array();
    // Allow __public__ pref to be used if logging in or user not validated.
    $tmp_login = empty($guest) ? $login : ($guest == 'guest' ? '__public__' : $guest);
    $rows = dbi_get_cached_rows('SELECT cal_setting, cal_value
    FROM webcal_user_pref WHERE cal_login = ?', array($tmp_login));
    if ($rows) {
        for ($i = 0, $cnt = count($rows); $i < $cnt; $i++) {
            $row = $rows[$i];
            $setting = $row[0];
            $value = $row[1];
            if ($setting == 'LANGUAGE') {
                $lang_found = true;
            }
            if ($ALLOW_COLOR_CUSTOMIZATION == 'N' && isset($colors[$setting])) {
                continue;
            }
            // $sys_setting = 'sys_' . $setting;
            // Save system defaults.
            if (!empty($GLOBALS[$setting])) {
                $GLOBALS['sys_' . $setting] = $GLOBALS[$setting];
            }
            $GLOBALS[$setting] = $prefarray[$setting] = $value;
        }
    }
    // Set users timezone.
    if (isset($GLOBALS['TIMEZONE'])) {
        set_env('TZ', $GLOBALS['TIMEZONE']);
    }
    // Get views for this user and global views.
    // If NUC and not authorized by UAC, disallow global views.
    $rows = dbi_get_cached_rows('SELECT cal_view_id, cal_name, cal_view_type,
    cal_is_global, cal_owner FROM webcal_view WHERE cal_owner = ? ' . ($is_nonuser && (!access_is_enabled() || access_is_enabled() && !access_can_access_function(ACCESS_VIEW, $guest)) ? '' : ' OR cal_is_global = \'Y\' ') . 'ORDER BY cal_name', array($tmp_login));
    if ($rows) {
        $views = array();
        for ($i = 0, $cnt = count($rows); $i < $cnt; $i++) {
            $row = $rows[$i];
            $url = 'view_';
            if ($row[2] == 'E') {
                $url .= 'r.php?';
            } elseif ($row[2] == 'S') {
                $url .= 't.php?';
            } elseif ($row[2] == 'T') {
                $url .= 't.php?';
            } else {
                $url .= strtolower($row[2]) . '.php?';
            }
            $v = array('cal_view_id' => $row[0], 'cal_name' => $row[1], 'cal_view_type' => $row[2], 'cal_is_global' => $row[3], 'cal_owner' => $row[4], 'url' => $url . 'id=' . $row[0]);
            $views[] = $v;
        }
    }
    // If user has not set a language preference and admin has not specified a
    // language, then use their browser settings to figure it out
    // and save it in the database for future use (email reminders).
    $lang = 'none';
    if (!$lang_found && strlen($tmp_login) && $tmp_login != '__public__') {
        if ($LANGUAGE == 'none') {
            $lang = $browser_lang;
        }
        dbi_execute('INSERT INTO webcal_user_pref ( cal_login, cal_setting,
     cal_value ) VALUES ( ?, ?, ? )', array($tmp_login, 'LANGUAGE', $lang));
    }
    reset_language(!empty($LANGUAGE) && $LANGUAGE != 'none' ? $LANGUAGE : $browser_lang);
    if (empty($DATE_FORMAT) || $DATE_FORMAT == 'LANGUAGE_DEFINED') {
        $DATE_FORMAT = translate('__month__ __dd__, __yyyy__');
    }
    if (empty($DATE_FORMAT_MY) || $DATE_FORMAT_MY == 'LANGUAGE_DEFINED') {
        $DATE_FORMAT_MY = translate('__month__ __yyyy__');
    }
    if (empty($DATE_FORMAT_MD) || $DATE_FORMAT_MD == 'LANGUAGE_DEFINED') {
        $DATE_FORMAT_MD = translate('__month__ __dd__');
    }
    if (empty($DATE_FORMAT_TASK) || $DATE_FORMAT_TASK == 'LANGUAGE_DEFINED') {
        $DATE_FORMAT_TASK = translate('__mm__/__dd__/__yyyy__');
    }
    $has_boss = user_has_boss($tmp_login);
    $is_assistant = empty($user) ? false : user_is_assistant($tmp_login, $user);
    $is_nonuser_admin = $user ? user_is_nonuser_admin($tmp_login, $user) : false;
    // if ( $is_nonuser_admin ) load_nonuser_preferences ($user);
}
Example #9
0
 public function __construct()
 {
     parent::__construct();
     $this->authenticate->redirect_except();
     reset_language(current_language());
 }
Example #10
0
function send_reminder($id, $event_date)
{
    global $names, $emails, $site_extras, $debug, $only_testing, $server_url, $languages, $tzoffset, $application_name;
    global $EXTRA_TEXT, $EXTRA_MULTILINETEXT, $EXTRA_URL, $EXTRA_DATE, $EXTRA_EMAIL, $EXTRA_USER, $EXTRA_REMINDER, $LANGUAGE, $LOG_REMINDER;
    global $allow_external_users, $external_reminders;
    $pri[1] = translate("Low");
    $pri[2] = translate("Medium");
    $pri[3] = translate("High");
    // get participants first...
    $sql = "SELECT cal_login FROM webcal_entry_user " . "WHERE cal_id = {$id} AND cal_status IN ('A','W') " . "ORDER BY cal_login";
    $res = dbi_query($sql);
    $participants = array();
    $num_participants = 0;
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            $participants[$num_participants++] = $row[0];
        }
    }
    // get external participants
    $ext_participants = array();
    $num_ext_participants = 0;
    if (!empty($allow_external_users) && $allow_external_users == "Y" && !empty($external_reminders) && $external_reminders == "Y") {
        $sql = "SELECT cal_fullname, cal_email FROM webcal_entry_ext_user " . "WHERE cal_id = {$id} AND cal_email IS NOT NULL " . "ORDER BY cal_fullname";
        $res = dbi_query($sql);
        if ($res) {
            while ($row = dbi_fetch_row($res)) {
                $ext_participants[$num_ext_participants] = $row[0];
                $ext_participants_email[$num_ext_participants++] = $row[1];
            }
        }
    }
    if (!$num_participants && !$num_ext_participants) {
        if ($debug) {
            echo "No participants found for event id: {$id} <br />\n";
        }
        return;
    }
    // get event details
    $res = dbi_query("SELECT cal_create_by, cal_date, cal_time, cal_mod_date, " . "cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, " . "cal_name, cal_description FROM webcal_entry WHERE cal_id = {$id}");
    if (!$res) {
        echo "Db error: could not find event id {$id}.\n";
        return;
    }
    if (!($row = dbi_fetch_row($res))) {
        echo "Error: could not find event id {$id} in database.\n";
        return;
    }
    // send mail.  we send one user at a time so that we can switch
    // languages between users if needed.
    $mailusers = array();
    $recipients = array();
    if (isset($single_user) && $single_user == "Y") {
        $mailusers[] = $emails[$single_user_login];
        $recipients[] = $single_user_login;
    } else {
        for ($i = 0; $i < count($participants); $i++) {
            if (strlen($emails[$participants[$i]])) {
                $mailusers[] = $emails[$participants[$i]];
                $recipients[] = $participants[$i];
            } else {
                if ($debug) {
                    echo "No email for user {$participants[$i]} <br />\n";
                }
            }
        }
        for ($i = 0; $i < count($ext_participants); $i++) {
            $mailusers[] = $ext_participants_email[$i];
            $recipients[] = $ext_participants[$i];
        }
    }
    if ($debug) {
        echo "Found " . count($mailusers) . " with email addresses <br />\n";
    }
    for ($j = 0; $j < count($mailusers); $j++) {
        $recip = $mailusers[$j];
        $user = $participants[$j];
        if (!empty($languages[$user])) {
            $userlang = $languages[$user];
        } else {
            $userlang = $LANGUAGE;
        }
        // system default
        if ($userlang == "none") {
            $userlang = "English-US";
        }
        // gotta pick something
        if ($debug) {
            echo "Setting language to \"{$userlang}\" <br />\n";
        }
        reset_language($userlang);
        // reset timezone setting for current user
        if (empty($tzoffset[$user])) {
            $GLOBALS["TZ_OFFSET"] = 0;
        } else {
            $GLOBALS["TZ_OFFSET"] = $tzoffset[$user];
        }
        $body = translate("This is a reminder for the event detailed below.") . "\n\n";
        $create_by = $row[0];
        $name = $row[9];
        $description = $row[10];
        // add trailing '/' if not found in server_url
        if (!empty($server_url)) {
            if (substr($server_url, -1, 1) == "/") {
                $body .= $server_url . "view_entry.php?id=" . $id . "\n\n";
            } else {
                $body .= $server_url . "/view_entry.php?id=" . $id . "\n\n";
            }
        }
        $body .= strtoupper($name) . "\n\n";
        $body .= translate("Description") . ":\n";
        $body .= indent($description) . "\n";
        $body .= translate("Date") . ": " . date_to_str($event_date) . "\n";
        if ($row[2] >= 0) {
            $body .= translate("Time") . ": " . display_time($row[2]) . "\n";
        }
        if ($row[5] > 0) {
            $body .= translate("Duration") . ": " . $row[5] . " " . translate("minutes") . "\n";
        }
        if (!empty($disable_priority_field) && !$disable_priority_field) {
            $body .= translate("Priority") . ": " . $pri[$row[6]] . "\n";
        }
        if (!empty($disable_access_field) && !$disable_access_field) {
            $body .= translate("Access") . ": " . ($row[8] == "P" ? translate("Public") : translate("Confidential")) . "\n";
        }
        if (!empty($single_user_login) && $single_user_login == false) {
            $body .= translate("Created by") . ": " . $row[0] . "\n";
        }
        $body .= translate("Updated") . ": " . date_to_str($row[3]) . " " . display_time($row[4]) . "\n";
        // site extra fields
        $extras = get_site_extra_fields($id);
        for ($i = 0; $i < count($site_extras); $i++) {
            $extra_name = $site_extras[$i][0];
            $extra_descr = $site_extras[$i][1];
            $extra_type = $site_extras[$i][2];
            if ($extras[$extra_name]['cal_name'] != "") {
                $body .= translate($extra_descr) . ": ";
                if ($extra_type == $EXTRA_DATE) {
                    $body .= date_to_str($extras[$extra_name]['cal_date']) . "\n";
                } else {
                    if ($extra_type == $EXTRA_MULTILINETEXT) {
                        $body .= "\n" . indent($extras[$extra_name]['cal_data']) . "\n";
                    } else {
                        if ($extra_type == $EXTRA_REMINDER) {
                            $body .= ($extras[$extra_name]['cal_remind'] > 0 ? translate("Yes") : translate("No")) . "\n";
                        } else {
                            // default method for $EXTRA_URL, $EXTRA_TEXT, etc...
                            $body .= $extras[$extra_name]['cal_data'] . "\n";
                        }
                    }
                }
            }
        }
        if (!empty($single_user) && $single_user != "Y" && !empty($disable_participants_field) && !$disable_participants_field) {
            $body .= translate("Participants") . ":\n";
            for ($i = 0; $i < count($participants); $i++) {
                $body .= "  " . $names[$participants[$i]] . "\n";
            }
            for ($i = 0; $i < count($ext_participants); $i++) {
                $body .= "  " . $ext_participants[$i] . " (" . translate("External User") . ")\n";
            }
        }
        $subject = translate("Reminder") . ": " . $name;
        if (strlen($GLOBALS["email_fallback_from"])) {
            $extra_hdrs = "From: " . $GLOBALS["email_fallback_from"] . "\r\n" . "X-Mailer: " . translate($application_name);
        } else {
            $extra_hdrs = "X-Mailer: " . translate($application_name);
        }
        if ($debug) {
            echo "Sending mail to {$recip} (in {$userlang})\n";
        }
        if ($only_testing) {
            if ($debug) {
                echo "<hr /><pre>To: {$recip}\nSubject: {$subject}\n{$extra_hdrs}\n\n{$body}\n\n</pre>\n";
            }
        } else {
            mail($recip, $subject, $body, $extra_hdrs);
            activity_log($id, "system", $user, $LOG_REMINDER, "");
        }
    }
}
Example #11
0
$fileDir = '../includes';
//change this path if needed
$firebird_path = 'c&#58;/program files/firebird/firebird_1_5/examples/employee.fdb';
clearstatcache();
// We may need time to run extensive database loads
if (!get_php_setting('safe_mode')) {
    set_time_limit(240);
}
// If we're using SQLLite, it seems that magic_quotes_sybase must be on
//ini_set('magic_quotes_sybase', 'On');
// Check for proper auth settings
if (!empty($_SERVER['PHP_AUTH_USER'])) {
    $PHP_AUTH_USER = $_SERVER['PHP_AUTH_USER'];
}
//We'll always use browser defined languages
reset_language('none');
//Some common translations used in the install script
// translate ( 'WebCalendar Installation Wizard' ) translate ( 'Step' )
$wizardStr = translate('WebCalendar Installation Wizard Step XXX');
$passwordStr = translate('Password');
$singleUserStr = translate('Single-User');
$loginStr = translate('Login');
$failureStr = '<b>' . translate('Failure Reason') . ': </b>';
$manualStr = translate('You must manually create database');
$cachedirStr = translate('Database Cache Directory');
$logoutStr = translate('Logout');
$testSettingsStr = translate('Test Settings');
$createNewStr = translate('Create New');
$datebaseNameStr = translate('Database Name');
$backStr = translate('Back');
$nextStr = translate('Next');
Example #12
0
 /** Validates username and password. */
 public function validate($language)
 {
     reset_language($language);
     // Set validation rules
     $this->form_validation->set_rules('username', lang('username'), 'trim|required|callback_authenticate');
     $this->form_validation->set_rules('password', lang('password'), 'trim|required');
     // Rewrite error messages
     $this->form_validation->set_message('authenticate', lang('invalid_login'));
     return $this->form_validation->run();
 }
 /**
  * Checks if surveys have been completed
  */
 public function check_completed()
 {
     if (!$this->input->is_cli_request()) {
         echo "This script can only be accessed via the command line" . PHP_EOL;
         return;
     }
     // Set the language to Dutch (TODO: set to language of participant?)
     reset_language(L::Dutch);
     // Get all testinvites that have not yet been completed
     $testinvites = $this->testInviteModel->get_not_completed_testinvites();
     foreach ($testinvites as $testinvite) {
         $testsurvey = $this->testInviteModel->get_testsurvey_by_testinvite($testinvite);
         // If the survey still exists in LimeSurvey...
         if ($this->surveyModel->get_survey_by_id($testsurvey->limesurvey_id)) {
             // Check with LimeSurvey whether the survey has actually been completed
             $result = $this->surveyModel->get_result_by_token($testsurvey->limesurvey_id, $testinvite->token);
             if ($result) {
                 // If there is actually a result row, set the survey to completed
                 $this->testInviteModel->set_completed($testinvite->id, $result->submitdate);
             }
         }
     }
 }
function send_reminder($id, $event_date)
{
    global $ALLOW_EXTERNAL_USERS, $debug, $def_tz, $emails, $EXTERNAL_REMINDERS, $attachics, $htmlmail, $is_task, $LANGUAGE, $languages, $names, $only_testing, $SERVER_URL, $site_extras, $t_format, $tz;
    $ext_participants = $participants = array();
    $num_ext_participants = $num_participants = 0;
    $pri[1] = translate('High');
    $pri[2] = translate('Medium');
    $pri[3] = translate('Low');
    // Get participants first...
    $res = dbi_execute('SELECT cal_login, cal_percent FROM webcal_entry_user
    WHERE cal_id = ? AND cal_status IN ( \'A\',\'W\' ) ORDER BY cal_login', array($id));
    if ($res) {
        while ($row = dbi_fetch_row($res)) {
            $participants[$num_participants++] = $row[0];
            $percentage[$row[0]] = $row[1];
        }
    }
    $partcnt = count($participants);
    // Get external participants.
    if (!empty($ALLOW_EXTERNAL_USERS) && $ALLOW_EXTERNAL_USERS == 'Y' && !empty($EXTERNAL_REMINDERS) && $EXTERNAL_REMINDERS == 'Y') {
        $res = dbi_execute('SELECT cal_fullname, cal_email
      FROM webcal_entry_ext_user WHERE cal_id = ? AND cal_email IS NOT NULL
      ORDER BY cal_fullname', array($id));
        if ($res) {
            while ($row = dbi_fetch_row($res)) {
                $ext_participants[$num_ext_participants] = $row[0];
                $ext_participants_email[$num_ext_participants++] = $row[1];
            }
        }
    }
    $ext_partcnt = count($ext_participants);
    if (!$num_participants && !$num_ext_participants) {
        if ($debug) {
            echo 'No participants found for event id' . ": {$id}<br />\n";
        }
        return;
    }
    // Get event details.
    $res = dbi_execute('SELECT cal_create_by, cal_date, cal_time, cal_mod_date,
    cal_mod_time, cal_duration, cal_priority, cal_type, cal_access, cal_name,
    cal_description, cal_due_date, cal_due_time FROM webcal_entry
    WHERE cal_id = ?', array($id));
    if (!$res) {
        echo translate('Database error') . ': ' . translate('could not find event id') . " {$id}.\n";
        return;
    }
    if (!($row = dbi_fetch_row($res))) {
        echo translate('Error') . ': ' . str_replace('XXX', $id, translate('could not find event id XXX in database.')) . "\n";
        return;
    }
    // Send mail. We send one user at a time so that we can switch
    // languages between users if needed (as well as HTML vs plain text).
    $mailusers = $recipients = array();
    if (isset($single_user) && $single_user == 'Y') {
        $mailusers[] = $emails[$single_user_login];
        $recipients[] = $single_user_login;
    } else {
        for ($i = 0; $i < $partcnt; $i++) {
            if (strlen($emails[$participants[$i]])) {
                $mailusers[] = $emails[$participants[$i]];
                $recipients[] = $participants[$i];
            } else {
                if ($debug) {
                    echo "No email for user {$participants[$i]}.<br />\n";
                }
            }
        }
        for ($i = 0; $i < $ext_partcnt; $i++) {
            $mailusers[] = $ext_participants_email[$i];
            $recipients[] = $ext_participants[$i];
        }
    }
    $mailusercnt = count($mailusers);
    if ($debug) {
        echo 'Found ' . $mailusercnt . " with email addresses<br />\n";
    }
    for ($j = 0; $j < $mailusercnt; $j++) {
        $recip = $mailusers[$j];
        $user = $recipients[$j];
        $isExt = !in_array($user, $participants);
        $userlang = empty($languages[$user]) ? $LANGUAGE : $languages[$user];
        $userTformat = !empty($t_format[$user]) ? $t_format[$user] : 24;
        // Gotta pick something.
        if ($userlang == 'none') {
            $userlang = 'English-US';
        }
        // Gotta pick something.
        if ($debug) {
            echo "Setting language to \"{$userlang}\".<br />\n";
        }
        reset_language($userlang);
        $adminStr = translate('Administrator');
        // Reset timezone setting for current user.
        if (!empty($tz[$user])) {
            $display_tzid = 2;
            // Display TZ.
            $user_TIMEZONE = $tz[$user];
        } else {
            if (!empty($def_tz)) {
                $display_tzid = 2;
                $user_TIMEZONE = $def_tz;
            } else {
                $display_tzid = 3;
                // Do not use offset & display TZ.
                // I think this is the only real timezone set to UTC...since 1972 at least.
                $user_TIMEZONE = 'Africa/Monrovia';
            }
        }
        // This will allow date functions to use the proper TIMEZONE.
        set_env('TZ', $user_TIMEZONE);
        $useHtml = !empty($htmlmail[$user]) ? 'Y' : 'N';
        $padding = !empty($htmlmail[$user]) ? '&nbsp;&nbsp;&nbsp;' : '   ';
        $body = str_replace('XXX', $is_task ? translate('task') : translate('event'), translate('This is a reminder for the XXX detailed below.')) . "\n\n";
        $create_by = $row[0];
        $event_time = date_to_epoch($row[1] . ($row[2] != -1 ? sprintf("%06d", $row[2]) : ''));
        $name = $row[9];
        $description = $row[10];
        // Add trailing '/' if not found in server_url.
        // Don't include link for External users.
        if (!empty($SERVER_URL) && !$isExt) {
            $eventURL = $SERVER_URL . (substr($SERVER_URL, -1, 1) == '/' ? '' : '/') . 'view_entry.php?id=' . $id . '&em=1';
            if ($useHtml == 'Y') {
                $eventURL = activate_urls($eventURL);
            }
            $body .= $eventURL . "\n\n";
        }
        $body .= strtoupper($name) . "\n\n" . translate('Description') . ":\n" . $padding . $description . "\n" . ($is_task ? translate('Start Date') : translate('Date')) . ': ' . date_to_str($row[2] > 0 ? date('Ymd', $event_date) : gmdate('Ymd', $event_date)) . "\n" . ($row[2] > 0 ? ($is_task ? translate('Start Time') : translate('Time')) . ': ' . display_time('', $display_tzid, $event_time, $userTformat) . "\n" : ($row[2] == 0 && ($row[5] = 1440) ? translate('Time') . ': ' . translate('All day event') . "\n" : '')) . ($row[5] > 0 && !$is_task ? translate('Duration') . ': ' . $row[5] . ' ' . translate('minutes') . "\n" : ($is_task ? translate('Due Date') . ': ' . date_to_str($row[11]) . "\n" . translate('Due Time') . ': ' . display_time($row[12], $display_tzid, '', $userTformat) . "\n" : '')) . ($is_task && isset($percentage[$user]) ? translate('Pecentage Complete') . ': ' . $percentage[$user] . "%\n" : '') . (empty($DISABLE_PRIORITY_FIELD) || $DISABLE_PRIORITY_FIELD != 'Y' ? translate('Priority') . ': ' . $row[6] . '-' . $pri[ceil($row[6] / 3)] . "\n" : '');
        if (empty($DISABLE_ACCESS_FIELD) || $DISABLE_ACCESS_FIELD != 'Y') {
            $body .= translate('Access') . ': ';
            if ($row[8] == 'C') {
                $body .= translate('Confidential') . "\n";
            } elseif ($row[8] == 'P') {
                $body .= translate('Public') . "\n";
            } elseif ($row[8] == 'R') {
                $body .= translate('Private') . "\n";
            }
        }
        $body .= (!empty($single_user_login) && !$single_user_login ? translate('Created by') . ': ' . $row[0] . "\n" : '') . translate('Updated') . ': ' . date_to_str($row[3]) . ' ' . display_time($row[3] . sprintf("%06d", $row[4]), $display_tzid, '', $userTformat) . "\n";
        // Site extra fields.
        $extras = get_site_extra_fields($id);
        $site_extracnt = count($site_extras);
        for ($i = 0; $i < $site_extracnt; $i++) {
            if ($site_extras[$i] == 'FIELDSET') {
                continue;
            }
            $extra_name = $site_extras[$i][0];
            $extra_descr = $site_extras[$i][1];
            $extra_type = $site_extras[$i][2];
            $extra_arg1 = $site_extras[$i][3];
            $extra_arg2 = $site_extras[$i][4];
            if (!empty($site_extras[$i][5])) {
                $extra_view = $site_extras[$i][5] & EXTRA_DISPLAY_REMINDER;
            }
            if (!empty($extras[$extra_name]['cal_name']) && $extras[$extra_name]['cal_name'] != '' && !empty($extra_view)) {
                $val = '';
                $body .= $extra_descr;
                if ($extra_type == EXTRA_DATE) {
                    $body .= ': ' . $extras[$extra_name]['cal_date'] . "\n";
                } elseif ($extra_type == EXTRA_MULTILINETEXT) {
                    $body .= "\n" . $padding . $extras[$extra_name]['cal_data'] . "\n";
                } elseif ($extra_type == EXTRA_RADIO) {
                    $body .= ': ' . $extra_arg1[$extras[$extra_name]['cal_data']] . "\n";
                } else {
                    // Default method for EXTRA_URL, EXTRA_TEXT, etc...
                    $body .= ': ' . $extras[$extra_name]['cal_data'] . "\n";
                }
            }
        }
        if ((empty($single_user) || $single_user != 'Y') && (empty($DISABLE_PARTICIPANTS_FIELD) || $DISABLE_PARTICIPANTS_FIELD != 'N')) {
            $body .= translate('Participants') . ":\n";
            for ($i = 0; $i < $partcnt; $i++) {
                $body .= $padding . $names[$participants[$i]] . "\n";
            }
            for ($i = 0; $i < $ext_partcnt; $i++) {
                $body .= $padding . $ext_participants[$i] . ' ( ' . translate('External User') . ")\n";
            }
        }
        $subject = translate('Reminder') . ': ' . stripslashes($name);
        if ($debug) {
            echo "Sending mail to {$recip} (in {$userlang}).<br />\n";
        }
        if ($only_testing) {
            if ($debug) {
                echo '<hr />
<pre>
To: ' . $recip . '
Subject: ' . $subject . '
From:' . $adminStr . '

' . $body . '

</pre>
';
            }
        } else {
            $mail = new WebCalMailer();
            user_load_variables($user, 'temp');
            $recipName = $isExt ? $user : $GLOBALS['tempfullname'];
            // Send ics attachment to External Users or
            // or users who explicitly chose to receive it.
            $attach = $isExt || isset($attachics[$user]) ? $id : '';
            $mail->WC_Send($adminStr, $recip, $recipName, $subject, $body, $useHtml, $GLOBALS['EMAIL_FALLBACK_FROM'], $attach);
            $cal_text = ($isExt ? translate('External User') : '') . $recipName;
            activity_log($id, 'system', $user, LOG_REMINDER, $cal_text);
        }
    }
}
 /** Validates an e-mail */
 public function validate_email($language)
 {
     reset_language($language);
     // Set validation rules
     $this->form_validation->set_rules('email', lang('email'), 'trim|required|valid_email|callback_participant_exists');
     return $this->form_validation->run();
 }
Example #16
0
     $fmtdate = $row[2];
     $time = $row[3];
     dbi_free_result($res);
 }
 if ($time != '-1') {
     $hour = substr($time, 0, 2);
     $minute = substr($time, 2, 2);
 }
 for ($i = 0; $i < count($partlogin); $i++) {
     // does this user want email for this?
     $send_user_mail = get_pref_setting($partlogin[$i], "EMAIL_EVENT_REJECTED");
     user_load_variables($partlogin[$i], "temp");
     $user_language = get_pref_setting($partlogin[$i], "LANGUAGE");
     if ($send_user_mail == "Y" && strlen($tempemail) && $send_email != "N") {
         if ($GLOBALS['LANGUAGE'] != $user_language && !empty($user_language) && $user_language != 'none') {
             reset_language($user_language);
         }
         $msg = translate("Hello") . ", " . $tempfullname . ".\n\n" . translate("An appointment has been rejected by") . " " . $login_fullname . ". " . translate("The subject was") . " \"" . $name . " \"\n" . translate("The description is") . " \"" . $description . "\"\n" . translate("Date") . ": " . date_to_str($fmtdate) . "\n" . (empty($hour) && empty($minute) ? "" : translate("Time") . ": " . display_time($hour * 10000 + $minute * 100)) . "\n\n\n";
         if (!empty($server_url)) {
             $url = $server_url . "view_entry.php?id=" . $id;
             $msg .= "\n\n" . $url;
         }
         $from = $email_fallback_from;
         if (strlen($login_email)) {
             $from = $login_email;
         }
         $extra_hdrs = "From: {$from}\r\nX-Mailer: " . translate("Title");
         mail($tempemail, translate($application_name) . " " . translate("Notification") . ": " . $name, html_to_8bits($msg), $extra_hdrs);
         activity_log($id, $login, $partlogin[$i], $LOG_NOTIFICATION, "Event rejected by {$app_user}");
     }
 }
Example #17
0
 // Don't send mail if we are editing a non-user calendar and we are the admin.
 if (!$is_nonuser_admin && $can_email == 'Y') {
     // Only send mail if their email address is filled in.
     $do_send = get_pref_setting($participants[$i], $newevent ? 'EMAIL_EVENT_ADDED' : 'EMAIL_EVENT_UPDATED');
     $htmlmail = get_pref_setting($participants[$i], 'EMAIL_HTML');
     $t_format = get_pref_setting($participants[$i], 'TIME_FORMAT');
     $user_TIMEZONE = get_pref_setting($participants[$i], 'TIMEZONE');
     set_env('TZ', $user_TIMEZONE);
     $user_language = get_pref_setting($participants[$i], 'LANGUAGE');
     user_load_variables($participants[$i], 'temp');
     if (boss_must_be_notified($login, $participants[$i]) && !empty($tempemail) && $do_send == 'Y' && $send_user_mail && $SEND_EMAIL != 'N') {
         // We send to creator if they want it.
         if ($send_own != 'Y' && $participants[$i] == $login) {
             continue;
         }
         reset_language(empty($user_language) || $user_language == 'none' ? $LANGUAGE : $user_language);
         $fmtdate = $timetype == 'T' ? date('Ymd', $eventstart) : gmdate('Ymd', $eventstart);
         $msg = str_replace('XXX', $tempfullname, $helloStr) . "\n\n" . str_replace('XXX', $login_fullname, $newevent || empty($old_status[$participants[$i]]) ? $newAppStr : $updAppStr) . "\n" . str_replace('XXX', $name, $subjStr) . "\n\n" . str_replace('XXX', $description, $descStr) . "\n" . str_replace('XXX', date_to_str($fmtdate), $dateStr) . "\n" . ($timetype != 'T' ? '' : str_replace('XXX', display_time('', 2, $eventstart, $t_format), $timeStr) . "\n") . $extra_email_data . str_replace('XXX', generate_application_name(), $REQUIRE_APPROVALS == 'Y' ? translate('Please look on XXX to accept or reject this appointment.') : translate('Please look on XXX to view this appointment.'));
         // Add URL to event, if we can figure it out.
         if (!empty($SERVER_URL)) {
             // DON'T change & to &amp; here. Email will handle it.
             $url = $SERVER_URL . 'view_entry.php?id=' . $id . '&em=1';
             if ($htmlmail == 'Y') {
                 $url = activate_urls($url);
             }
             $msg .= "\n\n" . $url;
         }
         $wantsAttach = get_pref_setting($participants[$i], 'EMAIL_ATTACH_ICS', 'N');
         $attachId = $wantsAttach == 'Y' ? $id : '';
         // Use WebCalMailer class.
         $mail->WC_Send($login_fullname, $tempemail, $tempfullname, $name, $msg, $htmlmail, $from, $attachId);
    }
    dbi_free_result($res);
}
//get user settings
$res = dbi_execute('SELECT cal_setting, cal_value FROM webcal_user_pref
  WHERE cal_login = ?', array($prefuser));
if ($res) {
    while ($row = dbi_fetch_row($res)) {
        $prefarray[$row[0]] = $row[1];
    }
    dbi_free_result($res);
}
//this will force $LANGUAGE to to the current value and eliminate having
//to double click the 'SAVE' buton
$translation_loaded = false;
reset_language(get_pref_setting($login, 'LANGUAGE'));
//move this include here to allow proper translation
include 'includes/date_formats.php';
//get list of menu themes
$menuthemes = array();
$dir = 'includes/menu/themes/';
if (is_dir($dir)) {
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if ($file == '.' || $file == '..' || $file == 'CVS' || $file == 'default') {
                continue;
            }
            if (is_dir($dir . $file)) {
                $menuthemes[] = $file;
            }
        }
Example #19
0
 public function __construct()
 {
     parent::__construct();
     reset_language(L::Dutch);
     $this->form_validation->set_error_delimiters('<p class="error">', '</p>');
 }