/** * @desc Elimina de la base de datos las imagenes especificadas **/ function deleteImages() { global $xoopsSecurity, $xoopsModule; $ids = rmc_server_var($_REQUEST, 'ids', 0); $work = rmc_server_var($_REQUEST, 'work', 0); $page = rmc_server_var($_REQUEST, 'page', 0); $ruta = "&page={$page}"; //Verificamos que nos hayan proporcionado una imagen para eliminar if (!is_array($ids)) { redirectMsg('./images.php?work=' . $work . $ruta, __('You must select an image to delete!', 'works'), 1); die; } if (!$xoopsSecurity->check()) { redirectMsg('./images.php?work=' . $work . $ruta, __('Session token expired!', 'works'), 1); die; } $errors = ''; foreach ($ids as $k) { //Verificamos si la imagen es válida if ($k <= 0) { $errors .= sprintf(__('Image ID "%s" is not valid!', 'works'), $k); continue; } //Verificamos si la imagen existe $img = new PWImage($k); if ($img->isNew()) { $errors .= sprintf(__('Image with ID "%s" does not exists!', 'works'), $k); continue; } if (!$img->delete()) { $errors .= sprintf(__('Image "%s" could not be deleted!', 'works'), $img->title()); } } if ($errors != '') { redirectMsg('./images.php?work=' . $work . $ruta, __('Errors ocurred while trying to delete images', 'works') . '<br />' . $errors, 1); die; } else { redirectMsg('./images.php?work=' . $work . $ruta, __('Images deleted successfully!', 'works'), 0); die; } }
die; } if (!$work->isPublic()) { $xoopsTpl->assign('lang_preview', __('You are in preview mode! This work is hidden for all other users.', 'works')); } $cat = new PWCategory($work->category()); $client = new PWClient($work->client()); $work_data = array('id' => $work->id(), 'title' => $work->title(), 'desc' => $work->desc(), 'intro' => $work->descShort(), 'category' => array('name' => $cat->name(), 'description' => $cat->desc(), 'id' => $cat->id(), 'nameid' => $cat->nameId(), 'link' => $cat->link()), 'client' => $client->businessName(), 'site' => $work->nameSite(), 'url' => formatURL($work->url()), 'created' => formatTimeStamp($work->created(), 's'), 'start' => formatTimeStamp($work->start(), 's'), 'period' => $work->period(), 'cost' => $mc['cost'] ? sprintf($mc['format_currency'], number_format($work->cost(), 2)) : '', 'mark' => $work->mark(), 'image' => XOOPS_UPLOAD_URL . '/works/' . $work->image(), 'thumb' => XOOPS_UPLOAD_URL . '/works/ths/' . $work->image(), 'comment' => $work->comment(), 'rating' => PWFunctions::rating($work->rating()), 'views' => $work->views(), 'metas' => $work->get_metas(), 'public' => $work->isPublic(), 'link' => $work->link()); $work_data = RMEvents::get()->run_event('works.work.data<{$work.l}', $work_data, $work); $xoopsTpl->assign('work', $work_data); $work->addView(); //Obtenemos todas las imágenes del trabajo $sql = "SELECT * FROM " . $db->prefix('pw_images') . " WHERE work=" . $work->id(); $result = $db->query($sql); while ($row = $db->fetchArray($result)) { $img = new PWImage(); $img->assignVars($row); $tpl->append('images', array('id' => $img->id(), 'image' => XOOPS_UPLOAD_URL . '/works/ths/' . $img->image(), 'title' => $img->title(), 'desc' => $img->desc(), 'link_image' => XOOPS_UPLOAD_URL . '/works/' . $img->image())); } RMEvents::get()->run_event('works.load.work.images', $work); $tpl->assign('xoops_pagetitle', $work->title() . ' » ' . $mc['title']); /** * Otros trabajos **/ if ($mc['other_works'] > 0) { if ($mc['other_works'] == 2) { //Trabajos destacados $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public=1 AND mark=1 AND id_work<>'" . $work->id() . "' ORDER BY RAND() LIMIT 0," . $mc['num_otherworks']; } elseif ($mc['other_works'] == 1) { //Misma categoría $sql = "SELECT * FROM " . $db->prefix('pw_works') . " WHERE public=1 AND catego=" . $work->category() . " AND id_work<>'" . $work->id() . "' ORDER BY RAND() LIMIT 0," . $mc['num_otherworks'];