Base class for managing metadata about various Habari objects
 /**
  * @param Version $version
  *
  * @return bool
  */
 public function complies(Version $version)
 {
     if ($version->getMajor()->getValue() != $this->major) {
         return false;
     }
     return $version->getMinor()->getValue() == $this->minor;
 }
 /**
  * This function will create a new user object and return the newly created user object.
  *
  * @param array $userInfo This should have the properties: username, firstname, lastname, password, ui_language
  *
  * @return mixed
  */
 public function registerUser(array $userInfo, $userLanguage)
 {
     $user = \User::create($userInfo);
     //make the first user an admin
     if (\User::all()->count() <= 1) {
         $user->is_admin = 1;
     }
     // Trim trailing whitespace from user first and last name.
     $user->firstname = trim($user->firstname);
     $user->lastname = trim($user->lastname);
     $user->save();
     \Setting::create(['ui_language' => $userLanguage, 'user_id' => $user->id]);
     /* Add welcome note to user - create notebook, tag and note */
     //$notebookCreate = Notebook::create(array('title' => Lang::get('notebooks.welcome_notebook_title')));
     $notebookCreate = new \Notebook();
     $notebookCreate->title = Lang::get('notebooks.welcome_notebook_title');
     $notebookCreate->save();
     $notebookCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
     //$tagCreate = Tag::create(array('title' => Lang::get('notebooks.welcome_note_tag'), 'visibility' => 0));
     $tagCreate = new \Tag();
     $tagCreate->title = Lang::get('notebooks.welcome_note_tag');
     $tagCreate->visibility = 0;
     $tagCreate->user_id = $user->id;
     $tagCreate->save();
     //$tagCreate->users()->attach($user->id);
     $noteCreate = new \Note();
     $versionCreate = new \Version(['title' => Lang::get('notebooks.welcome_note_title'), 'content' => Lang::get('notebooks.welcome_note_content'), 'content_preview' => mb_substr(strip_tags(Lang::get('notebooks.welcome_note_content')), 0, 255), 'user_id' => $user->id]);
     $versionCreate->save();
     $noteCreate->version()->associate($versionCreate);
     $noteCreate->notebook_id = $notebookCreate->id;
     $noteCreate->save();
     $noteCreate->users()->attach($user->id, ['umask' => \PaperworkHelpers::UMASK_OWNER]);
     $noteCreate->tags()->sync([$tagCreate->id]);
     return $user;
 }
Example #3
0
 /**
  * @dataProvider processProvider
  * @param bool $isPost
  */
 public function testProcess($isPost)
 {
     $this->requestMock->expects($this->once())->method('isPost')->will($this->returnValue($isPost));
     if ($isPost) {
         $this->cookieMock->expects($this->once())->method('set');
     }
     $this->version->process();
 }
Example #4
0
/**
 * Wiki for phpWebSite
 *
 * See docs/CREDITS for copyright information
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @package Wiki
 * @author Greg Meiste <*****@*****.**>
 */
