XoopsModules25x /
suico
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | /* |
||
| 5 | You may not change or alter any portion of this comment or credits |
||
| 6 | of supporting developers from this source code or any supporting source code |
||
| 7 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, |
||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 12 | */ |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @category Module |
||
| 16 | * @package suico |
||
| 17 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 18 | * @license GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 19 | * @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
||
| 20 | */ |
||
| 21 | |||
| 22 | use Xmf\Request; |
||
| 23 | use XoopsModules\Suico; |
||
| 24 | |||
| 25 | require __DIR__ . '/header.php'; |
||
| 26 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 27 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 3, _MD_SUICO_TOKENEXPIRED); |
||
| 28 | } |
||
| 29 | $video_id = Request::getInt('video_id', 0, 'POST'); |
||
| 30 | $marker = Request::getInt('marker', 0, 'POST'); |
||
| 31 | $uid = (int)$xoopsUser->getVar('uid'); |
||
| 32 | if (1 === $marker) { |
||
| 33 | /** |
||
| 34 | * Creating the factory loading the video changing its caption |
||
| 35 | */ |
||
| 36 | $videoFactory = new Suico\VideoHandler( |
||
| 37 | $xoopsDB |
||
| 38 | ); |
||
| 39 | $video = $videoFactory->create(false); |
||
| 40 | $video->load($video_id); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 41 | $video->setVar('video_title', trim(htmlspecialchars($_POST['title'], ENT_QUOTES | ENT_HTML5))); |
||
| 42 | $video->setVar('video_desc', trim(htmlspecialchars($_POST['caption'], ENT_QUOTES | ENT_HTML5))); |
||
| 43 | /** |
||
| 44 | * Verifying who's the owner to allow changes |
||
| 45 | */ |
||
| 46 | if ($uid === $video->getVar('uid_owner')) { |
||
| 47 | if ($videoFactory->insert2($video)) { |
||
| 48 | redirect_header('videos.php?uid=' . $uid . '#' . $video_id, 2, _MD_SUICO_DESC_EDITED); |
||
| 49 | } else { |
||
| 50 | redirect_header('index.php?uid=' . $uid, 2, _MD_SUICO_ERROR); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 | /** |
||
| 55 | * Creating the factory and the criteria to edit the video |
||
| 56 | * The user must be the owner |
||
| 57 | */ |
||
| 58 | $videoFactory = new Suico\VideoHandler( |
||
| 59 | $xoopsDB |
||
| 60 | ); |
||
| 61 | $criteria_video = new Criteria('video_id', $video_id); |
||
| 62 | $criteriaUid = new Criteria('uid_owner', $uid); |
||
| 63 | $criteria = new CriteriaCompo($criteria_video); |
||
| 64 | $criteria->add($criteriaUid); |
||
| 65 | /** |
||
| 66 | * Lets fetch the info of the video to be able to render the form |
||
| 67 | * The user must be the owner |
||
| 68 | */ |
||
| 69 | $array_vid = $videoFactory->getObjects( |
||
| 70 | $criteria |
||
| 71 | ); |
||
| 72 | if ($array_vid) { |
||
| 73 | $title = $array_vid[0]->getVar('video_title'); |
||
| 74 | $caption = $array_vid[0]->getVar('video_desc'); |
||
| 75 | $url = $array_vid[0]->getVar('youtube_code'); |
||
| 76 | } |
||
| 77 | $videoFactory->renderFormEdit($title, $caption, $video_id, $url); |
||
| 78 | require dirname(__DIR__, 2) . '/footer.php'; |
||
| 79 |