/**
  * @return boolean
  */
 protected function _add_dynamic_site_id_option()
 {
     $entity_table_name = 'admin_link';
     $fields = array('add_dynamic_site_id' => array('db_type' => "enum('true','false')"));
     $updater = new FieldToEntityTable($entity_table_name, $fields);
     $result = $updater->update_entity_table();
     $updater->report();
     return $result;
 }
 /**
  * Run the upgrader
  *
  * @return string HTML report
  */
 public function run()
 {
     $entity_table_name = 'form';
     $updater = new FieldToEntityTable($entity_table_name, $this->get_fields_definition());
     if ($updater->field_exists('apply_akismet_filter')) {
         return '<p>This updater has already been run.</p>';
     } else {
         $updater->update_entity_table();
         ob_start();
         $updater->report();
         return ob_get_clean();
     }
 }
 /**
  * Run the upgrader
  *
  * @return string HTML report
  */
 public function run()
 {
     $entity_table_name = 'blog';
     $updater = new FieldToEntityTable($entity_table_name, $this->get_fields_definition());
     if ($updater->field_exists('blog_feed_include_content') && $updater->field_exists('reminder_days') && $updater->field_exists('reminder_emails')) {
         return '<p>This updater has already been run.</p>';
     } else {
         $updater->update_entity_table();
         ob_start();
         $updater->report();
         return ob_get_clean();
     }
 }
 /**
  * Run the upgrader
  *
  * @return string HTML report
  */
 public function run()
 {
     $entity_table_name = 'page_node';
     $fields = array('extra_head_content_structured' => array('db_type' => 'text'));
     $updater = new FieldToEntityTable($entity_table_name, $fields);
     if ($updater->field_exists('extra_head_content_structured')) {
         return '<p>This updater has already been run.</p>';
     } else {
         $updater->update_entity_table();
         ob_start();
         $updater->report();
         return ob_get_clean();
     }
 }
 protected function add_fields($test_mode = false)
 {
     $log = '';
     foreach ($this->new_fields as $field => $db_type) {
         $field_params = array($field => array('db_type' => $db_type));
         $updater = new FieldToEntityTable('page_node', $field_params);
         $updater->test_mode = $test_mode;
         $updater->update_entity_table();
         ob_start();
         $updater->report();
         $log .= ob_get_contents();
         ob_end_clean();
     }
     return $log;
 }
 /**
  * Create the google map type.
  */
 protected function create_google_map_type()
 {
     // make sure the cache is clear
     reason_refresh_relationship_names();
     reason_refresh_unique_names();
     $str = '';
     $google_map_id = reason_create_entity(id_of('master_admin'), id_of('type'), $this->user_id(), 'Google Map', $this->google_map_type_details);
     create_default_rels_for_new_type($google_map_id);
     create_reason_table('google_map', $this->google_map_type_details['unique_name'], $this->user_id());
     $ftet = new FieldToEntityTable('google_map', $this->google_map_table_fields);
     $ftet->update_entity_table();
     ob_start();
     $ftet->report();
     $str .= ob_get_contents();
     ob_end_clean();
     // create all the necessary relationships for the google map type
     create_allowable_relationship(id_of('minisite_page'), id_of('google_map_type'), 'page_to_google_map', $this->page_to_google_map_details);
     create_allowable_relationship(id_of('event_type'), id_of('google_map_type'), 'event_to_google_map', $this->event_to_google_map_details);
     $str .= '<p>Created page_to_google_map and even_to_google_map allowable relationships</p>';
     return $str;
 }
 /**
  * Run the upgrader
  * @return string HTML report
  */
 public function run()
 {
     if ($this->already_run()) {
         return '<p>This script has already run.</p>';
     } else {
         $ret = '';
         if (!$this->site_changes_made()) {
             $updater = new FieldToEntityTable('site', array('theme_customization' => array('db_type' => 'text')));
             $updater->update_entity_table();
             ob_start();
             $updater->report();
             $ret .= ob_get_flush();
         }
         if (!$this->theme_changes_made()) {
             $table_id = create_reason_table('theme', 'theme_type', $this->user_id());
             $updater = new FieldToEntityTable('theme', array('theme_customizer' => array('db_type' => 'tinytext')));
             $updater->update_entity_table();
             ob_start();
             $updater->report();
             $ret .= ob_get_flush();
         }
         return $ret;
     }
 }
 protected function create_course_section_type()
 {
     $str = '';
     $course_section_type_id = reason_create_entity(id_of('master_admin'), id_of('type'), $this->user_id(), 'Course Section', $this->course_section_type_details);
     $str .= '<p>Create course section type entity</p>';
     create_default_rels_for_new_type($course_section_type_id);
     create_reason_table('course_section', $this->course_section_type_details['unique_name'], $this->user_id());
     $ftet = new FieldToEntityTable('course_section', $this->course_section_type_schema);
     $ftet->update_entity_table();
     ob_start();
     $ftet->report();
     $str .= ob_get_contents();
     ob_end_clean();
     //create_relationship( id_of('master_admin'), id_of('social_account_type'), relationship_id_of('site_to_type') );
     return $str;
 }
        $es->add_relation('entity.name IN ("use_custom_footer","custom_footer")');
        $es->add_left_relationship($table->id(), relationship_id_of('field_to_entity_table'));
        $es->set_num(2);
        $fields = $es->run_one();
        $fields_to_create = array('use_custom_footer' => 'enum(\'yes\',\'no\')', 'custom_footer' => 'text');
        foreach ($fields as $field) {
            unset($fields_to_create[$field->get_value('name')]);
        }
        if (empty($fields_to_create)) {
            echo '<p>Fields exist; script has already been run.</p>';
        } else {
            if ($_POST['go'] != 'run') {
                echo '<p>Would have created these fields:</p>';
                pray($fields_to_create);
            } else {
                $update_fields = array();
                foreach ($fields_to_create as $key => $value) {
                    $update_fields[$key] = array('db_type' => $value);
                }
                $updater = new FieldToEntityTable('site', $update_fields);
                $updater->update_entity_table();
                $updater->report();
            }
        }
    }
}
?>
<p><a href="index.php">Return to Index</a></p>
</body>
</html>
 protected function create_publication_social_sharing_field()
 {
     $ftet = new FieldToEntityTable('blog', array('enable_social_sharing' => array('db_type' => "enum('yes','no')")));
     $ftet->update_entity_table();
     ob_start();
     $ftet->report();
     $str = ob_get_contents();
     ob_end_clean();
     return $str;
 }
 /**
  * Creates entity tables if necessary
  */
 function add_field_to_entity_table($table, $field_name, $field_db_type)
 {
     // lets make sure the table exists first
     $es = new entity_selector();
     $es->add_type(id_of('content_table'));
     $es->add_relation('entity.name = "' . $table . '"');
     $results = $es->run_one();
     if ($results) {
         if (in_array($field_name, get_fields_by_content_table($table))) {
             echo '<p>The ' . $table . ' entity table already has the field ' . $field_name . ' - the script has probably been run.</p>';
             return false;
         } else {
             $updater = new FieldToEntityTable($table, array($field_name => array('db_type' => $field_db_type)));
             if ($this->mode == 'test') {
                 $updater->test_mode = true;
             }
             $updater->update_entity_table();
             $updater->report();
         }
     }
 }
