I’ve got an emergent Document Mangement snippet/module up and more-or-less working; go to any of the links on the silly Mondrian home page and log in as filemanager, password filemanager. Actually being able to download files is the next step; I’m somewhat slowed by the need to have two different pages, one for the "manager" and one for regular users; they will only be able to see files assigned to them to check in (upload) or check out (download). A more normal system, similar to SourceSafe, would only have the one page with all filenames visible.
http://www.sottwell.com
Thanks to two really nice Javascript scripts that I found:
Tabtastic -
http://phrogz.net/JS/Tabtastic/index.html
MREDKJ -
http://www.mredkj.com/tutorials/tutorial_mixed2b.html
Ok, this puppy now uploads, allows the owner to modify file data, and downloads! Next up...checkout/checkin status. Suggestions and criticism would be greatly appreciated!
What a bitch!!!
What I’ve got is a live website with two "manager" users, and a whole bunch of local employees who assign work out to freelancers.
Now, I’ve already got a really cheap file upload/download system set up for them, but it takes "manager" users to upload the files for the freelancers.
So what I’m developing is a real document management system that will allow web user logins for handling the docman management, and all their freelance webusers can view/checkout/checkin the files assigned to them.
This means two two-layer sets of permissions; modx permissions to specify docman managers or users , then two different docman users, one for being able to view the files and one for checkout/checkin. The latter has its own table.
After many days of fighting with javascript and PHP integration, and stupid typos in the HTML, I’m almost done. It all works, except for one niggly little permissions issue. I’m trying to make this as easy on the database as possible; it already practically lives in the database!
I had to give up on the idea of tabs, unless I want to spend another week or two learning the guts of AJAX, since getting the read and write permission lists for each file would be horrendous for all of the files if the system is handling more than two or three files.
About half of the time has been devoted to error handling, and I’m sure there will be some dumb user stuff that I haven’t been able to imagine.
Once I get this last permissions issue settled, I’ll be testing it for the rest of the week, then will upload the whole mess to the client’s site. Once I do that, and see exactly how it has to be installed, I’ll package it up all nice and neat for anybody who wants it. It can be modified easily enough to be a simple file upload manager, without the checkin-checkout business. I added a counter field for keeping track of the number of downloads, so that’s already done.
Well, and I’ll have to set up some kind of method of "cleaning up" the docman permissions table in case web users have been deleted. And set up an "add category" form to enable the category feature. But my client doesn’t need that, and I really want it up this weekend.
I do have one question, if anybody has read past my "venting" to this point. On downloading the file, both for view and for checkout, I need to refresh the page, to show the incremented download count and the change in the checkin/checkout status. How can I use "header()" commands to initiate the download, then update the database (so far so good...) and THEN refresh the page?
-
- 1,732 Posts
Hi,
A very nice snippet that can be used as a download manager. Any plans to add versioning support?
There is a "logs" folder that keeps track of checkin/checkout activity; it would be easy enough to modify the system to create a random filename on initial upload, then create new random filenames on checkin, and just use the logging feature to keep track of the latest version (sort by date...). It would be even better to create a new folder on initial upload, and keep all the random-named version in that folder. I do need to add a ’view log’ page; forgot about that.
As far as making them publicly viewable (without requiring login), that would be easy enough to do...just add a third docman user permission (1 is for (loggedin) view, 2 is for checkout), so say 1 is for general view, 2 is for logged user view, 3 is for logged user checkout. And, of course, make the docman Modx document a publicly viewable page so it gets in your menu system. For my purpose, I don’t want it publicly viewable, but all I have to do is assign it to a docgroup and put it in an unpublished folder to really hide it.
I’m still trying to find out how to refresh the page to show the updated status and download count after downloading and checking out (which is just a download with logging). I suppose it could be done with javascript. Errors result in a return to the main page with an error message; I’m thinking about a way to pass the error and the action in the GET to return to the page where the error was generated. Right now the "switchboard" main script just uses POST, which is why it’s all with buttons, but I suppose I gould use GET, or even REQUEST, and have more flexibility and prettier links.
Finally, once I do learn how to play with Ajax, it can all be done on one page with tabs and HTTPRequest-whatever objects. At this point, I’m still hesitant to lean so heavily on Javascript. The selection mover script bothers me a little as it is. The nose of the camel...
Got a question for all you bright youngsters. I’ve got this query to detect if I have permissions still in the docman perms table for users that have been deleted from the ModX web user tables.
:
$query = "SELECT DISTINCT uid FROM $dbase.files_perms LEFT JOIN $dbase.".$table_prefix."web_groups ON $dbase.files_perms.uid=webuser WHERE webuser IS NULL";
$rs = $modx->dbQuery($query);
while($row = $modx->fetchRow($rs)) {
echo $row['uid'];
}
Works fine. Problem is, I want to DELETE FROM files_perms. Now I can easily run a delete query instead of an echo statement in the while clause. But I know there has to be a single query that will accomplish this.
Heh. I’m HOT today! Made chipati for the first time and they turned out great (flat Indian bread, my bf is from Calcutta...everything’s getting outsourced these days
and he got me a nice heavy griddle last time he was in England), I’ve lost five pounds and my gums stopped bleeding, and I found out how to do it all by myself (well, myself and Google, anyway)
$modx->dbQuery("DELETE FROM $dbase.files_perms USING $dbase.files_perms
LEFT JOIN $dbase.".$table_prefix."web_groups
ON $dbase.".$table_prefix."web_groups.webuser = $dbase.files_perms.uid
WHERE $dbase.".$table_prefix."web_groups.webuser is NULL");