CMS  Version 3.9
DocumentLibrary Class Reference

Inherits DataItem.

Public Member Functions

 Owner ()
 
 isOwner ()
 
 Documents ($constraint="")
 
 Folders ($constraint="")
 
 getOwnerName ()
 
 getLibraryDirectory ()
 
 getFolders ($constraint="")
 
 countDocuments ()
 
 FileshareUsers ($constraint="")
 
 getFileshareUser ($user_id)
 
 allowAccess ()
 
 allowDelete ()
 Can only delete an empty library. More...
 
 allowManageFiles ()
 
 fileshareAllowUpload ()
 
 isFileshareMember ()
 
 getFileSize ($document)
 
 DocumentLibrary ()
 

Static Public Member Functions

static findByIdentifier ($identifier)
 
static getDefaultRole ($fileshare=false)
 

Public Attributes

 $fields
 
 $relations
 

Detailed Description

Definition at line 41 of file document_library.inc.

Member Function Documentation

◆ allowAccess()

DocumentLibrary::allowAccess ( )

Definition at line 156 of file document_library.inc.

157  {
158  global $user;
159 
160  if(!$user)
161  $user = FileshareManager::setVisitor();
162 
163  if($this->isOwner() || checkRole($this->allow_access) || $this->isFileshareMember($user->user_id))
164  {
165  return true;
166  }
167  return false;
168  }
global $user

◆ allowDelete()

DocumentLibrary::allowDelete ( )

Can only delete an empty library.

Returns
boolean

Definition at line 175 of file document_library.inc.

176  {
177  if(!$this->document_library_id) return false;
178 
179  return (!count($this->Documents()) && checkRole($this->delete_files)) ? true : false;
180  }
Documents($constraint="")
$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

◆ allowManageFiles()

DocumentLibrary::allowManageFiles ( )

Definition at line 182 of file document_library.inc.

183  {
184  global $user;
185 
186  if(!$user)
187  return false;
188 
189  if($this->isOwner() || checkRole($this->manage_folders) || $this->isFileshareMember())
190  {
191  return true;
192  }
193  return false;
194 
195  }

◆ countDocuments()

DocumentLibrary::countDocuments ( )

Definition at line 128 of file document_library.inc.

129  {
130  return queryValue(Document, "COUNT(1)", "WHERE document_library_id={$this->document_library_id}");
131  }
This class maps the publication table.
Definition: document.inc:43

◆ DocumentLibrary()

DocumentLibrary::DocumentLibrary ( )

Definition at line 256 of file document_library.inc.

257  {
258  $this->primary_key = "document_library_id";
259  $this->table = "document_library";
260 
261  $this->default_format = "{name}";
262  $this->cacheLocal = true;
263 
264  // Patch in the user class, since this can be overridden by the application
265  $mgr = new UserManager();
266  $this->relations["Owner"] = $mgr->getUserClass();
267 
268  $this->DataItem(func_get_args());
269  }
Provides the interface to the user model for the application.

◆ Documents()

DocumentLibrary::Documents (   $constraint = "")

Definition at line 89 of file document_library.inc.

90  {
91  return $this->getRelatedList(Document, "", $constraint);
92  }
$constraint

◆ fileshareAllowUpload()

DocumentLibrary::fileshareAllowUpload ( )

Definition at line 197 of file document_library.inc.

198  {
199  global $user;
200 
201  if(!$user)
202  return false;
203 
204  if($this->isOwner() || checkRole($this->upload_files) || $this->isFileshareMember())
205  return true;
206  else
207  return false;
208  }

◆ FileshareUsers()

DocumentLibrary::FileshareUsers (   $constraint = "")

Definition at line 142 of file document_library.inc.

143  {
144  return $this->getRelatedList(FileshareUserXref, "document_library_id", $constraint);
145  }

◆ findByIdentifier()

static DocumentLibrary::findByIdentifier (   $identifier)
static

Definition at line 133 of file document_library.inc.

134  {
135  $match = Query::create(DocumentLibrary, "WHERE identifier=:id")
136  ->bind(":id", $identifier)
137  ->executeSingle();
138 
139  return $match;
140  }
$identifier

◆ Folders()

DocumentLibrary::Folders (   $constraint = "")

Definition at line 94 of file document_library.inc.

95  {
96  return $this->getRelatedList(DocumentFolder, "", $constraint);
97  }

◆ getDefaultRole()

