PageRenderTime 59ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/default.inc.php

https://github.com/adamfranco/segue-1.x
PHP | 1245 lines | 827 code | 245 blank | 173 comment | 384 complexity | 20fd63eb6db06796facf157374afc838 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?
  2. /******************************************************************************
  3. * handle group adding backend here
  4. ******************************************************************************/
  5. if (count($_REQUEST[group]) && ($_REQUEST[newgroup] || $_REQUEST[groupname])) { // they chose a group
  6. if (!$_REQUEST[newgroup]) $_REQUEST[newgroup] = $_REQUEST[groupname];
  7. if (ereg("^[a-zA-Z0-9_-]{1,20}$",$_REQUEST[newgroup])) {
  8. $groupObj = new group($_REQUEST[newgroup],$_SESSION[auser]);
  9. if (group::exists($_REQUEST[newgroup])) { // already exists
  10. if ($groupObj->fetchFromDB()) {
  11. $groupObj->addClasses($_REQUEST[group]);
  12. $groupObj->updateDB();
  13. $list = implode(",",$groupObj->classes);
  14. log_entry("classgroups","$_SESSION[auser] updated $_REQUEST[newgroup] to be $list","NULL",$groupObj->id,"classgroup");
  15. } else
  16. $groupAddError = "Somebody has already created a class group with that name. Please try another name.";
  17. } else { // new group
  18. $groupObj->addClasses($_REQUEST[group]);
  19. $groupObj->updateDB();
  20. log_entry("classgroups","$_SESSION[auser] added $_REQUEST[newgroup] with ".implode(",",$groupObj->classes),"NULL",$groupObj->id,"classgroup");
  21. }
  22. } else
  23. $groupAddError = "Your group name is invalid. It may only contain alphanumeric characters, '_', '-', and be under 21 characters. No spaces, punctuation, etc.";
  24. }
  25. // default page
  26. $defaultStartQueries = $_totalQueries;
  27. $pagetitle = "Segue";
  28. $color = 0;
  29. $sitesprinted=array();
  30. //printpre($_SESSION);
  31. /******************************************************************************
  32. * Display Options
  33. ******************************************************************************/
  34. if (isset($_REQUEST[expand_pastclasses]) && $_REQUEST[expand_pastclasses] == 'true')
  35. $_SESSION["expand_pastclasses"] = true;
  36. else if (isset($_REQUEST[expand_pastclasses]) && $_REQUEST[expand_pastclasses] == 'false')
  37. $_SESSION["expand_pastclasses"] = false;
  38. else if (!isset($_SESSION["expand_pastclasses"]))
  39. $_SESSION["expand_pastclasses"] = false;
  40. if (isset($_REQUEST[expand_editorsites]) && $_REQUEST[expand_editorsites] == 'true')
  41. $_SESSION["expand_editorsites"] = true;
  42. else if (isset($_REQUEST[expand_editorsites]) && $_REQUEST[expand_editorsites] == 'false')
  43. $_SESSION["expand_editorsites"] = false;
  44. else if (!isset($_SESSION["expand_editorsites"]))
  45. $_SESSION["expand_editorsites"] = false;
  46. if (isset($_REQUEST[expand_personalsites]) && $_REQUEST[expand_personalsites] == 'true')
  47. $_SESSION["expand_personalsites"] = true;
  48. else if (isset($_REQUEST[expand_personalsites]) && $_REQUEST[expand_personalsites] == 'false')
  49. $_SESSION["expand_personalsites"] = false;
  50. else if (!isset($_SESSION["expand_personalsites"]))
  51. $_SESSION["expand_personalsites"] = false;
  52. if (isset($_REQUEST[expand_othersites]) && $_REQUEST[expand_othersites] == 'true')
  53. $_SESSION["expand_othersites"] = true;
  54. else if (isset($_REQUEST[expand_othersites]) && $_REQUEST[expand_othersites] == 'false')
  55. $_SESSION["expand_othersites"] = false;
  56. else if (!isset($_SESSION["expand_othersites"]))
  57. $_SESSION["expand_othersites"] = false;
  58. if (isset($_REQUEST[expand_upcomingclasses]) && $_REQUEST[expand_upcomingclasses] == 'true')
  59. $_SESSION["expand_upcomingclasses"] = true;
  60. else if (isset($_REQUEST[expand_upcomingclasses]) && $_REQUEST[expand_upcomingclasses] == 'false')
  61. $_SESSION["expand_upcomingclasses"] = false;
  62. else if (!isset($_SESSION["expand_upcomingclasses"]))
  63. $_SESSION["expand_upcomingclasses"] = false;
  64. if (isset($_REQUEST[expand_recentactivity]) && $_REQUEST[expand_recentactivity] == 'true')
  65. $_SESSION["expand_recentactivity"] = true;
  66. else if (isset($_REQUEST[expand_recentactivity]) && $_REQUEST[expand_recentactivity] == 'false')
  67. $_SESSION["expand_recentactivity"] = false;
  68. else if (!isset($_SESSION["expand_recentactivity"]))
  69. $_SESSION["expand_recentactivity"] = false;
  70. /******************************************************************************
  71. * public site listing link
  72. ******************************************************************************/
  73. $leftnav_extra .= <<< END
  74. <table width="100%" border='0' cellpadding='0' cellspacing='0'>
  75. <tr>
  76. <td height="100%" valign="bottom" style="font-weight: bolder">
  77. <a href='sitelisting.php?$sid' onclick='doWindow("listing",600,500)' target='listing'>Site Listing</a>
  78. </td>
  79. </tr>
  80. </table>
  81. END;
  82. /******************************************************************************
  83. * handle site copy
  84. ******************************************************************************/
  85. if ($_REQUEST[copysite] && $_REQUEST[newname] && $_REQUEST[origname]) {
  86. $newname = $_REQUEST[newname];
  87. $origSite =& new site($_REQUEST[origname]);
  88. $origSite->fetchDown(1);
  89. /******************************************************************************
  90. * Check to make sure that the slot is not already in use.
  91. * Hitting refresh after copying a site, will insert a second copy of the site
  92. * if we don't check for this.
  93. ******************************************************************************/
  94. $query = "SELECT FK_site FROM slot WHERE slot_name = '".addslashes($newname)."'";
  95. $r = db_query($query);
  96. $a = db_fetch_assoc($r);
  97. if (!$a[FK_site]) {
  98. $copyDiscussions = ($_REQUEST['copy_discussions'])?TRUE:FALSE;
  99. $origSite->copySite($newname, TRUE, $copyDiscussions);
  100. log_entry("copy_site","$_SESSION[auser] copied site ".$origname." to ".$newname,$newname,$origSite->id,"site"); // Should maybe be the newsite's id.
  101. }
  102. }
  103. /******************************************************************************
  104. * Links to other segue instances
  105. ******************************************************************************/
  106. if ($allowclasssites != $allowpersonalsites &&
  107. ($personalsitesurl != "" || $classsitesurl != "")) {
  108. if ($allowclasssites) {
  109. add_link(topnav,"Classes");
  110. add_link(topnav,"Community","$personalsitesurl",'','','');
  111. } else {
  112. add_link(topnav,"Classes","$classsitesurl",'','','');
  113. add_link(topnav,"Community");
  114. }
  115. }
  116. /******************************************************************************
  117. * Output page, get classes, etc.
  118. ******************************************************************************/
  119. if ($_loggedin) {
  120. //add_link(leftnav,"Links");
  121. foreach ($defaultlinks as $t=>$u)
  122. add_link(leftnav,$t,"http://".$u,'','',"_blank");
  123. add_link(leftnav,helplink("index"),"1");
  124. /******************************************************************************
  125. * List sites
  126. ******************************************************************************/
  127. printc("\n<div align='right'>\n\t<a href='email.php?$sid&amp;action=user&amp;from=home' onclick='doWindow(\"email\",700,500)' target='email'>Your Posts</a>\n</div>");
  128. /*********************************************************
  129. * Fetch all of the info for all of the sites and slots
  130. * that the user is an editor or owner for, so we don't have
  131. * to get them again.
  132. *********************************************************/
  133. // this should include all sites that the user owns as well.
  134. $userOwnedSlots = slot::getSlotInfoWhereUserOwner($_SESSION['auser']);
  135. if (!is_array($userOwnedSlots) || !array_key_exists($_SESSION['auser'], $userOwnedSlots)) {
  136. $userOwnedSlots[$_SESSION['auser']] = array();
  137. $userOwnedSlots[$_SESSION['auser']]['slot_name'] = $_SESSION['auser'];
  138. $userOwnedSlots[$_SESSION['auser']]['slot_type'] = 'personal';
  139. $userOwnedSlots[$_SESSION['auser']]['slot_owner'] = $_SESSION['auser'];
  140. $userOwnedSlots[$_SESSION['auser']]['site_exits'] = false;
  141. }
  142. if ($_SESSION["expand_othersites"] != 0 || $_SESSION["expand_editorsites"] != 0 || $_SESSION["expand_pastclasses"] != 0 || $_SESSION["expand_upcomingclasses"] != 0 || $_SESSION["expand_personalsites"] != 0) {
  143. // Add any user-owned groups that aren't already in the slot list
  144. $userOwnedGroups = group::getGroupsOwnedBy($_SESSION['auser']);
  145. foreach ($userOwnedGroups as $classSiteName) {
  146. if (!isset($userOwnedSlots[$classSiteName])) {
  147. $userOwnedSlots[$classSiteName] = array();
  148. $userOwnedSlots[$classSiteName]['slot_name'] = $classSiteName;
  149. $userOwnedSlots[$classSiteName]['slot_type'] = 'class';
  150. $userOwnedSlots[$classSiteName]['slot_owner'] = $_SESSION['auser'];
  151. $userOwnedSlots[$classSiteName]['site_exits'] = false;
  152. }
  153. }
  154. if ($_SESSION["expand_editorsites"] != 0) {
  155. $siteLevelEditorSites = segue::getSiteInfoWhereUserIsSiteLevelEditor($_SESSION['auser']);
  156. $anyLevelEditorSites = segue::getSiteInfoWhereUserIsEditor($_SESSION['auser']);
  157. }
  158. }
  159. $usersCurrentClasses = $classes;
  160. $usersOldClasses = $oldclasses;
  161. $usersFutureClasses = $futureclasses;
  162. $usersAllClasses = $allclasses[$_SESSION['auser']];
  163. // replace groupclasses with their groups
  164. $classgroupLists = getClassgroupListsForGroupsContainingClasses(array_keys($usersAllClasses));
  165. foreach ($classgroupLists as $groupName => $classgroupList) {
  166. foreach ($classgroupList as $className => $classParts) {
  167. // Make a virtual group-code to sort with.
  168. // Note: this assumes (for ordering purposes), that all classes in the
  169. // group are in the same semester/year.
  170. $groupParts = array(
  171. 'code' => $groupName,
  172. 'sect' => '',
  173. 'sem' => $classParts['sem'],
  174. 'year' => $classParts['year']
  175. );
  176. if (isset($usersCurrentClasses[$className])) {
  177. unset($usersCurrentClasses[$className]);
  178. if (!isset($usersCurrentClasses[$groupName]))
  179. $usersCurrentClasses[$groupName] = $groupParts;
  180. }
  181. if (isset($usersOldClasses[$className])) {
  182. unset($usersOldClasses[$className]);
  183. if (!isset($usersOldClasses[$groupName]))
  184. $usersOldClasses[$groupName] = $groupParts;
  185. }
  186. if (isset($usersFutureClasses[$className])) {
  187. unset($usersFutureClasses[$className]);
  188. if (!isset($usersFutureClasses[$groupName]))
  189. $usersFutureClasses[$groupName] = $groupParts;
  190. }
  191. if (isset($usersAllClasses[$className])) {
  192. unset($usersAllClasses[$className]);
  193. if (!isset($usersAllClasses[$groupName]))
  194. $usersAllClasses[$groupName] = $groupParts;
  195. }
  196. }
  197. }
  198. // Sort the classes
  199. $usersCurrentClasses = array_keys(sortClasses($usersCurrentClasses));
  200. $usersOldClasses = array_keys(sortClasses($usersOldClasses));
  201. $usersFutureClasses = array_keys(sortClasses($usersFutureClasses));
  202. $usersAllClasses = array_keys(sortClasses($usersAllClasses));
  203. // Fetch all of the class info
  204. $usersAllClassesInfo = slot::getSlotInfoForSlots($usersAllClasses);
  205. foreach ($usersAllClasses as $classSiteName) {
  206. if (!isset($usersAllClassesInfo[$classSiteName])) {
  207. $usersAllClassesInfo[$classSiteName] = array();
  208. $usersAllClassesInfo[$classSiteName]['slot_name'] = $classSiteName;
  209. $usersAllClassesInfo[$classSiteName]['slot_type'] = 'class';
  210. $usersAllClassesInfo[$classSiteName]['slot_owner'] = null;
  211. $usersAllClassesInfo[$classSiteName]['site_exits'] = false;
  212. }
  213. }
  214. // visitor are users who post to public discussions w/o logging in
  215. // visitors are not allowed to create sites
  216. if ($_SESSION[atype] == 'visitor') {
  217. printc("Welcome to Segue. You have a visitor account that was created when you registered with Segue. ");
  218. printc("This account will allow you to post to any public discussions ");
  219. printc("and view all publically accessible sites.<br /><br />");
  220. } else if ($_SESSION[atype] == 'guest') {
  221. printc("Welcome to Segue. You have been given a guest account. ");
  222. printc("This account will allow you to view sites and post to discussions/assessments");
  223. printc("that are limited to users in the ".$cfg[inst_name]." community.<br /><br />");
  224. }
  225. printc("\n<table width='100%'>");
  226. /******************************************************************************
  227. * Recent Activity
  228. ******************************************************************************/
  229. if ($_SESSION["expand_recentactivity"] == 0) {
  230. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_recentactivity=true'>+</a> Recent Activity</td>\n\t\t</tr>");
  231. } else {
  232. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_recentactivity=false'>-</a> Recent Activity</td>\n\t\t</tr>");
  233. }
  234. printc("\n</table>");
  235. if ($_SESSION["expand_recentactivity"] != 0) {
  236. printc("<table border='0' width='100%' align ='center' cellpadding='0' cellspacing='5'>");
  237. printc("<tr><td valign='top'>");
  238. //recent discussions
  239. //pagination variables
  240. if (isset($_REQUEST["discussion_set"]) && $_REQUEST["discussion_set"] > 0)
  241. $_SESSION["discussion_set"] = intval($_REQUEST["discussion_set"]);
  242. else if (!isset($_SESSION["discussion_set"]))
  243. $_SESSION["discussion_set"] = 1;
  244. $num_per_set = 10;
  245. $start = ($_SESSION["discussion_set"] - 1) * $num_per_set;
  246. $end = $start + $num_per_set;
  247. $recent_discussions = recent_discussions($start, $num_per_set, $_SESSION["aid"]);
  248. $number_in_batch = db_num_rows($recent_discussions);
  249. if ($number_in_batch > 0 || $start > 0) {
  250. $recent_discussions_sites = "\n<table border='0' width='100%' align='center' cellpadding='1' cellspacing='0'>";
  251. $recent_discussions_sites .= "\n\t<tr><td colspan='4' align='left' class='title2'>Recent Discussions";
  252. //print out headers
  253. $recent_discussions_sites .= "</td></tr>";
  254. $recent_discussions_sites .= "\n\t<tr>\n\t\t<td class='title3'>Date/Time</td>\n\t\t<td class='title3'>Participant</td>\n\t\t<td class='title3'>Subject</td>\n\t\t<td class='title3'>Site</td>\n\t</tr>";
  255. // printpre($start);
  256. // printpre($end);
  257. // printpre($number_in_batch);
  258. while ($a = db_fetch_assoc($recent_discussions)) {
  259. $recent_discussions_sites .= "<tr>";
  260. preg_match('/^([0-9]{4}-[0-9]{2}-[0-9]{2}) ([0-9]{2}:[0-9]{2}):[0-9]{2}/', $a['discussion_tstamp'], $matches);
  261. //$tstamp =& TimeStamp::fromString($tstamp);
  262. //$time =& $tstamp->asTime();
  263. //$recent_discussions_sites .= "<td valign='top' class='list'>".$tstamp->ymdString()."<br/>".$time->string12(true)."</td>";
  264. $recent_discussions_sites .= "\n\t<td valign='top' class='list' style='white-space: nowrap;'>".$matches[1]." &nbsp; ".$matches[2]."</td>";
  265. $recent_discussions_sites .= "\n\t<td valign='top' class='list'><a href='$PHP_SELF?type=recent&amp;user=".$a['user_uname']."'>".$a['user_fname']."</a></td>";
  266. $recent_discussions_sites .= "\n\t<td valign='top' class='list'><a href='".$_full_uri."/index.php?&amp;site=".$a['slot_name'];
  267. $recent_discussions_sites .= "&amp;action=site&amp;section=".$a['section_id']."&amp;page=".$a['page_id']."&amp;story=".$a['story_id'];
  268. $recent_discussions_sites .= "&amp;detail=".$a['story_id']."#".$a['discussion_id'];
  269. $recent_discussions_sites .= "' target='new_window'>";
  270. $recent_discussions_sites .= urldecode($a['discussion_subject'])."</a></td>";
  271. $recent_discussions_sites .= "\n\t<td valign='top' class='list'><a href='".$_full_uri."/index.php?&amp;site=".$a['slot_name'];
  272. $recent_discussions_sites .= "&amp;action=site&amp;section=".$a['section_id']."&amp;page=".$a['page_id']."&amp;story=".$a['story_id'];
  273. $recent_discussions_sites .= "&amp;detail=".$a['story_id'];
  274. $recent_discussions_sites .= "' target='new_window'>".$a['site_title']."</a></td>";
  275. $recent_discussions_sites .= "\n\t</tr>";
  276. }
  277. // print out discussion pagination
  278. $pagelinks = array();
  279. if ($num_per_set != 0) {
  280. $recent_discussions_sites .= "\n\t<tr><td colspan='4' align='left'>";
  281. $recent_discussions_sites .= "\n\t<div class='multi_page_links'>";
  282. for ($i = 1; $i <= ($start / $num_per_set); $i++) {
  283. $pagelinks[] = "?$sid&amp;discussion_set=".$i;
  284. $recent_discussions_sites .= "\n\t\t<a href='?$sid&amp;discussion_set=".$i."'>".$i."</a> | ";
  285. }
  286. // The current one is the last one printed
  287. $pagelinks[] = "current";
  288. $recent_discussions_sites .= "\n\t\t<strong>".$i."</strong> ";
  289. // Next links if there are more results
  290. if ($number_in_batch >= $num_per_set) {
  291. $i++;
  292. $recent_discussions_sites .= " | \n\t\t<a href='?$sid&amp;discussion_set=".$i."'>".$i." >></a> ";
  293. }
  294. $recent_discussions_sites .= "\n\t</div>\n\t</td>\n\t</tr>";
  295. }
  296. $recent_discussions_sites .= "\n</table>";
  297. printc($recent_discussions_sites);
  298. }
  299. printc("\n\t</td>\n\t</tr>\n\t<tr>\n\t<td valign='top'>");
  300. // recently edited content
  301. $recentComponents = recent_edited_components(10, $_SESSION["aid"]);
  302. if (count($recentComponents)) {
  303. $number_recent_sites = count($recentComponents);
  304. $edited_sites = "\n\t\t<table border='0' width='100%' align ='center' cellpadding='1' cellspacing='0'>";
  305. $edited_sites .= "\n\t\t\t<tr>\n\t\t\t<td colspan='3' align='left' class='title2'>Your Recent Edits";
  306. $edited_sites .="</td>\n\t\t\t</tr>";
  307. $edited_sites .= "\n\t\t\t<tr>\n\t\t\t<td class='title3'>Date</td>\n\t\t\t<td class='title3'>Site</td>\n\t\t\t<td class='title3'>Most Recent Edit...</td>\n\t\t\t</tr>";
  308. foreach ($recentComponents as $a) {
  309. $url = $_full_uri."/index.php?";
  310. $url .= "&amp;action=site&amp;site=".$a['slot_name'];
  311. if ($a['mr_section_id'])
  312. $url .= "&amp;section=".$a['mr_section_id'];
  313. if ($a['mr_page_id'])
  314. $url .= "&amp;page=".$a['mr_page_id'];
  315. if ($a['mr_story_id'])
  316. $url .= "&amp;story=".$a['mr_story_id'];
  317. // printpre($a);
  318. $edited_sites .= "\n\t\t\t<tr>";
  319. preg_match('/^([0-9]{4}-[0-9]{2}-[0-9]{2})/', $a['most_recent_tstamp'], $matches);
  320. $edited_sites .= "\n\t\t\t<td valign='top' class='list'>".$matches[1]."</td>";
  321. $edited_sites .= "\n\t\t\t<td valign='top' class='list' style='text-align: left; width: 25%; padding-left: 5px;'> <a href=\"".$url."\" target='new_window'>".$a['site_title']."</a></td>";
  322. $edited_sites .= "\n\t\t\t<td valign='top' class='list'><a href=\"".$url."\" target='new_window'>";
  323. // $edited_sites .= $a['site_title'];
  324. if ($a['mr_section_title'] != "") {
  325. $edited_sites .= " > ".$a['mr_section_title'];
  326. }
  327. if ($a['mr_page_title'] != "") {
  328. $edited_sites .= " > ".$a['mr_page_title'];
  329. }
  330. if ($a['mr_story_title'] != "") {
  331. $edited_sites .= " > ".$a['mr_story_title'];
  332. }
  333. $edited_sites .= "</a></td>";
  334. $edited_sites .= "\n\t\t\t</tr>";
  335. }
  336. $edited_sites .= "\n\t\t</table>";
  337. printc($edited_sites);
  338. }
  339. printc("\n\t</td>\n\t</tr>\n</table>");
  340. }
  341. /******************************************************************************
  342. * Print out classes
  343. ******************************************************************************/
  344. if ($allowclasssites) {
  345. $_class_list_titles = array("usersCurrentClasses"=>"Your Current Classes",
  346. "usersFutureClasses"=>"Upcoming Classes",
  347. "usersOldClasses"=>"Previous Semesters");
  348. /*********************************************************
  349. * Class Sites for students
  350. *********************************************************/
  351. if ($_SESSION[atype]=='stud') {
  352. //loop through all classes in list
  353. foreach ($_class_list_titles as $timePeriod => $title) {
  354. /******************************************************************************
  355. * Current Classes Title
  356. ******************************************************************************/
  357. if ($timePeriod == "usersCurrentClasses") {
  358. printc("\n<table border='0' width='100%'>");
  359. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'>Current Class Sites</td>\n\t\t</tr>");
  360. printc("\n\t\t\t\t<tr>\n\t\t\t\t\t<th>class</th>\n\t\t\t\t\t<th>site</th>\n\t\t\t\t</tr>");
  361. $groupsPrinted = array();
  362. foreach ($usersCurrentClasses as $className) {
  363. if ($classSiteName = group::getNameFromClass($className)) {
  364. if ($groupsPrinted[$classSiteName])
  365. continue;
  366. $groupsPrinted[$classSiteName] = true;
  367. } else {
  368. $classSiteName = $className;
  369. }
  370. if (isset($userOwnedSlots[$classSiteName]))
  371. printStudentSiteLine($classSiteName, $userOwnedSlots[$classSiteName]);
  372. else if (isset($anyLevelEditorSites[$classSiteName]))
  373. printStudentSiteLine($classSiteName, $anyLevelEditorSites[$classSiteName]);
  374. else if (isset($usersAllClassesInfo[$classSiteName]))
  375. printStudentSiteLine($classSiteName, $usersAllClassesInfo[$classSiteName]);
  376. else
  377. printc("\n\t\t\t\t<tr>\n\t\t\t\t<td colspan='2' style='background-color: red; font-weight: bold'>There was an error loading information for site: ".$classSiteName."\n\t\t\t\t\t</td>\n\t\t\t\t</tr>");
  378. }
  379. printc("\n\t\t\t</table>");
  380. } else if ($timePeriod == "usersOldClasses") {
  381. /******************************************************************************
  382. * expand/collapse link for previous sites listing
  383. ******************************************************************************/
  384. if ($timePeriod == "usersOldClasses") {
  385. printc("<table border='0' width='100%'>");
  386. if (!$_SESSION["expand_pastclasses"]) {
  387. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_pastclasses=true'>+</a> $title \n\t\t</td></tr>");
  388. } else {
  389. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_pastclasses=false'>-</a> $title \n\t\t</td></tr>");
  390. printc("\n\t<tr>");
  391. printc("\n\t\t<td valign='top'>");
  392. }
  393. }
  394. if ($_SESSION["expand_pastclasses"] == 0 && $timePeriod == "usersOldClasses") {
  395. // do nothing
  396. } else {
  397. printc("\n\t\t\t<table width='100%'>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>class</th>\n\t\t\t\t\t<th>site</th>\n\t\t\t\t</tr>");
  398. $groupsPrinted = array();
  399. foreach ($$timePeriod as $className) {
  400. if ($classSiteName = group::getNameFromClass($className)) {
  401. if ($groupsPrinted[$classSiteName])
  402. continue;
  403. $groupsPrinted[$classSiteName] = true;
  404. } else {
  405. $classSiteName = $className;
  406. }
  407. // Your other sites
  408. if (isset($userOwnedSlots[$classSiteName]))
  409. printStudentSiteLine($classSiteName, $userOwnedSlots[$classSiteName]);
  410. //Sites you can edit
  411. else if (isset($anyLevelEditorSites[$classSiteName]))
  412. printStudentSiteLine($classSiteName, $anyLevelEditorSites[$classSiteName]);
  413. else if (isset($usersAllClassesInfo[$classSiteName]))
  414. printStudentSiteLine($classSiteName, $usersAllClassesInfo[$classSiteName]);
  415. else
  416. printc("\n\t\t\t\t<tr>\n\t\t\t\t<td colspan='2' style='background-color: red; font-weight: bold'>There was an error loading information for site: ".$classSiteName."\n\t\t\t\t\t</td>\n\t\t\t\t</tr>");
  417. }
  418. printc("\n\t\t\t</table>");
  419. printc("\n\t\t</td>");
  420. printc("\n\t</tr>");
  421. }
  422. }
  423. }
  424. printc("\n</table>");
  425. }
  426. }
  427. if (isset($groupAddError) && $groupAddError)
  428. error($groupAddError);
  429. // printc("\n<div class='title'>Sites".helplink("sites")."</div>");
  430. printc("\n<form name='groupform' action='$PHP_SELF?$sid&amp;action=default' method='post'>");
  431. printc("\n\t<table width='100%'>");
  432. /*********************************************************
  433. * Personal Sites
  434. *********************************************************/
  435. // if ($allowpersonalsites) {
  436. // // print out the personal site if there is a slot for them that they own.
  437. // if ($userOwnedSlots[$_SESSION['auser']]['slot_owner'] == $_SESSION['auser']) {
  438. // // visitor are users who post to public discussions w/o logging in
  439. // // visitors are not allowed to create sites
  440. // if ($_SESSION[atype] == 'visitor') {
  441. // printc("Welcome to Segue. You have a visitor account that was created when you registered with Segue. ");
  442. // printc("This account will allow you to post to any public discussions ");
  443. // printc("and view all publically accessible sites.<br /><br />");
  444. // } else if ($_SESSION[atype] == 'guest') {
  445. // printc("Welcome to Segue. You have been given a guest account. ");
  446. // printc("This account will allow you to view sites and post to discussions/assessments");
  447. // printc("that are limited to users in the ".$cfg[inst_name]." community.<br /><br />");
  448. // } else {
  449. // printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'>Personal Site</td>\n\t\t</tr>");
  450. // printSiteLine2($userOwnedSlots[$_SESSION['auser']]);
  451. // }
  452. // }
  453. // }
  454. /*********************************************************
  455. * Personal Sites
  456. *********************************************************/
  457. if ($allowpersonalsites) {
  458. // visitor are users who post to public discussions w/o logging in
  459. // visitors are not allowed to create sites
  460. if ($_SESSION[atype] != 'visitor' && $_SESSION[atype] != 'guest') {
  461. if ($_SESSION["expand_personalsites"] == 0) {
  462. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_personalsites=true'>+</a> Personal Sites</td>\n\t\t</tr>");
  463. } else {
  464. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_personalsites=false'>-</a> Personal Sites</td>\n\t\t</tr>");
  465. }
  466. if ($_SESSION["expand_personalsites"] != 0) {
  467. $sites=array();
  468. if (is_array($userOwnedSlots)) {
  469. foreach (array_keys($userOwnedSlots) as $name) {
  470. $info =& $userOwnedSlots[$name];
  471. if (!in_array($name, $sitesprinted) && $info['slot_type'] == 'personal') {
  472. $sites[$name] =& $info;
  473. }
  474. }
  475. }
  476. if (count($sites)) {
  477. foreach (array_keys($sites) as $name)
  478. printSiteLine2($sites[$name]);
  479. }
  480. unset($sites);
  481. }
  482. }
  483. }
  484. /*********************************************************
  485. * Class sites for professors
  486. *********************************************************/
  487. if ($allowclasssites) {
  488. //class sites for professors (for student see above)
  489. if ($_SESSION['atype'] == 'prof' || $_SESSION['atype'] == 'admin') {
  490. //current classes
  491. if (count($classes)) {
  492. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'>Current Class Sites</td>\n\t\t</tr>");
  493. $groupsPrinted = array();
  494. foreach ($usersCurrentClasses as $className) {
  495. if ($classSiteName = group::getNameFromClass($className)) {
  496. if ($groupsPrinted[$classSiteName])
  497. continue;
  498. $groupsPrinted[$classSiteName] = true;
  499. } else {
  500. $classSiteName = $className;
  501. }
  502. if (isset($userOwnedSlots[$classSiteName]))
  503. printSiteLine2($userOwnedSlots[$classSiteName], 0, 1, $_SESSION[atype]);
  504. else if (isset($anyLevelEditorSites[$classSiteName]))
  505. printSiteLine2($anyLevelEditorSites[$classSiteName], 0, 1, $_SESSION[atype]);
  506. else if (isset($usersAllClassesInfo[$classSiteName]))
  507. printSiteLine2($usersAllClassesInfo[$classSiteName], 0, 1, $_SESSION[atype]);
  508. else
  509. printc("\n\t\t<tr>\n\t\t\t<td colspan='2' style='background-color: red; font-weight: bold'>There was an error loading information for site: ".$classSiteName."</td>\n\t\t</tr>");
  510. }
  511. }
  512. //upcoming classes
  513. if (count($usersFutureClasses)) {
  514. if ($_SESSION["expand_upcomingclasses"] == 0) {
  515. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_upcomingclasses=true'>+</a> Upcoming Classes</td>\n\t\t</tr>");
  516. } else {
  517. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_upcomingclasses=false'>-</a> Upcoming Classes</td>\n\t\t</tr>");
  518. foreach ($usersFutureClasses as $className) {
  519. if ($classSiteName = group::getNameFromClass($className)) {
  520. if ($groupsPrinted[$classSiteName]) {
  521. continue;
  522. }
  523. $groupsPrinted[$classSiteName] = true;
  524. } else {
  525. $classSiteName = $className;
  526. }
  527. if (isset($userOwnedSlots[$classSiteName]))
  528. printSiteLine2($userOwnedSlots[$classSiteName], 0, 1, $_SESSION[atype]);
  529. else if (isset($anyLevelEditorSites[$classSiteName]))
  530. printSiteLine2($anyLevelEditorSites[$classSiteName], 0, 1, $_SESSION[atype]);
  531. else if (isset($usersAllClassesInfo[$classSiteName]))
  532. printSiteLine2($usersAllClassesInfo[$classSiteName], 0, 1, $_SESSION[atype]);
  533. else
  534. printc("\n\t\t<tr>\n\t\t\t<td colspan='2'>There was an error loading information for site: ".$classSiteName."</td>\n\t\t</tr>");
  535. }
  536. }
  537. }
  538. //info/interface for groups
  539. if (count($classes) || count($usersFutureClasses)) {
  540. printc("\n\t\t<tr>\n\t\t\t<th colspan='2' align='right'>add checked sites to group: \n\t\t\t\t<input type='text' name='newgroup' size='10' class='textfield' />");
  541. $havegroups = count($userOwnedGroups);
  542. if ($havegroups) {
  543. printc(" \n\t\t\t\t<select name='groupname' onchange='document.groupform.newgroup.value = document.groupform.groupname.value'>");
  544. printc("\n\t\t\t\t\t<option value=''>-choose-</option>");
  545. foreach ($userOwnedGroups as $group) {
  546. printc("\n\t\t\t\t\t<option value='$group'>$group</option>");
  547. }
  548. printc("\n\t\t\t\t</select>");
  549. }
  550. printc(" \n\t\t\t\t<input type='submit' class='button' value='add' />");
  551. printc("\n\t\t\t</th>\n\t\t</tr>");
  552. printc("\n\t\t<tr>\n\t\t\t<th colspan='2' align='left'>");
  553. printc("\n\t\t\t\t<div style='padding-left: 10px; font-size: 10px;'>By adding sites to a group you can consolidate multiple class sites into one entity. This is useful if you teach multiple sections of the same class and want to work on only one site for those classes/sections. Check the boxes next to the classes you would like to add, and either type in a new group name or choose an existing one.</div>");
  554. if ($havegroups) printc("\n\t\t\t\t<div class='desc'>\n\t\t\t\t\t<a href='edit_groups.php?$sid' target='groupeditor' onclick='doWindow(\"groupeditor\",400,400)'>[edit class groups]</a>\n\t\t\t\t</div>");
  555. printc("\n\t\t\t</th>\n\t\t</tr>");
  556. }
  557. //past classes
  558. if ($_SESSION["expand_pastclasses"] == 0) {
  559. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_pastclasses=true'>+</a> Past Classes</td>\n\t\t</tr>");
  560. } else {
  561. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_pastclasses=false'>-</a> Past Classes</td>\n\t\t</tr>");
  562. }
  563. if ($_SESSION["expand_pastclasses"] != 0) {
  564. $sites=array();
  565. if (is_array($userOwnedSlots)) {
  566. foreach (array_keys($userOwnedSlots) as $name) {
  567. $info =& $userOwnedSlots[$name];
  568. if (!in_array($name, $sitesprinted)) {
  569. if ($allowclasssites && !$allowpersonalsites) {
  570. if ($info['slot_type'] != 'personal' && $info['slot_type'] == 'class')
  571. $sites[$name] =& $info;
  572. } else if (!$allowclasssites && $allowpersonalsites) {
  573. if ($info['slot_type'] == 'personal')
  574. $sites[$name] =& $info;
  575. } else
  576. $sites[$name] =& $info;
  577. }
  578. }
  579. }
  580. if (count($sites)) {
  581. foreach (array_keys($sites) as $name)
  582. printSiteLine2($sites[$name]);
  583. }
  584. unset($sites);
  585. }
  586. }
  587. }
  588. /*********************************************************
  589. * Other sites where user is owner (student, staff or faculty
  590. *********************************************************/
  591. if ($allowclasssites) {
  592. if ($_SESSION["expand_othersites"] == 0) {
  593. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_othersites=true'>+</a> Your Other Sites".helplink("othersites","?")."</td>\n\t\t</tr>");
  594. } else {
  595. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_othersites=false'>-</a> Your Other Sites".helplink("othersites","?")."</td>\n\t\t</tr>");
  596. }
  597. if ($_SESSION["expand_othersites"] != 0) {
  598. $sites=array();
  599. if (is_array($userOwnedSlots)) {
  600. foreach (array_keys($userOwnedSlots) as $name) {
  601. $info =& $userOwnedSlots[$name];
  602. if (!in_array($name, $sitesprinted)) {
  603. if ($info['slot_type'] != 'personal' && $info['slot_type'] != 'class') {
  604. $sites[$name] =& $info;
  605. }
  606. }
  607. }
  608. }
  609. if (count($sites)) {
  610. foreach (array_keys($sites) as $name)
  611. printSiteLine2($sites[$name]);
  612. }
  613. unset($sites);
  614. }
  615. }
  616. /******************************************************************************
  617. * sites where the user is an Editor
  618. ******************************************************************************/
  619. if ($_SESSION["expand_editorsites"] == 0) {
  620. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_editorsites=true'>+</a> Sites you can edit".helplink("othersites","?")."</td>\n\t\t</tr>");
  621. } else {
  622. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'><a href='$PHP_SELF?expand_editorsites=false'>-</a> Sites you can edit".helplink("othersites","?")."</td>\n\t\t</tr>");
  623. }
  624. if ($_SESSION["expand_editorsites"]) {
  625. $sites = array();
  626. if (is_array($anyLevelEditorSites)) {
  627. foreach (array_keys($anyLevelEditorSites) as $name) {
  628. $info =& $anyLevelEditorSites[$name];
  629. if (!in_array($name, $sitesprinted)
  630. && ($info['hasPermissionDownA']
  631. || $info['hasPermissionDownE']
  632. || $info['hasPermissionDownD'])
  633. && $_SESSION['auser'] != $info['slot_owner'])
  634. {
  635. if ($allowclasssites && !$allowpersonalsites) {
  636. if($info['slot_type'] != 'personal')
  637. $sites[$name] =& $info;
  638. } else if (!$allowclasssites && $allowpersonalsites) {
  639. if ($info['slot_type'] == 'personal')
  640. $sites[$name] =& $info;
  641. } else
  642. $sites[$name] =& $info;
  643. }
  644. }
  645. }
  646. if (count($sites)) {
  647. // printc("\n\t\t<tr>\n\t\t\t<td class='inlineth' colspan='2'>Sites to which you have editor permissions</td>\n\t\t</tr>");
  648. foreach (array_keys($sites) as $name)
  649. printSiteLine2($sites[$name]);
  650. }
  651. unset($sites);
  652. }
  653. /******************************************************************************
  654. * copy site bar
  655. ******************************************************************************/
  656. printc("\n\t\t<tr>\n\t\t\t<td class='inlineth'>\n\t\t\t\t<form action='$PHP_SELF?$sid' method='post' name='copyform'>\n\t\t\t\t\t<table width='100%'>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t<td>");
  657. // ******************************* THESE TWO
  658. // $allExistingSitesSlots = allSitesSlots($_SESSION[auser]);
  659. // = array_unique($allExistingSitesSlots[0]);
  660. // $allExistingSlots = array_unique($allExistingSitesSlots[1]);
  661. // ******************************* THESE TWO
  662. $allExistingSlots = array();
  663. $allExistingSites = array();
  664. //printpre($userOwnedSlots);
  665. if (is_array($userOwnedSlots)) {
  666. foreach (array_keys($userOwnedSlots) as $name) {
  667. $info =& $userOwnedSlots[$name];
  668. if ($info['site_exists'])
  669. $allExistingSites[] = $name;
  670. else
  671. $allExistingSlots[] = $name;
  672. }
  673. }
  674. if (is_array($siteLevelEditorSites)) {
  675. foreach (array_keys($siteLevelEditorSites) as $name) {
  676. $info =& $siteLevelEditorSites[$name];
  677. $allExistingSites[] = $name;
  678. }
  679. }
  680. foreach (array_merge($usersCurrentClasses, $usersFutureClasses) as $name) {
  681. $info =& $usersAllClassesInfo[$name];
  682. if (!$info['site_exits']
  683. && (!$info['slot_owner'] || $info['slot_owner'] == $_SESSION['auser'])
  684. && ($_SESSION['atype'] == 'prof' || $_SESSION['atype'] == 'admin'))
  685. {
  686. $allExistingSlots[] = $name;
  687. }
  688. }
  689. $allExistingSites = array_unique($allExistingSites);
  690. natcasesort($allExistingSites);
  691. $allExistingSlots = array_unique($allExistingSlots);
  692. natcasesort($allExistingSlots);
  693. if (count($allExistingSites) && count($allExistingSlots)) {
  694. printc("Copy Site: ");
  695. printc("\n\t\t\t\t\t\t\t\t<select name='origname'>");
  696. printc("\n\t\t\t\t\t\t\t\t\t<option value=''>-choose-</option>");
  697. printOptions($allExistingSites);
  698. printc("\n\t\t\t\t\t\t\t\t</select>");
  699. printc(" to ");
  700. printc("\n\t\t\t\t\t\t\t\t<select name='newname'>");
  701. printc("\n\t\t\t\t\t\t\t\t\t<option value=''>-choose-</option>");
  702. printOptions($allExistingSlots);
  703. printc("\n\t\t\t\t\t\t\t\t</select>");
  704. /* printc(" Clear Permissions: <input type='checkbox' name='clearpermissions' value='1' checked='checked'/>"); */
  705. printc("\n\t\t\t\t\t\t\t\t Copy discussion posts: <input type='checkbox' name='copy_discussions' value='1' checked='checked'/>");
  706. printc("\n\t\t\t\t\t\t\t\t <input type='submit' name='copysite' value='Copy' class='button' />");
  707. }
  708. printc("\n\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t<td align='right'>");
  709. if ($_SESSION[amethod] =='db' || $_SESSION[lmethod]=='db') printc("<a href='passwd.php?$sid&amp;action=change' target='password' onclick='doWindow(\"password\",400,300)'>change password</a>");
  710. printc("</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</table>\n\t\t\t\t</form>\n\t\t\t</td>\n\t\t</tr>");
  711. printc("\n\t</table>");
  712. printc("\n</form>");
  713. } else {
  714. //add_link(leftnav,"Home","index.php?$sid","","");
  715. //add_link(leftnav,"Personal Site List<br />","index.php?$sid&amp;action=list","","");
  716. add_link(leftnav,"Links");
  717. foreach ($defaultlinks as $t=>$u)
  718. add_link(leftnav,$t,"http://".$u,'','',"_blank");
  719. // add_link(leftnav,$t." <img src='globe.gif' border='0' align='absmiddle' height='15' width='15' />",$u,'','',"_blank");
  720. printc("\n\t<div class='title'>$defaulttitle</div>");
  721. printc("\n\t<div class='leftmargin'>");
  722. printc($defaultmessage);
  723. printc("\n\t</div>");
  724. // if this is the first time they have run Segue, we need to do some first-time
  725. // configuration
  726. if (!user::numDBUsers()) {
  727. require("_first_time_run.inc.php");
  728. }
  729. }
  730. /******************************************************************************
  731. * functions
  732. ******************************************************************************/
  733. function printOptions($siteArray) {
  734. foreach ($siteArray as $n=>$site) {
  735. printc("\n<option value='$site'>$site</option>");
  736. }
  737. }
  738. /**
  739. * Build an array of all of the sites and slots that the user
  740. * is either the owner of or an editor (has permission add, edit, and delete) of
  741. */
  742. function allSitesSlots ($user) {
  743. global $classes, $usersFutureClasses;
  744. $allsites = array();
  745. // The user's personal site
  746. if ($user == slot::getOwner($user) || !slot::exists($user)) {
  747. $allsites[$user] = array();
  748. $allsites[$user]['slot_name'] = $user;
  749. $allsites[$user]['slot_type'] = 'personal';
  750. $allsites[$user]['owner_uname'] = $user;
  751. $allsites[$user]['site_exits'] = false;
  752. }
  753. // Add slots that the user is an owner of.
  754. // This will include all of the created sites as well
  755. $allsites = array_merge($allsites, $slots);
  756. // Add the sites that the user is a Site-Level Editor for.
  757. $allsites = array_merge($allsites, segue::getSiteInfoWhereUserIsSiteLevelEditor($user));
  758. $sitesEditorOf = segue::getSiteInfoWhereUserIsSiteLevelEditor($user);
  759. $usersAllClasses = array();
  760. if ($_SESSION[atype] == 'prof') {
  761. foreach ($classes as $n => $v) $usersAllClasses[] = $n;
  762. foreach ($usersFutureClasses as $n => $v) $usersAllClasses[] = $n;
  763. }
  764. printpre($allsites);
  765. printpre($usersAllClasses);
  766. printpre($sitesEditorOf);
  767. printpre($sitesOwnerOf);
  768. printpre($slots);
  769. $allsites = array_unique(array_merge($allsites,$usersAllClasses,$sitesOwnerOf,$sitesEditorOf,$slots));
  770. $allGroups = group::getGroupsOwnedBy($user);
  771. $sitesInGroups = array();
  772. foreach ($allGroups as $n=>$g) {
  773. $sitesInGroups = array_unique(array_merge($sitesInGroups,group::getClassesFromName($g)));
  774. }
  775. foreach ($allsites as $n=>$site) {
  776. if (!in_array($site,$sitesInGroups)) $allsites2[] = $site;
  777. }
  778. $allsites = array_merge($allsites2,$allGroups);
  779. asort($allsites);
  780. /* print "<pre>"; print_r($usersAllClasses); print "</pre>"; */
  781. $sites = array();
  782. $slots = array();
  783. foreach ($allsites as $n=>$site) {
  784. $siteObj =& new site($site);
  785. $exists = $siteObj->fetchFromDB();
  786. if ($exists)
  787. $sites[] = $site;
  788. else
  789. $slots[] = $site;
  790. }
  791. return array($sites, $slots);
  792. }
  793. // remove already printed sites from array of site objects
  794. function &removePrinted(&$sites) {
  795. global $sitesprinted;
  796. $s = array();
  797. foreach (array_keys($sites) as $i => $key) {
  798. $site =& $sites[$key];
  799. $site_name = $site->name;
  800. if (!in_array($site_name,$sitesprinted)) $s[] =& $site;
  801. }
  802. return $s;
  803. }
  804. // prints one site
  805. function printSiteLine2($siteInfo, $ed=0, $isclass=0, $atype='stud') {
  806. // The $ed parameter is a bunch of crap and makes assumptions about
  807. // editor permissions that don't exist, such as profs of a class
  808. // always being the owner. It should have no effect in this function.
  809. global $color,$possible_themes;
  810. global $sitesprinted;
  811. global $_full_uri;
  812. global $cfg;
  813. $name = $siteInfo['slot_name'];
  814. // printpre($siteInfo);
  815. if (in_array($name,$sitesprinted)) return;
  816. $sitesprinted[]=$name;
  817. $exists = $siteInfo['site_exists'];
  818. // printpre("exists:".$exists);
  819. $namelink = ($exists)?"$PHP_SELF?$sid&amp;action=site&amp;site=$name":"$PHP_SELF?$sid&amp;action=add_site&amp;sitename=$name";
  820. $namelink2 = ($exists)?"$PHP_SELF?$sid&amp;action=viewsite&amp;site=$name":"$PHP_SELF?$sid&amp;action=add_site&amp;sitename=$name";
  821. printc("\n\t\t<tr>");
  822. printc("\n\t\t\t<td class='td$color' colspan='2'>");
  823. $status = ($exists)?"Created":"Not Created";
  824. if ($exists) {
  825. if ($siteInfo['site_active'])
  826. $active = "<span class='green'>active</span>";
  827. else
  828. $active = "<span class='red'>(inactive)</span>";
  829. }
  830. printc("\n\t\t\t\t<table width='100%' cellpadding='0' cellspacing='0'>\n\t\t\t\t\t<tr>\n\t\t\t\t\t\t<td align='left'>");
  831. if ($isclass
  832. && $_SESSION[atype] == 'prof' && ((!$exists
  833. && (!$siteInfo['slot_owner']
  834. || $_SESSION[auser] == $siteInfo['slot_owner']))
  835. || ($exists && $_SESSION[auser] == $siteInfo['slot_owner'])))
  836. {
  837. // if:
  838. // isclass - is a class
  839. // if it doesn't exist, either there is no owner or we are the owner.
  840. // if it exists, the user the owner
  841. printc("\n\t\t\t\t\t\t\t<input type='checkbox' name='group[]' value='$name' />");
  842. }
  843. printc("$name - ");
  844. if ($exists) {
  845. printc("\n\t\t\t\t\t\t\t<span style ='font-size:14px;'><a href='$namelink'>".$siteInfo['site_title']."</a></span>");
  846. } else if (!$siteInfo['slot_owner'] || $_SESSION[auser] == $siteInfo['slot_owner']) {
  847. // if the slot doesn't have an owner or we are the owner.
  848. if ($_SESSION[atype] == 'prof' && $isclass) {
  849. //if ($isclass) {
  850. printc("\n\t\t\t\t\t\t\t<span style ='font-size:10px;'>");
  851. if ($cfg['disable_new_sites'] == TRUE && $_SESSION['ltype'] != 'admin') {
  852. printc("Create: Site (disabled)");
  853. } else {
  854. printc("Create: <a href='$namelink'>Site</a> ");
  855. }
  856. printc("</span>");
  857. } else {
  858. if ($cfg['disable_new_sites'] == TRUE && $_SESSION['ltype'] != 'admin') {
  859. printc("Create Site (disabled)");
  860. } else {
  861. printc("\n\t\t\t\t\t\t\t<span style ='font-size:10px;'><a href='$namelink'>Create Sites</a></span>");
  862. }
  863. }
  864. } else {
  865. // if the slot does have an owner that isn't us
  866. printc("\n\t\t\t\t\t\t\t<span style ='font-size:10px;'>This site is owned by user \"".$siteInfo['slot_owner']."\". Contact your system administrator if you feel you should own this site.</span>");
  867. }
  868. printc("\n\t\t\t\t\t\t</td>\n\t\t\t\t\t\t<td align='right'>");
  869. printc((($active)?"\n\t\t\t\t\t\t\t[$active]":""));
  870. printc("\n\t\t\t\t\t\t</td>\n\t\t\t\t\t</tr>\n\t\t\t\t</table>");
  871. //printc("<div style='padding-left: 20px;'>");
  872. // Class Group printing
  873. if ($siteInfo['is_classgroup']) {
  874. $classlist = group::getClassesFromName($name);
  875. $list = implode(", ",$classlist);
  876. printc("\n\t\t\t\t<div style='padding-left: 20px; font-size: 10px;'>this is a group and contains the following classes: <b>$list</b><br />\n\t\t\t\t</div>");
  877. $sitesprinted = array_merge($sitesprinted,$classlist);
  878. }
  879. if ($exists) {
  880. $addedby = $siteInfo['site_addedby'];
  881. /* $viewpermissions=$a[viewpermissions]; */
  882. $added = timestamp2usdate($siteInfo['site_added_timestamp']);
  883. $edited = $siteInfo['site_edited_timestamp'];
  884. $editedby = $siteInfo['site_editedby'];
  885. printc("\n\t\t\t\t<div style='padding-left: 20px; font-size: 10px;'>added by $addedby on $added".(($editedby)?", edited on ".timestamp2usdate($edited):"")."<br />\n\t\t\t\t</div>");
  886. if (!ereg("^0000", $siteInfo['activatedate']) || !ereg("^0000", $siteInfo['deactivatedate'])) {
  887. printc("\n\t\t\t\t<div style='padding-left: 20px; font-size: 10px;'>available: ");
  888. printc(txtdaterange($siteInfo['activatedate'], $siteInfo['deactivatedate']));
  889. printc("\n\t\t\t\t</div>");
  890. }
  891. printc("\n\t\t\t\t<div align='left'>");
  892. $addr = "$_full_uri/sites/$name";
  893. printc("\n\t\t\t\t\t<div style='padding-left: 20px; font-size: 12px;'>\n\t\t\t\t\t\tURL: <a href='$addr' target='_blank'>$addr</a><br />\n\t\t\t\t\t</div>\n\t\t\t\t</div>");
  894. printc("\n\t\t\t\t<div align='right'>");
  895. if ($_SESSION[auser] == $siteInfo['slot_owner']
  896. || $siteInfo['hasPermissionDownA']
  897. || $siteInfo['hasPermissionDownE']
  898. || $siteInfo['hasPermissionDownD'])
  899. {
  900. // if the user is an editor or the owner
  901. printc("\n\t\t\t\t\t <a href='$PHP_SELF?$sid&amp;action=viewsite&amp;site=$name'>edit</a> | ");
  902. }
  903. if ($_SESSION[auser] == $siteInfo['slot_owner']
  904. || ($siteInfo['hasSitePermissionA']
  905. && $siteInfo['hasSitePermissionE']
  906. && $siteInfo['hasSitePermissionD']))
  907. {
  908. // if the user is the owner or a site-level editor...
  909. printc("\n\t\t\t\t\t <a href='$PHP_SELF?$sid&amp;action=edit_site&amp;sitename=$name'>settings</a> | ");
  910. }
  911. if ($_SESSION[auser] == $siteInfo['slot_owner']) {
  912. // if the user is the owner, not an editor
  913. printc("\n\t\t\t\t\t <a href='$PHP_SELF?$sid&amp;action=delete_site&amp;name=$name'>delete</a> | ");
  914. printc("\n\t\t\t\t\t <a href='edit_permissions.php?$sid&amp;site=$name' onclick='doWindow(\"permissions\",600,400)' target='permissions'>permissions</a>");
  915. } else if (($siteInfo['hasPermissionDownA']
  916. || $siteInfo['hasPermissionDownE']
  917. || $siteInfo['hasPermissionDownD'])
  918. && $_SESSION[auser] != $siteInfo['slot_owner']) {
  919. // if the user is an editor
  920. printc("\n\t\t\t\t\t <a href='edit_permissions.php?$sid&amp;site=$name' onclick='doWindow(\"permissions\",600,400)' target='permissions'>your permissions</a>");
  921. }
  922. if ($isclass && $_SESSION[atype] == 'prof') {
  923. printc(" |\n\t\t\t\t\t <a href=\"Javascript:sendWindow('addstudents',500,400,'add_students.php?$sid&amp;name=".$name."')\">students</a> \n");
  924. }
  925. printc("\n\t\t\t\t</div>");
  926. }
  927. printc("\n\t\t\t</td>\n\t\t</tr>");
  928. // check for an associated site slot and whether an associated site has been created for the current user
  929. $assoc_siteinfo = associatedSiteCreated($_SESSION[auser], $name);
  930. $assoc_site_title = $assoc_siteinfo['site_title'];
  931. if ($assoc_site_title != "") {
  932. printSiteLine2($assoc_siteinfo, 0, 0);
  933. $studentSitesColor = 1-$studentSitesColor;
  934. } else if (associatedSiteExists($_SESSION[auser], $className) == "true") {
  935. $studentSitesColor = 1-$studentSitesColor;
  936. printc("\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td class='td$studentSitesColor' width='150'>".$siteInfo['slot_name']."-".$_SESSION[auser]."</td>");
  937. if ($cfg['disable_new_sites'] == TRUE && $_SESSION['ltype'] != 'admin') {
  938. printc("Create: Site (disabled)");
  939. } else {
  940. printc("\n\t\t\t\t\t<td align='left' class='td$studentSitesColor'>Create: <a href='$PHP_SELF?$sid&amp;action=add_site&amp;sitename=".$siteInfo['slot_name']."-".$_SESSION[auser]."'> Site</a></td>");
  941. }
  942. }
  943. $color=1-$color;
  944. }
  945. function printStudentSiteLine($className, $siteInfo) {
  946. global $studentSitesColor;
  947. if (!isset($studentSitesColor))
  948. $studentSitesColor=0;
  949. printc("\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='td$studentSitesColor' width='150'>$className</td>");
  950. if ($siteInfo['site_exists']) {
  951. if ($siteInfo['site_active']) {
  952. printc("\n\t\t\t\t\t<td align='left' class='td$studentSitesColor'><a href='$PHP_SELF?$sid&amp;action=site&amp;site=".$siteInfo['slot_name']."'>".$siteInfo['site_title']."</a></td>");
  953. } else {
  954. printc("\n\t\t\t\t\t<td style='color: #999' class='td$studentSitesColor'>created, not yet available</td>");
  955. }
  956. // check for an associated site slot and whether an associated site has been created for the current user
  957. $assoc_siteinfo = associatedSiteCreated($_SESSION[auser], $className);
  958. $assoc_site_title = $assoc_siteinfo['site_title'];
  959. if ($assoc_site_title != "") {
  960. printSiteLine2($assoc_siteinfo, 0, 1);
  961. $studentSitesColor = 1-$studentSitesColor;
  962. } else if (associatedSiteExists($_SESSION[auser], $className) == "true") {
  963. $studentSitesColor = 1-$studentSitesColor;
  964. printc("\n\t\t\t\t</tr><tr>\n\t\t\t\t\t<td class='td$studentSitesColor' width='150'>".$siteInfo['slot_name']."-".$_SESSION[auser]."</td>");
  965. if ($cfg['disable_new_sites'] == TRUE && $_SESSION['ltype'] != 'admin') {
  966. printc("Create: Site (disabled)");
  967. } else {
  968. printc("\n\t\t\t\t\t<td align='left' class='td$studentSitesColor'>Create: <a href='$PHP_SELF?$sid&amp;action=add_site&amp;sitename=".$siteInfo['slot_name']."-".$_SESSION[auser]."'> Site</a></td>");
  969. }
  970. }
  971. //check webcourses databases to see if course website was created in course folders (instead of Segue)
  972. } else if ($course_site = coursefoldersite($className)) {
  973. $course_url = urldecode($course_site['url']);
  974. $title = urldecode($course_site['title']);
  975. printc("\n\t\t\t\t\t<td style='color: #999' class='td$studentSitesColor'><a href='$course_url' target='new_window'>$title</td>");
  976. } else
  977. printc("\n\t\t\t\t\t<td style='color: #999' class='td$studentSitesColor'>not created</td>");
  978. printc("\n\t\t\t\t</tr>");
  979. $studentSitesColor = 1-$studentSitesColor;
  980. }
  981. //$sitefooter .= "\n<div align='right' style='color: #999; font-size: 10px;'>by <a style='font-weight: normal; text-decoration: underline' href='mailto: gschineATmiddleburyDOTedu'>Gabriel Schine</a>, <a href='mailto:achapinATmiddleburyDOTedu' style='font-weight: normal; text-decoration: underline'>Alex Chapin</a>, <a href='mailto:afrancoATmiddleburyDOTedu' style='font-weight: normal; text-decoration: underline'>Adam Franco</a> and <a href='mailto:dradichkATmiddleburyDOTedu' style='font-weight: normal…

Large files files are truncated, but you can click here to view the full file