?> </td> <td> <input type="password" name="password_new2" value="" /> <?php _h('Please confirm your new password here a second time.'); ?> </td> </tr> </table> <?php $fieldset_data['elements']['password'] = array('title' => _l('Change Password'), 'fields' => array(ob_get_clean())); } } if ((module_user::can_i('view', 'Users Passwords', 'Config') && $user_id == module_security::get_loggedin_id() || module_user::can_i('edit', 'Users Passwords', 'Config')) && (int) $user_id > 0 && $user_id != "new") { $fieldset_data['elements']['auto'] = array('title' => _l('Auto Login Link'), 'fields' => array('<a href="' . module_security::generate_auto_login_link($user_id) . '">' . _l('right click - copy link') . '</a> ', _hr('If you give this link to a user (or bookmark it for yourself) then it will log in automatically. To re-set an auto-login link simply change your password to something new.'))); } if (!module_security::can_user_login($user_id)) { $fieldset_data['elements']['warninglogin'] = array('warning' => _l('(note: this user does not have login permissions yet - login will not work)')); } echo module_form::generate_fieldset($fieldset_data); // todo - hook in here for a user configuration area // modules can load configuration variables in here. // hmm, is this the same as user roles. i guess it is, we'll just use user roles for now. ?> <?php /*if(module_user::can_i('edit','Fine Tune Permissions','Config')){ $user_permissions = module_security::get_user_permissions($user_id); if($user_id && !$current_role){
public function login_link($report_id) { return module_security::generate_auto_login_link($report_id); }
private function _handle_send_email() { $options = @unserialize(base64_decode($_REQUEST['options'])); if (!$options) { $options = array(); } $options = $this->get_email_compose_options($options); if (isset($_REQUEST['custom_to'])) { $custom_to = is_array($_REQUEST['custom_to']) ? $_REQUEST['custom_to'] : array($_REQUEST['custom_to']); $to = array(); foreach ($custom_to as $ct) { $ct = explode('||', $ct); $ct['email'] = $ct[0]; $ct['name'] = isset($ct[1]) ? $ct[1] : ''; $ct['user_id'] = isset($ct[2]) ? (int) $ct[2] : 0; $to[] = $ct; } } else { $to = isset($options['to']) && is_array($options['to']) ? $options['to'] : array(); } $email = $this->new_email(); $email->subject = $options['subject']; foreach ($to as $t) { if (isset($t['user_id']) && $t['user_id'] > 0) { $email->set_to('user', $t['user_id'], $t['email'], $t['name'] . (isset($t['last_name']) && module_config::c('email_to_full_name', 1) ? ' ' . $t['last_name'] : '')); } else { $email->set_to_manual($t['email'], $t['name'] . (isset($t['last_name']) && module_config::c('email_to_full_name', 1) ? ' ' . $t['last_name'] : '')); } } // set from is the default from address. if (isset($options['from_email'])) { $email->set_from_manual($options['from_email'], isset($options['from_name']) ? $options['from_name'] : ''); $email->set_bounce_address($options['from_email']); } if ($options['cc'] && is_array($options['cc'])) { foreach ($options['cc'] as $cc_details) { $bits = explode('||', $cc_details); if (count($bits) >= 2 && $bits[0]) { $email->set_cc_manual($bits[0], $bits[1]); } } } if ($options['bcc']) { $bcc = explode(',', $options['bcc']); foreach ($bcc as $b) { $b = trim($b); if (strlen($b)) { $email->set_bcc_manual($b, ''); } } } if (isset($options['company_id'])) { $email->company_id = $options['company_id']; } if (isset($options['customer_id'])) { // todo: verify this is a legit customer id we can send emails to. $email->customer_id = $options['customer_id']; if ($options['customer_id'] > 0) { foreach (module_customer::get_replace_fields($options['customer_id']) as $key => $val) { //echo "Replacing $key with $val <br>"; $email->replace($key, $val); } } } if (isset($options['newsletter_id'])) { $email->newsletter_id = $options['newsletter_id']; } if (isset($options['file_id'])) { $email->file_id = $options['file_id']; } if (isset($options['send_id'])) { $email->send_id = $options['send_id']; } if (isset($options['invoice_id'])) { $email->invoice_id = $options['invoice_id']; if ($options['invoice_id'] > 0) { foreach (module_invoice::get_replace_fields($options['invoice_id']) as $key => $val) { $email->replace($key, $val); } } } if (isset($options['job_id'])) { $email->job_id = $options['job_id']; if ($options['job_id'] > 0) { foreach (module_job::get_replace_fields($options['job_id']) as $key => $val) { $email->replace($key, $val); } } } if (isset($options['website_id'])) { $email->website_id = $options['website_id']; if ($options['website_id'] > 0) { foreach (module_website::get_replace_fields($options['website_id']) as $key => $val) { $email->replace($key, $val); } } } if (isset($options['quote_id'])) { $email->quote_id = $options['quote_id']; if ($options['quote_id'] > 0) { foreach (module_quote::get_replace_fields($options['quote_id']) as $key => $val) { $email->replace($key, $val); } } } // custom data integration if (class_exists('module_data', false) && module_config::c('custom_data_in_email', 1) && $options['customer_id'] > 0 && !empty($_REQUEST['custom_data_info']) && !empty($_REQUEST['custom_data_related'])) { global $plugins; // find all possible custom data entries $data_types = $plugins['data']->get_data_types(); foreach ($data_types as $data_type) { switch ($data_type['data_type_menu']) { case _CUSTOM_DATA_MENU_LOCATION_CUSTOMER: if ($plugins['data']->can_i('view', $data_type['data_type_name'])) { $search = array('customer_id' => $options['customer_id'], 'data_type_id' => $data_type['data_type_id']); // we have to limit the data types to only those created by current user if they are not administration $datas = $plugins['data']->get_datas($search); if ($datas) { // found some! does this exist in one of our inputs? if (!empty($_REQUEST['custom_data_info'][$data_type['data_type_id']]) && !empty($_REQUEST['custom_data_related'][$data_type['data_type_id']])) { $data_record_id = $_REQUEST['custom_data_related'][$data_type['data_type_id']]; $data_info = json_decode($_REQUEST['custom_data_info'][$data_type['data_type_id']], true); if (is_array($data_info) && isset($datas[$data_record_id])) { // we have a winner! $list_fields = array(); $data_field_groups = $plugins['data']->get_data_field_groups($data_type['data_type_id']); foreach ($data_field_groups as $data_field_group) { $data_fields = $plugins['data']->get_data_fields($data_field_group['data_field_group_id']); foreach ($data_fields as $data_field) { if ($data_field['show_list']) { $list_fields[$data_field['data_field_id']] = $data_field; } } } $list_data_items = $plugins['data']->get_data_items($data_record_id); foreach ($list_fields as $list_field) { $settings = @unserialize($list_data_items[$list_field['data_field_id']]['data_field_settings']); if (!isset($settings['field_type'])) { $settings['field_type'] = isset($list_field['field_type']) ? $list_field['field_type'] : false; } $value = false; if (isset($list_data_items[$list_field['data_field_id']])) { $value = $list_data_items[$list_field['data_field_id']]['data_text']; } if ($value) { $data_info['key'] = $value; break; } } $data_info['data_record_id'] = $data_record_id[$data_type['data_type_id']]; $email->custom_data[$data_type['data_type_id']] = $data_info; $email->set_custom_data($data_type['data_type_id'], $data_record_id); } } } } } } } // final override for first_name last_name if selected from the custom to drop down foreach ($to as $t) { if (isset($t['user_id']) && $t['user_id'] > 0) { $user = module_user::get_user($t['user_id']); if ($user) { if (strpos($options['content'], '{AUTO_LOGIN_LINK}') !== false && $t['user_id'] != 1) { $email->replace('AUTO_LOGIN_LINK', module_security::generate_auto_login_link($t['user_id'])); } $email->replace('first_name', $user['name']); $email->replace('last_name', $user['last_name']); } } } if (isset($options['note_id'])) { $email->note_id = $options['note_id']; } if (isset($options['debug_message'])) { $email->debug_message = $options['debug_message']; } $email->set_html($options['content']); foreach ($options['attachments'] as $attachment) { $email->AddAttachment($attachment['path'], $attachment['name']); } // new addition, manually added attachments. if (isset($_FILES['manual_attachment']) && isset($_FILES['manual_attachment']['tmp_name'])) { foreach ($_FILES['manual_attachment']['tmp_name'] as $key => $tmp_name) { if (is_uploaded_file($tmp_name) && isset($_FILES['manual_attachment']['name'][$key]) && strlen($_FILES['manual_attachment']['name'][$key])) { $email->AddAttachment($tmp_name, $_FILES['manual_attachment']['name'][$key]); } } } if ($email->send()) { if (isset($options['success_callback_args']) && count($options['success_callback_args']) && $options['success_callback'] && is_callable($options['success_callback'])) { // new callback method using call_user_func_array $args = $options['success_callback_args']; $args['email_id'] = $email->email_id; if (preg_match('#module_\\w#', $options['success_callback'])) { call_user_func($options['success_callback'], $args); } } /*else if($options['success_callback']){ eval($options['success_callback']); }*/ set_message('Email sent successfully'); redirect_browser($options['complete_url']); } else { set_error('Sending email failed: ' . $email->error_text); redirect_browser($options['cancel_url']); } }