static DocumentLibrary::getDefaultRole (   $fileshare = false)
static

Definition at line 227 of file document_library.inc.

228  {
229  $identifier = $_REQUEST["identifier"];
230 
231  if(preg_match("/fileshare/i", $identifier) || $fileshare)
232  $constraint = "WHERE role like 'admin%' or role like 'fileshare%'";
233  else
234  $constraint = "WHERE role like 'admin%'";
235 
236  $roles = Query::create(SiteRole, $constraint)->execute();
237 
238  if(count($roles) > 0)
239  $role = formatItems($roles, "{role}", ",");
240 
241  return $role;
242  }
$role
Definition: role_form.inc:41

◆ getFileshareUser()

DocumentLibrary::getFileshareUser (   $user_id)

Definition at line 147 of file document_library.inc.

148  {
149  $xrefs = $this->FileshareUsers("WHERE user_id = $user_id");
150  return (count($xrefs) > 0) ? $xrefs[0] : null;
151  }
FileshareUsers($constraint="")

◆ getFileSize()

DocumentLibrary::getFileSize (   $document)

Definition at line 244 of file document_library.inc.

245  {
246  $path = $this->getLibraryDirectory() . DIRECTORY_SEPARATOR . $document->file;
247 
248  if (file_exists($path))
249  {
250  return getScaledSize(filesize($path));
251  }
252 
253  return "";
254  }
if(! $page) $path
Definition: page.inc:57
if(! $document_id) $document
Definition: delete.inc:43

◆ getFolders()

DocumentLibrary::getFolders (   $constraint = "")

Definition at line 123 of file document_library.inc.

124  {
125  return reindexList($this->Folders($constraint), "path");
126  }
Folders($constraint="")

◆ getLibraryDirectory()

DocumentLibrary::getLibraryDirectory ( )

Definition at line 106 of file document_library.inc.

107  {
108  global $config;
109 
110  $d = $config['uploadbase'] . DIRECTORY_SEPARATOR . "library_{$this->document_library_id}";
111 
112  if (!is_dir($d) && !file_exists($d))
113  {
114  $docs = $d.DIRECTORY_SEPARATOR."documents";
115  mkdir($d);
116  mkdir($docs);
117  chmod($docs, 0777);
118  }
119 
120  return $d;
121  }
if(!checkRole($library->allow_access) &&! $library->allowAccess()) if(!checkRole($document->allow_access)) $d
Definition: download.inc:66
global $config
Definition: import.inc:4

◆ getOwnerName()

DocumentLibrary::getOwnerName ( )

Definition at line 99 of file document_library.inc.

100  {
101  $owner = $this->Owner();
102 
103  return ($owner) ? $owner->getFullName() : "";
104  }

◆ isFileshareMember()

DocumentLibrary::isFileshareMember ( )

Definition at line 211 of file document_library.inc.

212  {
213  global $user;
214 
215  $member = $this->getFileshareUser($user->user_id);
216 
217  return ($member) ? true : false;
218  }
getFileshareUser($user_id)

◆ isOwner()

DocumentLibrary::isOwner ( )

Definition at line 76 of file document_library.inc.

77  {
78  global $user;
79 
80  if(!$user)
81  return false;
82 
83  $owner = $this->Owner();
84 
85  return ($owner->user_id == $user->user_id) ? true : false;
86  }

◆ Owner()

DocumentLibrary::Owner ( )

Definition at line 67 of file document_library.inc.

68  {
69  if(!$this->owner_id)
70  return null;
71 
72  $mgr = new UserManager();
73  return $mgr->getUser($this->owner_id);
74  }
$calendar owner_id

Member Data Documentation

◆ $fields

DocumentLibrary::$fields
Initial value:
= array("document_library_id" => Number,
"name" => String,
"identifier" => String,
"description" => Text,
"hidden" => Boolean,
"allow_comments" => Boolean,
"owner_id" => Number,
"allow_access" => String,
"manage_folders" => String,
"upload_files" => String,
"delete_files" => String,
"create_date" => Timestamp,
"last_modified" => Timestamp)

Definition at line 45 of file document_library.inc.

◆ $relations

DocumentLibrary::$relations
Initial value:
= array( "Owner" => "",
"Documents" => Document,
"Folders" => DocumentFolder,
"FileshareUsers" => FileshareUserXref
)

Definition at line 59 of file document_library.inc.


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