Gallery_utils::DeleteFiles(str_replace('/', DIRECTORY_SEPARATOR, '../' . DEFAULT_GALLERY_PATH . $filepath), IM_PREFIX . '*', false); } if ($result) { $params['module_message'] = $this->Lang('thumbsdeleted') . ' ' . $this->Lang('thumbsrecreated'); } } elseif (isset($params['directoryname'])) { // cleanup the directoryname, see reference-arrays in lib/replacement.php $params['directoryname'] = munge_string_to_url($params['directoryname']); // add subgallery if (empty($params['directoryname'])) { $params['module_error'] = $this->Lang('error_directorynameinvalid'); $this->Redirect($id, 'editgallery', '', $params); exit; } $params['gid'] = $params['moveto']; $galleryinfo = Gallery_utils::Getgalleryinfobyid($params['gid']); $gallerypath = $galleryinfo['filepath'] . $galleryinfo['filename']; if (is_dir($gallerypath . $params['directoryname'])) { $params['module_error'] = $this->Lang('error_directoryalreadyexists'); $this->Redirect($id, 'editgallery', '', $params); exit; } else { if (!mkdir('../' . DEFAULT_GALLERY_PATH . $gallerypath . $params['directoryname'])) { $params = array('gid' => $params['gid'], 'mode' => 'edit', 'module_error' => $this->Lang('error_cantcreatedir') . ' \'' . $gallerypath . $params['directoryname'] . '\''); $this->Redirect($id, 'editgallery', '', $params); exit; } $gallerytitle = isset($params['gallerytitle']) ? $params['gallerytitle'] : ''; $gallerycomment = isset($params['gallerycomment']) ? $params['gallerycomment'] : ''; $gallerydate = date('Y-m-d H:i:s'); if (isset($params['gallerydate'])) {
$query = "UPDATE " . cms_db_prefix() . "module_gallery SET active = 0 WHERE fileid IN (" . $fids . ")"; $db->Execute($query); break; case 'switchactive': $query = "UPDATE " . cms_db_prefix() . "module_gallery SET active = active^1 WHERE fileid IN (" . $fids . ")"; $db->Execute($query); break; case 'move': $galleryinfo = Gallery_utils::Getgalleryinfobyid($params['moveto']); $newdir = $galleryinfo['filepath'] . $galleryinfo['filename']; $editors = explode(';', $galleryinfo['editors']); if (Gallery_utils::CheckEditor($userid, $params['moveto'], $editors)) { // permission to edit destination dir foreach ($fid_array as $fid) { if ($fid != 1) { $fileinfo = Gallery_utils::Getgalleryinfobyid($fid); $newpath = '../' . DEFAULT_GALLERY_PATH . $newdir . $fileinfo['filename']; $oldpath = '../' . DEFAULT_GALLERY_PATH . $fileinfo['filepath'] . $fileinfo['filename']; if (strpos($fileinfo['filename'], "/") === FALSE) { // 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++; }
function SearchReindex(&$module) { $galleries = Gallery_utils::GetGalleries(); foreach ($galleries as $gid => $gallery) { $galleryinfo = Gallery_utils::Getgalleryinfobyid($gid); if ($galleryinfo['active']) { $searchwords = $gallery['title'] . ' ' . $gallery['comment']; $db = $this->GetDB(); $query = "SELECT title, comment \n\t\t\t\t\t\t\t\t\tFROM " . cms_db_prefix() . "module_gallery g1\n\t\t\t\t\t\t\t\t\tWHERE galleryid=?"; $result = $db->Execute($query, array($gid)); if ($result && $result->RecordCount() > 0) { while ($row = $result->FetchRow()) { $searchwords .= ' ' . $row['title'] . ' ' . $row['comment']; } } $module->AddWords($this->GetName(), $gid, 'gallery', $searchwords); } } }
<?php if (!isset($gCms)) { exit; } // Check permissions if (!$this->CheckPermission('Use Gallery')) { echo $this->ShowErrors(lang('needpermissionto', 'Use Gallery')); return; } $file_id = isset($params['fid']) ? $params['fid'] : ''; $gallery = isset($params['gid']) ? $params['gid'] : ''; $galleryinfo = Gallery_utils::Getgalleryinfobyid($gallery); $query = "UPDATE " . cms_db_prefix() . "module_gallery SET defaultfile = ? WHERE fileid = ?"; $db->Execute($query, array($file_id, $gallery)); // Also change albumcovers of parentgalleries if ($galleryinfo['defaultfile'] != 0) { $query = "UPDATE " . cms_db_prefix() . "module_gallery SET defaultfile = ? WHERE defaultfile = ? AND fileid < ?"; $db->Execute($query, array($file_id, $galleryinfo['defaultfile'], $gallery)); } $this->Redirect($id, 'editgallery', $returnid, $params);
switch ($show) { case 'active': $query .= " AND g.active IS TRUE"; break; case 'inactive': $query .= " AND g.active IS FALSE"; break; } $query .= "\n\t\t\t\t\t\tORDER BY\n\t\t\t\t\t\t\tg.filedate DESC\n\t\t\t\t\t\tLIMIT 0,1"; $result = $db->Execute($query, array(empty($params['dir']) ? '%' : $params['dir'] . "/%")); if ($result && $result->RecordCount() > 0) { $output = array(); $row = $result->FetchRow(); $latestgalleryid = $row['fileid']; // get gallery info $galleryinfo = Gallery_utils::Getgalleryinfobyid($latestgalleryid); if (isset($params['template'])) { // override template settings with param template $templateprops = Gallery_utils::GetTemplateprops($params['template']); $galleryinfo['templateid'] = $templateprops['templateid']; $galleryinfo['template'] = $templateprops['template']; $galleryinfo['thumbwidth'] = $templateprops['thumbwidth']; $galleryinfo['thumbheight'] = $templateprops['thumbheight']; $galleryinfo['resizemethod'] = $templateprops['resizemethod']; } if (empty($galleryinfo['templateid'])) { // override template settings with default template $templateprops = Gallery_utils::GetTemplateprops($template); $galleryinfo['templateid'] = $templateprops['templateid']; $galleryinfo['template'] = $templateprops['template']; $galleryinfo['thumbwidth'] = $templateprops['thumbwidth'];