code refactor

This commit is contained in:
2016-06-28 21:48:55 +10:00
parent a1c091a03c
commit a4da6d2d93

View File

@@ -1538,58 +1538,35 @@ function _booking_leader_helper_email_summary($node) {
$found = FALSE;
//display study session data if enabled
if (variable_get('booking_enable_studygroups', 0) == 1)
{
if (variable_get('booking_enable_studygroups', 0) == 1) {
//look up the titles of the study groups
$studygroups_query = db_query("SELECT * FROM {booking_studygroup_list} WHERE booking_eventid = :eid",
array(':eid' => $event->eid));
$studygroups = $studygroups_query->fetchAllAssoc('sid');
//for ($i = 1; $i <= variable_get('booking_studygroup_count','0'); $i++)
//for ($i = 1; $i <= count($studygroups); $i++)
foreach ($studygroups as $studygroup)
{
foreach ($studygroups as $studygroup) {
//don't print info about the readings groups
//if ($i == variable_get('booking_readinggroup_id','7'))
// continue;
//if ($studygroups[$i]->booking_is_readinggroup == 'Y')
// continue;
if ($studygroup->booking_is_readinggroup == 'Y')
if ($studygroup->booking_is_readinggroup == 'Y') {
continue;
}
//calculate the session references
//$sessionid = "session" . $i;
$sessionid = "session" . $studygroup->sid;
$roleid = $sessionid . "_role";
$otherperson_name = "TBA";
$otherperson_email = "";
$otherperson_phone = "";
//check that this study group session has been defined for this attendee and that they
if (!empty($node->$sessionid) && $node->$roleid > 0)
{
/*
//make sure we only add this prefix text once, as soon as we've found a matching role
if ($found == FALSE)
{
$found = TRUE;
$rows[] = t("You have been assigned to perform the following roles for study groups:");
}
*/
//TODO: use a function for this.
//check that this study group session has been defined for this attendee and that they have a role to perform
if (!empty($node->$sessionid) && $node->$roleid > 0) {
//if they're a leader or reserver leader, then the matching person is the helper
if ($node->$roleid == 1 || $node->$roleid == 3)
{
if ($node->$roleid == 1 || $node->$roleid == 3) {
$role = "Leader";
$otherrole = "Helper";
$otherrole_id = 2;
}
//otherwise the matching person is the leader
else
{
else {
$role = "Helper";
$otherrole = "Leader";
$otherrole_id = 1;
@@ -1606,9 +1583,9 @@ function _booking_leader_helper_email_summary($node) {
//watchdog('booking', "<pre>Other person for studygroup !group and role !role result:\n@info</pre>",
// array('!group' => $studygroup->sid, '!role' => $otherrole_id, '@info' => print_r( $otherperson, true)));
foreach ($otherperson as $other)
{
//create the text for the token
foreach ($otherperson as $other) {
$otherperson_name = $other->booking_firstname . ' ' . $other->booking_lastname;
$otherperson_email = $other->booking_email;
$otherperson_phone = $other->booking_mobile;
@@ -1618,14 +1595,14 @@ function _booking_leader_helper_email_summary($node) {
array('!role' => $role, '!id' => $studygroup->sid, '!descrip' => $studygroup->booking_studygroup_descrip,
'!otherrole' => $otherrole, '!other' => $otherperson_name, '!phone' => $otherperson_phone, '!email' => $otherperson_email,
));
}
}
}
foreach ($rows as $key => $value)
//format the output to be used in an email
foreach ($rows as $key => $value) {
$rows[$key] = wordwrap($value);
}
return implode("\n", $rows);
}