function process() { $description = trim(tidy($this->get_value('description'))); $content = trim(get_safer_html(tidy($this->get_value('post_content')))); if(carl_empty_html($description)) { $words = explode(' ', $content, 31); unset($words[count($words)-1]); $description = implode(' ', $words).'…'; $description = trim(tidy($description)); // we're tidying it twice so that if we chop off a closing tag tidy will stitch it back up again } if(!empty($this->user_netID)) { $user_id = make_sure_username_is_user($this->user_netID, $this->site_info->id()); } else { $user_id = $this->site_info->id(); } if($this->hold_posts_for_review) { $status = 'pending'; } else { $status = 'published'; } $values = array ( 'status' => $status, 'release_title' => trim(strip_tags($this->get_value('title'))), 'author' => trim(strip_tags($this->get_value('author'))), 'content' => $content, 'description' => $description, 'datetime' => date('Y-m-d H:i:s', time()), 'keywords' => implode(', ', array(strip_tags($this->get_value('title')), date('Y'), date('F'))), 'show_hide' => 'show', 'new' => 0 ); $this->new_post_id = reason_create_entity( $this->site_info->id(), id_of('news'), $user_id, $values['release_title'], $values ); create_relationship( $this->new_post_id, $this->publication->id(), relationship_id_of('news_to_publication') ); if ($this->successfully_submitted()) { if($this->hold_posts_for_review) { echo '<p>Posts are being held for review on this publication. Please check back later to see if your post has been published.</p>'; echo '<a href="?">Back to main page</a>'; } else { echo '<p>Your post has been published.</p>'; echo '<a href="'.carl_construct_redirect(array('story_id'=>$this->new_post_id)).'">View it.</a>'; } } if($this->get_value('issue')) { create_relationship($this->new_post_id, $this->get_value('issue'), relationship_id_of('news_to_issue')); } if($this->get_value('section')) { create_relationship($this->new_post_id, $this->get_value('section'), relationship_id_of('news_to_news_section')); } if($this->get_value('categories')) { foreach($this->get_value('categories') as $category_id) { // Check to make sure ids posted actually belong to categories in the site if(array_key_exists($category_id, $this->categories)) { create_relationship( $this->new_post_id, $category_id, relationship_id_of('news_to_category') ); } } } $this->show_form = false; $this->do_notifications(); }
public function upload_media($disco) { $username = reason_check_authentication(); if (empty($username)) { $this->_user_id = make_sure_username_is_user('anonymous', $this->site_id); } else { $this->_user_id = make_sure_username_is_user($username, $this->site_id); //||| } // Begin the upload to Kaltura $kaltura_shim = new KalturaShim(); if ($disco->get_element('upload_file')->tmp_full_path) { $tmp_path_arr = explode("/", $disco->get_element('upload_file')->tmp_full_path); $this->_filename = end($tmp_path_arr); $this->_filepath = $this->get_kaltura_import_dir() . end($tmp_path_arr); rename($disco->get_element('upload_file')->tmp_full_path, $this->_filepath); } else { $this->_filename = $disco->get_value('url'); $this->_filepath = $disco->get_value('url'); } $categories = array($this->cur_page->get_value('name')); if (!empty($this->params['entries_gallery_page'])) { if (reason_unique_name_exists($this->params['entries_gallery_page'])) { $page_id = id_of($this->params['entries_gallery_page']); $page = new entity($page_id); $categories = array($page->get_value('name')); } } if ($disco->get_value('av_type') == 'Video') { $this->_entry = $kaltura_shim->upload_video($this->_filepath, $disco->get_value('media_title'), $disco->get_value('description'), '', $categories, $username); } else { $this->_entry = $kaltura_shim->upload_audio($this->_filepath, $disco->get_value('media_title'), $disco->get_value('description'), '', $categories, $username, $this->_filename); } if (!$this->_entry) { $disco->set_error('upload_file', 'There was an error during the upload process.' . $this->_filepath); } }
function process() { if(!empty($this->username)) { $user_id = make_sure_username_is_user($this->username, $this->site_id); } else { $user_id = $this->site_info->id(); } if($this->hold_comments_for_review) { $show_hide = 'hide'; } else { $show_hide = 'show'; } $flat_values = array ( 'state' => 'Live', 'author' => trim(get_safer_html(strip_tags($this->get_value('author')))), 'content' => trim(get_safer_html(strip_tags(tidy($this->get_value('comment_content')), '<p><em><strong><a><ol><ul><li><blockquote><acronym><abbr><br><cite><code><pre>'))), 'datetime' => date('Y-m-d H:i:s'), 'show_hide' => $show_hide, 'new'=>'0', ); $this->comment_id = reason_create_entity( $this->site_id, id_of('comment_type'), $user_id, trim(substr(strip_tags($flat_values['content']),0,40)), $flat_values, $testmode = false ); create_relationship( $this->news_item->_id, $this->comment_id, relationship_id_of('news_to_comment') ); $this->do_notifications(); }
} else { echo '<p>Would have made sure the external_css table had the field css_media</p>'; } // Add locks table if ($mode == 'run') { reason_include_once('classes/locks.php'); $e = new entity(id_of('type')); $locks = new ReasonEntityLocks($e); if ($locks->enable_locks()) { echo '<p>entity_lock table now exists.</p>'; } else { echo '<p>entity_lock table not created.</p>'; } } else { echo '<p>Would have made sure the locks table exists.</p>'; } if ($mode == 'run') { if (make_sure_username_is_user('anonymous', id_of('master_admin'))) { echo '<p>anonymous user exists.</p>'; } else { echo '<p>anonymous user not created.</p>'; } } else { echo '<p>Would have added a user called "anonymous".</p>'; } } ?> <p><a href="index.php">Return to Index</a></p> </body> </html>
public function upload_media($disco) { $username = reason_check_authentication(); if (empty($username)) { $this->_user_id = make_sure_username_is_user('anonymous', $this->site_id); } else { $this->_user_id = make_sure_username_is_user($username, $this->site_id); } // Begin the upload to whatever serivice is being used $at_remote_url = false; if ($disco->get_element('upload_file')->tmp_full_path) { $tmp_path_arr = explode("/", $disco->get_element('upload_file')->tmp_full_path); $this->_filename = $this->sanitize_filename($disco->get_element('upload_file')->file['name']); $this->_filepath = $this->get_media_import_dir() . $this->_filename; rename($disco->get_element('upload_file')->tmp_full_path, $this->_filepath); } else { $at_remote_url = true; $this->_filename = basename($disco->get_value('url')); $this->_filepath = $disco->get_value('url'); } $media_work_id = $this->_create_media_entity($disco); if ($disco->get_value('av_type') == 'Video') { $this->_entry = $this->shim->upload_video($this->_filepath, new entity($this->_media_work_id), $username, $at_remote_url); } else { $this->_entry = $this->shim->upload_audio($this->_filepath, new entity($this->_media_work_id), $username, $at_remote_url); } if (!$this->_entry) { $disco->set_error('upload_file', 'There was an error during the upload process.'); reason_expunge_entity($this->_media_work_id, $this->_user_id); $this->_media_work_id = false; return; } $values = array(); $values['entry_id'] = $this->_entry->id; $values['transcoding_status'] = 'converting'; $values['media_publication_datetime'] = date('Y-m-d H:i:s'); $values['show_hide'] = $this->params['show_hide_default']; reason_update_entity($this->_media_work_id, $this->_user_id, $values, false); }