本文整理汇总了PHP中Person::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Person::setValue方法的具体用法?PHP Person::setValue怎么用?PHP Person::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Person
的用法示例。
在下文中一共展示了Person::setValue方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: printFormSequential
private function printFormSequential()
{
$cancelURL = build_url(array('*' => NULL, 'view' => 'attendance__record', 'cohortids' => $this->_cohortids, 'attendance_date' => $this->_attendance_date, 'release' => 1));
$totalPrinted = 0;
foreach ($this->_record_sets as $i => $set) {
if ((int) $set->congregationid) {
$congregation = $GLOBALS['system']->getDBObject('congregation', (int) $set->congregationid);
} else {
if ($set->groupid) {
$group =& $GLOBALS['system']->getDBObject('person_group', $set->groupid);
} else {
return;
}
}
$title = $set->getCohortName();
$stats = $abs = array();
if ($set->statuses) {
$options = Attendance_Record_Set::getStatusOptions();
foreach ($set->statuses as $s) {
$stats[] = $options[$s];
}
}
if ($set->age_brackets) {
$GLOBALS['system']->includeDBClass('person');
$p = new Person();
foreach ($set->age_brackets as $ab) {
$p->setValue('age_bracket', $ab);
$abs[] = $p->getFormattedValue('age_bracket');
}
}
$title = implode(', ', $stats) . ' ' . implode(',', $abs) . ' in ' . $title;
?>
<h3><?php
echo ents($title);
?>
</h3>
<div class="width-really-auto form-inline">
<?php
$setPrinted = $set->printForm($i);
if ($setPrinted > 0) {
$totalPrinted += $setPrinted;
?>
<div class="container row-fluid control-group">
<p class="span6">
<?php
echo _('Total headcount:');
?>
<?php
$set->printHeadcountField();
?>
</p>
<p class="span6 align-right nowrap">
<input type="submit" class="btn" value="Save All Attendances" />
<a href="<?php
echo $cancelURL;
?>
" class="btn">Cancel</a>
</p>
</div>
<?php
} else {
?>
<i><?php
echo _('(No persons in this listing)');
?>
</i>
<?php
}
?>
</div>
<?php
}
return $totalPrinted;
}
示例2: save
function save($update_members = TRUE)
{
$msg = '';
if ($update_members) {
if (!empty($this->_old_values['status'])) {
if ($this->getValue('status') == 'archived') {
// Status has just been changed to 'archived' so archive members too
$members = $this->getMemberData();
if (!empty($members)) {
$GLOBALS['system']->includeDBClass('person');
$member = new Person();
$all_members_archived = TRUE;
foreach ($members as $id => $details) {
$member->populate($id, $details);
if ($member->canAcquireLock()) {
$member->acquireLock();
$member->setValue('status', 'archived');
$member->save(FALSE);
$member->releaseLock();
} else {
$all_members_archived = FALSE;
}
}
if ($all_members_archived) {
$msg = 'The ' . count($members) . ' members of the family have also been archived';
} else {
$msg = 'Not all members of the family could be accordingly archived because another user holds the lock';
}
}
} else {
if ($this->_old_values['status'] == 'archived') {
// Status has just been changed from archived to something else
$msg = 'NB Members of the family will need to be de-archived separately';
}
}
}
if (!empty($this->_old_values['family_name'])) {
// Family name has changed
// We update all the members' last names to match if
// (a) there is only one member, or
// (b) all members' current last name = the old family name
$members = $this->getMemberData();
if (count($members) == 1) {
$member = $GLOBALS['system']->getDBObject('person', key($members));
if ($member->canAcquireLock()) {
$member->acquireLock();
$member->setValue('last_name', $this->getValue('family_name'));
$member->save(FALSE);
$member->releaseLock();
$msg = 'The last name of the family\'s one member has also been set to "' . $this->getValue('family_name') . '"';
} else {
$msg = 'The family\'s one member could not be updated accordingly because another user holds the lock';
}
} else {
if (!empty($members)) {
$members_all_have_family_name = TRUE;
foreach ($members as $id => $member) {
if ($member['last_name'] != $this->_old_values['family_name']) {
$members_all_have_family_name = FALSE;
break;
}
}
if ($members_all_have_family_name) {
$all_members_updated = TRUE;
$GLOBALS['system']->includeDBClass('person');
$member = new Person();
foreach ($members as $id => $details) {
$member->populate($id, $details);
if ($member->canAcquireLock()) {
$member->acquireLock();
$member->setValue('last_name', $this->getValue('family_name'));
$member->save(FALSE);
$member->releaseLock();
} else {
$all_members_updated = FALSE;
}
}
if ($all_members_updated) {
$msg = 'Each family member\'s last name has also been set to "' . $this->getValue('family_name') . '"';
} else {
$msg = 'Not all family members could be updated with the new last name because another user holds the lock';
}
} else {
$msg = 'Family members have not been updated because they already have different last names';
}
}
}
}
}
$res = parent::save();
if ($msg) {
add_message($msg);
}
return $res;
}
示例3: processView
function processView()
{
$GLOBALS['system']->includeDBClass('family');
$this->_family = new Family();
if (array_get($_REQUEST, 'new_family_submitted')) {
// some initial checks
$i = 0;
$found_member = FALSE;
while (isset($_POST['members_' . $i . '_first_name'])) {
if (!empty($_POST['members_' . $i . '_first_name'])) {
$found_member = TRUE;
}
$i++;
}
if (!$found_member) {
add_message('New family must have at least one member', 'failure');
return FALSE;
}
if ($GLOBALS['user_system']->havePerm(PERM_EDITNOTE)) {
if (REQUIRE_INITIAL_NOTE && empty($_POST['initial_note_subject'])) {
add_message("A subject must be supplied for the initial family note", 'failure');
return FALSE;
}
}
$GLOBALS['system']->doTransaction('begin');
// Create the family record itself
$this->_family->processForm();
$success = $this->_family->create();
if ($success) {
// Add members
$i = 0;
$members = array();
$GLOBALS['system']->includeDBClass('person');
while (isset($_POST['members_' . $i . '_first_name'])) {
if (!empty($_POST['members_' . $i . '_first_name'])) {
$member = new Person();
$member->setValue('familyid', $this->_family->id);
$member->processForm('members_' . $i . '_');
if (!$member->create()) {
$success = FALSE;
break;
}
$members[] =& $member;
}
$i++;
}
}
if ($success) {
if ($GLOBALS['user_system']->havePerm(PERM_EDITNOTE)) {
if (REQUIRE_INITIAL_NOTE || !empty($_POST['initial_note_subject'])) {
// Add note
if (count($members) > 1) {
$GLOBALS['system']->includeDBClass('family_note');
$note = new Family_Note();
$note->setValue('familyid', $this->_family->id);
} else {
$GLOBALS['system']->includeDBClass('person_note');
$note = new Person_Note();
$note->setValue('personid', $members[0]->id);
}
$note->processForm('initial_note_');
$success = $note->create();
}
}
if (!empty($_POST['execute_plan'])) {
foreach ($_POST['execute_plan'] as $planid) {
$plan = $GLOBALS['system']->getDBObject('action_plan', $planid);
$plan->execute('family', $this->_family->id, process_widget('plan_reference_date', array('type' => 'date')));
}
}
}
// Before committing, check for duplicates
if (empty($_REQUEST['override_dup_check'])) {
$this->_similar_families = $this->_family->findSimilarFamilies();
if (!empty($this->_similar_families)) {
$GLOBALS['system']->doTransaction('rollback');
return;
}
}
if ($success) {
$GLOBALS['system']->doTransaction('commit');
add_message('Family Created');
redirect('families', array('familyid' => $this->_family->id));
} else {
$GLOBALS['system']->doTransaction('rollback');
$this->_family->id = 0;
add_message('Error during family creation, family not created', 'failure');
}
}
}
示例4: processView
function processView()
{
$GLOBALS['system']->includeDBClass('family');
$GLOBALS['system']->includeDBClass('person');
$GLOBALS['system']->includeDBClass('person_group');
$GLOBALS['system']->includeDBClass('congregation');
$GLOBALS['system']->includeDBClass('person_note');
if (!empty($_REQUEST['done'])) {
$this->_stage = 'done';
} else {
if (!empty($_POST['confirm_import'])) {
ini_set('memory_limit', '256M');
ini_set('max_execution_time', 60 * 10);
ini_set('zlib.output_compression', 'Off');
// read from session and create
$GLOBALS['system']->doTransaction('BEGIN');
$group = $GLOBALS['system']->getDBObject('person_group', $_SESSION['import']['groupid']);
$this->_captureErrors();
$done = 0;
?>
<h1 style="position: absolute; text-align: center; top: 40%; color: #ccc; width: 100%">Importing...</h1>
<div style="border: 1px solid; width: 50%; height: 30px; top: 50%; left: 25%; position: absolute"><div id="progress" style="background: blue; height: 30px; width: 2%; overflow: visible; line-height: 30px; text-align: center; color: white" /></div>
<p style="text-align: center; color: #888">If this indicator stops making progress, your import may still be running in the background.<br />You should <a href="<?php
echo build_url(array('view' => 'persons__list_all'));
?>
">check your system for the imported persons</a> before running the import again.</p>
<?php
foreach ($_SESSION['import']['families'] as $familydata) {
$members = $familydata['members'];
unset($familydata['members']);
$family = new Family();
$family->populate(0, $familydata);
if ($family->create()) {
foreach ($members as $persondata) {
$notetext = null;
if (!empty($persondata['note'])) {
$notetext = $persondata['note'];
unset($persondata['note']);
}
$person = new Person();
$person->populate(0, $persondata);
$person->setValue('familyid', $family->id);
if ($person->create()) {
$group->addMember($person->id);
if ($notetext) {
$note = new Person_Note();
$note->setValue('subject', 'Import note');
$note->setvalue('details', $notetext);
$note->setValue('personid', $person->id);
$note->create();
unset($note);
}
unset($person);
}
}
$done++;
if ($done % 20 == 0) {
?>
<script>var d = document.getElementById('progress'); d.innerHTML = 'Importing family <?php
echo $done . ' of ' . $_SESSION['import']['total_families'];
?>
'; d.style.width = '<?php
echo (int) ($done / $_SESSION['import']['total_families'] * 100);
?>
%'</script><?php
echo str_repeat(' ', 1024 * 4);
}
flush();
unset($family);
}
}
if ($errors = $this->_getErrors()) {
$msg = 'Errors during import - import aborted. <ul><li>' . implode('</li></li>', $errors) . '</li></ul>';
add_message($msg, 'failure', true);
$GLOBALS['system']->doTransaction('ROLLBACK');
} else {
add_message('Import complete', 'success');
$GLOBALS['system']->doTransaction('COMMIT');
}
?>
<script>document.location = '<?php
echo build_url(array());
?>
&done=1';</script>
<?php
exit;
} else {
if (!empty($_FILES['import'])) {
if (empty($_REQUEST['groupid'])) {
add_message("You must choose a group first", 'error');
$this->stage = 'begin';
return;
}
if (empty($_FILES['import']) || empty($_FILES['import']['tmp_name'])) {
add_message("You must upload a file", 'error');
return;
}
$this->_dummy_family = new Family();
$this->_dummy_person = new Person();
// read the csv and save to session
//.........这里部分代码省略.........
示例5: Person
?>
?view=_edit_group&action=remove_members&groupid=<?php
echo $groupid;
?>
" />
</span>
<div class="bulk-action well" id="update-field">
<table class="valign-middle">
<?php
$dummy = new Person();
foreach (array('congregationid', 'status', 'age_bracket') as $field) {
$dummy->fields[$field]['allow_empty'] = TRUE;
$dummy->fields[$field]['empty_text'] = '(No change)';
$dummy->setValue($field, NULL);
echo '<tr><td>Set ' . $dummy->getFieldLabel($field) . ' to: </td><td>';
$dummy->printFieldInterface($field);
echo '</td></tr>';
}
$customFields = $GLOBALS['system']->getDBObjectData('custom_field', array(), 'OR', 'rank');
$dummy = new Custom_Field();
$addParams = array('type' => 'select', 'options' => array('Replacing existing values ', 'Adding to existing values'));
foreach ($customFields as $fieldid => $fieldDetails) {
$dummy->populate($fieldid, $fieldDetails);
echo '<tr><td>Set ' . ents($dummy->getValue('name')) . ' to: </td><td>';
$dummy->printWidget('');
if ($dummy->getValue('allow_multiple')) {
echo '</td><td>';
print_widget('custom_' . $fieldid . '_add', $addParams, 0);
}
示例6: printForm
function printForm()
{
$GLOBALS['system']->includeDBClass('person_group');
$actions = $this->getValue('actions');
$notes = array_get($actions, 'notes');
if (empty($notes)) {
$notes = array(array());
// 1 blank note to start us off
}
?>
<table class="action-plan">
<tbody>
<tr>
<th>Name</th>
<td><?php
$this->printFieldInterface('name');
?>
</td>
</tr>
<tr>
<th>Notes</th>
<td>
When this plan is executed, add these notes to the person/family:
<table class="expandable">
<?php
foreach ($notes as $i => $note) {
?>
<tr>
<td>
<div class="well">
<?php
$this->_printNoteForm($note, $i);
?>
</div>
</td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<tr>
<th>Groups</th>
<td>
When this plan is executed, <b>add</b> the persons / famiy members to these groups:
<?php
Person_Group::printMultiChooser('groups', array_get($actions, 'groups', array()), array(), FALSE);
?>
</td>
</tr>
<tr>
<th></th>
<td>
When this plan is executed, <b>remove</b> the persons / famiy members from these groups:
<?php
Person_Group::printMultiChooser('groups_remove', array_get($actions, 'groups_remove', array()), array(), FALSE);
?>
</td>
</tr>
<tr>
<th>Fields</th>
<td>
When this plan is executed, for each person / family member:
<table class="fields">
<?php
$fields = array_get($actions, 'fields', array());
$dummy = new Person();
foreach (array('congregationid', 'status', 'age_bracket') as $field) {
$value = '';
$addToExisting = FALSE;
$v = array_get($fields, $field);
if ($v) {
$value = $v['value'];
$addToExisting = $v['add'];
}
$dummy->fields[$field]['allow_empty'] = TRUE;
$dummy->fields[$field]['empty_text'] = '(No change)';
if (strlen($value)) {
$dummy->setValue($field, $value);
}
echo '<tr><td>';
print_widget('fields_enabled[' . $field . ']', array('type' => 'checkbox'), strlen($value));
echo 'Set ' . $dummy->getFieldLabel($field) . ' </td><td>';
$dummy->printFieldInterface($field);
echo '</td></tr>';
}
$customFields = $GLOBALS['system']->getDBObjectData('custom_field', array(), 'OR', 'rank');
$dummy = new Custom_Field();
$addParams = array('type' => 'select', 'options' => array('Replacing existing values ', 'Adding to existing values'));
foreach ($customFields as $fieldid => $fieldDetails) {
$value = '';
$addToExisting = FALSE;
$v = array_get($fields, 'custom_' . $fieldid);
if ($v) {
$value = $v['value'];
$addToExisting = $v['add'];
}
$dummy->populate($fieldid, $fieldDetails);
echo '<tr><td>';
//.........这里部分代码省略.........
示例7: test
}
$a = array();
for ($i = 0; $i <= 5; $i++) {
$var2 = new stdClass();
$var2->value = $i;
$var2->{"position" . $i} = 'position at ' . $i;
$a[$i] = $var2;
}
for ($i = 0; $i <= 5; $i++) {
echo $a[$i]->{"position" . $i};
echo $a[$i]->value;
}
function test(&$intVal)
{
static $i = 0;
$i += $intVal;
$intVal++;
return $i;
}
$a = 5;
$b = 0;
for ($m = $a; $m < 10; $m++) {
$b += test($a);
}
echo "<br/>";
echo $a;
echo "<br/>";
echo $b;
$tim = new Person();
$tim->setValue("Tim", "Smith");
echo $tim->getValue();
示例8: printView
//.........这里部分代码省略.........
" />
<input type="hidden" name="attendances_submitted" value="1" />
<p class="visible-desktop smallprint">For greatest speed, press P for present and A for absent. The cursor will automatically progress to the next person. To go back, use the arrow keys.</p>
<?php
$totalPrinted = 0;
foreach ($this->_record_sets as $i => $set) {
if ((int) $set->congregationid) {
?>
<input type="hidden" name="congregationid[]" value="<?php
echo $set->congregationid;
?>
" />
<?php
$congregation = $GLOBALS['system']->getDBObject('congregation', (int) $set->congregationid);
$title = $congregation->getValue('name') . ' Congregation';
} else {
if ($set->groupid) {
$group =& $GLOBALS['system']->getDBObject('person_group', $set->groupid);
$title = $group->getValue('name') . ' Group';
?>
<input type="hidden" name="groupid" value="<?php
echo $set->groupid;
?>
" />
<?php
} else {
return;
}
}
if (strlen($set->age_bracket)) {
$GLOBALS['system']->includeDBClass('person');
$p = new Person();
$p->setValue('age_bracket', $set->age_bracket);
$title = $p->getFormattedValue('age_bracket') . ' in ' . $title;
}
?>
<h3><?php
echo ents($title);
?>
</h3>
<div class="width-really-auto form-inline">
<?php
$setPrinted = $set->printForm($i);
if ($setPrinted > 0) {
$totalPrinted += $setPrinted;
if ((int) $set->congregationid) {
$headcountFieldName = 'headcount[congregation][' . $set->congregationid . ']';
$headcountValue = Headcount::fetch('congregation', $this->_attendance_date, $set->congregationid);
} else {
$headcountFieldName = 'headcount[group][' . $set->groupid . ']';
$headcountValue = Headcount::fetch('person_group', $this->_attendance_date, $set->groupid);
}
?>
<div class="container row-fluid control-group">
<p class="span6">
Total headcount:
<input type="text" class="int-box" name="<?php
echo $headcountFieldName;
?>
" value="<?php
echo $headcountValue;
?>
" size="5" />
</p>
<p class="span6 align-right nowrap">