Example #1
0
 /**
  * Retrieve a Stripe account for this mercant
  *
  * @return Stripe_Customer|boolean
  * @throws Stripe_Error
  */
 public function getMerchantAccount()
 {
     if ($this->account->id) {
         return $this->account;
     }
     if (!$this->entity) {
         return false;
     }
     if (!($access_token = $this->getAccessToken())) {
         return false;
     }
     try {
         $stripe = new StripeClient();
         $stripe->setAccessToken($access_token);
         $account = $stripe->getAccount();
         if (!$account->id || isset($account->deleted)) {
             throw new Stripe_Error('Account does not exist or has been deleted');
         }
         $this->account = $account;
         return $this->account;
     } catch (Stripe_Error $e) {
         $this->entity->setPrivateSetting('stripe_secret_key', null);
         $this->entity->setPrivateSetting('stripe_publishable_key', null);
         return false;
     }
 }
Example #2
0
    foreach ($tool_options as $group_option) {
        $option_toggle_name = $group_option->name . "_enable";
        $option_default = $group_option->default_on ? 'yes' : 'no';
        $group->{$option_toggle_name} = get_input($option_toggle_name, $option_default);
    }
}
// Group membership - should these be treated with same constants as access permissions?
$is_public_membership = get_input('membership') == ACCESS_PUBLIC;
$group->membership = $is_public_membership ? ACCESS_PUBLIC : ACCESS_PRIVATE;
$group->setContentAccessMode(get_input('content_access_mode'));
if ($is_new_group) {
    $group->access_id = ACCESS_PUBLIC;
}
// default access
$default_access = (int) get_input('group_default_access');
$group->setPrivateSetting("elgg_default_access", $default_access);
if ($is_new_group) {
    // if new group, we need to save so group acl gets set in event handler
    $group->save();
}
// Invisible group support
// @todo this requires save to be called to create the acl for the group. This
// is an odd requirement and should be removed. Either the acl creation happens
// in the action or the visibility moves to a plugin hook
if (elgg_get_plugin_setting('hidden_groups', 'groups') == 'yes') {
    $visibility = (int) get_input('vis');
    if ($visibility == ACCESS_PRIVATE) {
        // Make this group visible only to group members. We need to use
        // ACCESS_PRIVATE on the form and convert it to group_acl here
        // because new groups do not have acl until they have been saved once.
        $visibility = $group->group_acl;
Example #3
0
 /**
  * Make sure entity is loaded from cache during save operations
  * See #10612
  */
 public function testNewGroupLoadedFromCacheDuringSaveOperations()
 {
     $group = new \ElggGroup();
     $group->subtype = 'test_group_subtype';
     // Add temporary metadata, annotation and private settings
     // to extend the scope of tests and catch issues with save operations
     $group->test_metadata = 'bar';
     $group->annotate('test_annotation', 'baz');
     $group->setPrivateSetting('test_setting', 'foo');
     $metadata_called = false;
     $metadata_event_handler = function ($event, $type, $metadata) use(&$metadata_called) {
         /* @var $metadata \ElggMetadata */
         $entity = get_entity($metadata->entity_guid);
         $this->assertEqual($metadata->entity_guid, $entity->guid);
         $metadata_called = true;
     };
     $annotation_called = false;
     $annotation_event_handler = function ($event, $type, $annotation) use(&$annotation_called) {
         /* @var $metadata \ElggAnnotation */
         $entity = get_entity($annotation->entity_guid);
         $this->assertEqual($annotation->entity_guid, $entity->guid);
         $annotation_called = true;
     };
     elgg_register_event_handler('create', 'metadata', $metadata_event_handler);
     elgg_register_event_handler('create', 'annotation', $annotation_event_handler);
     $group->save();
     elgg_unregister_event_handler('create', 'metadata', $metadata_event_handler);
     elgg_unregister_event_handler('create', 'annotation', $annotation_event_handler);
     $group->delete();
     $this->assertTrue($metadata_called);
     $this->assertTrue($annotation_called);
 }