42 require_once realpath(dirname(__FILE__).
"/../document/document_manager.inc");
56 $constraint =
"WHERE LOWER(keywords) like '%$keyword%'";
58 if ($this->library->document_library_id)
60 $this->documents =
$library->Documents(
"$constraint ORDER BY title");
64 $this->documents = array();
67 if(!count($this->documents))
69 $this->
emptyMessage =
"There are no documents in {$this->library->name}";
72 $this->
emptyMessage .=
" that match the keyword search '{$keyword}'</i>";
81 "Details" =>
"fileshare_library_form",
82 "Add Members" =>
"fileshare_library_members",
83 "Files" =>
"fileshare_library_files"
86 $qs = ($key) ?
"document_library_id=$key" :
"";
88 $tabs->cssClass =
"fileshare";
101 <div
id=
"role" style=
"float: right; width: 30%; z-index: 2; padding: 2px 0">
102 <a
class=
"button" href=
"#" onclick=
"new LibraryManager().openPermissionsDialog(<?php echo $library->document_library_id ?>); return false;">Set Global Access</a>
104 <div
id=
"member_search_form">
105 <label
for=
'name'>Add Members</label>
106 <input
id=
'LibraryGroupMembers_form_name' type=
'text' name=
'name' autocomplete=
'off' value=
'' size=
'20'/>
108 <div
style=
"float: left; padding-top: 8px; padding-bottom: 5px; margin-bottom: 10px"><span
class=
"ann">Type a user
's name or email address to add it to the list.</span></div>
114 * @members - users with fileshare privileges
117 static function constructListMembers($members, $document_library_id)
119 if(count($members) > 0)
121 foreach($members as $member)
123 echo FileshareManager::constructListMember($member, $document_library_id);
128 function createUploadedByFacet()
130 $facet = new MultiSelectFacetFilter("owner_id", array(Document => "{Owner.first_name} {Owner.last_name}"));
132 $facet->dropdownMaxWidth = "160px";
133 $facet->width = "200px";
134 $facet->height = "240px";
140 static function constructListMember($member, $document_library_id)
142 $text = "<div id=\"user_id_{$member->user_id}\" class=\"list_member\"> {$member->getFullName()} ";
143 $text .= "<a href=\"#\" class=\"list_action\"";
144 $text .= "onclick=\"new LibraryManager().removeMember($document_library_id, {$member->user_id}); return false;\"> \n";
145 $text .= "<span class=\"list_action\">x</span></a>\n";
150 function formatDocumentTitle($document)
152 $file = $document->file;
154 $type = getDocType($file);
155 $icon = getDocIcon($file);
157 $library = $document->DocumentLibrary();
158 $size = $library->getFileSize($document);
160 // All users who can view and access the details dialog. Only users with edit access
161 // can edit it; otherwise read only.
162 $details_icon = ($document->fileshareAllowEdit()) ? "icon_edit.png" : "icon_view.png";
163 $details_link = "<a href=\"edit_document?document_id={document_id}\" onclick=\"new LibraryManager().editDocumentDetailsDialog({document_id}); return false;\"><img src=\"/fakoli/images/{$details_icon}\" style=\"border: none;display: inline-block;vertical-align: middle;padding-right: 4px\"></a>\n";
165 if($document->fileshareAllowDelete())
167 $delete_link .= "<a href=\"delete_document?document_id={document_id}\" onclick=\"new LibraryManager().deleteFile({document_id}); return false;\"><img alt=\"delete\" src=\"/fakoli/images/icon_delete_trash.png\"></a>\n";
170 return $document->format("<span class='document_title
'>{title}</span><br/><img style='display:
inline-block;vertical-
align: middle
' src='$icon' alt='$type'/> <a href='/
action/document/download?
document_id={
document_id}
'>Download</a> $size <span style='display:
inline-block
'> {$details_link} {$delete_link}</span>");
174 * Get the libraries the user is linked to either by
175 * fileshare_user_xref, by being the owner, or by
178 * If the library allows visitors read access then
181 static function getSharedLibraries()
185 $userXref = new FileshareUserXref();
189 $user = FileshareManager::setVisitor();
190 $roleLibraries = Query::create(DocumentLibrary, "ORDER BY name")->execute();
191 $roleLibraries = filterByRole($roleLibraries, "allow_access");
193 $constraint = "WHERE owner_id=:u or document_library_id in (select document_library_id from {$userXref->table} where user_id=:u)";
195 $libraries = Query::create(DocumentLibrary, "$constraint ORDER BY name")
196 ->bind(":u", $user->user_id)
199 if(count($libraries) == 0)
200 $libraries = array();
202 if(count($roleLibraries) > 0)
204 foreach($roleLibraries as $rLibrary)
205 $libraries[] = $rLibrary;
208 return removeDuplicates($libraries, "document_library_id");
211 static function getLibraryLastModified($library)
213 $documents = Query::create(Document, "WHERE document_library_id=:l ORDER BY last_modified DESC LIMIT 1")
214 ->bind(":l", $library->document_library_id)
217 return (count($documents) > 0) ? $documents[0]->format("{last_modified:short}") : null;
220 static function getLibraryLastModifiedBy($library)
222 $documents = Query::create(Document, "WHERE document_library_id=:l ORDER BY last_modified DESC LIMIT 1")
223 ->bind(":l", $library->document_library_id)
226 $owner = (count($documents) > 0) ? $documents[0]->Owner() : null;
228 return ($owner) ? $owner->getFullName() : null;
232 * Create the identifier by changing library name to
233 * all lower case, replacing blanks with "_" and any
234 * removing all other nonalphnumeric characters.
236 static function setLibraryIdentifier(&$form)
238 $library = $form->data;
240 $name = preg_replace("/ /", "_", strtolower($library->name));
241 $library->identifier = preg_replace("/[^A-Za-z0-9_]/", "", $name);
243 $library->filter = new InclusionFilter("identifier");
247 static function onDeleteFileshareLibary($library)
249 $mgr = new DocumentManager($library);
250 $mgr->deleteDocumentLibrary();
251 redirect("fileshare_libraries");
254 static function getDocumentAuthor($document)
256 $owner = $document->Owner();
257 return ($owner) ? $owner->getFullName() : "";
260 static function getGlobalPermissionOptions()
262 $options = array(fileshare_only_group_members_read => "Limit Access to Group Members",
263 fileshare_all_site_members_read => "Allow All Site Members to View",
264 fileshare_all_visitors_read => "Allow All Site Members and Site Visitors to View"
269 static function setVisitor()
271 $userClass = UserManager::getUserClass();
272 $user = new $userClass();
274 $user->role = "visitor";
286 static function deleteUser($user)
288 $pk = $user->getPrimaryKey();
289 $user_id = $user->$pk;
291 trace("Component fileshare is deleting objects dependent on user_id {$user_id}", 3);
293 $xref = new FileshareUserXref();
294 $xref->delete("WHERE user_id={$user_id}");
299 static function upgradeComponent($version)
301 $mgr = new FileshareUpgradeManager();
302 $mgr->upgrade($version);
The DocumentManager class provides the core API and management functions for uploading documents and ...
static using()
Import the datamodels, views and manifest for the specified component(s).
static usingFile()
Uses the specified framework file(s) from the framework directory.
static drawMemberSearchForm($library)
For Members tab.
FileshareManager($library, $keyword="")
static libraryTabs($key="")