PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 1ms

/Controller/ConversionsController.php

https://github.com/Wargo/reddevil
PHP | 25 lines | 24 code | 1 blank | 0 comment | 7 complexity | 9e849424d0b51ddac2a9d8da8ae2f6ea MD5 | raw file
Possible License(s): GPL-2.0, AGPL-1.0, LGPL-2.1, GPL-3.0
  1. <?php
  2. class ConversionsController extends AppController {
  3. public function admin_add($mode = 'Trailer', $id = null) {
  4. $this->loadModel('Video');
  5. $flag = ($mode == 'Trailer')?'has_trailer':'has_video';
  6. $conditions = array('id' => $id, $flag => 1);
  7. if ($video = $this->Video->find('first', compact('conditions'))) {
  8. $conditions = array('model' => $mode, 'foreign_id' => $id);
  9. if (!$conversion = $this->Conversion->find('first', compact('conditions'))) {
  10. $this->Conversion->create();
  11. if ($this->Conversion->save($conditions)) {
  12. $this->Session->setFlash(__('Conversión del video programada'));
  13. } else {
  14. $this->Session->setFlash(__('Error al programar la conversión'));
  15. }
  16. } else {
  17. $this->Session->setFlash(__('Ya se programó la conversión de este vídeo'));
  18. }
  19. } else {
  20. $this->Session->setFlash(__('Vídeo incorrecto'));
  21. }
  22. $this->redirect($this->referer());
  23. }
  24. }