Esempio n. 1
0
function send_tracks($data)
{
    global $API, $CONFIG;
    $accounts = $API->DB->query_return("SELECT tracks.*,accounts.email,accounts.email_notifications,accounts.safari_push_notifications,accounts.push_notifications FROM tracks LEFT JOIN accounts ON tracks.account_id=accounts.id WHERE tracks.trackid={$data['trackid']}");
    $link = $API->SEO->make_link('view', 'trackid', $data['trackid']);
    if ($accounts) {
        foreach ($accounts as $a) {
            $email_notifications = explode(',', $a['email_notifications']);
            $safari_push_notificaions = explode(',', $a['safari_push_notifications']);
            $push_notificaions = explode(',', $a['push_notifications']);
            if ($push_notifications[0] != 'none' || !$push_notifications[0] || in_array('tracks', $push_notifications)) {
                $push_accounts[] = $a['account_id'];
            }
            if ($email_notifications[0] != 'none' || !$email_notifications[0] || in_array('tracks', $email_notifications)) {
                $body = "{$API->LANG->_to($a['account_id'], 'Hello')}!<br/>\n        {$API->LANG->_to($a['account_id'], 'App "%s", that you are tracking has been updated to version %s', $data['name'], $data['version'])}.<br/>\n        {$API->LANG->_to($a['account_id'], 'You can download app here')}:<br/>\n        {$link}\n        <br/><br/>\n        --<br/>\n        {$API->LANG->_to($a['account_id'], 'Best regards, team of')} {$CONFIG['sitename']}.";
                //$API->send_mail($a['email'], $CONFIG['sitename'], $CONFIG['siteemail'], $API->LANG->_to($a['account_id'], "App that you are tracking has been updated to v.%s!", $data['version']), $body);
            }
            if ($safari_push_notificaions[0] != 'none' || !$safari_push_notificaions[0] || in_array('tracks', $safari_push_notificaions)) {
                send_push_safari($API->LANG->_to($a['account_id'], 'Notification'), $API->LANG->_to($a['account_id'], "App that you are tracking has been updated to v.%s!", $data['version']), $link, $a['account_id']);
            }
        }
        if ($push_accounts) {
            $devices = $API->DB->query_return("SELECT push.udid,accounts.id FROM push LEFT JOIN accounts ON push.account_id=accounts.id WHERE account_id IN(" . $API->DB->sqlesc(implode(',', $push_accounts)) . ")");
            if ($devices) {
                foreach ($devices as $d) {
                    $udidslang[$API->LANG->getlang($d['id'])][] = $d['udid'];
                }
                $json = json_encode(array('id' => $data['trackid']));
                foreach ($udidslang as $lang => $udids) {
                    send_push($API->LANG->_translate($lang, "App %s has been updated", $data['name']), 3, $json, implode(',', $udids));
                }
            }
        }
    }
}
Esempio n. 2
0
    if ($a) {
        $email_notifications = explode(',', $a['email_notifications']);
        $safari_push_notificaions = explode(',', $a['safari_push_notifications']);
        $push_notificaions = explode(',', $a['push_notifications']);
        if ($push_notificaions[0] != 'none' || !$push_notificaions[0] || in_array('moderator', $push_notificaions)) {
            $pushes = $API->DB->query_row("SELECT GROUP_CONCAT(udid) AS udids FROM push RIGHT JOIN accounts ON push.account_id=accounts.id WHERE account_id={$id}");
            if ($pushes['udids']) {
                send_push($API->LANG->_to($a['id'], "You received message from moderator, check your email"), 0, '', $pushes['udids']);
            }
        }
        if ($email_notifications[0] != 'none' || !$email_notifications[0] || in_array('moderator', $email_notifications)) {
            $body = "{$API->LANG->_to($a['id'], 'Hello')}!<br/>\n{$API->LANG->_to($a['id'], 'Moderator has useful short message for you, that can speed up approving your apps in future')}:<br/>\n<strong>{$msg}</strong><br/>\n{$API->LANG->_to($a['id'], 'Please review this message and take appropriate action')}.\n<br/><br/>\n--<br/>\n{$API->LANG->_to($a['id'], 'Best regards, team of')} {$CONFIG['sitename']}";
            $API->send_mail($a['email'], $CONFIG['sitename'], $CONFIG['siteemail'], $API->LANG->_to($a['id'], "Important message from moderator"), $body);
        }
        if ($safari_push_notificaions[0] != 'none' || !$safari_push_notificaions[0] || in_array('moderator', $safari_push_notificaions)) {
            send_push_safari($API->LANG->_to($id, "Notification"), "You received message from moderator, check your email", $CONFIG['defaultbaseurl'], $id);
        }
        die('Message sent');
    } else {
        die('Error: no such account');
    }
} elseif ($action == 'logs') {
    $API->auth(array('view_logs' => 1));
    $log_types = $API->DB->query_return("SELECT type FROM logs GROUP BY type");
    //$log_types = explode(',',$log_types['lt']);
    $API->TPL->assign('log_types', $log_types);
    $type = htmlspecialchars(trim($API->getval('type')));
    if ($type) {
        $q[] = "type = " . $API->DB->sqlesc($type);
    }
    $API->TPL->assign('type', $type);