"MDL-14932, accessibility imporvement, see tracker"
[moodle-linuxchix.git] / search / documents / document.php
blob266dead49a9a94e4f8a6e95830efd467d3d175ea
1 <?php
2 /**
3 * Global Search Engine for Moodle
5 * @package search
6 * @category core
7 * @subpackage document_wrappers
8 * @author Michael Campanis (mchampan) [cynnical@gmail.com], Valery Fremaux [valery.fremaux@club-internet.fr] > 1.8
9 * @date 2008/03/31
10 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License
12 * Base search document from which other module/block types can
13 * extend.
16 /**
19 abstract class SearchDocument extends Zend_Search_Lucene_Document {
20 public function __construct(&$doc, &$data, $course_id, $group_id, $user_id, $path) {
21 //document identification and indexing
22 $this->addField(Zend_Search_Lucene_Field::Keyword('docid', $doc->docid));
23 //document type : the name of the Moodle element that manages it
24 $this->addField(Zend_Search_Lucene_Field::Keyword('doctype', $doc->documenttype));
25 //allows subclassing information from complex modules.
26 $this->addField(Zend_Search_Lucene_Field::Keyword('itemtype', $doc->itemtype));
27 //caches the course context.
28 $this->addField(Zend_Search_Lucene_Field::Keyword('course_id', $course_id));
29 //caches the originator's group.
30 $this->addField(Zend_Search_Lucene_Field::Keyword('group_id', $group_id));
31 //caches the originator if any
32 $this->addField(Zend_Search_Lucene_Field::Keyword('user_id', $user_id));
33 // caches the context of this information. i-e, the context in which this information
34 // is being produced/attached. Speeds up the "check for access" process as context in
35 // which the information resides (a course, a module, a block, the site) is stable.
36 $this->addField(Zend_Search_Lucene_Field::UnIndexed('context_id', $doc->contextid));
38 //data for document
39 $this->addField(Zend_Search_Lucene_Field::Text('title', $doc->title));
40 $this->addField(Zend_Search_Lucene_Field::Text('author', $doc->author));
41 $this->addField(Zend_Search_Lucene_Field::UnStored('contents', $doc->contents));
42 $this->addField(Zend_Search_Lucene_Field::UnIndexed('url', $doc->url));
43 $this->addField(Zend_Search_Lucene_Field::UnIndexed('date', $doc->date));
45 //additional data added on a per-module basis
46 $this->addField(Zend_Search_Lucene_Field::Binary('data', serialize($data)));
48 // adding a path allows the document to know where to find specific library calls
49 // for checking access to a module or block content. The Lucene records should only
50 // be responsible to bring back to that call sufficient and consistent information
51 // in order to perform the check.
52 $this->addField(Zend_Search_Lucene_Field::UnIndexed('path', $path));
54 // adding a capability set required for viewing. -1 if no capability required.
55 // the capability required for viewing is depending on the local situation
56 // of the document. each module should provide this information when pushing
57 // out search document structure. Although capability model should be kept flat
58 // there is no exclusion some module or block developpers use logical combinations
59 // of multiple capabilities in their code. This possibility should be left open here.
60 $this->addField(Zend_Search_Lucene_Field::UnIndexed('capabilities', $caps));