本文整理汇总了PHP中module_security::user_id_temp_restore方法的典型用法代码示例。如果您正苦于以下问题:PHP module_security::user_id_temp_restore方法的具体用法?PHP module_security::user_id_temp_restore怎么用?PHP module_security::user_id_temp_restore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类module_security
的用法示例。
在下文中一共展示了module_security::user_id_temp_restore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_file_changed_notice
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);
}
}
示例2: listCalendar
// 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
PRODID:-//Ultimate Client Manager/Calendar Plugin v1.0//EN
CALSCALE:GREGORIAN
X-WR-CALNAME:' . _l('CRM Calendar') . '
X-WR-TIMEZONE:' . module_config::c('timezone', 'America/New_York') . '
';
//$local_timezone_string = date('e');
//$local_timezone = new DateTimeZone($local_timezone_string);
//$local_time = new DateTime("now", $local_timezone);
$timezone_hours = module_config::c('timezone_hours', 0);
if (count($calendar_entries)) {
$x = 0;
foreach ($calendar_entries as $alert) {