Пример #1
0
function CreateNotification($type, $pdo, $targetid, $starterid, $valuein, $decision = NULL)
{
    $connection = new Connect();
    if ($type == 1) {
        //Notify that you have been invited to a new group
        $notification = strtok($connection->GetNamebyId($pdo, $starterid, 0), " ") . ' invited you to join ';
        $params = ["sourceid" => $starterid, "date" => time(), "type" => 1, "text" => $notification, "isread" => 0, "data" => "groupid:" . strval($valuein)];
        $connection->AddItemtoList($pdo, 1, $targetid, "groups_pending", $params, "data");
        $connection->AddNewtoList($pdo, 1, $targetid, "notification_raw", 1);
    } elseif ($type == 2) {
        //Notify that a person has accepted/denied your group join request
        $check = $connection->ListCheck($pdo, 0, $valuein, "people_accepted", $targetid);
        //Check person is still inside group
        if ($check) {
            if ($decision) {
                $notification = strtok($connection->GetNamebyId($pdo, $starterid, 0), " ") . ' accepted your invitation to join ';
            } else {
                $notification = strtok($connection->GetNamebyId($pdo, $starterid, 0), " ") . ' declined your invitation to join ';
            }
            $params = ["sourceid" => $starterid, "date" => time(), "type" => 2, "text" => $notification, "isread" => 0, "data" => "groupid:" . strval($valuein)];
            $connection->AddItemtoList($pdo, 1, $targetid, "groups_decision", $params, "data");
            $connection->AddNewtoList($pdo, 1, $targetid, "notification_raw", 2);
        }
    } elseif ($type == 3) {
        //Notify that a person has been made a group admin
        $groupname = $connection->GetNamebyId($pdo, $valuein, 1);
        $notification = "You have been made the admin of '{$groupname}'";
    } elseif ($type == 4) {
    }
}
Пример #2
0
}
if (array_key_exists('accepted', $_POST)) {
    $accepted = boolval(filter_input(INPUT_POST, 'accepted'));
} else {
    $safe = false;
}
if (array_key_exists('token', $_POST)) {
    $token = filter_input(INPUT_POST, 'token');
} else {
    $safe = false;
}
if ($safe) {
    $authenticated = $connection->Verify($connectinfo, $profid, $token);
    if ($authenticated) {
        //Do only if user has notification
        $check = $connection->ListCheck($connectinfo, 1, $profid, "groups_pending", $groupid);
        $checkdeclined = $connection->ListCheck($connectinfo, 2, $profid, "groups_declined", $groupid);
        $checkleft = $connection->ListCheck($connectinfo, 2, $profid, "groups_left", $groupid);
        if ($check == true || $checkdeclined == true || $checkleft == true) {
            $targetvalues = $connection->GetValue($connectinfo, 0, $groupid, "people_added");
            $targetvaluesarray = unserialize($targetvalues);
            $targetid = ReturnTargetID($targetvaluesarray, $profid);
            $connection->RemoveItemfromList($connectinfo, 1, $profid, "groups_pending", "groupid:" . strval($groupid), "data");
            if ($accepted) {
                //Add on to people accepted
                $connection->AddtoList($connectinfo, 0, $groupid, "people_accepted", $profid);
                //Add to group list of accepted friends
                $connection->AddtoList($connectinfo, 2, $profid, "groups_accepted", $groupid);
                //Add to profile list of accepted groups
                //(Notify group inviter that a new user has accepted group request?
                if ($checkdeclined == false && $checkleft == false) {
Пример #3
0
}
if (array_key_exists('id', $_POST)) {
    $idarray = filter_input(INPUT_POST, 'id', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY);
    if (count($idarray) < 1) {
        $safe = false;
    } else {
        $idstring = implode(';', $idarray);
    }
} else {
    $safe = false;
}
if ($safe) {
    $authenticated = $connection->Verify($connectinfo, $profid, $token);
    if ($authenticated) {
        //Do only if user is part of group & Group exists
        $check = $connection->ListCheck($connectinfo, 0, $groupid, "people_accepted", $profid);
        $groupexists = $connectinfo->prepare("SELECT id from Groups where id = :groupid");
        $groupexists->execute(array(':groupid' => $groupid));
        //Check if users supplied aren't already invited (Method below performs delete)
        $idtodelete = array();
        foreach ($idarray as $id) {
            $checkinvite = $connection->ListCheck($connectinfo, 0, $groupid, "people_requested", $id);
            //Requested (invited) people check
            if ($checkinvite) {
                $idtodelete[] = $id;
            }
        }
        foreach ($idtodelete as $key) {
            $keyToDelete = array_search($key, $idarray);
            unset($idarray[$keyToDelete]);
        }