Grayside.Org - spaces http://grayside.org/category/terms/spaces en Kicking Off OG Privacy http://grayside.org/2010/08/kicking-og-privacy <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><p>I&#8217;ve just published the <a href="http://drupal.org/project/og_privacy">Organic Groups Privacy</a> module to Drupal.Org. It&#8217;s an <span class="caps">API</span> module intended to help give developers an easy and flexible way to define public access to Organic Groups posts. It exists specifically so I can convince <a href="http://drupal.org/project/spaces">Spaces</a> that I really mean it when I say an arbitrary 90% of an Organic Group should be private.</p> <p>It is bundled with a Feature that demonstrates how you might integrate it with an Open Atrium site, but the core of <span class="caps">OG</span> Privacy can be useful even without Spaces being in the mix at all.</p> <p>With it, you can do such neat things as declare all Blog posts private to group members with a simple hook implementation:</p> <div class="geshifilter"> <div class="php geshifilter-php" style="font-family:monospace;"> <pre style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #009933; font-style: italic;">/** &nbsp;* Implementation of hook_og_privacy_policy_info(). &nbsp;*/</span> <span style="color: #000000; font-weight: bold;">function</span> custom_og_privacy_policy_info<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #000088;">$policies</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$policies</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'private_blog_type'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> &nbsp; &nbsp; <span style="color: #0000ff;">'access callback'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'custom_private_blog_policy'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; <span style="color: #0000ff;">'reason'</span> <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Blog posts are only viewable by group members.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$policies</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #009933; font-style: italic;">/** &nbsp;* Blog type privacy policy callback. &nbsp;*/</span> <span style="color: #000000; font-weight: bold;">function</span> og_privacy_blog_type_policy<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'blog'</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div> </div> <p>If you read through the <a href="http://drupalcode.org/viewvc/drupal/contributions/modules/og_privacy/og_privacy.api.php?view=markup"><span class="caps">API</span> documentation</a>, you will see that the above policy is <em>implicitly non-exclusive</em> meaning any old module could come along with it&#8217;s own policy to make a blog post visible.</p> <p>For an example of an exclusive policy, which exercises supreme executive veto power to guarantee the privacy of, say, all the content from your Atrium Casetracker feature, it might look like this:</p> <div class="geshifilter"> <div class="php geshifilter-php" style="font-family:monospace;"> <pre style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #009933; font-style: italic;">/** &nbsp;* Implementation of hook_og_privacy_policy_info(). &nbsp;*/</span> <span style="color: #000000; font-weight: bold;">function</span> custom_og_privacy_policy_info<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #000088;">$policies</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$policies</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'private_atrium_casetracker'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> &nbsp; &nbsp; <span style="color: #0000ff;">'access callback'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'custom_private_atrium_casetracker_policy'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; <span style="color: #0000ff;">'reason'</span> <span style="color: #339933;">=&gt;</span> t<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Content types created by the casetracker feature are viewable only by group members.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> &nbsp; &nbsp; <span style="color: #0000ff;">'exclusive'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;"><span class="caps">TRUE</span></span><span style="color: #339933;">,</span> &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$policies</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #009933; font-style: italic;">/** &nbsp;* Atrium Case Tracker privacy policy callback. &nbsp;*/</span> <span style="color: #000000; font-weight: bold;">function</span> og_privacy_atrium_casetracker_policy<span style="color: #009900;">&#40;</span><span style="color: #000088;">$node</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #000088;">$map</span> <span style="color: #339933;">=</span> features_get_component_map<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'node'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><a href="http://www.php.net/empty"><span style="color: #990000;">empty</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; &nbsp; <span style="color: #000088;">$feature</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/reset"><span style="color: #990000;">reset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$map</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">type</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #000088;">$feature</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'atrium_casetracker'</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #009900;">&#125;</span> &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;"><span class="caps">TRUE</span></span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div> </div> <p>By building your own selection of exportables and <em>hook_form_alter()</em> implementations around such policy definitions you can control public access very easily.</p> <p>For a somewhat more detailed explanation of the guts of how this works, <a href="http://drupalcode.org/viewvc/drupal/contributions/modules/og_privacy/<span class="caps">README</span>.txt?view=markup">check out the&nbsp;<span class="caps">README</span></a>.</p> </div></div></div><div class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above"><div class="field-label">Terms:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/category/terms/modules">modules</a></div><div class="field-item odd"><a href="/category/terms/spaces">spaces</a></div><div class="field-item even"><a href="/category/terms/og">og</a></div><div class="field-item odd"><a href="/category/terms/access">access</a></div></div></div> Mon, 16 Aug 2010 20:38:15 +0000 Grayside 87 at http://grayside.org http://grayside.org/2010/08/kicking-og-privacy#comments Spaces Integrating a CCK Field http://grayside.org/2010/07/spaces-integrating-cck-field <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><p>I wanted to make a <span class="caps">CCK</span> Field available only when a given feature was enabled. It turns out it&#8217;s really easy.</p> <p><span class="caps">CCK</span> comes with a <em>hook_field_access()</em> hook (see <a href="http://api.lullabot.com/content_access">content_access()</a>). Any implementation of this function that returns <span class="caps">FALSE</span> for a given field results in that field being denied to the user.</p> <p>By implementing this function with a <a href="http://drupal.org/project/spaces">Spaces</a> <span class="caps">API</span> call instead of the content_permissions module approach of a new, field-specific permission, all kinds of magic becomes possible.</p> <p>Read on for demonstration code.</p> <div class="geshifilter"> <div class="php geshifilter-php" style="font-family:monospace;"> <pre style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #009933; font-style: italic;">/** &nbsp;* Implementation of hook_field_access(). &nbsp;* Allow View/Edit access to 'field_my_cck_field' only when 'feature_name' is enabled. &nbsp;*/</span> <span style="color: #000000; font-weight: bold;">function</span> custom_field_access<span style="color: #009900;">&#40;</span><span style="color: #000088;">$op</span><span style="color: #339933;">,</span> <span style="color: #000088;">$field</span><span style="color: #339933;">,</span> <span style="color: #000088;">$account</span><span style="color: #339933;">,</span> <span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;"><span class="caps">NULL</span></span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Be sure not to affect other fields.</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'field_name'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #0000ff;">'field_my_cck_field'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;"><span class="caps">TRUE</span></span><span style="color: #339933;">;</span> &nbsp; <span style="color: #009900;">&#125;</span> &nbsp; &nbsp; <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$op</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'edit'</span><span style="color: #339933;">:</span> &nbsp; &nbsp; <span style="color: #b1b100;">case</span> <span style="color: #0000ff;">'view'</span><span style="color: #339933;">:</span> &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">// Make access contingent on whether a given feature is enabled in the current space, such as atrium_book.</span> &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> spaces_access_feature<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'view'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'feature_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre></div> </div> <p><strong><span class="caps">EDIT</span>: <a href="http://drupal.org/node/887272">Issue posted</a> to the Spaces queue with patch to add this functionality generically for all&nbsp;fields.</strong></p> </div></div></div><div class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above"><div class="field-label">Terms:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/category/terms/cck">cck</a></div><div class="field-item odd"><a href="/category/terms/openatrium">openatrium</a></div><div class="field-item even"><a href="/category/terms/access-control">access control</a></div><div class="field-item odd"><a href="/category/terms/spaces">spaces</a></div></div></div> Mon, 26 Jul 2010 20:25:09 +0000 Grayside 86 at http://grayside.org http://grayside.org/2010/07/spaces-integrating-cck-field#comments Integrating Some Other Feature with Spaces http://grayside.org/2010/07/integrating-some-other-feature-spaces <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><p>I have found more than once a situation in which I had a basic feature that could be used on any site which I would like to see integrated with Spaces (for OpenAtrium magic). It usually runs like this:</p> <ol> <li>I have the FeatureServer feature.</li> <li>I want it in OpenAtrium.</li> <li>Here&#8217;s a new Feature that provides some Contexts and some Groups variables.</li> <li>Here&#8217;s a patch that you must apply to FeatureServer to make Spaces aware of it. (And other stuff).</li> </ol> <p>&#35;4 is a pain, but I&#8217;ve recently discovered how to shrink it down a little more: hook_system_info_alter().</p> <div class="geshifilter"> <div class="php geshifilter-php" style="font-family:monospace;"> <pre style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #009933; font-style: italic;">/** &nbsp;* Implementation of hook_system_info_alter(). &nbsp;*/</span> <span style="color: #000000; font-weight: bold;">function</span> my_atrium_savvy_feature_system_info_alter<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$info</span><span style="color: #339933;">,</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'some_other_feature'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; &nbsp; <span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'spaces'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'types'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'og'</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre></div> </div> <p>This hook is called from <em>features_get_info()</em> in features.module. The hook allows you to changes all the info files settings of a feature. Note: Row is apparently a huge variable to dump to the&nbsp;screen.</p> </div></div></div><div class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above"><div class="field-label">Terms:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/category/terms/openatrium">openatrium</a></div><div class="field-item odd"><a href="/category/terms/spaces">spaces</a></div><div class="field-item even"><a href="/category/terms/features">features</a></div></div></div> Fri, 23 Jul 2010 16:10:17 +0000 Grayside 85 at http://grayside.org http://grayside.org/2010/07/integrating-some-other-feature-spaces#comments Optional Spaces Integration for a View http://grayside.org/2010/06/optional-spaces-integration-view <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><p>If you want to make an exported [node-based] View smoothly integrate with Spaces, you can use the following code to modify the View structure with the &#8220;Content in current space&#8221; filter. This filter does nothing if the View is not itself in a Space, otherwise it restricts all results to content in the same space. Add any conditions you want to control whether the Spaces integration is applied.</p> <div class="geshifilter"> <div class="php geshifilter-php" style="font-family:monospace;"> <pre style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #009933; font-style: italic;">/** &nbsp;* Implementation of hook_views_default_views_alter(). &nbsp;*/</span> <span style="color: #000000; font-weight: bold;">function</span> custom_views_default_views_alter<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$views</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>module_exists<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'spaces'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; &nbsp; <span style="color: #000088;">$views</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'view_name_here'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'default'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'filters'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'current'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'operator'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'all'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'value'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'group'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'0'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'exposed'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;"><span class="caps">FALSE</span></span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'expose'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'operator'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;"><span class="caps">FALSE</span></span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'label'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'id'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'current'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'table'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'spaces'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'field'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'current'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">'relationship'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'none'</span><span style="color: #339933;">,</span> &nbsp; &nbsp; <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre></div> </div> <p>If you would like to take it a step further, and create OpenAtrium features integration, insert the following:</p> <div class="geshifilter"> <div class="php geshifilter-php" style="font-family:monospace;"> <pre style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000088;">$views</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'view_name_here'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'default'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">display_options</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'access'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/array"><span style="color: #990000;">array</span></a><span style="color: #009900;">&#40;</span> &nbsp; <span style="color: #0000ff;">'type'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'atrium_feature'</span><span style="color: #339933;">,</span> &nbsp; <span style="color: #0000ff;">'spaces_feature'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'feature_name'</span><span style="color: #339933;">,</span> &nbsp; <span style="color: #0000ff;">'perm'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'access content'</span><span style="color: #339933;">,</span> <span style="color: #666666; font-style: italic;">// or any other permission</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div> </div> <p>hook_views_default_views_alter() fires off before the View is cached, so be sure to clear your cache after adding this code to see the results.</p> <p>This code snippet is a finding from my work on <a href="http://grayside.org/2010/06/integrating-features-server-openatrium">OpenAtrium-FeatureServer&nbsp;integration</a>.</p> </div></div></div><div class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above"><div class="field-label">Terms:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/taxonomy/term/1">drupal</a></div><div class="field-item odd"><a href="/category/terms/views">views</a></div><div class="field-item even"><a href="/category/terms/spaces">spaces</a></div></div></div> Tue, 15 Jun 2010 21:05:02 +0000 Grayside 82 at http://grayside.org http://grayside.org/2010/06/optional-spaces-integration-view#comments Spaces Private Content http://grayside.org/spaces-private-content <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><p>&gt; Replaced with a project on D.O: <a href="http://drupal.org/project/og_privacy"><span class="caps">OG</span>&nbsp;Privacy</a></p> </div></div></div><div class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above"><div class="field-label">Terms:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/category/terms/permissions">permissions</a></div><div class="field-item odd"><a href="/category/terms/openatrium">openatrium</a></div><div class="field-item even"><a href="/category/terms/spaces">spaces</a></div><div class="field-item odd"><a href="/category/terms/og">og</a></div></div></div> Wed, 31 Mar 2010 16:35:05 +0000 Grayside 60 at http://grayside.org http://grayside.org/spaces-private-content#comments Simple Spaces Recipe for a Static Welcome Widget http://grayside.org/2010/03/simple-spaces-recipe-static-welcome-widget <div class="field field-name-body field-type-text-with-summary field-label-hidden"><div class="field-items"><div class="field-item even"><p>One of the little conundrums in OpenAtrium (and I imagine in Spaces) is building static content for the space. (Or in OpenAtrium terms, getting a nice dashboard box to stay put, yet be customizable by group.)</p> <p>There are countless ways of doing this, but I opted to create a <span class="caps">CCK</span> Textarea field in my group content type (named <em>field_group_welcome_message</em>) and turn on the <span class="caps">PHP</span> filter.</p> <p>Then I created a <a href="http://drupal.org/project/boxes">Box</a> (which is what OpenAtrium uses, could just as well have been a block) using the following snippet:</p> <div class="geshifilter"> <div class="php geshifilter-php" style="font-family:monospace;"> <pre style="font-family: monospace; font-weight: normal; font-style: normal"><span style="color: #000088;">$space</span> <span style="color: #339933;">=</span> spaces_get_space<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$space</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">group</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">field_group_welcome_message</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;"><span class="caps">NULL</span></span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #000088;">$format</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$space</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">group</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">field_group_welcome_message</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'format'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> check_markup<span style="color: #009900;">&#40;</span><span style="color: #000088;">$text</span><span style="color: #339933;">,</span> <span style="color: #000088;">$format</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;"><span class="caps">TRUE</span></span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #000088;">$text</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$space</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">group</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">og_description</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">print</span> <span style="color: #000088;">$text</span><span style="color: #339933;">;</span></pre></div> </div> <p>The bit about <tt>$format</tt> and <tt>check_markup</tt> is only relevant if you turn on input filtering for your textarea. Can&#8217;t figure why you would not do that. <strong><span class="caps">UPDATE</span>: Added a check for a null welcome message. If there is none, the group description will be inserted.</strong></p> <p>Now, whenever anyone goes to edit the group node/group settings, they are also offered the chance to play with the welcome message. You could just as well use this technique to pull out the Body of the group node, if that&#8217;s available. In OpenAtrium it&#8217;s removed, since it doesn&#8217;t fit into the dashboard concept without this kind of magic.</p> <p>You could just as easily build some kind of zany view to achieve the same result, but you&#8217;d still need to do something to mark your target content uniquely. This method seems the most straightforward for the end-user.</p> <p>I will update this another time with information about enabling such a block by&nbsp;default.</p> </div></div></div><div class="field field-name-taxonomy-vocabulary-1 field-type-taxonomy-term-reference field-label-above"><div class="field-label">Terms:&nbsp;</div><div class="field-items"><div class="field-item even"><a href="/category/terms/openatrium">openatrium</a></div><div class="field-item odd"><a href="/category/terms/spaces">spaces</a></div><div class="field-item even"><a href="/category/terms/dashboard">dashboard</a></div><div class="field-item odd"><a href="/category/terms/boxes">boxes</a></div></div></div> Sun, 07 Mar 2010 08:33:50 +0000 Grayside 58 at http://grayside.org http://grayside.org/2010/03/simple-spaces-recipe-static-welcome-widget#comments