コード例 #1
0
 /**
  * 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;
 }
コード例 #2
0
 /**
  * Update the entity with each element's value
  **/
 function update_entity()
 {
     $entity_id = $this->entity->id();
     if (!empty($this->entity) && !empty($this->mapping)) {
         foreach ($this->mapping as $element => $array) {
             $values_array[$array['field']] = $this->get_value($element);
         }
         return reason_update_entity($entity_id, $this->user_netid, $values_array);
     } else {
         return false;
     }
 }
コード例 #3
0
 function change_news_custom_feed()
 {
     $news_type = new entity(id_of('news', false));
     $custom_feed = $news_type->get_value('custom_feed');
     if ($custom_feed == 'news.php') {
         if ($this->mode == 'run') {
             $values['custom_feed'] = 'sitewide_news.php';
             reason_update_entity($news_type->id(), $this->reason_user_id, $values);
             $link = REASON_HTTP_BASE_PATH . '/scripts/urls/update_urls.php';
             echo '<p>Changed the news type custom_feed from news to sitewide news.</p>';
         } else {
             echo '<p>Would change the news type custom_feed from news to sitewide news.</p>';
         }
     } else {
         echo '<p>The news type custom feed has been changed from news.php - this script has probably already been run.</p>';
     }
 }
コード例 #4
0
 function init()
 {
     $this->admin_page->set_show('leftbar', false);
     if (empty($this->admin_page->id)) {
         $this->_not_undeletable_reason = 'no_id_provided';
         return false;
     }
     if (!reason_user_has_privs($this->admin_page->user_id, 'publish')) {
         $this->_not_undeletable_reason = 'insufficient_privileges';
         return false;
     }
     $item = new entity($this->admin_page->id);
     $user = new entity($this->admin_page->user_id);
     if (!$item->user_can_edit_field('state', $user)) {
         $this->_not_undeletable_reason = 'state_field_locked';
         return false;
     }
     if ($item->get_value('state') != 'Deleted') {
         $this->_not_undeletable_reason = 'not_deleted_yet';
         return false;
     }
     reason_update_entity($this->admin_page->id, $this->admin_page->user_id, array('state' => 'Live'), false);
     if ($this->admin_page->type_id == id_of('minisite_page')) {
         // zap nav cache so it reappears.
         reason_include_once('classes/object_cache.php');
         $cache = new ReasonObjectCache($this->admin_page->site_id . '_navigation_cache');
         $cache->clear();
     }
     $manager_site_id = $this->admin_page->site_id;
     if ($item->get_value('type') == id_of('site')) {
         $manager_site_id = $item->id();
     }
     //Updates the rewrites to prevent infinite redirection loop.
     reason_include_once('classes/url_manager.php');
     $urlm = new url_manager($manager_site_id);
     $urlm->update_rewrites();
     $link = unhtmlentities($this->admin_page->make_link(array('cur_module' => 'Lister', 'id' => '', 'state' => 'deleted')));
     header('Location: ' . $link);
     die;
 }
コード例 #5
0
ファイル: sharing.php プロジェクト: natepixel/reason_package
 function init()
 {
     $this->head_items->add_stylesheet(REASON_ADMIN_CSS_DIRECTORY . 'sharing.css');
     reason_include_once('classes/sharing_filter.php');
     reason_include_once('content_listers/sharing.php');
     $type = new entity($this->admin_page->type_id);
     // save the type entity in an object scope
     $this->rel_type = $type;
     $this->get_views($type->id());
     if (empty($this->views)) {
         //add generic lister if not already present
         $this->views = array();
     } else {
         reset($this->views);
         $c = current($this->views);
         if ($c) {
             $lister = $c->id();
             $this->admin_page->request['lister'] = $lister;
         } else {
             $lister = '';
         }
     }
     $this->admin_page->title = $type->get_value('plural_name') ? $type->get_value('plural_name') : $type->get_value('name');
     if ($icon_url = reason_get_type_icon_url($type, false)) {
         $this->admin_page->title = '<img src="' . $icon_url . '" alt="" /> ' . $this->admin_page->title;
     }
     if ($this->admin_page->is_second_level()) {
         $this->admin_page->set_show('leftbar', false);
     }
     $this->viewer = new sharing_viewer();
     $this->viewer->set_page($this->admin_page);
     if (!isset($lister)) {
         $lister = '';
     }
     $this->viewer->init($this->admin_page->site_id, $type->id(), $lister);
     $this->filter = new sharing_filter();
     $this->filter->set_page($this->admin_page);
     $this->filter->grab_fields($this->viewer->filters);
 }
コード例 #6
0
ファイル: preview.php プロジェクト: hunter2814/reason_package
 function _ok_to_run_module()
 {
     if ($this->_ok_to_run !== true && $this->_ok_to_run !== false) {
         $this->_ok_to_run = false;
         if (!$this->admin_page->id) {
             return $this->_ok_to_run;
         }
         $owner_site = get_owner_site_id($this->admin_page->id);
         $entity = new entity($this->admin_page->id);
         if ($owner_site == $this->admin_page->site_id) {
             $this->_ok_to_run = true;
             return $this->_ok_to_run;
         }
         if (site_borrows_entity($this->admin_page->site_id, $entity->id())) {
             $this->_ok_to_run = true;
             return $this->_ok_to_run;
         }
         if (site_shares_type($owner_site, $entity->get_value('type')) && $entity->get_value('no_share') == 0) {
             $this->_ok_to_run = true;
             return $this->_ok_to_run;
         }
     }
     return $this->_ok_to_run;
 }
コード例 #7
0
/**
 *	Get the URL of a page
 *
 *	This function will provide the URL of a page of a particular type or types on a site
 *
 *	@param entity $site The site to look in
 *	@param page_tree $tree the page tree object for the site; this must be already initialized
 *	@param mixed $page_types The array of page types or string indicating single page type that is/are acceptable
 *	@param boolean $as_uri Returns a fully qualified URI if true; otherwise returns a URL relative to web root
 *	@param boolean $secure Uses https if true. This parameter only has an effect if $as_uri is true.
 */
