Beispiel #1
0
	private function nameUP($name,$userID,$projectID)
	{
		if (!$userID) {
			$u=LPC_User::getCurrent();
			$userID=$u->id;
		}
		if (!$projectID) {
			$p=LPC_Project::getCurrent();
			$projectID=$p->id;
		}
		return $name.'.u'.$userID.'.p'.$projectID;
	}
Beispiel #2
0
	function removeFromGroup($group,$project=false)
	{
		if (is_integer($group))
			$groupID=$group;
		elseif ($group instanceof LPC_Group)
			$groupID=$group->id;
		else
			throw new RuntimeException("Unknown parameter \$group type! Expecting an integer or a LPC_Group instance.");

		if ($project===false)
			$projectID=LPC_Project::getCurrent()->id;
		elseif (is_integer($project))
			$projectID=$project;
		elseif ($project instanceof LPC_Project)
			$projectID=$project->id;
		else
			throw new RuntimeException("Unknown parameter \$project type! Expecting boolean false, an integer or a LPC_Project instance.");

		$rs=$this->query("
			SELECT project
			FROM LPC_user_membership
			WHERE
				user_member=".$this->id." AND
				member_to=".$groupID." AND
				project IN (0,".$projectID.")
		");
		$projectIDs=array();
		while(!$rs->EOF) {
			$projectIDs[]=$rs->fields['project'];
			$rs->MoveNext();
		}
		$linkCount=count($projectIDs);
		$projectIDs=array_unique($projectIDs);
		foreach($projectIDs as $prjID)
			self::expireCache($prjID,$this->id);

		$rs=$this->query("
			DELETE
			FROM LPC_user_membership
			WHERE
				user_member=".$this->id." AND
				member_to=".$groupID." AND
				project IN (0,".$projectID.")
		");
		if (!$rs)
			return false;

		return $linkCount;
	}
Beispiel #3
0
	private function pid($projectID)
	{
		if ($projectID)
			return $projectID;
		return LPC_Project::getCurrent()->id;
	}
Beispiel #4
0
	/**
	* Returns the project specified by the respective id, or
	* a reference to the current project if $project==0.
	* Works with LPC_Project objects too.
	* @param mixed $project the id to use
	* @return reference a reference to the project object
	*/
	function defaultProject($project=0)
	{
		if ($project===0) {
			if ($proj=LPC_Project::getCurrent(true))
				return $proj;
			return new LPC_No_project();
		}
		if (is_numeric($project)) {
			$pc=LPC_project_class;
			return new $pc($project);
		}
		if (is_object($project)) {
			if (!is_a($project,"LPC_Project"))
				throw new InvalidArgumentException("Unknown class ".get_class($project));

			return $project;
		}
		throw new InvalidArgumentException("Unknown entity type: ".gettype($project));
	}
Beispiel #5
0
	return;
}

$u=LPC_User::newUser();
$u->idFromArrayKey($_REQUEST, 'user_id');

$f=new LPC_HTML_form();
$p->a($f);
$f->a(htmlspecialchars(_LS('rightsTestUserID')).": <input type='text' name='user_id' value='".$u->id."'> ");
$f->a("<input type='submit' name='submit' value='"._LS('rightsTestSubmit')."'>");

if (!$u->id)
	return;

if (defined('LPC_project_class') && LPC_project_class)
	$prj=LPC_Project::getCurrent();
else
	$prj=NULL;

$cache=LPC_Cache::getCurrent();
$t=new LPC_HTML_table();
$p->a($t);
$t->a("<tr><th>"._LS('rightTestUserDate')."</td><td>".date('r', $cache->getUPf(LPC_User::PD_KEY, $u->id))." (".($u->validatePermissionsCache()?"VALID":"INVALID").")</td></tr>");
$t->a("<tr><th>"._LS('rightTestGlobalExpDate')."</th><td>".date('r', $cache->getG(LPC_User::PE_KEY))."</td></tr>");
$t->a("<tr><th>"._LS('rightTestUserExpDate')."</th><td>".date('r', $cache->getU(LPC_User::PE_KEY, $u->id))."</td></tr>");
if ($prj) {
	$t->a("<tr><th>"._LS('rightTestProjectExpDate')."</th><td>".date('r', $cache->getP(LPC_User::PE_KEY, $prj->id))."</td></tr>");
	$t->a("<tr><th>"._LS('rightTestUserProjectExpDate')."</th><td>".date('r', $cache->getUP(LPC_User::PE_KEY, $u->id, $prj->id))."</td></tr>");
}
$t->a("<tr><th>"._LS('rightTestUserPermissions')."</th><td><pre>".print_r($cache->getUPf(LPC_User::P_KEY, $u->id),1));