コード例 #1
0
ファイル: group_add.php プロジェクト: 96imranahmed/Eventory
        foreach ($idtodelete as $key) {
            $keyToDelete = array_search($key, $idarray);
            unset($idarray[$keyToDelete]);
        }
        //ID's deleted
        if (count($idarray) < 1) {
            echo "Error - all the people invited were duplicates";
        } else {
            if ($check && $groupexists->rowCount() > 0) {
                $currentarray = [];
                $currentarray[$profid] = $idarray;
                $current = serialize($currentarray);
                $postsql = $connectinfo->prepare("UPDATE Groups SET people_added = :current WHERE id = :groupid");
                $postsql->execute(array(':current' => $current, ':groupid' => $groupid));
                foreach ($idarray as $id) {
                    CreateNotification(1, $connectinfo, $id, $profid, $groupid);
                    //Send them a notification
                    $connection->AddtoList($connectinfo, 0, $groupid, "people_requested", $id);
                }
            } else {
                if ($check) {
                    echo "Error - group doesn't exist";
                } else {
                    echo "Error - original user was not a part of this group";
                }
            }
        }
    } else {
        echo "Error - authorization mismatch";
    }
} else {
コード例 #2
0
                    if ($checkleft) {
                        $connection->RemovefromList($connectinfo, 2, $profid, "groups_left", $groupid);
                    }
                    if ($checkdeclined) {
                        $connection->RemovefromList($connectinfo, 2, $profid, "groups_declined", $groupid);
                    }
                }
            } else {
                if ($check == true && $checkdeclined == false && $checkleft == false) {
                    //Add on to people declined
                    $connection->AddtoList($connectinfo, 2, $profid, "groups_declined", $groupid);
                    //Add to profile list of declined group
                    $connection->RemoveItemfromList($connectinfo, 1, $profid, "groups_pending", "groupid:" . strval($groupid), "data");
                    //Clear "pending" notification
                    //(Notify group inviter that a new user has declined group request?)
                    CreateNotification(2, $connectinfo, $targetid, $profid, $groupid, FALSE);
                }
            }
        } else {
            $check = $connection->ListCheck($connectinfo, 0, $groupid, "people_accepted", $profid);
            if ($check) {
                echo "Error - user is already in group";
            } else {
                echo "Error - user wasn't invited to this group";
            }
        }
    } else {
        echo "Error - authorization mismatch";
    }
} else {
    echo "Error - invalid supplied post data (not enough info?)";
コード例 #3
0
        try {
            $starter = $idarray[0];
            $starterid = intval($starter);
            $prepsql = $connectinfo->prepare("INSERT INTO `Groups` (`name`, `people_requested`, `people_accepted`, `starter`) VALUES (:name,:idstring,:starter,:starterid)");
            $prepsql->execute(array(':name' => $name, ':idstring' => $idstring, 'starter' => $starter, ':starterid' => $starterid));
            $groupid = $connectinfo->lastInsertId();
            echo $groupid;
            //Add group to thread starter's list of groups
            $connection->AddtoList($connectinfo, 2, $starter, "groups_accepted", $groupid);
            //Notify users of new group
            array_shift($idarray);
            //Knock thread starter off!
            $added = array($starter => $idarray);
            //Setup added list
            $addedstring = serialize($added);
            $postsql = $connectinfo->prepare("UPDATE Groups SET people_added = :addedstring WHERE id = :groupid");
            $postsql->execute(array(':addedstring' => $addedstring, ':groupid' => $groupid));
            foreach ($idarray as $id) {
                $params = ["groupid" => $groupid, "sourceid" => $profid, "date" => time()];
                //Add to notifications for that particular id
                CreateNotification(1, $connectinfo, $id, $starter, $groupid);
            }
        } catch (PDOException $e) {
            echo 'Error ' . $e->GetMessage();
        }
    } else {
        echo "Error - authorization mismatch";
    }
} else {
    echo 'Error - invalid supplied post data (not enough info?)';
}