'All Media Mover files', 'description' => t('Provides all Media Mover files'), 'uri' => 'file', 'kind' => 'resource', 'callbacks' => array( 'resource' => 'media_media_mover_all_files', ), 'fields' => array('attachments', 'filefield'), ); $registration['media_mover_user'] = array( // human readable name 'name' => 'My Media Mover files', 'description' => 'Provides Media Mover generated files for this user', 'uri' => 'file', 'kind' => 'resource', 'description' => t('Integrate Users Media Mover files'), 'callbacks' => array( 'resource' => 'media_media_mover_user_files', ), 'fields' => array('attachments', 'filefield'), ); return $registration; } function media_media_mover_formatter_form($node_type, $field, $file_extension, $uri) { if ($uri) { $form['display'] = array( '#type' => 'item', '#value' => l($uri, $uri), ); $form['list'] = array( '#type' => 'checkbox', '#title' => 'List file', '#default_value' => TRUE, ); } return $form; } /** * Retrives all media mover files for reuse * * @param unknown_type $node_type * @param unknown_type $field * @param unknown_type $uid * @return unknown */ function media_media_mover_all_files($node_type, $field, $uid) { $files = array(); $results = db_query('SELECT complete_file FROM {media_mover_files} '); while ($file = db_fetch_array($results)) { $files[] = array( 'uri' => $file['complete_file'], 'filename' => basename($file['complete_file']), 'meta' => '', ); } return array( t('Media Mover') => array( t('All Media Mover files') => media_resource_display_user_files_form($files, t('All Media Mover files')), ) ); } /** * Retrives users media mover files * * @param unknown_type $node_type * @param unknown_type $field * @param unknown_type $uid * @return unknown */ function media_media_mover_user_files($node_type, $field, $uid) { global $user; $files = array(); $results = db_query('SELECT complete_file FROM {media_mover_files} mmf LEFT JOIN {node} n ON mmf.nid = n.nid LEFT JOIN {users} u ON u.uid = n.uid WHERE u.uid = %d ORDER BY n.created DESC', $user->uid); while ($file = db_fetch_array($results)) { $files[] = array( 'uri' => $file['complete_file'], 'filename' => basename($file['complete_file']), 'meta' => '', ); } return array( t('My files') => array( t('Media Mover files') => media_resource_display_user_files_form($files, t('My Media Mover files')), ) ); }