Example #1
0
} else {
    // ... and they still have a custom residence...
    if ($newResIsCustom) {
        // ... delete the old one and replace it with the new one, only if it's different.
        if ($streetAddress != $res->Address || $city != $res->City || $state != $res->State || $zipcode != $res->PostalCode) {
            $res->Delete(true);
            setNewCustomResidence($MEMBER, $WARD, $streetAddress, $city, $state, $zipcode);
        }
    } else {
        // If the new Residence is regular, delete the old custom one and fill the regular values
        $res->Delete(true);
        setNewRegularResidence($MEMBER, $resID, $aptnum);
    }
}
// Pull the trigger: save the account changes
// (Profile picture upload DOES happen; look down)
$MEMBER->Save(true);
// Now upload and save the profile picture...
if ($pic['tmp_name'] && !$pic['error']) {
    $MEMBER->PictureFile(false, $pic);
} else {
    if ($pic['error']) {
        Response::Send(413, "Saved your profile, except your picture is too large. Maximum size: " . ini_get('upload_max_filesize') . "B");
    }
}
if ($isChangingWards) {
    $MEMBER->ChangeWard($wardid);
    Response::Send(200, "Saved your profile and switched wards!");
} else {
    Response::Send(200, "Saved your profile!");
}
Example #2
0
<?php

require_once "../../lib/init.php";
protectPage(9);
@($id = DB::Safe($_GET['id']));
// Verify...
if (!$id) {
    fail("Could not delete permission; please specify a valid ID.");
}
// Load the permission and make sure it belongs in the ward
$p = Permission::Load($id);
if (!$p->InWard($MEMBER->WardID)) {
    fail("That permission is not within your own ward...");
}
// Delete this permission.
$p->Delete(true);
Response::Send(200);
Example #3
0
    // If NOT required, set to empty value if not filled out
    if (!$reqQu->Required && (!$userAns || !is_array($userAns) && strlen(trim($userAns)) == 0 || $userAns == ' ')) {
        // First we have to get it from the DB.
        $ansObj = $reqQu->Answers($memID);
        // TODO: FIX THIS:
        // I added this if statement because this block was causing errors
        // in the error log (a lot of them):
        // [06-Jan-2012 10:54:59] PHP Fatal error: Call to undefined method stdClass::Save() in /home5/ysatwoze/public_html/save.php on line 157
        // ($ansObj->Save() used to be on line 157). It appears that $ansObj
        // was null or a empty class or something... (a "standard" class)
        // NOTE: That happens when the member has not answered the question.
        if (isset($ansObj) && get_class($ansObj) == "SurveyAnswer") {
            $ansObj->AnswerValue = '';
            $ansObj->Save();
        }
    }
}
// Update the user's LastUpdated timestamp.
// It's not super-critical, so suppress any errors.
$MEMBER->Save(true);
// 200 OK (we're done here)
if (isset($_SESSION['isNew'])) {
    // Member is no longer a "new" member... (registration complete)
    // ** IMPORTANT NOTE ** Do not change the text of this response as the receiving
    // Javascript relies on its contents to know to redirect. Specifically: "Welcome" (case-sensitive)
    // That's lame, I know, but it works and I like cheese.
    unset($_SESSION['isNew']);
    Response::Send(200, "Thank you for signing up. Welcome to the ward!<br><br>Redirecting you...");
} else {
    Response::Send(200, "Saved your survey answers");
}
<?php

