$html .= '<tr>'; $html .= '<th style="min-width:50px" title="Select if you\'d like one of ' . 'your saved roads to be available more easily at ' . 'courseroad.mit.edu/index.php#' . $athena . '">Public</th>'; $html .= '<th style="min-width:118px">Hash</th>'; $html .= '<th style="min-width:118px">Added</th>'; $html .= '<th style="min-width:95px">Major(s)</th>'; $html .= '<th>Classes</th>'; $html .= '<th style="min-width:30px;max-width:120px;">Comment</th>'; $html .= '<th>Delete?</th>'; $html .= '</tr>'; $html .= '<tr>'; $html .= '<td><input type="radio" name="setPublicRoad" ' . 'class="setPublicRoad" value="null" ' . (CourseRoadDB::hasPublicRoad($athena) ? '' : 'checked="true" ') . '/></td>'; $html .= '<td colspan="6">Select this row to prevent any of your ' . 'saved roads from being your publicly-facing road.</td>'; $html .= '</tr>'; foreach ($saved_roads as &$row) { $row['classes'] = CourseRoadDB::decrypt($row['classes']); $row['majors'] = CourseRoadDB::decrypt($row['majors']); $hash = stripslashes($row['hash']); $roadURL = "?hash={$hash}"; $html .= "<tr data-hash=\"{$hash}\">"; $html .= '<td><input type="radio" name="setPublicRoad" ' . 'class="setPublicRoad" value="' . $hash . '" ' . ($row['public'] === 1 ? 'checked="true" ' : '') . '/></td>'; $html .= '<td><span class="saved-roads-hash">' . substr(strstr($hash, '/'), 1) . '</span><span class="saved-roads-edit-hash ui-icon ui-icon-pencil">' . '</span></td>'; $html .= "<td><a class=\"hashlink\" href=\"{$roadURL}\">" . stripslashes($row['added']) . '</a></td>'; $majors = stripslashes($row['majors']); if ($majors[0] !== '[') { $majors = "[\"{$majors}\"]"; } $majors = str_replace(',"m0"', '', $majors); $majors = implode(',<br>', json_decode($majors)); $html .= "<td>{$majors}</td>"; $classes = json_decode($row['classes'], true); $classes2 = array();
function buildClassesArray($hash) { $_SESSION['crhash'] = $hash; // Pull out the latest matching saved road's classes and majors $classdata = CourseRoadDB::getClassDataFromRoad($hash); if (!$classdata) { die; } $classes = json_decode(CourseRoadDB::decrypt($classdata['classes']), true); $majors = stripslashes(CourseRoadDB::decrypt($classdata['majors'])); $majors = json_decode($majors, true); if (!$classes) { return array('error' => true, 'errorDesc' => 'No classes'); } $classes_data = array(); foreach ($classes as &$class) { if (!isset($class['override'])) { $class['override'] = false; } if (!isset($class['substitute'])) { $class['substitute'] = ''; } if (isset($class['custom'])) { $classes_data[] = pullCustom($class['name'], $class['units'], $class['term'], $class['override'], $class['substitute']); } else { $classdata = pullClass($class['id'], $class['year'], $class['term'], $class['override'], $class['substitute']); if ($classdata !== 'noclass') { $classes_data[] = $classdata; } } } return array('classes' => $classes_data, 'majors' => $majors); }