Exemplo n.º 1
0
 public function __construct(array $fields, $subs = null, $callback = null)
 {
     $this->fields = $fields;
     $this->subs = $subs;
     $this->callback = $callback;
     $this->schema = Schema::get($this->className());
 }
Exemplo n.º 2
0
 function onCheckSchema()
 {
     $schema = Schema::get();
     $schema->ensureTable('grades', Grades::schemaDef());
     $schema->ensureTable('grades_group', Gradesgroup::schemaDef());
     return true;
 }
Exemplo n.º 3
0
 /**
  * Database schema setup
  *
  * @see Schema
  * @see ColumnDef
  *
  * @return boolean hook value; true means continue processing, false means stop.
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing user-submitted flags on profiles
     $schema->ensureTable('bookmark', array(new ColumnDef('id', 'char', 36, false, 'PRI'), new ColumnDef('profile_id', 'integer', null, false, 'MUL'), new ColumnDef('url', 'varchar', 255, false, 'MUL'), new ColumnDef('title', 'varchar', 255), new ColumnDef('description', 'text'), new ColumnDef('uri', 'varchar', 255, false, 'UNI'), new ColumnDef('created', 'datetime', null, false, 'MUL')));
     return true;
 }
 /**
  * Hook for ensuring our tables are created
  *
  * Ensures the fave_tally table is there and has the right columns
  *
  * @return boolean hook return
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing total number of times a notice has been faved
     $schema->ensureTable('fave_tally', Fave_tally::schemaDef());
     return true;
 }
 /**
  * Database schema setup
  *
  * @see Schema
  * @see ColumnDef
  *
  * @return boolean hook value; true means continue processing, false means stop.
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     $schema->ensureTable('spam_score', Spam_score::schemaDef());
     Spam_score::upgrade();
     return true;
 }
Exemplo n.º 6
0
 function onCheckSchema()
 {
     $schema = Schema::get();
     $schema->ensureTable('task', Task::schemaDef());
     $schema->ensureTable('task_grader', Task_Grader::schemaDef());
     return true;
 }
Exemplo n.º 7
0
 public static function beforeSchemaUpdate()
 {
     $table = strtolower(get_called_class());
     $schema = Schema::get();
     $schemadef = $schema->getTableDef($table);
     // 2015-12-31 RSVPs refer to Happening by event_uri now, not event_id. Let's migrate!
     if (isset($schemadef['fields']['event_uri'])) {
         // We seem to have already migrated, good!
         return;
     }
     // this is a "normal" upgrade from StatusNet for example
     echo "\nFound old {$table} table, upgrading it to add 'event_uri' field...";
     $schemadef['fields']['event_uri'] = array('type' => 'varchar', 'length' => 191, 'not null' => true, 'description' => 'Event URI');
     $schema->ensureTable($table, $schemadef);
     $rsvp = new RSVP();
     $rsvp->find();
     while ($rsvp->fetch()) {
         $event = Happening::getKV('id', $rsvp->event_id);
         if (!$event instanceof Happening) {
             $rsvp->delete();
             continue;
         }
         $orig = clone $rsvp;
         $rsvp->event_uri = $event->uri;
         $rsvp->updateWithKeys($orig);
     }
     print "DONE.\n";
     print "Resuming core schema upgrade...";
 }
 /**
  * Database schema setup
  *
  * We store user registrations in a table registration_ip.
  *
  * @return boolean hook value; true means continue processing, false means stop.
  */
 public function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing user-submitted flags on profiles
     $schema->ensureTable('registration_ip', Registration_ip::schemaDef());
     return true;
 }
