// move only one file, let's don't forget the thumb if ($permission_to_edit == 'all' || $permission_to_edit == 'this') { if (@rename($oldpath, $newpath)) { $newpath = '../' . DEFAULT_GALLERY_PATH . $newdir . IM_PREFIX . $fileinfo['filename']; $oldpath = '../' . DEFAULT_GALLERY_PATH . $fileinfo['filepath'] . IM_PREFIX . $fileinfo['filename']; @rename($oldpath, $newpath); $query = "UPDATE " . cms_db_prefix() . "module_gallery SET filepath = ?, galleryid = ? WHERE fileid = ?"; $db->Execute($query, array($newdir, $params['moveto'], $fid)); } } else { $nopermission++; } } else { // move directory $editors = explode(';', $fileinfo['editors']); if (Gallery_utils::CheckEditor($userid, $fid, $editors)) { if (@rename($oldpath, $newpath)) { $query = "UPDATE " . cms_db_prefix() . "module_gallery SET filepath = ?, galleryid = ? WHERE fileid = ?"; $db->Execute($query, array($newdir, $params['moveto'], $fid)); //move content $oldpath = $fileinfo['filepath'] . $fileinfo['filename']; $newpath = $newdir . $fileinfo['filename']; $query = "UPDATE " . cms_db_prefix() . "module_gallery SET filepath = REPLACE(filepath,?,?) WHERE filepath = ? OR filepath LIKE ?"; $db->Execute($query, array($oldpath, $newpath, $oldpath, $oldpath . '%')); } } else { $nopermission++; } } } }
if (!empty($field) || $field == 0) { if (isset($nonpublicfields) && !in_array($key, $nonpublicfields)) { $searchwords .= ' ' . $field; } $query = "INSERT INTO " . cms_db_prefix() . "module_gallery_fieldvals (fieldid, fileid, value) VALUES (?,?,?)"; $result = $db->Execute($query, array($key, $params['gid'], $field)); } } } $params['hideparentlink'] = isset($params['hideparentlink']) ? $params['hideparentlink'] : false; $params['hideparentlink'] = $params['gid'] == 1 ? true : $params['hideparentlink']; $params['templateid'] = $params['templateid'] == '' ? 0 : $params['templateid']; $params['editors'] = is_array($params['editors']) ? $params['editors'] : explode(';', $params['editors']); // prevent an editor to lock himself out $userid = get_userid(); if (!Gallery_utils::CheckEditor($userid, $params['gid'], $params['editors'])) { array_push($params['editors'], $userid); } $editors = implode(';', $params['editors']); $query = "UPDATE " . cms_db_prefix() . "module_gallery_props SET templateid=?,hideparentlink=?,editors=? WHERE fileid=?"; $result = $db->Execute($query, array($params['templateid'], $params['hideparentlink'], $editors, $params['gid'])); // Save images and subgalleries if (!empty($params['sort'])) { $sort = explode(",", $params['sort']); } if (isset($params['filetitle'])) { foreach ($params['filetitle'] as $key => $filetitle) { $filedate = ''; if (!empty($params['filedate'][$key])) { $checkdate = explode('-', $params['filedate'][$key]); $filedate = count($checkdate) == 3 && checkdate($checkdate[1], $checkdate[2], $checkdate[0]) ? $params['filedate'][$key] : '';
echo $this->ShowErrors(lang('needpermissionto', 'Use Gallery')); return; } $themeObject =& $gCms->variables['admintheme']; // check parameters if (!isset($params['gid']) || !isset($params['mode'])) { $params['module_error'] = lang('missingparams'); $this->Redirect($id, 'defaultadmin', '', $params); return; } $params['origaction'] = $params['action']; $galleryinfo = Gallery_utils::Getgalleryinfobyid($params['gid']); // check permission to edit $userid = get_userid(); $editors = explode(';', $galleryinfo['editors']); if (Gallery_utils::CheckEditor($userid, $params['gid'], $editors)) { $permission_to_edit = TRUE; $disabled = ''; } else { $permission_to_edit = FALSE; $disabled = ' disabled="disabled"'; } $defaulttemplate = $this->GetPreference('current_template'); if ($galleryinfo['templateid'] == 0) { // override template settings with default template $templateprops = Gallery_utils::GetTemplateprops($defaulttemplate); $galleryinfo['thumbwidth'] = $templateprops['thumbwidth']; $galleryinfo['sortitems'] = $templateprops['sortitems']; } $totaloffileorder = 0; $numberofimages = 0;