Hi,
i'm looking for a feature (or hack) for the upload of images in the adminarea:
I'd like to show the name of the user who uploaded pictures, in the description of the picture.
I need to add automaticaly after the upload, the username in the database from the logged in user $_zp_current_admin['user'] in the table zp_images in colum desc.
Is this possible or is there a feature?
Thx for helping and sorry for my bad english.
Comments
can you give me a hint how to customize the current implementation.
I Thought about to extend the insert query on clicking the upload submit button with the $_zp_current_admin['user'] variable.
Just the basics, in which file the insert query is and how to give the variable to it?
IMPORTANT it's an extrem experimental hack with no warranty.
First for single uploaded images put $image->setDesc($_zp_current_admin['name']); in admin-upload.php line 71 after $image->setTitle($name);
This causes an direct insert of the name from the logged in user.
For zip upload the desc field is only filled but no direct database insert. This hack only works if the user got permisson to edit.
After the upload redirect you have to push the save button to insert idatabase.
For uploaded .zip archives put the following lines in the admin.php in line 661 after the
<<$currentimage = 0;
<<foreach ($images as $filename) {
<<$image = newImage($album, $filename);
code:
//checking if description is already set for picture
$bildDesc = $image->getDesc();
//if description is empty set the logged in username
if($bildDesc == "")
$image->setDesc($_zp_current_admin['name']);
-- If you dont want to put in the username but the user: $_zp_current_admin['user'] or try any string.
-- You can replace setDesc against all the other setters, i guess, like setCredit, setCopyright, ... (It's not tested by me)
Note, for ZIP files this requires that PHP have ZZIPlib configured since I did not want to figure out how to modify the lib-pclzip.php to create the image objects as it created the image files.
You can, of course, make a modification of this plugin to change other fields as well.
The new nightly build fixed a problem in the admin/edit area for me, too.
The problem seemed to be throwed with a javascript file or the packer (disabling javascript and it works).
Firebug debugging reported "$(b) has no properties" by clicking on the edit tab.
Reference was to file zp-core/js/thickbox.js
It should be, instead, something like:
`$this->data = apply_filter('new_image', $this->data);`
Then, the plugin would be something along the lines of:
`
register_filter('new_image', 'add_admin_to_desc');
function add_admin_to_desc($obj) {
global $_zp_current_admin;
$obj['desc'] .= ' (uploaded by ' . $_zp_current_admin['name'] . ')';
return $obj;
}
`