コード例 #1
0
 /**
  * Store the form's values to this set of permissions.
  * @param PERMISSIONS $obj
  * @access private
  */
 public function commit($obj)
 {
     $obj->user_id = $this->_group->id;
     $obj->kind = Privilege_kind_group;
     parent::commit($obj);
 }
 /**
  * @param FORM_RENDERER $renderer
  * @param PERMISSIONS_FORMATTER $formatter
  * @access private
  * @abstract
  */
 protected function _draw_permission_controls($renderer, $formatter)
 {
     $user_query = $this->app->user_query();
     /* get the list of user ids that are already mapped in this folder. */
     $folder_query = $this->app->login->folder_query();
     /** @var FOLDER $folder */
     $folder = $folder_query->object_at_id($this->value_for('id'));
     $security = $folder->security_definition();
     $permissions = $security->user_permissions();
     $ids = array();
     foreach ($permissions as $permission) {
         $ids[] = $permission->ref_id;
     }
     if (sizeof($ids)) {
         $user_query->restrict_by_op('usr.id', $ids, Operator_not_in);
     }
     if (read_var('show_anon')) {
         $user_query->set_kind(Privilege_kind_anonymous);
     } else {
         $user_query->set_kind(Privilege_kind_registered);
     }
     /** @var USER[] $users */
     $users = $user_query->objects();
     $renderer->draw_text_line_with_named_object_chooser_row('title', $users);
     parent::_draw_permission_controls($renderer, $formatter);
 }
 /**
  * @param FORM_RENDERER $renderer
  * @param PERMISSIONS_FORMATTER $formatter
  * @access private
  * @abstract
  */
 protected function _draw_permission_controls($renderer, $formatter)
 {
     $group_query = $this->app->group_query();
     /* Show only groups that do not have permission in this folder. */
     $folder_query = $this->app->login->folder_query();
     /** @var FOLDER $folder */
     $folder = $folder_query->object_at_id(read_var('id'));
     $security = $folder->security_definition();
     $permissions = $security->group_permissions();
     $ids = array();
     foreach ($permissions as $permission) {
         $ids[] = $permission->ref_id;
     }
     if (sizeof($ids)) {
         $group_query->restrict_by_op('grp.id', $ids, Operator_not_in);
     }
     /** @var GROUP[] $groups */
     $groups = $group_query->objects();
     $renderer->draw_text_line_with_named_object_chooser_row('group_name', $groups);
     parent::_draw_permission_controls($renderer, $formatter);
 }