コード例 #1
0
ファイル: likes.php プロジェクト: dpredster/core
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
print "<div class='trail'>";
print "<div class='trailHead'><a href='" . $_SESSION[$guid]["absoluteURL"] . "'>" . _("Home") . "</a> > </div><div class='trailEnd'>" . _("Likes") . "</div>";
print "</div>";
print "<p>";
print _("This page shows you a break down of all your likes in the current year, and they have been earned.");
print "</p>";
//Count planner likes
$resultLike = countLikesByRecipient($connection2, $_SESSION[$guid]["gibbonPersonID"], "result", $_SESSION[$guid]["gibbonSchoolYearID"]);
if ($resultLike == FALSE) {
    print "<div class='error'>" . _('An error has occurred.') . "</div>";
} else {
    if ($resultLike->rowCount() < 1) {
        print "<div class='error'>";
        print _("There are no records to display.");
        print "</div>";
    } else {
        print "<table cellspacing='0' style='width: 100%'>";
        print "<tr class='head'>";
        print "<th style='width: 90px'>";
        print _("Photo");
        print "</th>";
        print "<th style='width: 180px'>";
        print _("Giver") . "<br/>";
コード例 #2
0
ファイル: functions.php プロジェクト: dpredster/core
function getMinorLinks($connection2, $guid, $cacheLoad)
{
    $return = FALSE;
    if (isset($_SESSION[$guid]["username"]) == FALSE) {
        if ($_SESSION[$guid]["webLink"] != "") {
            $return .= _("Return to") . " <a style='margin-right: 12px' target='_blank' href='" . $_SESSION[$guid]["webLink"] . "'>" . $_SESSION[$guid]["organisationNameShort"] . " " . _('Website') . "</a>";
        }
    } else {
        $return .= $_SESSION[$guid]["preferredName"] . " " . $_SESSION[$guid]["surname"] . " . ";
        $return .= "<a href='./logout.php'>" . _("Logout") . "</a> . <a href='./index.php?q=preferences.php'>" . _('Preferences') . "</a>";
        if ($_SESSION[$guid]["emailLink"] != "") {
            $return .= " . <a target='_blank' href='" . $_SESSION[$guid]["emailLink"] . "'>" . _('Email') . "</a>";
        }
        if ($_SESSION[$guid]["webLink"] != "") {
            $return .= " . <a target='_blank' href='" . $_SESSION[$guid]["webLink"] . "'>" . $_SESSION[$guid]["organisationNameShort"] . " " . _('Website') . "</a>";
        }
        if ($_SESSION[$guid]["website"] != "") {
            $return .= " . <a target='_blank' href='" . $_SESSION[$guid]["website"] . "'>" . _('My Website') . "</a>";
        }
        //GET AND SHOW LIKES
        //Get likes
        $getLikes = FALSE;
        if ($cacheLoad) {
            $getLikes = TRUE;
        } else {
            if (isset($_GET["q"])) {
                if ($_GET["q"] == "likes.php") {
                    $getLikes = TRUE;
                }
            }
        }
        if ($getLikes) {
            $_SESSION[$guid]["likesCount"] = countLikesByRecipient($connection2, $_SESSION[$guid]["gibbonPersonID"], "count", $_SESSION[$guid]["gibbonSchoolYearID"]);
        }
        //Show likes
        if (isset($_SESSION[$guid]["likesCount"])) {
            if ($_SESSION[$guid]["likesCount"] > 0) {
                $return .= " . <a title='" . _('Likes') . "' href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=likes.php'>" . $_SESSION[$guid]["likesCount"] . " x <img class='minorLinkIcon' style='margin-left: 2px; vertical-align: -75%' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/like_large_on.png'></a>";
            } else {
                $return .= " . " . $_SESSION[$guid]["likesCount"] . " x <img class='minorLinkIcon' title='" . _('Likes') . "' style='margin-left: 2px; opacity: 0.8; vertical-align: -75%' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/like_large_off.png'>";
            }
        }
        //GET & SHOW NOTIFICATIONS
        try {
            $dataNotifications = array("gibbonPersonID" => $_SESSION[$guid]["gibbonPersonID"], "gibbonPersonID2" => $_SESSION[$guid]["gibbonPersonID"]);
            $sqlNotifications = "(SELECT gibbonNotification.*, gibbonModule.name AS source FROM gibbonNotification JOIN gibbonModule ON (gibbonNotification.gibbonModuleID=gibbonModule.gibbonModuleID) WHERE gibbonPersonID=:gibbonPersonID AND status='New')\n\t\t\tUNION\n\t\t\t(SELECT gibbonNotification.*, 'System' AS source FROM gibbonNotification WHERE gibbonModuleID IS NULL AND gibbonPersonID=:gibbonPersonID2 AND status='New')\n\t\t\tORDER BY timestamp DESC, source, text";
            $resultNotifications = $connection2->prepare($sqlNotifications);
            $resultNotifications->execute($dataNotifications);
        } catch (PDOException $e) {
            $return .= "<div class='error'>" . $e->getMessage() . "</div>";
        }
        //Refresh notifications every 10 seconds for staff, 120 seconds for everyone else
        $interval = 120000;
        if ($_SESSION[$guid]["gibbonRoleIDCurrentCategory"] == "Staff") {
            $interval = 10000;
        }
        $return .= "<script type=\"text/javascript\">\n\t\t\t\$(document).ready(function(){\n\t\t\t\tsetInterval(function() {\n\t\t\t\t\t\$(\"#notifications\").load(\"index_notification_ajax.php\");\n\t\t\t\t}, " . $interval . ");\n\t\t\t});\n\t\t</script>";
        $return .= "<div id='notifications' style='display: inline'>";
        //CHECK FOR SYSTEM ALARM
        if (isset($_SESSION[$guid]["gibbonRoleIDCurrentCategory"])) {
            if ($_SESSION[$guid]["gibbonRoleIDCurrentCategory"] == "Staff") {
                $alarm = getSettingByScope($connection2, "System", "alarm");
                if ($alarm == "General" or $alarm == "Lockdown" or $alarm == "Custom") {
                    $type = "general";
                    if ($alarm == "Lockdown") {
                        $type = "lockdown";
                    } else {
                        if ($alarm == "Custom") {
                            $type = "custom";
                        }
                    }
                    $return .= "<script>\n\t\t\t\t\t\t\tif (\$('div#TB_window').is(':visible')===false) {\n\t\t\t\t\t\t\t\tvar url = '" . $_SESSION[$guid]["absoluteURL"] . "/index_notification_ajax_alarm.php?type=" . $type . "&KeepThis=true&TB_iframe=true&width=1000&height=500';\n\t\t\t\t\t\t\t\t\$(document).ready(function() {\n\t\t\t\t\t\t\t\t\ttb_show('', url);\n\t\t\t\t\t\t\t\t\t\$('div#TB_window').addClass('alarm') ;\n\t\t\t\t\t\t\t\t}) ;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t</script>";
                }
            }
        }
        if ($resultNotifications->rowCount() > 0) {
            $return .= " . <a title='" . _('Notifications') . "' href='" . $_SESSION[$guid]["absoluteURL"] . "/index.php?q=notifications.php'>" . $resultNotifications->rowCount() . " x " . "<img class='minorLinkIcon' style='margin-left: 2px; vertical-align: -75%' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/notifications_on.png'></a>";
        } else {
            $return .= " . 0 x " . "<img title='" . _('Notifications') . "' class='minorLinkIcon' style='margin-left: 2px; opacity: 0.8; vertical-align: -75%' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/notifications_off.png'>";
        }
        $return .= "</div>";
        //MESSAGE WALL!
        if (isActionAccessible($guid, $connection2, "/modules/Messenger/messageWall_view.php")) {
            include "./modules/Messenger/moduleFunctions.php";
            $addReturn = NULL;
            if (isset($_GET["addReturn"])) {
                $addReturn = $_GET["addReturn"];
            }
            $updateReturn = NULL;
            if (isset($_GET["updateReturn"])) {
                $updateReturn = $_GET["updateReturn"];
            }
            $deleteReturn = NULL;
            if (isset($_GET["deleteReturn"])) {
                $deleteReturn = $_GET["deleteReturn"];
            }
            if ($cacheLoad or @$_GET["q"] == "/modules/Messenger/messenger_post.php" and $addReturn == "success0" or @$_GET["q"] == "/modules/Messenger/messenger_postQuickWall.php" and $addReturn == "success0" or @$_GET["q"] == "/modules/Messenger/messenger_manage_edit.php" and $updateReturn == "success0" or @$_GET["q"] == "/modules/Messenger/messenger_manage.php" and $deleteReturn == "success0") {
                $messages = getMessages($guid, $connection2, "result");
                $messages = unserialize($messages);
                try {
                    $resultPosts = $connection2->prepare($messages[1]);
                    $resultPosts->execute($messages[0]);
                } catch (PDOException $e) {
                }
                $_SESSION[$guid]["messageWallCount"] = 0;
                if ($resultPosts->rowCount() > 0) {
                    $count = 0;
                    $output = array();
                    $last = "";
                    while ($rowPosts = $resultPosts->fetch()) {
                        if ($last == $rowPosts["gibbonMessengerID"]) {
                            $output[$count - 1]["source"] = $output[$count - 1]["source"] . "<br/>" . $rowPosts["source"];
                        } else {
                            $output[$_SESSION[$guid]["messageWallCount"]]["photo"] = $rowPosts["image_240"];
                            $output[$_SESSION[$guid]["messageWallCount"]]["subject"] = $rowPosts["subject"];
                            $output[$_SESSION[$guid]["messageWallCount"]]["details"] = $rowPosts["body"];
                            $output[$_SESSION[$guid]["messageWallCount"]]["author"] = formatName($rowPosts["title"], $rowPosts["preferredName"], $rowPosts["surname"], $rowPosts["category"]);
                            $output[$_SESSION[$guid]["messageWallCount"]]["source"] = $rowPosts["source"];
                            $output[$_SESSION[$guid]["messageWallCount"]]["gibbonMessengerID"] = $rowPosts["gibbonMessengerID"];
                            $_SESSION[$guid]["messageWallCount"]++;
                            $last = $rowPosts["gibbonMessengerID"];
                            $count++;
                        }
                    }
                    $_SESSION[$guid]["messageWallOutput"] = $output;
                }
            }
            //Check for house logo (needed to get bubble, below, in right spot)
            $isHouseLogo = FALSE;
            if (isset($_SESSION[$guid]["gibbonHouseIDLogo"]) and isset($_SESSION[$guid]["gibbonHouseIDName"])) {
                if ($_SESSION[$guid]["gibbonHouseIDLogo"] != "") {
                    $isHouseLogo = TRUE;
                }
            }
            $URL = $_SESSION[$guid]["absoluteURL"] . "/index.php?q=/modules/Messenger/messageWall_view.php";
            if (isset($_SESSION[$guid]["messageWallCount"]) == FALSE) {
                $return .= " . 0 x <img title='" . _('Message Wall') . "' class='minorLinkIcon' style='margin-left: 4px; opacity: 0.8; vertical-align: -75%' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/messageWall_none.png'>";
            } else {
                if ($_SESSION[$guid]["messageWallCount"] < 1) {
                    $return .= " . 0 x <img title='" . _('Message Wall') . "' class='minorLinkIcon' style='margin-left: 4px; opacity: 0.8; vertical-align: -75%' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/messageWall_none.png'>";
                } else {
                    $return .= " . <a title='" . _('Message Wall') . "' href='{$URL}'>" . $_SESSION[$guid]["messageWallCount"] . " x <img class='minorLinkIcon' style='margin-left: 4px; vertical-align: -75%' src='" . $_SESSION[$guid]["absoluteURL"] . "/themes/" . $_SESSION[$guid]["gibbonThemeName"] . "/img/messageWall.png'></a>";
                    if ($_SESSION[$guid]["pageLoads"] == 0 and ($_SESSION[$guid]["messengerLastBubble"] == NULL or $_SESSION[$guid]["messengerLastBubble"] < date("Y-m-d"))) {
                        print $messageBubbleBGColor = getSettingByScope($connection2, "Messenger", "messageBubbleBGColor");
                        $bubbleBG = "";
                        if ($messageBubbleBGColor != "") {
                            $bubbleBG = "; background-color: rgba(" . $messageBubbleBGColor . ")!important";
                            $return .= "<style>";
                            $return .= ".ui-tooltip, .arrow:after { {$bubbleBG} }";
                            $return .= "</style>";
                        }
                        $messageBubbleWidthType = getSettingByScope($connection2, "Messenger", "messageBubbleWidthType");
                        $bubbleWidth = 300;
                        $bubbleLeft = 770;
                        if ($messageBubbleWidthType == "Wide") {
                            $bubbleWidth = 700;
                            $bubbleLeft = 370;
                        }
                        if ($isHouseLogo) {
                            //Spacing with house logo
                            $bubbleLeft = $bubbleLeft - 70;
                            $return .= "<div id='messageBubbleArrow' style=\"left: 1019px; top: 58px; z-index: 9999\" class='arrow top'></div>";
                            $return .= "<div id='messageBubble' style=\"left: " . $bubbleLeft . "px; top: 74px; width: " . $bubbleWidth . "px; min-width: " . $bubbleWidth . "px; max-width: " . $bubbleWidth . "px; min-height: 100px; text-align: center; padding-bottom: 10px\" class=\"ui-tooltip ui-widget ui-corner-all ui-widget-content\" role=\"tooltip\">";
                        } else {
                            //Spacing without house logo
                            $return .= "<div id='messageBubbleArrow' style=\"left: 1089px; top: 38px; z-index: 9999\" class='arrow top'></div>";
                            $return .= "<div id='messageBubble' style=\"left: " . $bubbleLeft . "px; top: 54px; width: " . $bubbleWidth . "px; min-width: " . $bubbleWidth . "px; max-width: " . $bubbleWidth . "px; min-height: 100px; text-align: center; padding-bottom: 10px\" class=\"ui-tooltip ui-widget ui-corner-all ui-widget-content\" role=\"tooltip\">";
                        }
                        $return .= "<div class=\"ui-tooltip-content\">";
                        $return .= "<div style='font-weight: bold; font-style: italic; font-size: 120%; margin-top: 10px; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px dotted rgba(255,255,255,0.5); display: block'>" . _('New Messages') . "</div>";
                        $test = count($output);
                        if ($test > 3) {
                            $test = 3;
                        }
                        for ($i = 0; $i < $test; $i++) {
                            $return .= "<span style='font-size: 120%; font-weight: bold'>";
                            if (strlen($output[$i]["subject"]) <= 30) {
                                $return .= $output[$i]["subject"];
                            } else {
                                $return .= substr($output[$i]["subject"], 0, 30) . "...";
                            }
                            $return .= "</span><br/>";
                            $return .= "<i>" . $output[$i]["author"] . "</i><br/><br/>";
                        }
                        if (count($output) > 3) {
                            $return .= "<i>" . _('Plus more') . "...</i>";
                        }
                        $return .= "</div>";
                        $return .= "<div style='text-align: right; margin-top: 20px; color: #666'>";
                        $return .= "<a onclick='\$(\"#messageBubble\").hide(\"fade\", {}, 1); \$(\"#messageBubbleArrow\").hide(\"fade\", {}, 1)' style='text-decoration: none; color: #666' href='" . $URL . "'>" . _('Read All') . "</a> . ";
                        $return .= "<a style='text-decoration: none; color: #666' onclick='\$(\"#messageBubble\").hide(\"fade\", {}, 1000); \$(\"#messageBubbleArrow\").hide(\"fade\", {}, 1000)' href='#'>" . _('Dismiss') . "</a>";
                        $return .= "</div>";
                        $return .= "</div>";
                        $messageBubbleAutoHide = getSettingByScope($connection2, "Messenger", "messageBubbleAutoHide");
                        if ($messageBubbleAutoHide != "N") {
                            $return .= "<script type=\"text/javascript\">";
                            $return .= "\$(function() {";
                            $return .= "setTimeout(function() {";
                            $return .= "\$(\"#messageBubble\").hide('fade', {}, 3000)";
                            $return .= "}, 10000);";
                            $return .= "});";
                            $return .= "\$(function() {";
                            $return .= "setTimeout(function() {";
                            $return .= "\$(\"#messageBubbleArrow\").hide('fade', {}, 3000)";
                            $return .= "}, 10000);";
                            $return .= "});";
                            $return .= "</script>";
                        }
                        try {
                            $data = array("messengerLastBubble" => date("Y-m-d"), "gibbonPersonID" => $_SESSION[$guid]["gibbonPersonID"]);
                            $sql = "UPDATE gibbonPerson SET messengerLastBubble=:messengerLastBubble WHERE gibbonPersonID=:gibbonPersonID";
                            $result = $connection2->prepare($sql);
                            $result->execute($data);
                        } catch (PDOException $e) {
                        }
                    }
                }
            }
        }
        //House logo
        if (@$isHouseLogo) {
            $return .= " . <img class='minorLinkIconLarge' title='" . $_SESSION[$guid]["gibbonHouseIDName"] . "' style='vertical-align: -75%; margin-left: 4px' src='" . $_SESSION[$guid]["absoluteURL"] . "/" . $_SESSION[$guid]["gibbonHouseIDLogo"] . "'/>";
        }
    }
    return $return;
}