/** * Get repository user * * @param string $repository_user * @param Repository $repository * @return SourceUser */ function findByRepositoryUser($repository_user, $repository_id) { $source_user = SourceUsers::find(array('conditions' => "repository_user = '******' AND repository_id = '{$repository_id}'", 'one' => true)); if (instance_of($source_user, 'SourceUser')) { $source_user->setSystemUser(); } return $source_user; }
/** * Get CreatedBy information * * @param Repository $repository * @return User */ function getCreatedBy($repository = null) { if (is_null($repository)) { $repository = Repositories::findById($this->getParentId()); $repository->mapped_users = SourceUsers::findByRepository($repository); } // if if (isset($repository->mapped_users[$this->getCreatedByName()]) && instance_of($repository->mapped_users[$this->getCreatedByName()], 'SourceUser')) { $source_user = $repository->mapped_users[$this->getCreatedByName()]; if (instance_of($source_user->system_user, 'User')) { return $source_user->system_user; } // if } // if return parent::getCreatedBy(); }
/** * Delete user mapping * * @param void * @return null */ function repository_user_delete() { if (!$this->request->isAsyncCall()) { $this->httpError(HTTP_BAD_REQUEST, null, true); } // if if (!$this->request->isSubmitted()) { $this->httpError(HTTP_BAD_REQUEST, null, true); } // if $repository_user = array_var($_POST, 'repository_user'); $source_user = SourceUsers::findByRepositoryUser($repository_user, $this->active_repository->getId()); if (!instance_of($source_user, 'SourceUser')) { die('false'); } // if $deleted = $source_user->delete(); if ($deleted && !is_error($deleted)) { die('true'); } }
/** * Get mapped user * * @param string $repository_user * return mixed */ function getMappedUser($repository_user) { if (!is_foreachable($this->mapped_users)) { $this->mapped_users = SourceUsers::findByRepository($this); } // if if (isset($this->mapped_users[$repository_user]) && instance_of($this->mapped_users[$repository_user], 'SourceUser')) { $source_user = $this->mapped_users[$repository_user]; if (instance_of($source_user->system_user, 'User')) { return $source_user->system_user; } // if } // if return new AnonymousUser($repository_user, '*****@*****.**'); }