say() публичный статический Метод

Send a notification to a HipChat room.
public static say ( string $message = '', string $color = "green" )
$message string
$color string
Пример #1
0
 /**
  * Post every new registration to HipChat.
  *
  * @param UserModel $sender
  * @param array $args
  */
 public function userModel_afterInsertUser_handler($sender, $args)
 {
     // Determine how to link their name.
     $name = val('Name', $args['InsertFields']);
     if (c('Garden.Registration.Method') == 'Approval') {
         $user = anchor($name, '/user/applicants', '', array('WithDomain' => true));
         $reason = sliceParagraph(val('DiscoveryText', $args['InsertFields']));
         $message = sprintf(t('New member: %1$s (%2$s)'), $user, $reason);
     } else {
         // Use conservative name linking structure.
         $user = anchor($name, '/profile/' . $args['InsertUserID'] . '/' . $name, '', array('WithDomain' => true));
         $message = sprintf(t('New member: %1$s'), $user);
     }
     // Say it.
     HipChat::say($message);
 }
 /**
  * Webhook for Teamwork.
  *
  * POST data looks like this:
  * [  'event' => 'TASK.COMPLETED',
  *    'objectId' => '000',
  *    'accountId' => '000',
  *    'userId' => '000',
  * ]
  *
  * @see http://developer.teamwork.com/todolistitems
  *
  * @param Gdn_Controller $sender
  * @param $secret
  * @throws Exception
  */
 public function utilityController_teamworkTaskCompleted_create($sender, $secret)
 {
     if ($secret != c('SprintNotifier.Teamwork.Secret')) {
         throw new Exception('Invalid token.');
     }
     // Get data
     $data = Gdn::request()->post();
     // Sanity check we set up webhooks right.
     if (val('event', $data) != 'TASK.COMPLETED') {
         return;
     }
     // Cheat by storing some data in the config.
     $users = c('SprintNotifier.Teamwork.Users', []);
     $projects = c('SprintNotifier.Teamwork.Projects', []);
     // Get full task data via Teamwork's *ahem* "API".
     $task = self::teamworkTask(val('objectId', $data));
     // DEBUG
     UserModel::setMeta(0, array('TaskAPI' => var_export($task, true)), 'SprintNotifier.Debug.');
     // Respect project whitelist if we're using one.
     if (count($projects) && !in_array($task['project-name'], $projects)) {
         return;
     }
     // Build data for the chat message.
     $teamworkUserID = val('userId', $data);
     $userName = val($teamworkUserID, $users, 'User ' . val('userId', $data));
     $taskUrl = sprintf('https://%1$s.teamwork.com/tasks/%2$s', c('Teamwork.Account'), val('objectId', $data));
     $message = sprintf('%1$s completed %2$s task: <a href="%3$s">%4$s</a>', $userName, strtolower($task['project-name']), $taskUrl, $task['content']);
     // Override HipChat plugin's default token & room.
     saveToConfig('HipChat.Room', c('SprintNotifier.HipChat.RoomID'), false);
     saveToConfig('HipChat.Token', c('SprintNotifier.HipChat.Token'), false);
     // DEBUG
     UserModel::setMeta(0, array('Message' => var_export($message, true)), 'SprintNotifier.Debug.');
     // Say it! Bust it!
     if (class_exists('HipChat')) {
         HipChat::say($message);
     }
     self::bustCache();
     // 200 OK
     $sender->render('blank', 'utility', 'dashboard');
 }