function list_test_suite_recursive($directory, $recursive = false) { $folders = array(); $folder = new Folder($directory); foreach ($folder->get_folders('`^[^.].+$`') as $folder) { $folders[] = preg_replace('`^[\\./]*kernel`', '', $folder->get_path()); if ($recursive) { $folders = array_merge($folders, list_test_suite_recursive($folder->get_path(), true)); } } return $folders; }
/** * Creates a new Sample Folder including Folder * @param integer $sample_id * @return integer */ public function create($sample_id) { if (is_numeric($sample_id)) { $sample = new Sample($sample_id); // Folder $sample_folder_id = constant("SAMPLE_FOLDER_ID"); $folder = new Folder($sample_folder_id); $path = new Path($folder->get_path()); $path->add_element($sample_id); $name = $sample->get_name() . " (" . $sample->get_formatted_id() . ")"; if (($folder_id = parent::create($name, $sample_folder_id, $path->get_path_string(), $sample->get_owner_id(), null)) != null) { $sample_has_folder_access = new SampleHasFolder_Access(null); if ($sample_has_folder_access->create($sample_id, $folder_id) == null) { return null; } // Virtual Folders (Event) $sample_folder_create_event = new SampleFolderCreateEvent($folder_id); $event_handler = new EventHandler($sample_folder_create_event); if ($event_handler->get_success() == false) { $this->delete(); return false; } else { return $folder_id; } } else { return null; } } else { return null; } }
/** * @param integer $group_id * @return bool */ public function create($group_id) { global $transaction; if (is_numeric($group_id)) { $group = new Group($group_id); // Folder $group_folder_id = constant("GROUP_FOLDER_ID"); $folder = new Folder($group_folder_id); $path = new Path($folder->get_path()); $path->add_element($group_id); $folder = new Folder(null); if (($folder_id = parent::create($group->get_name(), $group_folder_id, $path->get_path_string(), 1, $group_id)) != null) { $folder_is_group_folder_access = new FolderIsGroupFolder_Access(null); if ($folder_is_group_folder_access->create($group_id, $folder_id) == null) { return false; } // Virtual Folders (Event) $group_folder_create_event = new GroupFolderCreateEvent($folder_id); $event_handler = new EventHandler($group_folder_create_event); if ($event_handler->get_success() == false) { $this->delete(); return false; } else { return true; } } else { return false; } } else { return false; } }
/** * Creates a new Project Folder including Folder * @param integer $project_id * @return integer */ public function create($project_id, $base_folder_id) { if (is_numeric($project_id)) { $project = new Project($project_id); // Folder if ($base_folder_id == null) { $project_folder_id = constant("PROJECT_FOLDER_ID"); } else { $project_folder_id = $base_folder_id; } $folder = new Folder($project_folder_id); $path = new Path($folder->get_path()); $path->add_element($project_id); if (($folder_id = parent::create($project->get_name(), $project_folder_id, $path->get_path_string(), $project->get_owner_id(), null)) != null) { $project_has_folder_access = new ProjectHasFolder_Access(null); if ($project_has_folder_access->create($project_id, $folder_id) == null) { return null; } // Virtual Folder $project_folder_create_event = new ProjectFolderCreateEvent($folder_id); $event_handler = new EventHandler($project_folder_create_event); if ($event_handler->get_success() == false) { $this->delete(); return false; } else { return $folder_id; } } else { return null; } } else { return null; } }
/** * @param integer $organisation_unit_id * @return bool */ public function create($organisation_unit_id) { if (is_numeric($organisation_unit_id)) { $organisation_unit = new OrganisationUnit($organisation_unit_id); // Folder $organisation_unit_folder_id = constant("ORGANISATION_UNIT_FOLDER_ID"); $folder = new Folder($organisation_unit_folder_id); $path = new Path($folder->get_path()); $path->add_element($organisation_unit_id); $folder = new Folder(null); if (($folder_id = parent::create($organisation_unit->get_name(), $organisation_unit_folder_id, $path->get_path_string(), $organisation_unit->get_master_owner_id(), null)) != null) { $folder_is_organisation_unit_folder_access = new FolderIsOrganisationUnitFolder_Access(null); if ($folder_is_organisation_unit_folder_access->create($organisation_unit_id, $folder_id) == null) { return false; } // Virtual Folders (Event) $organisation_unit_folder_create_event = new OrganisationUnitFolderCreateEvent($folder_id); $event_handler = new EventHandler($organisation_unit_folder_create_event); if ($event_handler->get_success() == false) { $this->delete(); return false; } else { return true; } } else { $this->delete(true, true); return false; } } else { return false; } }
private static function add_classes($directory, $pattern, $recursive = true) { $files = array(); $folder = new Folder($directory); $relative_path = Path::get_path_from_root($folder->get_path()); $files = $folder->get_files($pattern); foreach ($files as $file) { $filename = $file->get_name(); $classname = $file->get_name_without_extension(); self::$autoload[$classname] = $relative_path . '/' . $filename; } if ($recursive) { $folders = $folder->get_folders('`^[a-z]{1}.*$`i'); foreach ($folders as $a_folder) { if (!in_array($a_folder->get_path_from_root(), self::$exclude_paths) && !in_array($a_folder->get_name(), self::$exclude_folders_names)) { self::add_classes($a_folder->get_path(), $pattern); } } } }
/** * Creates a new folder * @param string $name * @param integer $toid * @param string $path * @param integer $owner_id * @param integer $owner_group_id * @return integer * @throws FolderCreateFailedException * @throws FolderCreateFolderAlreadyExistsException * @throws FolderCreatePhysicalCreationFailedException * @throws FolderCreateIDMissingException */ public function create($name, $toid, $path, $owner_id, $owner_group_id) { global $transaction; if (is_numeric($toid)) { $transaction_id = $transaction->begin(); try { $folder = new Folder($toid); $parent_data_entity_id = $folder->get_data_entity_id(); if (!$path) { $folder = new Folder($toid); $folder_name = str_replace(" ", "_", trim($name)); $path = $folder->get_path() . "/" . $folder_name; } $data_entity_id = parent::create($owner_id, $owner_group_id); parent::set_as_child_of($parent_data_entity_id); if (($folder_id = $this->folder->create($data_entity_id, $name, $path)) == null) { throw new FolderCreateFailedException(); } self::__construct($folder_id); $system_path = constant("BASE_DIR") . "/" . $path; if (file_exists($system_path)) { throw new FolderCreateFolderAlreadyExistsException(); } if (mkdir($system_path) == false) { throw new FolderCreatePhysicalCreationFailedException(); } } catch (BaseException $e) { if ($transaction_id != null) { $transaction->rollback($transaction_id); } throw $e; } if ($transaction_id != null) { $transaction->commit($transaction_id); } return $folder_id; } else { throw new FolderCreateIDMissingException(); } }
/** * Creates a new Project Folder including Folder * @param integer $project_id * @return integer */ public function create($project_id, $project_status_id) { if (is_numeric($project_id) and is_numeric($project_status_id)) { $project_status = new ProjectStatus($project_status_id); $project = new Project($project_id); $project_folder_id = ProjectFolder::get_folder_by_project_id($project_id); $folder = new Folder($project_folder_id); $path = new Path($folder->get_path()); $path->add_element("status-" . $project_status_id); if (($folder_id = parent::create($project_status->get_name(), $project_folder_id, $path->get_path_string(), $project->get_owner_id(), null)) != null) { $project_status_has_folder_access = new ProjectStatusHasFolder_Access(null); if ($project_status_has_folder_access->create($project_id, $project_status_id, $folder_id) == null) { return null; } return $folder_id; } else { return null; } } else { return null; } }
/** * @param integer $user_id * @return bool */ public function create($user_id) { if (is_numeric($user_id)) { $user = new User($user_id); // Folder $user_folder_id = constant("USER_FOLDER_ID"); $folder = new Folder($user_folder_id); $path = new Path($folder->get_path()); $path->add_element($user_id); if (($folder_id = parent::create($user->get_username(), $user_folder_id, $path->get_path_string(), $user_id, null)) != null) { $folder_is_user_folder_access = new FolderIsUserFolder_Access(null); if ($folder_is_user_folder_access->create($user_id, $folder_id) == null) { return false; } // _Public $public_path = new Path($path->get_path_string()); $public_path->add_element("_public"); $public_folder = new Folder(null); if ($public_folder->create("_public", $folder_id, $public_path->get_path_string(), $user_id, null) == null) { $this->delete(); return false; } // _Private $private_path = new Path($path->get_path_string()); $private_path->add_element("_private"); $private_folder = new Folder(null); if ($private_folder->create("_private", $folder_id, $private_path->get_path_string(), $user_id, null) == null) { $this->delete(); return false; } // Virtual Folders (Event) $user_folder_create_event = new UserFolderCreateEvent($folder_id); $event_handler = new EventHandler($user_folder_create_event); if ($event_handler->get_success() == false) { $this->delete(); return false; } else { return true; } } else { return false; } } else { return false; } }