CMS  Version 3.9
Document Class Reference

This class maps the publication table. More...

+ Inheritance diagram for Document:
+ Collaboration diagram for Document:

Public Member Functions

 Topics ($constraint="")
 
 Comments ($constraint="")
 
 Image ()
 
 Owner ()
 
 isOwner ()
 
 fileshareAllowEdit ()
 
 fileshareAllowDelete ()
 
 DocumentLibrary ()
 
 Document ()
 
 search ($params, $range=null)
 DataItems must implement this method to provide search functionality. More...
 

Public Attributes

 $fields
 
 $relations
 
 $fieldAliases
 

Detailed Description

This class maps the publication table.

Definition at line 42 of file document.inc.

Member Function Documentation

◆ Comments()

Document::Comments (   $constraint = "")

Definition at line 80 of file document.inc.

81  {
82  return $this->crossReference(Comment, DocumentCommentXref, $constraint);
83  }
$constraint

◆ Document()

Document::Document ( )

Definition at line 140 of file document.inc.

141  {
142  $this->primary_key = "document_id";
143  $this->table = "document";
144 
145  // Patch in the user class, since this can be overridden by the application
146  $mgr = new UserManager();
147  $this->relations["Owner"] = $mgr->getUserClass();
148 
149  $this->default_format = "{title}";
150 
151  $this->DataItem(func_get_args());
152  }
Provides the interface to the user model for the application.

◆ DocumentLibrary()

Document::DocumentLibrary ( )

Definition at line 135 of file document.inc.

136  {
137  return $this->getRelated(DocumentLibrary);
138  }

◆ fileshareAllowDelete()

Document::fileshareAllowDelete ( )

Definition at line 124 of file document.inc.

125  {
126  $library = $this->DocumentLibrary();
127 
128  if($this->isOwner() || $library->isOwner() ||
129  checkRole($library->delete_files))
130  return true;
131  else
132  return false;
133  }
if(! $document_library_id) $library
isOwner()
Definition: document.inc:96
DocumentLibrary()
Definition: document.inc:135

◆ fileshareAllowEdit()

Document::fileshareAllowEdit ( )

Definition at line 109 of file document.inc.

110  {
111  global $user;
112 
113  $library = $this->DocumentLibrary();
114 
115  $member = $library->getFileshareUser($user->user_id);
116 
117  if($this->isOwner() || checkRole($library->manage_folders) ||
118  checkRole($library->upload_files) || checkRole($library->delete_files) || $member)
119  return true;
120  else
121  return false;
122  }
global $user

◆ Image()

Document::Image ( )

Definition at line 85 of file document.inc.

86  {
87  return $this->getRelated(ImageRecord);
88  }

◆ isOwner()

Document::isOwner ( )

Definition at line 96 of file document.inc.

97  {
98  global $user;
99  $owner = $this->Owner();
100 
101  return ($owner->user_id == $user->user_id) ? true : false;
102  }
$table column("Redirect From", "<a href='redirect_form?redirect_id={redirect_id}'>{redirect_from}</a>", true, "width: 30%") -> column("Redirect To", "<a href='{redirect_to}' target='_blank'>{redirect_to}</a>", true, "width: 30%") ->column("Last Modified", "{last_modified}", true, "width: 20%; text-align: center") ->column("Override", "{ override true
Definition: redirects.inc:9

◆ Owner()

Document::Owner ( )

Definition at line 90 of file document.inc.

91  {
92  $mgr = new UserManager();
93  return $mgr->getUser($this->owner_id);
94  }
$calendar owner_id

◆ search()

Document::search (   $params,
  $range = null 
)

DataItems must implement this method to provide search functionality.

Parameters
mixed$paramseither search text or a SearchParameters object
array$rangean array of primary key IDs to which the search must be constrained

Implements Searchable.

Definition at line 154 of file document.inc.

155  {
156  trace("Searching Documents", 3);
157 
158 
159  if ($range)
160  {
161  $range = " AND {$this->primary_key} IN (".implode($range, ", ").")";
162  }
163 
164  if (is_object($params))
165  {
166  $search = clone $params;
167  $search->target = $this;
168 
169  if (!$range)
170  {
171  if (!$search->get("text", "like"))
172  {
173  $search->secondaryFields("author", "notes", "publication");
174  }
175  else
176  {
177  $search->remapField("text", "notes");
178  }
179  }
180 
181  $constraint = $search->generateConstraint();
182  $constraint .= $constraint ? " AND public=1" : " WHERE public=1";
183 
184  $constraint .= $range;
185 
186  $documents = Query::create(Document, $constraint)
187  ->execute();
188  }
189  else
190  {
191  $params = preg_replace('/[^\w]+/', ' ', $params);
192  $params = "%$params%";
193  $documents = Query::create(Document, "WHERE (title like :a OR keywords LIKE :b OR notes Like :c) and public=1 $range")
194  ->bind(":a", $params, ":b", $params, ":c", $params)
195  ->execute();
196  }
197 
199  }
$range
Definition: error_log.inc:13
This class maps the publication table.
Definition: document.inc:43
static wrap($items, $resultClass)
$documents

◆ Topics()

Document::Topics (   $constraint = "")

Definition at line 75 of file document.inc.

76  {
77  return $this->crossReference(Topic, DocumentTopicXref, $constraint);
78  }
This class maps the topic table.
Definition: topic.inc:38

Member Data Documentation

◆ $fieldAliases

Document::$fieldAliases
Initial value:
= array("image_id" => "Image",
"url" => "External URL")

Definition at line 72 of file document.inc.

◆ $fields

Document::$fields
Initial value:
= array("document_id" => Number,
"title" => String,
"file" => String,
"url" => String,
"publication_date" => Date,
"keywords" => String,
"author" => String,
"publication" => String,
"image_id" => Image,
"notes" => HTML,
"public" => Boolean,
"last_modified" => Timestamp,
"document_library_id" => Number,
"owner_id" => Number,
"allow_access" => String
)

Definition at line 46 of file document.inc.

◆ $relations

Document::$relations
Initial value:
= array( "Topics" => Topic,
"Owner" => "",
"DocumentLibrary" => DocumentLibrary,
"Comments" => Comment,
"Image" => ImageRecord
)

Definition at line 65 of file document.inc.


The documentation for this class was generated from the following file: