function init($args = array()) { parent::init($args); $site = new entity($this->site_id); if (!empty($this->params['sites'])) { $this->child_sites = array(); foreach ($this->params['sites'] as $unique_name) { if ($id = id_of($unique_name)) { $e = new entity($id); if ($e->get_value('type') == id_of('site') && ($site->get_value('site_state') != 'Live' || $e->get_value('site_state') == 'Live')) { $this->child_sites[$id] = $e; } } } } else { $es = new entity_selector(); $es->description = 'Getting child sites of this site'; $es->add_type(id_of('site')); $es->add_left_relationship($this->site_id, relationship_id_of('parent_site')); $es->set_order('entity.name'); if ($site->get_value('site_state') == 'Live') { $es->add_relation('site_state="Live"'); } $this->child_sites = $es->run_one(); } }
function show_feed_link() { $type = new entity(id_of('event_type')); if ($type->get_value('feed_url_string')) { echo '<div class="feedInfo"><a href="/' . REASON_GLOBAL_FEEDS_PATH . '/' . $type->get_value('feed_url_string') . '" title="RSS feed for this site\'s events">xml</a></div>'; } }
/** * Get the appropriate parameters to pass to the plasmature element * @param integer $site_id The Reason id of the site in which this editor is being invoked * @param integer $user_id The Reason id of the current user (0 if user is anonymous or not in the Reason user store) * @return array plasmature parameters */ function get_plasmature_element_parameters($site_id, $user_id = 0) { $params = array(); // site id $params['site_id'] = $site_id; // paths $params['paths'] = $this->_get_paths($site_id); // default widgets $site = new entity($site_id); if ($site->get_value('loki_default')) { $map = $this->_get_options_map(); if (array_key_exists($site->get_value('loki_default'), $map)) { $params['widgets'] = $map[$site->get_value('loki_default')]['maps_to']; } else { $params['widgets'] = $site->get_value('loki_default'); } } else { $params['widgets'] = 'default'; } // user is admin if (!empty($user_id) && (user_is_a($user_id, id_of('admin_role')) || user_is_a($user_id, id_of('power_user_role')))) { $params['widgets'] .= ' +source +debug'; } else { $params['widgets'] .= ' -source -debug'; } if (defined('REASON_DEFAULT_ALLOWED_TAGS')) { $params['allowable_tags'] = explode(',', str_replace(array('><', '<', '>'), array(',', '', ''), REASON_DEFAULT_ALLOWED_TAGS)); } if (defined('REASON_LOKI_CRASH_REPORT_URI') && REASON_LOKI_CRASH_REPORT_URI != '') { $params['crash_report_uri'] = REASON_LOKI_CRASH_REPORT_URI; } return $params; }
function thor_build_display_values() { $form = new entity($this->form_id); $form->get_values(); if ($form->get_value('type') != id_of('form')) { trigger_error('the thor viewer was passed an invalid id ('.$form_id.') - it must be passed the ID of a reason form entity'); } else { $form_xml_obj = new XMLParser($form->get_value('thor_content')); $form_xml_obj->Parse(); $display_values = array(); foreach ($form_xml_obj->document->tagChildren as $k=>$v) { $tagname = is_object($v) ? $v->tagName : ''; if (method_exists($this, '_build_display_'.$tagname)) { $build_function = '_build_display_'.$tagname; $display_values = array_merge($display_values, $this->$build_function($v)); } } } foreach ($this->extra_fields as $field_name) { $display_values[$field_name]['label'] = prettify_string($field_name); $display_values[$field_name]['type'] = 'text'; } $this->_display_values = (isset($display_values)) ? $display_values : array(); }
/** * Transforms an object (usuario) to a string (id). * * @param entity|null $entity * @return string */ public function transform($entity) { if (null === $entity) { return $this->id; } return $entity->getId(); }
function init($args = array()) { parent::init($args); $root_id = $this->parent->pages->root_node(); $this_page_id = $this->cur_page->id(); // check to see if this is a home page -- don't even query for siblings if ($root_id != $this_page_id) { $parent_id = $this->parent->pages->parent($this->cur_page->id()); if (!empty($parent_id)) { $sibling_ids = $this->parent->pages->children($parent_id); if (!empty($sibling_ids)) { foreach ($sibling_ids as $sibling_id) { if ($sibling_id != $root_id) { $page = new entity($sibling_id); if ($this->params['show_only_pages_in_nav'] && $page->get_value('nav_display') != 'Yes') { continue; } if (isset($this->params['show_external_links']) && !$this->params['show_external_links'] && $page->get_value('url')) { continue; } $this->siblings[$sibling_id] = $page; } } } $this->parent_page = new entity($parent_id); } } }
function get_pages_needing_change() { if (!isset($this->pages_needing_change)) { $es = new entity_selector(); $es->add_type(id_of('minisite_page')); $es->enable_multivalue_results(); $es->limit_tables('page_node'); $es->limit_fields('custom_page'); $es->add_relation('page_node.custom_page = "blurb"'); $es->add_left_relationship_field('minisite_page_to_text_blurb', 'entity', 'id', 'blurb_id'); $result = $es->run_one(); foreach ($result as $k => $page) { $blurbs = is_array($page->get_value('blurb_id')) ? $page->get_value('blurb_id') : array($page->get_value('blurb_id')); foreach ($blurbs as $blurb_id) { $blurb = new entity($blurb_id); $content = $blurb->get_value('content'); $demoted_content = demote_headings($content, 1); if ($content == $demoted_content) { $pages_needing_page_type_change[$k] = $k; } } } $this->pages_needing_change = isset($pages_needing_page_type_change) ? array_keys($pages_needing_page_type_change) : false; } return $this->pages_needing_change; }
function set_audience_id($aud_id) { $aud = new entity($aud_id); if ($aud->get_values()) { $this->audiences[$aud_id] = $aud; } }
function init() { if (!empty($this->admin_page->id)) { $temp = new entity($this->admin_page->id, false); if ($temp->get_value('new') && $temp->get_value('state') == 'Pending' && !$temp->get_value('name') && reason_user_has_privs($this->admin_page->user_id, 'delete_pending')) { reason_expunge_entity($this->admin_page->id, $this->admin_page->user_id); } } if (!empty($this->admin_page->request[CM_VAR_PREFIX . 'type_id'])) { $old_vars = array(); foreach ($this->admin_page->request as $key => $val) { if (substr($key, 0, strlen(CM_VAR_PREFIX)) == CM_VAR_PREFIX) { $old_vars[substr($key, strlen(CM_VAR_PREFIX))] = $val; $old_vars[$key] = ''; } } foreach ($this->admin_page->default_args as $arg) { if (!isset($old_vars[$arg])) { $old_vars[$arg] = ''; } } $link = $this->admin_page->make_link($old_vars); } else { $link = $this->admin_page->make_link(array('id' => '', 'site_id' => $this->admin_page->site_id, 'type_id' => $this->admin_page->type_id, 'cur_module' => 'Lister')); } header('Location: ' . unhtmlentities($link)); die; }
/** * Run the upgrader * * @return string HTML report */ public function run() { $ret = ''; $e = new entity(id_of('css')); if (!$e->get_value('custom_content_handler')) { reason_update_entity($e->id(), $this->user_id(), array('custom_content_handler' => 'css.php')); $ret .= '<p>The CSS type has been assigned a content manager.</p>' . "\n"; } $tables = get_entity_tables_by_type(id_of('css'), false); $has_meta = in_array('meta', $tables); $has_url = in_array('url', $tables); if ($has_meta || $has_url) { set_time_limit(3600); if ($has_meta) { $ret .= $this->_move_table_fields('meta'); } if ($has_url) { $ret .= $this->_move_table_fields('url'); } } if (empty($ret)) { $ret .= '<p>This upgrade has already been run. There is nothing to do.</p>'; } return $ret; }
function get_feed_as_text($params) { if (!empty($params['type_id'])) { $type = new entity($params['type_id']); if (!empty($params['feed'])) { $feed_file = $params['feed']; } elseif ($type->get_value('custom_feed')) { $feed_file = str_replace('.php', '', $type->get_value('custom_feed')); } else { $feed_file = 'default'; // otherwise use default feed script } reason_include_once('feeds/' . $feed_file . '.php'); $feed_class = $GLOBALS['_feed_class_names'][$feed_file]; if (!empty($params['site_id'])) { $site = new entity($params['site_id']); $feed = new $feed_class($type, $site); } else { $feed = new $feed_class($type); } $feed->set_request_vars($params); ob_start(); $feed->run(false); $feed_text = ob_get_contents(); ob_end_clean(); if (!empty($feed_text)) { return $feed_text; } } }
function checkPermissions() { // first, make sure user is logged in $username = reason_check_authentication(); if (!$username) { $this->error("this page requires authentication"); } else { // next, figure out the form id $matches = array(); $res = preg_match("/form_(\\d*)/", $this->table, $matches); if (count($matches) != 2) { $this->error("invalid table name"); } else { $formId = $matches[1]; // now that we've got the form id, find out what site it belongs to $form = new entity($formId); $site = $form->get_owner(); // and finally, make sure the logged in user has access to the site, and is an admin $hasSiteAccess = reason_username_has_access_to_site($username, $site->id()); // $isAdmin = user_is_a(get_user_id($username), id_of("admin_role")); // return $hasSiteAccess && $isAdmin; return $hasSiteAccess; } } return false; }
function show_entity_data($entity) { //echo '<h4>Entity data:</h4>'; $entity_type = new entity($entity->get_value('type')); echo '<p><strong>Type</strong>: ' . $entity_type->get_value('name') . '</p>'; $owner = $entity->get_owner(); if (is_object($owner)) { echo '<p><strong>Owner site</strong>: ' . $owner->get_value('name') . ' (ID: ' . $this->get_id_markup($owner->id()) . ')</p>' . "\n"; } else { echo '<p>No owner site (orphan entity)</p>' . "\n"; } echo '<table class="entityInfoDataTable">' . "\n"; echo '<tr>' . "\n"; echo '<th>Attribute</th>' . "\n"; echo '<th>Value</th>' . "\n"; echo '</tr>' . "\n"; $id_markup_keys = array('type', 'last_edited_by', 'created_by'); foreach ($entity->get_values() as $key => $value) { echo '<tr>' . "\n"; echo '<td>' . $key . '</td>' . "\n"; if (in_array($key, $id_markup_keys)) { echo '<td>' . $this->get_id_markup($value) . '</td>' . "\n"; } else { echo '<td>' . $value . '</td>' . "\n"; } echo '</tr>' . "\n"; } echo '</table>' . "\n"; }
function make_link($id) { $asset = $this->items[$id]; $owner_id = $asset->get_value('owner_id'); $owner_site = new entity($owner_id); return 'http://' . REASON_HOST . $owner_site->get_value('base_url') . MINISITE_ASSETS_DIRECTORY_NAME . '/' . $asset->get_value('file_name'); }
function init() { parent::init(); if (!empty($this->admin_page->request['event_id'])) { $event = new entity($this->admin_page->request['event_id']); $this->admin_page->title = 'Sorting Registration Slots of "' . $event->get_value('name') . '"'; } }
function init() { parent::init(); if (!empty($this->admin_page->request['parent_id'])) { $x = new entity($this->admin_page->request['parent_id']); $this->admin_page->title = 'Sorting Children of "' . $x->get_value('name') . '"'; } }
function get_blog_content_from_id($id) { $post = new entity($id); if ($post->get_value('content')) { return $post->get_value('content'); } else { return get_blog_description_from_id($id); } }
function pre_show_all_items() { if ($this->top_link_site_id == $this->site_id) { $this->link = $this->top_link_site_id = ''; } elseif (!empty($this->top_link_site_id) && empty($this->link)) { $site = new entity($this->top_link_site_id); $this->link = '<a href="' . $site->get_value('base_url') . '">' . $site->get_value('name') . " Home" . '</a>'; } }
function init() { parent::init(); if (!empty($this->admin_page->request['parent_id'])) { $x = new entity($this->admin_page->request['parent_id']); $this->admin_page->title = 'Sorting Children of "' . $x->get_value('name') . '"'; } elseif (!$this->is_new()) { $this->admin_page->title = 'Sorting Top Level Policies'; } }
/** * Set up and run the actual form used to import the images */ function run_form() { $f = new $this->image_import_form_class_name(); $user = new entity($this->admin_page->user_id); $f->username = $user->get_value('name'); $f->user_id = $this->admin_page->user_id; $f->site_id = $this->admin_page->site_id; $f->add_element('cancel_text', 'comment', array('text' => '<a href="' . $this->admin_page->make_link(array('cur_module' => 'Lister', 'id' => '')) . '">Cancel batch import</a>')); $f->run(); }
function delete_entity() { if ($this->get_value('id')) { $e = new entity($this->get_value('id')); if ($e->get_value('state') == 'Live' || $e->get_value('state') == 'Deleted') { $q = 'UPDATE URL_history SET deleted="yes" WHERE page_id="' . $this->get_value('id') . '"'; $r = db_query($q, 'Deleting Page'); } } parent::delete_entity(); }
/** * Attempts to delete a video from Vimeo. If the video wasn't uploaded through Reason, the * deletion call will simply fail. * @param $media_work_deleter */ public function delete_media_work($media_work_deleter) { if (VIMEO_UPLOADING_ENABLED) { $media_work = new entity($media_work_deleter->get_value('id')); $vimeo = new phpVimeo(VIMEO_CLIENT_ID, VIMEO_CLIENT_SECRET, VIMEO_ACCESS_TOKEN, VIMEO_ACCESS_TOKEN_SECRET); try { $vimeo->call('vimeo.videos.delete', array('video_id' => $media_work->get_value('entry_id'))); } catch (VimeoAPIException $e) { } } }
/** * Assemble the markup for a particular filter selector * @return string * @access private */ function _build_filter_set($key) { $ret = ''; $other_filter_links = $this->default_links; unset($other_filter_links[$key]); $combined_other_filter_links = implode('&', $other_filter_links); $ret .= '<div class="filters">'; foreach ($this->filter_types as $filter_name => $filter_type) { if (!empty($this->filter_entities[$filter_name])) { if ($type_id = id_of($filter_type['type'])) { $type = new entity($type_id); $name = $type->get_value('plural_name'); } else { $name = prettify_string($filter_name); } $ret .= '<h4>' . $name . '</h4>' . "\n"; $ret .= '<ul>'; if (!empty($this->filters[$key])) { $link = '?'; if (!empty($this->search_value)) { $link .= 'search=' . urlencode($this->search_value) . '&'; } if (!empty($other_filter_links)) { $link .= $combined_other_filter_links; } $ret .= '<li><a href="' . $link . '">All</a></li>' . "\n"; } foreach ($this->filter_entities[$filter_name] as $entity) { $ret .= '<li>'; if (!empty($this->filters[$key]) && $this->filters[$key]['type'] == $filter_name && $this->filters[$key]['id'] == $entity->id()) { $ret .= '<strong>' . $entity->get_value('name') . '</strong>' . "\n"; } else { $link = '?'; if (!empty($other_filter_links)) { $link .= $combined_other_filter_links . '&'; } if (!empty($this->search_value)) { $link .= 'search=' . urlencode($this->search_value) . '&'; } $link .= 'filter' . $key . '=' . $filter_name . '-' . $entity->id(); if (!empty($this->textonly)) { $link .= '&textonly=1'; } $ret .= '<a href="' . $link . '">' . $entity->get_value('name') . '</a>' . "\n"; } $ret .= '</li>'; } $ret .= '</ul>'; } } $ret .= '</div>' . "\n"; return $ret; }
function get_feed_url($site_id = '') { $site_id = $site_id ? $site_id : $this->get_site_id(); $publication_type = new entity(id_of('publication_type')); $feed_url_string = $publication_type->get_value('feed_url_string'); if ($feed_url_string) { $site = new entity($site_id); $base_url = $site->get_value('base_url'); $blog_feed_string = $this->get_value('blog_feed_string'); $feed_url = $base_url . MINISITE_FEED_DIRECTORY_NAME . '/' . $feed_url_string . '/' . $blog_feed_string; } return isset($feed_url) ? $feed_url : false; }
/** * Returns the path used for storing the given media file and temporary file name. * * @param $media_file_or_id entity or integer * @param $tmp_file_name string leave this out if getting the original file's path * @param $media_work entity * @param $extra_dir string * @return string */ public static function get_path($media_file_or_id, $tmp_file_name = '', $media_work = null, $extra_dir = '') { if (!$media_file_or_id || is_object($media_file_or_id)) { return self::_get_path_from_entities($media_file_or_id, $tmp_file_name, $media_work, $extra_dir); } elseif (!is_object($media_file_or_id)) { $media_file = new entity($media_file_or_id); if ($media_file->get_value('type') == id_of('av_file')) { return self::_get_path_from_entities($media_file, $tmp_file_name, $media_work, $extra_dir); } else { trigger_error('Non-Media File entity with type ' . $media_file_or_id->get_value('type') . ' given.'); } } }
function set_event($event) { if (!is_object($event)) { $event_id = turn_into_int($event); $event = new entity($event_id); } if ($event->get_values() && $event->get_value('type') == id_of('event_type')) { $this->event = $event; } else { trigger_error('Entity passed to reasonEvent object that is not an event'); $this->event = NULL; } }
function run() { //pray ($this->admin_page->request); $user = new entity($this->admin_page->user_id); $netid = $user->get_value('name'); echo '<br />You are logged in as <strong>' . $netid . '</strong><br /><br />'; $q = 'SELECT count(*) as c FROM entity WHERE last_edited_by = ' . $this->admin_page->user_id; $r = db_query($q, 'Unable to grab number of edited items.'); $row = mysql_fetch_array($r, MYSQL_ASSOC); mysql_free_result($r); $c = $row['c']; echo 'You have last edited ' . $c . ' item' . ($c != 1 ? 's' : '') . '<br /><br />'; }
function remove_minisite_page_rewrite_finish_action() { $minisite_page_type_entity = new entity(id_of('minisite_page')); $finish_action = $minisite_page_type_entity->get_value('finish_actions'); if ($finish_action != 'update_rewrites.php') { echo '<p>The minisite_page finish action is not update_rewrites.php - this script has probably been run</p>'; } elseif ($this->mode == 'test') { echo '<p>Would remove the update_rewrites.php finish action from the minisite_page type</p>'; } elseif ($this->mode == 'run') { $updates = array('finish_actions' => ''); reason_update_entity(id_of('minisite_page'), $this->reason_user_id, $updates); echo '<p>Removed the update_rewrites.php finish action from the minisite_page type</p>'; } }
/** * Get the appropriate parameters to pass to the plasmature element * @param integer $site_id The Reason id of the site in which this editor is being invoked * @param integer $user_id The Reason id of the current user (0 if user is anonymous or not in the Reason user store) * @return array plasmature parameters */ function get_plasmature_element_parameters($site_id, $user_id = 0) { $param['rows'] = 20; $param['external_css'][] = REASON_HTTP_BASE_PATH . 'tinymce/css/external.css'; $param['init_options']['content_css'] = $this->get_content_css_path(); $site = new entity($site_id); $loki_default = $site->get_value( 'loki_default' ); $config = (!empty($loki_default) && in_array($loki_default, array_keys($this->get_configuration_options()))) ? $loki_default : 'notables'; $imagetoolbar = ($this->reason_plugins_available($user_id)) ? 'reasonimage' : 'image'; /* these will need to change when the link plugin is available */ $linkplugin = ($this->reason_plugins_available($user_id)) ? 'link' : 'link'; $linktoolbar = ($this->reason_plugins_available($user_id)) ? 'reasonlink' : 'link'; $blockformats = ($config == 'notables_plus_pre' || $config == 'all') ? 'Paragraph=p;Header 1=h3;Header 2=h4;Pre=pre' : 'Paragraph=p;Header 1=h3;Header 2=h4'; $tabletoolbar = ($config == 'all' || $config == 'all_minus_pre') ? '|,table,' : ''; $cutcopypaste = ($config == 'default' || $config == 'all' || $config == 'all_minus_pre') ? '|,cut,copy,paste,' : ''; /* load the basic reason image and link plug in options */ if ($this->reason_plugins_available($user_id)) { $param['init_options']['reason_site_id'] = $site_id; $param['init_options']['reason_http_base_path'] = REASON_HTTP_BASE_PATH; } $param['init_options']['toolbar1'] = 'formatselect,|,bold,italic,|,hr,'.$cutcopypaste.'|,blockquote,|,numlist,bullist,|,indent,outdent,'.$tabletoolbar.'|,'.$imagetoolbar.',|,'.$linktoolbar.',unlink,|,anchor'; $param['init_options']['plugins'] = 'anchor,link,paste,advlist'; if ($this->reason_plugins_available($user_id)) { $param['init_options']['external_plugins'] = '{ "reasonintegration": "' . REASON_HTTP_BASE_PATH . 'tinymce/plugins/reasonintegration/plugin.js" }'; } else { $param['init_options']['plugins'] .= ',image'; } $param['init_options']['block_formats'] = $blockformats; if (!empty($tabletoolbar)) { $param['init_options']['plugins'] = 'contextmenu,table,' . $param['init_options']['plugins']; $param['init_options']['contextmenu'] = 'inserttable | cell row column deletetable'; } if (reason_user_has_privs($user_id, 'edit_html')) { $param['init_options']['toolbar1'] .= ',|,code'; $param['init_options']['plugins'] .= ',code'; } return $param; }
public function __construct(\field_ident $id_tag_post, \field_foreignkey $id_tag, \field_foreignkey $id_post) { parent::__construct(); $this->id_tag_post = $id_tag_post; $this->id_tag = $id_tag; $this->id_post = $id_post; }