function wiki_install(&$content)
{
    PHPWS_Core::initModClass('wiki', 'WikiManager.php');
    PHPWS_Core::initModClass('wiki', 'WikiPage.php');
    PHPWS_Core::initModClass('version', 'Version.php');
    // Adding pages that ship with the module
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/frontpage.txt')) {
        $frontpage = new WikiPage('FrontPage');
        $frontpage->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/frontpage.txt')));
        $frontpage->setOwnerId(Current_User::getId());
        $frontpage->setEditorId(Current_User::getId());
        $frontpage->setCreated(mktime());
        $frontpage->setUpdated(mktime());
        $frontpage->setComment('Provided by Wiki install');
        $frontpage->save();
        $version1 = new Version('wiki_pages');
        $version1->setSource($frontpage);
        $version1->setApproved(1);
        $version1->save();
    }
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/samplepage.txt')) {
        $samplepage = new WikiPage('SamplePage');
        $samplepage->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/samplepage.txt')));
        $samplepage->setOwnerId(Current_User::getId());
        $samplepage->setEditorId(Current_User::getId());
        $samplepage->setCreated(mktime());
        $samplepage->setUpdated(mktime());
        $samplepage->setComment('Provided by Wiki install');
        $samplepage->allow_edit = 0;
        $samplepage->save();
        $version2 = new Version('wiki_pages');
        $version2->setSource($samplepage);
        $version2->setApproved(1);
        $version2->save();
    }
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/sandbox.txt')) {
        $sandbox = new WikiPage('WikiSandBox');
        $sandbox->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/sandbox.txt')));
        $sandbox->setOwnerId(Current_User::getId());
        $sandbox->setEditorId(Current_User::getId());
        $sandbox->setCreated(mktime());
        $sandbox->setUpdated(mktime());
        $sandbox->setComment('Provided by Wiki install');
        $sandbox->save();
        $version3 = new Version('wiki_pages');
        $version3->setSource($sandbox);
        $version3->setApproved(1);
        $version3->save();
    }
    // Adding first interwiki link
    PHPWS_Core::initModClass('wiki', 'InterWiki.php');
    $interwiki = new InterWiki();
    $interwiki->setLabel('Wikipedia');
    $interwiki->setUrl('http://en.wikipedia.org/wiki/%s');
    $interwiki->save(FALSE);
    return TRUE;
}
 public function getApplications(Version $versionm)
 {
     $apps = $versionm->builds()->get();
     foreach ($apps as $app) {
         $app_address = "/builds/android/{$app->version->label->label_name}/{$app->version->version}/{$app->build}/{$app->bundle}";
         $result[] = array("name" => $app->name, "link_to_file" => Config::get('app.base_url') . $app_address . ".apk", "icon" => Config::get('app.base_url') . $app_address . ".png", "version" => $app->version->version, "build" => $app->build, "bundle" => $app->bundle, "date" => $app->created_at);
     }
     return Response::json($result)->header("Content-type", "application/json");
 }
Example #6
0
 public function setVersions($versions = [])
 {
     $this->versions = collect($versions)->map(function ($value, $version) {
         $obj = new Version($version);
         $obj->setChanges($value['changes']);
         $obj->setRequirements($value['requirements']);
         $obj->setTasks($value['tasks']);
         return $obj;
     });
 }
Example #7
0
 public function testGetValueDefaultModeSaving()
 {
     $this->appState->expects($this->once())->method('getMode')->will($this->returnValue(\Magento\Framework\App\State::MODE_DEFAULT));
     $storageException = new \UnexpectedValueException('Does not exist in the storage');
     $this->versionStorage->expects($this->once())->method('load')->will($this->throwException($storageException));
     $this->dateTime->expects($this->once())->method('toTimestamp')->will($this->returnValue('123'));
     $this->versionStorage->expects($this->once())->method('save')->with('123');
     $this->assertEquals('123', $this->object->getValue());
     $this->object->getValue();
     // Ensure caching in memory
 }
	public function executeNew(sfWebRequest $request)
	{
		$version = new Version();
		sfContext::getInstance()->getUser()->setAttribute('inclusion', false);
		$this->estado = Estado::crearEstado(Estado::CREADA);
		$version->setValidada(false);
		$version->setEstado($this->estado);
		$version->setArtefacto($this->buscarArtefacto($request));
		$this->forward404Unless($version->tramitable());
		$this->form = new VersionForm($version);

	}
Example #9
0
 /**
  * Gets the number of bits used in a specific QR code version.
  *
  * @param  Version $version
  * @return integer
  */
 public function getCharacterCountBits(Version $version)
 {
     $number = $version->getVersionNumber();
     if ($number <= 9) {
         $offset = 0;
     } elseif ($number <= 26) {
         $offset = 1;
     } else {
         $offset = 2;
     }
     return self::$characterCountBitsForVersions[$this->value][$offset];
 }
 public function actionIndex()
 {
     $model = new Version();
     if (isset($_POST['Version'])) {
         $model->setAttributes($_POST['Version'], false);
         if ($model->save()) {
             echo '成功';
         }
     } else {
         $data = $model->findAll(null);
         $this->send(ERROR_NONE, $data[0]);
     }
     $this->render('index', array('model' => $model));
 }
