PageRenderTime 104ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/Molinos/File/Handlers/Unlink.php

https://code.google.com/p/molinos-cms/
PHP | 37 lines | 19 code | 5 blank | 13 comment | 1 complexity | 8e88d38dbbb8658d28d9178ea2970930 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * ?????????? ???????? api/file/unlink.rpc
  4. *
  5. * @package Molinos_CMS
  6. * @subpackage File
  7. * @author Justin Forest <justin.forest@gmail.com>
  8. * @copyright 2006-2011 molinos.ru
  9. * @license http://www.gnu.org/copyleft/gpl.html GPL
  10. */
  11. class Molinos_File_Handlers_Unlink extends Molinos_Core_RequestHandler
  12. {
  13. /**
  14. * ?????????? ???? ?? ?????????.
  15. */
  16. public function get()
  17. {
  18. $t = new Molinos_Database_Transaction();
  19. $fieldName = $this->rarg('field');
  20. $node = Molinos_Core_API::getInstance('node')->load(array(
  21. 'id' => $this->rarg('node'),
  22. ))->knock(Molinos_Auth_ACL::UPDATE);
  23. if (Molinos_I18n_Utils::isFieldTranslated($node->class, $fieldName))
  24. $node->onSave("DELETE FROM {node__rel} WHERE `tid` = ? AND `key` = ? AND `lang` = ?", array($node->id, $fieldName, $node->lang));
  25. else
  26. $node->onSave("DELETE FROM {node__rel} WHERE `tid` = ? AND `key` = ?", array($node->id, $fieldName));
  27. // ????????????? ????, ????? ????????? ??????????? ?????????, ????? ???????????.
  28. $node->touch()->save();
  29. $t->commit();
  30. return new Molinos_HTTP_Responses_Redirect($this->arg('destination'));
  31. }
  32. }