/** * Sends the assignee email. * * @param Gravity_Flow_Assignee $assignee */ public function send_assignee_notification($assignee) { $this->log_debug(__METHOD__ . '() starting. assignee: ' . $assignee->get_key()); $form = $this->get_form(); $notification['workflow_notification_type'] = 'assignee'; $notification['fromName'] = empty($this->assignee_notification_from_name) ? get_bloginfo() : $this->assignee_notification_from_name; $notification['from'] = empty($this->assignee_notification_from_email) ? get_bloginfo('admin_email') : $this->assignee_notification_from_email; $notification['replyTo'] = $this->assignee_notification_reply_to; $notification['bcc'] = $this->assignee_notification_bcc; $notification['subject'] = empty($this->assignee_notification_subject) ? $form['title'] . ': ' . $this->get_name() : $this->assignee_notification_subject; $notification['message'] = $this->assignee_notification_message; if (defined('PDF_EXTENDED_VERSION') && version_compare(PDF_EXTENDED_VERSION, '4.0-beta2', '>=')) { if ($this->assignee_notification_gpdfEnable) { $gpdf_id = $this->assignee_notification_gpdfValue; $notification = $this->gpdf_add_notification_attachment($notification, $gpdf_id); } } $assignee_type = $assignee->get_type(); $assignee_id = $assignee->get_id(); if ($assignee_type == 'email') { $email = $assignee_id; $notification['id'] = 'workflow_step_' . $this->get_id() . '_user_' . $email; $notification['name'] = $notification['id']; $notification['to'] = $email; $notification['message'] = $this->replace_variables($this->assignee_notification_message, $assignee); $this->send_notification($notification); return; } if ($assignee_type == 'role') { $users = get_users(array('role' => $assignee_id)); } else { $users = get_users(array('include' => array($assignee_id))); } $this->log_debug(__METHOD__ . sprintf('() sending assignee notifications to %d users', count($users))); foreach ($users as $user) { $notification['id'] = 'workflow_step_' . $this->get_id() . '_user_' . $user->ID; $notification['name'] = $notification['id']; $notification['to'] = $user->user_email; $notification['message'] = $this->replace_variables($this->assignee_notification_message, $assignee); $this->send_notification($notification); } }
/** * @param Gravity_Flow_Assignee $assignee * * @return array */ function get_assignee_array($assignee) { return array('key' => $assignee->get_key(), 'id' => $assignee->get_id(), 'type' => $assignee->get_type(), 'display_name' => $assignee->get_display_name(), 'status' => $assignee->get_status()); }
/** * Loosely based on the JWT spec. * * @param Gravity_Flow_Assignee $assignee * @param array $scopes * @param string $expiration_timestamp * * @return string */ public function generate_access_token($assignee, $scopes = array(), $expiration_timestamp = false) { if (empty($scopes)) { $scopes = array('pages' => array('inbox', 'status')); } if (empty($expiration_timestamp)) { $expiration_timestamp = strtotime('+30 days'); } $jti = uniqid(); $token_array = array('iat' => time(), 'exp' => $expiration_timestamp, 'sub' => $assignee->get_key(), 'scopes' => $scopes, 'jti' => $jti); $token = rawurlencode(base64_encode(json_encode($token_array))); $secret = get_option('gravityflow_token_secret'); if (empty($secret)) { $secret = wp_generate_password(64); update_option('gravityflow_token_secret', $secret); } $sig = hash_hmac('sha256', $token, $secret); $token .= '.' . $sig; $this->log_event('token', 'generated', 0, 0, json_encode($token_array), 0, 0, $assignee->get_id(), $assignee->get_type(), $assignee->get_display_name()); return $token; }