function get_page_link(&$site, &$tree, $page_types, $as_uri = false, $secure = false)
{
    if (empty($site) || empty($page_types)) {
        trigger_error('site and page types must all be passed to get_page_link', EMERGENCY);
    } elseif (is_string($page_types)) {
        $page_types = array($page_types);
    } elseif (!is_array($page_types)) {
        trigger_error('$page_types must be an array or string', EMERGENCY);
    }
    $relations = array();
    $es = new entity_selector($site->id());
    $es->add_type(id_of('minisite_page'));
    foreach ($page_types as $page_type) {
        $relations[] = 'page_node.custom_page = "' . $page_type . '"';
    }
    $es->add_relation('(' . implode(' or ', $relations) . ')');
    $es->set_num(1);
    $pages = $es->run_one();
    if (!empty($pages)) {
        $page = current($pages);
        if (!empty($tree)) {
            $ret = $tree->get_full_url($page->id(), $as_uri, $secure);
        } else {
            $ret = build_URL($page->id());
        }
    } else {
        $ret = $site->get_value('base_url');
    }
    if ($as_uri && empty($pages)) {
        if ($secure) {
            $ret = securest_available_protocol() . '://' . REASON_HOST . $ret;
        } else {
            $ret = 'http://' . REASON_HOST . $ret;
        }
    }
    return $ret;
}
コード例 #8
0
ファイル: site.php プロジェクト: hunter2814/reason_package
 /**
  * Automatically called each time the form loads.
  * 
  * Checks the show_form variable to determine if the deletion page should be shown.
  * Displays each entity that will be deleted with the site, in the format
  * <h4>Type</h4> <ul> <li> Entity <a href = "Preview of entity"> Preview </a> </li> </ul>
  *
  * Contains javascript to display a confirmation window after delete is submitted.
  **/
 function show_form()
 {
     if ($this->show_form) {
         $site = new entity($this->get_value('id'));
         $action_word = 'Deleting';
         if ('Deleted' == $site->get_value('state')) {
             $action_word = 'Expunging';
         }
         echo $action_word . " a site will delete all entities it owns. For " . $site->get_value('name') . " this includes:<br>";
         $borrowing_array = $this->get_borrowing_list();
         foreach ($borrowing_array as $type_id => $entities) {
             $type_entity = new entity($type_id);
             $type_name = $type_entity->get_value('plural_name') ? $type_entity->get_value('plural_name') : $type_entity->get_value('name');
             $temp_string = "\n<h4>" . $type_name . "</h4>\n<ul>";
             foreach (array_keys($entities) as $entity_id) {
                 $link_address = '<a href="?site_id=' . $site->id() . '&amp;type_id=' . $type_id . '&amp;id=' . $entity_id . '&amp;cur_module=Preview" target="_blank">Preview</a> (id: ' . $entity_id . ')';
                 $entity_object = new entity($entity_id);
                 $entity_name = $entity_object->get_display_name();
                 $temp_string .= "\n<li>" . $entity_name . " " . $link_address . "</li>";
             }
             $temp_string .= "\n</ul>";
             echo $temp_string;
         }
         parent::show_form();
         echo "<script>";
         echo "\n\$(document).ready(function(){";
         echo "\n\$('form#disco_form').submit(function(event){";
         echo "\nif(window.confirm('" . $action_word . " this site will delete all entities listed. Are you sure you want to proceed?')){";
         echo "\n}";
         echo "\nelse{";
         echo "\nevent.preventDefault();";
         echo "\ncancelDisableSubmit();";
         echo "\n}";
         echo "\n});";
         echo "\n});";
         /*
         echo "\ndocument.getElementById('disco_form')[0].onsubmit=function() {return displayWarning(this)}";
         echo "\nfunction displayWarning(item)\n{\n\na = window.confirm('Deleting this site will delete all entities listed. Are you sure you want to proceed?')\nif(a!=true)\n{\nreturn false\n}\n}";
         */
         echo "\n</script>";
     } else {
         echo $this->no_show_form();
     }
 }
コード例 #9
0
if (!isset($_POST['verify'])) {
    echo '<p>This script creates a number of fields in the user entity table, and sets the user type to use the user content previewer.';
    echo 'Running this script changes the reason database so that the Reason user type can be used for authentication purposes.</p>';
}
if (isset($_POST['verify']) && $_POST['verify'] == 'Run the Script') {
    // Use the field_to_entity_table_class to add needed fields to 'user' entity table
    $fields = array('user_surname' => array('db_type' => 'tinytext'), 'user_given_name' => array('db_type' => 'tinytext'), 'user_email' => array('db_type' => 'tinytext'), 'user_phone' => array('db_type' => 'tinytext'), 'user_password_hash' => array('db_type' => 'tinytext'), 'user_authoritative_source' => array('db_type' => "enum('reason','external')"));
    $updater = new FieldToEntityTable('user', $fields);
    $updater->update_entity_table();
    $updater->report();
    // Set the custom_previewer value for the User type to User
    $user_type_entity = new entity(id_of('user'));
    $previewer = $user_type_entity->get_value('custom_previewer');
    if ($previewer != "user.php") {
        $update_array = array('type' => array('custom_previewer' => 'user.php'));
        $update = update_entity($user_type_entity->id(), $user_id, $update_array, false);
        if ($update) {
            echo '<h2>Updated user content previewer to user.php</h2>';
        }
    } else {
        echo '<h3>User content previewer already set to user.php</h3>';
    }
    $group_fields = array('ldap_group_filter' => array('db_type' => 'text'), 'ldap_group_member_fields' => array('db_type' => 'tinytext'), 'group_has_members' => array('db_type' => 'enum(\'true\',\'false\')'));
    $updater = new FieldToEntityTable('user_group', $group_fields);
    $updater->update_entity_table();
    $updater->report();
    // check to see if field is still in db
    $results = db_query('DESCRIBE user_group');
    $field_exists = false;
    while ($row = mysql_fetch_array($results)) {
        if ($row['Field'] == 'course_identifier_strings') {
コード例 #10
0
force_secure_if_available();
$user_netID = reason_require_authentication();
$reason_user_id = get_user_id($user_netID);
if (empty($reason_user_id)) {
    die('valid Reason user required');
}
if (!reason_user_has_privs($reason_user_id, 'upgrade')) {
    die('You must have upgrade privileges to run this script');
}
$stt = new entity(id_of('site_type_type'));
if ($stt->get_value('custom_content_handler')) {
    echo '<p>Site Types already have a content manager. There is no need to run this script!</p>';
} else {
    echo '<p>This script will add the site type content manager to this Reason instance. This content manager makes creating site types easier by adding useful comments.</p>';
    if (empty($_POST['run'])) {
        echo '<form action="?" method="post"><input type="submit" name="run" value="Run It" /></form>';
    } else {
        $success = reason_update_entity($stt->id(), $reason_user_id, array('custom_content_handler' => 'site_type.php'));
        if ($success) {
            echo '<p>Successfully updated site types to use new content manager</p>';
        } else {
            echo '<p>Unable to update site type to use new content manager. Please see the errors triggered (or the Reason error log) to identify why it did not work. Alternately, you can manually update this Reason instance. Here\'s how:</p>';
            echo '<ol><li>Log in to Reason</li><li>Go into the Master Admin</li><li>Choose "Types"</li><li>Find the type "Site Type" and click Edit</li><li>Choose "Site Type" on the Content Manager field</li><li>Save and finish</li></ol>';
        }
    }
}
echo '<p><a href="index.php">Back to 4.0b4 to 4.0b5 upgrades</a></p>';
?>
</body>
</html>
コード例 #11
0
 function stats_link()
 {
     // if using google analytics don't show Stats
     if (!$this->show['analytics']) {
         if (defined('REASON_STATS_URI_BASE') && REASON_STATS_URI_BASE != '') {
             $site = new entity($this->site_id);
             if ($site->get_value('unique_name')) {
                 $show = false;
                 if ($site->get_value('site_state') == 'Live') {
                     $show = true;
                 } else {
                     $es = new entity_selector();
                     $es->add_right_relationship($site->id(), relationship_id_of('site_archive'));
                     $es->add_relation('site_state = "Live"');
                     $es->set_num(1);
                     $sites = $es->run_one(id_of('site'), 'Archived');
                     if (!empty($sites)) {
                         $show = true;
                     }
                 }
                 if ($show) {
                     $link = REASON_STATS_URI_BASE;
                     if (function_exists('posix_uname')) {
                         $uname = posix_uname();
                         $uname_host = $uname['nodename'];
                     } else {
                         $uname_host = php_uname('n');
                     }
                     $link .= strtolower($uname_host) . '/';
                     $link .= $_SERVER['HTTP_HOST'] . '/';
                     $link .= $site->get_value('unique_name') . '/';
                     return $link;
                 }
             }
         }
     }
     return false;
 }
コード例 #12
0
ファイル: tickler.php プロジェクト: hunter2814/reason_package
}
if ($pub->get_value('type') != id_of('publication_type')) {
    die('The publication provided is not, in fact, a publication' . "\n");
}
$days = (int) $args['days'];
if (empty($days)) {
    die('Please provide days as an integer (e.g. 1, 2, 3, or 73)' . "\n");
}
$time = strtotime('-' . $days . ' days');
if (empty($time)) {
    die('Something appears to be amiss -- no time value was able to be resolved from the number of days provided' . "\n");
}
$datetime = date('Y-m-d H:i:s', $time);
$es = new entity_selector();
$es->add_type(id_of('news'));
$es->add_left_relationship($pub->id(), relationship_id_of('news_to_publication'));
$es->add_relation('`datetime` >= "' . $datetime . '"');
$es->set_num(1);
$posts = $es->run_one();
if (empty($posts)) {
    echo 'No new posts on publication id ' . $pub->id() . ' (' . $pub->get_value('name') . ') since ' . $datetime . '.' . "\n";
    if (!empty($args['emails'])) {
        $message = 'FYI, there are currently no recent posts on the Reason publication "' . $pub->get_value('name') . '."' . "\n\n";
        $message .= 'You are signed up to receive notices when this publication has not been updated in the last ' . $days . ' days.' . "\n\n";
        $message .= 'It may be time to add a new post!' . "\n\n";
        $message .= 'Click here to add posts to this publication: http://' . REASON_WEB_ADMIN_PATH . '?site_id=' . get_owner_site_id($pub->id()) . '&type_id=' . id_of('news') . "\n\n";
        $message .= 'If you are no longer responsible for this publication, please contact a Reason administrator to have this email sent to someone else.' . "\n\n";
        $message .= 'Thank you!' . "\n\n";
        mail($args['emails'], 'Reason Publication Reminder', $message, 'From: <*****@*****.**>');
        echo 'Message sent to ' . $args['emails'] . "\n";
    }
コード例 #13
0
	/**
	 * Get a page on the site for a given category
	 *
	 * @param entity $category
	 * @return entity $page
	 */
	function _get_page_for_category($category)
	{
		$ps = new entity_selector($this->site_id);
		$ps->add_type( id_of('minisite_page') );
		$ps->add_left_relationship($category->id(), relationship_id_of('page_to_category'));
		$ps->add_relation('entity.id != "'.addslashes($this->page_id).'"');
		$ps->set_num(1);
		$pages = $ps->run_one();
		if(!empty($pages))
			return current($pages);
		else
			return false;
	}
コード例 #14
0
ファイル: events.php プロジェクト: natepixel/reason_package
	/**
	 * Get the audiences for a given event entity
	 *
	 * Returned audience entities are sweetened with the value _link, containing an html-encoded URL
	 *
	 * @param object $e event entity
	 * @return array audience entities
	 */
	function get_event_audiences($e)
	{
		$audiences = array();
		$es = new entity_selector();
		$es->description = 'Selecting audiences for event';
		$es->limit_tables();
		$es->limit_fields();
		$es->enable_multivalue_results();
		$es->add_type( id_of('event_type'));
		$es->add_relation('entity.id = ' . $e->id());
		$es->add_left_relationship_field('event_to_audience', 'entity', 'id', 'aud_ids');
		$with_audiences = $es->run_one();
		if (!empty($with_audiences))
        {
        	$audiences = array();
        	$event = reset($with_audiences);
        	$aud_ids = $event->get_value('aud_ids');
        	$aud_ids = is_array($aud_ids) ? $aud_ids : array($aud_ids);
        	foreach( $aud_ids AS $aud_id )
        	{
        		$aud = new entity($aud_id);
        		$aud->set_value('_link', $this->construct_link(array('audience'=>$aud->id(),'no_search'=>'1'), false));
        		$audiences[$aud_id] = $aud;
        	}
        }
        return $audiences;
	}
コード例 #15
0
ファイル: site.php プロジェクト: hunter2814/reason_package
 function run()
 {
     echo '<div id="siteIntro">' . "\n";
     $e = new entity($this->admin_page->site_id);
     echo '<div id="siteNotices">' . "\n";
     if ($e->get_value('site_state') == "Not Live" && $e->get_value('unique_name') != 'master_admin') {
         echo '<div class="notLiveNotice"><h4>This site is not live.</h4><p>Among other things, that means that it\'s excluded from search engines (so people won\'t stumble upon a site that isn\'t ready for public consumption).</p>' . "\n";
         if (user_can_edit_site($this->admin_page->user_id, id_of('master_admin'))) {
             echo '<p><a href="' . $this->admin_page->make_link(array('site_id' => id_of('master_admin'), 'type_id' => id_of('site'), 'id' => $e->id(), 'cur_module' => 'Editor')) . '">Edit this site</a></p>' . "\n";
         } else {
             echo '<p>Please contact ' . REASON_CONTACT_INFO_FOR_CHANGING_USER_PERMISSIONS . ' when you are ready to make this site live.</p>' . "\n";
         }
         echo '</div>' . "\n";
     }
     if ($e->get_value('description')) {
         echo '<div id="siteDesc">' . "\n";
         if (strip_tags($e->get_value('description')) == $e->get_value('description')) {
             echo nl2br($e->get_value('description'));
         } else {
             echo $e->get_value('description');
         }
         echo '</div>' . "\n";
     }
     $sites = $this->admin_page->get_sites();
     if (count($sites) == 1) {
         parent::run();
     }
     echo '</div>' . "\n";
     echo '<div id="guide">' . "\n";
     $es = new entity_selector();
     $es->add_type(id_of('type'));
     $es->add_right_relationship($e->id(), relationship_id_of('site_to_type'));
     $es->limit_tables();
     $es->limit_fields();
     $non_editable_es = carl_clone($es);
     $non_editable_es->add_right_relationship($e->id(), relationship_id_of('site_cannot_edit_type'));
     $noneditable_types = $non_editable_es->run_one();
     if (!empty($noneditable_types)) {
         $es->add_relation('entity.id NOT IN (' . implode(',', array_keys($noneditable_types)) . ')');
     }
     $es->set_order('entity.name ASC');
     $types = $es->run_one();
     if (array_key_exists(id_of('minisite_page'), $types)) {
         $page_type_array[id_of('minisite_page')] = $types[id_of('minisite_page')];
         unset($types[id_of('minisite_page')]);
         $types = array_merge($page_type_array, $types);
     }
     echo '<ul>' . "\n";
     foreach ($types as $type) {
         $es = new entity_selector($e->id());
         $es->set_sharing('owns');
         $es->add_type($type->id());
         $es->limit_tables();
         $es->limit_fields();
         $es->set_order('entity.last_modified DESC');
         if (reason_user_has_privs($this->admin_page->user_id, 'edit')) {
             $state = 'Live';
             $state_link_val = 'live';
         } else {
             $state = 'Pending';
             $state_link_val = 'pending';
         }
         $ents = $es->run_one($type->id(), $state);
         $ents_count = count($ents);
         $name = $type->get_value('plural_name') ? $type->get_value('plural_name') : $type->get_value('name');
         echo '<li class="' . $type->get_value('unique_name') . '" style="list-style-image:url(' . reason_get_type_icon_url($type) . ')">';
         echo '<h4><a href="' . $this->admin_page->make_link(array('type_id' => $type->id(), 'cur_module' => 'Lister', 'state' => $state_link_val)) . '">' . $name . '</a> <span class="count">(' . $ents_count . ')</span></h4>' . "\n";
         if (!empty($ents)) {
             echo '<div class="recent">' . "\n";
             echo 'Recently edited:' . "\n";
             echo '<ul>' . "\n";
             $i = 1;
             foreach ($ents as $ent_id => $ent) {
                 if ($i > 3) {
                     break;
                 }
                 $name = strip_tags($ent->get_display_name());
                 if (empty($name)) {
                     $name = '[unnamed]';
                 }
                 echo '<li class="item' . $i . '"><a href="' . $this->admin_page->make_link(array('type_id' => $type->id(), 'id' => $ent_id, 'cur_module' => 'Editor')) . '">' . $name . '</a></li>' . "\n";
                 $i++;
             }
             echo '</ul>' . "\n";
             echo '</div>' . "\n";
         }
         echo '</li>' . "\n";
     }
     echo '</ul>' . "\n";
     echo '</div>' . "\n";
     echo '</div>' . "\n";
 }
コード例 #16
0
ファイル: finish.php プロジェクト: hunter2814/reason_package
 function init()
 {
     if (!$this->admin_page->id) {
         return false;
     }
     //these next few lines check the entity to make sure it has everything it needs
     $this->load_content_manager();
     $this->check_entity_values();
     $this->get_required_relationships();
     if (!empty($this->req_rels)) {
         $this->check_required_relationships();
     }
     /* the new finish stuff */
     // new_entity stuff
     // figure out if the entity is new and store that so we can change the data in the database but still know what's going on
     $temp = new entity($this->admin_page->id, false);
     if ($temp->get_value('new')) {
         $this->new_entity = true;
     } else {
         $this->new_entity = false;
     }
     // when finishing an entity, we want to ensure that it is live and not new (unless it is a page)
     if ($this->admin_page->type_id != id_of('minisite_page') && $temp->get_value('state') == 'Pending' && reason_user_has_privs($this->admin_page->user_id, 'publish')) {
         $update_values['state'] = 'Live';
         if (!empty($this->disco_item)) {
             $this->disco_item->set_value('state', "Live");
         }
     }
     if ($temp->get_value('new') != '0') {
         $update_values['new'] = 0;
         if (!empty($this->disco_item)) {
             $this->disco_item->set_value('new_entity', 0);
         }
     }
     if (!empty($update_values)) {
         reason_update_entity($this->admin_page->id, $this->admin_page->user_id, $update_values, false);
         // archive, yes?
     }
     $original = new entity($this->admin_page->id, false);
     $original->get_values();
     // get archive relationship id
     $q = 'SELECT id FROM allowable_relationship WHERE name LIKE "%archive%" AND relationship_a = ' . $this->admin_page->type_id . ' AND relationship_b = ' . $this->admin_page->type_id;
     $r = db_query($q, 'Unable to get archive relationship.');
     $row = mysql_fetch_array($r, MYSQL_ASSOC);
     $this->rel_id = $row['id'];
     // get archives
     $es = new entity_selector($this->admin_page->site_id);
     $es->add_type($this->admin_page->type_id);
     $es->add_right_relationship($this->admin_page->id, $this->rel_id);
     $es->add_relation('last_modified = "' . $original->get_value('last_modified') . '"');
     $es->set_num(1);
     $similar_archived = $es->run_one('', 'Archived');
     // if the entity has in fact been changed, actually create the relationship
     if (empty($similar_archived)) {
         $archived_id = duplicate_entity($original, false, true, array('state' => 'Archived'));
         create_relationship($this->admin_page->id, $archived_id, $this->rel_id);
     }
     // DETERMINE WHERE TO GO
     if (!empty($this->admin_page->request[CM_VAR_PREFIX . 'type_id'])) {
         // this code block is intended to associate a new entity with the context entity upon finish - it once created backwards relationships IF we reached an
         // entity with get_value('new') = 1 from the reverse associator. This needs fixin. We do so by running this section of code only in the case where
         // the "old" module was the associator (the only module that allows the creation of new entities than need a relationship back to the a side entity
         // whose context is relevant.
         if ($this->new_entity && $this->admin_page->request[CM_VAR_PREFIX . 'cur_module'] == 'Associator') {
             $rel_info = reason_get_allowable_relationship_info($this->admin_page->request[CM_VAR_PREFIX . 'rel_id']);
             $entity_a = new entity($this->admin_page->request[CM_VAR_PREFIX . 'id']);
             $entity_b = new entity($this->admin_page->request['id']);
             // lets do a bit of additional sanity checking.
             if ($rel_info['relationship_a'] == $entity_a->get_value('type') && $rel_info['relationship_b'] == $entity_b->get_value('type')) {
                 if ($rel_info['connections'] == 'one_to_many') {
                     $this->delete_existing_relationships();
                 }
                 create_relationship($entity_a->id(), $entity_b->id(), $rel_info['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);
     } elseif (!empty($this->admin_page->request['next_entity'])) {
         $link = $this->admin_page->make_link(array('cur_module' => 'Editor', 'id' => $this->admin_page->request['next_entity']));
     } 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'));
     }
     // before redirecting, check to see if there are any custom finish actions associated with this type.
     // the entity_type variable is declared earlier in the check_entity_values method.
     //Run any custom finish actions specified in the content manager
     if (!empty($this->disco_item)) {
         $this->disco_item->run_custom_finish_actions($this->new_entity);
     }
     if ($this->entity_type->get_value('finish_actions')) {
         $finish_actions_filename = $this->entity_type->get_value('finish_actions');
     } else {
         $finish_actions_filename = 'default.php';
     }
     reason_include_once('finish_actions/' . $finish_actions_filename);
     $finish_action_class_name = $GLOBALS['_finish_action_classes'][$finish_actions_filename];
     $fac = new $finish_action_class_name();
     $vars = array('site_id' => $this->admin_page->site_id, 'type_id' => $this->admin_page->type_id, 'id' => $this->admin_page->id, 'user_id' => $this->admin_page->user_id);
     $fac->init($vars);
     $fac->run();
     header('Location: ' . unhtmlentities($link));
     die;
 }
コード例 #17
0
 /**
  * Deletes any existing media in Kaltura that corresponds with this media work.
  */
 function _remove_existing_media($entry_id)
 {
     // First grab all related Media Files
     $es = new entity_selector();
     $es->add_type(id_of('av_file'));
     $es->add_right_relationship($this->manager->get_value('id'), relationship_id_of('av_to_av_file'));
     $media_files = $es->run_one();
     $user = new entity($this->manager->admin_page->user_id);
     // Delete actual Reason entities for media files
     foreach ($media_files as $entity) {
         reason_expunge_entity($entity->id(), $user->id());
     }
     // Remove Entries from Kaltura
     $this->kaltura_shim->delete_media($entry_id, $user->get_value('name'));
 }
コード例 #18
0
$notification = $zencoder->notifications->parseIncoming();
$output = current($notification->job->outputs);
$media_work = get_media_work($notification->job->id);
if ($media_work) {
    $user = new entity($media_work->get_value('created_by'));
    $netid = $user->get_value('name');
    // first check to see if all successfully transcoded
    if ($output->state == "skipped") {
        echo 'This output was skipped because of conditional outputs.' . "\n";
        $output = current($notification->job->outputs);
        $label = $output->label;
        $label_parts = explode('_', $label);
        $format = reset($label_parts);
        $id = end($label_parts);
        echo 'Expunging Media File ' . $id . "\n";
        reason_expunge_entity($id, $user->id());
    } elseif ($output->state != "finished") {
        echo 'Output ' . $output->id . ' for job ' . $notification->job->id . ' not successful in encoding.' . "\n";
        echo 'There were errors or cancellations in the transcoding process.' . "\n";
        set_error($media_work);
    } else {
        if ($media_work->get_value('av_type') == 'Video') {
            process_video($media_work, $notification, $mime_type_map, $netid);
        } elseif ($media_work->get_value('av_type') == 'Audio') {
            process_audio($media_work, $notification, $mime_type_map, $netid);
        } else {
            echo 'Media Work with id ' . $media_work->id() . ' has invalid av_type.' . "\n";
            set_error($media_work);
        }
    }
} else {
コード例 #19
0
ファイル: policy.php プロジェクト: natepixel/reason_package
		function page_link( $policy ) // {{{
		{
			if( !is_object( $policy ) )
				$policy = new entity( $policy );
			
			$link = carl_make_link(array('policy_id'=>$policy->id()));

			return $link;
		}
コード例 #20
0
ファイル: theme.php プロジェクト: natepixel/reason_package
	function add_complete($unique_name,$name,$css = array(),$template_name,$user_id)
	{
		if($this->get_id())
		{
			trigger_error('add_complete method may only be called on a reasonTheme that does not yet have an ID assigned.');
			return false;
		}
		$all_ok = true;
		$output =  '<h4>Adding theme: '.$unique_name.'</h4>';
		$output .= '<ol>';
		if(empty($template_name))
		{
			$template_name = 'default';
		}
		if(empty($name))
		{
			$name = prettify_string($unique_name);
		}
		$template = get_template_by_name($template_name);
		if(empty($template))
		{
			$all_ok = false;
			$template_id = reason_add_template($template_name);
			if(!empty($template_id))
			{
				$template = new entity($template_id);
				$output .= '<li>Template created ('.$template_name.', id '.$template->id().')</li>';
			}
			else
			{
				$output .= '<li>Unable to create template '.$template_name.'. The template file may not be placed correctly.';
				if($this->test_mode)
				{
					$output .= ' Would abort theme addition.';
				}
				else
				{
					$output .= ' Aborting theme addition.';
				}
				$output .= '</li></ol>';
				return array('success'=>false,'report'=>$output);
			}
		}
		else
		{
			$output .= '<li>Template found ('.$template_name.', id '.$template->id().')</li>';
		}
		
		$theme_id = id_of($unique_name);
		if(!$theme_id)
		{
			$all_ok = false;
			$output .= '<li>Theme with unique name '.$unique_name.' needs to be created</li>';
			if(!$this->test_mode)
			{
				$theme_id = $this->create($unique_name,$name,$template->id(),$user_id);
				if(!$theme_id)
				{
					$output .= '<li>Theme '.$name.' unable to be created; aborting theme addition</li></ol>';
					return array('success'=>false,'report'=>$output);
				}
				else
				{
					$output .= '<li>Theme with unique name '.$unique_name.' created</li>';
				}
			}
			else
			{
				$output .= '<li>Would have attempted to create theme entity.</li>';
			}
		}
		else
		{
			$this->set_id($theme_id);
		}
		
		if($this->get_template_id() != $template->id())
		{
			$all_ok = false;
			$output .= '<li>Current theme template id ('.$this->get_template_id().') not the same as specified in update ('.$template->id().').</li>';
			if($this->test_mode)
			{
				$output .= '<li>Would have set theme template to be id '.$template->id().'</li>';
			}
			else
			{
				if($this->attach_template($template->id()))
				{
					$output .= '<li>Attached template id '.$template->id().' to '.$unique_name.'.</li>';
				}
				else
				{
					$output .= '<li>Unable to attach template for some reason. Aborting theme addition.</li>';
					return array('success'=>false,'report'=>$output);
				}
			}
				
		}
		
		$retrieved_css_entities = array();
		
		foreach($css as $css_name=>$css_info)
		{
			$output .= '<li>CSS: '.$css_name.'<ol>';
			if(empty($css_info['url']))
			{
				$output .= '<li>'.$css_name.' has no url specified; skipping this css item</li></ol></li>';
				continue;
			}
			else
			{
				$css_url = $css_info['url'];
			}
			if(empty($retrieved_css_entities[$css_url]))
			{
				$es = new entity_selector();
				$es->add_type(id_of('css'));
				$es->add_relation('url = "'.addslashes($css_url).'"');
				$es->set_num(1);
				$css_ents = $es->run_one();
				if(!empty($css_ents))
				{
					$retrieved_css_entities[$css_url] = current($css_ents);
				}
			}
			if(empty($retrieved_css_entities[$css_url]))
			{
				$all_ok = false;
				//create css & get id of css
				if($this->test_mode)
				{
					$output .= '<li>Would have created a css entity for '.$css_url.' and attached it to the theme</li>';
				}
				else
				{
					$css_id = reason_create_entity(id_of('master_admin'), id_of('css'), $user_id, $css_name, $css_info);
					if($css_id)
					{
						$output .= '<li>Created a css entity for '.$css_url.'</li>';
					}
					else
					{
						$output .= '<li>Tried to create a css entity for '.$css_url.' but was unsuccessful. Aborting creation of this css item.</li>';
						continue;
					}
				}
			}
			else
			{
				$css_id = $retrieved_css_entities[$css_url]->id();
				$output .= '<li>A css entity exists for '.$css_url.' at Reason id '.$css_id.'</li>';
			}
			if(!empty($css_id))
			{
				// attach css
				$attached_css = $this->get_css();
				if(empty($attached_css[$css_id]))
				{
					$all_ok = false;
					if($this->test_mode)
					{
						$output .= '<li>Would have attached css at '.$css_url.' to '.$unique_name.'.</li>';
					}
					else
					{
						if($this->attach_css($css_id))
						{
							$output .= '<li>Attached css at '.$css_url.' to '.$unique_name.'.</li>';
						}
						else
						{
							$output .= '<li>Unable to attach css at '.$css_url.' to '.$unique_name.'; perhaps there is an unknown problem.</li>';
						}
					}
				}
				else
				{
					$output .= '<li>Css at '.$css_url.' already attached to '.$unique_name.'</li>';
				}
				$output .= '</ol></li>';
			}
		}
		if($all_ok)
		{
			$output .= '<li><strong>Everything OK.</strong> The theme '.$unique_name.' appears to be set up correctly.  No database changes are needed.</li>';
		}
		$output .= '</ol>';
		return array('success'=>true,'report'=>$output);
	}
コード例 #21
0
 /**
  * If the news type feed_url_string is no longer news,
  * still create a rewrite for the old style news page so that the old link does not break.
  *
  * @author Nathan White
  * @todo consider removal at some future point
  */
 function _update_old_style_news()
 {
     $news_type_entity = new entity(id_of('news'));
     if ($news_type_entity->get_value('feed_url_string') != 'news') {
         $this->debug('updating old style news');
         fputs($this->_fp, "\n# old style news rewrite\n\n") or trigger_error('Unable to write to htaccess', HIGH);
         fputs($this->_fp, 'RewriteRule ^' . MINISITE_FEED_DIRECTORY_NAME . '/news$ ' . FEED_GENERATOR_STUB_PATH . '?type_id=' . $news_type_entity->id() . '&site_id=' . $this->site->id() . "&feed=news\n") or trigger_error('Unable to write to htaccess file', HIGH);
     }
 }
コード例 #22
0
ファイル: entity.php プロジェクト: hunter2814/reason_package
 /**
  * Returns true if entity is owned or borrowed by site in first argument
  * @param integer $site_id
  * @return bool
  */
 function owned_or_borrowed_by($site_id)
 {
     $site = new entity($site_id);
     $owner = $this->get_owner();
     if ($owner->id() == $site->id() || $this->has_right_relation_with_entity($site, get_borrows_relationship_id($this->get_value('type')))) {
         return true;
     } else {
         return false;
     }
 }
コード例 #23
0
ファイル: module.php プロジェクト: natepixel/reason_package
		/**
		 * Checks to make sure that the given news item is OK to display.
		 * 
		 * This should return true if the entity looks OK to be shown and false if it does not.
		 *
		 * It also does some checks and may redirect to make URLs sane (IE link given with wrong section).
		 *
		 * @param entity $entity news_item_entity
		 * @return boolean True if OK
		 */
		function further_checks_on_entity( $entity )
		{
			if(empty($this->items[$entity->id()]))
			{
				if($entity->get_value('status') == 'pending' && !user_has_access_to_site($this->site_id)) return false;
				$publication_check = ($entity->has_left_relation_with_entity($this->publication, 'news_to_publication'));
				// check that issue id is present and validated if the publication has issue
				if ($this->publication->get_value('has_issues') == 'yes')
				{
					$issue_check = (!empty($this->request['issue_id']) && ($this->request['issue_id'] == $this->issue_id));
				}
				else $issue_check = true;
				if ($publication_check && $issue_check) return true;
				else return false;
			}
			else
			{
				return true;
			}
		}
コード例 #24
0
	public function process( $disco )
	{
		$s = get_microtime();
		$q = 'SELECT * from entity where state = "Live" AND entity.id > ' . (int) $disco->get_value('starting_id') . ' LIMIT ' . (int) $disco->get_value('num_to_process');
		$result = db_query($q);
		$num_rows = mysql_num_rows($result);
		$updated_count = 0;
		if ($num_rows > 0)
		{
			while ($row = mysql_fetch_assoc($result))
			{
				$eid = $row['id'];
				$e = new entity($eid);
				$values = $e->get_values();
				$hash = md5(serialize($values));
				$updated = reason_update_entity($e->id(), $this->user_id(), $values, false);
				if ($updated) $updated_count++;
			}
			$disco->set_value('starting_id', $eid);
		}
		$e = get_microtime();
		
		$complete = ($num_rows < $disco->get_value('num_to_process'));
		
		// Lets show our results
		echo '<div id="results">';
		echo '<h3>Results</h3>';
		echo '<ul>';
		echo '<li><strong>Checked - </strong> <span class="num_checked">' . $num_rows . '</span></li>';
		echo '<li><strong>Updated - </strong> <span class="num_updated">' . $updated_count . '</span></li>';
		echo '<li><strong>Processing Time (ms) - </strong> ' . round( (($e - $s) * 1000) ) . '</li>';
		echo '</ul>';
		if (!$complete)
		{
			echo '<p>The starting ID has been updated to <span class="starting_id">' . $eid . '</span></p>';
			$disco->actions = array('Continue Entity Sanitization');
		}
		else
		{
			$status = '<p><strong>Processing is complete.</strong></p>';
			$disco->add_element('status', 'comment', array('text' => $status));
			$disco->actions = array();
		}
		echo '</div>';
		echo '<hr/>';
	}
コード例 #25
0
	/** duplicate_entity( $id, $dup_relationships = true, $maintain_dates = false, $overrides = array() ) {{{
	 *	Duplicates entity with id = $id.
	 *
	 *	Specifically, copies all fields of an entity to a new id.  If dup_relationships
	 *	is true, also copies all relationships, replacing the old id with the new inserted one.
	 *
	 *	@param	$id						ID of entity to duplicate
	 *									OR an entity object to duplicate
	 *	@param	$dup_relationships		Bool that determines whether to duplicate relationships or not
	 *	@param	$maintain_dates			Bool that determines whether to 
	 *	@param	$overrides				array of field => value pairs to override any values for the new entity
	 *	@return							the new, duplicated entity id
	 */
	function duplicate_entity( $id, $dup_relationships = true, $maintain_dates = false, $overrides = array() )
	{
		// get all values and structure from existing object
		if( is_object( $id ) AND get_class( $id ) == 'entity' )
			$e = $id;
		else
			$e = new entity( $id );

		// get the site that owns this entity
		$site = $e->get_owner();
		
		// get the tables used by this type/entity
		$tables = get_entity_tables_by_id( $e->id() );

		//! start of new code (see commented note below)

		$ignored_fields = array( 'id', 'name', 'type', 'last_edited_by' );

		if( !$maintain_dates )
		{
			$ignored_fields[] = 'last_modified';
			$ignored_fields[] = 'creation_date';
		}

		// Don't ignore values set as overrides
		foreach ($ignored_fields as $key => $val)
			if (isset($overrides[$val])) unset ($ignored_fields[$key]);
		
		// convert values of entity to tabled-array structure, make sure to ignore proper fields
		$values = values_to_tables( $tables, array_merge( $e->get_values(), $overrides ), $ignored_fields );
		
		// create new entity record
		$new_entity_id = create_entity(
			$site->id(), 
			$e->get_value('type'), 
			$e->get_value('last_edited_by'), 
			$e->get_value('name'), 
			$values
		);

		// copy relationships
		if( $dup_relationships )
		{
			// make new left relationships
			$left_rels = $e->get_left_relationships();
			foreach( $left_rels AS $rel_type => $rel_obj )
			{
				if( is_int( $rel_type ) )
				{
					foreach( $rel_obj AS $r )
						create_relationship( $new_entity_id, $r->id(), $rel_type );
				}
			}
			// make new right relationships
			$right_rels = $e->get_right_relationships();
			foreach( $right_rels AS $rel_type => $rel_obj )
			{
				if( is_int( $rel_type ) )
				{
					foreach( $rel_obj AS $r )
						create_relationship( $r->id(), $new_entity_id, $rel_type );
				}
			}
		}

		// return the new entity
		return $new_entity_id;
	} // }}}
コード例 #26
0
ファイル: util.php プロジェクト: hunter2814/reason_package
/**
 * Factory function for grabbing and setting up the theme customizer for a given site
 *
 * @param mixed $site site entity or ID
 * @param mixed $theme theme entity or ID; if not provided Reason will determine the current theme
 * @return mixed object or false if no customizer
 */
function reason_get_theme_customizer($site, $theme = NULL)
{
    if (is_numeric($site)) {
        $site = new entity($site);
    }
    if (empty($theme)) {
        $es = new entity_selector();
        $es->add_type(id_of('theme_type'));
        $es->add_right_relationship($site->id(), relationship_id_of('site_to_theme'));
        $es->set_num(1);
        $tmp = $es->run_one();
        if (!empty($tmp)) {
            $theme = current($tmp);
        } else {
            return false;
        }
    } elseif (is_numeric($theme)) {
        $theme = new entity($theme);
    }
    if ($theme->get_value('theme_customizer')) {
        reason_include_once('theme_customizers/' . $theme->get_value('theme_customizer') . '.php');
        if (!empty($GLOBALS['reason_theme_customizers'][$theme->get_value('theme_customizer')])) {
            if (class_exists($GLOBALS['reason_theme_customizers'][$theme->get_value('theme_customizer')])) {
                if ($site->get_value('theme_customization')) {
                    $all_customization_data = json_decode($site->get_value('theme_customization'));
                    $theme_id = $theme->id();
                    if (isset($all_customization_data->{$theme_id})) {
                        $customization_data = $all_customization_data->{$theme_id};
                    }
                }
                if (empty($customization_data)) {
                    $customization_data = new stdClass();
                }
                $customizer = new $GLOBALS['reason_theme_customizers'][$theme->get_value('theme_customizer')]();
                $customizer->set_customization_data($customization_data);
            } else {
                trigger_error('Theme customizer "' . $theme->get_value('theme_customizer') . '" not registered properly.');
                $customizer = false;
            }
        } else {
            trigger_error('Theme customizer "' . $theme->get_value('theme_customizer') . '" not found or not registered properly.');
            $customizer = false;
        }
    }
    return isset($customizer) ? $customizer : false;
}
コード例 #27
0
 function update_section_content_manager()
 {
     $type = new entity(id_of('news_section_type'));
     if ($type->get_value('custom_content_handler')) {
         echo '<p>Section type already has a content manager. No need to update.</p>' . "\n";
         return;
     }
     if ($this->mode == 'run') {
         if (reason_update_entity($type->id(), $this->reason_user_id, array('custom_content_handler' => 'news_section.php'))) {
             echo '<p>Section content manager successfully updated</p>' . "\n";
         } else {
             echo '<p>Section content manager not updated. Go to master admin -&gt; Types -&gt; News Section and set the Content Manger field to "News Section."</p>' . "\n";
         }
     } else {
         echo '<p>Would have updated the section type to use the content manager news_section.php</p>' . "\n";
     }
 }
コード例 #28
0
 function get_post_list_markup()
 {
     $markup_string = '';
     $site_id = $this->passed_vars['site']->id();
     $links = $this->passed_vars['links_to_current_publications'];
     $pub_ids = array_keys($links);
     $pub_ents = array();
     /* $category_list = array(
      *     'some_pub_id' => array(
      *         'some_cat',
      *         'another_cat'
      *     ),
      *     ...
      * );
      */
     // This is about to become a monstrous, horrendous hack.
     // Probably the least efficient, most annoying code I've
     // ever written, no joke. It is gross.
     $category_list = array();
     $flat_cat_list = array();
     $duplicate_cat_list = array();
     // For each publication scraped by this list
     foreach ($pub_ids as $pub) {
         // Get the pub entities and throw them in $pub_ents for their names later
         $pub_ents[$pub] = new entity($pub);
         // Return all news posts that belong to $pub, along with their categories
         $category_list[$pub] = array();
         $es = new entity_selector();
         $es->add_type(id_of('news'));
         $es->add_left_relationship($pub, relationship_id_of('news_to_publication'));
         $es->enable_multivalue_results();
         $es->add_left_relationship_field('news_to_category', 'entity', 'id', 'category_ids');
         //			$es->add_left_relationship_field('news_to_publication', 'entity', 'id', 'publication_ids');
         // For each news post returned
         foreach ($es->run_one() as $result) {
             // If it has multiple categories attached
             if (is_array($result->get_value('category_ids'))) {
                 // For each one
                 foreach ($result->get_value('category_ids') as $cat_id) {
                     // If this category hasn't been seen in this publication yet
                     if (!in_array($cat_id, array_keys($category_list[$pub]))) {
                         // Get its entity, and put it in an array that organizes it by pub.
                         $cat_ent = new entity($cat_id);
                         if ($cat_ent->get_value('state') == 'Live') {
                             $category_list[$pub][$cat_id] = $cat_ent;
                             // If we've seen this category name before at all
                             if (in_array($cat_ent->get_value('name'), $flat_cat_list)) {
                                 // Add it to the duplicate cat list.
                                 $duplicate_cat_list[$cat_id] = $cat_ent->get_value('name');
                             } else {
                                 // Just go ahead and add it to the flat_cat_list.
                                 $flat_cat_list[$cat_id] = $cat_ent->get_value('name');
                             }
                         }
                     }
                 }
                 // If there's only one category attached to the post, and we haven't seen it before in this publication
             } elseif (!in_array($result->get_value('category_ids'), array_keys($category_list[$pub]))) {
                 // Add it to the list!
                 $cat_ent = new entity($result->get_value('category_ids'));
                 if ($cat_ent->get_value('state') == 'Live') {
                     $category_list[$pub][$result->get_value('category_ids')] = $cat_ent;
                     // If we've seen this category name before at all
                     if (in_array($cat_ent->get_value('name'), $flat_cat_list)) {
                         // Add it to the duplicate cat list.
                         $duplicate_cat_list[$cat_end->id()] = $cat_ent->get_value('name');
                     } else {
                         // Just go ahead and add it to the flat_cat_list.
                         $flat_cat_list[$cat_ent->id()] = $cat_ent->get_value('name');
                     }
                 }
             }
         }
     }
     $markup_string .= '<h4 class="categoryHeading">More articles about...</h4>';
     $markup_string .= '<ul class="all_cats_links">';
     foreach ($pub_ids as $publication_id) {
         $publication_url = $links[$publication_id];
         foreach ($category_list[$publication_id] as $category) {
             $category_url = '?filters[1][type]=category&filters[1][id]=' . $category->id();
             $markup_string .= '<li class="' . $publication_id . '_cat"><a href="' . $publication_url . $category_url . '">' . $category->get_value('name');
             if (in_array($category->get_value('name'), $duplicate_cat_list)) {
                 $markup_string .= " (" . $pub_ents[$publication_id]->get_value("name") . ")";
             }
             $markup_string .= '</a></li>';
         }
     }
     $markup_string .= '</ul>';
     return $markup_string;
 }
コード例 #29
0
$media_file_id = !empty($_REQUEST['media_file_id']) ? (int) $_REQUEST['media_file_id'] : 0;
$media_work_id = !empty($_REQUEST['media_work_id']) ? (int) $_REQUEST['media_work_id'] : 0;
$hash = !empty($_REQUEST['hash']) ? (string) $_REQUEST['hash'] : '';
if (!$media_file_id || !$media_work_id || !$hash) {
    http_response_code(404);
    die;
}
$media_file = new entity($media_file_id);
if (!$media_file->get_values() || $media_file->get_value('type') != id_of('av_file')) {
    http_response_code(404);
    die;
}
# First, grab the media_work associated with the provided media file
$es = new entity_selector();
$es->add_type(id_of('av'));
$es->add_left_relationship($media_file->id(), relationship_id_of('av_to_av_file'));
$es->add_relation('`entity`.`id` = "' . addslashes($media_work_id) . '"');
$es->add_relation('`media_work`.`integration_library` != ""');
$es->set_num(1);
$works = $es->run_one();
if (empty($works)) {
    http_response_code(404);
    die;
}
$media_work = current($works);
# check to make sure the REQUEST var hash is correct
$displayer = MediaWorkFactory::media_work_displayer($media_work);
if ($displayer) {
    $displayer->set_media_work($media_work);
} else {
    http_response_code(404);
コード例 #30
0
ファイル: archive.php プロジェクト: hunter2814/reason_package
 function get_archive_name($id)
 {
     $edited_by_id = $this->history[$id]->get_value('last_edited_by');
     if (!empty($edited_by_id)) {
         $user = new entity($edited_by_id);
         if ($user->get_values()) {
             $name = $user->get_value('name');
         } else {
             $name = 'user id ' . $user->id();
         }
     } else {
         $name = '[unknown]';
     }
     if ($id == $this->current->id()) {
         return 'Current Version - ' . $name;
     } else {
         return prettify_mysql_timestamp($this->history[$id]->get_value('last_modified'), 'n/j/y, g:i a') . ' Version - ' . $name;
     }
 }