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

/php/lib/share_manager/component/content_object_user_share_rights_browser/content_object_user_share_rights_browser_table_cell_renderer.class.php

https://bitbucket.org/chamilo/chamilo-repository-dev/
PHP | 91 lines | 69 code | 12 blank | 10 comment | 8 complexity | ea7e6505c24d304091de4159585320e3 MD5 | raw file
  1. <?php
  2. namespace repository;
  3. use user\UserDataManager;
  4. use common\libraries\Translation;
  5. use common\libraries\ToolbarItem;
  6. use common\libraries\Toolbar;
  7. use common\libraries\Theme;
  8. use common\libraries\Path;
  9. use common\libraries\ObjectTableCellRenderer;
  10. use common\libraries\Request;
  11. use rights\UserEntity;
  12. require_once dirname(__FILE__) . '/share_right_column.class.php';
  13. require_once dirname(__FILE__) . '/action_column.php';
  14. require_once dirname(__FILE__) . '/content_object_user_share_rights_browser_table_column_model.class.php';
  15. require_once Path :: get_user_path() . 'lib/user_table/default_user_table_cell_renderer.class.php';
  16. /**
  17. * Cell renderer for the content object user share rights browser
  18. * @author Pieterjan Broekaert
  19. */
  20. class ContentObjectUserShareRightsBrowserTableCellRenderer extends ObjectTableCellRenderer
  21. {
  22. private $browser;
  23. function __construct($browser)
  24. {
  25. $this->browser = $browser;
  26. }
  27. /**
  28. *
  29. * @param StaticTableColumn $column
  30. * @param <type> $registration
  31. * @return cell content
  32. */
  33. function render_cell($column, $user)
  34. {
  35. if ($column instanceof ShareRightColumn)
  36. {
  37. $location = RepositoryRights :: get_instance()->get_location_by_identifier_from_users_subtree(RepositoryRights :: TYPE_USER_CONTENT_OBJECT, array_pop($this->browser->get_content_objects())->get_id(), array_pop($this->browser->get_content_objects())->get_owner_id());
  38. $rights = RepositoryRights :: get_instance()->get_granted_rights_for_rights_entity_item(RepositoryManager :: APPLICATION_NAME, UserEntity :: ENTITY_TYPE, $user->get_id(), $location);
  39. $copy_right = array_search(RepositoryRights :: COPY_RIGHT, $rights);
  40. if ($copy_right)
  41. {
  42. array_splice($rights, $copy_right, 1);
  43. if ($column->get_right_id() == RepositoryRights :: COPY_RIGHT)
  44. {
  45. return Theme :: get_common_image('action_setting_true', 'png');
  46. }
  47. }
  48. if ($column->get_right_id() <= max($rights))
  49. {
  50. return Theme :: get_common_image('action_setting_true', 'png');
  51. }
  52. else
  53. {
  54. return Theme :: get_common_image('action_setting_false', 'png');
  55. }
  56. }
  57. else
  58. if ($column instanceof ActionColumn)
  59. {
  60. $toolbar = new Toolbar(Toolbar :: TYPE_HORIZONTAL);
  61. $toolbar->add_item(new ToolbarItem(Translation :: get('ContentObjectUserShareEditor'), Theme :: get_common_image_path() . 'action_edit.png', $this->browser->get_url(array(
  62. ShareManager :: PARAM_SHARE_ACTION => ShareManager :: ACTION_UPDATE_ENTITY,
  63. ShareManager :: PARAM_TARGET_USERS => $user->get_id()), $user->get_id(), null), ToolbarItem :: DISPLAY_ICON));
  64. $toolbar->add_item(new ToolbarItem(Translation :: get('ContentObjectUserShareDeleter'), Theme :: get_common_image_path() . 'action_delete.png', $this->browser->get_url(array(
  65. ShareManager :: PARAM_SHARE_ACTION => ShareManager :: ACTION_REMOVE_ENTITY,
  66. ShareManager :: PARAM_TARGET_USERS => $user->get_id()), $user->get_id(), null), ToolbarItem :: DISPLAY_ICON));
  67. return $toolbar->as_html();
  68. }
  69. else //display the username
  70. {
  71. return $user->get_fullname();
  72. }
  73. }
  74. function render_id_cell($user_share)
  75. {
  76. return $user_share->get_user_id();
  77. }
  78. }
  79. ?>