Esempio n. 12
0
 $updater2->report();
 $entity_table_name = 'user_group';
 $fields = array('group_has_members' => array('db_type' => "enum('true','false')"));
 $updater3 = new FieldToEntityTable($entity_table_name, $fields);
 $updater3->update_entity_table();
 $updater3->report();
 $entity_table_name = 'blog';
 $fields = array('hold_posts_for_review' => array('db_type' => "enum('yes','no')"), 'publication_type' => array('db_type' => "enum('Blog','Newsletter')"), 'has_issues' => array('db_type' => "enum('yes','no')"), 'has_sections' => array('db_type' => "enum('yes','no')"), 'has_sections' => array('db_type' => "enum('yes','no')"), 'notify_upon_post' => array('db_type' => "tinytext"), 'notify_upon_comment' => array('db_type' => "tinytext"));
 $updater4 = new FieldToEntityTable($entity_table_name, $fields);
 $updater4->update_entity_table();
 $updater4->report();
 $entity_table_name = 'news_section';
 $fields = array('posts_per_section_on_front_page' => array('db_type' => "tinyint DEFAULT 2"));
 $updater5 = new FieldToEntityTable($entity_table_name, $fields);
 $updater5->update_entity_table();
 $updater5->report();
 $blog_type = id_of('blog_type');
 $issue_type = id_of('issue_type');
 $news_type = id_of('news');
 $news_section_type = id_of('news_section_type');
 $text_blurb_type = id_of('text_blurb');
 $image_type = id_of('image');
 // we only report success - error triggering will report failure and reason for failure
 if ($blog_type_exists && create_allowable_relationship($issue_type, $blog_type, 'issue_to_blog', array('connections' => 'one_to_many', 'description' => 'Issue to Publication', 'display_name' => 'Assign this issue to a publication'))) {
     echo '<p>Created issue_to_blog allowable relationship</p>';
 }
 if (create_allowable_relationship($issue_type, $image_type, 'issue_to_image', array('connections' => 'one_to_many', 'description' => 'Issue to Image', 'display_name' => 'Associate an image with this issue'))) {
     echo '<p>Created issue_to_image allowable relationship</p>';
 }
 if (create_allowable_relationship($issue_type, $text_blurb_type, 'issue_to_text_blurb', array('connections' => 'many_to_many', 'description' => 'Issue to Text Blurb', 'display_name' => 'Associate text blurbs with this issue'))) {
     echo '<p>Created issue_to_text_blurb allowable relationship</p>';
 /**
  * Checks if image table has our new fields (thumbnail_image_type and original_image_type) --
  * if not, then creates these fields in the image table
  * 
  * @return boolean whether or not new fields were actually created
  */
 function add_unexisting_image_fields()
 {
     $table_name = 'image';
     $new_field_names = array('thumbnail_image_type' => array('db_type' => 'tinytext'), 'original_image_type' => array('db_type' => 'tinytext'));
     $existing_field_names = get_fields_by_content_table($table_name);
     // check if our new fields exist yet
     $new_fields_needed = false;
     foreach (array_keys($new_field_names) as $field_name) {
         if (!in_array($field_name, $existing_field_names)) {
             $new_fields_needed = true;
         }
     }
     if ($new_fields_needed) {
         $field_updater = new FieldToEntityTable($table_name, $new_field_names);
         $field_updater->update_entity_table();
         $field_updater->report();
         return true;
     } else {
         return false;
     }
 }
 protected function add_transcoding_status_field($test_mode = false)
 {
     $log = '';
     $field_params = array('transcoding_status' => array('db_type' => 'enum("ready", "converting", "error", "finalizing")'));
     $updater = new FieldToEntityTable('media_work', $field_params);
     $updater->test_mode = $test_mode;
     $updater->update_entity_table();
     ob_start();
     $updater->report();
     $log .= ob_get_contents();
     ob_end_clean();
     return $log;
 }
 protected function _add_fields()
 {
     $updater = new FieldToEntityTable('policies', $this->_get_fields_to_add());
     $updater->update_entity_table();
     ob_start();
     $updater->report();
     return ob_get_clean();
 }
function create_external_url_type($type_id, $type_name, $type_unique_name, $type_plural_name, $entity_table_fields)
{
    $user_id = get_user_id(reason_require_authentication());
    if ($type_id == 0) {
        $type_id = reason_create_entity(id_of('master_admin'), id_of('type'), $user_id, $type_name, array('unique_name' => $type_unique_name, 'plural_name' => $type_plural_name, 'new' => 0));
        if ($type_id != 0) {
            report($type_name . ' type created');
            if (@create_default_rels_for_new_type($type_id, $type_unique_name)) {
                report($type_name . ' default rels created');
            }
        } else {
            warn($type_name . ' not created - this is unexpected');
            return false;
        }
    }
    if (!empty($entity_table_fields)) {
        foreach ($entity_table_fields as $table_name => $table_fields) {
            $table_id = @create_reason_table($table_name, $type_id, $user_id);
            if ($table_id) {
                report('created entity table ' . $table_name . ' with id ' . $table_id);
            } else {
                report('did not create entity table ' . $table_name . ' - probably already exists - will try to add to type');
                add_entity_table_to_type($table_name, $type_id);
            }
            $updater = new FieldToEntityTable($table_name, $table_fields);
            $updater->update_entity_table();
            if ($updater->fields > 0) {
                ob_start();
                $updater->report();
                $updater_report = '<h3>Amputee Report - entity table ' . $table_name . '</h3><hr />' . ob_get_contents() . '<hr />';
                ob_end_clean();
                report($updater_report);
            }
        }
        $fixer = new AmputeeFixer();
        $fixer->fix_amputees($type_id);
        report('fixed amputees for type ' . $type_name);
    } else {
        report($type_name . ' requires no entity table(s) because it has no fields other than what is in the entity table');
    }
    return $type_id;
}