/php/lib/share_manager/component/content_object_user_share_rights_browser/content_object_user_share_rights_browser_table_cell_renderer.class.php
PHP | 91 lines | 69 code | 12 blank | 10 comment | 8 complexity | ea7e6505c24d304091de4159585320e3 MD5 | raw file
- <?php
- namespace repository;
-
- use user\UserDataManager;
- use common\libraries\Translation;
- use common\libraries\ToolbarItem;
- use common\libraries\Toolbar;
- use common\libraries\Theme;
- use common\libraries\Path;
- use common\libraries\ObjectTableCellRenderer;
- use common\libraries\Request;
- use rights\UserEntity;
-
- require_once dirname(__FILE__) . '/share_right_column.class.php';
- require_once dirname(__FILE__) . '/action_column.php';
- require_once dirname(__FILE__) . '/content_object_user_share_rights_browser_table_column_model.class.php';
- require_once Path :: get_user_path() . 'lib/user_table/default_user_table_cell_renderer.class.php';
-
- /**
- * Cell renderer for the content object user share rights browser
- * @author Pieterjan Broekaert
- */
- class ContentObjectUserShareRightsBrowserTableCellRenderer extends ObjectTableCellRenderer
- {
- private $browser;
-
- function __construct($browser)
- {
- $this->browser = $browser;
- }
-
- /**
- *
- * @param StaticTableColumn $column
- * @param <type> $registration
- * @return cell content
- */
- function render_cell($column, $user)
- {
- if ($column instanceof ShareRightColumn)
- {
- $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());
- $rights = RepositoryRights :: get_instance()->get_granted_rights_for_rights_entity_item(RepositoryManager :: APPLICATION_NAME, UserEntity :: ENTITY_TYPE, $user->get_id(), $location);
-
- $copy_right = array_search(RepositoryRights :: COPY_RIGHT, $rights);
-
- if ($copy_right)
- {
- array_splice($rights, $copy_right, 1);
- if ($column->get_right_id() == RepositoryRights :: COPY_RIGHT)
- {
- return Theme :: get_common_image('action_setting_true', 'png');
- }
- }
-
- if ($column->get_right_id() <= max($rights))
- {
- return Theme :: get_common_image('action_setting_true', 'png');
- }
- else
- {
- return Theme :: get_common_image('action_setting_false', 'png');
- }
- }
- else
- if ($column instanceof ActionColumn)
- {
- $toolbar = new Toolbar(Toolbar :: TYPE_HORIZONTAL);
- $toolbar->add_item(new ToolbarItem(Translation :: get('ContentObjectUserShareEditor'), Theme :: get_common_image_path() . 'action_edit.png', $this->browser->get_url(array(
- ShareManager :: PARAM_SHARE_ACTION => ShareManager :: ACTION_UPDATE_ENTITY,
- ShareManager :: PARAM_TARGET_USERS => $user->get_id()), $user->get_id(), null), ToolbarItem :: DISPLAY_ICON));
- $toolbar->add_item(new ToolbarItem(Translation :: get('ContentObjectUserShareDeleter'), Theme :: get_common_image_path() . 'action_delete.png', $this->browser->get_url(array(
- ShareManager :: PARAM_SHARE_ACTION => ShareManager :: ACTION_REMOVE_ENTITY,
- ShareManager :: PARAM_TARGET_USERS => $user->get_id()), $user->get_id(), null), ToolbarItem :: DISPLAY_ICON));
- return $toolbar->as_html();
- }
- else //display the username
- {
- return $user->get_fullname();
- }
-
- }
-
- function render_id_cell($user_share)
- {
- return $user_share->get_user_id();
- }
-
- }
-
- ?>