Пример #1
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;
 }
Пример #2
0
/**
 * We use a 1 hour cache for this super common query. We update the cache in admin_actions.php whenever allowable relationships are added or changed.
 */
function reason_get_relationship_names()
{
    $cache = new ReasonObjectCache('reason_relationship_names', 3600);
    if ($relationship_names =& $cache->fetch()) {
        return $relationship_names;
    } else {
        return reason_refresh_relationship_names();
    }
}
 function remove_allowable_relationships_with_missing_types()
 {
     echo '<hr/>';
     $ids = get_allowable_relationships_with_missing_types();
     if ($this->mode == 'run') {
         if (count($ids) > 0) {
             $deleted_count = remove_allowable_relationships_with_missing_types();
             reason_refresh_relationship_names();
             echo '<p>Removed ' . $deleted_count . ' allowable relationships with missing types.</p>';
         } else {
             echo '<p>Nothing to delete there are no allowable relationships with missing types.</p>';
         }
     } else {
         echo '<p>Would delete ' . count($ids) . ' allowable relationships with missing types.</p>';
     }
 }
Пример #4
0
	/**
	 * Examines the allowable relationships table, removes allowable relationships that reference a type that does not exist
	 *
	 * @todo database abstraction
	 * @todo move into a database maintenance class
	 * @return number of deleted allowable_relationships
	 * @author Nathan White
	 */
	function remove_allowable_relationships_with_missing_types()
	{
		$ids = get_allowable_relationships_with_missing_types();
		if (!empty($ids))
		{
			$ids_to_delete = implode(',', $ids);
			$q = 'DELETE from allowable_relationship WHERE id IN ('.$ids_to_delete.')';
			db_query($q);
			reason_refresh_relationship_names();
			return count($ids);
		}
		return 0;
	}
 function where_to()
 {
     reason_refresh_relationship_names();
     // lets make sure this reflects changes.
     return carl_make_redirect(array('table_row_action' => '', 'table_action_id' => ''));
 }