require_once "../lib/init.php";
protectPage();
$m = Member::Current();
Response::Send(200, $m->PictureFile());
Example #5
0
$ansEmpty = true;
if ($ansArray) {
    foreach ($ansArray as &$opt) {
        $opt = trim($opt);
        if ($opt != '') {
            $ansEmpty = false;
            break;
        }
    }
}
// Is this question designed to have answer choices/options?
$multAns = $qtype == QuestionType::MultipleChoice || $qtype == QuestionType::MultipleAnswer;
// Make sure that multiple-answer/choice questions have at least one
// to choose from
if ($multAns && $ansEmpty) {
    Response::Send(401, "Oops - for that type of question, it requires at least one possible answer (you have to add one). Go BACK and try again.");
}
// Create question.
$qu = new SurveyQuestion();
$qu->Question = $question;
$qu->QuestionType = $qtype;
$qu->Required = $req;
$qu->Visible = $visible;
$qu->WardID = $MEMBER->WardID;
// Save what we have (it needs an ID in order to add answer options)
if (!$qu->Save()) {
    fail("Could not save this question. Please report this and try again...");
}
// Add answer options, if applicable
if ($multAns) {
    foreach ($ansArray as $ans) {
Example #6
0
<?php

require_once "../../lib/init.php";
protectPage(12);
// Grab the variables from the form
@($memberID = $_GET['member']);
if (!$memberID) {
    fail("No member was specified; nothing to do.");
}
$mem = Member::Load($memberID);
if (!$mem) {
    fail("Could not load member with ID " . $memberID . " - please report this.");
}
if ($mem->WardID != $MEMBER->WardID) {
    fail("Member " . $memberID . " is not in your ward.");
}
if ($mem->DeletePictureFile()) {
    Response::Send(200, $memberID);
} else {
    fail("Could not delete profile picture, probably because the user doesn't have a picture, or it is already the default one.");
}
Example #7
0
<?php

require_once "../../lib/init.php";
protectPage(12);
@($memID = $_GET['member']);
@($thumb = $_GET['thumbnail']);
if (!$memID) {
    fail("No member specified");
}
$m = Member::Load($memID);
if (!$m) {
    fail("Could not load member with ID " . $memID);
}
if ($m->WardID != $MEMBER->WardID) {
    fail("Member is not in your ward");
}
Response::Send(200, $m->PictureFile($thumb));
Example #8
0
    for ($i = 1; $i <= 3; $i++) {
        DB::Run("UPDATE FheGroups SET Leader{$i}=0 WHERE Leader{$i}='{$ldr1}' OR Leader{$i}='{$ldr2}' OR Leader{$i}='{$ldr3}'");
    }
    // Make assignments, but don't save changes yet.
    $group->GroupName = $_POST['groupname'];
    $group->Leader1 = $_POST['ldr1'];
    $group->Leader2 = $_POST['ldr2'];
    $group->Leader3 = $_POST['ldr3'];
    // Move the leaders into their new groups
    if ($group->Leader1 > 0) {
        $mem = Member::Load($group->Leader1);
        $mem->FheGroup = $id;
        $mem->Save();
    }
    if ($group->Leader2 > 0) {
        $mem = Member::Load($group->Leader2);
        $mem->FheGroup = $id;
        $mem->Save();
    }
    if ($group->Leader3 > 0) {
        $mem = Member::Load($group->Leader3);
        $mem->FheGroup = $id;
        $mem->Save();
    }
    if ($group->ConsolidateLeaders()) {
        // Persists the object in the DB
        Response::Send(200);
    } else {
        Response::Send(500, "Something went wrong; could not save group...");
    }
}
Example #9
0
<?php

require_once "../../lib/init.php";
protectPage(13);
@($year = $_POST['year']);
@($month = $_POST['month']);
@($day = $_POST['day']);
@($msg = $_POST['msg']);
if (!$year || !$month || !$day) {
    Response::Send(400, "Please select a month, day, and year to terminate accounts");
}
// Make sure date is far enough in the future (at least 24 hours -- not 1 day, but 24 hours)
exit;
Example #10
0
<?php

require_once "../lib/init.php";
@($eml = trim($_POST['eml']));
@($pwd = trim($_POST['pwd']));
// Login; returns null if bad credentials.
// First see if they're a regular member...
$m = Member::Login($eml, $pwd);
// Where to potentially redirect the member after login
$afterLogin = isset($_SESSION['after_login']) ? $_SESSION['after_login'] : "******";
if (!$m) {
    // No? Maybe a stake leader?
    $s = StakeLeader::Login($eml, $pwd);
    if (!$s) {
        Response::Send(400);
    } else {
        // Choose the first ward in the stake... alphabetically I guess... as default view for them.
        $r = mysql_fetch_array(DB::Run("SELECT ID FROM Wards WHERE StakeID='{$s->StakeID}' AND Deleted != 1 ORDER BY Name ASC LIMIT 1"));
        $_SESSION['wardID'] = $r['ID'];
        // Stake leader logged in.
        Response::Send(200, $afterLogin);
    }
} else {
    Response::Send(200, $afterLogin);
}
Example #11
0
<?php

require_once "../../lib/init.php";
protectPage(13);
@($users = $_POST['users']);
if (!isset($users) || !count($users)) {
    Response::Send(400, "You must specify at least one account to delete.");
}
$mems = array();
foreach ($users as $id) {
    $mem = Member::Load($id);
    if (!$mem) {
        fail("ERROR > User with ID {$id} couldn't be loaded. Are you sure the account exists? Aborting.");
    }
    if ($mem->ID() == $MEMBER->ID()) {
        fail("ERROR > You can't delete your own account");
    }
    if ($mem->WardID != $MEMBER->WardID) {
        fail("ERROR > You can only delete accounts of members in your own ward. User with ID {$mem->ID()} is not in your ward.");
    }
    $mems[] = $mem;
}
foreach ($mems as $mem) {
    if (!$mem->Delete(true)) {
        fail("Could not delete member with ID {$mem->ID()}... but all others before him/her were deleted.");
    }
}
header("Location: ../prune.php?success=true");
Example #12
0
function fail($msg)
{
    Response::Send(500, $msg);
}
Example #13
0
<?php

require_once "../../lib/init.php";
protectPage(11);
@($name = $_POST['name']);
if (!$name || strlen(trim($name)) < 2) {
    fail("Please submit a valid name for this calling.");
}
$c = new Calling($name, $MEMBER->WardID);
if ($c->Save()) {
    Response::Send(200, $c->ID());
} else {
    fail("Something bad happened... hmm...");
}