Пример #1
0
function create_type($site, $type, $user, $name, $array)
{
    $ret = reason_create_entity($site, $type, $user, $name, $array);
    id_of('type', false);
    //clear cache
    create_default_rels_for_new_type($ret, $array['unique_name']);
    return $ret;
}
Пример #2
0
 /**
  * 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;
 }
Пример #3
0
 function add_quote_type()
 {
     if (reason_unique_name_exists('quote_type', false)) {
         echo '<p>quote_type already exists. No need to create</p>' . "\n";
         return false;
     }
     if ($this->mode == 'run') {
         reason_create_entity(id_of('master_admin'), id_of('type'), $this->reason_user_id, 'Quote', $this->quote_type_details);
         if (reason_unique_name_exists($this->quote_type_details['unique_name'], false)) {
             $type_id = id_of('quote_type');
             create_default_rels_for_new_type($type_id, $this->quote_type_details['unique_name']);
             $this->add_entity_table_to_type('meta', 'quote_type');
             $this->add_entity_table_to_type('chunk', 'quote_type');
             // setup its relationship to entity tables
             echo '<p>quote_types successfully created</p>' . "\n";
         } else {
             echo '<p>Unable to create quote_type</p>';
         }
     } else {
         echo '<p>Would have created quote_type.</p>' . "\n";
     }
 }
 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;
 }
 protected function create_social_account_type()
 {
     $str = '';
     $social_account_type_id = reason_create_entity(id_of('master_admin'), id_of('type'), $this->user_id(), 'Social Account', $this->social_account_type_details);
     $str .= '<p>Create social account type entity</p>';
     create_default_rels_for_new_type($social_account_type_id);
     create_reason_table('social_account', $this->social_account_type_details['unique_name'], $this->user_id());
     $ftet = new FieldToEntityTable('social_account', array('account_type' => array('db_type' => 'tinytext'), 'account_id' => array('db_type' => 'tinytext'), 'account_details' => array('db_type' => 'text')));
     $ftet->update_entity_table();
     ob_start();
     $ftet->report();
     $str .= ob_get_contents();
     ob_end_clean();
     create_allowable_relationship(id_of('site'), id_of('social_account_type'), 'site_to_social_account', $this->site_to_social_account_details);
     $str .= '<p>Created site to social account relationship.</p>';
     create_relationship(id_of('master_admin'), id_of('social_account_type'), relationship_id_of('site_to_type'));
     return $str;
 }
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;
}