예제 #1
0
 /**
  * @param string $json_argument_array
  * @return integer
  * @throws ProjectSecurityAccessDeniedException
  * @throws ProjectIDMissingException
  */
 public static function count_project_permissions($json_argument_array)
 {
     global $user, $project_security;
     $argument_array = json_decode($json_argument_array);
     $project_id = $argument_array[1];
     if (is_numeric($project_id)) {
         $project = new Project($project_id);
         $project_permission_array = ProjectPermission::list_entries_by_project_id($project_id);
         if ($user->get_user_id() == $project->get_owner_id() or $project_security->is_access(2, false) == true or $project_security->is_access(4, false) == true or $project_security->is_access(7, false) == true) {
             return Project_Wrapper::count_project_permissions($project_id);
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }
예제 #2
0
 /**
  * @throws ProjectIDMissingException
  * @throws ProjectSecurityAccessDeniedException
  * @throws ProjectPermissionIDMissingException
  */
 public static function permission_delete()
 {
     global $project_security, $user;
     if ($_GET['project_id']) {
         if ($_GET['id']) {
             $project = new Project($_GET['project_id']);
             if ($user->get_user_id() == $project->get_owner_id() or $project_security->is_access(2, false) == true or $project_security->is_access(4, false) == true or $project_security->is_access(7, false) == true) {
                 if ($_GET['sure'] != "true") {
                     $template = new HTMLTemplate("project/admin/permission_delete.html");
                     $paramquery = $_GET;
                     $paramquery['sure'] = "true";
                     $params = http_build_query($paramquery);
                     $template->set_var("yes_params", $params);
                     $paramquery = $_GET;
                     unset($paramquery['nextpage']);
                     unset($paramquery['id']);
                     $paramquery['run'] = "admin_permission";
                     $params = http_build_query($paramquery);
                     $template->set_var("no_params", $params);
                     $template->output();
                 } else {
                     $paramquery = $_GET;
                     unset($paramquery['nextpage']);
                     unset($paramquery['id']);
                     unset($paramquery['sure']);
                     $paramquery['run'] = "admin_permission";
                     $params = http_build_query($paramquery);
                     $project_permission = ProjectPermission::get_instance($_GET['id']);
                     if ($project_permission->delete()) {
                         Common_IO::step_proceed($params, "Delete Permission", "Operation Successful", null);
                     } else {
                         Common_IO::step_proceed($params, "Delete Permission", "Operation Failed", null);
                     }
                 }
             } else {
                 throw new ProjectSecurityAccessDeniedException();
             }
         } else {
             throw new ProjectPermissionIDMissingException();
         }
     } else {
         throw new ProjectIDMissingException();
     }
 }
예제 #3
0
 /**
  * @see ProjectInterface::move_to_project()
  * @param integer $organisation_unit_id
  * @return bool
  * @throws ProjectMoveException
  * @throws ProjectMoveProjectExistsException
  * @throws ProjectMovePermissionException
  * @throws ProjectMoveFolderException
  * @throws ProjectSecurityAccessDeniedException
  */
 public function move_to_project($project_id)
 {
     global $user, $transaction;
     if ($this->project_id and $this->project and is_numeric($project_id)) {
         $project_security = new ProjectSecurity($this->project_id);
         if ($project_security->is_access(3, false)) {
             if (self::exist_project_name(null, $project_id, $this->project->get_name()) == false) {
                 $transaction_id = $transaction->begin();
                 $project_permission_array = ProjectPermission::list_entries_by_project_id($this->project_id);
                 if (is_array($project_permission_array) and count($project_permission_array) >= 1) {
                     foreach ($project_permission_array as $key => $value) {
                         try {
                             $project_permission = ProjectPermission::get_instance($value);
                             $project_permission->delete();
                         } catch (ProjectPermissionException $e) {
                             if ($transaction_id != null) {
                                 $transaction->rollback($transaction_id);
                             }
                             throw new ProjectMovePermissionException();
                         }
                     }
                 }
                 if ($this->project->set_toid_organ_unit(null) == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectMoveException();
                 }
                 if ($this->project->set_toid_project($project_id) == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectMoveException();
                 }
                 $folder_id = ProjectFolder::get_folder_by_project_id($this->project_id);
                 $folder = new Folder($folder_id);
                 $destination_id = ProjectFolder::get_folder_by_project_id($project_id);
                 if ($folder->move_folder($destination_id, false) == false) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectMoveFolderException();
                 }
                 if ($transaction_id != null) {
                     $transaction->commit($transaction_id);
                 }
                 return true;
             } else {
                 throw new ProjectMoveProjectExistsException();
             }
         } else {
             throw new ProjectSecurityAccessDeniedException();
         }
     } else {
         throw new ProjectMoveException();
     }
 }
예제 #4
0
/**
 * Determines whether a ProjectUser object allows access to an object
 *
 * @param ApplicationDataObject $object
 * @param ProjectPermission $proj_perm
 * @return unknown
 */
function can_manage_type($object_type, $proj_perm, $access_level)
{
    if ($proj_perm) {
        switch ($object_type) {
            case 'ProjectEvents':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteEvents();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadEvents();
                    } else {
                        return false;
                    }
                }
                break;
            case 'ProjectFiles':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteFiles();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadFiles();
                    } else {
                        return false;
                    }
                }
                break;
            case 'ProjectMessages':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteMessages();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadMessages();
                    } else {
                        return false;
                    }
                }
                break;
            case 'ProjectMilestones':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteMilestones();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadMilestones();
                    } else {
                        return false;
                    }
                }
                break;
            case 'ProjectTasks':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteTasks();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadTasks();
                    } else {
                        return false;
                    }
                }
                break;
            case 'ProjectWebpages':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteWeblinks();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadWeblinks();
                    } else {
                        return false;
                    }
                }
                break;
            case 'MailContents':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteMails();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadMails();
                    } else {
                        return false;
                    }
                }
                break;
            case 'Companies':
            case 'Contacts':
                if ($access_level == ACCESS_LEVEL_WRITE) {
                    return $proj_perm->getCanWriteContacts();
                } else {
                    if ($access_level == ACCESS_LEVEL_READ) {
                        return $proj_perm->getCanReadContacts();
                    } else {
                        return false;
                    }
                }
                break;
        }
    }
    return false;
}
예제 #5
0
 /**
  * @see ProjectSecurityInterface::change_organisation_unit_permission()
  * @param integer $organisation_unit_id
  * @return bool
  * @throws ProjectSecurityChangeException
  */
 public function change_organisation_unit_permission($organisation_unit_id)
 {
     global $transaction;
     if (is_numeric($organisation_unit_id)) {
         $transaction_id = $transaction->begin();
         $organisation_unit = new OrganisationUnit($organisation_unit_id);
         $project_permission_ou_group_array = ProjectPermission::list_entries_by_project_id_and_intention($this->project_id, 4);
         if (is_array($project_permission_ou_group_array) and count($project_permission_ou_group_array) >= 1) {
             foreach ($project_permission_ou_group_array as $key => $value) {
                 try {
                     $project_permission = ProjectPermission::get_instance($value);
                     $project_permission->delete() == false;
                 } catch (ProjectPermissionException $e) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectSecurityChangeException();
                 }
             }
         }
         $project_permission_array = ProjectPermission::list_entries_by_project_id_and_intention($this->project_id, 3);
         if (count($project_permission_array) > 0 and is_numeric($project_permission_array[0])) {
             $project_permission = ProjectPermission::get_instance($project_permission_array[0]);
             if (($return_value = $project_permission->set_organisation_unit_id($organisation_unit_id)) == false) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new ProjectSecurityChangeException();
             }
         } else {
             try {
                 $project_permission = new ProjectPermissionOrganisationUnit(null);
                 $return_value = $project_permission->create($organisation_unit_id, $this->project_id, (int) Registry::get_value("project_organisation_unit_default_permission"), null, 3);
             } catch (ProjectPermissionOrganisationUnitException $e) {
                 if ($transaction_id != null) {
                     $transaction->rollback($transaction_id);
                 }
                 throw new ProjectSecurityChangeException();
             }
         }
         $group_array = $organisation_unit->list_groups();
         if (is_array($group_array) and count($group_array) >= 1) {
             foreach ($group_array as $key => $value) {
                 try {
                     $project_permission = new ProjectPermissionGroup(null);
                     $project_permission->create($value, $this->project_id, (int) Registry::get_value("project_group_default_permission"), null, 4);
                 } catch (ProjectPermissionGroupException $e) {
                     if ($transaction_id != null) {
                         $transaction->rollback($transaction_id);
                     }
                     throw new ProjectSecurityChangeException();
                 }
             }
         }
         if ($transaction_id != null) {
             $transaction->commit($transaction_id);
         }
         return $return_value;
     } else {
         throw new ProjectSecurityChangeException("Missing Information");
     }
 }