Example #11
0
 /**
  * Internal function to return a Version object from a row.
  * @param $row array
  * @return Version
  */
 function &_returnVersionFromRow(&$row)
 {
     $version = new Version();
     $version->setMajor($row['major']);
     $version->setMinor($row['minor']);
     $version->setRevision($row['revision']);
     $version->setBuild($row['build']);
     $version->setDateInstalled($this->datetimeFromDB($row['date_installed']));
     $version->setCurrent($row['current']);
     $version->setProductType(isset($row['product_type']) ? $row['product_type'] : null);
     $version->setProduct(isset($row['product']) ? $row['product'] : null);
     HookRegistry::call('VersionDAO::_returnVersionFromRow', array(&$version, &$row));
     return $version;
 }
Example #12
0
 public function getGeneral()
 {
     $data = array();
     $version = new Version();
     $data['platform'] = $version->getLongVersion();
     $data['php_version'] = phpversion();
     $data['php_build'] = php_uname();
     $data['db_version'] = $this->db->getVersion();
     $data['db_collation'] = $this->db->getCollation();
     $data['server'] = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : getenv('SERVER_SOFTWARE');
     $data['sapi'] = php_sapi_name();
     $data['user_agent'] = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
     return $data;
 }
Example #13
0
function get_invalid_versions()
{
    $invalid = array();
    require_once 'modules/Versions/ExpectedVersions.php';
    foreach ($expect_versions as $expect) {
        $version = new Version();
        $result = $version->db->query("Select * from  {$version->table_name}  where  name='" . $expect['name'] . "'");
        $valid = $version->db->fetchByAssoc($result);
        if ($valid == null || !$version->is_expected_version($expect) && !empty($version->name)) {
            $invalid[$expect['name']] = $expect;
        }
    }
    return $invalid;
}
 /**
  * Determine si cette version est plus recente qu'une autre.
  * @param Version $version La version a comparer.
  * @return bool Vrai si cette version est plus recente que celle specifiee.
  */
 public function isNewerThan(Version $version)
 {
     $otherFetchedVersion = $version->getFetchedVersion();
     foreach ($this->fetchedVersion as $id => $no) {
         if (!array_key_exists($id, $otherFetchedVersion)) {
             return true;
         } elseif ($no == $otherFetchedVersion[$id]) {
             continue;
         } elseif ($no > $otherFetchedVersion[$id]) {
             return true;
         } else {
             return false;
         }
     }
     return false;
 }
Example #15
0
 /**
  * Create Note and Version instances
  *
  * $created_at and $updated_at values we have from parsed xml
  *
  * @param $title
  * @param $content
  * @param $created_at
  * @param $updated_at
  * @return \Note
  */
 protected function createNote($title, $content, $created_at, $updated_at)
 {
     $noteCreate = new \Note();
     $noteCreate->created_at = $created_at;
     $noteCreate->updated_at = $updated_at;
     // Add spaces for strip_tags
     $contentPreview = preg_replace('/(<[^>]+>)/', '$1 ', $content);
     $contentPreview = strip_tags($contentPreview);
     $versionCreate = new \Version(['title' => $title, 'content' => $content, 'content_preview' => mb_substr($contentPreview, 0, 255), 'created_at' => $created_at, 'updated_at' => $updated_at, 'user_id' => \Auth::user()->id]);
     $versionCreate->save();
     $noteCreate->version()->associate($versionCreate);
     $noteCreate->notebook_id = $this->notebook->id;
     $noteCreate->save();
     $noteCreate->users()->attach(\Auth::user()->id, array('umask' => \PaperworkHelpers::UMASK_OWNER));
     return $noteCreate;
 }
 private static function _open()
 {
     $res = '<StampMaster>';
     $res .= '<version>' . Version::getVersion() . '</version>';
     $res .= '</StampMaster>';
     return $res;
 }
