예제 #1
0
function editPicture($uid)
{
    $app = JFactory::getApplication('administrator');
    JToolBarHelper::title(JText::_('COM_DATSOGALLERY_EDIT_IMAGE'), 'tb-editimage');
    JToolBarHelper::custom('save', 'dg-save.png', 'dg-save.png', JText::_('COM_DATSOGALLERY_SAVE'), false);
    JToolBarHelper::spacer();
    JToolBarHelper::custom('cancel', 'dg-cancel.png', 'dg-cancel.png', JText::_('COM_DATSOGALLERY_CANCEL'), false);
    require JPATH_COMPONENT . DS . 'config.datsogallery.php';
    require_once JPATH_COMPONENT . DS . 'images.datsogallery.php';
    $db = JFactory::getDBO();
    $row = new DatsoImages($db);
    $row->load($uid);
    $clist = CategoryList($row->catid, "catid", ' size="1"');
    if (!$uid) {
        $row->published = 0;
    }
    datsogallery_html::editPicture($row, $clist, $ad_pathoriginals, $ad_thumbwidth, $ad_thumbheight, $ad_crop, $ad_cropratio);
}
예제 #2
0
function deletePic($uid)
{
    $app = JFactory::getApplication('site');
    $db = JFactory::getDBO();
    $user = JFactory::getUser();
    $uri = JFactory::getURI();
    $return = $uri->toString();
    $url = 'index.php?option=com_users&view=login';
    $url .= '&return=' . base64_encode($return);
    if (!$user->id) {
        $app->redirect($url, JText::_('You must login first'));
    }
    require JPATH_COMPONENT_ADMINISTRATOR . DS . 'config.datsogallery.php';
    jimport('joomla.filesystem.file');
    $menu = JSite::getMenu();
    $ids = $menu->getItems('link', 'index.php?option=com_datsogallery&view=datsogallery');
    $itemid = isset($ids[0]) ? '&Itemid=' . $ids[0]->id : '';
    $db->setQuery('SELECT owner_id FROM #__datsogallery WHERE id = ' . (int) $uid);
    $own = $db->loadResult();
    if ($own != $user->id) {
        $app->redirect(JRoute::_("index.php?option=com_datsogallery" . $itemid, false), JText::_('COM_DATSOGALLERY_NOT_ALOWED_DELETE_IMAGE'));
    }
    if ($uid) {
        $row = new DatsoImages($db);
        $row->load($uid);
        if (JFile::exists(JPath::clean(JPATH_ROOT . $ad_pathoriginals . DS . $row->imgoriginalname))) {
            JFile::delete(JPATH_ROOT . $ad_pathoriginals . DS . $row->imgoriginalname);
        }
        $db->setQuery('DELETE FROM #__datsogallery_comments WHERE cmtpic = ' . (int) $uid);
        if (!$db->query()) {
            echo "<script> alert('" . $db->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        }
        $db->setQuery('DELETE FROM #__datsogallery where id = ' . (int) $uid);
        if (!$db->query()) {
            echo "<script> alert('" . $db->getErrorMsg() . "'); window.history.go(-1); </script>\n";
        }
    }
    $app->redirect(JRoute::_("index.php?option=com_datsogallery&task=userpanel" . $itemid, false), JText::_('COM_DATSOGALLERY_IMAGE_DELETED'));
}