Пример #1
0
/**
 * SUBSCRIPTIONS
 * @param $object
 * @return mixed
 */
function decorate_subscription($object)
{
    if ($object) {
        $CI =& get_instance();
        $CI->load->model(array('Plan'));
        $object->failed = ci_boolval($object->failed);
        $object->additional_users = intval($object->additional_users);
        $object->plan_id = intval($object->plan_id);
        $object->plan = decorate_plan($CI->Plan->load($object->plan_id));
        if (isset($object->card)) {
            unset($object->card->fingerprint, $object->card->name, $object->card->cvc_check, $object->card->customer, $object->card->address_line1, $object->card->address_line2, $object->card->address_city, $object->card->object, $object->card->funding, $object->card->address_state, $object->card->address_zip, $object->card->address_country, $object->card->address_line1_check, $object->card->address_zip_check, $object->card->dynamic_last4, $object->card->metadata);
            $object->card = $object->card->__toArray();
        }
        unset($object->deleted, $object->user_id, $object->id, $object->failed_event, $object->stripe_customer_id, $object->stripe_subscription_id, $object->stripe_additional_subscription_id);
    }
    return $object;
}
Пример #2
0
 /**
  * Returns the notification settings for a user.  We store notify_general and notify_promotions on the user
  * directly.  Then we specify notify on the actual projects to indicate that the user should or should not
  * be notified for any messages for those projects
  * @param $user_id
  * @return stdClass
  */
 function get_notifications($user_id)
 {
     $this->load->model('Project');
     $notifications = new stdClass();
     $user = $this->load($user_id);
     $notifications->notify_general = ci_boolval($user->notify_general);
     $notifications->notify_promotions = ci_boolval($user->notify_promotions);
     $projects = $this->Project->get_for_user($user_id);
     $notifications->projects = array();
     foreach ($projects as $project) {
         $proj = new stdClass();
         $proj->uuid = $project->uuid;
         $proj->name = $project->name;
         $proj->notify = ci_boolval($project->notify);
         $notifications->projects[] = $proj;
     }
     return $notifications;
 }