/** * Loeschen eines Bildes */ function Joom_User_DeletePic() { $config = Joom_getConfig(); $mainframe =& JFactory::getApplication('site'); $database =& JFactory::getDBO(); $user =& JFactory::getUser(); jimport('joomla.filesystem.file'); if ($this->userid != $user->get('id') && !$this->adminlogged) { $mainframe->redirect(JRoute::_($this->userpanel_url . _JOOM_ITEMID, false), JText::_('JGS_ALERT_NOT_ALLOWED_DELETE_PICTURE')); } if ($this->picid) { $row = new mosjoomgallery($database); $row->load($this->picid); $catpath = Joom_GetCatPath($row->catid); //Detailbild loeschen if (JFile::delete(JPATH_ROOT . DS . $config->jg_pathimages . DS . $catpath . $row->imgfilename)) { //Thumb loeschen if (JFile::delete(JPATH_ROOT . DS . $config->jg_paththumbs . DS . $catpath . $row->imgthumbname)) { // ggf. Originalbild loeschen if (file_exists(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $row->imgfilename)) { JFile::delete(JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $row->imgfilename); } //Kommentare loeschen $database->setQuery(" DELETE \n FROM \n #__joomgallery_comments\n WHERE \n cmtpic={$this->picid}\n "); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } //Namensschilder loeschen $database->setQuery(" DELETE \n FROM \n #__joomgallery_nameshields\n WHERE \n nid = {$this->picid}\n "); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } //Bild loeschen $database->setQuery(" DELETE \n FROM \n #__joomgallery\n WHERE \n id = {$this->picid}\n "); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "'); window.history.go(-1); </script>\n"; } } else { die(JText::_('JGS_COULD_NOT_DELETE_THUMBNAIL_FILE')); } } else { die(JText::_('JGS_COULD_NOT_DELETE_PICTURE_FILE')); } $mainframe->redirect(JRoute::_($this->userpanel_url . _JOOM_ITEMID, false), JText::_('JGS_ALERT_PICTURE_AND_COMMENTS_DELETED')); } }
/** * Show the form to edit a picture * * @param int $uid id of picture */ function Joom_ShowEditPicture($uid) { $config = Joom_getConfig(); $database =& JFactory::getDBO(); $user =& JFactory::getUser(); $row = new mosjoomgallery($database); $row->load($uid); $database->setQuery("SELECT name\n FROM #__joomgallery_catg\n WHERE cid = {$row->catid}"); $catname = $database->loadResult(); // Build User select list $selname = $config->jg_realname ? "name" : "username"; $sql = "SELECT id as value, {$selname} as text" . "\n FROM #__users" . "\n ORDER BY {$selname}"; $database->setQuery($sql); if (!$database->query()) { echo $database->stderr(); return; } // set owner to current admin user, if none set: $owner = $row->owner ? $row->owner : $user->get('id'); $Lists['users'] = JHTML::_('select.genericlist', $database->loadObjectList(), 'owner', 'class="inputbox" size="1"', 'value', 'text', $owner); HTML_Joom_AdminPictures::Joom_ShowEditPicture_HTML($row, $catname, $Lists); }
/** * The following function was taken from admin.frontpage.php Joomla 1.0 * @copyright Copyright (C) 2005 Open Source Matters. All rights reserved. * modification aHa - additional saveorder for categories * @see admin.joomgallery.php // only backend * @param int $cid * @param unknown_type $catg */ function Joom_SaveOrder(&$cid, &$catg) { $mainframe =& JFactory::getApplication('administrator'); $database =& JFactory::getDBO(); $returntask = Joom_mosGetParam('returntask', null); if ($returntask == 'pictures') { $total = count($cid); $order = Joom_mosGetParam('order', array(0), 'post'); for ($i = 0; $i < $total; $i++) { //get catid $database->setQuery("SELECT catid\n FROM #__joomgallery\n WHERE id={$cid[$i]}"); $piccatid = $database->loadResult(); $query = "UPDATE #__joomgallery\n SET ordering = {$order[$i]}\n WHERE id = {$cid[$i]}"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "');\n window.history.go(-1); </script>\n"; exit; } // update ordering $row = new mosjoomgallery($database); $row->load($cid[$i]); $row->reorder('catid=' . $piccatid); } $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&act=pictures', JText::_('JG_NEW_ORDERING_SAVED')); } else { $total = count($catg); $order = Joom_mosGetParam('order', array(0), 'post'); for ($i = 0; $i < $total; $i++) { $query = "UPDATE #__joomgallery_catg\n SET ordering = {$order[$i]}\n WHERE cid = {$catg[$i]}"; $database->setQuery($query); if (!$database->query()) { echo "<script> alert('" . $database->getErrorMsg() . "');\n window.history.go(-1); </script>\n"; exit; } // update ordering $row = new mosjoomgallery($database); $row->load($catg[$i]); $row->reorder(''); } $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&act=categories', JText::_('JG_NEW_ORDERING_SAVED')); } }
/** * recreates thumbnails of the selected images * if original image is existent, detail image will be recreated, too. */ function Joom_Recreate() { jimport('joomla.filesystem.file'); $mainframe =& JFactory::getApplication('administrator'); $database =& JFactory::getDBO(); $config = Joom_GetConfig(); $cids = $mainframe->getUserStateFromRequest('joom.recreate.ids', 'id', array(), 'array'); $thumb_count = $mainframe->getUserState('joom.recreate.thumbcount'); $img_count = $mainframe->getUserState('joom.recreate.imgcount'); $row = new mosjoomgallery($database); // before first loop check for selected images if (is_null($thumb_count) and !count($cids)) { return array(false, JText::_('JGA_NO_IMAGES_SELECTED')); } //Check the maximum execution time of the script //set secure setting of the real execution time $max_execution_time = @ini_get('max_execution_time'); //try to set the max execution time to 60s if lower than //if not succesful the return value will be the old time, so use this if ($max_execution_time < 60) { #@ini_set('max_execution_time','60'); $max_execution_time = @ini_get('max_execution_time'); } $maxtime = (int) $max_execution_time * 0.8; $starttime = time(); $debugoutput = ''; //loop through selected images foreach ($cids as $key => $cid) { $row->load($cid); //catpath for category $catpath = Joom_GetCatPath($row->catid); $orig = JPATH_ROOT . DS . $config->jg_pathoriginalimages . $catpath . $row->imgfilename; $img = JPATH_ROOT . DS . $config->jg_pathimages . $catpath . $row->imgfilename; $thumb = JPATH_ROOT . DS . $config->jg_paththumbs . $catpath . $row->imgthumbname; //check if there is an original image if (JFile::exists($orig)) { $orig_existent = true; } else { //if not, use detail image to create thumbnail $orig_existent = false; if (JFile::exists($img)) { $orig = $img; } else { JError::raiseWarning(100, JText::sprintf('JGA_IMG_NOT_EXISTENT', $img)); $mainframe->setUserState('joom.recreate.cids', array()); $mainframe->setUserState('joom.recreate.count', null); return false; } } //TODO: move image into a trash instead of deleting immediately for possible rollback JFile::delete($thumb); $return = Joom_ResizeImage($debugoutput, $orig, $thumb, $config->jg_useforresizedirection, $config->jg_thumbwidth, $config->jg_thumbheight, $config->jg_thumbcreation, $config->jg_thumbquality); if (!$return) { JError::raiseWarning(100, JText::sprintf('JGA_COULD_NOT_CREATE_THUMB', $thumb)); $mainframe->setUserState('joom.recreate.cids', array()); $mainframe->setUserState('joom.recreate.thumbcount', null); $mainframe->setUserState('joom.recreate.imgcount', null); return false; } $mainframe->enqueueMessage(JText::sprintf('JGA_SUCCESSFULLY_CREATED_THUMB', $row->id, $row->imgtitle)); $thumb_count++; if ($orig_existent) { //TODO: move image into a trash instead of deleting immediately for possible rollback JFile::delete($img); $return = Joom_ResizeImage($debugoutput, $orig, $img, false, $config->jg_maxwidth, false, $config->jg_thumbcreation, $config->jg_picturequality, true); if (!$return) { JError::raiseWarning(100, JText::sprintf('JGA_COULD_NOT_CREATE_IMG', $img)); $this->_mainframe->setUserState('joom.recreate.cids', array()); $this->_mainframe->setUserState('joom.recreate.thumbcount', null); $this->_mainframe->setUserState('joom.recreate.imgcount', null); return false; } } $mainframe->enqueueMessage(JText::sprintf('JGA_SUCCESSFULLY_CREATED_IMG', $row->id, $row->imgtitle)); $img_count++; unset($cids[$key]); //check remaining time $timeleft = -(time() - $starttime - $maxtime); if ($timeleft <= 0 and count($cids)) { $mainframe->setUserState('joom.recreate.cids', $cids); $mainframe->setUserState('joom.recreate.thumbcount', $thumb_count); $mainframe->setUserState('joom.recreate.imgcount', $img_count); $mainframe->redirect('index.php?option=' . _JOOM_OPTION . '&task=recreate', JText::_('JGA_REDIRECT')); } } $mainframe->setUserState('joom.recreate.cids', array()); $mainframe->setUserState('joom.recreate.thumbcount', null); $mainframe->setUserState('joom.recreate.imgcount', null); return array($thumb_count, $img_count); }