mysite_get_myid($type = NULL, $string = NULL, $title = NULL, $content = NULL, $format = NULL, $base = NULL, $xml = NULL)
mysite.module, line 3037
Retrieve or create a MySite id for string-based keys. This function is used to create entries in the {mysite_content} table which is designed to handle non-numeric keys. This lets us keep all the keys in the {mysite_data} table as integers.
$type The type of mysite content being created. Required.
$string The string to be used as a unique key for this $type. For example, if we create an entry to map the path 'taxonomy/term/1+3' the $string would be '1+3'. Required.
$title The title to store for this content element. Optional.
$content Content to store with this element. This is typically used by the droplet.inc to create arbitrary block-style content, but this field can store any data the administrator or the type include needs to define. Optional.
$format A numeric identifier indicating the filter_format of the $content. Used for secure output. See droplet.inc for usage examples. Optional.
$base The base URL (either http://example.com or a drupal 'path/to/item'). Used as the 'read more' link on page render. Optional.
$xml The URL (either http://example.com or a drupal 'path/to/item') for the RSS/ATOM feed for the content. This is an optional layout feature not currently implemented. Optional.
function mysite_get_myid($type = NULL, $string = NULL, $title = NULL, $content = NULL, $format = NULL, $base = NULL, $xml = NULL) {
if (!empty($string) && !empty($type)) {
$sql = "SELECT myid FROM {mysite_content} WHERE type_key = '%s' AND type = '%s'";
$data= db_fetch_object(db_query($sql, $string, $type));
if ($data->myid == 0) {
$myid = db_next_id("{mysite_content}_id");
if (!is_null($content)) {
$content = serialize($content);
}
$sql = "INSERT INTO {mysite_content} (myid, type, type_key, title, content, format, base, xml) VALUES (%d, '%s', '%s', '%s', '%s', %d, '%s', '%s')";
db_query($sql, $myid, $type, $string, $title, $content, $format, $base, $xml, $icon);
return $myid;
}
else {
return $data->myid;
}
}
else {
drupal_set_message('Error defining content type.', 'error');
}
}