<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
<channel>

<title>Carleton College Reason Developer Zone FAQs</title>
<description>FAQs from Reason Developer Zone</description>
<link>http://apps.carleton.edu/opensource/reason/developers/faqs/</link>
<generator>Reason</generator>
<copyright>Carleton College, 2013</copyright>

<item>
<title>What exactly do left and right relationships means when using the entity selector?</title>
<description>&lt;p&gt;When using entity selectors, it can be confusing, especially for new reason programmers, to know which of these methods to use in a given situation:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;add_left_relationship&lt;/li&gt;
&lt;li&gt;add_left_relationship_field&lt;/li&gt;
&lt;li&gt;add_right_relationship&lt;/li&gt;
&lt;li&gt;add_right_relationship_field&lt;br /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;Why the Confusion???&lt;br /&gt;&lt;/h3&gt;
&lt;p&gt;The confusion typically revolves around whether to use the &quot;left&quot; or &quot;right&quot; versions of these methods. The words &quot;left&quot; or &quot;right&quot; in entity selector methods refer to which side of the relationship the type of entity being selected exists. Following these two rules should set you straight:&lt;br /&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;If the type you are selecting with your entity selector is on the right side of the relationship that you are referencing in the function, use the right hand version of the function.&lt;/li&gt;
&lt;li&gt;If the type you are selecting with your entity selector is on the left side of the relationship that your are referencing in the function, use the left hand version of the function.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;A Couple Examples&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Example 1:&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div class=&quot;callOut&quot;&gt;
&lt;p&gt;I am writing an entity selector which selects images attached to a page. The relationship I'm selecting the images across is the minisite_page_to_image relationship. From the naming convention used for relationship names, I know that the minisite_page_to_image relationship has minisite_pages on the left, and images on the right. I use the method add_right_relationship. The entity selector would look like this:&lt;/p&gt;
&lt;pre&gt;
$es = new entity_selector($site_id);&lt;br /&gt;$es-&amp;gt;add_type(id_of('image'));&lt;br /&gt;$es-&amp;gt;add_right_relationship($page_id, relationship_id_of('minisite_page_to_image'));&lt;br /&gt;$result = $es-&amp;gt;run_one();
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Example 2:&lt;/strong&gt;&lt;/p&gt;
&lt;div class=&quot;callOut&quot;&gt;
&lt;p&gt;I am writing an entity selector to grab all the pages in a site that have images, along with the image ids. So - I want to select page entities, augmented with the image ids. The relationship I'm selecting across is minisite_page_to_image. In this relationship, pages are on the left side, images on the right. I'm going to use the method add_left_relationship_field since the type the entity selector is grabbing is on the left side of the relationship. The entity selector would look like this:&lt;/p&gt;
&lt;pre&gt;
$es = new entity_selector($site_id);&lt;br /&gt;$es-&amp;gt;add_type(id_of('minisite_page'));&lt;br /&gt;$es-&amp;gt;enable_multivalue_results();&lt;br /&gt;$es-&amp;gt;add_left_relationship_field('minisite_page_to_image', 'entity', 'id', 'image_id');&lt;br /&gt;$result = $es-&amp;gt;run_one();
&lt;/pre&gt;&lt;/div&gt;
&lt;h3&gt;Something To Ponder&lt;/h3&gt;
&lt;p&gt;Interestingly, the entity selector could (and probably should) be reworked to have singular methods for adding a relationship or relationship_field. In the above example, I know I am selecting pages. I also know the relationship I am selecting over. It can be determined programatically that add_left_relationship_field is needed in this case, since pages are on the left side of the relationship. The only situation where the selection is ambiguous is when the relationship is between two items of the same type. Makes the brain hum.&lt;/p&gt;</description>
<pubDate>Thu, 19 Jun 2008 14:31:02 -0500</pubDate>
<link>http://apps.carleton.edu/opensource/reason/developers/faqs/?faq_id=125341</link>
</item>

<item>
<title>How do I set up a new site?</title>
<description>&lt;p&gt;You need to be an administrator in the Reason instance with access to the &quot;Master Admin&quot; site. From the Master Admin site, choose the &quot;Sites&quot; option on the left-hand menu, and then choose &quot;Create a new site.&quot;&lt;/p&gt;
&lt;p&gt;After choosing options for your site, Reason will create the directory in the file system along with the necessary .htaccess rules.&lt;/p&gt;</description>
<pubDate>Fri, 02 Nov 2007 17:44:24 -0500</pubDate>
<link>http://apps.carleton.edu/opensource/reason/developers/faqs/?faq_id=125330</link>
</item>

