|
36 | 36 | //* This function is not available in demo mode |
37 | 37 | if($conf['demo_mode'] == true) $app->error('This function is disabled in demo mode.'); |
38 | 38 |
|
39 | | -$app->uses('tpl'); |
| 39 | +$app->uses('tpl,tform'); |
40 | 40 |
|
41 | 41 | $app->tpl->newTemplate('form.tpl.htm'); |
42 | 42 | $app->tpl->setInclude('content_tpl', 'templates/client_message.htm'); |
|
60 | 60 | //* Send message |
61 | 61 | if($error == '') { |
62 | 62 | if(intval($_POST['recipient']) > 0){ |
63 | | - $circle = $app->db->queryOneRecord("SELECT client_ids FROM client_circle WHERE active = 'y' AND circle_id = ".intval($_POST['recipient'])); |
| 63 | + $circle = $app->db->queryOneRecord("SELECT client_ids FROM client_circle WHERE active = 'y' AND circle_id = ".intval($_POST['recipient'])." AND ".$app->tform->getAuthSQL('r')); |
64 | 64 | if(isset($circle['client_ids']) && $circle['client_ids'] != ''){ |
65 | 65 | $tmp_client_ids = explode(',',$circle['client_ids']); |
66 | 66 | $where = array(); |
|
106 | 106 | $app->tpl->setVar('subject',$_POST['subject']); |
107 | 107 | $app->tpl->setVar('message',$_POST['message']); |
108 | 108 | } |
| 109 | +} else { |
| 110 | + // pre-fill Sender field with reseller's email address |
| 111 | + if($_SESSION["s"]["user"]["typ"] != 'admin'){ |
| 112 | + $client_id = intval($_SESSION['s']['user']['client_id']); |
| 113 | + if($client_id > 0){ |
| 114 | + $sql = "SELECT email FROM client WHERE client_id = ".$client_id; |
| 115 | + $client = $app->db->queryOneRecord($sql); |
| 116 | + if($client['email'] != '') $app->tpl->setVar('sender',$client['email']); |
| 117 | + } |
| 118 | + } |
109 | 119 | } |
110 | 120 |
|
111 | 121 | // Recipient Drop-Down |
112 | | -$recipient = '<option value="0">'.$wb['all_clients_resellers_txt'].'</option>'; |
113 | | -$sql = "SELECT * FROM client_circle WHERE active = 'y'"; |
| 122 | +$recipient = '<option value="0"'.(intval($_POST['recipient']) == 0 ? ' selected="selected"' : '').'>'.($_SESSION["s"]["user"]["typ"] == 'admin'? $wb['all_clients_resellers_txt'] : $wb['all_clients_txt']).'</option>'; |
| 123 | +$sql = "SELECT * FROM client_circle WHERE active = 'y' AND ".$app->tform->getAuthSQL('r'); |
114 | 124 | $circles = $app->db->queryAllRecords($sql); |
115 | 125 | if(is_array($circles) && !empty($circles)){ |
116 | 126 | foreach($circles as $circle){ |
117 | | - $recipient .= '<option value="'.$circle['circle_id'].'">'.$circle['circle_name'].'</option>'; |
| 127 | + $recipient .= '<option value="'.$circle['circle_id'].'"'.(intval($_POST['recipient']) == $circle['circle_id'] ? ' selected="selected"' : '').'>'.$circle['circle_name'].'</option>'; |
118 | 128 | } |
119 | 129 | } |
120 | 130 | $app->tpl->setVar('recipient',$recipient); |
|
0 commit comments