mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
Add the search for 1st character of certain fields, showing alphabet at the top. This feature was lost for 2 years(!), so hopefully it works for you.
This commit is contained in:
parent
65dd2fb78c
commit
63d80f2fcd
@ -84,6 +84,7 @@
|
||||
/* Might change this to '' at the end---> */
|
||||
$_start = get_var('start',array('POST','GET'));
|
||||
$_query = get_var('query',array('POST','GET'));
|
||||
$_cquery = get_var('cquery', array('GET'));
|
||||
$_sort = get_var('sort',array('POST','GET'));
|
||||
$_order = get_var('order',array('POST','GET'));
|
||||
$_filter = get_var('filter',array('POST','GET'));
|
||||
@ -104,6 +105,13 @@
|
||||
$this->query = $_query;
|
||||
}
|
||||
|
||||
if((empty($_cquery) && !empty($this->cquery)) || !empty($_cquery))
|
||||
{
|
||||
$this->cquery = $_cquery;
|
||||
}
|
||||
|
||||
// $this->cquery = ((empty($_cquery) && !empty($this->cquery)) || !empty($_cquery)) ? $_cquery : $this->cquery;
|
||||
|
||||
if(isset($_POST['fcat_id']) || isset($_POST['fcat_id']))
|
||||
{
|
||||
$this->cat_id = $_fcat_id;
|
||||
@ -145,6 +153,7 @@
|
||||
'start' => $this->start,
|
||||
'limit' => $this->limit,
|
||||
'query' => $this->query,
|
||||
'cquery' => $this->cquery,
|
||||
'sort' => $this->sort,
|
||||
'order' => $this->order,
|
||||
'filter' => $this->filter,
|
||||
@ -228,6 +237,7 @@
|
||||
$this->start = $data['start'];
|
||||
$this->limit = $data['limit'];
|
||||
$this->query = $data['query'];
|
||||
$this->cquery = $data['cquery'];
|
||||
$this->sort = $data['sort'];
|
||||
$this->order = $data['order'];
|
||||
$this->filter = $data['filter'];
|
||||
@ -245,7 +255,7 @@
|
||||
{
|
||||
if(@is_array($dirty[$i]))
|
||||
{
|
||||
while(list($name,$value) = @each($dirty[$i]))
|
||||
foreach($dirty[$i] as $name => $value)
|
||||
{
|
||||
$cleaned[$i][$name] = $GLOBALS['phpgw']->strip_html($dirty[$i][$name]);
|
||||
}
|
||||
@ -348,7 +358,7 @@
|
||||
}
|
||||
if(!@$fields['owner'])
|
||||
{
|
||||
$fields['owner'] = $GLOBALS['phpgw_info']['user']['account_id'];
|
||||
$fields['owner'] = (int)$GLOBALS['phpgw_info']['user']['account_id'];
|
||||
}
|
||||
if(empty($fields['access']))
|
||||
{
|
||||
|
@ -34,6 +34,8 @@
|
||||
|
||||
function read_entries($data)
|
||||
{
|
||||
// echo 'OK!';
|
||||
// _debug_array($data);exit;
|
||||
return $this->contacts->read(
|
||||
$data['start'],
|
||||
$data['limit'],
|
||||
@ -41,7 +43,9 @@
|
||||
$data['query'],
|
||||
$data['filter'],
|
||||
$data['sort'],
|
||||
$data['order']
|
||||
$data['order'],
|
||||
-1,
|
||||
$data['cquery']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -68,6 +68,7 @@
|
||||
$this->start = $this->bo->start;
|
||||
$this->limit = $this->bo->limit;
|
||||
$this->query = $this->bo->query;
|
||||
$this->cquery = $this->bo->cquery;
|
||||
$this->sort = $this->bo->sort;
|
||||
$this->order = $this->bo->order;
|
||||
$this->filter = $this->bo->filter;
|
||||
@ -81,6 +82,7 @@
|
||||
'start' => $this->start,
|
||||
'limit' => $this->limit,
|
||||
'query' => $this->query,
|
||||
'cquery' => $this->cquery,
|
||||
'sort' => $this->sort,
|
||||
'order' => $this->order,
|
||||
'filter' => $this->filter,
|
||||
@ -97,6 +99,7 @@
|
||||
'start' => $this->start,
|
||||
'limit' => $this->limit,
|
||||
'query' => $this->query,
|
||||
'cquery' => $this->cquery,
|
||||
'sort' => $this->sort,
|
||||
'order' => $this->order,
|
||||
'filter' => $this->filter,
|
||||
@ -232,6 +235,46 @@
|
||||
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','row','row');
|
||||
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','delete_block','delete_block');
|
||||
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','addressbook_footer','addressbook_footer');
|
||||
$GLOBALS['phpgw']->template->set_block('addressbook_list_t','addressbook_alpha','addressbook_alpha');
|
||||
|
||||
/* Setup query for 1st char of fullname, company, lastname using user lang */
|
||||
if(lang('alphabet') == 'alphabet*')
|
||||
{
|
||||
$aar = array('a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z');
|
||||
}
|
||||
else
|
||||
{
|
||||
$aar = explode(',',lang('alphabet'));
|
||||
}
|
||||
$aar[] = 'all';
|
||||
foreach($aar as $char)
|
||||
{
|
||||
if($this->cquery == $char ||
|
||||
($char == 'all' && !$this->cquery))
|
||||
{
|
||||
$GLOBALS['phpgw']->template->set_var('charbgcolor','#000000');
|
||||
$GLOBALS['phpgw']->template->set_var('charcolor','#FFFFFF');
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['phpgw']->template->set_var('charbgcolor',$GLOBALS['phpgw_info']['theme']['th_bg']);
|
||||
$GLOBALS['phpgw']->template->set_var('charcolor',$GLOBALS['phpgw_info']['theme']['th_text']);
|
||||
}
|
||||
if($char == 'all')
|
||||
{
|
||||
$GLOBALS['phpgw']->template->set_var('charlink',
|
||||
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index&cquery=')
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$GLOBALS['phpgw']->template->set_var('charlink',
|
||||
$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index&cquery=' . $char)
|
||||
);
|
||||
}
|
||||
$GLOBALS['phpgw']->template->set_var('char',$char != 'all' ? strtoupper($char) : lang('all'));
|
||||
$GLOBALS['phpgw']->template->fp('alphalinks','addressbook_alpha',True);
|
||||
}
|
||||
|
||||
$custom = $this->fields->read_custom_fields();
|
||||
$customfields = array();
|
||||
@ -402,6 +445,7 @@
|
||||
'fields' => $columns_to_display,
|
||||
'filter' => $qfilter,
|
||||
'query' => $this->query,
|
||||
'cquery' => $this->cquery,
|
||||
'sort' => $this->sort,
|
||||
'order' => $this->order
|
||||
));
|
||||
@ -641,9 +685,14 @@
|
||||
unset($fields['referer']);
|
||||
$fields['owner'] = $GLOBALS['phpgw_info']['user']['account_id'];
|
||||
|
||||
$this->bo->add_entry($fields);
|
||||
|
||||
$ab_id = $this->bo->get_lastid();
|
||||
$ab_id = $this->bo->add_entry($fields);
|
||||
if(@is_array($ab_id) || !$ab_id)
|
||||
{
|
||||
/* Errors encountered during validation */
|
||||
$errors = $ab_id;
|
||||
break;
|
||||
}
|
||||
// $ab_id = $this->bo->get_lastid();
|
||||
|
||||
Header('Location: '
|
||||
. $GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.view&ab_id=' . $ab_id . '&referer=' . $referer));
|
||||
@ -665,6 +714,11 @@
|
||||
|
||||
$this->addressbook_form('','menuaction=addressbook.uiaddressbook.add','Add','',$customfields,$this->cat_id);
|
||||
|
||||
$GLOBALS['phpgw']->template->set_var('errors','');
|
||||
if(@is_array($errors))
|
||||
{
|
||||
$GLOBALS['phpgw']->template->set_var('errors',implode(',',$errors));
|
||||
}
|
||||
$GLOBALS['phpgw']->template->set_var('lang_save',lang('Save'));
|
||||
$GLOBALS['phpgw']->template->set_var('lang_cancel',lang('Cancel'));
|
||||
$GLOBALS['phpgw']->template->set_var('cancel_url',$GLOBALS['phpgw']->link('/index.php','menuaction=addressbook.uiaddressbook.index'));
|
||||
@ -1199,7 +1253,7 @@
|
||||
. strtolower($cf) . ']"'
|
||||
. ($this->prefs[$cf] ? ' checked' : '')
|
||||
. '>' . str_replace('_',' ',$cf) . '</option></td>' . "\n";
|
||||
|
||||
|
||||
if(!(++$i % 6))
|
||||
{
|
||||
echo "</tr>\n";
|
||||
@ -1540,12 +1594,12 @@
|
||||
$temp_month[$month] = ' selected';
|
||||
$bday_month = '<select name="entry[bday_month]">'
|
||||
. '<option value=""' . $temp_month[0] . '>' . '</option>'
|
||||
. '<option value="1"' . $temp_month[1] . '>' . lang('january') . '</option>'
|
||||
. '<option value="1"' . $temp_month[1] . '>' . lang('january') . '</option>'
|
||||
. '<option value="2"' . $temp_month[2] . '>' . lang('february') . '</option>'
|
||||
. '<option value="3"' . $temp_month[3] . '>' . lang('march') . '</option>'
|
||||
. '<option value="4"' . $temp_month[4] . '>' . lang('april') . '</option>'
|
||||
. '<option value="5"' . $temp_month[5] . '>' . lang('may') . '</option>'
|
||||
. '<option value="6"' . $temp_month[6] . '>' . lang('june') . '</option>'
|
||||
. '<option value="6"' . $temp_month[6] . '>' . lang('june') . '</option>'
|
||||
. '<option value="7"' . $temp_month[7] . '>' . lang('july') . '</option>'
|
||||
. '<option value="8"' . $temp_month[8] . '>' . lang('august') . '</option>'
|
||||
. '<option value="9"' . $temp_month[9] . '>' . lang('september') . '</option>'
|
||||
@ -1673,7 +1727,7 @@
|
||||
if(!ereg('^http://',$url))
|
||||
{
|
||||
$url = 'http://' . $url;
|
||||
}
|
||||
}
|
||||
|
||||
$birthday = $GLOBALS['phpgw']->common->dateformatorder($bday_year,$bday_month,$bday_day)
|
||||
. '<font face="'.$theme["font"].'" size="-2">'.lang('(e.g. 1969)').'</font>';
|
||||
@ -1687,7 +1741,7 @@
|
||||
{
|
||||
$create .= '';
|
||||
}
|
||||
|
||||
|
||||
$GLOBALS['phpgw']->template->set_var('lang_home',lang('Home'));
|
||||
$GLOBALS['phpgw']->template->set_var('lang_business',lang('Business'));
|
||||
$GLOBALS['phpgw']->template->set_var('lang_personal',lang('Personal'));
|
||||
|
@ -22,6 +22,10 @@ function check_all(which)
|
||||
{lang_showing}
|
||||
<br>{searchreturn}
|
||||
{search_filter}
|
||||
<table width="95%" border="1" cellspacing="1" cellpadding="3">
|
||||
<tr>{alphalinks}
|
||||
</tr>
|
||||
</table>
|
||||
<table width="95%" border="0" cellspacing="1" cellpadding="3">
|
||||
<form name="addr_index" action="{action_url}" method="POST">
|
||||
<tr bgcolor="{th_bg}">{cols}
|
||||
@ -65,3 +69,6 @@ function check_all(which)
|
||||
</table>
|
||||
</div>
|
||||
<!-- END addressbook_footer -->
|
||||
|
||||
<!-- BEGIN addressbook_alpha --><td bgcolor="{charbgcolor}" align="center"><a href="{charlink}"><font color="{charcolor}">{char}</a></font></td>
|
||||
<!-- END addressbook_alpha -->
|
||||
|
@ -116,25 +116,26 @@
|
||||
@param $order string sort-order DESC=descending, ASC=ascending
|
||||
@param $lastmod integer get only fields modified since, -1=for all
|
||||
*/
|
||||
function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='', $lastmod=-1)
|
||||
function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='', $lastmod=-1,$cquery='')
|
||||
{
|
||||
if(@is_array($fields))
|
||||
{
|
||||
$fields['owner'] = 'owner'; // we need the owner to set the rights
|
||||
}
|
||||
if ($entrys = contacts_::read($start,$limit,$fields,$query,$filter,$sort,$order, $lastmod))
|
||||
if($entries = contacts_::read($start,$limit,$fields,$query,$filter,$sort,$order,$lastmod,$cquery))
|
||||
{
|
||||
foreach($entrys as $nr => $entry)
|
||||
foreach($entries as $nr => $entry)
|
||||
{
|
||||
$entrys[$nr]['rights'] = (int)$this->grants[$entry['owner']];
|
||||
$entries[$nr]['rights'] = (int)$this->grants[$entry['owner']];
|
||||
}
|
||||
}
|
||||
return $entrys;
|
||||
return $entries;
|
||||
}
|
||||
|
||||
function split_stock_and_extras($fields)
|
||||
{
|
||||
while (list($field,$value) = @each($fields))
|
||||
settype($fields, 'array');
|
||||
foreach($fields as $field => $value)
|
||||
{
|
||||
/* Depending on how the array was built, this is needed. */
|
||||
if(@is_int($value))
|
||||
@ -157,11 +158,10 @@
|
||||
function loop_addslashes($fields)
|
||||
{
|
||||
$absf = $this->stock_contact_fields;
|
||||
while ($t = each($absf))
|
||||
foreach($absf as $t => $nul)
|
||||
{
|
||||
$ta[] = $this->db->db_addslashes($fields[$t[0]]);
|
||||
$ta[] = $this->db->db_addslashes($fields[$t]);
|
||||
}
|
||||
reset($absf);
|
||||
return $ta;
|
||||
}
|
||||
|
||||
@ -170,7 +170,7 @@
|
||||
{
|
||||
if(@is_array($id))
|
||||
{
|
||||
while (list($null,$t_id) = each($id))
|
||||
foreach($id as $nul => $t_id)
|
||||
{
|
||||
$this->delete_($t_id);
|
||||
}
|
||||
@ -184,14 +184,20 @@
|
||||
function asc_sort($a,$b)
|
||||
{
|
||||
echo "<br>A:'".$a."' B:'".$b;
|
||||
if($a[1]==$b[1]) return 0;
|
||||
if($a[1] == $b[1])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ($a[1]>$b[1])?1:-1;
|
||||
}
|
||||
|
||||
function desc_sort($a,$b)
|
||||
{
|
||||
echo "<br>A:'".$a."' B:'".$b;
|
||||
if($a[1]==$b[1]) return 0;
|
||||
if($a[1]==$b[1])
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return ($a[1]<$b[1])?1:-1;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@
|
||||
}
|
||||
|
||||
/* send this the range, query, sort, order and whatever fields you want to see */
|
||||
function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='', $lastmod=-1)
|
||||
function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='', $lastmod=-1,$cquery='')
|
||||
{
|
||||
if(!$start) { $start = 0; }
|
||||
if(!$limit) { $limit = 0; }
|
||||
@ -394,7 +394,16 @@
|
||||
$ldap_fields = array();
|
||||
$myfilter = '';
|
||||
|
||||
if($query)
|
||||
if($cquery)
|
||||
{
|
||||
$search_filter = array(
|
||||
'fn' => 'cn',
|
||||
'n_family' => 'sn',
|
||||
'org_name' => 'o'
|
||||
);
|
||||
$myfilter = $this->makefilter($filterfields,$search_filter,"$cquery*",$DEBUG);
|
||||
}
|
||||
elseif($query)
|
||||
{
|
||||
// the old code was searching about all fields
|
||||
// this was very slow
|
||||
@ -669,23 +678,21 @@
|
||||
$ldap_fields['objectclass'][0] = 'organizationalPerson';
|
||||
$ldap_fields['objectclass'][1] = 'inetOrgPerson';
|
||||
$ldap_fields['objectclass'][2] = 'phpgwContact';
|
||||
//$ldap_fields['last_mod'] = $GLOBALS['phpgw']->datetime->gmtnow;
|
||||
//$ldap_fields['last_mod'] = $GLOBALS['phpgw']->datetime->gmtnow;
|
||||
|
||||
// a hack!!
|
||||
// there should be some validate function in this class
|
||||
if(empty($ldap_fields['sn']))
|
||||
$err = $this->validate($ldap_fields);
|
||||
if(@is_array($err) && @isset($err[0]))
|
||||
{
|
||||
$ldap_fields['sn'] = $ldap_fields['cn'];
|
||||
return $err;
|
||||
}
|
||||
if(empty($ldap_fields['cn']))
|
||||
{
|
||||
$ldap_fields['cn'] = $ldap_fields['sn'];
|
||||
}
|
||||
|
||||
// _debug_array($ldap_fields); exit;
|
||||
$err = ldap_add($this->ldap, $dn, $ldap_fields);
|
||||
if(!$err)
|
||||
{
|
||||
return False;
|
||||
}
|
||||
|
||||
if (count($extra_fields))
|
||||
if(count($extra_fields))
|
||||
{
|
||||
while (list($name,$value) = each($extra_fields))
|
||||
{
|
||||
@ -696,6 +703,58 @@
|
||||
return $this->nextid;
|
||||
}
|
||||
|
||||
/* LDAP syntaxes require some testing prior to add */
|
||||
function validate(&$entry)
|
||||
{
|
||||
$errors = array();
|
||||
foreach($entry as $field => $value)
|
||||
{
|
||||
if(strstr($field,'phone'))
|
||||
{
|
||||
/* Regex for testing valid international phone number entries.
|
||||
* LDAP may reject bad values here, such as an email address in a phone number.
|
||||
* This format is somewhat loose, allowing for optional parenthesis, + sign,
|
||||
* and 0-7 numbers between separators.
|
||||
*/
|
||||
$regex = "/^[\s]*[\(]?[\+]?\d{0,7}[\s]?[\(]?[0-9]{0,7}[ ]?[\)]?[-]{0,7}[ ]?[0-9]{0,7}[ ]*[-]{0,7}[ ]*[0-9]{0,7}[ ]*$/x";
|
||||
if(!preg_match($regex,$value))
|
||||
{
|
||||
$errors[] = array($field => $value);
|
||||
}
|
||||
}
|
||||
elseif(strstr($field,'mailtype') || strstr($field,'mailhometype'))
|
||||
{
|
||||
/* Check for valid mail type */
|
||||
if(!@isset($this->email_types[$value]))
|
||||
{
|
||||
$errors[] = array($field => $value);
|
||||
}
|
||||
}
|
||||
elseif(strstr($field,'mail'))
|
||||
{
|
||||
/* Check for valid email address - TODO - should depend on mail type */
|
||||
$regex = "/[ |\t|\r|\n]*\"?([^\"]+\"?@[^ <>\t]+\.[^ <>\t][^ <>\t]+)[ |\t|\r|\n]*/x";
|
||||
if(!preg_match($regex,$value))
|
||||
{
|
||||
$errors[] = array($field => $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Verify sn/cn attrs set */
|
||||
if(empty($entry['sn']) && !empty($entry['cn']))
|
||||
{
|
||||
$entry['sn'] = $entry['cn'];
|
||||
}
|
||||
if(empty($entry['cn']) && !empty($entry['sn']))
|
||||
{
|
||||
$entry['cn'] = $entry['sn'];
|
||||
}
|
||||
$entry['cn'] = $entry['cn'] ? $entry['cn'] : '-';
|
||||
$entry['sn'] = $entry['sn'] ? $entry['sn'] : '-';
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
function field_exists($id,$field_name)
|
||||
{
|
||||
$this->db->query("select count(*) from $this->ext_table where contact_id='$id' and contact_name='"
|
||||
|
@ -189,7 +189,8 @@
|
||||
|
||||
if(@is_array($stock_fieldnames))
|
||||
{
|
||||
while (list($f_name) = each($stock_fieldnames))
|
||||
// while (list($f_name) = each($stock_fieldnames))
|
||||
foreach($stock_fieldnames as $f_name)
|
||||
{
|
||||
$return_fields[0][$f_name] = $this->db->f($f_name);
|
||||
}
|
||||
@ -199,8 +200,9 @@
|
||||
if ($this->db->f('adr_one_type'))
|
||||
{
|
||||
$one_type = $this->db->f('adr_one_type');
|
||||
reset($this->adr_types);
|
||||
while (list($name,$val) = each($this->adr_types))
|
||||
// reset($this->adr_types);
|
||||
// while (list($name,$val) = each($this->adr_types))
|
||||
foreach($this->adr_types as $name => $val)
|
||||
{
|
||||
eval("if (strstr(\$one_type,\$name)) { \$return_fields[0][\"one_\$name\"] = \"on\"; }");
|
||||
}
|
||||
@ -208,8 +210,9 @@
|
||||
if ($this->db->f('adr_two_type'))
|
||||
{
|
||||
$two_type = $this->db->f('adr_two_type');
|
||||
reset($this->adr_types);
|
||||
while (list($name,$val) = each($this->adr_types))
|
||||
// reset($this->adr_types);
|
||||
// while (list($name,$val) = each($this->adr_types))
|
||||
foreach($this->adr_types as $name => $val)
|
||||
{
|
||||
eval("if (strstr(\$two_type,\$name)) { \$return_fields[0][\"two_\$name\"] = \"on\"; }");
|
||||
}
|
||||
@ -258,7 +261,8 @@
|
||||
|
||||
if (@is_array($stock_fieldnames))
|
||||
{
|
||||
while (list($f_name) = each($stock_fieldnames))
|
||||
// while (list($f_name) = each($stock_fieldnames))
|
||||
foreach($stock_fieldnames as $f_name)
|
||||
{
|
||||
$return_fields[0][$f_name] = $this->db->f($f_name);
|
||||
}
|
||||
@ -268,8 +272,9 @@
|
||||
if ($this->db->f('adr_one_type'))
|
||||
{
|
||||
$one_type = $this->db->f('adr_one_type');
|
||||
reset($this->adr_types);
|
||||
while (list($name,$val) = each($this->adr_types))
|
||||
// reset($this->adr_types);
|
||||
// while (list($name,$val) = each($this->adr_types))
|
||||
foreach($this->adr_types as $name => $val)
|
||||
{
|
||||
eval("if (strstr(\$one_type,\$name)) { \$return_fields[0][\"one_\$name\"] = \"on\"; }");
|
||||
}
|
||||
@ -277,8 +282,9 @@
|
||||
if ($this->db->f('adr_two_type'))
|
||||
{
|
||||
$two_type = $this->db->f('adr_two_type');
|
||||
reset($this->adr_types);
|
||||
while (list($name,$val) = each($this->adr_types))
|
||||
// reset($this->adr_types);
|
||||
// while (list($name,$val) = each($this->adr_types))
|
||||
foreach($this->adr_types as $name => $val)
|
||||
{
|
||||
eval("if (strstr(\$two_type,\$name)) { \$return_fields[0][\"two_\$name\"] = \"on\"; }");
|
||||
}
|
||||
@ -296,7 +302,7 @@
|
||||
}
|
||||
|
||||
/* send this the range, query, sort, order and whatever fields you want to see */
|
||||
function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='', $lastmod=-1)
|
||||
function read($start=0,$limit=0,$fields='',$query='',$filter='',$sort='',$order='', $lastmod=-1,$cquery='')
|
||||
{
|
||||
if(!$start) { $start = 0; }
|
||||
if(!$limit) { $limit = 0; }
|
||||
@ -346,18 +352,20 @@
|
||||
}
|
||||
|
||||
/* now check each element of the array and convert into SQL for queries below */
|
||||
$i=0;
|
||||
reset($filterfields);
|
||||
while (list($name,$value) = each($filterfields))
|
||||
$i = 0;
|
||||
// reset($filterfields);
|
||||
// while (list($name,$value) = each($filterfields))
|
||||
foreach($filterfields as $name => $value)
|
||||
{
|
||||
if ($DEBUG) { echo '<br>DEBUG - Filter intermediate strings 2: #'.$name.'# => #'.$value.'#'; }
|
||||
$isstd=0;
|
||||
if ($name && empty($value))
|
||||
{
|
||||
if ($DEBUG) { echo '<br>DEBUG - filter field "'.$name.'" is empty (NULL)'; }
|
||||
while (list($fname,$fvalue)=each($check_stock))
|
||||
// while (list($fname,$fvalue)=each($check_stock))
|
||||
foreach($check_stock as $fname => $fvalue)
|
||||
{
|
||||
if ($fvalue==$name)
|
||||
if($fvalue == $name)
|
||||
{
|
||||
$filterlist .= $name.' is NULL,';
|
||||
if ($DEBUG) { echo '<br>DEBUG - filter field "'.$name.'" is a stock field'; }
|
||||
@ -367,26 +375,27 @@
|
||||
}
|
||||
elseif($name && $value)
|
||||
{
|
||||
reset($check_stock);
|
||||
while (list($fname,$fvalue)=each($check_stock))
|
||||
// reset($check_stock);
|
||||
// while (list($fname,$fvalue)=each($check_stock))
|
||||
foreach($check_stock as $fname => $fvalue)
|
||||
{
|
||||
if ($fvalue==$name)
|
||||
if($fvalue == $name)
|
||||
{
|
||||
if ($name == 'cat_id')
|
||||
if($name == 'cat_id')
|
||||
{
|
||||
$filterlist .= "(" . $name . " LIKE '%," . $value . ",%' OR " . $name."='".$value."');";
|
||||
}
|
||||
elseif(@is_int($value))
|
||||
{
|
||||
$filterlist .= $name."=".$value.";";
|
||||
$filterlist .= $name . '=' . $value . ';';
|
||||
}
|
||||
elseif ($value == "!''") // check for not empty
|
||||
{
|
||||
$filterlist .= $name."!='';";
|
||||
$filterlist .= $name . "!='';";
|
||||
}
|
||||
else
|
||||
{
|
||||
$filterlist .= $name."='".$value."';";
|
||||
$filterlist .= $name . "='" . $value . "';";
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -439,7 +448,8 @@
|
||||
if(@is_array($this->grants))
|
||||
{
|
||||
$grants = $this->grants;
|
||||
while (list($user) = each($grants))
|
||||
// while (list($user) = each($grants))
|
||||
foreach($grants as $user)
|
||||
{
|
||||
$public_user_list[] = $user;
|
||||
}
|
||||
@ -477,7 +487,7 @@
|
||||
{
|
||||
$fwhere .= " AND last_mod > $lastmod ";
|
||||
}
|
||||
else if($lastmod >= 0)
|
||||
elseif($lastmod >= 0)
|
||||
{
|
||||
$fwhere = " WHERE last_mod > $lastmod ";
|
||||
}
|
||||
@ -489,15 +499,32 @@
|
||||
|
||||
$filtermethod = '';
|
||||
|
||||
if($query)
|
||||
if($cquery)
|
||||
{
|
||||
$cfields = array(
|
||||
'fn' => 'cn',
|
||||
'n_family' => 'sn',
|
||||
'org_name' => 'o'
|
||||
);
|
||||
$sql = 'SELECT * FROM ' . $this->std_table . ' WHERE (';
|
||||
$sqlcount = 'SELECT COUNT(id) FROM ' . $this->std_table . ' WHERE (';
|
||||
while(list($f,$x) = each($cfields))
|
||||
{
|
||||
$sql .= " UPPER($f) LIKE UPPER('$cquery%') OR ";
|
||||
$sqlcount .= " UPPER($f) LIKE UPPER('$cquery%') OR ";
|
||||
}
|
||||
$sql = substr($sql,0,-3) . ') ' . $fand . $filtermethod . $ordermethod;
|
||||
$sqlcount = substr($sqlcount,0,-3) . ') ' . $fand . $filtermethod;
|
||||
unset($f); unset($x);
|
||||
}
|
||||
elseif($query)
|
||||
{
|
||||
$query = str_replace("'",'',$query);
|
||||
$query = str_replace('"','',$query);
|
||||
|
||||
$sql = "SELECT * FROM $this->std_table WHERE (";
|
||||
$sqlcount = "SELECT COUNT(id) FROM $this->std_table WHERE (";
|
||||
reset($this->stock_contact_fields);
|
||||
while(list($f,$x) = each($this->stock_contact_fields))
|
||||
foreach($this->stock_contact_fields as $f => $x)
|
||||
{
|
||||
$sql .= " UPPER($f) LIKE UPPER('%$query%') OR ";
|
||||
$sqlcount .= " UPPER($f) LIKE UPPER('%$query%') OR ";
|
||||
@ -561,7 +588,8 @@
|
||||
|
||||
if(@is_array($stock_fieldnames))
|
||||
{
|
||||
while(list($f_name) = each($stock_fieldnames))
|
||||
// while(list($f_name) = each($stock_fieldnames))
|
||||
foreach($stock_fieldnames as $f_name)
|
||||
{
|
||||
$return_fields[$i][$f_name] = $this->db->f($f_name);
|
||||
}
|
||||
@ -618,15 +646,16 @@
|
||||
|
||||
$id = $this->db->get_last_insert_id($this->std_table, 'id');
|
||||
|
||||
if (count($extra_fields))
|
||||
if(count($extra_fields))
|
||||
{
|
||||
while (list($name,$value) = each($extra_fields))
|
||||
// while (list($name,$value) = each($extra_fields))
|
||||
foreach($extra_fields as $name => $value)
|
||||
{
|
||||
$this->db->query("INSERT INTO $this->ext_table VALUES ('$id','" . $owner . "','"
|
||||
. $this->db->db_addslashes($name) . "','" . $this->db->db_addslashes($value) . "')",__LINE__,__FILE__);
|
||||
}
|
||||
}
|
||||
return $id;
|
||||
return ($id ? $id : False);
|
||||
}
|
||||
|
||||
function field_exists($id,$field_name)
|
||||
@ -690,7 +719,8 @@
|
||||
$this->db->query($sql="UPDATE $this->std_table SET $fields_s WHERE "
|
||||
. "id=$id",__LINE__,__FILE__);
|
||||
}
|
||||
while (list($x_name,$x_value) = @each($extra_fields))
|
||||
// while (list($x_name,$x_value) = @each($extra_fields))
|
||||
foreach($extra_fields as $x_name => $x_value)
|
||||
{
|
||||
if ($this->field_exists($id,$x_name))
|
||||
{
|
||||
|
@ -34,6 +34,7 @@ afghanistan common en AFGHANISTAN
|
||||
albania common en ALBANIA
|
||||
algeria common en ALGERIA
|
||||
all common en All
|
||||
alphabet common en a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
|
||||
american samoa common en AMERICAN SAMOA
|
||||
andorra common en ANDORRA
|
||||
angola common en ANGOLA
|
||||
|
Loading…
Reference in New Issue
Block a user