/**
  * Load initial properties from this object.
  * @param OBJECT_IN_FOLDER $obj
  */
 public function load_from_object($obj)
 {
     $folder = $obj->parent_folder();
     $this->set_value('id', $obj->id);
     $this->set_value('subject', "{$folder->title}: {$obj->title}");
     $this->load_with_defaults();
 }
Exemplo n.º 2
0
 /**
  * Return default handler objects for supported tasks.
  * @param string $handler_type Specific functionality required.
  * @param OBJECT_RENDERER_OPTIONS $options
  * @return object
  * @access private
  */
 protected function _default_handler_for($handler_type, $options = null)
 {
     switch ($handler_type) {
         case Handler_print_renderer:
         case Handler_html_renderer:
         case Handler_text_renderer:
             include_once 'projects/gui/release_renderer.php';
             return new RELEASE_RENDERER($this->app, $options);
         case Handler_commands:
             include_once 'projects/cmd/release_commands.php';
             return new RELEASE_COMMANDS($this);
         case Handler_history_item:
             include_once 'projects/obj/project_history_items.php';
             return new RELEASE_HISTORY_ITEM($this->app);
         default:
             return parent::_default_handler_for($handler_type, $options);
     }
 }
Exemplo n.º 3
0
 /**
  * Is the requested action allowed for this user?
  * If the permission applies to content, the "obj" cannot be empty. Owner-
  * dependent permissions use the {@link OBJECT_IN_FOLDER::owner()} to
  * determine the full permission. {@link APPLICATION_USER_OPTIONS} defines a
  * few settings that control which permissions are owner-dependent. If the
  * permission set is {@link Privilege_set_user}, the "obj" must be a {@link
  * USER} instead.
  * @param string $set_name Check this set of permissions.
  * @param integer $type Check this permission (or permissions).
  * @param OBJECT_IN_FOLDER|USER $obj
  * @see OBJECT_IN_FOLDER
  * @return boolean
  */
 public function is_allowed($set_name, $type, $obj = null)
 {
     $this->assert(!$this->ad_hoc_login, 'Cannot use an ad-hoc login.', 'is_allowed', 'USER');
     $user_options = $this->app->user_options;
     $user_permissions = $this->permissions();
     if ($user_permissions->global_privileges->supports($set_name)) {
         $Result = $user_permissions->global_privileges->enabled($set_name, $type);
         if ($set_name == Privilege_set_user) {
             switch ($type) {
                 case Privilege_view:
                     if ($obj) {
                         $Result = $Result || $obj->equals($this);
                     }
                     break;
                 case Privilege_modify:
                     $Result = $Result || $user_options->users_can_edit_self && $obj->equals($this);
                     break;
             }
         }
         if ($set_name == Privilege_set_global) {
             switch ($type) {
                 case Privilege_subscribe:
                 case Privilege_password:
                     if ($obj) {
                         $Result = $Result || $obj->equals($this);
                     }
                     break;
             }
         }
     } else {
         if ($user_permissions->allow_privileges->enabled($set_name, $type)) {
             $Result = true;
         } else {
             if ($user_permissions->deny_privileges->enabled($set_name, $type)) {
                 $Result = false;
             } else {
                 /** @var FOLDER $folder */
                 $folder = $obj->security_context();
                 $folder_permissions = $folder->permissions();
                 $Result = $folder_permissions->enabled($set_name, $type);
                 if (!$Result) {
                     /** @var USER $owner */
                     $owner = $obj->owner();
                     switch ($type) {
                         case Privilege_view:
                         case Privilege_view_history:
                             $Result |= $owner->equals($this);
                             break;
                         case Privilege_modify:
                             $Result |= $user_options->users_can_modify_own_content && $owner->equals($this);
                             break;
                         case Privilege_delete:
                             $Result |= $user_options->users_can_delete_own_content && $owner->equals($this);
                             break;
                         case Privilege_purge:
                             $Result |= $user_options->users_can_purge_own_content && $owner->equals($this);
                             break;
                     }
                 }
             }
         }
     }
     return $Result;
 }
 /**
  * Show parent folders in outline form. 
  * @param OBJECT_IN_FOLDER $obj
  * @access private
  */
 protected function _echo_folders($obj)
 {
     $folder = $obj->parent_folder();
     $depth = 0;
     while ($folder->id && !$folder->is_root()) {
         if ($depth) {
             echo str_repeat(' ', ($depth - 1) * 2);
             echo $this->app->display_options->object_separator;
         }
         echo $this->app->get_icon_with_text($folder->icon_url, Sixteen_px, $folder->title_as_link());
         echo '<br>';
         $folder = $folder->parent_folder();
         $depth += 1;
     }
 }
Exemplo n.º 5
0
 /**
  * Return default handler objects for supported tasks.
  * @param string $handler_type Specific functionality required.
  * @param OBJECT_RENDERER_OPTIONS $options
  * @return object
  * @access private
  */
 protected function _default_handler_for($handler_type, $options = null)
 {
     switch ($handler_type) {
         case Handler_print_renderer:
         case Handler_html_renderer:
         case Handler_text_renderer:
             include_once 'webcore/gui/attachment_renderer.php';
             return new ATTACHMENT_RENDERER($this->app, $options);
         case Handler_commands:
             include_once 'webcore/cmd/attachment_commands.php';
             return new ATTACHMENT_COMMANDS($this);
         case Handler_history_item:
             include_once 'webcore/obj/webcore_history_items.php';
             return new ATTACHMENT_HISTORY_ITEM($this->app);
         default:
             return parent::_default_handler_for($handler_type, $options);
     }
 }
 /**
  * Options for purging an object.
  * @param OBJECT_IN_FOLDER $obj
  * @return PURGE_OPTIONS
  * @access private
  */
 protected function _purge_options_for($obj)
 {
     $Result = $obj->make_purge_options();
     $Result->remove_resources = $this->value_for('remove_resources');
     return $Result;
 }
 /**
  * Options for moving an object to the target folder.
  * @param OBJECT_IN_FOLDER $obj
  * @return FOLDER_OPERATION_OPTIONS
  * @access private
  */
 protected function _move_options_for($obj)
 {
     $Result = $obj->make_move_options();
     $Result->maintain_permissions = $this->value_for('maintain_permissions');
     $Result->copy_as_draft = $this->value_for('copy_as_draft');
     return $Result;
 }
 /**
  * @param PURGE_OPTIONS $options
  * @access private
  */
 protected function _purge($options)
 {
     $attachment_query = $this->attachment_query();
     $attachments = $attachment_query->objects();
     foreach ($attachments as &$attachment) {
         $attachment->purge($options);
     }
     parent::_purge($options);
 }
Exemplo n.º 9
0
 /**
  * Delete the given object.
  * @param OBJECT_IN_FOLDER $obj
  * @access private
  */
 public function commit($obj)
 {
     $options = $obj->make_purge_options();
     $this->_configure_purge_options($options);
     $obj->purge($options);
 }