public function savePage() { global $app, $siteName, $siteUrl; $args = func_get_args(); $in = array(); if (count($args) == 5) { list($email, $school, $campus, $term, $ids) = $args; } else { list($email, $school, $term, $ids) = $args; $campus = null; } if (!$this->validate($email)) { echo "false"; return; } $in['school'] = $school; $in['campus'] = $campus; $in['term'] = $term; $in['ids'] = htmlspecialchars($ids); if (!$school || $school == 'isbn') { $route = 'isbn_results'; } else { if ($campus) { $route = 'multicampus_results'; } else { $route = 'singlecampus_results'; } } $url = $app->request()->getUrl() . $app->urlFor($route, $in) . '?saved'; $numItems = count(explode(SECTION_DELIMITER, $ids)); $numWithRegularNoun = function ($num, $noun) { return ($num > 1 ? cardinal($num) . ' ' : '') . $noun . ($num > 1 ? 's' : ''); }; if ($school == 'isbn') { $yourX = "your " . $numWithRegularNoun($numItems, 'book'); } else { if ($school = SchoolQuery::create()->findOneBySlug($school)) { $schoolName = $school->getName(); $yourX = "all your books for your " . $numWithRegularNoun($numItems, 'course') . " at {$schoolName}"; } else { echo "false"; return; } } $date = date('l, F j'); $subject = "Your Textbooks at {$siteUrl}"; $body = <<<END Hey there, Here's a link to {$yourX}: {$url} Use that link at any time to come back to {$siteName} and find the lowest prices for your textbooks. Have a great semester! We'll see you soon. -- You're receiving this email because on {$date}, someone visited {$siteUrl} and requested an email reminder with a link to their textbooks. If you feel you received this message in error, let us know by replying to this message. We'll make sure it doesn't happen again. END; try { $this->sendMail($email, $subject, $body); echo "true"; } catch (Exception $e) { echo "false"; throw $e; } }
$booksPronoun = $results->numItems != 1 ? "them" : "it"; ?> <p class='lightboxHeader first centered'>Here's the deal.</p> <?php if ($isbnMode) { ?> <p id='recommendation'>We searched the web, crunched some numbers, and came up with a few options for buying your <?php echo $booksNoun; ?> :</p> <?php } else { if ($results->numItems) { $numCourses = $results->numSections; $numCoursesF = $numCourses != 1 ? cardinal($numCourses) : ""; $coursesNoun = "course" . ($numCourses != 1 ? "s" : ""); $requiresVerb = "require" . ($numCourses != 1 ? "" : "s"); $numCourseBooks = $results->numItems; $bookstoreComplete = $results->bookstoreHasAllBooks ? 'has ' : "has {$results->numBookstoreBooks} of "; $showBookstore = true; if ($results->numBookstoreBooks == 0) { $bookstoreComplete = $results->numItems > 1 ? "has none of " : "doesn't have "; $showBookstore = false; } ?> <p id='recommendation'><?php echo "Your {$numCoursesF} {$coursesNoun} {$requiresVerb} {$numCourseBooks} {$booksNoun}."; ?> Your school bookstore <?php