/**
  * @see ProjectPermissionOrganisationUnitInterface::delete()
  * @return bool
  * @throws ProjectPermissionOrganisationUnitDeleteException
  * @throws ProjectPermisisonOrganisationUnitDeleteVirtualFolderException
  */
 public function delete()
 {
     global $transaction;
     if ($this->permission_id and $this->project_permission) {
         $transaction_id = $transaction->begin();
         $project_id = $this->project_permission->get_project_id();
         $project_folder_id = ProjectFolder::get_folder_by_project_id($project_id);
         $permission_string = strrev(decbin($this->project_permission->get_permission()));
         if (ProjectPermission_Access::count_entries_with_project_id_and_organisation_unit_id($project_id, $this->project_permission->get_organisation_unit_id()) <= 1) {
             $folder_id = OrganisationUnitFolder::get_folder_by_organisation_unit_id($this->project_permission->get_organisation_unit_id());
             $virtual_folder = new VirtualFolder(null);
             $virtual_folder_array = $virtual_folder->list_entries_by_folder_id($folder_id);
             foreach ($virtual_folder_array as $key => $value) {
                 $virtual_folder = new ProjectVirtualFolder($value);
                 if ($virtual_folder->is_project_vfolder() == true) {
                     $virtual_folder_id = $value;
                 }
             }
             if ($virtual_folder_id) {
                 $virtual_folder = new VirtualFolder($virtual_folder_id);
                 if ($virtual_folder->unlink_folder($project_folder_id) == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectPermissionOrganisationUnitDeleteVirtualFolderException();
                 }
             }
         }
         if (parent::delete() == true) {
             if ($transaction_id != null) {
                 $transaction->commit($transaction_id);
             }
             return true;
         } else {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             throw new ProjectPermissionOrganisationUnitDeleteException();
         }
     } else {
         throw new ProjectPermissionOrganisationUnitDeleteException();
     }
 }
Ejemplo n.º 2
0
 /**
  * @see ProjectPermissionInterface::set_group_id()
  * @param integer $group_id
  * @return bool
  */
 public function set_group_id($group_id)
 {
     global $transaction;
     if (is_numeric($group_id) and $this->project_permission and $this->permission_id) {
         $transaction_id = $transaction->begin();
         $project_id = $this->project_permission->get_project_id();
         $project_folder_id = ProjectFolder::get_folder_by_project_id($project_id);
         $current_group_folder_id = GroupFolder::get_folder_by_group_id($this->project_permission->get_group_id());
         $new_group_folder_id = GroupFolder::get_folder_by_group_id($group_id);
         $current_virtual_folder_array = VirtualFolder::list_entries_by_folder_id($current_group_folder_id);
         foreach ($current_virtual_folder_array as $key => $value) {
             $virtual_folder = new ProjectVirtualFolder($value);
             if ($virtual_folder->is_project_vfolder() == true) {
                 $virtual_folder_id = $value;
             }
         }
         if ($virtual_folder_id) {
             $virtual_folder = new VirtualFolder($virtual_folder_id);
             if ($virtual_folder->unlink_folder($project_folder_id) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
         }
         $new_virtual_folder_array = $virtual_folder->list_entries_by_folder_id($new_group_folder_id);
         foreach ($new_virtual_folder_array as $key => $value) {
             $virtual_folder = new ProjectVirtualFolder($value);
             if ($virtual_folder->is_project_vfolder() == true) {
                 $virtual_folder_id = $value;
             }
         }
         if ($virtual_folder_id) {
             $virtual_folder = new VirtualFolder($virtual_folder_id);
             if ($virtual_folder->link_folder($project_folder_id) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 return false;
             }
         }
         if ($this->project_permission->set_group_id($group_id) == false) {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             return false;
         } else {
             if ($transaction_id != null) {
                 $transaction->commit($transaction_id);
             }
             return true;
         }
     } else {
         return false;
     }
 }
Ejemplo n.º 3
0
 /**
  * @see SampleSecurityInterface::delete_organisation_unit()
  * @param integer $entry_id
  * @return bool
  */
 public function delete_organisation_unit($entry_id)
 {
     global $transaction;
     if ($this->sample_id and is_numeric($entry_id)) {
         $transaction_id = $transaction->begin();
         $sample_has_organisation_unit = new SampleHasOrganisationUnit_Access($entry_id);
         $organisation_unit_id = $sample_has_organisation_unit->get_organisation_unit_id();
         $success = $sample_has_organisation_unit->delete();
         if ($success == true) {
             $sample_folder_id = SampleFolder::get_folder_by_sample_id($this->sample_id);
             $folder_id = OrganisationUnitFolder::get_folder_by_organisation_unit_id($organisation_unit_id);
             $virtual_folder = new VirtualFolder(null);
             $virtual_folder_array = $virtual_folder->list_entries_by_folder_id($folder_id);
             foreach ($virtual_folder_array as $key => $value) {
                 $virtual_folder = new SampleVirtualFolder($value);
                 if ($virtual_folder->is_sample_vfolder() == true) {
                     $virtual_folder_id = $value;
                 }
             }
             if ($virtual_folder_id) {
                 $virtual_folder = new VirtualFolder($virtual_folder_id);
                 if ($virtual_folder->unlink_folder($sample_folder_id) == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     return false;
                 }
             }
             $organisation_unit = new OrganisationUnit($organisation_unit_id);
             $group_array = $organisation_unit->list_groups();
             if (is_array($group_array) and count($group_array) >= 1) {
                 foreach ($group_array as $key => $value) {
                     $folder_id = GroupFolder::get_folder_by_group_id($value);
                     $virtual_folder = new VirtualFolder(null);
                     $virtual_folder_array = $virtual_folder->list_entries_by_folder_id($folder_id);
                     foreach ($virtual_folder_array as $key => $value) {
                         $virtual_folder = new SampleVirtualFolder($value);
                         if ($virtual_folder->is_sample_vfolder() == true) {
                             $virtual_folder_id = $value;
                         }
                     }
                     if (is_numeric($virtual_folder_id)) {
                         $virtual_folder = new VirtualFolder($virtual_folder_id);
                         if ($virtual_folder->unlink_folder($sample_folder_id) == false) {
                             if ($transaction_id != null) {
                                 $transaction->rollback($transaction_id);
                             }
                             return false;
                         }
                     }
                 }
             }
             if ($transaction_id != null) {
                 $transaction->commit($transaction_id);
             }
             return true;
         } else {
             if ($transaction_id != null) {
                 $transaction->rollback($transaction_id);
             }
             return false;
         }
     } else {
         return false;
     }
 }