private function charge_succeeded($event) { $this->load->model('Subscription'); $this->load->helper('notification'); $customer_id = $event->data->object->customer; $card_last_four = $event->data->object->card->last4; $amount = round($event->data->object->amount / 100, 2); $subscription = $this->Subscription->load_by_field('stripe_customer_id', $customer_id); if ($subscription) { /* Their subscription has failed to charge */ $this->Subscription->update($subscription->id, array('updated' => timestamp_to_mysqldatetime(now()))); $text = sprintf('[Stripe Event] charge.succeeded for subscription [%d]', $subscription->id); loggly(array('text' => $text, 'method' => 'stripe.charge_succeeded', 'event' => $event)); $user = $this->User->load($subscription->user_id); notify_successful_charge($user, $card_last_four, $amount); } }
function voice_post($action = '', $meeting_uuid = '') { $this->data = array(); header('Content-Type: application/xml; charset=utf-8'); if (!$action) { $this->load->view('twilio/enter-pin', $this->data); } else { if ($action === 'pin') { $pin = $this->post('Digits'); $this->data['pin'] = $pin; /* Lookup the conference by pin */ $today = date("Y-m-d"); $participant_meeting = $this->Meeting->load_by_pin($pin, $today); /* If this is a meeting participant */ if ($participant_meeting) { if ($participant_meeting->ended) { $this->load->view('twilio/conference-ended.php', $this->data); return; } $this->data['meeting_id'] = $participant_meeting->uuid; $this->load->view('twilio/conference-participant.php', $this->data); return; } /* If this is a meeting moderator */ $moderator_meeting = $this->Meeting->load_by_moderator_pin($pin, $today); if ($moderator_meeting) { if ($moderator_meeting->ended) { $this->load->view('twilio/conference-ended.php', $this->data); return; } $this->Meeting->update_by_uuid($moderator_meeting->uuid, array('started' => timestamp_to_mysqldatetime(now()))); $this->data['meeting_id'] = $moderator_meeting->uuid; $this->load->view('twilio/conference-moderator.php', $this->data); return; } $this->load->view('twilio/invalid-pin.php', $this->data); } else { if ($action === 'end') { $this->Meeting->update_by_uuid($meeting_uuid, array('ended' => timestamp_to_mysqldatetime(now()))); return; } } } }
/** * * @SWG\Api( * path="/meeting/{uuid}/end", * description="API for meeting actions", * @SWG\Operation( * method="POST", * type="Meeting", * summary="Ends an ongoing meeting from a moderator", * @SWG\Parameter( * name="uuid", * description="UUID of the meeting", * paramType="path", * required=true, * type="string" * ), * ) * ) * * Adds a delta (change) to an ongoing meeting * @param string $uuid */ private function meeting_end($uuid = '') { $meeting = validate_meeting_uuid($uuid, true, true); if ($meeting->ended) { $this->Meeting->update($meeting->id, array('ended' => timestamp_to_mysqldatetime(now()))); $meeting = $this->Meeting->load($meeting->id); } $this->response($this->decorate_object($meeting)); }
function date_to_mysqldatetime($date = "", $datetime = TRUE) { return timestamp_to_mysqldatetime(date_to_timestamp($date), $datetime); }
function add_data() { $data = array('created' => timestamp_to_mysqldatetime(now())); return $data; }
/** * Converts a stripe invoice into a friendlier json object * @param $object */ function decorate_invoice($object) { unset($object->id, $object->customer, $object->livemode, $object->webhooks_delivered_at, $object->charge, $object->application_fee, $object->subscription, $object->attempted, $object->closed, $object->forgiven, $object->lines, $object->object, $object->starting_balance, $object->ending_balance, $object->next_payment_attempt, $object->metadata, $object->statement_descriptor, $object->description, $object->receipt_number); $object->subtotal = $object->subtotal / 100; $object->total = $object->total / 100; $object->amount_due = $object->amount_due / 100; $object->tax = $object->tax / 100; $object->date = timestamp_to_mysqldatetime($object->date); $object->period_start = timestamp_to_mysqldatetime($object->period_start); $object->period_end = timestamp_to_mysqldatetime($object->period_end); return $object->__toArray(); }
function add_data() { $this->load->library('uuid'); $data = array('uuid' => $this->uuid->v4(), 'created' => timestamp_to_mysqldatetime(now())); return $data; }
} } break; case "article": if (empty($tables['membre']['content'])) { $flash['error'][] = T_("You can not import 'articles' table without importing the 'membres' table"); break; } if (empty($tables['flux']['content'])) { $flash['error'][] = T_("You can not import 'articles' table without importing the 'flux' table"); break; } $core->con->execute("TRUNCATE TABLE `" . $core->prefix . "post`"); foreach ($table['content'] as $key => $value) { $num_membre = $value[0]; $article_pub = timestamp_to_mysqldatetime($value[1]); $article_titre = $value[2]; $article_url = $value[3]; $article_content = $value[4]; $article_statut = $value[5]; $article_score = $value[6]; $user_id = $tables['membre']['content'][$num_membre][0]; $user_id = preg_replace("( )", "_", $user_id); $user_id = cleanString($user_id); # We build the url of article $parse = @parse_url($article_url); if (!$parse['scheme']) { $site_membre = $tables['membre']['content'][$num_membre][2]; $article_url = $site_membre . $article_url; } $rs3 = $core->con->select('SELECT MAX(post_id) ' . 'FROM ' . $core->prefix . 'post ');
function add_data() { $this->load->library('uuid'); $data = array('uuid' => $this->uuid->v4(), 'creator_id' => intval(get_user_id()), 'team_id' => intval(get_team_id()), 'archived' => 0, 'deleted' => 0, 'created' => timestamp_to_mysqldatetime(now())); return $data; }
function record_login($user_id = 0) { $user = $this->User->load($user_id); $data = array('last_login' => timestamp_to_mysqldatetime(now())); $this->db->where('id', $user_id); $this->db->update($this->get_scope(), $data); }
/** * * @SWG\Api( * path="/", * description="API for message actions", * @SWG\Operation( * method="POST", * type="Message", * summary="Create a new message for the current user (user must be logged in)", * @SWG\Parameter( * name="content", * description="Content of the message", * paramType="form", * required=true, * type="string" * ), * @SWG\Parameter( * name="project_uuid", * description="The UUID of the project that this message is attached to", * paramType="form", * required=true, * type="string" * ), * @SWG\Parameter( * name="parent_uuid", * description="The UUID of the message that is the parent of this one (if it is a reply -- leave it null if it is a new message)", * paramType="form", * required=false, * type="string" * ), * @SWG\Parameter( * name="recipients", * description="A Comma-Separated List of UUIDs of individuals who should be recipients of the message (Example: '123,232,443'). If this is null, the message will be sent to all users on the project. This will also be ignored if there is a parent_uuid set since we will default to the parent email for recipients", * paramType="form", * required=false, * type="array[string]" * ) * ) * ) * * Creates a new message and attaches project members to it. */ public function index_post() { /* Validate add */ $this->load->library('form_validation'); $this->load->helper('notification'); $this->form_validation->set_rules('content', 'Content', 'trim|required|xss_clean'); $this->form_validation->set_rules('project_uuid', 'Project UUID', 'trim|xss_clean'); $this->form_validation->set_rules('parent_uuid', 'Parent UUID', 'trim|xss_clean'); if ($this->form_validation->run() == FALSE) { json_error('There was a problem with your submission: ' . validation_errors(' ', ' ')); } else { $project_uuid = $this->post('project_uuid', TRUE); $parent_uuid = $this->post('parent_uuid', TRUE); if ($project_uuid) { $project = validate_project_uuid($this->post('project_uuid', TRUE)); } else { if ($parent_uuid) { $parent_message = $this->Message->load_by_uuid($parent_uuid); $project = validate_project_uuid($this->Project->get_uuid($parent_message->project_id)); } else { json_error('There as was a problem with your submission. Either project_uuid or parent_uuid are required'); exit; } } $data = array('content' => $this->post('content', TRUE), 'project_id' => $project->id, 'sender_id' => get_user_id()); if ($parent_message) { /* Prevent messages that are replies to replies so we don't have to deal with a multi-level hierarchy */ if ($parent_message->parent_id) { json_error('The parent uuid provided belongs to a reply. You cannot reply to a reply but only to the parent message.'); } else { $data['parent_id'] = $parent_message->id; } } $message = $this->Message->load($this->Message->add($data)); /* Set the recipients on the message if it doesn't have a parent */ /* Allow the recipients to be optional, if it isn't specified, all people on the project are marked as recipients */ if (!$message->parent_id) { $recipients = $this->post('recipients', TRUE); if (!$recipients) { $users = $this->User->get_for_project($project->id); foreach ($users as $user) { $existing = $this->Message->get_message_user($message->id, $user->id); if (!$existing) { $this->Message->add_message_user($message->id, $user->id); } } } else { $recipients = explode(",", $recipients); foreach ($recipients as $recipient) { $user = $this->User->load_by_uuid($recipient); $existing = $this->Message->get_message_user($message->id, $user->id); if (!$existing) { $this->Message->add_message_user($message->id, $user->id); } } } /* This is a new message, so store the add activity */ activity_add_message($message->id); notify_new_message($message->id, get_user_id()); } else { /* Update the updated date on the parent message */ $this->Message->update($message->parent_id, array('updated' => timestamp_to_mysqldatetime(now()))); /* This is a new message, so store the add activity */ activity_reply_message($message->id); notify_new_message($message->id, get_user_id(), $message->parent_id); } $this->response($this->decorate_object($message)); } }
private function process_invite($invite, $user) { $this->load->helper('notification'); /* Process Invites */ $invite_key = $this->post('invite_key', TRUE); $invite_type = $this->post('invite_type', TRUE); if ($invite_key && $invite_type && $invite) { /* Team Invite */ if ($invite_type == INVITE_TYPE_TEAM) { /* Add the user to the team */ $this->Team->add_user($invite->team_id, $user->id); /* Update the invite so that the user is set on it */ $this->Team_Invite->update($invite->id, array('user_id' => $user->id, 'used' => timestamp_to_mysqldatetime(now()))); activity_user_join_team($invite->team_id, $user->id); notify_team_invite_accepted($invite->id); } else { $project = $this->Project->load($invite->project_id); /* Add the user to the project */ $this->Project->add_user($invite->project_id, $user->id); /* Look up the project to see if the user is already on the team, if not add them */ if (!$this->User->is_on_team($project->team_id, $user->id)) { $this->Team->add_user($project->team_id, $user->id); activity_user_join_team($project->team_id, $user->id); } /* Update the invite so that the user is set on it */ $this->Project_Invite->update($invite->id, array('user_id' => $user->id, 'used' => timestamp_to_mysqldatetime(now()))); activity_user_join_project($project->id, $user->id); notify_project_invite_accepted($invite->id); } } }