<item>
<title>How does Reason's session system work?</title>
<description>&lt;p&gt;Reason's session system is pretty integrated with the Minisite and Minisite module system. If you are working in that context, the session is usually available as $this-&amp;gt;session in the template or the module. If you are not in that system, it can be access from the global function get_reason_session(). The form that you get the session is fairly specific:&lt;/p&gt;
&lt;pre&gt;
$sess =&amp;amp; get_reason_session();
&lt;/pre&gt;
&lt;p&gt;The ampersand is important because the function keeps a single static copy of the session. This is to avoid having multiple instances of the session object floating around while Reason is running.&lt;/p&gt;
&lt;p&gt;The session system has a couple of requirements - data can only be stored and accessed from the session if the connection is secure to avoid session hijacking problems as well as just keeping things more secure. If a script tries to do anything to a session object while on an insecure page, a warning will be triggered. You can use on_secure_page() to check if you are secure or not. You can also use&lt;/p&gt;
&lt;pre&gt;
$sess-&amp;gt;exists();
&lt;/pre&gt;
&lt;p&gt;to see if a session has been started. This can be used on an insecure page without error. So, if a session exists and we're on a secure page, we can then start the session. Most code looks something like this:&lt;/p&gt;
&lt;pre&gt;
if( $sess-&amp;gt;exists() AND on_secure_page() )&lt;br /&gt;
{&lt;br /&gt;
     $sess-&amp;gt;start();&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if( $sess-&amp;gt;has_started() )&lt;br /&gt;
{&lt;br /&gt;
   $username = $sess-&amp;gt;get( 'username' );&lt;br /&gt;
}
&lt;/pre&gt;
&lt;p&gt;Notice how I made sure the session was started with has_started(). If it has started, you know that you are secure and the session exists.&lt;/p&gt;
&lt;p&gt;Timeouts are also somewhat built-in to the session object. If start() ever returns FALSE, you can check the $error_num variable that was juset set. Really, here's what session starting should look like:&lt;/p&gt;
&lt;pre&gt;
if( $sess-&amp;gt;exists() AND on_secure_page() )&lt;br /&gt;
{&lt;br /&gt;
     if( !$sess-&amp;gt;start() )&lt;br /&gt;
    {&lt;br /&gt;
           if( $sess-&amp;gt;error_num == ERR_SESS_EXPIRED )&lt;br /&gt;
               {&lt;br /&gt;
                   // do something about an expired session&lt;br /&gt;
            }&lt;br /&gt;
   }&lt;br /&gt;
}
&lt;/pre&gt;</description>
<pubDate>Thu, 21 Jul 2005 02:53:19 -0500</pubDate>
<link>http://apps.carleton.edu/opensource/reason/developers/faqs/?faq_id=125372</link>
</item>

<item>
<title>How do I get more information from the PHP error log?</title>
<description>Every time PHP throws a low-ish level error, Reason's error handler catches it, logs it, and takes appropriate action. The log file is specified in the error handler itself (/global_stock/php/error_handler.php) as a constant. This file is a CSV file that can be easily parsed by the program /usr/local/sbin/error_watcher.php. A usual usage of this script looks something like this: cat /tmp/php-errors-apps.carleton.edu | php /usr/local/sbin/error_watcher.php -l2 -v5 So, we're piping the error log to the program (which currently needs to be run by PHP) and given the options l = 2 and v = 5. 'l' corresponds to the lowest level of error you want reported (1 = FATAL, 2 = ERROR, 3 = WARNING, 4 = NOTICE) and 'v' is the verbosity of the report. The default is 1, where only the errors that happened are shown. 2 is the error and the URLs it occurred on (this is the setting the PHP Watcher email script uses), and 5 is all information on all errors (this is a LOT of data). 3 and 4 have not been developed at this time. Anyway, this can get some slightly better information about the error if you want some more. Things like the line number, the script, etc.</description>
<pubDate>Thu, 21 Jul 2005 02:39:37 -0500</pubDate>
<link>http://apps.carleton.edu/opensource/reason/developers/faqs/?faq_id=125361</link>
</item>

<item>
<title>How can I manually regenerate URLs?</title>
<description>By using the Update URLs script located in Other Links in Master Admin. There you can regenerate all URLs for all sites, all URLs for one site, or run it in a test mode to see if all sites are actually set up correctly. If sites are not set up correctly, the script, at the bottom of the page, will alert you to what commands need to be run on the command line.</description>
<pubDate>Thu, 21 Jul 2005 02:32:25 -0500</pubDate>
<link>http://apps.carleton.edu/opensource/reason/developers/faqs/?faq_id=125349</link>
</item>

</channel>
</rss>