コード例 #1
0
ファイル: GroupList.php プロジェクト: rinaldinoor/scoreBoard
 public function render($event)
 {
     $template = $this->template;
     $template->groups = $this->model->getGroups()->where('eventID', $event);
     $template->setFile(dirname(__FILE__) . '/GroupList.latte');
     $template->render();
 }
コード例 #2
0
ファイル: TeamList.php プロジェクト: rinaldinoor/scoreBoard
 public function render($id)
 {
     $template = $this->template;
     $template->setFile(dirname(__FILE__) . '/TeamList.latte');
     $teams = $this->results->where('groupID', $id)->order('points DESC, goal_diff DESC');
     //dump($teams);
     $template->names = $this->teams;
     $template->teams = $teams;
     $template->render();
 }
コード例 #3
0
ファイル: MatchList.php プロジェクト: rinaldinoor/scoreBoard
 public function render($group, $unplayed = 'ready')
 {
     $template = $this->template;
     $template->matches = $this->model->getMatches()->where('groupID', $group);
     $template->unplayed = $this->model->getMatches()->where(array('groupID' => $group, 'state' => $unplayed));
     $template->state = $unplayed;
     $template->group = $group;
     $template->names = $this->model->getTeams();
     $template->setFile(dirname(__FILE__) . '/MatchList.latte');
     $template->render();
 }
コード例 #4
0
 /**
  * Performs an authentication
  * @param  array
  * @return NIdentity
  * @throws NAuthenticationException
  */
 public function authenticate(array $credentials)
 {
     list($username, $password) = $credentials;
     $row = $this->users->where('username', $username)->fetch();
     if (!$row) {
         throw new NAuthenticationException("User '{$username}' not found.", self::IDENTITY_NOT_FOUND);
     }
     if ($row->password !== $this->calculateHash($password)) {
         throw new NAuthenticationException("Invalid password.", self::INVALID_CREDENTIAL);
     }
     unset($row->password);
     return new NIdentity($row->id, $row->role, $row->toArray());
 }
コード例 #5
0
ファイル: ActiveRow.php プロジェクト: rinaldinoor/scoreBoard
	protected function getReference($table, $column)
	{
		if (array_key_exists($column, $this->data)) {
			$this->access($column);

			$value = $this->data[$column];
			$value = $value instanceof NTableRow ? $value->getPrimary() : $value;

			$referenced = $this->table->getReferencedTable($table, $column, !empty($this->modified[$column]));
			$referenced = isset($referenced[$value]) ? $referenced[$value] : NULL; // referenced row may not exist

			if (!empty($this->modified[$column])) { // cause saving changed column and prevent regenerating referenced table for $column
				$this->modified[$column] = 0; // 0 fails on empty, pass on isset
			}

			return $referenced;
		}
	}
コード例 #6
0
ファイル: Selection.php プロジェクト: rinaldinoor/scoreBoard
	/**
	 * Returns referenced row.
	 * @param  string
	 * @param  string
	 * @param  bool  checks if rows contains the same primary value relations
	 * @return NTableRow or NULL if the row does not exist
	 */
	public function getReferencedTable($table, $column, $checkReferenceNewKeys = FALSE)
	{
		$referenced = & $this->referenced[$table][$column];
		if ($referenced === NULL || $checkReferenceNewKeys || $this->checkReferenceNewKeys) {
			$keys = array();
			foreach ($this->rows as $row) {
				if ($row[$column] === NULL)
					continue;

				$key = $row[$column] instanceof NTableRow ? $row[$column]->getPrimary() : $row[$column];
				$keys[$key] = TRUE;
			}

			if ($referenced !== NULL && $keys === array_keys($this->rows)) {
				$this->checkReferenceNewKeys = FALSE;
				return $referenced;
			}

			if ($keys) {
				$referenced = new NTableSelection($table, $this->connection);
				$referenced->where($table . '.' . $this->getPrimary($table), array_keys($keys));
			} else {
				$referenced = array();
			}
		}

		return $referenced;
	}
コード例 #7
0
	protected function execute()
	{
		if ($this->rows !== NULL) {
			return;
		}

		$referencing = & $this->refTable->referencing[$this->getSql()];
		if ($referencing === NULL) {
			$limit = $this->limit;
			$rows = count($this->refTable->rows);
			if ($this->limit && $rows > 1) {
				$this->limit = NULL;
			}
			parent::execute();
			$this->limit = $limit;
			$referencing = array();
			$offset = array();
			foreach ($this->rows as $key => $row) {
				$ref = & $referencing[$row[$this->column]];
				$skip = & $offset[$row[$this->column]];
				if ($limit === NULL || $rows <= 1 || (count($ref) < $limit && $skip >= $this->offset)) {
					$ref[$key] = $row;
				} else {
					unset($this->rows[$key]);
				}
				$skip++;
				unset($ref, $skip);
			}
		}

		$this->data = & $referencing[$this->active];
		if ($this->data === NULL) {
			$this->data = array();
		}
	}
コード例 #8
0
ファイル: GroupedSelection.php プロジェクト: krecek/nrsn
	public function delete()
	{
		$builder = $this->sqlBuilder;

		$this->sqlBuilder = clone $this->sqlBuilder;
		$this->where($this->column, $this->active);
		$return = parent::delete();

		$this->sqlBuilder = $builder;
		return $return;
	}