function send_file_changed_notice($file_id, $new_file = false, $send_to_admin = false) { $file_data = $this->get_file($file_id); // do we schedule an alert for this file upload? if (module_security::can_user(module_security::get_loggedin_id(), _FILE_UPLOAD_ALERT_STRING)) { // the current user is one who receives file alerts. // so for now we don't schedule this alert. // hmm - this might not work with a team environment, we'll send alerts no matter what :) } // if there are assigned staff members then only those members will receive notifications. $alert_users = module_user::get_users_by_permission(array('category' => _LABEL_USER_SPECIFIC, 'name' => _FILE_UPLOAD_ALERT_STRING, 'module' => 'config', 'view' => 1)); if (count($file_data['staff_ids']) > 0 && !(count($file_data['staff_ids']) == 1 && $file_data['staff_ids'][0] == 0)) { foreach ($alert_users as $user_id => $alert_user) { if (!in_array($user_id, $file_data['staff_ids'])) { // this user has permissions to receive alerts, but they're not assigned. unset($alert_users[$user_id]); } } } else { if (!$send_to_admin && isset($alert_users[1])) { unset($alert_users[1]); // skip admin for now until we can control that option } } // dont set a notification to ourselves. if (isset($alert_users[module_security::get_loggedin_id()])) { unset($alert_users[module_security::get_loggedin_id()]); } $file_data['customer_name'] = ''; $file_data['customer_link'] = ''; if (isset($file_data['customer_id']) && $file_data['customer_id']) { $customer_data = module_customer::get_customer($file_data['customer_id']); $file_data['customer_name'] = $customer_data['customer_name']; $file_data['customer_link'] = module_customer::link_open($file_data['customer_id']); } $file_data['file_link'] = self::link_open($file_id); foreach ($alert_users as $alert_user) { // check if this user has access to this file. if (!$alert_user['user_id']) { continue; } if (is_callable('module_security::user_id_temp_set')) { module_security::user_id_temp_set($alert_user['user_id']); $file_test = self::get_file($file_id); module_security::user_id_temp_restore(); if (!$file_test || $file_test['file_id'] != $file_id) { //echo 'user '.$alert_user['user_id'].' has no permissions <br>'; continue; // no permissions } } if (isset($alert_user['customer_id']) && $alert_user['customer_id'] > 0) { // only send this user an alert of the file is from this customer account. if (!isset($file_data['customer_id']) || $file_data['customer_id'] != $alert_user['customer_id']) { //echo 'skipping '.$alert_user['user_id'].' - no customer match <br>';continue; continue; // skip this user } } //echo 'sending to '.$alert_user['user_id'].'<br>';continue; $notification_data = array('email_id' => 0, 'view_time' => 0, 'notification_type' => $new_file ? _FILE_NOTIFICATION_TYPE_UPLOADED : _FILE_NOTIFICATION_TYPE_UPDATED, 'file_id' => $file_id, 'user_id' => $alert_user['user_id']); $template = module_template::get_template_by_key('file_upload_alert_email'); $template->assign_values($file_data); $html = $template->render('html'); // send an email to this user. $email = module_email::new_email(); $email->file_id = $file_id; $email->replace_values = $file_data; $email->set_to('user', $alert_user['user_id']); $email->set_from('user', module_security::get_loggedin_id()); $email->set_subject($template->description); // do we send images inline? $email->set_html($html); if ($email->send()) { // it worked successfully!! // sweet. $notification_data['email_id'] = $email->email_id; } else { /// log err? set_error('Failed to send notification email to user id ' . $alert_user['user_id']); } update_insert('file_notification_id', 'new', 'file_notification', $notification_data); } }
* More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ header('Content-type: text/calendar; charset=utf-8'); header('Content-Disposition: inline; filename="calfull.ics"'); $calendar_entries = array(); $login = false; // is this a calendar event for a specific staff member? if (isset($options['staff_id']) && (int) $options['staff_id'] > 0 && isset($options['staff_hash']) && !empty($options['staff_hash'])) { // check hash matches again. even though this is already done in the external hook part of calednar.php if ($options['staff_hash'] == module_calendar::staff_hash($options['staff_id'])) { // correct! log this user in, temporarily for the query and then log them out again. module_security::user_id_temp_set($options['staff_id']); $login = true; } } // get 4 months either side of todays date. for ($x = -4; $x <= 4; $x++) { $ret = listCalendar(date('m/d/Y', strtotime('+' . $x . ' months')), 'month'); if (is_array($ret) && isset($ret['events']) && count($ret['events'])) { $calendar_entries = array_merge($calendar_entries, $ret['events']); } } if ($login) { module_security::user_id_temp_restore(); } echo 'BEGIN:VCALENDAR VERSION:2.0