[mod] textline as a criteria

3rd party code for phpList

[mod] textline as a criteria

Postby MarkIngles » 6:40pm, Tue 29 Aug, 2006

Hello,
I needed to use a text line as a criteria to select users for a list. I added the code to do just that. I'm not sure why it wasn't there to begin with, so it might not work properly for you. It works for me. YMMV.

send_core.php around line 399 (right after the break for checkbox
Code: Select all
case "textline":
  $values = "attr$attribute$i";
  $value = $_POST[$values][0];

  if (isset($where_clause)) {
    $where_clause .= " and "; 
    $select_clause .= " left join $tables[user_attribute] as table$i on table$first.userid = table$i.userid ";
  } else {
    $select_clause = "table$i.userid from $tables[user_attribute] as table$i ";
    $first = $i;
  }

  $where_clause .= "table$i.attributeid = $attribute and ";
  if ($value) {
    $where_clause .= "( table$i.value LIKE '%$value%') ";
  } else {
    $where_clause .= "( table$i.value = '') ";
  }
break;


Line 1271 (after adding above) right before
default:
$criteria_content .= "\n -- error: huh, unknown type ".$attribute["type"]." --\n";

Code: Select all
case "textline":
  $any = 1;
  $criteria_content .= sprintf ('<tr><td><input>%s</td>
                        <td><b>is like</b></td><td><input></td></tr>',
                        $i, $attribute["id"], $attribute["name"], $attribute["id"],$i);
break;


That doesn't translate because I put the words "is like" in there instead of using the internationalizaion.

I hope this helps somebody.
This was against version 2.10.2.

-Mark
MarkIngles
phpLister
 
Posts: 7
Joined: 6:26pm, Tue 29 Aug, 2006
Location: Sunny Florida, USA

Postby H2B2 » 6:51pm, Tue 29 Aug, 2006

Hi Mark,

Thanks for sharing your mod! :D

Cheers,
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby MarkIngles » 6:52pm, Tue 29 Aug, 2006

You should see a birthday or anniversary one coming soon. I'm not exactly sure where to put it yet.
-Mark
MarkIngles
phpLister
 
Posts: 7
Joined: 6:26pm, Tue 29 Aug, 2006
Location: Sunny Florida, USA

Postby Menathor » 4:57am, Sun 03 Sep, 2006

Hey Mark - thanks for the mod- works great!! I really hope textline searches can be included in the send message criteria in the next release - it using lists via attributes so much more powerful!!


One thing I noticed- text field appears on the simple critera page when sending messages, but not when using the advanced critiera page (when define"STACKED_ATTRIBUTE_SELECTION" at line 378 in config.php = 1 instead of 0). I've tried playing around with the code to get it working but to no avail.

Any suggestions?


Cheers,
Raj
Menathor
phpLister
 
Posts: 14
Joined: 3:14pm, Tue 29 Aug, 2006

Postby MarkIngles » 6:26am, Sun 03 Sep, 2006

I don't use the advanced selection, so it doesn't work for that.
Mark
MarkIngles
phpLister
 
Posts: 7
Joined: 6:26pm, Tue 29 Aug, 2006
Location: Sunny Florida, USA

Postby flug » 12:26am, Mon 25 Sep, 2006

The patch above didn't work for me. However the patch below does--giving radio buttons allowing me to select any of the several textline attributes I have in my database.


send_core.php around line 399 (right after the break for checkbox

Code: Select all
case "textline":
  $values = "attr$attribute$i";
  $value = $_POST[$values][0];

  if (isset($where_clause)) {
    $where_clause .= " and ";
    $select_clause .= " left join $tables[user_attribute] as table$i on table$first.userid = table$i.userid ";
  } else {
    $select_clause = "table$i.userid from $tables[user_attribute] as table$i ";
    $first = $i;
  }

  $where_clause .= "table$i.attributeid = $attribute and ";
  if ($value) {
    $where_clause .= "( table$i.value LIKE '%$value%') ";
  } else {
    $where_clause .= "( table$i.value = '') ";
  }
break;


Line 1271 (after adding above) right before default:
$criteria_content .= "\n -- error: huh, unknown type ".$attribute["type"]." --\n";

Code: Select all
        case "textline":
            $any = 1;
            $criteria_content .= sprintf ('<tr><td><input>%s</td>
                        <td><b>is like</b></td><td><input></td></tr>',
                        $i, $attribute["id"], $attribute["name"], $attribute["id"],$i);
          break;


This still doesn't work under the "advance attributes" (or "stacked attributes").

This still doesn't appear to save the criteria you have selected (ie, when you go back to the criteria page it looks like everything is de-selected and so you think that it didn't "save" your selected criteria--but it did in fact actually save). The workaround for this is to note the message number, go to "messages", view the message, note the SQL code under "userselection". There you can see your selection has actually been saved.

This is under PHPList 2.10.2.
flug
PL Nut
 
Posts: 25
Joined: 12:17am, Mon 28 Aug, 2006

Postby flug » 2:25am, Mon 25 Sep, 2006

OK, here is a mod that will also work with stacked attributes.

First, this is a little more extensive than the mod above.

2nd, be sure to save a backup copy of send_core.php, the file you will be working on--so you can restore that original file if something goes wrong.

3rd, this is for PHPList 2.10.2--it might work for other versions that are not too different from 2.10.2.

4th, line numbers are only approximate.

5th, before doing this mod, first put in place the mod listed above on this thread (although I think they are pretty much independent of each other, I haven't tested this mod independently).

6th, this mod only works with "stacked attribute" functionality, so to use it go to your config.php file and change this setting as follows:

Code: Select all
define("STACKED_ATTRIBUTE_SELECTION",1);


7th, I've tested this a little but not extensively.

8th, If you don't want to make all these mods, here is a download with a complete "send_core.php" you should be able to drop in as a replacement for the one in ver 2.10.2. It contains all the mods on this thread plus the "calculate" bug fix. But do keep a backup of your original send_core.php:

http://mobikefed.dreamhosters.com/phplist/admin/send_core.zip

Here is the mod:

Near line 799, you will find 'case "date": . . . . break;'.

After the 'break;' but before the
Code: Select all
     default:
        if (isset($where_clause)) {

insert this code:

Code: Select all
      case "textline":
        $textline_value = $crit_data["values"];
 
        if (!$textline_value) {
          break;
        }
        if (isset($where_clause)) {
          $where_clause .= " $mainoperator ";
          $select_clause .= " left join $tables[user_attribute] as table$tc on table0.userid = table$tc.userid ";
        } else {
          $select_clause = " table$tc.userid from $tables[user_attribute] as table$tc ";
        }

        $where_clause .= ' ( table'.$tc.'.attributeid = '.$crit_data["attribute"].' and table'.$tc.'.value != "" and table'.$tc.'.value ';
        $textlineoperator = '';
        switch ($crit_data["operator"]) {
          case "is":
            $where_clause .= ' = "'.$date_value . '" )';$textlineoperator = '=';break;
          case "isnot":
            $where_clause .= ' != "'.$date_value . '" )';$textlineoperator = '!=';break;
          case "like":
            $where_clause .= ' LIKE "'.$date_value . '" )';
            $textlineoperator = 'LIKE';
            $textline_value="%".$textline_value."%";
            break;
          case "notlike":
            $where_clause .= ' NOT LIKE "'.$date_value . '" )';
            $textlineoperator = 'NOT LIKE';
            $textline_value="%".$textline_value."%";
            break;

        }
#        $where_clause .= " )";
        $subqueries[$i]['query'] = sprintf('select userid from %s where attributeid = %d and value != "" and value %s "%s" ',$GLOBALS['tables']['user_attribute'],
          $crit_data['attribute'],
          $textlineoperator,
          $textline_value);

        break;


Near line 1413 find this code:
Code: Select all
$attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox") %s',$tables["attribute"],$already_used));

Replace with this:
Code: Select all
   $attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox","textline") %s',$tables["attribute"],$already_used));


Around line 1458 find this code:
Code: Select all
      case "date":
        $att_js .= sprintf('value_divs[%d] = "criteria_values_text";'."\n",$att["id"]);
        $att_js .= sprintf('value_default[%d] = "%s";'."\n",$att["id"],$GLOBALS['I18N']->get('dd-mm-yyyy'));
        $att_js .= sprintf('values[%d] = new Array(%d);'."\n",$att["id"],1);

        $att_js .= sprintf('values[%d][%d] =  new Option("%s","%d",false,false);'."\n",$att["id"],$c,
         "Date" ,"dd-mm-yyyy"); # just to avoid javascript errors, not actually used
        $att_js .= sprintf('operators[%d] = new Array(4);'."\n",$att["id"]);
        $att_js .= sprintf('operators[%d][0] =  new Option("%s","is",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('is'));
        $att_js .= sprintf('operators[%d][1] =  new Option("%s","isnot",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isnot'));
        $att_js .= sprintf('operators[%d][2] =  new Option("%s","isbefore",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isbefore'));
        $att_js .= sprintf('operators[%d][3] =  new Option("%s","isafter",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isafter'));

Replace that entire code with this:
Code: Select all
      case "textline":

        $att_js .= sprintf('value_divs[%d] = "criteria_values_text";'."\n",$att["id"]);
        $att_js .= sprintf('value_default[%d] = "%s";'."\n",$att["id"],'');
        $att_js .= sprintf('values[%d] = new Array(%d);'."\n",$att["id"],1);
        //bhugh, rem-ed out because it somehow conflicts with the actual value the person enters for this criterion
        //$att_js .= sprintf('values[%d][%d] =  new Option("%s","%d",false,false);'."\n",$att["id"],"0",
        //  $att["id"],"dd-mm-yyyy"); # just to avoid javascript errors, not actually used
        $att_js .= sprintf('operators[%d] = new Array(4);'."\n",$att["id"]);
        $att_js .= sprintf('operators[%d][0] =  new Option("%s","is",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('is'));
        $att_js .= sprintf('operators[%d][1] =  new Option("%s","isnot",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isnot'));
        $att_js .= sprintf('operators[%d][2] =  new Option("%s","like",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('like'));
        $att_js .= sprintf('operators[%d][3] =  new Option("%s","notlike",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('notlike'));
        break;

      case "date":
        $att_js .= sprintf('value_divs[%d] = "criteria_values_text";'."\n",$att["id"]);
        $att_js .= sprintf('value_default[%d] = "%s";'."\n",$att["id"],$GLOBALS['I18N']->get('dd-mm-yyyy'));
        $att_js .= sprintf('values[%d] = new Array(%d);'."\n",$att["id"],1);
        //bhugh, rem-ed out because it somehow conflicts with the actual value the person enters for this criterion
        //$att_js .= sprintf('values[%d][%d] =  new Option("%s","%d",false,false);'."\n",$att["id"],$c,
        // "Date" ,"dd-mm-yyyy"); # just to avoid javascript errors, not actually used
        $att_js .= sprintf('operators[%d] = new Array(4);'."\n",$att["id"]);
        $att_js .= sprintf('operators[%d][0] =  new Option("%s","is",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('is'));
        $att_js .= sprintf('operators[%d][1] =  new Option("%s","isnot",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isnot'));
        $att_js .= sprintf('operators[%d][2] =  new Option("%s","isbefore",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isbefore'));
        $att_js .= sprintf('operators[%d][3] =  new Option("%s","isafter",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isafter'));

[Note: The above also fixes a bug in the "Date" attribute code that prevented it from working on my installation. However it may cause javascript errors--though I haven't encountered them.]

Around line 1557 find this code:
Code: Select all
$attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox") %s',$tables["attribute"],$already_used));


Replace with this:
Code: Select all
  $attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox","textline") %s',$tables["attribute"],$already_used));
Last edited by flug on 5:24pm, Mon 25 Sep, 2006, edited 1 time in total.
flug
PL Nut
 
Posts: 25
Joined: 12:17am, Mon 28 Aug, 2006

Postby H2B2 » 3:23am, Mon 25 Sep, 2006

flug,

Thanks for your contribution! :D
H2B2
Moderator
 
Posts: 7188
Joined: 1:51am, Wed 15 Mar, 2006

Postby flug » 1:31am, Tue 26 Sep, 2006

This still doesn't appear to save the criteria you have selected


I should clarify that both under the original 2.10.2 code and under the mods appearing on this thread, this is an *appearance only*--ie, the criteria you select are actually saved just fine. But when you return to the criteria page nothing is selected which leads you to believe (incorrectly) that your settings were not saved.

In fact your criteria were saved, and you can verify this by going to "messages" and looking at the info for the message you are working on.
flug
PL Nut
 
Posts: 25
Joined: 12:17am, Mon 28 Aug, 2006

Re: textline as a criteria

Postby albert » 8:22am, Sat 24 Mar, 2007

I did exactly what you did..
I filled in the "Position" is like "network"
but the criteria did not work...
why
I selected the other criteria and they worked.

MarkIngles wrote:Hello,
I needed to use a text line as a criteria to select users for a list. I added the code to do just that. I'm not sure why it wasn't there to begin with, so it might not work properly for you. It works for me. YMMV.
albert
phpList newbie
 
Posts: 1
Joined: 7:53am, Sat 24 Mar, 2007

Postby flug » 6:00am, Thu 24 May, 2007

I've modded the mod again.

Now it also has the ability to

1. Do textline searches where the search is a comma-separated list and the search finds ANY of the terms list.

I use this typically to search for zip codes. Like: search for zip IN "64133,64134,64123". The result is users with ANY of those zips. Or you could search for city IN "Jonestone, Smithville" to find users in EITHER of those two towns.

2. Do textline searches for a list of items using the LIKE-style matching. So you could search for zip codes LIKE-IN "6413,6414,6417" which would match. 64130, 64131,64132, 64140,64141, 64142, 64170,64171, 64172, etc.

3. Do the "NOT" of either of these searches (ie, find all user who do not live in zip 64132,64133,64134).

* Be sure to save a backup copy of send_core.php, the file you will be working on--so you can restore that original file if something goes wrong.

* This is for PHPList 2.10.2--it might work for other versions that are not too different from 2.10.2.

* Line numbers are only approximate.

* This mod only works with "stacked attribute" functionality, so to use it go to your config.php file and change this setting as follows:

Code: Select all
define("STACKED_ATTRIBUTE_SELECTION",1);


* I've tested this a little but not extensively.

* If you don't want to make all these mods, here is a download with a complete "send_core.php" you should be able to drop in as a replacement for the one in ver 2.10.2. It contains all the mods on this thread plus the "calculate" bug fix and a few other misc. bug fixes. But do keep a backup of your original send_core.php:

http://mobikefed.dreamhosters.com/phplist/admin/send_core2.zip

Here is the mod:

Near line 799, you will find 'case "date": . . . . break;'.

After the 'break;' but before the
Code: Select all
     default:
        if (isset($where_clause)) {

insert this code:

Code: Select all
            case "textline":
        $textline_value = $crit_data["values"];
 
        if (!$textline_value) {
          break;
        }
        if (isset($where_clause)) {
          $where_clause .= " $mainoperator ";
          $select_clause .= " left join $tables[user_attribute] as table$tc on table0.userid = table$tc.userid ";
        } else {
          $select_clause = " table$tc.userid from $tables[user_attribute] as table$tc ";
        }

        $where_clause .= ' ( table'.$tc.'.attributeid = '.$crit_data["attribute"].' and table'.$tc.'.value != "" and table'.$tc.'.value ';
        $textlineoperator = '';
        switch ($crit_data["operator"]) {
          case "is":
            $where_clause .= ' = "'.$textline_value . '" )';
            $textlineoperator = '=';
            $textline_value='"'.$textline_value.'"';
            $textline_not=false; //true if a "not" or "!=" type select
            break;
          case "isnot":
            $where_clause .= ' != "'.$textline_value . '" )';$textlineoperator = '!=';break;
            $textline_not=true; //true if a "not" or "!=" type select
          case "like":
            $where_clause .= ' LIKE "'.$textline_value . '" )';
            $textlineoperator = 'LIKE';
            $textline_value="\"%".$textline_value."%\"";
            $textline_not=false; //true if a "not" or "!=" type select
            break;
          case "notlike":
            $where_clause .= ' NOT LIKE "'.$textline_value . '" )';
            $textlineoperator = 'NOT LIKE';
            $textline_value="\"%".$textline_value."%\"";
            $textline_not=true; //true if a "not" or "!=" type select
            break;

          //bhugh, 5/2007, added to get "in" & "not in" options working with textline
          case "in":
            $textlineoperator = 'IN';
            //escape the textline to make it SQL safe, then turn it into a comma-separated
            //list with each value enclosed in "", like "first","second","third","etc"
            $textline_value= mysql_real_escape_string($textline_value);
            $textline_value_array=explode(",",$textline_value);
            $textline_value='"' . implode ('","',   $textline_value_array) . '"';
            $textline_value="(".$textline_value.")";
            $where_clause .= ' IN ('.$textline_value . ') )';
            $textline_not=false; //true if a "not" or "!=" type select
            break;
          case "not in":
            $textlineoperator = 'NOT IN';
            //escape the textline to make it SQL safe, then turn it into a comma-separated
            //list with each value enclosed in "", like "first","second","third","etc"
            $textline_value= mysql_real_escape_string($textline_value);
            $textline_value_array=explode(",",$textline_value);
            $textline_value='"' . implode ('","',   $textline_value_array) . '"';
            $where_clause .= ' NOT IN ('.$textline_value . ') )';
            $textline_value="(".$textline_value.")";
            $textline_not=true; //true if a "not" or "!=" type select
            break;

          case "likein":
            $textlineoperator = 'LIKE';
            //escape the textline to make it SQL safe, then turn it into a comma-separated
            //list with each value enclosed in "", like "first","second","third","etc"
            $textline_value= mysql_real_escape_string($textline_value);
            $textline_value_array=explode(",",$textline_value);
            //OK, this is a kludge
            $textline_value='"%' . implode ('%") or value LIKE ("%',   $textline_value_array) . '%"';
            $where_clause .= ' IN ('.$textline_value . ') )';
            $textline_value="(".$textline_value.")";
            $textline_not=false; //true if a "not" or "!=" type select
            break;

          case "not likein":
            $textlineoperator = 'NOT LIKE';
            //escape the textline to make it SQL safe, then turn it into a comma-separated
            //list with each value enclosed in "", like "first","second","third","etc"
            $textline_value= mysql_real_escape_string($textline_value);
            $textline_value_array=explode(",",$textline_value);
            //OK, this is a kludge
            $textline_value='"%' . implode ('%") and value NOT LIKE ("%',   $textline_value_array) . '%"';
            $where_clause .= ' IN ('.$textline_value . ') )';
            $textline_value="(".$textline_value.")";
            $textline_not=true; //true if a "not" or "!=" type select
            break;


        }
#        $where_clause .= " )";
        //bhugh, in case of "NOT" or "!=" type query, must do right join so as to be sure
        //to include all users who don't even have the attribute marked/listed in the attribute table
        //ie, if the attribute is zipcode, some users have zip 12345, some 12346, some have
        //NO ZIP CODE ENTERED in the attribute table.  So query zip=12345 is easy.  But
        //for query zip!=12345 you have to right join with the entire user table (and also
        //use a slightly different "where" clause so as
        //to include all users who don't even have a zipcode entered at all.
        if ($textline_not) {
        $subqueries[$i]['query'] = sprintf('select id from %s as table%d right join %s as tableb%d on table%d.userid=tableb%d.id and table%d.attributeid = %d where  ( value %s %s )',
          $GLOBALS['tables']['user_attribute'],$tc,
          $GLOBALS['tables']['user'], $tc,
          $tc, $tc, $tc,
          $crit_data['attribute'],
          $textlineoperator,
          $textline_value);
        } else {
          $subqueries[$i]['query'] = sprintf('select userid from %s where attributeid = %d and value != "" and ( value %s %s )',$GLOBALS['tables']['user_attribute'],
          $crit_data['attribute'],
          $textlineoperator,
          $textline_value);
        }


        break;


Near line 1413 find this code:
Code: Select all
$attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox") %s',$tables["attribute"],$already_used));

Replace with this:
Code: Select all
   $attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox","textline") %s',$tables["attribute"],$already_used));


Around line 1458 find this code:
Code: Select all
      case "date":
        $att_js .= sprintf('value_divs[%d] = "criteria_values_text";'."\n",$att["id"]);
        $att_js .= sprintf('value_default[%d] = "%s";'."\n",$att["id"],$GLOBALS['I18N']->get('dd-mm-yyyy'));
        $att_js .= sprintf('values[%d] = new Array(%d);'."\n",$att["id"],1);

        $att_js .= sprintf('values[%d][%d] =  new Option("%s","%d",false,false);'."\n",$att["id"],$c,
         "Date" ,"dd-mm-yyyy"); # just to avoid javascript errors, not actually used
        $att_js .= sprintf('operators[%d] = new Array(4);'."\n",$att["id"]);
        $att_js .= sprintf('operators[%d][0] =  new Option("%s","is",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('is'));
        $att_js .= sprintf('operators[%d][1] =  new Option("%s","isnot",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isnot'));
        $att_js .= sprintf('operators[%d][2] =  new Option("%s","isbefore",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isbefore'));
        $att_js .= sprintf('operators[%d][3] =  new Option("%s","isafter",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isafter'));

Replace that entire code with this:
Code: Select all
      case "textline":

        $att_js .= sprintf('value_divs[%d] = "criteria_values_text";'."\n",$att["id"]);
        $att_js .= sprintf('value_default[%d] = "%s";'."\n",$att["id"],'');
        $att_js .= sprintf('values[%d] = new Array(%d);'."\n",$att["id"],1);
        //bhugh, rem-ed out because it somehow conflicts with the actual value the person enters for this criterion
        //$att_js .= sprintf('values[%d][%d] =  new Option("%s","%d",false,false);'."\n",$att["id"],"0",
        //  $att["id"],"dd-mm-yyyy"); # just to avoid javascript errors, not actually used
        $att_js .= sprintf('operators[%d] = new Array(4);'."\n",$att["id"]);
        //bhugh, 5/2007, added to get "in" & "not in" options working with textline
        $att_js .= sprintf('operators[%d][0] =  new Option("%s","in",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('in (comma-separated list)'));
        $att_js .= sprintf('operators[%d][1] =  new Option("%s","not in",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('not in (comma-separated list)'));
        $att_js .= sprintf('operators[%d][2] =  new Option("%s","is",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('is'));
        $att_js .= sprintf('operators[%d][3] =  new Option("%s","isnot",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isnot'));
        $att_js .= sprintf('operators[%d][4] =  new Option("%s","like",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('like'));
        $att_js .= sprintf('operators[%d][5] =  new Option("%s","notlike",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('notlike'));
        //bhugh, 5/2007, added to get "like-in" & "not like-in" options working with textline
$att_js .= sprintf('operators[%d][6] =  new Option("%s","likein",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('like-in (comma-separated list)'));
$att_js .= sprintf('operators[%d][7] =  new Option("%s","not likein",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('not like-in (comma-separated list)'));

        break;

      case "date":
        $att_js .= sprintf('value_divs[%d] = "criteria_values_text";'."\n",$att["id"]);
        $att_js .= sprintf('value_default[%d] = "%s";'."\n",$att["id"],$GLOBALS['I18N']->get('dd-mm-yyyy'));
        $att_js .= sprintf('values[%d] = new Array(%d);'."\n",$att["id"],1);
        //bhugh, rem-ed out because it somehow conflicts with the actual value the person enters for this criterion
        //$att_js .= sprintf('values[%d][%d] =  new Option("%s","%d",false,false);'."\n",$att["id"],$c,
        // "Date" ,"dd-mm-yyyy"); # just to avoid javascript errors, not actually used
        $att_js .= sprintf('operators[%d] = new Array(4);'."\n",$att["id"]);
        $att_js .= sprintf('operators[%d][0] =  new Option("%s","is",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('is'));
        $att_js .= sprintf('operators[%d][1] =  new Option("%s","isnot",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isnot'));
        $att_js .= sprintf('operators[%d][2] =  new Option("%s","isbefore",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isbefore'));
        $att_js .= sprintf('operators[%d][3] =  new Option("%s","isafter",false,true);'."\n",$att["id"],$GLOBALS['I18N']->get('isafter'));

[Note: The above also fixes a bug in the "Date" attribute code that prevented it from working on my installation. However it may cause javascript errors--though I haven't encountered them.]

Around line 1557 find this code:
Code: Select all
$attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox") %s',$tables["attribute"],$already_used));


Replace with this:
Code: Select all
  $attreq = Sql_Query(sprintf('select * from %s where type in ("select","radio","date","checkboxgroup","checkbox","textline") %s',$tables["attribute"],$already_used));
flug
PL Nut
 
Posts: 25
Joined: 12:17am, Mon 28 Aug, 2006

Postby Denver Dave » 5:39am, Sat 27 Oct, 2007

Thanks for the code. I haven't used it yet, but realize to manage newsletters by zip code would be difficult without it.

Do you know if this will be a standard part of phplist anytime in the near future?
Denver Dave
PL Nut
 
Posts: 34
Joined: 9:55pm, Wed 23 Jun, 2004

Work with 2.10.5

Postby kenwvs » 8:16pm, Sat 08 Dec, 2007

I am wondering if anyone has used this mod with version 2.10.5 and if it is working properly.

Thanks for posting this mod, it is exactly what I am looking for.
kenwvs
phpLister
 
Posts: 7
Joined: 4:04am, Thu 12 Apr, 2007

Set Up and appears to work but not sending messages

Postby kenwvs » 11:57pm, Sat 08 Dec, 2007

I have gone through and configured the setup to what I believe is the proper settings, and am having a couple of problems.

1. If I am searching for a city that is two words, it puts the words together (example Red Deer becomes RedDeer) so it won't find the cities. Do I need to put something between the words?

2. I locate the records I want to send a mailing to, and it shows that there are records, but when I process the queuee, it doesn't send any emails. This is the message I am getting. I am not using the lists at all, and am not sure if this is what is causing the problem.

Processing message 114
Looking for users
31 users apply for attributes, now checking lists
Found them: 0 to process
Processed 0 out of 0 users
Hmmm, No users found to send to
It took 8 mins 18 secs to send this message
Script stage: 3
Finished, Nothing to do
Finished, All done

Thanks for your help!!

Ken
kenwvs
phpLister
 
Posts: 7
Joined: 4:04am, Thu 12 Apr, 2007

Re: Set Up and appears to work but not sending messages

Postby flug » 1:53am, Sun 09 Dec, 2007

kenwvs wrote:2. I locate the records I want to send a mailing to, and it shows that there are records, but when I process the queuee, it doesn't send any emails. This is the message I am getting. I am not using the lists at all, and am not sure if this is what is causing the problem.


Ken,

I'm not sure exactly what you mean by "I am not using the lists at all" but my guess is that is the cause of the problem.

Does that mean you are not selecting any list to send your message to?

If so, then what you see is the expected & normal PHPList behavior.

The message "31 users apply for attributes" simply means that there are 31 users in your user database that the attributes apply to.

However when you go to send a message, it will only go to those users for which BOTH of these two things are true:

1. The attributes you have selected apply to them

2. They are subscribed to the list that message is being sent to.

My guess is you have 31 users falling into category #1 but ZERO users falling into category #2 and therefore your message goes to no one.

Solution--go in & select a mailing list for your message to go to.

Hint #1: For testing purposes I set up a few fake users on a "test email list", gave them different zip codes or whatever attribute I wanted to test, & then mailed things to this test list.

Hint #2: Most email providers allow you to add some characters to your email address with a "+" character.

So for instance in my case I made users of my test list like:

flug+1@flug.com
flug+2@flug.com
flug+3@flug.com
etc.

I signed them all up separately with phplist and gave them some different attributes as I needed for testing. But when I send some thing to the test list it just all comes to me.

This allows me to test things without bothering my real users with test emails.
flug
PL Nut
 
Posts: 25
Joined: 12:17am, Mon 28 Aug, 2006

Next

Return to Contributions: Plug-ins, Add-ons, Mods

Who is online

Users browsing this forum: No registered users and 3 guests