Пример #1
0
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Affero General Public License for more details.

	You should have received a copy of the GNU Affero General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
require '../init.php';
$data['error'] = 'OK';
$data['countAlive'] = $data['countKilled'] = 0;
try {
    $l = new Liste();
    $data['priorities'] = $PRIORITIES;
    $data['labels'] = $l->getListe('t_labels', "*", 'id', 'ASC');
    $data['devs'] = $l->getListe('t_devs', "*", 'id', 'ASC', 'id', '>=', '0');
    $l->getListe('t_bugs', "id", "priority", "DESC", "closed", "=", 0);
    $data['countAlive'] = $l->countResults();
    $l->getListe('t_bugs', "id", "priority", "DESC", "closed", "=", 1);
    $data['countKilled'] = $l->countResults();
    $l->resetFiltre();
    $l->addFiltre('nom', '!=', 'password_access');
    $l->addFiltre('nom', '!=', 'api_access');
    $l->getListe('t_config', '*', 'id', 'ASC');
    $data['globalConf'] = $l->simplifyList('nom');
    $data['available_languages'] = array();
    foreach (glob($pathLang . '/*') as $langFile) {
        if (is_dir($langFile)) {
            continue;
        }
Пример #2
0
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU Affero General Public License for more details.

	You should have received a copy of the GNU Affero General Public License
	along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
require '../init.php';
$data['error'] = 'OK';
try {
    extract($_GET);
    if (!isset($type)) {
        $type = 0;
    }
    $l = new Liste();
    $bugList = $l->getListe('t_bugs', "*", "priority", "DESC", "closed", "=", $type);
    if (!$bugList) {
        $bugList = array();
    }
    $data['bugsList'] = $bugList;
} catch (Exception $e) {
    $data['error'] = $e->getMessage();
    $data['trace'] = $e->getTrace();
}
header('HTTP/1.1 200 OK');
header('Content-type: application/json; charset=UTF-8');
echo ")]}',\n";
// Pour sécu anti injection JSONP
echo json_encode($data, JSON_UNESCAPED_UNICODE);
Пример #3
0
         throw new Exception("API::get_bug : missing id_bug!");
     }
     $b = new Bug((int) $id_bug);
     $response["data"] = $b->getBugData();
     $response["error"] = "OK";
     $response["message"] = "Bug retreived.";
 }
 /**
  * ACTION COUNT BUGS
  */
 if ($action === "count_bugs") {
     if (!isset($closed)) {
         $closed = false;
     }
     $lB = new Liste();
     $bugList = $lB->getListe('t_bugs', '*', 'date', 'DESC', 'closed', '=', (int) $closed);
     if (!$bugList) {
         $bugList = array();
     }
     $response["data"] = count($bugList);
     $response["error"] = "OK";
     $response["message"] = "Bugs count retreived.";
 }
 /**
  * ACTION ADD BUG (need password api_access)
  */
 if ($action === "insert_bug") {
     if (!isset($password)) {
         throw new Exception("API: missing password!");
     }
     if ($password !== $api_access) {
Пример #4
0
 /**
  * Send an email notification to devs
  * @param STRING $type The type of notification to send ('new', 'close', 'comment', or 'assign')
  * @return INt Number of email actually sent
  */
 public function notify($type)
 {
     global $LANG;
     $iC = new Infos('t_config');
     $iC->loadInfos('nom', 'enable_notify');
     if ($iC->getInfos('value') == 0) {
         return 0;
     }
     $iC->loadInfos('nom', 'project_name');
     $project_name = $iC->getInfos('value');
     $iC->loadInfos('nom', 'language');
     $language = $iC->getInfos('value');
     $mail = new PHPMailer(true);
     $mail->isMail();
     if ($language === 'Francais') {
         $mail->setLanguage('fr', INSTALL_PATH . 'language/phpMailer/');
     }
     $mail->CharSet = 'UTF-8';
     $mail->From = "*****@*****.**";
     $mail->FromName = "Bughunter {$project_name}";
     $mail->isHTML(true);
     switch ($type) {
         case "new":
             $subject = $LANG['Notify_newBug_subject'];
             $bodyTxt = $LANG['Notify_newBug_body'];
             break;
         case "close":
             $subject = $LANG['Notify_killBug_subject'];
             $bodyTxt = $LANG['Notify_killBug_body'];
             break;
         case "comment":
             $subject = $LANG['Notify_comment_subject'];
             $bodyTxt = $LANG['Notify_comment_body'];
             break;
         case "assign":
             $subject = $LANG['Notify_assign_subject'];
             $bodyTxt = $LANG['Notify_assign_body'];
             break;
         default:
             throw new Exception("Notification type unknown.");
     }
     $bugData = $this->getBugData(true);
     $subject = preg_replace('/\\{\\{BUG_ID\\}\\}/', $bugData['id'], $subject);
     $mail->Subject = $subject;
     $template = file_get_contents(INSTALL_PATH . 'mails/template.html');
     $html = preg_replace('/\\{\\{SUBJECT\\}\\}/', $subject, $template);
     $html = preg_replace('/\\{\\{BODY\\}\\}/', $bodyTxt, $html);
     $html = preg_replace('/\\{\\{DATE\\}\\}/', date('Y-m-d'), $html);
     $html = preg_replace('/\\{\\{PROJECT\\}\\}/', $project_name, $html);
     $html = preg_replace('/\\{\\{URL_BH\\}\\}/', preg_replace('/\\/actions$/', '', get_url()), $html);
     $html = preg_replace('/\\{\\{REPORTER\\}\\}/', $bugData['author'], $html);
     $html = preg_replace('/\\{\\{BUG_ID\\}\\}/', $bugData['id'], $html);
     $html = preg_replace('/\\{\\{BUG_TITLE\\}\\}/', $bugData['title'], $html);
     $html = preg_replace('/\\{\\{BUG_DESCR\\}\\}/', $bugData['description'], $html);
     $html = preg_replace('/\\{\\{BUG_LABEL\\}\\}/', $bugData['label']['name'], $html);
     if ($type === "comment") {
         $comm = end($bugData['comment']);
         $html = preg_replace('/\\{\\{COMM_AUTHOR\\}\\}/', $comm['dev']['pseudo'], $html);
         $html = preg_replace('/\\{\\{COMM_MESSAGE\\}\\}/', nl2br($comm['message']), $html);
     }
     $l = new Liste();
     $l->addFiltre('id', '>', '0');
     $l->addFiltre('notify', '=', '1');
     $l->getListe('t_devs');
     $devs = $l->simplifyList();
     if (!$devs) {
         return 0;
     }
     $countSent = 0;
     foreach ($devs as $dev) {
         if ($type === "assign" && $bugData['FK_dev_ID'] != $dev['id']) {
             continue;
         }
         $mail->Body = $html;
         $mail->addAddress($dev['mail']);
         if ($mail->send()) {
             $countSent++;
         }
         $mail->clearAddresses();
         //			file_put_contents(INSTALL_PATH.'data/debugMail_'.$dev['pseudo'].'.html', $html);
     }
     return $countSent;
 }