1<?php
2
3require_once("docutil.php");
4require_once("../html/inc/util.inc");
5require_once("help_funcs.php");
6require_once("help_db.php");
7
8$volid = get_int('volid');
9
10$vol = vol_lookup($volid);
11
12function show_info($vol) {
13    $x = "Country: $vol->country\n";
14    if ($vol->availability) {
15        $x .= "<br>Usual hours: $vol->availability";
16    }
17    if ($vol->specialties) {
18        $x .= "<br>Specialties: $vol->specialties";
19    }
20    if ($vol->projects) {
21        $x .= "<br>Projects: $vol->projects";
22    }
23    if ($vol->lang2) {
24        $x .= "<br>Primary language: $vol->lang1";
25        $x .= "<br>Secondary language: $vol->lang2";
26    }
27    $x .= "<p>";
28    return $x;
29}
30
31function live_contact($vol) {
32    $skypeid = $vol->skypeid;
33    echo "
34    <script>
35        if (navigator.userAgent.indexOf('MSIE') != -1) {
36            document.write(
37                \"<br>If requested, please enable ActiveX controls for this site.<br>\"
38            );
39        }
40    </script>
41    <p>
42    <script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
43    ";
44    if ($vol->voice_ok) {
45        echo "<a href=skype:$skypeid?call onclick=\"return skypeCheck();\"><img align=top border=0 src=images/help/phone_icon_green.gif> Call (voice)</a>
46        ";
47    }
48    if ($vol->text_ok) {
49        echo "<p><a href=skype:$skypeid?chat onclick=\"return skypeCheck();\"><img align=top border=0 src=images/help/skype_chat_icon.png> Chat (text)</a>
50        ";
51    }
52
53    echo " <p>";
54    help_warning();
55    echo " <hr> ";
56}
57
58function show_rating($vol, $rating) {
59    echo "
60        If $vol->name has helped you, please give us your feedback:
61        <form action=help_vol.php>
62        <input type=hidden name=volid value=\"$vol->id\">
63    ";
64    list_start();
65    list_item(
66        "Rating<br><span class=note>Would you recommend $vol->name to people seeking help with BOINC?</span>",
67        star_select("rating", $rating->rating)
68    );
69    list_item("Comments", textarea("comment", $rating->comment));
70    list_item("", "<input type=submit name=rate value=OK>");
71    list_end();
72    echo "
73    </form>
74    ";
75}
76
77function email_contact($vol) {
78    echo "
79        <p>
80        <h2>Contact $vol->name by email</h2>
81        <form action=help_vol.php>
82        <input type=hidden name=volid value=\"$vol->id\">
83    ";
84    list_start();
85    list_item(
86        "Your email address",
87        input("email_addr", "")
88    );
89    list_item("Subject<br><span class=note>Include 'BOINC' in the subject so $vol->name will know it's not spam</span>", input("subject", ""));
90    list_item("Message<br><span class=note>
91
92        Please include a detailed description of the problem
93        you're experiencing.
94        If possible, include the contents of BOINC's event log.
95        </span>",
96        textarea("message", "")
97    );
98    list_item("", "<input type=submit name=send_email value=OK>");
99    list_end();
100    echo "</form>
101    ";
102}
103
104$send_email = get_str2('send_email');
105$rate = get_str2('rate');
106//session_set_cookie_params(86400*365);
107//@session_start();
108//$uid = @session_id();
109$uid = false;
110
111if ($send_email) {
112    $volid = $_GET['volid'];
113    $subject = stripslashes($_GET['subject']);
114    $vol = vol_lookup($volid);
115    if (!$vol || $vol->hide) {
116        boinc_error_page("No such volunteer $volid");
117    }
118    $msg = stripslashes($_GET['message']);
119    if (!$msg) {
120        boinc_error_page("You must supply a message");
121    }
122    $body = "The following message was sent by a BOINC Help user.\n";
123    $email_addr = $_GET['email_addr'];
124    if (!is_valid_email_addr($email_addr)) {
125        boinc_error_page("You must specify a valid email address");
126    }
127    $reply = "\r\nreply-to: $email_addr";
128    $body .= "\n\n";
129    $body .= $msg;
130    if (!$subject) $subject = "BOINC Help request";
131    mail($vol->email_addr, $subject, $body, "From: BOINC".$reply);
132    page_head("Message sent");
133    echo "Your message has been sent to $vol->name";
134    page_tail();
135} else if ($rate) {
136    $volid = $_GET['volid'];
137    $vol = vol_lookup($volid);
138    if (!$vol) {
139        boinc_error_page("No such volunteer $volid");
140    }
141    $x = $_GET['rating'];
142    if ($x==null) {
143        boinc_error_page("no rating given");
144    }
145    $rating = (int) $x;
146    if ($rating < 0 || $rating > 5) {
147        boinc_error_page("bad rating");
148    }
149    $comment = stripslashes($_GET['comment']);
150    $r = null;
151    $r->volunteerid = $volid;
152    $r->rating = $rating;
153    $r->timestamp = time();
154    $r->comment = $comment;
155    $r->auth = $uid;
156    if ($uid) {
157        $oldr = rating_lookup($r);
158        if ($oldr) {
159            $retval = rating_update($r);
160            if ($retval) vol_update_rating($vol, $oldr, $r);
161        } else {
162            $retval = rating_insert($r);
163            if ($retval) vol_new_rating($vol, $rating);
164        }
165    } else {
166        $retval = rating_insert($r);
167        if ($retval) vol_new_rating($vol, $rating);
168    }
169    if (!$retval) {
170        echo mysql_error();
171        boinc_error_page("database error");
172    }
173    page_head("Feedback recorded");
174    echo "Your feedback has been recorded.  Thanks.
175        <p>
176        <a href=help.php>Return to BOINC Help</a>.
177    ";
178    page_tail();
179} else {
180    page_head("Help Volunteer: $vol->name");
181    skype_script();
182    echo show_info($vol);
183if (false) {
184    $status = skype_status($vol->skypeid);
185    if ($status != $vol->status) {
186        $vol->status = $status;
187        $vol->last_check = time();
188        if (online($vol->status)) {
189            $vol->last_online = time();
190        }
191        vol_update_status($vol);
192    }
193    $image = button_image($status);
194    echo "
195        <script type=\"text/javascript\" src=\"http://download.skype.com/share/skypebuttons/js/skypeCheck.js\"></script>
196        <img src=images/help/$image><p>
197    ";
198    echo "<table class=box cellpadding=8 width=100%><tr><td width=40%>";
199    if (online($status)) {
200        live_contact($vol);
201    }
202}
203    echo "<h2>Contact $vol->name by Skype</h2>\n";
204    skype_call_button($vol);
205    email_contact($vol);
206    echo "</td></tr></table><p>\n";
207    echo "<table class=box cellpadding=8 width=100%><tr><td>";
208    $rating = rating_vol_auth($vol->id, $uid);
209    if (!$rating) {
210        $rating = new StdClass;
211        $rating->rating = -1;
212        $rating->comment = "";
213    }
214    show_rating($vol, $rating);
215    echo "</td></tr></table>\n";
216
217    page_tail();
218}
219?>
220