function Lookup($pid_idx) { global $project_cache; # Look in cache first if (array_key_exists("{$pid_idx}", $project_cache)) { return $project_cache["{$pid_idx}"]; } $foo = new Project($pid_idx); if (!$foo->IsValid()) { # Try lookup by plain uid. $foo = Project::LookupByPid($pid_idx); if (!$foo || !$foo->IsValid()) { return null; } # Return here, already in the cache. return $foo; } # Insert into cache. $project_cache["{$pid_idx}"] = $foo; return $foo; }
function MayEditPub($user, $isadmin, $row) { global $TBDB_TRUST_LOCALROOT; if ($isadmin) { return true; } if (!$user) { return false; } $uid_idx = $user->uid_idx(); if ($uid_idx == $row['owner'] && $row['editable_owner']) { return true; } $pid = $row['project']; if ($pid == '') { return false; } $proj = Project::LookupByPid($pid); if (!$proj) { return false; } return TBMinTrust($proj->UserTrust($user), $TBDB_TRUST_LOCALROOT); }