Skip to content

Instantly share code, notes, and snippets.

@Pepan
Created July 16, 2013 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pepan/6009199 to your computer and use it in GitHub Desktop.
Save Pepan/6009199 to your computer and use it in GitHub Desktop.
metoda skladajici adresy pro odchozi email
/** JCH
* @param int $p_bug_id
* @param string $p_notify_type
* @param array $p_extra_user_ids_to_email
* @return array
*/
function email_collect_recipients_02($p_bug_id, $p_notify_type, $p_extra_user_ids_to_email = array()) {
$bug_id = db_prepare_int($p_bug_id);
$recipients = array();
require_once("config_inc.php");
include_once('library/adodb/adodb.inc.php');
include_once('library/adodb/adodb-active-record.inc.php');
global $_ADODB_ACTIVE_DBS;
if (empty($_ADODB_ACTIVE_DBS)) {
$db = NewADOConnection($GLOBALS['g_db_type'] . '://' . $GLOBALS['g_db_username'] . ':' . $GLOBALS['g_db_password'] . '@' . $GLOBALS['g_hostname'] . '/' . $GLOBALS['g_database_name'] . '?charset=' . $GLOBALS['g_db_charset']);
ADOdb_Active_Record::SetDatabaseAdapter($db);
}
//$db->debug = true;
require_once('activerec/bug.php');
$bug = new Bug();
$bug->Load('id=?', array($bug_id));
switch ($bug->status) {
case NEW_: //novy
case DENIED: //zamítnutý - $p_notify_type == 'bugnote' je pro pripad pridana POZNAMKA nebo PRILOHA
if ($bug->reporter->isShop() || $bug->reporter->isOv() || $bug->reporter->isFacilty() || $p_notify_type == 'bugnote') {
if (!($bug->reporter->isFacilty() && ($bug->isCee() || $bug->isFast()))) {
$recipients[1] = $bug->branch_office->shops[0]->email; // prodejna
if (!empty($bug->branch_office->shops[0]->ov_area->mantis_user->id)) {
$recipients[$bug->branch_office->shops[0]->ov_area->mantis_user->id] = $bug->branch_office->shops[0]->ov_area->mantis_user->email;
}
}
}
break;
case FEEDBACK:
break;
case ACKNOWLEDGED: //schválený
if ($bug->reporter->isShop() || $bug->reporter->isOv() || $bug->reporter->isFacilty()) {
if (!($bug->reporter->isFacilty() && ($bug->isCee() || $bug->isFast()))) {
$recipients[$bug->supplier->getUser()->id] = $bug->supplier->getUser()->email;
}
}
break;
case CONFIRMED: //přijatý
case ASSIGNED: //přiřazený
case RESOLVED: //vyřešený
if ($p_notify_type == 'bugnote') {
if (!(($bug->isCee() || $bug->isFast()))) {
$recipients[$bug->supplier->getUser()->id] = $bug->supplier->getUser()->email;
// PBE 1.5.2011 omezeni obesilanych lidi pri zadani poznamky na 4 z facility
$query = "SELECT DISTINCT HU.id as user_id
FROM mantis_bug_table AS B
INNER JOIN mantis_bugnote_table AS N ON B.id = N.bug_id
INNER JOIN mantis_user_table AS NU
ON N.reporter_id = NU.id AND NU.access_level = 55
INNER JOIN mantis_bug_history_table H ON B.id = H.bug_id
INNER JOIN mantis_user_table AS HU
ON H.user_id = HU.id
AND HU.access_level = 70
AND HU.username IN ('jjezdik','rkoutek','psochorovsky','jseifert')
WHERE B.id = " . db_param();
$result = db_query_bound($query, Array($c_bug_id));
$count = db_num_rows($result);
while ($rec = db_fetch_array($result)) {
$recipients[$rec['id']] = $rec['email'];
}
}
}
break;
case REFUSED: //odmítnutý
if (!(($bug->isCee() || $bug->isFast()))) {
// PBE 1.5.2011 omezeni obesilanych lidi pri zadani poznamky na 4 z facility
$query = "SELECT DISTINCT HU.id as user_id
FROM mantis_bug_table AS B
INNER JOIN mantis_bugnote_table AS N ON B.id = N.bug_id
INNER JOIN mantis_user_table AS NU
ON N.reporter_id = NU.id AND NU.access_level = 55
INNER JOIN mantis_bug_history_table H ON B.id = H.bug_id
INNER JOIN mantis_user_table AS HU
ON H.user_id = HU.id
AND HU.access_level = 70
AND HU.username IN ('jjezdik','rkoutek','psochorovsky','jseifert')
WHERE B.id = " . db_param();
$result = db_query_bound($query, Array($c_bug_id));
$count = db_num_rows($result);
while ($rec = db_fetch_array($result)) {
$recipients[$rec['id']] = $rec['email'];
}
}
break;
case CLOSED: //uzavřený
break;
default:
}
/*echo "kolik:".count($recipients);
foreach ($recipients as $k => $r)
{
echo "$r:$k<br />";
}*/
return $recipients;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment