public static function setUpBeforeClass()
 {
     if (defined('SKIPPING')) {
         return;
     }
     $db = new fDatabase(DB_TYPE, DB, DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT);
     if (DB_TYPE == 'sqlite') {
         $db->execute(file_get_contents(DB_SETUP_FILE));
         $db->execute(file_get_contents(DB_EXTENDED_SETUP_FILE));
     }
     $db->execute(file_get_contents(DB_POPULATE_FILE));
     $db->execute(file_get_contents(DB_EXTENDED_POPULATE_FILE));
     self::$db = $db;
     self::$schema = new fSchema($db);
     fORMDatabase::attach(self::$db);
     fORMSchema::attach(self::$schema);
     fORMOrdering::configureOrderingColumn('TopAlbum', 'position');
     fORMOrdering::configureOrderingColumn('FavoriteAlbum', 'position');
     fORMOrdering::configureOrderingColumn('YearFavoriteAlbum', 'position');
     if (defined('MAP_TABLES')) {
         fORM::mapClassToTable('User', 'user');
         fORM::mapClassToTable('Group', 'group');
         fORM::mapClassToTable('Artist', 'popular_artists');
         fORM::mapClassToTable('Album', 'records');
     }
 }
 public function setUp()
 {
     if (defined('SKIPPING')) {
         $this->markTestSkipped();
     }
     if (defined('MAP_TABLES')) {
         fORM::mapClassToTable('User', 'user');
         fORM::mapClassToTable('Group', 'group');
         fORM::mapClassToTable('Artist', 'popular_artists');
         fORM::mapClassToTable('Album', 'records');
     }
 }
Exemplo n.º 3
0
 public function setUp()
 {
     if (defined('SKIPPING')) {
         $this->markTestSkipped();
     }
     fORMDatabase::attach(self::$db);
     fORMSchema::attach(self::$schema);
     if (defined('MAP_TABLES')) {
         fORM::mapClassToTable('User', 'user');
         fORM::mapClassToTable('Group', 'group');
         fORM::mapClassToTable('Artist', 'popular_artists');
         fORM::mapClassToTable('Album', 'records');
     }
 }
 public function setUp()
 {
     if (defined('SKIPPING')) {
         $this->markTestSkipped();
     }
     fORMDatabase::attach(self::$db);
     fORMDatabase::attach(self::$db2, 'db2');
     fORMSchema::attach(self::$schema);
     fORMSchema::attach(self::$schema2, 'db2');
     fORM::mapClassToTable('Db2User', 'users');
     fORM::mapClassToDatabase('Db2User', 'db2');
     fORM::mapClassToTable('Db2Group', 'groups');
     fORM::mapClassToDatabase('Db2Group', 'db2');
 }
 public function setUp()
 {
     if (defined('SKIPPING')) {
         $this->markTestSkipped();
     }
     fORMDatabase::attach($this->sharedFixture['db']);
     fORMDatabase::attach($this->sharedFixture['db2'], 'db2');
     fORMSchema::attach($this->sharedFixture['schema']);
     fORMSchema::attach($this->sharedFixture['schema2'], 'db2');
     fORM::mapClassToTable('Db2User', 'users');
     fORM::mapClassToDatabase('Db2User', 'db2');
     fORM::mapClassToTable('Db2Group', 'groups');
     fORM::mapClassToDatabase('Db2Group', 'db2');
 }
Exemplo n.º 6
0
 public function testCustomClassTableMapping()
 {
     $this->assertEquals('users', fORM::tablize('User'));
     $this->assertEquals('User', fORM::classize('users'));
     fORM::mapClassToTable('User', 'person');
     $this->assertEquals('person', fORM::tablize('User'));
     $this->assertEquals('User', fORM::classize('person'));
     $this->assertNotEquals('users', fORM::tablize('User'));
     $this->assertEquals('bicycles', fORM::tablize('Bicycle'));
     $this->assertEquals('Bicycle', fORM::classize('bicycles'));
     fORM::mapClassToTable('Bicycle', 'bike');
     $this->assertEquals('bike', fORM::tablize('Bicycle'));
     $this->assertEquals('Bicycle', fORM::classize('bike'));
     $this->assertNotEquals('bicycles', fORM::tablize('Bicycle'));
 }
 protected function setUp()
 {
     if (defined('SKIPPING')) {
         return;
     }
     $db = new fDatabase(DB_TYPE, DB, DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT);
     $db->execute(file_get_contents(DB_SETUP_FILE));
     $db->execute(file_get_contents(DB_EXTENDED_SETUP_FILE));
     $db->execute(fix_schema(file_get_contents(DB_ALTERNATE_SCHEMA_SETUP_FILE)));
     $db->clearCache();
     fORMDatabase::attach($db);
     $this->sharedFixture = $db;
     fORM::mapClassToTable('Flourish2User', fix_schema('flourish2.users'));
     fORM::mapClassToTable('Flourish2Group', fix_schema('flourish2.groups'));
     fORM::mapClassToTable('Flourish2Artist', fix_schema('flourish2.artists'));
     fORM::mapClassToTable('Flourish2Album', fix_schema('flourish2.albums'));
 }
 protected function setUp()
 {
     if (defined('SKIPPING')) {
         return;
     }
     $db = new fDatabase(DB_TYPE, DB, DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT);
     $db->execute(file_get_contents(DB_SETUP_FILE));
     $db2 = new fDatabase(DB_TYPE, DB_2, DB_2_USERNAME, DB_2_PASSWORD, DB_2_HOST, DB_2_PORT);
     $db2->execute(file_get_contents(DB_2_SETUP_FILE));
     $this->sharedFixture = array($db, $db2);
     fORMDatabase::attach($db);
     fORMDatabase::attach($db2, 'db2');
     fORM::mapClassToTable('Db2User', 'users');
     fORM::mapClassToDatabase('Db2User', 'db2');
     fORM::mapClassToTable('Db2Group', 'groups');
     fORM::mapClassToDatabase('Db2Group', 'db2');
 }
 public static function setUpBeforeClass()
 {
     if (defined('SKIPPING')) {
         return;
     }
     $db = new fDatabase(DB_TYPE, DB, DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT);
     $db->execute(file_get_contents(DB_SETUP_FILE));
     $db2 = new fDatabase(DB_TYPE, DB_2, DB_2_USERNAME, DB_2_PASSWORD, DB_2_HOST, DB_2_PORT);
     $db2->execute(file_get_contents(DB_2_SETUP_FILE));
     self::$db = $db;
     self::$db2 = $db2;
     fORMDatabase::attach($db);
     fORMDatabase::attach($db2, 'db2');
     fORM::mapClassToTable('Db2User', 'users');
     fORM::mapClassToDatabase('Db2User', 'db2');
     fORM::mapClassToTable('Db2Group', 'groups');
     fORM::mapClassToDatabase('Db2Group', 'db2');
 }
Exemplo n.º 10
0
 public function setUp()
 {
     if (defined('SKIPPING')) {
         $this->markTestSkipped();
     }
     $db = $this->sharedFixture['db'];
     $db->execute(file_get_contents(DB_EXTENDED_SETUP_FILE));
     $db->clearCache();
     fORMDatabase::attach($db);
     fORMSchema::attach($this->sharedFixture['schema']);
     fORMOrdering::configureOrderingColumn('TopAlbum', 'position');
     fORMOrdering::configureOrderingColumn('FavoriteAlbum', 'position');
     fORMOrdering::configureOrderingColumn('YearFavoriteAlbum', 'position');
     if (defined('MAP_TABLES')) {
         fORM::mapClassToTable('User', 'user');
         fORM::mapClassToTable('Group', 'group');
         fORM::mapClassToTable('Artist', 'popular_artists');
         fORM::mapClassToTable('Album', 'records');
     }
 }
 public static function setUpBeforeClass()
 {
     if (defined('SKIPPING')) {
         return;
     }
     $db = new fDatabase(DB_TYPE, DB, DB_USERNAME, DB_PASSWORD, DB_HOST, DB_PORT);
     if (DB_TYPE == 'sqlite') {
         $db->execute(file_get_contents(DB_SETUP_FILE));
         $db->execute(file_get_contents(DB_EXTENDED_SETUP_FILE));
         $db->execute(fix_schema(file_get_contents(DB_ALTERNATE_SCHEMA_SETUP_FILE)));
     }
     $db->execute(file_get_contents(DB_POPULATE_FILE));
     $db->execute(file_get_contents(DB_EXTENDED_POPULATE_FILE));
     $db->execute(fix_schema(file_get_contents(DB_ALTERNATE_SCHEMA_POPULATE_FILE)));
     $db->clearCache();
     fORMDatabase::attach($db);
     self::$db = $db;
     fORM::mapClassToTable('Flourish2User', fix_schema('flourish2.users'));
     fORM::mapClassToTable('Flourish2Group', fix_schema('flourish2.groups'));
     fORM::mapClassToTable('Flourish2Artist', fix_schema('flourish2.artists'));
     fORM::mapClassToTable('Flourish2Album', fix_schema('flourish2.albums'));
 }
Exemplo n.º 12
0
 public function setUp()
 {
     if (defined('SKIPPING')) {
         $this->markTestSkipped();
     }
     fORMDatabase::attach($this->sharedFixture['db']);
     fORMSchema::attach($this->sharedFixture['schema']);
     if (defined('MAP_TABLES')) {
         fORM::mapClassToTable('User', 'user');
         fORM::mapClassToTable('Group', 'group');
         fORM::mapClassToTable('Artist', 'popular_artists');
         fORM::mapClassToTable('Album', 'records');
     }
     fORM::registerActiveRecordMethod('User', 'hasChanged', 'changed');
 }
Exemplo n.º 13
0
 protected function setupORM()
 {
     if ($this->isOrmSettedUp) {
         return;
     }
     $this->defineConstants();
     // Extract port from host. See wpdb::db_connect
     $port = null;
     $host = $this->wp->getDbHost();
     if (preg_match('/^(.+):(\\d+)$/', trim($host), $m)) {
         $host = $m[1];
         $port = $m[2];
     }
     $database = new fDatabase('mysql', $this->wp->getDbName(), $this->wp->getDbUser(), $this->wp->getDbPassword(), $host, $port);
     // $database->enableDebugging(true);
     fORMDatabase::attach($database);
     fORM::mapClassToTable('WpTesting_Model_Test', WP_DB_PREFIX . 'posts');
     fORM::mapClassToTable('WpTesting_Model_Question', WPT_DB_PREFIX . 'questions');
     fORM::mapClassToTable('WpTesting_Model_Taxonomy', WP_DB_PREFIX . 'term_taxonomy');
     fORM::mapClassToTable('WpTesting_Model_GlobalAnswer', WP_DB_PREFIX . 'terms');
     fORM::mapClassToTable('WpTesting_Model_Answer', WPT_DB_PREFIX . 'answers');
     fORM::mapClassToTable('WpTesting_Model_Scale', WP_DB_PREFIX . 'terms');
     fORM::mapClassToTable('WpTesting_Model_Score', WPT_DB_PREFIX . 'scores');
     fORM::mapClassToTable('WpTesting_Model_Passing', WPT_DB_PREFIX . 'passings');
     fORM::mapClassToTable('WpTesting_Model_Result', WP_DB_PREFIX . 'terms');
     fORM::mapClassToTable('WpTesting_Model_Formula', WPT_DB_PREFIX . 'formulas');
     fORM::mapClassToTable('WpTesting_Model_Respondent', WP_DB_PREFIX . 'users');
     fGrammar::addSingularPluralRule('Taxonomy', 'Taxonomy');
     fGrammar::addSingularPluralRule('Score', 'Score');
     fGrammar::addSingularPluralRule('Answer', 'Answer');
     $schema = fORMSchema::retrieve('name:default');
     $fkOptions = array('on_delete' => 'cascade', 'on_update' => 'cascade');
     $schema->setKeysOverride(array(array('column' => 'test_id', 'foreign_table' => WP_DB_PREFIX . 'posts', 'foreign_column' => 'ID') + $fkOptions), WPT_DB_PREFIX . 'questions', 'foreign');
     $schema->setKeysOverride(array(array('column' => 'answer_id', 'foreign_table' => WPT_DB_PREFIX . 'answers', 'foreign_column' => 'answer_id') + $fkOptions, array('column' => 'scale_id', 'foreign_table' => WP_DB_PREFIX . 'terms', 'foreign_column' => 'term_id') + $fkOptions), WPT_DB_PREFIX . 'scores', 'foreign');
     $schema->setKeysOverride(array(array('column' => 'test_id', 'foreign_table' => WP_DB_PREFIX . 'posts', 'foreign_column' => 'ID') + $fkOptions, array('column' => 'respondent_id', 'foreign_table' => WP_DB_PREFIX . 'users', 'foreign_column' => 'ID') + $fkOptions), WPT_DB_PREFIX . 'passings', 'foreign');
     $schema->setKeysOverride(array(array('column' => 'answer_id', 'foreign_table' => WPT_DB_PREFIX . 'answers', 'foreign_column' => 'answer_id') + $fkOptions, array('column' => 'passing_id', 'foreign_table' => WPT_DB_PREFIX . 'passings', 'foreign_column' => 'passing_id') + $fkOptions), WPT_DB_PREFIX . 'passing_answers', 'foreign');
     $schema->setKeysOverride(array(array('column' => 'test_id', 'foreign_table' => WP_DB_PREFIX . 'posts', 'foreign_column' => 'ID') + $fkOptions, array('column' => 'result_id', 'foreign_table' => WP_DB_PREFIX . 'terms', 'foreign_column' => 'term_id') + $fkOptions), WPT_DB_PREFIX . 'formulas', 'foreign');
     $schema->setColumnInfoOverride(null, WP_DB_PREFIX . 'term_relationships', 'term_order');
     $schema->setKeysOverride(array(array('column' => 'object_id', 'foreign_table' => WP_DB_PREFIX . 'posts', 'foreign_column' => 'ID') + $fkOptions, array('column' => 'term_taxonomy_id', 'foreign_table' => WP_DB_PREFIX . 'term_taxonomy', 'foreign_column' => 'term_taxonomy_id') + $fkOptions), WP_DB_PREFIX . 'term_relationships', 'foreign');
     $schema->setKeysOverride(array(array('column' => 'term_id', 'foreign_table' => WP_DB_PREFIX . 'terms', 'foreign_column' => 'term_id') + $fkOptions), WP_DB_PREFIX . 'term_taxonomy', 'foreign');
     $schema->setKeysOverride(array(array('column' => 'question_id', 'foreign_table' => WPT_DB_PREFIX . 'questions', 'foreign_column' => 'question_id') + $fkOptions, array('column' => 'global_answer_id', 'foreign_table' => WP_DB_PREFIX . 'terms', 'foreign_column' => 'term_id') + $fkOptions), WPT_DB_PREFIX . 'answers', 'foreign');
     $schema->setKeysOverride(array(), WPT_DB_PREFIX . 'sections', 'foreign');
     $schema->setKeysOverride(array(), WPT_DB_PREFIX . 'fields', 'foreign');
     $schema->setKeysOverride(array(), WPT_DB_PREFIX . 'field_values', 'foreign');
     $this->wp->doAction('wp_testing_orm_setup', $schema, $database);
     $this->isOrmSettedUp = true;
 }
Exemplo n.º 14
0
    public static function getByID($id)
    {
        return fRecordSet::build('EventTime', array('pkid=' => $id));
    }
    public static function getRangeVisible($firstDay, $lastDay)
    {
        return fRecordSet::build('EventTime', array('eventdate>=' => $firstDay, 'eventdate<=' => $lastDay, 'calevent{id}.hidden!' => 1, 'eventstatus!' => 'S'), array('eventdate' => 'asc'));
    }
    private function getEvent()
    {
        if ($this->getEventstatus() === 'E') {
            return $this->createEvent('exceptionid');
        }
        return $this->createEvent('id');
    }
    public function getFormattedDate()
    {
        return $this->getEventdate()->format('Y-m-d');
    }
    public function toEventSummaryArray()
    {
        $eventArray = $this->getEvent()->toArray();
        $eventArray['date'] = $this->getFormattedDate();
        $eventArray['caldaily_id'] = $this->getPkid();
        $eventArray['cancelled'] = $this->getEventstatus() == 'C';
        $eventArray['newsflash'] = $this->getNewsflash();
        return $eventArray;
    }
}
fORM::mapClassToTable('EventTime', 'caldaily');
 public function setUp()
 {
     if (defined('SKIPPING')) {
         $this->markTestSkipped();
     }
     fORMDatabase::attach($this->sharedFixture['db']);
     fORMSchema::attach($this->sharedFixture['schema']);
     fORM::mapClassToTable('Flourish2User', fix_schema('flourish2.users'));
     fORM::mapClassToTable('Flourish2Group', fix_schema('flourish2.groups'));
     fORM::mapClassToTable('Flourish2Artist', fix_schema('flourish2.artists'));
     fORM::mapClassToTable('Flourish2Album', fix_schema('flourish2.albums'));
 }
