- Small refactoring: build words index in common kolab_format_xcal class
- Define tags to be cached with task objects - Allow to query cache with NOT LIKE (!~) queries
This commit is contained in:
parent
277edc7313
commit
2ad9e2e1ba
4 changed files with 53 additions and 32 deletions
|
@ -27,8 +27,6 @@ class kolab_format_event extends kolab_format_xcal
|
||||||
protected $read_func = 'kolabformat::readEvent';
|
protected $read_func = 'kolabformat::readEvent';
|
||||||
protected $write_func = 'kolabformat::writeEvent';
|
protected $write_func = 'kolabformat::writeEvent';
|
||||||
|
|
||||||
public static $fulltext_cols = array('title', 'description', 'location', 'attendees:name', 'attendees:email');
|
|
||||||
|
|
||||||
private $kolab2_rolemap = array(
|
private $kolab2_rolemap = array(
|
||||||
'required' => 'REQ-PARTICIPANT',
|
'required' => 'REQ-PARTICIPANT',
|
||||||
'optional' => 'OPT-PARTICIPANT',
|
'optional' => 'OPT-PARTICIPANT',
|
||||||
|
@ -181,34 +179,6 @@ class kolab_format_event extends kolab_format_xcal
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback for kolab_storage_cache to get words to index for fulltext search
|
|
||||||
*
|
|
||||||
* @return array List of words to save in cache
|
|
||||||
*/
|
|
||||||
public function get_words()
|
|
||||||
{
|
|
||||||
$data = '';
|
|
||||||
foreach (self::$fulltext_cols as $colname) {
|
|
||||||
list($col, $field) = explode(':', $colname);
|
|
||||||
|
|
||||||
if ($field) {
|
|
||||||
$a = array();
|
|
||||||
foreach ((array)$this->data[$col] as $attr)
|
|
||||||
$a[] = $attr[$field];
|
|
||||||
$val = join(' ', $a);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$val = is_array($this->data[$col]) ? join(' ', $this->data[$col]) : $this->data[$col];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strlen($val))
|
|
||||||
$data .= $val . ' ';
|
|
||||||
}
|
|
||||||
|
|
||||||
return array_unique(rcube_utils::normalize_string($data, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load data from old Kolab2 format
|
* Load data from old Kolab2 format
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -123,4 +123,24 @@ class kolab_format_task extends kolab_format_xcal
|
||||||
$this->data = $object;
|
$this->data = $object;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for kolab_storage_cache to get object specific tags to cache
|
||||||
|
*
|
||||||
|
* @return array List of tags to save in cache
|
||||||
|
*/
|
||||||
|
public function get_tags()
|
||||||
|
{
|
||||||
|
$tags = array();
|
||||||
|
|
||||||
|
if ($this->data['status'] == 'COMPLETED' || $this->data['complete'] == 100)
|
||||||
|
$tags[] = 'complete';
|
||||||
|
|
||||||
|
if ($this->data['priority'] == 1)
|
||||||
|
$tags[] = 'flagged';
|
||||||
|
|
||||||
|
if (!empty($this->data['alarms']))
|
||||||
|
$tags[] = 'x-has-alarms';
|
||||||
|
|
||||||
|
return $tags;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,8 @@ abstract class kolab_format_xcal extends kolab_format
|
||||||
{
|
{
|
||||||
public $CTYPE = 'application/calendar+xml';
|
public $CTYPE = 'application/calendar+xml';
|
||||||
|
|
||||||
|
public static $fulltext_cols = array('title', 'description', 'location', 'attendees:name', 'attendees:email');
|
||||||
|
|
||||||
protected $sensitivity_map = array(
|
protected $sensitivity_map = array(
|
||||||
'public' => kolabformat::ClassPublic,
|
'public' => kolabformat::ClassPublic,
|
||||||
'private' => kolabformat::ClassPrivate,
|
'private' => kolabformat::ClassPrivate,
|
||||||
|
@ -358,4 +360,32 @@ abstract class kolab_format_xcal extends kolab_format
|
||||||
$this->obj->setAlarms($valarms);
|
$this->obj->setAlarms($valarms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback for kolab_storage_cache to get words to index for fulltext search
|
||||||
|
*
|
||||||
|
* @return array List of words to save in cache
|
||||||
|
*/
|
||||||
|
public function get_words()
|
||||||
|
{
|
||||||
|
$data = '';
|
||||||
|
foreach (self::$fulltext_cols as $colname) {
|
||||||
|
list($col, $field) = explode(':', $colname);
|
||||||
|
|
||||||
|
if ($field) {
|
||||||
|
$a = array();
|
||||||
|
foreach ((array)$this->data[$col] as $attr)
|
||||||
|
$a[] = $attr[$field];
|
||||||
|
$val = join(' ', $a);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$val = is_array($this->data[$col]) ? join(' ', $this->data[$col]) : $this->data[$col];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($val))
|
||||||
|
$data .= $val . ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
return array_unique(rcube_utils::normalize_string($data, true));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -383,8 +383,9 @@ class kolab_storage_cache
|
||||||
$qvalue = '(' . join(',', array_map(array($this->db, 'quote'), $param[2])) . ')';
|
$qvalue = '(' . join(',', array_map(array($this->db, 'quote'), $param[2])) . ')';
|
||||||
$param[1] = 'IN';
|
$param[1] = 'IN';
|
||||||
}
|
}
|
||||||
else if ($param[1] == '~' || $param[1] == 'LIKE') {
|
else if ($param[1] == '~' || $param[1] == 'LIKE' || $param[1] == '!~' || $param[1] == '!LIKE') {
|
||||||
$param[1] = 'LIKE';
|
$not = ($param[1] == '!~' || $param[1] == '!LIKE') ? 'NOT ' : '';
|
||||||
|
$param[1] = $not . 'LIKE';
|
||||||
$qvalue = $this->db->quote('%'.preg_replace('/(^\^|\$$)/', ' ', $param[2]).'%');
|
$qvalue = $this->db->quote('%'.preg_replace('/(^\^|\$$)/', ' ', $param[2]).'%');
|
||||||
}
|
}
|
||||||
else if ($param[0] == 'tags') {
|
else if ($param[0] == 'tags') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue