Segment pageUrl not working properly -plugin 'Live' should be updated

I was having some issues for filtering correctly the segment ‘pageUrl’ with the plugin Live.

At first you can see what is going to print out when one wants to filter some words out from the url.

Segment Editor configuration:
http://s1.directupload.net/file/d/3345/m6xbz7q5_jpg.htm

Segment Output
http://s7.directupload.net/file/d/3345/qj59i95k_jpg.htm

So that i could have some better filtering. I’ve made somes changes in the filre ./plugin/Live/API.php
It doesnt look profissional, but now it does exactly what it is expected.

By the way I am not a programmer, but a sysadministrator and i am pretty sure that some other people would like this change. I know that there is a file ./core/SegmentExpression.php which could be used in order to not repeating few lines. I just didnt want to waste time trying to figure it out how it is possible. Anyway here is what i changed:

./plugin/Live/API.php


private function enrichVisitorArrayWithActions($visitorDetailsArray, $actionsLimit, $timezone)
    {

    $pattern='/^(.+?)(==|!=|>=|>|<=|<|=@|!@){1}(.*)/';
    $segmentsArray = array();
    $sqlsAndOr = array();

    if (isset($_REQUEST['segment'])){
        $getSegments = $_REQUEST['segment'];

        preg_match_all('/[,;]/',$getSegments,$andOr);
        foreach($andOr[0] as $sqlAndOr){
            switch ($sqlAndOr){
                case ';':
                $sqlsAndOr[] = 'AND';
                break;
            case ',':
                $sqlsAndOr[] = 'OR';
                break;
            }
        }

        $segmentSplit = preg_split('/[,;]/',$getSegments);

        foreach($segmentSplit as $segmentMatches){
               preg_match($pattern,$segmentMatches,$segmentArray);
            switch ($segmentArray[2]){
            case '==':
                $segmentArray[2] = "= '";
                $segmentArray[3] .= "'";
                break;
            case '!=':
                $segmentArray[2] = "<> '";
                $segmentArray[3] .= "'";
                break;
            case '>=':
                $segmentArray[2] = ">= '";
                $segmentArray[3] .= "'";
                break;
            case '>':
                $segmentArray[2] = "> '";
                $segmentArray[3] .= "'";
                break;
            case '<=':
                $segmentArray[2] = "<= '";
                $segmentArray[3] .= "'";
                break;
            case '<':
                $segmentArray[2] = "< '";
                $segmentArray[3] .= "'";
                break;
            case '=@':
                $segmentArray[2] = "LIKE '%";
                $segmentArray[3] .= "%'";
                break;
            case '!@':
                $segmentArray[2] = "NOT LIKE '%";
                $segmentArray[3] .= "%'";
                break;
            default:
                throw new Exception("Filter contains the match type '" . $segmentArray[2] . "' which is not supported");
                 break;
            }
            $segmentsArray[] = $segmentArray;
        }
        
        if (isset($segmentsArray[0][0])){

            $sqlUrl = "AND (";
            $i = 0; $addOr = 0;
            foreach($segmentsArray as $segment){
                switch($segment[1]){
                    case 'pageUrl':
                        if ($addOr++!=0) $sqlUrl .= $sqlsAndOr[$i-1] ." ";
                            $sqlUrl .= "log_action.name ". $segment[2] . $segment[3] ." ";
                }
                $i++;
            }
            $sqlUrl .= ")";
        } else $sqlUrl = "";
    } else $sqlUrl = "";

    if ($sqlUrl == "AND ()") $sqlUrl = "";

        $idVisit = $visitorDetailsArray['idVisit'];

        $sqlCustomVariables = '';
        for ($i = 1; $i <= Piwik_Tracker::MAX_CUSTOM_VARIABLES; $i++) {
            $sqlCustomVariables .= ', custom_var_k' . $i . ',
custom_var_v' . $i;
        }
        // The second join is a LEFT join to allow returning records that
don't have a matching page title
        // eg. Downloads, Outlinks. For these, idaction_name is set to 0
        $sql = "
                SELECT
                    COALESCE(log_action.type,log_action_title.type) AS type,
                    log_action.name AS url,
                    log_action.url_prefix,
                    log_action_title.name AS pageTitle,
                    log_action.idaction AS pageIdAction,
                    log_link_visit_action.idlink_va AS pageId,
                    log_link_visit_action.server_time as serverTimePretty,
                    log_link_visit_action.time_spent_ref_action as timeSpentRef,
                    log_link_visit_action.custom_float
                    $sqlCustomVariables
                FROM " . Piwik_Common::prefixTable('log_link_visit_action') . " AS log_link_visit_action
                    LEFT JOIN " . Piwik_Common::prefixTable('log_action') . " AS log_action
                    ON  log_link_visit_action.idaction_url = log_action.idaction
                    LEFT JOIN " . Piwik_Common::prefixTable('log_action') . " AS log_action_title
                    ON  log_link_visit_action.idaction_name = log_action_title.idaction
                WHERE log_link_visit_action.idvisit = ? ". $sqlUrl ."
                ORDER BY server_time ASC
                LIMIT 0, $actionsLimit
                 ";
...

Now it will be printed out only the url which contain the wished word.

http://s7.directupload.net/file/d/3345/c2st4j8g_jpg.htm

Should i add a Ticket for Piwik 2.0?

PS: great job with this OpenSource Projekt.

Kind Regards.

Can you please post a Pull request with your change and what problem it solves? thanks!
see http://piwik.org/participate/contributing-with-git/