Exemplo n.º 9
0
 /**
  * Set up our tables (event and rsvp)
  *
  * @see Schema
  * @see ColumnDef
  *
  * @return boolean hook value; true means continue processing, false means stop.
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     $schema->ensureTable('happening', Happening::schemaDef());
     $schema->ensureTable('rsvp', RSVP::schemaDef());
     return true;
 }
Exemplo n.º 10
0
 /**
  * Hook for ensuring our tables are created
  *
  * Ensures that the user_flag_profile table exists
  * and has the right columns.
  *
  * @return boolean hook return
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing user-submitted flags on profiles
     $schema->ensureTable('user_flag_profile', array(new ColumnDef('profile_id', 'integer', null, false, 'PRI'), new ColumnDef('user_id', 'integer', null, false, 'PRI'), new ColumnDef('created', 'datetime', null, false, 'MUL'), new ColumnDef('cleared', 'datetime', null, true, 'MUL')));
     return true;
 }
Exemplo n.º 11
0
 /**
  * Database schema setup
  *
  * @return boolean hook value
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing user-submitted flags on profiles
     $schema->ensureTable('email_summary_status', Email_summary_status::schemaDef());
     return true;
 }
Exemplo n.º 12
0
 /**
  * Hook for ensuring our tables are created
  *
  * Ensures the fave_tally table is there and has the right columns
  *
  * @return boolean hook return
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing total number of times a notice has been faved
     $schema->ensureTable('fave_tally', array(new ColumnDef('notice_id', 'integer', null, false, 'PRI'), new ColumnDef('count', 'integer', null, false), new ColumnDef('modified', 'timestamp', null, false, null, 'CURRENT_TIMESTAMP', 'on update CURRENT_TIMESTAMP')));
     return true;
 }
Exemplo n.º 13
0
 /**
  * Database schema setup
  *
  * @return boolean hook value
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing user-submitted flags on profiles
     $schema->ensureTable('email_summary_status', array(new ColumnDef('user_id', 'integer', null, false, 'PRI'), new ColumnDef('send_summary', 'tinyint', null, false, null, 1), new ColumnDef('last_summary_id', 'integer', null, true), new ColumnDef('created', 'datetime', null, false), new ColumnDef('modified', 'datetime', null, false)));
     return true;
 }
Exemplo n.º 14
0
 /**
  * Database schema setup
  *
  * @see Schema
  * @see ColumnDef
  *
  * @return boolean hook value; true means continue processing, false means stop.
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     $schema->ensureTable('poll', Poll::schemaDef());
     $schema->ensureTable('poll_response', Poll_response::schemaDef());
     return true;
 }
 /**
  * Database schema setup
  *
  * We store user registrations in a table registration_ip.
  *
  * @return boolean hook value; true means continue processing, false means stop.
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing user-submitted flags on profiles
     $schema->ensureTable('registration_ip', array(new ColumnDef('user_id', 'integer', null, false, 'PRI'), new ColumnDef('ipaddress', 'varchar', 15, false, 'MUL'), new ColumnDef('created', 'timestamp', null, false, 'MUL')));
     return true;
 }
Exemplo n.º 16
0
 /**
  * Database schema setup
  *
  * Add the notice_title helper table
  *
  * @see Schema
  * @see ColumnDef
  *
  * @return boolean hook value; true means continue processing, false means stop.
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing titles for notices
     $schema->ensureTable('notice_title', Notice_title::schemaDef());
     return true;
 }
Exemplo n.º 17
0
 /**
  * Hook for ensuring our tables are created
  *
  * Ensures that the user_flag_profile table exists
  * and has the right columns.
  *
  * @return boolean hook return
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing user-submitted flags on profiles
     $schema->ensureTable('user_flag_profile', User_flag_profile::schemaDef());
     return true;
 }
Exemplo n.º 18
0
 /**
  * Database schema setup
  *
  * Add the notice_title helper table
  *
  * @see Schema
  * @see ColumnDef
  *
  * @return boolean hook value; true means continue processing, false means stop.
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing titles for notices
     $schema->ensureTable('notice_title', array(new ColumnDef('notice_id', 'integer', null, true, 'PRI'), new ColumnDef('title', 'varchar', Notice_title::MAXCHARS, false)));
     return true;
 }
Exemplo n.º 19
0
 /**
  * Database schema setup
  *
  * @return boolean hook value
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing blacklist patterns for nicknames
     $schema->ensureTable('nickname_blacklist', Nickname_blacklist::schemaDef());
     $schema->ensureTable('homepage_blacklist', Homepage_blacklist::schemaDef());
     return true;
 }
Exemplo n.º 20
0
 /**
  * Database schema setup
  *
  * @return boolean hook value
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing blacklist patterns for nicknames
     $schema->ensureTable('nickname_blacklist', array(new ColumnDef('pattern', 'varchar', 255, false, 'PRI'), new ColumnDef('created', 'datetime', null, false)));
     $schema->ensureTable('homepage_blacklist', array(new ColumnDef('pattern', 'varchar', 255, false, 'PRI'), new ColumnDef('created', 'datetime', null, false)));
     return true;
 }
Exemplo n.º 21
0
 /**
  * Set up our tables (question and answer)
  *
  * @see Schema
  * @see ColumnDef
  *
  * @return boolean hook value; true means continue processing, false means stop.
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     $schema->ensureTable('qna_question', QnA_Question::schemaDef());
     $schema->ensureTable('qna_answer', QnA_Answer::schemaDef());
     $schema->ensureTable('qna_vote', QnA_Vote::schemaDef());
     return true;
 }
Exemplo n.º 22
0
 function onCheckSchema()
 {
     $schema = Schema::get();
     $schema->ensureTable('submirror', SubMirror::schemaDef());
     // @hack until key definition support is merged
     SubMirror::fixIndexes($schema);
     return true;
 }
 function onCheckSchema()
 {
     $schema = Schema::get();
     $schema->ensureTable('profile_detail', Profile_detail::schemaDef());
     // @hack until key definition support is merged
     Profile_detail::fixIndexes($schema);
     return true;
 }
 /**
  * Database schema setup
  *
  * @see Schema
  * @see ColumnDef
  *
  * @return boolean hook value
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing user-submitted flags on profiles
     $schema->ensureTable('group_privacy_settings', Group_privacy_settings::schemaDef());
     $schema->ensureTable('group_message', Group_message::schemaDef());
     $schema->ensureTable('group_message_profile', Group_message_profile::schemaDef());
     return true;
 }
 /**
  * Database schema setup
  *
  * @see Schema
  * @see ColumnDef
  *
  * @return boolean hook value
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     // For storing user-submitted flags on profiles
     $schema->ensureTable('group_privacy_settings', array(new ColumnDef('group_id', 'integer', null, false, 'PRI'), new ColumnDef('allow_privacy', 'integer'), new ColumnDef('allow_sender', 'integer'), new ColumnDef('created', 'datetime'), new ColumnDef('modified', 'timestamp')));
     $schema->ensureTable('group_message', array(new ColumnDef('id', 'char', 36, false, 'PRI'), new ColumnDef('uri', 'varchar', 255, false, 'UNI'), new ColumnDef('from_profile', 'integer', null, false, 'MUL'), new ColumnDef('to_group', 'integer', null, false, 'MUL'), new ColumnDef('content', 'text'), new ColumnDef('rendered', 'text'), new ColumnDef('url', 'varchar', 255, false, 'UNI'), new ColumnDef('created', 'datetime')));
     $schema->ensureTable('group_message_profile', array(new ColumnDef('to_profile', 'integer', null, false, 'PRI'), new ColumnDef('group_message_id', 'char', 36, false, 'PRI'), new ColumnDef('created', 'datetime')));
     return true;
 }
Exemplo n.º 26
0
 /**
  * Set up all our tables...
  */
 function onCheckSchema()
 {
     $schema = Schema::get();
     $tables = array('Yammer_state', 'Yammer_user', 'Yammer_group', 'Yammer_notice', 'Yammer_notice_stub');
     foreach ($tables as $table) {
         $schemaDef = call_user_func(array($table, 'schemaDef'));
         $schema->ensureTable(strtolower($table), $schemaDef);
     }
     return true;
 }
Exemplo n.º 27
0
function updateSchemaCore()
{
    printfnq("Upgrading core schema...");
    $schema = Schema::get();
    $schemaUpdater = new SchemaUpdater($schema);
    foreach (tableDefs() as $table => $def) {
        $schemaUpdater->register($table, $def);
    }
    $schemaUpdater->checkSchema();
    printfnq("DONE.\n");
}
Exemplo n.º 28
0
 public function __call($name, $arguments)
 {
     $value = $this->formatLabel(substr($name, 3, strlen($name)));
     $name = strtolower(substr($name, 0, 3));
     if (ORMConfig::get('strict', 'orm')) {
         if (!is_array(Schema::get(ORMConfig::get('schema', 'orm'), $this->sDomain, $value))) {
             throw new Exception($value . ' was not found in schema');
         }
     }
     if ($name == 'set') {
         return $this->set($value, $arguments);
     } elseif ($name == 'get') {
         return $this->get($value, $arguments);
     } elseif ($name == 'add') {
         return $this->add($value, $arguments);
     } else {
         throw new Exception('Method does not exist');
     }
 }
Exemplo n.º 29
0
 public static function beforeSchemaUpdate()
 {
     $table = strtolower(get_called_class());
     $schema = Schema::get();
     $schemadef = $schema->getTableDef($table);
     // 2016-01-06 We have to make sure there is no conversation with id==0 since it will screw up auto increment resequencing
     if ($schemadef['fields']['id']['auto_increment']) {
         // since we already have auto incrementing ('serial') we can continue
         return;
     }
     // The conversation will be recreated in upgrade.php, which will
     // generate a new URI, but that's collateral damage for you.
     $conv = new Conversation();
     $conv->id = 0;
     if ($conv->find()) {
         while ($conv->fetch()) {
             // Since we have filtered on 0 this only deletes such entries
             // which I have been afraid wouldn't work, but apparently does!
             // (I thought it would act as null or something and find _all_ conversation entries)
             $conv->delete();
         }
     }
 }
Exemplo n.º 30
0
 public function onStartUpgrade()
 {
     // This is a migration feature that will make sure we move
     // certain User preferences to the Profile_prefs table.
     // Introduced after commit b5fd2a048fc621ea05d756caba17275ab3dd0af4
     // on Sun Jul 13 16:30:37 2014 +0200
     $user = new User();
     $user->whereAdd('emailnotifyfav IS NOT NULL');
     if ($user->find()) {
         printfnq("Detected old User table (emailnotifyfav IS NOT NULL). Moving 'emailnotifyfav' property to Profile_prefs...");
         // First we'll make sure Profile_prefs exists
         $schema = Schema::get();
         $schema->ensureTable('profile_prefs', Profile_prefs::schemaDef());
         // Make sure we have our own tables setup properly
         while ($user->fetch()) {
             $user->setPref('email', 'notify_fave', $user->emailnotifyfav);
             $orig = clone $user;
             $user->emailnotifyfav = 'null';
             // flag this preference as migrated
             $user->update($orig);
         }
         printfnq("DONE.\n");
     }
 }