Exemple #1
0
function importActivityStream($user, $doc)
{
    $feed = $doc->documentElement;
    $subjectEl = ActivityUtils::child($feed, Activity::SUBJECT, Activity::SPEC);
    if (!empty($subjectEl)) {
        $subject = new ActivityObject($subjectEl);
        printfv(_("Backup file for user %s (%s)") . "\n", $subject->id, Ostatus_profile::getActivityObjectNickname($subject));
    } else {
        throw new Exception("Feed doesn't have an <activity:subject> element.");
    }
    if (is_null($user)) {
        printfv(_("No user specified; using backup user.") . "\n");
        $user = userFromSubject($subject);
    }
    $entries = $feed->getElementsByTagNameNS(Activity::ATOM, 'entry');
    printfv(_("%d entries in backup.") . "\n", $entries->length);
    for ($i = $entries->length - 1; $i >= 0; $i--) {
        try {
            $entry = $entries->item($i);
            $activity = new Activity($entry, $feed);
            switch ($activity->verb) {
                case ActivityVerb::FOLLOW:
                    subscribeProfile($user, $subject, $activity);
                    break;
                case ActivityVerb::JOIN:
                    joinGroup($user, $activity);
                    break;
                case ActivityVerb::POST:
                    postNote($user, $activity);
                    break;
                default:
                    throw new Exception("Unknown verb: {$activity->verb}");
            }
        } catch (Exception $e) {
            print $e->getMessage() . "\n";
            continue;
        }
    }
}
Exemple #2
0
function createGroup($mysqli, $userId, $name, $schoolId)
{
    if (doesUserExist($mysqli, $userId)) {
        if (doesSchoolExist($mysqli, $schoolId)) {
            if ($stmt = $mysqli->prepare("INSERT INTO groups SET name = ?, school_id = ?, creator_id = ?")) {
                $stmt->bind_param("sii", $name, $schoolId, $userId);
                $stmt->execute();
                $groupInsertId = $mysqli->insert_id;
                joinGroup($mysqli, $userId, $groupInsertId);
                return $groupInsertId;
            } else {
                return "Faulty MYSQLI Statement";
            }
        } else {
            return "School does not exist";
        }
    } else {
        return "User does not exist";
    }
}
include_once 'Smarty.class.php';
$main_smarty = new Smarty();
include 'config.php';
include mnminclude . 'html1.php';
include mnminclude . 'group.php';
include mnminclude . 'link.php';
include mnminclude . 'tags.php';
include mnminclude . 'smartyvariables.php';
check_referrer();
//to join and unjoin the group
if (isset($_REQUEST['id'])) {
    $gid = $_REQUEST['id'];
    $privacy = $_REQUEST['privacy'];
    if ($_REQUEST['join'] == "true") {
        joinGroup($gid, $privacy);
    }
    if ($_REQUEST['join'] == "false") {
        unjoinGroup($gid, $privacy);
    }
    //page redirect
    $redirect = '';
    $redirect = getmyurl("group_story", $gid);
    header("Location: {$redirect}");
    die;
}
//to activate the group from mail link
if ($_REQUEST['activate'] == 'true') {
    $member_status = 'active';
    $group_id = $_REQUEST['group_id'];
    $user_id = $_REQUEST['user_id'];
Exemple #4
0
 } else {
     if ($reason == "Join Group") {
         if (isset($_POST['reason'])) {
             $cid = $_POST['CID'];
             $myID = $_POST['UID'];
             $groupID = $_POST['GID'];
             $groupStatus = $_POST['GS'];
         } else {
             $cid = $_GET['CID'];
             $myID = $_GET['UID'];
             $groupID = $_GET['GID'];
             $groupStatus = $_GET['GS'];
             //$year= $_POST['Y'];
         }
         if (!empty($myID) && !empty($groupID)) {
             echo json_encode(joinGroup($myID, $groupID, $cid, $groupStatus));
         } else {
             echo "Error. Please try again";
         }
     } else {
         if ($reason == "Leave Group" || $reason == "Cancel Group Request") {
             if (isset($_POST['reason'])) {
                 $myID = $_POST['UID'];
                 $groupID = $_POST['GID'];
             } else {
                 $myID = $_GET['UID'];
                 $groupID = $_GET['GID'];
             }
             echo json_encode(leaveGroup($groupID, $myID));
         } else {
             if ($reason == "Load my Groups") {
Exemple #5
0
<?php

session_start();
require_once '../db.php';
if (!isset($_POST['group'])) {
    die('group must be present');
    return;
}
if (!isset($_SESSION['userId'])) {
    die('Not logged in');
    return;
}
joinGroup(mongoIdSanitize($_SESSION['userId']), mongoUserSanitize($_SESSION['userName']), mongoIdSanitize($_POST['group']));
Exemple #6
0
function createGroup($userId, $userName, $groupName, $description)
{
    $db = getDB();
    $insert = array('created' => new MongoDate(), 'description' => $description, 'name' => $groupName);
    $db->groups->insert($insert);
    joinGroup($userId, $userName, $insert['_id']->{'$id'});
}
Exemple #7
0
if (filter_has_var(INPUT_POST, "group_id")) {
    $group_id = filter_input(INPUT_POST, "group_id");
    $user_id = $_SESSION["user_id"];
    //检查用户是否该组成员
    if (isMember($user_id, $group_id)) {
        $_SESSION["group_id"] = $group_id;
        $_SESSION["group_name"] = getGroupNameById($group_id);
        showPrayList($group_id);
    } else {
        showJoinGroup($group_id);
    }
} else {
    if (filter_has_var(INPUT_POST, "joinGroup")) {
        $group_id = filter_input(INPUT_POST, "joinGroup");
        $user_id = $_SESSION["user_id"];
        joinGroup($user_id, $group_id);
    } else {
        if (isset($_SESSION["group_id"])) {
            $group_id = $_SESSION["group_id"];
            showPrayList($group_id);
        } else {
            echo "<script>window.location = 'index.php'</script>";
        }
    }
}
function isMember($user_id, $group_id)
{
    try {
        $pdo = new PDO("mysql:host=" . DBHOST . "; port=" . DBPORT . "; dbname=" . DBNAME, DBUSER, DBPASS);
        //$pdo = new PDO("mysql:host=localhost; dbname=pray","pray", "pray");
        $smt = $pdo->prepare("SELECT * FROM groupMember WHERE user_id=? AND group_id=?");
Exemple #8
0
<?php

include_once '../functions.php';
include_once '../db_connect.php';
sec_session_start();
if (isset($_SESSION["user_id"], $_POST["group_id"])) {
    echo joinGroup($mysqli, $_SESSION["user_id"], $_POST["group_id"]);
} else {
    header('Location: ../../school.php?error=Faulty Post Variables');
}