changed git call from https to git readonly
[atutor.git] / mods / calendar / sync_cal.php
1 <?php\r
2 /*\r
3 This is the ATutor webcalendar module page. It allows an instructor to synchronize\r
4 the ATutor and WebCalendar databases.\r
5 */\r
6 define('AT_INCLUDE_PATH', '../../include/');\r
7 require (AT_INCLUDE_PATH.'vitals.inc.php');\r
8 \r
9 if($_REQUEST['webcalendar_sync'] == 1){\r
10         //populate the webcal_user table with ATutor members\r
11         $sql = "SELECT * from ".TABLE_PREFIX."members";\r
12         $result = mysql_query($sql,$db);\r
13         if(!$result3 = mysql_query($sql)){\r
14                 $msg->addError('WEBCALENDAR_UPDATE_MEMBERS_FAILED');\r
15         }else{\r
16                 $msg->addFeedback('WEBCALENDAR_UPDATE_MEMBERS_SAVED');\r
17         }\r
18         while ($row = mysql_fetch_array($result)){\r
19                 $sql2  = "REPLACE INTO webcal_user VALUES ('$row[1]','".md5($row[2])."','$row[6]','$row[5]','N','$row[3]')";\r
20                 $result1 = mysql_query($sql2, $db);\r
21         }\r
22 \r
23         //populate the webcal_group table with ATutor courses\r
24         $sql5 = "SELECT * FROM ".TABLE_PREFIX."courses";\r
25         $result5 = mysql_query($sql5,$db);\r
26         while ($row = mysql_fetch_array($result5)){\r
27                 $sql2  = "REPLACE INTO webcal_group VALUES ('$row[0]','".$row[1]."','$row[6]','$row[5]')";\r
28                 $result1 = mysql_query($sql2, $db);\r
29         }\r
30         if(!$result1 = mysql_query($sql)){\r
31                 $msg->addError('WEBCALENDAR_UPDATE_GROUPS_FAILED');\r
32         }else{\r
33                 $msg->addFeedback('WEBCALENDAR_UPDATE_GROUPS_SAVED');\r
34         }\r
35 \r
36         //populate webcal_group_users users enrolled courses (i.e. groups) \r
37 \r
38         $sql6 = "SELECT * FROM ".TABLE_PREFIX."course_enrollment WHERE approved='y'";\r
39         $result6 = mysql_query($sql6,$db);\r
40         while ($row = mysql_fetch_array($result6)){\r
41 \r
42                 $sql8 = "SELECT login FROM ".TABLE_PREFIX."members WHERE member_id='$row[0]'";\r
43                 $result8 = mysql_query($sql8,$db);\r
44                 while($row1 = mysql_fetch_array($result8)){\r
45                         $at_login_name = $row1[0];\r
46                 }\r
47                 $sql2  = "REPLACE INTO webcal_group_user VALUES ('$row[1]','$at_login_name')";\r
48                 if(!$result7 = mysql_query($sql2)){\r
49                         $msg->addError('WEBCALENDAR_UPDATE_GROUPMEMS_FAILED');\r
50                 }else{\r
51                         $msg->addFeedback('WEBCALENDAR_UPDATE_GROUPMEMS_SAVED');\r
52                 }\r
53         }\r
54 \r
55 \r
56 }\r
57 \r
58 require (AT_INCLUDE_PATH.'header.inc.php');\r
59 \r
60 ?>\r
61                 <div class="input-form">\r
62                 <div class="row">\r
63                         <p><?php echo _AT('webcalendar_sync'); ?></p>\r
64                         <p>     <strong><?php echo $webcalendar_sync; ?> </strong>                                                                      </p>\r
65                         <div class="row buttons">\r
66                         <form action="<?php  $_SERVER['PHP_SELF']; ?>" method="post">\r
67                         <input type="hidden" name="webcalendar_sync" value="1">\r
68                         <input type="submit" value="<?php echo _AT('webcalendar_sync_button'); ?>" style="botton">\r
69                         </form>\r
70                         </div>\r
71                 </div>\r
72                 </div>\r
73                 \r
74 <?php \r
75 \r
76  require (AT_INCLUDE_PATH.'footer.inc.php'); ?>