Example #1
0
	/**
	 * Install only this mod
	 *
	 * @param string $phpbb phpBB root
	 */
	public function install_one($phpbb)
	{
		// Don't let install mods to non-phpBB
		if (!$this->test_phpbb($phpbb)) {
			throw new NotPhpbb('phpBB not found');
		}

		$editor = new Editor($phpbb);
		foreach ($this->copyresolvers as $test)
		{
			$editor->addCopyResolver($test);
		}

		try
		{
			// Perform copy action
			foreach ($this->actions['copy'] as $file)
			{
				$editor->copy($file['from'], $file['to']);
			}

			// Perform delete action
			foreach ($this->actions['delete'] as $file)
			{
				$editor->delete($file);
			}

			// Perform edits
			foreach ($this->actions['edit'] as $file => $edits)
			{
				$editor->file_open($file);

				foreach ($edits as $edit)
				{
					$this->do_edit($editor, $edit);
				}

				$editor->file_close();
			}

			// Perform sql queries
			foreach ($this->actions['sql'] as $dbms => $queries)
			{
				foreach ($queries as $query)
				{
					$editor->sql($query, $dbms);
				}
			}

			// Perform sql queries
			if (!empty($this->actions['installer'])) {
				$editor->installer($this->actions['installer']);
			}
		}
		catch (EditorException $e)
		{
			throw new InstallFailed("Editor exception", 0, $e);
		}

		$editor->commit_changes();
	}