Example #17
0
 function test_requires_upgrade()
 {
     Options::set('db_version', Version::DB_VERSION - 1);
     $this->assert_equal(true, Version::requires_upgrade());
     Options::set('db_version', Version::DB_VERSION);
     $this->assert_equal(false, Version::requires_upgrade());
 }
 /**
  * @return Version
  */
 public function getVersion()
 {
     if (false === isset(self::$m_versions[$this->m_component])) {
         self::$m_versions[$this->m_component] = Version::parse($this->initialized()->version);
     }
     return self::$m_versions[$this->m_component];
 }
 public static function from_upload(array $data, $key_mode = false)
 {
     $create = array();
     $file = $data['file'];
     $user = $data['user'];
     if ($key_mode) {
         $keys = collect(function ($key) {
             return $key->key;
         }, Pki::find('all', array('select' => '`key`', 'conditions' => array('user_id' => $user->id))));
         $sig = $data['sig'];
         if (!static::verify($file, $sig, $keys)) {
             throw new NimbleException('Invalid package signature');
         }
     }
     $package_data = new PackageExtractor($file);
     if ($user->pear_farm_url() !== $package_data->data['channel']) {
         throw new Exception('Package channel ' . $package_data->data['channel'] . ' does not match ' . $user->pear_farm_url());
     }
     $name = $package_data->data['name'];
     $version = $package_data->data['version']['release'];
     $stability = $package_data->data['stability']['release'];
     if (!Package::exists(array('name' => $name, 'user_id' => $user->id))) {
         $package = new Package(array('name' => $name, 'user_id' => $user->id, 'category_id' => Category::find_by_name('Default')->id));
     } else {
         $package = Package::find('first', array('conditions' => array('name' => $name, 'user_id' => $user->id)));
     }
     if (!$package->new_record && Version::exists(array('version' => $version, 'package_id' => $package->id))) {
         throw new NimbleException("There is already a {$version}. You cannot replace existing packages. Please bump the version number and try again." . " You can delete a version from the web interface if needed.");
     }
     $package->move_uploaded_file($file, $version);
     $type = VersionType::find_by_name($stability);
     $package->versions = array(array('raw_xml' => $package_data->get_package_xml(), 'version' => $version, 'meta' => serialize($package_data->data), 'version_type_id' => $type->id, 'summary' => $package_data->data['summary'], 'description' => $package_data->data['description'], 'min_php' => $package_data->data['dependencies']['required']['php']['min']));
     $package->save();
     return $package;
 }
Example #20
0
 public function run()
 {
     $faker = Faker::create();
     foreach (range(1, 10) as $index) {
         Version::create([]);
     }
 }
 public function indexAction()
 {
     $panel = Bootstrap::panel('Search for crash reports')->color('blue');
     $form = Bootstrap::form(Url::href('reports', 'search'))->horizontal()->method('get')->add(BootstrapUI::select2('package_id', 'package', Package::getSelectOptions(true)))->add(BootstrapUI::select2('brand_id', 'brand', Brand::getSelectOptions(true)))->add(BootstrapUI::select2('os_version_id', 'OS and version', Version::getSelectOptions(true)))->add(BootstrapUI::select2('country_id', 'country', Country::getSelectOptions(true)))->add(Bootstrap::textfield('date_from', null, 'date and time from')->type('datetime-local'))->add(Bootstrap::textfield('date_to', null, 'date and time to')->type('datetime-local'))->addSubmit('Search');
     $panel->content($form);
     return View::create('base')->with('title', 'Search for reports')->with('content', Bootstrap::row()->add(12, $panel));
 }
