Beispiel #1
0
function sms_custom_hook_setsmsincomingaction($sms_datetime, $sms_sender, $custom_keyword, $custom_param = '', $sms_receiver = '')
{
    $ok = false;
    $db_query = "SELECT uid,custom_id FROM " . _DB_PREF_ . "_featureCustom WHERE custom_keyword='{$custom_keyword}'";
    $db_result = dba_query($db_query);
    if ($db_row = dba_fetch_array($db_result)) {
        $c_uid = $db_row['uid'];
        if (sms_custom_handle($sms_datetime, $sms_sender, $custom_keyword, $custom_param)) {
            $ok = true;
        }
    }
    $ret['uid'] = $c_uid;
    $ret['status'] = $ok;
    return $ret;
}
Beispiel #2
0
/**
 * Implementations of hook recvsms_process()
 *
 * @param string $sms_datetime
 *        date and time when incoming sms inserted to playsms
 * @param string $sms_sender
 *        sender on incoming sms
 * @param string $keyword
 *        check if keyword is for sms_custom
 * @param string $custom_param
 *        get parameters from incoming sms
 * @param string $sms_receiver
 *        receiver number that is receiving incoming sms
 * @param string $smsc
 *        SMSC ID
 * @param string $raw_message
 *        raw incoming message
 * @return array $ret array of keyword owner uid and status, TRUE if incoming sms handled
 */
function sms_custom_hook_recvsms_process($sms_datetime, $sms_sender, $keyword, $custom_param = '', $sms_receiver = '', $smsc = '', $raw_message = '')
{
    $ok = FALSE;
    $keyword = trim(strtoupper($keyword));
    $sms_receiver = trim($sms_receiver);
    // match keyword with receiver number
    if ($sms_receiver) {
        $db_query = "SELECT uid, custom_id FROM " . _DB_PREF_ . "_featureCustom WHERE (custom_keyword='{$keyword}' OR custom_keyword LIKE '{$keyword} %' OR custom_keyword LIKE '% {$keyword}' OR custom_keyword LIKE '% {$keyword} %') AND sms_receiver='{$sms_receiver}'";
        $db_result = dba_query($db_query);
        if ($db_row = dba_fetch_array($db_result)) {
            $uid = $db_row['uid'];
            $custom_id = $db_row['custom_id'];
        }
    }
    // look for matching with catchall, if found it will override above matches
    $db_query = "SELECT uid, custom_id FROM " . _DB_PREF_ . "_featureCustom WHERE (custom_keyword='{$keyword}' OR custom_keyword LIKE '{$keyword} %' OR custom_keyword LIKE '% {$keyword}' OR custom_keyword LIKE '% {$keyword} %') AND sms_receiver = ''";
    $db_result = dba_query($db_query);
    if ($db_row = dba_fetch_array($db_result)) {
        $uid = $db_row['uid'];
        $custom_id = $db_row['custom_id'];
    }
    if ($uid && $custom_id) {
        if (sms_custom_handle($uid, $custom_id, $sms_datetime, $sms_sender, $sms_receiver, $keyword, $custom_param, $smsc, $raw_message)) {
            $ok = TRUE;
        }
        $ret['uid'] = $c_uid;
    }
    $ret['status'] = $ok;
    return $ret;
}