Example #1
0
 public function __construct($name = null, $wardID = 0, $preset = false)
 {
     if (!$name || strlen(trim($name)) == 0 || !$wardID) {
         return;
     }
     if (!Ward::Load($wardID)) {
         fail("Could not create calling because the ward ID passed in is invalid.");
     }
     $this->Name = strip_tags($name);
     $this->Preset = $preset;
     $this->WardID = $wardID;
     $this->Save();
 }
Example #2
0
 public function Save()
 {
     // The ward ID and question content is required!
     if (!$this->WardID || !trim($this->Question)) {
         fail("ERROR > Cannot save this question without a ward ID and question text.");
     }
     if (!Ward::Load($this->WardID)) {
         fail("ERROR > Cannot save question \"" . $this->Question . "\" because the ward ID (" . $this->WardID . ") is found to be invalid.");
     }
     // Make sure the question is unique
     $safeQ = DB::Safe($this->Question);
     $q = "SELECT 1 FROM SurveyQuestions WHERE Question='{$safeQ}' AND WardID='{$this->WardID}' AND ID!='{$this->ID}' LIMIT 1";
     if (mysql_num_rows(DB::Run($q)) > 0) {
         fail("Oops. Could not save question; that question already exists in this ward.");
     }
     $q = DB::BuildSaveQuery($this, get_object_vars($this));
     $r = DB::Run($q);
     if (!$this->ID) {
         $this->ID = mysql_insert_id();
     }
     return $r ? true : false;
 }
