//Get student log data
 try {
     $dataLog = array("gibbonPersonID" => $rowRollGroup["gibbonPersonID"], "date" => $currentDate . "%");
     $sqlLog = "SELECT * FROM gibbonAttendanceLogPerson, gibbonPerson WHERE gibbonAttendanceLogPerson.gibbonPersonID=gibbonPerson.gibbonPersonID AND gibbonAttendanceLogPerson.gibbonPersonID=:gibbonPersonID AND date LIKE :date ORDER BY timestampTaken DESC";
     $resultLog = $connection2->prepare($sqlLog);
     $resultLog->execute($dataLog);
 } catch (PDOException $e) {
     print "<div class='error'>" . $e->getMessage() . "</div>";
 }
 $rowLog = $resultLog->fetch();
 if ($rowLog["type"] == "Absent") {
     print "<td style='border: 1px solid #CC0000!important; background: none; background-color: #F6CECB; width:20%; text-align: center; vertical-align: top'>";
 } else {
     print "<td style='border: 1px solid #ffffff; width:20%; text-align: center; vertical-align: top'>";
 }
 print getUserPhoto($guid, $rowRollGroup["image_75"], 75);
 print "<div style='padding-top: 5px'><b>" . formatName("", htmlPrep($rowRollGroup["preferredName"]), htmlPrep($rowRollGroup["surname"]), "Student", true) . "<b></div><br/>";
 print "<input type='hidden' name='{$count}-gibbonPersonID' value='" . $rowRollGroup["gibbonPersonID"] . "'>";
 print "<select style='float: none; width:130px; margin-bottom: 3px' name='{$count}-type'>";
 print "<option ";
 if ($rowLog["type"] == "Present") {
     print "selected ";
 }
 print "value='Present'>" . _('Present') . "</option>";
 print "<option ";
 if ($rowLog["type"] == "Present - Late") {
     print "selected ";
 }
 print "value='Present - Late'>" . _('Present - Late') . "</option>";
 print "<option ";
 if ($rowLog["type"] == "Present - Offsite") {
Exemple #2
0
</nav>
</div>

<main>
<div class="section">

<?php 
$accessToken = $_COOKIE['accessToken'];
$param['page'] = isset($_GET['page']) ? $_GET['page'] : 1;
$param['num'] = getPagingNumByRequestName('user/getNoticeList');
$noticeInfo = FCurl::get('user/getNoticeList', $param + array('accessToken' => $accessToken));
foreach ($noticeInfo as $value) {
    // print_r($value);
    echo '<div class="row">
              <div class="col s2">';
    echo getUserPhoto($value['createUserPhoto']);
    echo '</div>
              <div class="col s10">
                <h5><a class="blue-text text-darken-4" href="#">' . $value['createUser'] . '</a></h5>
                <div class="flow-text">' . eventTranslate($value['noticeContent']);
    foreach ($value['noticeUser'] as $noticeUserIndex) {
        echo attranslate($noticeUserIndex);
    }
    echo getEventPhoto($value['photo']);
    $userId = $value['createUserId'];
    if ($value['enable_open']) {
        if ($value['eventType'] == 'group') {
            echo '</div><div class="row grey lighten-3" onclick="window.location=' . "'" . "group_info.php?from=quan&id=" . $userId . "'" . '" >
	                  <div class="col s2"><i class="small grey-text text-darken-2 mdi-action-account-box prefix"></i></div>';
        } else {
            echo '</div><div class="row grey lighten-3" onclick="window.location=' . "'" . "contact_info.php?from=quan&id=" . $userId . "'" . '" >
            ?>
/rollGroups_details.php">
							<input type="hidden" name="gibbonRollGroupID" value="<?php 
            print $gibbonRollGroupID;
            ?>
">
							<input type="hidden" name="address" value="<?php 
            print $_SESSION[$guid]["address"];
            ?>
">
							<?php 
            print "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/" . $_SESSION[$guid]["module"] . "/rollGroups_details.php&gibbonRollGroupID={$gibbonRollGroupID}'>" . _('Clear Filters') . "</a>";
            ?>
							<input type="submit" value="<?php 
            print _("Submit");
            ?>
">
						</td>
					</tr>
				</table>
			</form>
			<?php 
            print "<h3>";
            print _("Students");
            print "</h3>";
            printRollGroupTable($guid, $gibbonRollGroupID, 5, $connection2, FALSE, $orderBy);
            //Set sidebar
            $_SESSION[$guid]["sidebarExtra"] = getUserPhoto($guid, $primaryTutor240, 240);
        }
    }
}
Exemple #4
0
 print _("Date");
 print "</th>";
 print "</tr>";
 $count = 0;
 $rowNum = "odd";
 while ($row = $resultLike->fetch()) {
     if ($count % 2 == 0) {
         $rowNum = "even";
     } else {
         $rowNum = "odd";
     }
     $count++;
     //COLOR ROW BY STATUS!
     print "<tr class={$rowNum}>";
     print "<td>";
     print getUserPhoto($guid, $row["image_240"], 75);
     print "</td>";
     print "<td>";
     $roleCategory = getRoleCategory($row["gibbonRoleIDPrimary"], $connection2);
     if ($roleCategory == "Student" and isActionAccessible($guid, $connection2, "/modules/Students/student_view_details.php")) {
         print "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/Students/student_view_details.php&gibbonPersonID=" . $row["gibbonPersonID"] . "'>" . formatName("", $row["preferredName"], $row["surname"], $roleCategory, false) . "</a><br/>";
         print "<span style='font-size: 85%; font-style: italic'>" . _($roleCategory) . "</i>";
     } else {
         print formatName("", $row["preferredName"], $row["surname"], $roleCategory, false) . "<br/>";
         print "<span style='font-size: 85%; font-style: italic'>" . _($roleCategory) . "</i>";
     }
     print "</td>";
     print "<td>";
     print _($row["title"]) . "<br/>";
     print "<span style='font-size: 85%; font-style: italic'>" . $row["comment"] . "</span>";
     print "</td>";
 print _("Actions");
 print "</th>";
 print "</tr>";
 $count = 0;
 $rowNum = "odd";
 foreach ($children as $child) {
     if ($count % 2 == 0) {
         $rowNum = "even";
     } else {
         $rowNum = "odd";
     }
     $count++;
     //COLOR ROW BY STATUS!
     print "<tr class={$rowNum}>";
     print "<td>";
     print getUserPhoto($guid, $child["image_240"], 75);
     print "</td>";
     print "<td>";
     print "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/User Admin/user_manage_edit.php&gibbonPersonID=" . $child["gibbonPersonID"] . "'>" . formatName("", $child["preferredName"], $child["surname"], "Student") . "</a>";
     print "</td>";
     print "<td>";
     print $child["status"];
     print "</td>";
     print "<td>";
     try {
         $dataDetail = array("gibbonPersonID" => $child["gibbonPersonID"], "gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"]);
         $sqlDetail = "SELECT * FROM gibbonRollGroup JOIN gibbonStudentEnrolment ON (gibbonStudentEnrolment.gibbonRollGroupID=gibbonRollGroup.gibbonRollGroupID) WHERE gibbonPersonID=:gibbonPersonID AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID";
         $resultDetail = $connection2->prepare($sqlDetail);
         $resultDetail->execute($dataDetail);
     } catch (PDOException $e) {
         print "<div class='error'>" . $e->getMessage() . "</div>";
             }
         }
     }
 }
 //Set sidebar
 $_SESSION[$guid]["sidebarExtra"] = "";
 //Show alerts
 $alert = getAlertBar($guid, $connection2, $gibbonPersonID, $row["privacy"], "", FALSE, TRUE);
 $_SESSION[$guid]["sidebarExtra"] .= "<div style='background-color: none; font-size: 12px; margin: 3px 0 0px 0; width: 240px; text-align: left; height: 40px; padding: 5px 10px;'>";
 if ($alert == "") {
     $_SESSION[$guid]["sidebarExtra"] .= "<b>" . _('No Current Alerts') . "</b>";
 } else {
     $_SESSION[$guid]["sidebarExtra"] .= $alert;
 }
 $_SESSION[$guid]["sidebarExtra"] .= "</div>";
 $_SESSION[$guid]["sidebarExtra"] .= getUserPhoto($guid, $row["image_240"], 240);
 //PERSONAL DATA MENU ITEMS
 $_SESSION[$guid]["sidebarExtra"] .= "<h4>" . _('Personal') . "</h4>";
 $_SESSION[$guid]["sidebarExtra"] .= "<ul class='moduleMenu'>";
 $style = "";
 if ($subpage == "Overview") {
     $style = "style='font-weight: bold'";
 }
 $_SESSION[$guid]["sidebarExtra"] .= "<li><a {$style} href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=" . $_GET["q"] . "&gibbonPersonID={$gibbonPersonID}&search=" . $search . "&search={$search}&allStudents={$allStudents}&subpage=Overview'>" . _('Overview') . "</a></li>";
 $style = "";
 if ($subpage == "Personal") {
     $style = "style='font-weight: bold'";
 }
 $_SESSION[$guid]["sidebarExtra"] .= "<li><a {$style} href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=" . $_GET["q"] . "&gibbonPersonID={$gibbonPersonID}&search=" . $search . "&search={$search}&allStudents={$allStudents}&subpage=Personal'>" . _('Personal') . "</a></li>";
 $style = "";
 if ($subpage == "Family") {
Exemple #7
0
  <table class="hoverable">
    <thead>
      <tr>
          <th data-field="photo">头像</th>
          <th data-field="name">姓名</th>
          <th data-field="tel">电话</th>
      </tr>
    </thead>

    <tbody>
      <?php 
foreach ($contactLsit as $value) {
    ?>
      <tr>
        <td><?php 
    echo getUserPhoto($value['photo']);
    ?>
</td>
        <td><?php 
    echo $value['nickname'];
    ?>
</td>
        <td>
      <?php 
    $value['phoneNum'] = explode(',', $value['phoneNum']);
    foreach ($value['phoneNum'] as $phoneIndex) {
        ?>
      <a href="tel://<?php 
        echo trim($phoneIndex);
        ?>
"><?php 
Exemple #8
0
function printClassGroupTable($guid, $gibbonCourseClassID, $columns, $connection2)
{
    try {
        $dataClassGroup = array("gibbonCourseClassID" => $gibbonCourseClassID);
        $sqlClassGroup = "SELECT * FROM gibbonCourseClassPerson INNER JOIN gibbonPerson ON gibbonCourseClassPerson.gibbonPersonID=gibbonPerson.gibbonPersonID WHERE gibbonCourseClassID=:gibbonCourseClassID AND status='Full' AND (dateStart IS NULL OR dateStart<='" . date("Y-m-d") . "') AND (dateEnd IS NULL  OR dateEnd>='" . date("Y-m-d") . "') AND (NOT role='Student - Left') AND (NOT role='Teacher - Left') ORDER BY role DESC, surname, preferredName";
        $resultClassGroup = $connection2->prepare($sqlClassGroup);
        $resultClassGroup->execute($dataClassGroup);
    } catch (PDOException $e) {
    }
    print "<table class='noIntBorder' cellspacing='0' style='width:100%'>";
    $count = 0;
    while ($rowClassGroup = $resultClassGroup->fetch()) {
        if ($count % $columns == 0) {
            print "<tr>";
        }
        print "<td style='width:20%; text-align: center; vertical-align: top'>";
        //Alerts, if permission allows
        print getAlertBar($guid, $connection2, $rowClassGroup["gibbonPersonID"], $rowClassGroup["privacy"]);
        //User photo
        print getUserPhoto($guid, $rowClassGroup["image_240"], 75);
        //HEY SHORTY IT'S YOUR BIRTHDAY!
        $daysUntilNextBirthday = daysUntilNextBirthday($rowClassGroup["dob"]);
        if ($daysUntilNextBirthday == 0) {
            print "<img title='" . sprintf(_('%1$s  birthday today!'), $rowClassGroup["preferredName"] . "&#39;s") . "' style='z-index: 99; margin: -20px 0 0 74px; width: 25px; height: 25px' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/gift_pink.png'/>";
        } else {
            if ($daysUntilNextBirthday > 0 and $daysUntilNextBirthday < 8) {
                print "<img title='{$daysUntilNextBirthday} ";
                if ($daysUntilNextBirthday != 1) {
                    print sprintf(_('days until %1$s birthday!'), $rowClassGroup["preferredName"] . "&#39;s");
                } else {
                    print sprintf(_('day until %1$s birthday!'), $rowClassGroup["preferredName"] . "&#39;s");
                }
                print "' style='z-index: 99; margin: -20px 0 0 74px; width: 25px; height: 25px' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/gift.png'/>";
            }
        }
        if ($rowClassGroup["role"] == "Student") {
            print "<div style='padding-top: 5px'><b><a href='index.php?q=/modules/Students/student_view_details.php&gibbonPersonID=" . $rowClassGroup["gibbonPersonID"] . "'>" . formatName("", $rowClassGroup["preferredName"], $rowClassGroup["surname"], "Student") . "</a></b><br/>";
        } else {
            print "<div style='padding-top: 5px'><b>" . formatName($rowClassGroup["title"], $rowClassGroup["preferredName"], $rowClassGroup["surname"], "Staff") . "</b><br/>";
        }
        print "<i>" . $rowClassGroup["role"] . "</i><br/><br/></div>";
        print "</td>";
        if ($count % $columns == $columns - 1) {
            print "</tr>";
        }
        $count++;
    }
    for ($i = 0; $i < $columns - $count % $columns; $i++) {
        print "<td></td>";
    }
    if ($count % $columns != 0) {
        print "</tr>";
    }
    print "</table>";
}
Exemple #9
0
             $students[$count][8] = $rowChild["rollGroupWebsite"];
             $count++;
         }
     }
 }
 if ($count > 0) {
     print "<h2>";
     print _("Parental Dashboard");
     print "</h2>";
     include "./modules/Timetable/moduleFunctions.php";
     for ($i = 0; $i < $count; $i++) {
         print "<h4>";
         print $students[$i][1] . " " . $students[$i][0];
         print "</h4>";
         print "<div style='margin-right: 1%; float:left; width: 15%; text-align: center'>";
         print getUserPhoto($guid, $students[$i][5], 75);
         print "<div style='height: 5px'></div>";
         print "<span style='font-size: 70%'>";
         print "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/Students/student_view_details.php&gibbonPersonID=" . $students[$i][4] . "'>" . _('Student Profile') . "</a><br/>";
         if (isActionAccessible($guid, $connection2, "/modules/Roll Groups/rollGroups_details.php")) {
             print "<a href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/Roll Groups/rollGroups_details.php&gibbonRollGroupID=" . $students[$i][7] . "'>" . _('Roll Group') . " (" . $students[$i][3] . ")</a><br/>";
         }
         if ($students[$i][8] != "") {
             print "<a target='_blank' href='" . $students[$i][8] . "'>" . $students[$i][3] . " " . _('Website') . "</a>";
         }
         print "</span>";
         print "</div>";
         print "<div style='margin-bottom: 30px; margin-left: 1%; float: left; width: 83%'>";
         $dashboardContents = getParentalDashboardContents($connection2, $guid, $students[$i][4]);
         if ($dashboardContents == FALSE) {
             print "<div class='error'>";
 if ($rowEvent["gibbonPersonIDStatusResponsible"] != "") {
     try {
         $dataPerson = array("gibbonPersonID" => $rowEvent["gibbonPersonIDStatusResponsible"]);
         $sqlPerson = "SELECT title, preferredName, surname, image_75 FROM gibbonPerson WHERE gibbonPersonID=:gibbonPersonID";
         $resultPerson = $connection2->prepare($sqlPerson);
         $resultPerson->execute($dataPerson);
     } catch (PDOException $e) {
         print "<div class='error'>" . $e->getMessage() . "</div>";
     }
     if ($resultPerson->rowCount() == 1) {
         $rowPerson = $resultPerson->fetch();
     }
 }
 print "<td>";
 if (is_array($rowPerson)) {
     print getUserPhoto($guid, $rowPerson["image_75"], 75);
 }
 if (is_array($rowPerson)) {
     print "<div style='margin-top: 3px; font-weight: bold'>" . formatName($rowPerson["title"], $rowPerson["preferredName"], $rowPerson["surname"], "Staff", FALSE, TRUE) . "</div>";
 }
 print "</td>";
 print "<td>";
 print $rowEvent["status"] . "<br/>";
 if ($rowEvent["timestampOut"] != "") {
     print "<span style='font-size: 85%; font-style: italic'>" . dateConvertBack($guid, substr($rowEvent["timestampOut"], 0, 10));
     if ($rowEvent["timestampReturn"] != "") {
         print " - " . dateConvertBack($guid, substr($rowEvent["timestampReturn"], 0, 10));
     }
     print "</span>";
 }
 print "</td>";
     $resultClassGroup = $connection2->prepare($sqlClassGroup);
     $resultClassGroup->execute($dataClassGroup);
 } catch (PDOException $e) {
     $_SESSION[$guid]["sidebarExtra"] .= "<div class='error'>" . $e->getMessage() . "</div>";
 }
 if ($resultClassGroup->rowCount() > 0) {
     $_SESSION[$guid]["sidebarExtra"] .= "<span style='font-size: 115%; font-weight: bold; padding-top: 21px'>" . _('Guests') . "<br/></span>";
     $_SESSION[$guid]["sidebarExtra"] .= "<table cellspacing='0' style='width:260px; float: right'>";
     $count2 = 0;
     $count2Students = 0;
     while ($rowClassGroup = $resultClassGroup->fetch()) {
         if ($count2 % $columns == 0) {
             $_SESSION[$guid]["sidebarExtra"] .= "<tr>";
         }
         $_SESSION[$guid]["sidebarExtra"] .= "<td style='border: 1px solid #ffffff; width:20%; text-align: center; vertical-align: top'>";
         $_SESSION[$guid]["sidebarExtra"] .= getUserPhoto($guid, $rowClassGroup["image_75"], 75);
         $_SESSION[$guid]["sidebarExtra"] .= "<div style='padding-top: 5px'><b>" . formatName($rowClassGroup["title"], $rowClassGroup["preferredName"], $rowClassGroup["surname"], "Staff") . "</b><br/>";
         $_SESSION[$guid]["sidebarExtra"] .= "<i>" . $rowClassGroup["role"] . "</i><br/><br/></div>";
         $_SESSION[$guid]["sidebarExtra"] .= "</td>";
         if ($count2 % $columns == $columns - 1) {
             $_SESSION[$guid]["sidebarExtra"] .= "</tr>";
         }
         $count2++;
         if ($rowClassGroup["role"] == "Student") {
             $count2Students++;
         }
     }
     for ($i = 0; $i < $columns - $count2 % $columns; $i++) {
         $_SESSION[$guid]["sidebarExtra"] .= "<td style='width:20%;'></td>";
     }
     if ($count2 % $columns != 0) {
Exemple #12
0
function getMessages($guid, $connection2, $mode = "", $date = "")
{
    $return = "";
    $dataPosts = array();
    if ($date == "") {
        $date = date("Y-m-d");
    }
    if ($mode != "print" and $mode != "count" and $mode != "result") {
        $mode = "print";
    }
    //Work out all role categories this user has, ignoring "Other"
    $roles = $_SESSION[$guid]["gibbonRoleIDAll"];
    $roleCategory = "";
    $staff = FALSE;
    $student = FALSE;
    $parent = FALSE;
    for ($i = 0; $i < count($roles); $i++) {
        $roleCategory = getRoleCategory($roles[$i][0], $connection2);
        if ($roleCategory == "Staff") {
            $staff = TRUE;
        } else {
            if ($roleCategory == "Student") {
                $student = TRUE;
            } else {
                if ($roleCategory == "Parent") {
                    $parent = TRUE;
                }
            }
        }
    }
    //If parent get a list of student IDs
    if ($parent) {
        $children = "(";
        try {
            $data = array("gibbonPersonID" => $_SESSION[$guid]["gibbonPersonID"]);
            $sql = "SELECT * FROM gibbonFamilyAdult WHERE gibbonPersonID=:gibbonPersonID AND childDataAccess='Y'";
            $result = $connection2->prepare($sql);
            $result->execute($data);
        } catch (PDOException $e) {
        }
        while ($row = $result->fetch()) {
            try {
                $dataChild = array("gibbonFamilyID" => $row["gibbonFamilyID"], "gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"]);
                $sqlChild = "SELECT * FROM gibbonFamilyChild JOIN gibbonPerson ON (gibbonFamilyChild.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonStudentEnrolment ON (gibbonPerson.gibbonPersonID=gibbonStudentEnrolment.gibbonPersonID) WHERE gibbonFamilyID=:gibbonFamilyID AND gibbonPerson.status='Full' AND (dateStart IS NULL OR dateStart<='" . date("Y-m-d") . "') AND (dateEnd IS NULL  OR dateEnd>='" . date("Y-m-d") . "') AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID ORDER BY surname, preferredName ";
                $resultChild = $connection2->prepare($sqlChild);
                $resultChild->execute($dataChild);
            } catch (PDOException $e) {
            }
            while ($rowChild = $resultChild->fetch()) {
                $children .= "gibbonPersonID=" . $rowChild["gibbonPersonID"] . " OR ";
            }
        }
        if ($children != "(") {
            $children = substr($children, 0, -4) . ")";
        } else {
            $children = FALSE;
        }
    }
    //My roles
    $roles = $_SESSION[$guid]["gibbonRoleIDAll"];
    $sqlWhere = "(";
    if (count($roles) > 0) {
        for ($i = 0; $i < count($roles); $i++) {
            $dataPosts["role" . $roles[$i][0]] = $roles[$i][0];
            $sqlWhere .= "id=:role" . $roles[$i][0] . " OR ";
        }
        $sqlWhere = substr($sqlWhere, 0, -3) . ")";
    }
    if ($sqlWhere != "(") {
        $dataPosts["date1"] = $date;
        $dataPosts["date2"] = $date;
        $dataPosts["date3"] = $date;
        $sqlPosts = "(SELECT gibbonMessenger.*, title, surname, preferredName, authorRole.category AS category, image_240, concat('Role: ', gibbonRole.name) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole AS authorRole ON (gibbonPerson.gibbonRoleIDPrimary=authorRole.gibbonRoleID) JOIN gibbonRole ON (gibbonMessengerTarget.id=gibbonRole.gibbonRoleID) WHERE gibbonMessengerTarget.type='Role' AND (messageWall_date1=:date1 OR messageWall_date2=:date2 OR messageWall_date3=:date3) AND {$sqlWhere})";
    }
    //My role categories
    try {
        $dataRoleCategory = array("gibbonPersonID" => $_SESSION[$guid]["gibbonPersonID"]);
        $sqlRoleCategory = "SELECT DISTINCT category FROM gibbonRole JOIN gibbonPerson ON (gibbonPerson.gibbonRoleIDAll LIKE CONCAT('%', gibbonRole.gibbonRoleID, '%')) WHERE gibbonPersonID=:gibbonPersonID";
        $resultRoleCategory = $connection2->prepare($sqlRoleCategory);
        $resultRoleCategory->execute($dataRoleCategory);
    } catch (PDOException $e) {
        print $e->getMessage();
    }
    $sqlWhere = "(";
    if ($resultRoleCategory->rowCount() > 0) {
        $i = 0;
        while ($rowRoleCategory = $resultRoleCategory->fetch()) {
            $dataPosts["role" . $rowRoleCategory["category"]] = $rowRoleCategory["category"];
            $sqlWhere .= "id=:role" . $rowRoleCategory["category"] . " OR ";
            $i++;
        }
        $sqlWhere = substr($sqlWhere, 0, -3) . ")";
    }
    if ($sqlWhere != "(") {
        $dataPosts["date1"] = $date;
        $dataPosts["date2"] = $date;
        $dataPosts["date3"] = $date;
        $sqlPosts = $sqlPosts . " UNION (SELECT DISTINCT gibbonMessenger.*, title, surname, preferredName, authorRole.category AS category, image_240, concat('Role Category: ', gibbonRole.category) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole AS authorRole ON (gibbonPerson.gibbonRoleIDPrimary=authorRole.gibbonRoleID) JOIN gibbonRole ON (gibbonMessengerTarget.id=gibbonRole.category) WHERE gibbonMessengerTarget.type='Role Category' AND (messageWall_date1=:date1 OR messageWall_date2=:date2 OR messageWall_date3=:date3) AND {$sqlWhere})";
    }
    //My year groups
    if ($staff) {
        $dataPosts["date4"] = $date;
        $dataPosts["date5"] = $date;
        $dataPosts["date6"] = $date;
        $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, 'Year Groups' AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) WHERE gibbonMessengerTarget.type='Year Group' AND (messageWall_date1=:date4 OR messageWall_date2=:date5 OR messageWall_date3=:date6) AND staff='Y')";
    }
    if ($student) {
        $dataPosts["date7"] = $date;
        $dataPosts["date8"] = $date;
        $dataPosts["date9"] = $date;
        $dataPosts["gibbonSchoolYearID1"] = $_SESSION[$guid]["gibbonSchoolYearID"];
        $dataPosts["gibbonPersonID1"] = $_SESSION[$guid]["gibbonPersonID"];
        $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Year Group ', gibbonYearGroup.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonStudentEnrolment ON (gibbonMessengerTarget.id=gibbonStudentEnrolment.gibbonYearGroupID) JOIN gibbonYearGroup ON (gibbonStudentEnrolment.gibbonYearGroupID=gibbonYearGroup.gibbonYearGroupID) WHERE gibbonStudentEnrolment.gibbonPersonID=:gibbonPersonID1 AND gibbonMessengerTarget.type='Year Group' AND (messageWall_date1=:date7 OR messageWall_date2=:date8 OR messageWall_date3=:date9) AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID1 AND students='Y')";
    }
    if ($parent and $children != FALSE) {
        $dataPosts["date10"] = $date;
        $dataPosts["date11"] = $date;
        $dataPosts["date12"] = $date;
        $dataPosts["gibbonSchoolYearID2"] = $_SESSION[$guid]["gibbonSchoolYearID"];
        $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Year Group: ', gibbonYearGroup.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonStudentEnrolment ON (gibbonMessengerTarget.id=gibbonStudentEnrolment.gibbonYearGroupID) JOIN gibbonYearGroup ON (gibbonStudentEnrolment.gibbonYearGroupID=gibbonYearGroup.gibbonYearGroupID) WHERE " . preg_replace("/gibbonPersonID/", "gibbonStudentEnrolment.gibbonPersonID", $children) . " AND gibbonMessengerTarget.type='Year Group' AND (messageWall_date1=:date10 OR messageWall_date2=:date11 OR messageWall_date3=:date12) AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID2 AND parents='Y')";
    }
    //My roll groups
    if ($staff) {
        $sqlWhere = "(";
        try {
            $dataRollGroup = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"], "gibbonPersonIDTutor" => $_SESSION[$guid]["gibbonPersonID"], "gibbonPersonIDTutor2" => $_SESSION[$guid]["gibbonPersonID"], "gibbonPersonIDTutor3" => $_SESSION[$guid]["gibbonPersonID"]);
            $sqlRollGroup = "SELECT * FROM gibbonRollGroup WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND (gibbonPersonIDTutor=:gibbonPersonIDTutor OR gibbonPersonIDTutor2=:gibbonPersonIDTutor2 OR gibbonPersonIDTutor3=:gibbonPersonIDTutor3)";
            $resultRollGroup = $connection2->prepare($sqlRollGroup);
            $resultRollGroup->execute($dataRollGroup);
        } catch (PDOException $e) {
        }
        if ($resultRollGroup->rowCount() > 0) {
            while ($rowRollGroup = $resultRollGroup->fetch()) {
                $dataPosts["roll" . $rowRollGroup["gibbonRollGroupID"]] = $rowRollGroup["gibbonRollGroupID"];
                $sqlWhere .= "id=:roll" . $rowRollGroup["gibbonRollGroupID"] . " OR ";
            }
            $sqlWhere = substr($sqlWhere, 0, -3) . ")";
            if ($sqlWhere != "(") {
                $dataPosts["date13"] = $date;
                $dataPosts["date14"] = $date;
                $dataPosts["date15"] = $date;
                $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Roll Group: ', gibbonRollGroup.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonRollGroup ON (gibbonMessengerTarget.id=gibbonRollGroup.gibbonRollGroupID) WHERE gibbonMessengerTarget.type='Roll Group' AND (messageWall_date1=:date13 OR messageWall_date2=:date14 OR messageWall_date3=:date15) AND {$sqlWhere} AND staff='Y')";
            }
        }
    }
    if ($student) {
        $dataPosts["date16"] = $date;
        $dataPosts["date17"] = $date;
        $dataPosts["date18"] = $date;
        $dataPosts["gibbonSchoolYearID3"] = $_SESSION[$guid]["gibbonSchoolYearID"];
        $dataPosts["gibbonPersonID2"] = $_SESSION[$guid]["gibbonPersonID"];
        $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Roll Group: ', gibbonRollGroup.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonStudentEnrolment ON (gibbonMessengerTarget.id=gibbonStudentEnrolment.gibbonRollGroupID) JOIN gibbonRollGroup ON (gibbonStudentEnrolment.gibbonRollGroupID=gibbonRollGroup.gibbonRollGroupID) WHERE gibbonStudentEnrolment.gibbonPersonID=:gibbonPersonID2 AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID3 AND gibbonMessengerTarget.type='Roll Group' AND (messageWall_date1=:date16 OR messageWall_date2=:date17 OR messageWall_date3=:date18) AND students='Y')";
    }
    if ($parent and $children != FALSE) {
        $dataPosts["date19"] = $date;
        $dataPosts["date20"] = $date;
        $dataPosts["date21"] = $date;
        $dataPosts["gibbonSchoolYearID4"] = $_SESSION[$guid]["gibbonSchoolYearID"];
        $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Roll Group: ', gibbonRollGroup.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonStudentEnrolment ON (gibbonMessengerTarget.id=gibbonStudentEnrolment.gibbonRollGroupID) JOIN gibbonRollGroup ON (gibbonStudentEnrolment.gibbonRollGroupID=gibbonRollGroup.gibbonRollGroupID) WHERE " . preg_replace("/gibbonPersonID/", "gibbonStudentEnrolment.gibbonPersonID", $children) . " AND gibbonStudentEnrolment.gibbonSchoolYearID=:gibbonSchoolYearID4 AND gibbonMessengerTarget.type='Roll Group' AND (messageWall_date1=:date19 OR messageWall_date2=:date20 OR messageWall_date3=:date21) AND parents='Y')";
    }
    //My courses
    //First check for any course, then do specific parent check
    try {
        $dataClasses = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"], "gibbonPersonID" => $_SESSION[$guid]["gibbonPersonID"]);
        $sqlClasses = "SELECT DISTINCT gibbonCourseClass.gibbonCourseID FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonPersonID=:gibbonPersonID AND NOT role LIKE '%- Left'";
        $resultClasses = $connection2->prepare($sqlClasses);
        $resultClasses->execute($dataClasses);
    } catch (PDOException $e) {
    }
    $sqlWhere = "(";
    if ($resultClasses->rowCount() > 0) {
        while ($rowClasses = $resultClasses->fetch()) {
            $dataPosts["course" . $rowClasses["gibbonCourseID"]] = $rowClasses["gibbonCourseID"];
            $sqlWhere .= "id=:course" . $rowClasses["gibbonCourseID"] . " OR ";
        }
        $sqlWhere = substr($sqlWhere, 0, -3) . ")";
        if ($sqlWhere != "(") {
            if ($staff) {
                $dataPosts["date22"] = $date;
                $dataPosts["date23"] = $date;
                $dataPosts["date24"] = $date;
                $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Course: ', gibbonCourse.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonCourse ON (gibbonMessengerTarget.id=gibbonCourse.gibbonCourseID) WHERE gibbonMessengerTarget.type='Course' AND (messageWall_date1=:date22 OR messageWall_date2=:date23 OR messageWall_date3=:date24) AND {$sqlWhere} AND staff='Y')";
            }
            if ($student) {
                $dataPosts["date25"] = $date;
                $dataPosts["date26"] = $date;
                $dataPosts["date27"] = $date;
                $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Course: ', gibbonCourse.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonCourse ON (gibbonMessengerTarget.id=gibbonCourse.gibbonCourseID) WHERE gibbonMessengerTarget.type='Course' AND (messageWall_date1=:date25 OR messageWall_date2=:date26 OR messageWall_date3=:date27) AND {$sqlWhere} AND students='Y')";
            }
        }
    }
    if ($parent and $children != FALSE) {
        try {
            $dataClasses = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"]);
            $sqlClasses = "SELECT DISTINCT gibbonCourseClass.gibbonCourseID FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND " . preg_replace("/gibbonPersonID/", "gibbonCourseClassPerson.gibbonPersonID", $children) . " AND NOT role LIKE '%- Left'";
            $resultClasses = $connection2->prepare($sqlClasses);
            $resultClasses->execute($dataClasses);
        } catch (PDOException $e) {
        }
        $sqlWhere = "(";
        if ($resultClasses->rowCount() > 0) {
            while ($rowClasses = $resultClasses->fetch()) {
                $dataPosts["course" . $rowClasses["gibbonCourseID"]] = $rowClasses["gibbonCourseID"];
                $sqlWhere .= "id=:course" . $rowClasses["gibbonCourseID"] . " OR ";
            }
            $sqlWhere = substr($sqlWhere, 0, -3) . ")";
            if ($sqlWhere != "(") {
                $dataPosts["date28"] = $date;
                $dataPosts["date29"] = $date;
                $dataPosts["date30"] = $date;
                $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Course: ', gibbonCourse.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonCourse ON (gibbonMessengerTarget.id=gibbonCourse.gibbonCourseID) WHERE gibbonMessengerTarget.type='Course' AND (messageWall_date1=:date28 OR messageWall_date2=:date29 OR messageWall_date3=:date30) AND {$sqlWhere} AND parents='Y')";
            }
        }
    }
    //My classes
    //First check for any role, then do specific parent check
    try {
        $dataClasses = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"], "gibbonPersonID" => $_SESSION[$guid]["gibbonPersonID"]);
        $sqlClasses = "SELECT gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonPersonID=:gibbonPersonID AND NOT role LIKE '%- Left'";
        $resultClasses = $connection2->prepare($sqlClasses);
        $resultClasses->execute($dataClasses);
    } catch (PDOException $e) {
    }
    $sqlWhere = "(";
    if ($resultClasses->rowCount() > 0) {
        while ($rowClasses = $resultClasses->fetch()) {
            $dataPosts["class" . $rowClasses["gibbonCourseClassID"]] = $rowClasses["gibbonCourseClassID"];
            $sqlWhere .= "id=:class" . $rowClasses["gibbonCourseClassID"] . " OR ";
        }
        $sqlWhere = substr($sqlWhere, 0, -3) . ")";
        if ($sqlWhere != "(") {
            if ($staff) {
                $dataPosts["date31"] = $date;
                $dataPosts["date32"] = $date;
                $dataPosts["date33"] = $date;
                $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Class: ', gibbonCourse.nameShort, '.', gibbonCourseClass.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonCourseClass ON (gibbonMessengerTarget.id=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) WHERE gibbonMessengerTarget.type='Class' AND (messageWall_date1=:date31 OR messageWall_date2=:date32 OR messageWall_date3=:date33) AND {$sqlWhere} AND staff='Y')";
            }
            if ($student) {
                $dataPosts["date34"] = $date;
                $dataPosts["date35"] = $date;
                $dataPosts["date36"] = $date;
                $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Class: ', gibbonCourse.nameShort, '.', gibbonCourseClass.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonCourseClass ON (gibbonMessengerTarget.id=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) WHERE gibbonMessengerTarget.type='Class' AND (messageWall_date1=:date34 OR messageWall_date2=:date35 OR messageWall_date3=:date36) AND {$sqlWhere} AND students='Y')";
            }
        }
    }
    if ($parent and $children != FALSE) {
        try {
            $dataClasses = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"]);
            $sqlClasses = "SELECT gibbonCourseClass.gibbonCourseClassID FROM gibbonCourse JOIN gibbonCourseClass ON (gibbonCourse.gibbonCourseID=gibbonCourseClass.gibbonCourseID) JOIN gibbonCourseClassPerson ON (gibbonCourseClassPerson.gibbonCourseClassID=gibbonCourseClass.gibbonCourseClassID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND " . preg_replace("/gibbonPersonID/", "gibbonCourseClassPerson.gibbonPersonID", $children) . " AND NOT role LIKE '%- Left'";
            $resultClasses = $connection2->prepare($sqlClasses);
            $resultClasses->execute($dataClasses);
        } catch (PDOException $e) {
        }
        $sqlWhere = "(";
        if ($resultClasses->rowCount() > 0) {
            while ($rowClasses = $resultClasses->fetch()) {
                $dataPosts["class" . $rowClasses["gibbonCourseClassID"]] = $rowClasses["gibbonCourseClassID"];
                $sqlWhere .= "id=:class" . $rowClasses["gibbonCourseClassID"] . " OR ";
            }
            $sqlWhere = substr($sqlWhere, 0, -3) . ")";
            if ($sqlWhere != "(") {
                $dataPosts["date37"] = $date;
                $dataPosts["date38"] = $date;
                $dataPosts["date39"] = $date;
                $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Class: ', gibbonCourse.nameShort, '.', gibbonCourseClass.nameShort) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonCourseClass ON (gibbonMessengerTarget.id=gibbonCourseClass.gibbonCourseClassID) JOIN gibbonCourse ON (gibbonCourseClass.gibbonCourseID=gibbonCourse.gibbonCourseID) WHERE gibbonMessengerTarget.type='Class' AND (messageWall_date1=:date37 OR messageWall_date2=:date38 OR messageWall_date3=:date39) AND {$sqlWhere} AND parents='Y')";
            }
        }
    }
    //My activities
    if ($staff) {
        try {
            $dataActivities = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"], "gibbonPersonID" => $_SESSION[$guid]["gibbonPersonID"]);
            $sqlActivities = "SELECT gibbonActivity.gibbonActivityID FROM gibbonActivity JOIN gibbonActivityStaff ON (gibbonActivityStaff.gibbonActivityID=gibbonActivity.gibbonActivityID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonActivityStaff.gibbonPersonID=:gibbonPersonID";
            $resultActivities = $connection2->prepare($sqlActivities);
            $resultActivities->execute($dataActivities);
        } catch (PDOException $e) {
        }
        $sqlWhere = "(";
        if ($resultActivities->rowCount() > 0) {
            while ($rowActivities = $resultActivities->fetch()) {
                $dataPosts["activity" . $rowActivities["gibbonActivityID"]] = $rowActivities["gibbonActivityID"];
                $sqlWhere .= "id=:activity" . $rowActivities["gibbonActivityID"] . " OR ";
            }
            $sqlWhere = substr($sqlWhere, 0, -3) . ")";
            if ($sqlWhere != "(") {
                $dataPosts["date40"] = $date;
                $dataPosts["date41"] = $date;
                $dataPosts["date42"] = $date;
                $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Activity: ', gibbonActivity.name) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonActivity ON (gibbonMessengerTarget.id=gibbonActivity.gibbonActivityID) WHERE gibbonMessengerTarget.type='Activity' AND (messageWall_date1=:date40 OR messageWall_date2=:date41 OR messageWall_date3=:date42) AND {$sqlWhere} AND staff='Y')";
            }
        }
    }
    if ($student) {
        try {
            $dataActivities = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"], "gibbonPersonID" => $_SESSION[$guid]["gibbonPersonID"]);
            $sqlActivities = "SELECT gibbonActivity.gibbonActivityID FROM gibbonActivity JOIN gibbonActivityStudent ON (gibbonActivityStudent.gibbonActivityID=gibbonActivity.gibbonActivityID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND gibbonActivityStudent.gibbonPersonID=:gibbonPersonID AND status='Accepted'";
            $resultActivities = $connection2->prepare($sqlActivities);
            $resultActivities->execute($dataActivities);
        } catch (PDOException $e) {
        }
        $sqlWhere = "(";
        if ($resultActivities->rowCount() > 0) {
            while ($rowActivities = $resultActivities->fetch()) {
                $dataPosts["activity" . $rowActivities["gibbonActivityID"]] = $rowActivities["gibbonActivityID"];
                $sqlWhere .= "id=:activity" . $rowActivities["gibbonActivityID"] . " OR ";
            }
            $sqlWhere = substr($sqlWhere, 0, -3) . ")";
            if ($sqlWhere != "(") {
                $dataPosts["date43"] = $date;
                $dataPosts["date44"] = $date;
                $dataPosts["date45"] = $date;
                $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Activity: ', gibbonActivity.name) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonActivity ON (gibbonMessengerTarget.id=gibbonActivity.gibbonActivityID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) WHERE gibbonMessengerTarget.type='Activity' AND (messageWall_date1=:date43 OR messageWall_date2=:date44 OR messageWall_date3=:date45) AND {$sqlWhere} AND students='Y')";
            }
        }
    }
    if ($parent and $children != FALSE) {
        try {
            $dataActivities = array("gibbonSchoolYearID" => $_SESSION[$guid]["gibbonSchoolYearID"]);
            $sqlActivities = "SELECT gibbonActivity.gibbonActivityID FROM gibbonActivity JOIN gibbonActivityStudent ON (gibbonActivityStudent.gibbonActivityID=gibbonActivity.gibbonActivityID) WHERE gibbonSchoolYearID=:gibbonSchoolYearID AND " . preg_replace("/gibbonPersonID/", "gibbonActivityStudent.gibbonPersonID", $children) . " AND status='Accepted'";
            $resultActivities = $connection2->prepare($sqlActivities);
            $resultActivities->execute($dataActivities);
        } catch (PDOException $e) {
        }
        $sqlWhere = "(";
        if ($resultActivities->rowCount() > 0) {
            while ($rowActivities = $resultActivities->fetch()) {
                $dataPosts["activity" . $rowActivities["gibbonActivityID"]] = $rowActivities["gibbonActivityID"];
                $sqlWhere .= "id=:activity" . $rowActivities["gibbonActivityID"] . " OR ";
            }
            $sqlWhere = substr($sqlWhere, 0, -3) . ")";
            if ($sqlWhere != "(") {
                $dataPosts["date46"] = $date;
                $dataPosts["date47"] = $date;
                $dataPosts["date48"] = $date;
                $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, title, surname, preferredName, category, image_240, concat('Activity: ', gibbonActivity.name) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonActivity ON (gibbonMessengerTarget.id=gibbonActivity.gibbonActivityID) WHERE gibbonMessengerTarget.type='Activity' AND (messageWall_date1=:date46 OR messageWall_date2=:date47 OR messageWall_date3=:date48) AND {$sqlWhere} AND parents='Y')";
            }
        }
    }
    //Houses
    $dataPosts["date49"] = $date;
    $dataPosts["date50"] = $date;
    $dataPosts["date51"] = $date;
    $dataPosts["gibbonPersonID3"] = $_SESSION[$guid]["gibbonPersonID"];
    $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, gibbonPerson.title, gibbonPerson.surname, gibbonPerson.preferredName, category, gibbonPerson.image_240, concat('Houses: ', gibbonHouse.name) AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonPerson AS inHouse ON (gibbonMessengerTarget.id=inHouse.gibbonHouseID) JOIN gibbonHouse ON (gibbonPerson.gibbonHouseID=gibbonHouse.gibbonHouseID)WHERE gibbonMessengerTarget.type='Houses' AND (messageWall_date1=:date49 OR messageWall_date2=:date50 OR messageWall_date3=:date51) AND inHouse.gibbonPersonID=:gibbonPersonID3)";
    //Individuals
    $dataPosts["date52"] = $date;
    $dataPosts["date53"] = $date;
    $dataPosts["date54"] = $date;
    $dataPosts["gibbonPersonID4"] = $_SESSION[$guid]["gibbonPersonID"];
    $sqlPosts = $sqlPosts . " UNION (SELECT gibbonMessenger.*, gibbonPerson.title, gibbonPerson.surname, gibbonPerson.preferredName, category, gibbonPerson.image_240, 'Individual: You' AS source FROM gibbonMessenger JOIN gibbonMessengerTarget ON (gibbonMessengerTarget.gibbonMessengerID=gibbonMessenger.gibbonMessengerID) JOIN gibbonPerson ON (gibbonMessenger.gibbonPersonID=gibbonPerson.gibbonPersonID) JOIN gibbonRole ON (gibbonPerson.gibbonRoleIDPrimary=gibbonRole.gibbonRoleID) JOIN gibbonPerson AS individual ON (gibbonMessengerTarget.id=individual.gibbonPersonID) WHERE gibbonMessengerTarget.type='Individuals' AND (messageWall_date1=:date52 OR messageWall_date2=:date53 OR messageWall_date3=:date54) AND individual.gibbonPersonID=:gibbonPersonID4)";
    //SPIT OUT RESULTS
    if ($mode == "result") {
        $resultReturn = array();
        $resultReturn[0] = $dataPosts;
        $resultReturn[1] = $sqlPosts . " ORDER BY subject, gibbonMessengerID, source";
        return serialize($resultReturn);
    } else {
        $count = 0;
        try {
            $sqlPosts = $sqlPosts . " ORDER BY subject, gibbonMessengerID, source";
            $resultPosts = $connection2->prepare($sqlPosts);
            $resultPosts->execute($dataPosts);
        } catch (PDOException $e) {
            print $e->getMessage();
        }
        if ($resultPosts->rowCount() < 1) {
            $return .= "<div class='warning'>";
            $return .= _("There are no records to display.");
            $return .= "</div>";
        } else {
            $output = array();
            $last = "";
            while ($rowPosts = $resultPosts->fetch()) {
                if ($last == $rowPosts["gibbonMessengerID"]) {
                    $output[$count - 1]["source"] = $output[$count - 1]["source"] . "<br/>" . $rowPosts["source"];
                } else {
                    $output[$count]["photo"] = $rowPosts["image_240"];
                    $output[$count]["subject"] = $rowPosts["subject"];
                    $output[$count]["details"] = $rowPosts["body"];
                    $output[$count]["author"] = formatName($rowPosts["title"], $rowPosts["preferredName"], $rowPosts["surname"], $rowPosts["category"]);
                    $output[$count]["source"] = $rowPosts["source"];
                    $output[$count]["gibbonMessengerID"] = $rowPosts["gibbonMessengerID"];
                    $output[$count]["gibbonPersonID"] = $rowPosts["gibbonPersonID"];
                    $count++;
                    $last = $rowPosts["gibbonMessengerID"];
                }
            }
            $return .= "<table cellspacing='0' style='margin-top: 10px'>";
            $return .= "<tr>";
            $return .= "<th style='text-align: center'>";
            $return .= _("Sharing");
            $return .= "</th>";
            $return .= "<th>";
            $return .= _("Message");
            $return .= "</th>";
            $return .= "</tr>";
            $rowCount = 0;
            $rowNum = "odd";
            for ($i = 0; $i < count($output); $i++) {
                if ($rowCount % 2 == 0) {
                    $rowNum = "even";
                } else {
                    $rowNum = "odd";
                }
                $rowCount++;
                $return .= "<tr class={$rowNum}>";
                $return .= "<td style='text-align: center; vertical-align: top; padding-bottom: 10px; padding-top: 10px; border-top: 1px solid #666; width: 100px'>";
                $return .= "<a name='" . $output[$i]["gibbonMessengerID"] . "'></a>";
                $return .= getUserPhoto($guid, $output[$i]["photo"], 75) . "<br/>";
                //DEAL WITH LIKES
                $likesGiven = countLikesByContextAndGiver($connection2, "Messenger", "gibbonMessengerID", $output[$i]["gibbonMessengerID"], $_SESSION[$guid]["gibbonPersonID"], $output[$i]["gibbonPersonID"]);
                if ($output[$i]["gibbonPersonID"] == $_SESSION[$guid]["gibbonPersonID"]) {
                    if ($likesGiven == 1) {
                        $return .= $likesGiven . "x " . _('Like') . "<br/><br/>";
                    } else {
                        $return .= $likesGiven . "x " . _('Likes') . "<br/><br/>";
                    }
                } else {
                    $comment = addSlashes($output[$i]["subject"]);
                    $return .= "<div id='star" . $output[$i]["gibbonMessengerID"] . "'>";
                    $return .= "<script type=\"text/javascript\">";
                    $return .= "\$(document).ready(function(){";
                    $return .= "\$(\"#starAdd" . $output[$i]["gibbonMessengerID"] . "\").click(function(){";
                    $return .= "\$(\"#star" . $output[$i]["gibbonMessengerID"] . "\").load(\"" . $_SESSION[$guid]["absoluteURL"] . "/modules/Messenger/messageWall_view_starAjax.php\",{\"gibbonPersonID\": \"" . $output[$i]["gibbonPersonID"] . "\", \"gibbonMessengerID\": \"" . $output[$i]["gibbonMessengerID"] . "\", \"mode\": \"add\", \"comment\": \"" . $comment . "\"});";
                    $return .= "});";
                    $return .= "\$(\"#starRemove" . $output[$i]["gibbonMessengerID"] . "\").click(function(){";
                    $return .= "\$(\"#star" . $output[$i]["gibbonMessengerID"] . "\").load(\"" . $_SESSION[$guid]["absoluteURL"] . "/modules/Messenger/messageWall_view_starAjax.php\",{\"gibbonPersonID\": \"" . $output[$i]["gibbonPersonID"] . "\", \"gibbonMessengerID\": \"" . $output[$i]["gibbonMessengerID"] . "\", \"mode\": \"remove\", \"comment\": \"" . $comment . "\"});";
                    $return .= "});";
                    $return .= "});";
                    $return .= "</script>";
                    if ($likesGiven != 1) {
                        $return .= "<a id='starAdd" . $output[$i]["gibbonMessengerID"] . "' onclick='return false;' href='#'><img style='margin-top: -8px; margin-bottom: 5px' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/like_off.png'></a>";
                    } else {
                        $return .= "<a id='starRemove" . $output[$i]["gibbonMessengerID"] . "' onclick='return false;' href='#'><img style='margin-top: -8px; margin-bottom: 5px' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/like_on.png'></a>";
                    }
                    $return .= "</div>";
                }
                $return .= "<b><u>Posted By</b></u><br/>";
                $return .= $output[$i]["author"] . "<br/><br/>";
                $return .= "<b><u>Shared Via</b></u><br/>";
                $return .= $output[$i]["source"] . "<br/><br/>";
                $return .= "</td>";
                $return .= "<td style='border-left: none; vertical-align: top; padding-bottom: 10px; padding-top: 10px; border-top: 1px solid #666; width: 640px'>";
                $return .= "<h3 style='margin-top: 3px'>";
                $return .= $output[$i]["subject"];
                $return .= "</h3>";
                $return .= "</p>";
                $return .= $output[$i]["details"];
                $return .= "</p>";
                $return .= "</td>";
                $return .= "</tr>";
            }
            $return .= "</table>";
        }
        if ($mode == "print") {
            return $return;
        } else {
            return $count;
        }
    }
}
Exemple #13
0
		                <div class="flow-text">' . eventTranslate($value['eventContent']) . '<a href="#">' . $value['noticeUser'] . '</a>' . getEventPhoto($value['photo']) . '</div>
		                    <div class="row grey lighten-3">
		                  <div class="col s2"><i class="small grey-text text-darken-2 mdi-action-lock prefix"></i></div>';
        }
    } else {
        if ($value['enable_open']) {
            echo '<div class="row">
		              <div class="col s12">
		                <h5>' . getUserPhoto($value['createUserPhoto'], 30) . $value['createUser'] . '</h5>
		                <div class="flow-text">' . eventTranslate($value['eventContent']) . '<a href="#">' . $value['noticeUser'] . '</a>' . getEventPhoto($value['photo']) . '</div>
		                    <div class="row grey lighten-3" onclick="window.location=' . "'" . "contact_info.php?from=quan&id=" . $userId . "'" . '" >
		                  <div class="col s2"><i class="small grey-text text-darken-2 mdi-action-account-box prefix"></i></div>';
        } else {
            echo '<div class="row">
		              <div class="col s12">
		                <h5>' . getUserPhoto($value['createUserPhoto'], 30) . $value['createUser'] . '</h5>
		                <div class="flow-text">' . eventTranslate($value['eventContent']) . '<a href="#">' . $value['noticeUser'] . '</a>' . getEventPhoto($value['photo']) . '</div>
		                    <div class="row grey lighten-3" >
		                  <div class="col s2"><i class="small grey-text text-darken-2 mdi-action-lock prefix"></i></div>';
        }
    }
    echo '<div class="col s10">' . $value['eventCreateUserNickname'] . '</div>';
    echo '<div class="col s10">';
    if ($value['eventType'] == 'group') {
        foreach ($value['relation'] as $key => $relationIndex) {
            $valueIndexArray = array();
            foreach ($relationIndex as $valueIndex) {
                $valueIndexArray[] = $valueIndex['nickname'];
            }
            echo $key . ':<a href="#">' . implode(',', $valueIndexArray) . '</a> ';
        }