| @@ 546-608 (lines=63) @@ | ||
| 543 | * @param mixed $group ElggGroup or null. If a group, uses values from the group. |
|
| 544 | * @return array |
|
| 545 | */ |
|
| 546 | function groups_prepare_form_vars($group = null) { |
|
| 547 | $values = array( |
|
| 548 | 'name' => '', |
|
| 549 | 'membership' => ACCESS_PUBLIC, |
|
| 550 | 'vis' => ACCESS_PUBLIC, |
|
| 551 | 'guid' => null, |
|
| 552 | 'entity' => null, |
|
| 553 | 'owner_guid' => elgg_get_logged_in_user_guid(), |
|
| 554 | 'content_access_mode' => ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED |
|
| 555 | ); |
|
| 556 | ||
| 557 | // handle customizable profile fields |
|
| 558 | $fields = elgg_get_config('group'); |
|
| 559 | ||
| 560 | if ($fields) { |
|
| 561 | foreach ($fields as $name => $type) { |
|
| 562 | $values[$name] = ''; |
|
| 563 | } |
|
| 564 | } |
|
| 565 | ||
| 566 | // handle tool options |
|
| 567 | $tools = elgg_get_config('group_tool_options'); |
|
| 568 | if ($tools) { |
|
| 569 | foreach ($tools as $group_option) { |
|
| 570 | $option_name = $group_option->name . "_enable"; |
|
| 571 | $values[$option_name] = $group_option->default_on ? 'yes' : 'no'; |
|
| 572 | } |
|
| 573 | } |
|
| 574 | ||
| 575 | // get current group settings |
|
| 576 | if ($group) { |
|
| 577 | foreach (array_keys($values) as $field) { |
|
| 578 | if (isset($group->$field)) { |
|
| 579 | $values[$field] = $group->$field; |
|
| 580 | } |
|
| 581 | } |
|
| 582 | ||
| 583 | if ($group->access_id != ACCESS_PUBLIC && $group->access_id != ACCESS_LOGGED_IN) { |
|
| 584 | // group only access - this is done to handle access not created when group is created |
|
| 585 | $values['vis'] = ACCESS_PRIVATE; |
|
| 586 | } else { |
|
| 587 | $values['vis'] = $group->access_id; |
|
| 588 | } |
|
| 589 | ||
| 590 | // The content_access_mode was introduced in 1.9. This method must be |
|
| 591 | // used for backwards compatibility with groups created before 1.9. |
|
| 592 | $values['content_access_mode'] = $group->getContentAccessMode(); |
|
| 593 | ||
| 594 | $values['entity'] = $group; |
|
| 595 | } |
|
| 596 | ||
| 597 | // get any sticky form settings |
|
| 598 | if (elgg_is_sticky_form('groups')) { |
|
| 599 | $sticky_values = elgg_get_sticky_values('groups'); |
|
| 600 | foreach ($sticky_values as $key => $value) { |
|
| 601 | $values[$key] = $value; |
|
| 602 | } |
|
| 603 | } |
|
| 604 | ||
| 605 | elgg_clear_sticky_form('groups'); |
|
| 606 | ||
| 607 | return $values; |
|
| 608 | } |
|
| 609 | ||
| @@ 577-640 (lines=64) @@ | ||
| 574 | * @param mixed $group ElggGroup or null. If a group, uses values from the group. |
|
| 575 | * @return array |
|
| 576 | */ |
|
| 577 | function groups_prepare_form_vars($group = null) { |
|
| 578 | $values = array( |
|
| 579 | 'name' => '', |
|
| 580 | 'name2' => '', |
|
| 581 | 'membership' => ACCESS_PUBLIC, |
|
| 582 | 'vis' => ACCESS_PUBLIC, |
|
| 583 | 'guid' => null, |
|
| 584 | 'entity' => null, |
|
| 585 | 'owner_guid' => elgg_get_logged_in_user_guid(), |
|
| 586 | 'content_access_mode' => ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED |
|
| 587 | ); |
|
| 588 | ||
| 589 | // handle customizable profile fields |
|
| 590 | $fields = elgg_get_config('group'); |
|
| 591 | ||
| 592 | if ($fields) { |
|
| 593 | foreach ($fields as $name => $type) { |
|
| 594 | $values[$name] = ''; |
|
| 595 | } |
|
| 596 | } |
|
| 597 | ||
| 598 | // handle tool options |
|
| 599 | $tools = elgg_get_config('group_tool_options'); |
|
| 600 | if ($tools) { |
|
| 601 | foreach ($tools as $group_option) { |
|
| 602 | $option_name = $group_option->name . "_enable"; |
|
| 603 | $values[$option_name] = $group_option->default_on ? 'yes' : 'no'; |
|
| 604 | } |
|
| 605 | } |
|
| 606 | ||
| 607 | // get current group settings |
|
| 608 | if ($group) { |
|
| 609 | foreach (array_keys($values) as $field) { |
|
| 610 | if (isset($group->$field)) { |
|
| 611 | $values[$field] = $group->$field; |
|
| 612 | } |
|
| 613 | } |
|
| 614 | ||
| 615 | if ($group->access_id != ACCESS_PUBLIC && $group->access_id != ACCESS_LOGGED_IN) { |
|
| 616 | // group only access - this is done to handle access not created when group is created |
|
| 617 | $values['vis'] = ACCESS_PRIVATE; |
|
| 618 | } else { |
|
| 619 | $values['vis'] = $group->access_id; |
|
| 620 | } |
|
| 621 | ||
| 622 | // The content_access_mode was introduced in 1.9. This method must be |
|
| 623 | // used for backwards compatibility with groups created before 1.9. |
|
| 624 | $values['content_access_mode'] = $group->getContentAccessMode(); |
|
| 625 | ||
| 626 | $values['entity'] = $group; |
|
| 627 | } |
|
| 628 | ||
| 629 | // get any sticky form settings |
|
| 630 | if (elgg_is_sticky_form('groups')) { |
|
| 631 | $sticky_values = elgg_get_sticky_values('groups'); |
|
| 632 | foreach ($sticky_values as $key => $value) { |
|
| 633 | $values[$key] = $value; |
|
| 634 | } |
|
| 635 | } |
|
| 636 | ||
| 637 | elgg_clear_sticky_form('groups'); |
|
| 638 | ||
| 639 | return $values; |
|
| 640 | } |
|
| 641 | ||
| 642 | /** |
|
| 643 | * View stats for a group |
|
| @@ 600-663 (lines=64) @@ | ||
| 597 | * @param mixed $group ElggGroup or null. If a group, uses values from the group. |
|
| 598 | * @return array |
|
| 599 | */ |
|
| 600 | function groups_prepare_form_vars($group = null) { |
|
| 601 | $values = array( |
|
| 602 | 'name' => '', |
|
| 603 | 'name2' => '', |
|
| 604 | 'membership' => ACCESS_PUBLIC, |
|
| 605 | 'vis' => ACCESS_PUBLIC, |
|
| 606 | 'guid' => null, |
|
| 607 | 'entity' => null, |
|
| 608 | 'owner_guid' => elgg_get_logged_in_user_guid(), |
|
| 609 | 'content_access_mode' => ElggGroup::CONTENT_ACCESS_MODE_UNRESTRICTED |
|
| 610 | ); |
|
| 611 | ||
| 612 | // handle customizable profile fields |
|
| 613 | $fields = elgg_get_config('group'); |
|
| 614 | ||
| 615 | if ($fields) { |
|
| 616 | foreach ($fields as $name => $type) { |
|
| 617 | $values[$name] = ''; |
|
| 618 | } |
|
| 619 | } |
|
| 620 | ||
| 621 | // handle tool options |
|
| 622 | $tools = elgg_get_config('group_tool_options'); |
|
| 623 | if ($tools) { |
|
| 624 | foreach ($tools as $group_option) { |
|
| 625 | $option_name = $group_option->name . "_enable"; |
|
| 626 | $values[$option_name] = $group_option->default_on ? 'yes' : 'no'; |
|
| 627 | } |
|
| 628 | } |
|
| 629 | ||
| 630 | // get current group settings |
|
| 631 | if ($group) { |
|
| 632 | foreach (array_keys($values) as $field) { |
|
| 633 | if (isset($group->$field)) { |
|
| 634 | $values[$field] = $group->$field; |
|
| 635 | } |
|
| 636 | } |
|
| 637 | ||
| 638 | if ($group->access_id != ACCESS_PUBLIC && $group->access_id != ACCESS_LOGGED_IN) { |
|
| 639 | // group only access - this is done to handle access not created when group is created |
|
| 640 | $values['vis'] = ACCESS_PRIVATE; |
|
| 641 | } else { |
|
| 642 | $values['vis'] = $group->access_id; |
|
| 643 | } |
|
| 644 | ||
| 645 | // The content_access_mode was introduced in 1.9. This method must be |
|
| 646 | // used for backwards compatibility with groups created before 1.9. |
|
| 647 | $values['content_access_mode'] = $group->getContentAccessMode(); |
|
| 648 | ||
| 649 | $values['entity'] = $group; |
|
| 650 | } |
|
| 651 | ||
| 652 | // get any sticky form settings |
|
| 653 | if (elgg_is_sticky_form('groups')) { |
|
| 654 | $sticky_values = elgg_get_sticky_values('groups'); |
|
| 655 | foreach ($sticky_values as $key => $value) { |
|
| 656 | $values[$key] = $value; |
|
| 657 | } |
|
| 658 | } |
|
| 659 | ||
| 660 | elgg_clear_sticky_form('groups'); |
|
| 661 | ||
| 662 | return $values; |
|
| 663 | } |
|
| 664 | ||
| 665 | /** |
|
| 666 | * View stats for a group |
|