Example #3
0
@($city = $_POST['city']);
@($state = $_POST['state']);
@($zipcode = $_POST['zipcode']);
@($phone = trim($_POST['phone']));
@($hidePhone = isset($_POST['hidePhone']) ? 1 : 0);
@($receiveSms = isset($_POST['receiveSms']) ? 1 : 0);
@($address = trim($_POST['address']));
@($pic = $_FILES['profilepic']);
$isChangingWards = $WARD->ID() != $wardid && $wardid > 0;
// Required fields filled out?
if (!$email || !$fname || !$lname || !$gender || !$resID || !$dob || $isChangingWards && !$wardpwd) {
    Response::Send(400, "Please fill out all required fields.");
}
// If changing wards, make sure ward password is correct
if ($isChangingWards) {
    $newWard = Ward::Load($wardid);
    if ($newWard != null && !$newWard->PasswordMatches($wardpwd)) {
        Response::Send(401, "Your new ward's password is incorrect. Please make sure you typed the ward password correctly.");
    }
}
$newResIsCustom = $resID == "-";
// Make sure necessary Residence information is filled out
if (!$newResIsCustom && !$aptnum) {
    Response::Send(400, "Oops - could you please fill out your apartment number? We need that. Thanks!");
}
if ($newResIsCustom && (!$address || !$streetAddress || !$city || !$state || !$zipcode)) {
    Response::Send(400, "Oops - could you please type your full address and click the little check-mark to verify it? We'll need to know where you live.");
}
// Passwords match?
if ($pwd1 && $pwd2 && $pwd1 != $pwd2 || $pwd1 && !$pwd2) {
    Response::Send(400, "Oops! Your passwords don't match. Please make sure they're the same in order to change your password.");
Example #4
0
 public function ChangeWard($wardid)
 {
     if (dayDifference($this->RegistrationDate) < 7) {
         fail("Cannot change wards within 7 days of being in a new ward.");
     }
     $new_ward = Ward::Load($wardid);
     if (!$new_ward) {
         fail("Could not change ward: ward ID {$wardid} not valid.");
     }
     $this->DeleteWardItems();
     $this->WardID = $wardid;
     $this->RegistrationDate = now();
     $this->LastUpdated = 0;
     $this->Save();
 }
Example #5
0
    echo 'selected';
}
?>
>Select a ward</option>
<?php 
foreach ($stakes as $sid => $wards) {
    $stakeObj = Stake::Load($sid);
    ?>
	<optgroup label="<?php 
    echo $stakeObj->Name;
    ?>
">
<?php 
    foreach ($wards as $wid) {
        // Get the bishop's name, if any.
        $ward = Ward::Load($wid);
        $bishop = $ward->GetBishop();
        ?>
		<option value="<?php 
        echo $wid;
        ?>
"<?php 
        if (isset($WARD) && $WARD->ID() == $wid) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $ward->Name;
        if ($bishop) {
            echo " (Bishop " . $bishop->LastName . ")";
        }
Example #6
0
<?php

require_once "../lib/init.php";
protectPage(0, true);
// This file allows a stake leader (ONLY) to change current wards.
@($id = trim($_GET['id']));
if (!$LEADER || !$id) {
    // User is not a stake leader or no ward ID was specified
    header("Location: /");
    exit;
}
$ward = Ward::Load($id);
if (!$ward || $ward->StakeID() != $LEADER->StakeID) {
    // Bad ward ID or ward is not in this leader's stake
    header("Location: /");
    exit;
}
if ($ward->Deleted) {
    fail("That ward is no longer available on this site.");
}
// Set new ward ID
$_SESSION['wardID'] = $id;
// Redirect.
header("Location: /directory");
Example #7
0
// Keep users logged in for a month... TODO: This doesn't work??
$SESSION_LIFETIME = 60 * 60 * 24 * 30;
session_set_cookie_params($SESSION_LIFETIME);
ini_set('session.gc_maxlifetime', $SESSION_LIFETIME);
// Start session... we'll need it
session_start();
require_once "common.php";
// Open a persistent connection to the database
$DB = new DB();
// If the user is logged in, update last activity.
// They could be a leader or a regular member.
$MEMBER = Member::Current();
$LEADER = null;
$WARD = null;
if ($MEMBER) {
    $MEMBER->UpdateLastActivity();
} else {
    $LEADER = StakeLeader::Current();
    if ($LEADER) {
        $LEADER->UpdateLastActivity();
    }
}
if ($MEMBER) {
    $WARD = Ward::Load($MEMBER->WardID);
} else {
    if ($LEADER) {
        $WARD = Ward::Load($_SESSION['wardID']);
    }
}
$USER = $MEMBER ? $MEMBER : $LEADER;
define('IS_MOBILE', isMobile());
Example #8
0
<?php

require_once "../lib/init.php";
// Returns 200 OK if the submitted password
// is a correct ward/password combination.
// Also sets the ward_id session variable.
// A successful result should let the user
// proceed to registration.
@($wardID = $_POST['ward_id']);
@($pwd = trim($_POST['pwd']));
$ward = Ward::Load($wardID);
if (!$ward) {
    Response::Send(404, "Please choose a ward. If you did, contact your ward website person.");
}
if (!$ward->PasswordMatches($pwd)) {
    Response::Send(401, "Wrong ward/password combination. Please try again!");
}
// If they get to this point, successful authentication. A-OK.
$_SESSION['ward_id'] = $ward->ID();
Response::Send(200);
Example #9
0
$m->Email = $email;
$m->HideEmail = $hideEmail;
$m->Gender = $gender;
$m->SetPassword($pwd1);
$m->PhoneNumber = $phone;
$m->HidePhone = $hidePhone;
$m->Birthday = sqldate($dob);
$m->HideBirthday = $hideBirthday;
$m->ReceiveEmails = true;
$m->ReceiveTexts = true;
// Fill out housing/Residence info
if (!$resIsCustom) {
    $m->ResidenceID = $resID;
    $m->Apartment = strtoupper(preg_replace("/[^A-Za-z0-9 ]/", '', $aptnum));
} else {
    $ward = Ward::Load($_SESSION['ward_id']);
    $newRes = $ward->AddResidence("", $streetAddress, $city, $state, $zipcode, true);
    $m->ResidenceID = $newRes->ID();
    $m->Apartment = "";
}
// Pull the trigger: save the account.
// (Profile picture upload DOES happen; look down)
$m->Save();
// No need to 'register' anymore.
unset($_SESSION['ward_id']);
// Log member in so the survey can be filled out
$m->Login($email, $pwd1);
// Trigger to tell the user on the next page
// that they aren't done yet...!
// (Do this before the profile picture in case there's problems)
$_SESSION['isNew'] = true;