您的位置:軟件測(cè)試 > 軟件項(xiàng)目管理 > 項(xiàng)目管理軟件 > 禪道項(xiàng)目管理軟件
讓禪道也可以玩BearyChat
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2015/10/10 14:06:36 ] 推薦標(biāo)簽:項(xiàng)目管理軟件 禪道

  簡(jiǎn)單的理解,BearycChat是一種IM,是一種能聚合各種MS系統(tǒng)消息的東西,是團(tuán)隊(duì)協(xié)作過(guò)程中消息流轉(zhuǎn)的利器。
  我是工具控,所以不折騰不舒服。
  廢話不說(shuō),上碼:
/path_to_zentao/module/action/ext/model/logHistory.php
<?php
/**
* Log histories for an action.
*
* @param  int    $actionID
* @param  array  $changes
* @access public
* @return void
*/
public function logHistory($actionID, $changes)
{
foreach($changes as $change)
{
$change['action'] = $actionID;
$result = $this->dao->insert(TABLE_HISTORY)->data($change)->exec();
//bearychat notice
$this->notifyBearychat($actionID, $change['new']);
}
}
protected function notifyBearychat($actionID, $text) {
$action = $this->dao->select('*')->from(TABLE_ACTION)
->where('id')->eq($actionID)
->fetch();
$_actions = $this->loadModel('action')->transformActions(array($action));
$action = $_actions[0];
$title = strip_tags(sprintf("%s, %s <em>%s</em> %s %s %s。", $action->date, $action->actor, $action->actionLabel, $action->objectLabel, $action->objectName, 'http://'.(isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : '')) . $action->objectLink));
return $this->curlPostPayload2Bearychat($title, $text);//, 'project-' . $action->project . ''
}
protected function curlPostPayload2Bearychat($title, $text, $channel = 'pms') {
$url = 'https://hook.bearychat.com/your_self_params';//簡(jiǎn)單的定義于此
$str = array('payload' => json_encode(array('text' => $title, 'markdown' => true, 'channel' => $channel, 'attachments' => array(array('text' => strip_tags($text))))));//
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $str);
if (substr($url, 0, 8) == "https://")
{
$opt[CURLOPT_SSL_VERIFYHOST] = 1;
$opt[CURLOPT_SSL_VERIFYPEER] = FALSE;
}
curl_setopt_array($ch, $opt);
curl_exec($ch);
curl_close($ch);
}

軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd