function get_workspace_info(Project $workspace, $defaultParent = 0, $all_ws = null) { $parent = $defaultParent; if (!$all_ws) { $all_ws = logged_user()->getWorkspaces(true); } if (!is_array($all_ws)) { $all_ws = array(); } $wsset = array(); foreach ($all_ws as $w) { $wsset[$w->getId()] = true; } $tempParent = $workspace->getParentId(); $x = $workspace; while ($x instanceof Project && !isset($wsset[$tempParent])) { $tempParent = $x->getParentId(); $x = $x->getParentWorkspace(); } if (!$x instanceof Project) { $tempParent = 0; } $workspace_info = array("id" => $workspace->getId(), "name" => $workspace->getName(), "color" => $workspace->getColor(), "parent" => $tempParent, "realParent" => $workspace->getParentId(), "depth" => $workspace->getDepth()); if (logged_user()->getPersonalProjectId() == $workspace->getId()) { $workspace_info["isPersonal"] = true; } return $workspace_info; }