예제 #6
0
 /**
  * @see EventListenerInterface::listen_events()
  * @param object $event_object
  * @return bool
  */
 public static function listen_events($event_object)
 {
     if ($event_object instanceof UserDeleteEvent) {
         if (ProjectPermission_Access::delete_by_user_id($event_object->get_user_id()) == false) {
             return false;
         }
     }
     if ($event_object instanceof GroupDeleteEvent) {
         if (ProjectPermission_Access::delete_by_group_id($event_object->get_group_id()) == false) {
             return false;
         }
     }
     if ($event_object instanceof OrganisationUnitDeleteEvent) {
         if (ProjectPermission_Access::delete_by_organisation_unit_id($event_object->get_organisation_unit_id()) == false) {
             return false;
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitLeaderCreateEvent) {
         $project_array = Project::list_organisation_unit_related_projects($event_object->get_organisation_unit_id(), true);
         if (is_array($project_array) and count($project_array) >= 1) {
             $project_permission = new ProjectPermissionUser(null);
             foreach ($project_array as $key => $value) {
                 if ($project_permission->create($event_object->get_leader_id(), $value, (int) Registry::get_value("project_leader_default_permission"), null, 2) == null) {
                     return false;
                 }
             }
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitLeaderDeleteEvent) {
         $project_array = Project::list_organisation_unit_related_projects($event_object->get_organisation_unit_id(), true);
         if (is_array($project_array) and count($project_array) >= 1) {
             foreach ($project_array as $key => $value) {
                 $permission_array = self::list_entries_by_project_id_and_intention_and_user_id($value, 2, $event_object->get_leader_id());
                 if (is_array($permission_array) and count($permission_array) >= 1) {
                     foreach ($permission_array as $permission_key => $permission_value) {
                         $project_permission = self::get_instance($permission_value);
                         if ($project_permission->delete() == false) {
                             return false;
                         }
                     }
                 }
             }
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitQualityManagerCreateEvent) {
         $project_array = Project::list_organisation_unit_related_projects($event_object->get_organisation_unit_id(), true);
         if (is_array($project_array) and count($project_array) >= 1) {
             $project_permission = new ProjectPermissionUser(null);
             foreach ($project_array as $key => $value) {
                 if ($project_permission->create($event_object->get_quality_manager_id(), $value, (int) Registry::get_value("project_quality_manager_default_permission"), null, 5) == null) {
                     return false;
                 }
             }
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitQualityManagerDeleteEvent) {
         $project_array = Project::list_organisation_unit_related_projects($event_object->get_organisation_unit_id(), true);
         if (is_array($project_array) and count($project_array) >= 1) {
             foreach ($project_array as $key => $value) {
                 $permission_array = self::list_entries_by_project_id_and_intention_and_user_id($value, 5, $event_object->get_quality_manager_id());
                 if (is_array($permission_array) and count($permission_array) >= 1) {
                     foreach ($permission_array as $permission_key => $permission_value) {
                         $project_permission = self::get_instance($permission_value);
                         if ($project_permission->delete() == false) {
                             return false;
                         }
                     }
                 }
             }
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitGroupCreateEvent) {
         $project_array = self::list_system_setted_projects_by_organisation_id($event_object->get_organisation_unit_id());
         if (is_array($project_array) and count($project_array) >= 1) {
             foreach ($project_array as $key => $value) {
                 $project_permission = new ProjectPermissionGroup(null);
                 if ($project_permission->create($event_object->get_group_id(), $value, (int) Registry::get_value("project_group_default_permission"), null, 4) == null) {
                     return false;
                 }
             }
         }
     }
     /**
      * @todo slow
      */
     if ($event_object instanceof OrganisationUnitGroupDeleteEvent) {
         $project_array = self::list_system_setted_projects_by_organisation_id($event_object->get_organisation_unit_id());
         if (is_array($project_array) and count($project_array) >= 1) {
             foreach ($project_array as $key => $value) {
                 $project_permission_array = ProjectPermission::list_entries_by_project_id_and_intention_and_group_id($value, 4, $event_object->get_group_id());
                 if (is_array($project_permission_array) and count($project_permission_array) >= 1) {
                     foreach ($project_permission_array as $sub_key => $sub_value) {
                         $project_permission = self::get_instance($sub_value);
                         if ($project_permission->delete() == false) {
                             return false;
                         }
                     }
                 }
             }
         }
     }
     return true;
 }
 /**
  * @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();
     }
 }