Exemplo n.º 16
0
define('TBL_USER_PERMISSION', 'userpermission');
fORM::mapClassToTable('Banner', 'banner');
fORM::mapClassToTable('BannerSection', 'bannersection');
fORM::mapClassToTable('Section', 'section');
fORM::mapClassToTable('Region', 'region');
fORM::mapClassToTable('Resource', 'resource');
fORM::mapClassToTable('EconomicUnitCategory', 'economic_unit_categories');
fORM::mapClassToTable('EconomicUnit', 'economic_units');
fORM::mapClassToTable('EconomicUnitProduct', 'economic_unit_product');
fORM::mapClassToTable('EconomicUnitHasCategory', 'economic_units_has_economic_unit_categories');
fORM::mapClassToTable('User', TBL_USER);
fORM::mapClassToTable('Role', TBL_ROLE);
fORM::mapClassToTable('Permission', TBL_PERMISSION);
fORM::mapClassToTable('Category', TBL_CATEGORY);
fORM::mapClassToTable('UserPermission', TBL_USER_PERMISSION);
fORM::mapClassToTable('Log', 'log');
/* Public Directories & Files */
define('SITE', 'http:' . DS . DS . $_SERVER['HTTP_HOST'] . DS . 'adminv3' . DS);
define('CSS', SITE . 'css' . DS);
define('JS', SITE . 'js' . DS);
define('SCRIPT', JS . 'script' . DS);
define('HOME', SITE . 'home' . DS);
define('BANNER', SITE . 'banner' . DS);
define('GEOLOCATION', SITE . 'geolocation' . DS);
define('USER', SITE . 'user' . DS);
define('CATEGORIES', SITE . 'categories' . DS);
define('LOGOUT', SITE . 'logout' . DS);
define('LOGIN', SITE . 'login' . DS);
define('IMAGES', SITE . 'images' . DS);
define('ICON', IMAGES . 'icon' . DS);
/* Private Directories & Files */
Exemplo n.º 17
0
        // add all times that exist, maybe none.
        $detailArray["dates"] = $this->getDates();
        // Return the actual dates, not the hacky string
        // return potentially augmented array
        return $detailArray;
    }
    public function secretValid($secret)
    {
        return $this->getPassword() == $secret;
    }
    private function generateSecret()
    {
        $this->setPassword(md5(drupal_random_bytes(32)));
    }
    public function emailSecret()
    {
        global $PROTOCOL, $HOST, $PATH;
        $base = $PROTOCOL . $HOST . $PATH;
        $headers = 'From: bikefun@shift2bikes.org' . "\r\n" . 'Reply-To: bikefun@shift2bikes.org' . "\r\n";
        mail($this->getEmail(), "Shift2Bike Event Secret URL: " . $this->getTitle(), "Hi! To publish and edit the event, please visit {$base}#editEvent/" . $this->getId() . "/" . $this->getPassword(), $headers);
    }
    public function unhide()
    {
        if ($this->getHidden() != 0) {
            $this->setHidden(0);
            $this->store();
        }
    }
}
fORM::mapClassToTable('Event', 'calevent');