Example #22
0
	/**
	 * Returns all theme information -- dir, path, theme.xml, screenshot url
	 * @return array An array of Theme data
	 **/
	public static function get_all_data()
	{
		if ( !isset( self::$all_data ) ) {
			foreach ( self::get_all() as $theme_dir => $theme_path ) {
				$themedata = array();
				$themedata['dir'] = $theme_dir;
				$themedata['path'] = $theme_path;
				$themedata['theme_dir'] = $theme_path;

				$themedata['info'] = simplexml_load_file( $theme_path . '/theme.xml' );
				if ( $themedata['info']->getName() != 'pluggable' || (string) $themedata['info']->attributes()->type != 'theme' ) {
					$themedata['screenshot'] = Site::get_url( 'admin_theme' ) . "/images/screenshot_default.png";
					$themedata['info']->description = '<span class="error">' . _t( 'This theme is a legacy theme that is not compatible with Habari ' ) . Version::get_habariversion() . '. <br><br>Please update your theme.</span>';
					$themedata['info']->license = '';
				}
				else {
					foreach ( $themedata['info'] as $name=>$value ) {
						$themedata[$name] = (string) $value;
					}

					if ( $screenshot = Utils::glob( $theme_path . '/screenshot.{png,jpg,gif}', GLOB_BRACE ) ) {
						$themedata['screenshot'] = Site::get_url( 'habari' ) . dirname( str_replace( HABARI_PATH, '', $theme_path ) ) . '/' . basename( $theme_path ) . "/" . basename( reset( $screenshot ) );
					}
					else {
						$themedata['screenshot'] = Site::get_url( 'admin_theme' ) . "/images/screenshot_default.png";
					}
				}
				
				self::$all_data[$theme_dir] = $themedata;
			}
		}
		return self::$all_data;
	}
Example #23
0
 /**
  * Pre-installation.
  * @return boolean
  */
 function preInstall()
 {
     $this->currentVersion = Version::fromString('');
     $this->locale = $this->getParam('locale');
     $this->installedLocales = $this->getParam('additionalLocales');
     if (!isset($this->installedLocales) || !is_array($this->installedLocales)) {
         $this->installedLocales = array();
     }
     if (!in_array($this->locale, $this->installedLocales) && Locale::isLocaleValid($this->locale)) {
         array_push($this->installedLocales, $this->locale);
     }
     if ($this->getParam('manualInstall')) {
         // Do not perform database installation for manual install
         // Create connection object with the appropriate database driver for adodb-xmlschema
         $conn =& new DBConnection($this->getParam('databaseDriver'), null, null, null, null);
         $this->dbconn =& $conn->getDBConn();
     } else {
         // Connect to database
         $conn =& new DBConnection($this->getParam('databaseDriver'), $this->getParam('databaseHost'), $this->getParam('databaseUsername'), $this->getParam('databasePassword'), $this->getParam('createDatabase') ? null : $this->getParam('databaseName'), true, $this->getParam('connectionCharset') == '' ? false : $this->getParam('connectionCharset'));
         $this->dbconn =& $conn->getDBConn();
         if (!$conn->isConnected()) {
             $this->setError(INSTALLER_ERROR_DB, $this->dbconn->errorMsg());
             return false;
         }
     }
     DBConnection::getInstance($conn);
     return parent::preInstall();
 }
