public static function delete(Repo $repo) { if ($repo->isNew()) { return false; } return self::physicallyDelete($repo->getEscapedName()); }
/** * @param string $name the compound name of the ref entry, e.g. "pq/Connection/exec" * @param \mdref\Repo $repo the containing repository */ public function __construct($name, Repo $repo) { $this->repo = $repo; $this->name = $name; $this->list = explode("/", $name); $this->path = $repo->hasEntry($name); }
/** * @param array $refs list of mdref repository paths */ public function __construct(array $refs) { foreach ($refs as $path) { $repo = new Repo($path); $this->repos[$repo->getName()] = $repo; } }
public function test_registerSaleItemQty() { /** === Test Data === */ $SALE_ITEM_ID = 21; $TOTAL = 23; $LOTS_DATA = [[Alias::AS_STOCK_ITEM_ID => 1, Alias::AS_LOT_ID => 2, Alias::AS_QTY => 3], [Alias::AS_STOCK_ITEM_ID => 1, Alias::AS_LOT_ID => 4, Alias::AS_QTY => 300]]; /** === Setup Mocks === */ $mDef = $this->_mockTransactionDefinition(); $this->mManTrans->shouldReceive('begin')->once()->andReturn($mDef); /** * First loop */ // $this->_repoQtySale->create($qtySaleData); $this->mRepoQtySale->shouldReceive('create')->once(); // $this->_repoQty->deleteById($qtyPk); $this->mRepoQty->shouldReceive('deleteById')->once(); /** * Second loop */ // $this->_repoQtySale->create($qtySaleData); $this->mRepoQtySale->shouldReceive('create')->once(); // $this->_repoQty->updateById($qtyPk, $qtyUpdateData); $this->mRepoQty->shouldReceive('updateById')->once(); /** * Close transaction. */ // $this->_manTrans->commit($def); $this->mManTrans->shouldReceive('commit')->once(); // $this->_manTrans->end($def); $this->mManTrans->shouldReceive('end')->once(); /** === Call and asserts === */ $this->obj->registerSaleItemQty($SALE_ITEM_ID, $TOTAL, $LOTS_DATA); }
public function execute() { if ('' === ($name = trim($this->getRequest()->getParameter('name', '')))) { die('Bad request'); } $this->getResponse()->setParameter('title', 'Subvy'); $this->getResponse()->setParameter('subversion_root_url', Configuration::get('svn_root_url')); $escaped_name = RepoManager::escape($name); $repo = new Repo($escaped_name); if ($created_repo_name = $repo->create()) { $this->getResponse()->setParameter('name', $escaped_name); $this->getResponse()->setParameter('image', 'images/tick.png'); $this->getResponse()->setParameter('status', 'Exito'); $this->getResponse()->setParameter('message', 'El repositorio ' . $created_repo_name . ' fue creado.'); } else { $this->getResponse()->setParameter('name', $escaped_name); $this->getResponse()->setParameter('image', 'images/error.png'); $this->getResponse()->setParameter('status', 'No disponible'); $this->getResponse()->setParameter('message', 'El repositorio ' . $created_repo_name . ' ya existe.'); } }
public function setUser() { // Should all succeed because of auth filter $token = APIToken::where('device_id', '=', \Input::get('device_id'))->where('token', '=', \Input::get('auth_token'))->get()->first(); if ($token) { $user = \Repo::call('User')->find($token->user_id); if ($user) { \Auth::login($user); $this->token = $token; } } }
public function getTreeInPath($path = null) { if (is_null($path)) { $path = $this->repo->getPath(); } $tree = $this->getTree(); if ($path) { $tree = array_filter($tree, function ($item) use($path) { return 0 === strpos($item['path'], $path); }); } return $tree; }
public function __construct() { parent::__construct(); // Clean up & update cached DB $pkgs = explode("\n\n", $this->pkgs); array_pop($pkgs); // remove file end $this->pkgs = []; for ($i = 0, $l = count($pkgs); $i < $l; $i++) { $pkg = explode("\n", $pkgs[$i]); // TODO: Figure out why `new stdClass()` doesn't work $new_pkg = (object) array(); foreach ($pkg as $datum) { $data = explode(': ', $datum); $new_pkg->{$data}[0] = $data[1]; } $this->pkgs[] = $new_pkg; } }
/** * undocumented function * * @param string $type * @param string $options * @return void */ function find($type = 'all', $options = array()) { if (!empty($options['conditions']['path'])) { $options['path'] = $options['conditions']['path']; unset($options['conditions']['path']); } $options = array_merge(array('path' => '.', 'limit' => 100, 'page' => 1), $options); if (empty($options['path'])) { return false; } $data = $this->look('history', array('path' => $options['path'])); if (preg_match_all('/[\\s+](\\d+)[\\s+]/', $data, $matches)) { $data = array_filter($matches[1]); } if ($type == 'count') { return count($data); } if ($type == 'all') { return parent::_findAll($data, compact('limit', 'page')); } }
/** * @param $line * * @return Repo[] * @throws GitoliteException */ protected function parseRepo($line) { $find = []; $arr = preg_split("/[\\s\t]+/", $line); array_shift($arr); foreach ($arr as $name) { if (self::isTeam($name)) { if (!($team = $this->getTeamAsRepo($name))) { GitoliteException::throwUndefinedTeam($name); } $find = array_merge($find, $team->items); } else { $repo = new Repo(); $repo->setName($name); $this->addRepo($repo); $find[] = $repo; } } return $find; }
function getRepositoryByName($name) { $repoFromDb = getRepositoryByNameSoft($name); if ($repoFromDb == null) { createRepository($name); $repoFromDb = getRepositoryByNameSoft($name); } if ($repoFromDb == null) { throw new Exception('Could not find repo by name: ' . $name); } else { $repo = new Repo(); $repo->fromDatabase($repoFromDb); return $repo; } }
private $tableName; public function __construct($tableName) { return $this->tableName = $tableName; } public function __call($finder, $arguments) { preg_match("/findAllBy([A-Z].*)/", $finder, $outputArray); if (!$outputArray) { throw new \Exception("f**k"); } $fieldUpperName = $outputArray[1]; preg_match_all("/[A-Z][^A-Z]+/", $fieldUpperName, $matches); $fieldName = implode('_', array_map(function ($part) { return mb_strtolower($part); }, $matches[0])); return $this->where($fieldName . $arguments[0]); } public function where($fieldName, $value) { $format = "select * from %s where %s = '%s'"; return sprintf($format, $this->_escape($this->tableName), $this->_escape($fieldName), $this->_escape($value)); } private function _escape($value) { // NOTE: we must to implement escape logic over here in real world return $value; } } $repo = new Repo("users"); $repo->findAllByName();
/** * Import gitolite.conf * */ public function import() { $file = file($this->getGitLocalRepositoryPath() . DIRECTORY_SEPARATOR . self::GITOLITE_CONF_DIR . DIRECTORY_SEPARATOR . self::GITOLITE_CONF_FILE); foreach ($file as $line) { $line = trim($line); if ($line == '') { continue; } if (preg_match('/^[@]/', $line)) { $line_split = preg_split("/[=]+/", $line, 2); if (count($line_split) != 2) { throw new \Exception('Invalid team def.'); } $team_name = substr(trim($line_split[0]), 1); $team = new Team(); $team->setName($team_name); $usr = preg_split("/[\\s\t]+/", trim($line_split[1])); foreach ($usr as $u) { // is team if (substr($u, 0, 1) == '@') { $u = substr($u, 1); if (!isset($this->teams[$u])) { throw new \Exception('Undef team.'); } $team->addTeam($this->teams[$u]); } else { if (isset($this->users[$u])) { $team->addUser($this->users[$u]); } else { $user = new User(); $user->setUsername($u); $key = $this->getGitLocalRepositoryPath() . DIRECTORY_SEPARATOR . self::GITOLITE_KEY_DIR . DIRECTORY_SEPARATOR . $user->renderKeyFileName(); if (file_exists($key)) { $user->addKey(file_get_contents($key)); } $this->users[$u] = $user; $team->addUser($user); } } } $this->teams[$team_name] = $team; } elseif (preg_match('/^repo/', $line)) { $line_split = preg_split("/[\\s\t]+/", $line, 2); if (count($line_split) != 2) { throw new \Exception('Invalid repository def.'); } $repo = new Repo(); $repo->setName(trim($line_split[1])); } elseif (preg_match('/^(R|RW|RW\\+|\\-|RWC|RW\\+C|RWD|RW\\+D|RWCD|RW\\+CD|RWDC|RW\\+DC)/', $line)) { $teams = array(); $users = array(); $line_split = preg_split("/[=]+/", $line, 2); if (count($line_split) != 2) { throw new \FuelException('Invalid rule.'); } $acl_split = preg_split("/[\\s\t]+/", trim($line_split[0]), 2); $refexes = isset($acl_split[1]) ? $acl_split[1] : false; $acl = new Acl(); $acl->setPermission($acl_split[0]); if ($refexes) { $acl->setRefexes($refexes); } $usr = preg_split("/[\\s\t]+/", trim($line_split[1])); foreach ($usr as $u) { // is team if (substr($u, 0, 1) == '@') { $u = substr($u, 1); if (!isset($this->teams[$u])) { throw new \Exception('Undef. team'); } $acl->addTeam($this->teams[$u]); } else { if (!isset($this->users[$u])) { $this->users[$u] = new User(); $this->users[$u]->setUsername($u); $key = $this->getGitLocalRepositoryPath() . DIRECTORY_SEPARATOR . self::GITOLITE_KEY_DIR . DIRECTORY_SEPARATOR . $this->users[$u]->renderKeyFileName(); if (file_exists($key)) { $this->users[$u]->addKey(file_get_contents($key)); } } $acl->addUser($this->users[$u]); } } $repo->addAcl($acl); $this->repos[$repo->getName()] = $repo; } } }
/** * Run a command specific to this type of repo * * @see execute for params * @return mixed */ function run($command, $args = array(), $return = false) { extract($this->config); $gitDir = null; if (empty($this->_before) && empty($this->gitDir)) { $gitDir = "--git-dir={$this->path} "; } return parent::run("{$gitDir}{$command}", $args, $return); }
if ($email == '') { $validation_errors[] = 'email'; $message[] = 'Please enter your email address.'; } if ($secret == '') { $validation_errors[] = 'secret'; $message[] = 'Please enter your password.'; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { $validation_errors[] = "email"; $message[] = "Please enter a valid email address."; } if (empty($validation_errors)) { $success = $encrypt->verify($secret); if ($success == true) { $repo = new Repo(); $row = $repo->getArraySingle($repo->buildSql(array('table' => 'individual', 'index' => 'email', 'value' => $email, 'columns' => array('id')))); $action = 'redirect'; $rurl = 'profile.php'; $post_data = array('individual_id' => $row['id']); } else { $validation_errors[] = 'email'; $validation_errors[] = 'secret'; $message[] = 'Incorrect email and password'; } } if (!empty($validation_errors)) { http_response_code(400); header("Content-Type: application/json"); echo json_encode(array('success' => false, 'validation_errors' => $validation_errors, 'message' => "<div class='notice bad'><p>" . implode("<br/>", $message) . "</p></div>")); exit;