$widget = ''; // inital submit options $submit_options = array('id' => 'simplekaltura-submit', 'name' => 'save', 'value' => elgg_echo('save'), 'class' => 'elgg-button-submit'); // Only include the widget and js when adding if (!$entity) { $widget = elgg_view('simplekaltura/form_elements/ksu_widget'); // Disable the submit button initially, this will be enabled later once a video is selected $submit_options['disabled'] = 'DISABLED'; $submit_options['class'] .= ' elgg-state-disabled'; } else { // Get entry to check status $entry = simplekaltura_get_entry($entity->kaltura_entryid); // Check for ready status if ($entry->status == KalturaEntryStatus::READY) { // Update local entity simplekaltura_update_video($entity); $thumbnail_input = elgg_view('input/simplekaltura_thumbs', array('entity' => $entity)); $thumbnail_content = "<div>\n \t\t\t{$thumbnail_input}\n\t\t\t</div><br />"; } else { echo "<div class='elgg-message elgg-state-notice'>" . elgg_echo('simplekaltura:notconverted') . "</div>"; } } $container_hidden = elgg_view('input/hidden', array('name' => 'container_guid', 'value' => $container_guid)); $entity_hidden = elgg_view('input/hidden', array('name' => 'guid', 'value' => $guid)); // Labels/Input $title_label = elgg_echo('title'); $title_input = elgg_view('input/text', array('id' => 'video_title', 'name' => 'video_title', 'value' => $title)); $description_label = elgg_echo("simplekaltura:label:description"); $description_input = elgg_view("input/longtext", array('name' => 'video_description', 'value' => $description)); $tag_label = elgg_echo('tags'); $tag_input = elgg_view('input/tags', array('id' => 'video_tags', 'name' => 'video_tags', 'value' => $tags));
/** * Cron function to update all simplekaltura_video objects */ function simplekaltura_bulk_update() { elgg_load_library('simplekaltura'); elgg_load_library('KalturaClient'); // Get a kaltura client $client = simplekaltura_create_client(true); // Set up pager $pager = new KalturaFilterPager(); $pager->pageIndex = "1"; $pager->pageSize = "0"; // Set up filter $filter = new KalturaMediaEntryFilter(); $filter->tagsAdminTagsMultiLikeOr = elgg_get_plugin_setting('kaltura_admin_tags', 'simplekaltura'); // Grab entries $result = $client->media->listAction($filter, $pager); // Get elgg entities $options = array('type' => 'object', 'subtype' => 'simplekaltura_video', 'limit' => 0); $ia = elgg_set_ignore_access(true); // just need an array of the kaltura ids and GUIDs $batch = new ElggBatch('elgg_get_entities', $options); $video_ids = array(); foreach ($batch as $video) { if ($video->kaltura_entryid) { $video_ids[$video->kaltura_entryid] = $video->getGUID(); } } // Match up each found entry to an elgg entity $success = true; foreach ($result->objects as $entry) { // If it exists.. $video_guid = elgg_extract($entry->id, $video_ids); if ($video_guid) { $videoupdate = get_entity($video_guid); $success &= simplekaltura_update_video($videoupdate, $entry); } } elgg_set_ignore_access($ia); return $success; }