Example #24
0
 /**
  * @param string $url URL to request
  * @param string $method Request method to use (default 'GET')
  * @param int $timeout
  * @internal param int $timeuot Timeout in seconds (default 180)
  */
 public function __construct($url, $method = 'GET', $timeout = 180)
 {
     $this->method = strtoupper($method);
     $this->url = $url;
     $this->set_timeout($timeout);
     // load the proxy configuration, if it exists
     $default = new \stdClass();
     $proxy = Config::get('proxy', $default);
     if (isset($proxy->server)) {
         $this->set_config(array('proxy' => (array) $proxy));
     }
     // populate the default proxy exceptions list, since we can't up there
     $this->config['proxy']['exceptions'] = array_merge($this->config['proxy']['exceptions'], array('localhost', '127.0.0.1', '::1'));
     // these next two could be duplicates of 'localhost' and 127.0.0.1 / ::1 if you're on localhost - that's ok
     if (isset($_SERVER['SERVER_NAME'])) {
         $this->config['proxy']['exceptions'][] = $_SERVER['SERVER_NAME'];
     }
     if (isset($_SERVER['SERVER_ADDR'])) {
         $this->config['proxy']['exceptions'][] = $_SERVER['SERVER_ADDR'];
     }
     $this->user_agent .= '/' . Version::get_habariversion();
     $this->add_header(array('User-Agent' => $this->user_agent));
     // if they've manually specified that we should not use curl, use sockets instead
     if (Config::get('remote_request_processor') == 'socket') {
         $this->processor = new SocketRequestProcessor();
     } else {
         // otherwise, see if we can use curl and fall back to sockets if not
         if (function_exists('curl_init') && !(ini_get('safe_mode') || ini_get('open_basedir'))) {
             $this->processor = new CURLRequestProcessor();
         } else {
             $this->processor = new SocketRequestProcessor();
         }
     }
 }
 function _detectProjectId()
 {
     $project_id = null;
     if (isset($this->controller->params['project_id'])) {
         $project_id = $this->controller->params['project_id'];
     }
     if ($this->controller->name == 'Versions') {
         $version_id = $this->controller->params['pass'][0];
         App::uses('Version', 'Model');
         $version = new Version();
         $bind = array('belongsTo' => array('Project' => array('className' => 'Project')));
         $version->bindModel($bind);
         $version_row = $version->find('first', array('condtions' => array('id' => $version_id)));
         $project_id = $version_row['Project']['identifier'];
     }
     return $project_id;
 }
Example #26
0
 /**
  * Get latest available version, using $force always returns a version no matter if it is the same as the published one
  * @param bool $force
  * @return array
  */
 public function getLatestVersion($force = false)
 {
     $versionData = $this->db->fetchRow("SELECT id,date FROM versions WHERE cid = ? AND ctype='document' ORDER BY `id` DESC LIMIT 1", $this->model->getId());
     if ($versionData["id"] && $versionData["date"] > $this->model->getModificationDate() || $force) {
         $version = Version::getById($versionData["id"]);
         return $version;
     }
     return;
 }
 /**
  * Alias::config()
  * set or get config
  * setting config will reset instance to FALSE
  * 
  * @param bool $config
  * @return array / void
  */
 public static function config($config = FALSE)
 {
     if ($config === FALSE) {
         return self::$_config;
     } else {
         self::$_config = $config;
         self::$_instance = FALSE;
     }
 }
Example #28
0
 /**
  * @dataProvider provideLessThanCases
  */
 function testLessThanCases($aArray, $bArray)
 {
     $a = $this->makeVersion($aArray);
     $b = $this->makeVersion($bArray);
     $actual = Version::compare($a, $b);
     $this->assertLessThan(0, $actual);
     $actual = Version::compare($b, $a);
     $this->assertGreaterThan(0, $actual);
 }
Example #29
0
 /**
  * System Exception Handler
  *
  * @param \Exception $exception The exception to handle
  *
  * @return void
  */
 public function handleException(\Exception $exception)
 {
     fwrite(STDERR, "\n\nOups... phpDox encountered a problem and has terminated!\n");
     fwrite(STDERR, "\nIt most likely means you've found a bug, so please file a report for this\n");
     fwrite(STDERR, "and paste the following details and the stacktrace (if given) along:\n\n");
     fwrite(STDERR, "PHP Version: " . PHP_VERSION . " (" . PHP_OS . ")\n");
     fwrite(STDERR, "PHPDox Version: " . $this->version->getVersion() . "\n");
     $this->renderException($exception);
     fwrite(STDERR, "\n\n\n");
 }
Example #30
0
 public function run()
 {
     $faker = Faker::create();
     $plugins = Plugin::all();
     foreach ($plugins as $plugin) {
         foreach (range(1, rand(2, 10)) as $index) {
             Version::create(['name' => $faker->randomFloat(2, 0, 9), 'risk' => rand(0, 3), 'plugin_id' => $plugin->id]);
         }
     }
 }