Ejemplo n.º 1
0
					</form>
					<br>

					<h2 id="by-calling">Privileges granted to callings</h2>

					<table class="privList">
						<tr>
							<th>Calling</th>
							<th>Privilege</th>
							<th>Options</th>
						</tr>
					<?php 
$rm = DB::Run("SELECT CallingID, PrivilegeID FROM GrantedPrivileges INNER JOIN Callings ON Callings.ID = CallingID INNER JOIN Privileges ON Privileges.ID = GrantedPrivileges.PrivilegeID WHERE CallingID > 0 AND Callings.WardID={$MEMBER->WardID} ORDER BY Callings.Name ASC, Privileges.Privilege ASC");
while ($row = mysql_fetch_array($rm)) {
    $priv = Privilege::Load($row['PrivilegeID']);
    $call = Calling::Load($row['CallingID']);
    ?>
						<tr>
							<td>
								<b><?php 
    echo $call->Name;
    ?>
</b>
							</td>
							<td>
								<span title="<?php 
    echo $priv->HelpText();
    ?>
"><?php 
    echo $priv->Privilege();
Ejemplo n.º 2
0
 public static function Create($name, $stakeID, $rawPwd)
 {
     if (!strlen(trim($name)) || !$stakeID || !strlen(trim($rawPwd))) {
         fail("Cannot create a ward without a name, stake ID, and password (and residences are strongly recommended, if possible).");
     }
     if (!Stake::Load($stakeID)) {
         fail("Could not create ward because stake ID was found to be invalid.");
     }
     $ward = new Ward();
     $ward->Name = strip_tags($name);
     $ward->StakeID = $stakeID;
     $ward->Salt = salt();
     $ward->Password = hashPwd($rawPwd, $ward->Salt);
     $ward->Balance = 2.5;
     $ward->Deleted = false;
     if (!$ward->Save()) {
         return null;
     }
     // Set up pre-defined callings, privileges, permissions, and a sample survey question or two.
     $callings = array();
     $callings[1] = new Calling("Bishop", $ward->ID, true);
     $callings[2] = new Calling("Bishopric 1st Counselor", $ward->ID, true);
     $callings[3] = new Calling("Bishopric 2nd Counselor", $ward->ID, true);
     $callings[4] = new Calling("Executive Secretary", $ward->ID, true);
     $callings[5] = new Calling("Elders Quorum President", $ward->ID, true);
     $callings[6] = new Calling("Elders Quorum 1st Counselor", $ward->ID, true);
     $callings[7] = new Calling("Elders Quorum 2nd Counselor", $ward->ID, true);
     $callings[8] = new Calling("Elders Quorum Secretary", $ward->ID, true);
     $callings[9] = new Calling("Relief Society President", $ward->ID, true);
     $callings[10] = new Calling("Relief Society 1st Counselor", $ward->ID, true);
     $callings[11] = new Calling("Relief Society 2nd Counselor", $ward->ID, true);
     $callings[12] = new Calling("Relief Society Secretary", $ward->ID, true);
     $callings[13] = new Calling("Ward Clerk", $ward->ID, true);
     $callings[14] = new Calling("Membership Clerk", $ward->ID, true);
     foreach ($callings as $c) {
         $c->Save();
     }
     // Save each calling
     // Compile an array of each privilege in the database; currently, we have IDs 1 through 13
     $privileges = array();
     $priv_count = mysql_fetch_row(DB::Run("SELECT COUNT(1) FROM Privileges"))[0];
     for ($i = 1; $i <= $priv_count; $i++) {
         $privileges[$i] = Privilege::Load($i);
     }
     // Bishopric (excluding executive secretary) can mass email all ward members,
     // see everything in the export file, and manage privileges, and send texts
     for ($i = 1; $i <= 3; $i++) {
         $privileges[PRIV_EMAIL_ALL]->GrantToCalling($callings[$i]->ID());
         $privileges[PRIV_EXPORT_EMAIL]->GrantToCalling($callings[$i]->ID());
         $privileges[PRIV_EXPORT_PHONE]->GrantToCalling($callings[$i]->ID());
         $privileges[PRIV_EXPORT_BDATE]->GrantToCalling($callings[$i]->ID());
         $privileges[PRIV_MNG_SITE_PRIV]->GrantToCalling($callings[$i]->ID());
         $privileges[PRIV_TEXT_ALL]->GrantToCalling($callings[$i]->ID());
     }
     // Executive secretary gets all privileges (except redundant ones 2 and 3 - mass email brothers/sisters)
     for ($i = PRIV_EMAIL_ALL; $i <= PRIV_TEXT_ALL; $i++) {
         if ($i != PRIV_EMAIL_BRO && $i != PRIV_EMAIL_SIS) {
             $privileges[$i]->GrantToCalling($callings[4]->ID());
         }
     }
     // EQ presidency gets to mass-email all brothers
     for ($i = 5; $i <= 8; $i++) {
         $privileges[PRIV_EMAIL_BRO]->GrantToCalling($callings[$i]->ID());
     }
     // The EQ president needs to see more in the export file
     $privileges[PRIV_EXPORT_EMAIL]->GrantToCalling($callings[5]->ID());
     $privileges[PRIV_EXPORT_PHONE]->GrantToCalling($callings[5]->ID());
     $privileges[PRIV_EXPORT_BDATE]->GrantToCalling($callings[5]->ID());
     // RS presidency gets to mass-email all sisters
     for ($i = 9; $i <= 12; $i++) {
         $privileges[PRIV_EMAIL_SIS]->GrantToCalling($callings[$i]->ID());
     }
     // RS president can see more in the export file, too
     $privileges[PRIV_EXPORT_EMAIL]->GrantToCalling($callings[9]->ID());
     $privileges[PRIV_EXPORT_PHONE]->GrantToCalling($callings[9]->ID());
     $privileges[PRIV_EXPORT_BDATE]->GrantToCalling($callings[9]->ID());
     // Ward clerks can see all info in export file and manage site privileges
     $privileges[PRIV_EXPORT_EMAIL]->GrantToCalling($callings[13]->ID());
     $privileges[PRIV_EXPORT_PHONE]->GrantToCalling($callings[13]->ID());
     $privileges[PRIV_EXPORT_BDATE]->GrantToCalling($callings[13]->ID());
     $privileges[PRIV_MNG_SITE_PRIV]->GrantToCalling($callings[13]->ID());
     // Membership clerks needs to see all info in export file, and can
     // manage callings, profile pictures, and delete accounts
     $privileges[PRIV_EXPORT_EMAIL]->GrantToCalling($callings[14]->ID());
     $privileges[PRIV_EXPORT_PHONE]->GrantToCalling($callings[14]->ID());
     $privileges[PRIV_EXPORT_BDATE]->GrantToCalling($callings[14]->ID());
     $privileges[PRIV_MNG_CALLINGS]->GrantToCalling($callings[14]->ID());
     $privileges[PRIV_MNG_PROFILE_PICS]->GrantToCalling($callings[14]->ID());
     $privileges[PRIV_DELETE_ACCTS]->GrantToCalling($callings[14]->ID());
     // --------------------------------------------------- //
     // Create a sample/starter question.
     $qu = new SurveyQuestion();
     $qu->Question = "Welcome to the singles ward! Do you prefer blue, brown, or green eyes?";
     $qu->QuestionType = QuestionType::MultipleChoice;
     $qu->Required = false;
     $qu->Visible = true;
     $qu->WardID = $ward->ID();
     $qu->Save();
     $qu->AddAnswerOption("Brown eyes");
     $qu->AddAnswerOption("Blue eyes");
     $qu->AddAnswerOption("Green eyes");
     // Let a few people see it: Bishop, Exec. Sec, EQP, and RSP
     $p = new Permission();
     $p->QuestionID($qu->ID());
     $p->Allow($callings[1]->ID(), "Calling", true);
     $p->Allow($callings[4]->ID(), "Calling", true);
     $p->Allow($callings[5]->ID(), "Calling", true);
     $p->Allow($callings[9]->ID(), "Calling", true);
     // I think we're all done here!
     return $ward;
 }
Ejemplo n.º 3
0
        }
    }
} elseif (sizeof($_GET) > 0) {
    @($action = $_GET['action']);
    @($privID = $_GET['id']);
    @($m = $_GET['m']);
    @($c = $_GET['c']);
    if ($action == "revoke") {
        // Revoke this privilege
        if (!$privID) {
            fail("Need a privilege ID to revoke; cannot revoke no privilege!");
        }
        if ($m && $c || !$m && !$c) {
            fail("Please choose a member or a calling to revoke from.");
        }
        $priv = Privilege::Load($privID);
        if ($privID == 10) {
            // 10 is Manage Site Privileges; at least one member or calling from the ward should always have this.
            // This query gets a list of unique privileges.
            $epicQuery = "SELECT GrantedPrivileges.ID, Members.WardID FROM GrantedPrivileges\n\t\t\t\t\t\tINNER JOIN Members ON Members.ID = GrantedPrivileges.MemberID\n\t\t\t\t\t\tWHERE WardID = {$MEMBER->WardID} AND GrantedPrivileges.PrivilegeID = 10\n\t\t\t\t\t\tUNION\n\t\t\t\t\t\tSELECT GrantedPrivileges.ID, Callings.WardID FROM GrantedPrivileges\n\t\t\t\t\t\tINNER JOIN Callings ON Callings.ID = GrantedPrivileges.CallingID\n\t\t\t\t\t\tWHERE WardID = {$MEMBER->WardID} AND GrantedPrivileges.PrivilegeID = 10;";
            if (mysql_num_rows(DB::Run($epicQuery)) == 1) {
                fail("At least one member or calling of your ward must be able to manage the site privileges. This was the last one; could not revoke.");
            }
        }
        if ($m) {
            $mem = Member::Load($m);
            if ($mem->WardID != $MEMBER->WardID) {
                fail("You can only revoke privileges from members of your ward.");
            } else {
                $priv->RevokeFromMember($m);
            }