« September 2010 | Main | November 2010 »

October 28, 2010

Code Snippets for Rules

Execute PHP Code
PHP code to execute: Block

$my_node = node_load(8223);
$my_role = $my_node->field_person_role;
dpm($my_node);
if ( !empty($my_role[0][value]) ) {
print "Hurray!";
}

#####################################


$my_user = user_load(1);
//dpm($my_user);

$diff = $my_user->login - $my_user->created;
if ($diff < 30) {

dpm($node->login);
print "created = ";
dpm($node->created);

// return TRUE;
}

else{
print "ELSE!";
//return FALSE;
}


#########################

dpm($user);
print "account = ";
$acc_uid = [account:uid];
dpm($acc_uid);


$my_user = user_load([account:uid]);
dpm($my_user);

$diff = $my_user->login - $my_user->created;
if ($diff < 30) {

dpm($node->login);
print "created = ";
dpm($node->created);

// return TRUE;
}

else{
print "ELSE!";
//return FALSE;
}

http://www.gcfyouthlive.com/v2/sites/all/themes/youthlive/images/login_button.png

http://www.assamjatriniwas.com/images/register.png

Posted by kkwaiser at 07:26 PM | Comments (0)

Virtual hosts and multisites

multi-sites

symbolic links from one directory to core files in another

Virtual hosts

Sites available
$ ls -al /etc/apache2/sites-available/

$ ls -al /etc/apache2/sites-enabled/

Apache modules enabled or available
mods-enabled
mods-available
must have mod-rewrite enabled

To get site into sites-available
/etc/apache2/sites-available
cp default foobar.example.com


Move a website from available to enabled
sudo a2ensite [site URL]

Link to Inigo's blog entry on this

Posted by kkwaiser at 03:24 PM | Comments (0)

Cron notes with Marsh

Master.com

set URL
Enabled services:
- watchdog
-- watch url/cron.php
-- pager with hit cron.php every 15 minutes, if no hit then site is down and will receive email

man cron

crontab is how to invoke cron from cli

get into edit mode:
sudo crontab -e
select nano

Default crontab file:
# m h dom mon dow command

Configure crontab to hit cron.php every 15 minutes:
0,15,30,45 * * * * wget http://informationmanager.eeb.lsa.umich.edu/beta/cron.php
will hit on the hour, 1/4 after, 1/2 past, etc...

Posted by kkwaiser at 03:07 PM | Comments (0)

October 27, 2010

Panels Tutorial

Panels Node Template:

Enable Modules:
Panels
Panel nodes
CTools
Views content panes
Page manager (Optional)
Stylizer (Optional)


Go to Panels admin page (admin/build/panels)

Edit Node Template (admin/build/pages/edit/node_view)
Add Variant
- Name: DataSet
- Selection Rules
- Create Variant or Update and Save?? Take the former
- Selection Rule > Node: Type > Add > Node Being Viewed > DataSet > Continue
- Choose Layout > Flexible > Continue
- Panel Settings > Continue
- Panel Content > Update and Save

Layout Design
Pane (piece of content) or region (each column or region)

1) Add Region for Personnel
- Content > Show layout Designer > Row > Add Region to Right > Personnel

2) Add Region for Variable Information
- Content > Show layout Designer > Column > Add Row to Bottom > Add Region > Variable Info

3) Update and Save

Add Content

Content > Gear in Region of Interest > Add Content > Node > Methods (field_dataset_methods)

Add Relationship

1) Contexts > Relationships > Node from Reference
- Node: Node being viewed
- Identifier: Owner Reference
- Keyword: ownerreference
- Node reference field: Owner
- Save

2) Now you can add fields associated with the Owner (Person content type)


Add Variable View:

Create a View of DataSet Variables

Add View
Add Content Pane
Change Name (Under Basic Settings)
Change Style -> Table

Add Argument [NID]
Add relationship: Data File - field_dataset_datafile_ref
Add Field: Node Title


Add relationship: Variable - field_datafile_variable_ref > Data File Relationship
Modify Field: Node Title -> add Variable Reference relationship

Input on pane config:

Tweak Field Labels

Configure Arguments
Argument Input > Edit > From Context > Required Context: Node: Node ID

Posted by kkwaiser at 01:05 PM | Comments (0)

October 22, 2010

Rip a chapter and convert the VOB file to flash

This is one of those posts that makes me want to curse with pride because, really, why should I know how to do this? OK, I don't really know what I'm doing here but someone else does and they where nice enough to let me in on the secret. Here goes:

1) Install mplayer and mencoder for Ubuntu. I just used synaptic for this.
$sudo synaptic

2) Following this tutorial, rip the dvd (or chapter) to the hard drive:

For the whole dvd:
$ mplayer dvd://1 -dumpstream -dumpfile myvideo.vob

*For a single chapter (key was here):
$ mplayer dvd://1 -chapter 1 -dumpstream -dumpfile myvideo.vob

*This doesn't actually seem to work.

3) Convert the file you just ripped into flv format:

$sudo mencoder myvideo.vob -of lavf -ovc lavc -lavcopts vcodec=flv:vbitrate=150 -ofps 25 -oac mp3lame -lameopts abr:br=32 -srate 44100 -vf scale=720 -o outputfile.flv

4) This gives you one huge flv of the entire dvd disc. I broke the disc down into chapters with Moyea FLV Editor Lite. Note, this is a Mac/Windows package, it looks like Avidemux would work for the Linux OS.

5) Created an account at SciVee.tv and uploaded the files.

This is the reason I post my work notes publicly. I would be dead-in-the-water if it weren't for the [insert hyperbole here] souls who share their knowledge on the interwebs.

Posted by kkwaiser at 05:14 PM | Comments (0)

Approximate a dynamically constructed link or menu item using Rules

Goal: Dynamically construct a link that forwards a user to their edit content profile page (e.g. www.foo.com/user/1/profile/person).

Problem: Drupal's Core menu system is not token-enabled. The tricky part is that the 1 must be dynamically replaced with the [User:ID] of whomever is logged in.

Note:
This concept can be applied to both internal links and menu items.
This is something of a workaround and there are no doubt other ways to accomplish this.

Assumptions:
Some familiarity with all modules employed here.
A content type call Person which is part of the user profile.
No knowledge of PHP or the Drupal API.

Modules:
Content Profile
CCK
Rules
Token - to get the User ID info
Path Rules - Allows you to "Check Path" of destination URL.

1) Create a Page. Call it pageX

2) Under "URL path settings" set a custom URL for pageX. Call it pageX-url. You can also just remember the Node ID and use that instead of a custom URL.

3) Pick a menu to modify (admin/build/menu) and add a menu item that directs users to pageX (path: pageX-url) when clicked on.

4) Configure a rule (admin/rules/trigger) that redirects users who are about to visit www.foo.com/pageX-url to www.foo.com/user/[user:ID]/profile/person:

- Event: "Content is going to be viewed"
- Condition: "Check Path" where the path to check for is "pageX-url"
- Action: "Page redirect" where To: user/[user:uid]/profile/person

5) Navigate to www.foo.com/pageX-url, you should be forwarded to the edit form of the user profile listed above.

Posted by kkwaiser at 12:09 PM | Comments (0)

October 20, 2010

Rules links I don't want to lose

Cancel Post Action for when using "Content is going to be saved"

Field validation lacks a content argument

Rule Event show/hide field A depending on field B value

Can't activate Form Events on a Second Form ( Events for node_type_form have already been activated.)

Triggered Rules vs. Form Events

match an empty field

Check null value in form field

Creating a node programmatically

Using Rules for Node Validation

Posted by kkwaiser at 04:46 PM | Comments (0)

More thoughts on species-related resources at UMBS

I received feedback from our Resident Biologist, Bob Vande Kopple, on the idea I outlined in a previous post. Here are his thoughts, followed by my response.

Hi Bob,

Thanks for the thoughtful reply. In terms of goals, I see four primary species-related resources at UMBS:

- Species presence lists
- Datasets pertinent to a species, taxon, or taxa
- Pubs pertinent to a species, taxon, or taxa
- Biological Research Collections

My goal is to compose a system that is capable of integrating these resources based upon their common thread (i.e., the species) much as we have done with the researchers, publications, research sites and datasets.

Because this is a gargantuan project, my goal is that the process underlying it resemble building blocks. For example, to include a species list (e.g. mammals or insects; they can be done independently) we need two components:

1) A hierarchical, taxonomic list that ranges from Kingdom->Genus
2) A Species "entity" that refers to the correct Genus and includes additional information such as source and region found in.

Once this list is built, the species can later be referenced to relevant Datasets and Pubs. Once the research collection are digitized, each item in the collection can reference the appropriate species (thereby completing the quadfecta and completing a Tree of Life for Northern Michigan.)

Other thoughts:
Planning for how classes will use and contribute to this is a very good idea and should also be done at the outset.

The size and complexity of the insect (or algae?!?) list is indeed intimidating.

Actually, the whole project is intimidating and the way to get this done, in truth, is for us to find grant money that would bring in others to assist. That is what I REALLY want to do. Want to help me write a grant??

Best,

kbk


Posted by kkwaiser at 11:29 AM | Comments (0)

October 19, 2010

GLEON Aquatics Training Survey

Posted by kkwaiser at 10:36 AM | Comments (0)

October 13, 2010

Adding an SMTP Email server

Further into the abyss...

https://help.ubuntu.com/community/find
Followed this post to install postfix.

Lines on how to disable scripts that start Postfix

Similar to above link but for different OS.

Disable Postfix on Linux

Turn off in Redhat


A post on assessing security of PostFix installs.

Posted by kkwaiser at 11:10 AM | Comments (0)

Sending Emails from a Drupal Site

Oh boy. Here comes another brute-force learning exercise. The goal this time is to auto-email a node (e.g., housing application) upon creation.

First, the modules:

PHPMailer - "Adds SMTP support for sending e-mails using the PHPMailer library. Comes with detailed configuration instructions for how to use Google Mail as mail server."
- Couple thousand users, D7 dev version available

SMTP Authentication Support - "This module allows Drupal to bypass the PHP mail() function and send email directly to an SMTP server. The module supports SMTP authentication and can even connect to servers using SSL if supported by PHP."
- ~10,000 users

Views Send - "Views Send allow sending mass mailing using Views Bulk Operations."
- Issues entitled "Send nodes as messages" with uncommitted patch
- <200 users

Printer, e-mail and PDF versions - "This module allows you to generate the following printer-friendly versions of any node:

* Printer-friendly version (webpage format) (at www.example.com/print/nid)
* PDF version (at www.example.com/printpdf/nid)
* Send by-email (at www.example.com/printmail/nid)
"
- Issue "Option to send node content as an attachment to the e-mail" with a committed patch.
- ~35,000 users + D7 dev version

MimeMail - "This is a Mime Mail component module (for use by other modules)."
- 24,000+ users, No D7 version in the works
- Posts here and here on sending files as attachments (vs nodes)
- How to use mimemail
- Patch to send HTML emails via Rules.

Send - "Uses the Mime Mail module to send HTML emails containing the a node body or teaser"

Posted by kkwaiser at 09:19 AM | Comments (0)

October 11, 2010

User registration workflow: URL redirects

Current state of things:

1) Registration Portal page - splits registrations into Instructional and Research pathways

2) User and Person Registration - Collects personal information (address, etc.) and creates user login. Linked from 1).
a) I switched from CCK3 (Multigroup) to CCK2 because I was getting errors. This page is relevant to the error. See related materials as another post of mine.
b) I removed email authentication because it conflicted with the URL redirect. Should experiment more with this though? Similar post here.

3) Create Research Project for Researchers. Auto direct from 2).
a) Had issues with Rules Module Redirect + Content Profile not entering profile data into the database. Solution here. Similar post here.

4) Create Housing Application. Auto Direct after completion of 3).
- Need to look at this more. The rule redirects every time a research project is created which is too often. I really just want it to happen the first time someone logs in.

Posted by kkwaiser at 12:17 PM | Comments (0)

October 08, 2010

How to for the Data Module

I'm still wrapping my head around this module. Basically, it allows you to expose individual tables (data tables) to the Views module. Here are my notes. The original post is here.

Note, a colleague also experimented with the Data Module and posted his notes here.

Assumptions:
- The Data Module and its required modules are installed/enabled.
- Basic working knowledge of Data and Views
- Ability to do direct database insertions

1) Create new Table by going to admin/build/data/create
- An export of my table, data_table_x, is attached.
Note: I used phpMyAdmin to make my ID column auto-increment

2) Insert data into data_table_x
- I used phpMyAdmin to manually insert 3 rows :
id, variable_x, node_ref_id
1, 234, 8021
2, 253, 8021
3, 323, 8021

Notes:
- The first two columns are arbitrary, node_ref_id column contains the NID of the node I want to reference.
- The Feeds module can be used to accomplish steps 1 and 2.

3) Relate to nodes. Go to admin/build/data/edit/data_table_x/node and specify the Content Type you want to relate to and the column with the NID of the node you want to relate to (node_ref_id, in this case.)

4) Browse to admin/content/data/view/data_table_x, you should see your data. If not, then back to the drawing board with you.

5) Manually populate data_table_node table.
- Again, through phpMyAdmin, I inserted 1 row:
nid, data_table_name, id
8021, data_table_x, 8021

- Note: Is it by design that you need to manually update this table? I do not know.

6) Modify view so the Node Title of the referenced node is visible.
- Edit data_table_x view: admin/build/views/edit/data_table_x
- Add a relationship: Data node: Data table
- Add another relationship: Data node: Node
- Add Node Title field (with mandatory relationship) > "Exclude from display" & "Link this field to its node"
- Modify Table > Style Options to group by Node Title.
- Save
- See export of this view attached.

Notes:
- The relationship 'Data node: Node' is not available until relationship 'Data node: Data table' is added
- Node Title field cannot be added until relationships are specified

Posted by kkwaiser at 04:12 PM | Comments (0)

October 07, 2010

Evaluating CCK3 and MultiGroup

As part of building a new registration form for UMBS I am considering switching from CCK2 to CCK3, which allows for "Add New" abilities for grouped fields such as Address or Arrival/Departure dates. Here are some important resources:

Usage stats for CCK 6.x-3.x-dev

Relevant Forum Issues:

Support for multiple entry fields and field groups in CCK token

Status of CCK3 and plans for D7
- The last line of this comment summarizes my trepidations vis-a-vis CCK3.

Figure out whether Fields API and Multigroup module can coexist - Discussion on future of multigroup
- Current status of CCK3 summarized in this comment

State of the multigroup module

Possible alternative modules:
FlexiField

Other Critical Questions:

Compatibility of CCK3 with Content Profile for User Registration
- Latest patch for this functionality here.

Similar to above issue.

Posted by kkwaiser at 02:11 PM | Comments (0)

October 06, 2010

How to Create a DataFile from within DataSet

I think I figured out a way to create a DataFile from within the Add DataSet form. In fact, this works AND while you're creating a DataFile you can also Create Variable. Sick.

I've set this up on John's test site. Here are the steps:

1) Go to: http://nps.evsc.virginia.edu/drupaltest & login : lterpal luvDrupa1
2) Create DataSet:
http://nps.evsc.virginia.edu/drupaltest/?q=node/add/data-set
3) Click the "+" symbol next to the Data File Structure node reference
4) While creating the Data File Structure, you can also add Variables

Also of interest:
The NodeRelationships Module also builds an ER Diagram for you. Witness:
http://nps.evsc.virginia.edu/drupaltest/?q=admin/content/node-type/data-set/relationships

Modules Needed:
ModalFrame, NodeRelationships, JQuery Update, JQueryUI

Disclaimer:
There seems to be a JQuery UI fiasco at hand. ModalFrame requires 1.7+, JQueryUI requires 1.6. When I upgrade to JQuery UI 1.7, the Tabs broke but I was able to enable ModalFrame. I then downgraded to 1.6 and everything worked (dirty, dirty, dirty, hack that will probably blow up shortly. I know.)

Another approach:
The Popups Reference and Popups Modules may be able to do the same thing but the maintainer for these modules has abandoned.

Posted by kkwaiser at 03:14 PM | Comments (0)

Note about sorting Content Taxonomy Fields in Views

This comment says it all:

The ability to do so is there, it's just not immediately obvious.

Although creating a content taxonomy field and throwing it into a table produces a column of term names, Views only sees the data as a bunch of tids. Because of this, allowing the sorting on that column would produce some unintended results.

Instead, you need to create a relationship. Once you've created your Content Taxonomy field, go to your View and add a relationship. Under the "Content" selections, pick the Content Taxonomy field you want sortable. Save that, and now you need to create a new field. Select "Taxonomy: Term" as your field and continue. In the new options and in the "Relationship" dropdown, select the relationship that you just created, make any other changes you'd like, then click the "Update" button.

At this point, you should be able to click your "Style: Table" gear and be able to sort by term name. Just remember to save the changes to the View itself! =)

Posted by kkwaiser at 09:14 AM | Comments (0)

Node Import with Content Taxonomy Fields

Just a note that there is a patch out there that allows Node Import to correctly handle importing data into Content Taxonomy fields.

Posted by kkwaiser at 09:01 AM | Comments (0)

October 05, 2010

Incorporating species taxonomic data into Drupal

I've worked up a proof-of-concept that outlines one approach to incorporating species/presence information into the website. Here are the critical points:

-----------------------------------------------------------
Looking at any taxonomic level (e.g., subclass Pterygota) shows four basic elements:
1) Descriptive text information (not present for most taxonomic classes but can be added later)
2) List of Taxonomic groups directly below the one being viewed
3) All species below this level in the tax structure
4) All pubs for taxa at lower levels

For example, here is the Pterygota subclass:
http://informationmanager.eeb.lsa.umich.edu/beta/taxonomy/term/11502

-------------------------------------------------------------
Clicking on a species record gives you a bit more information. For example,
abagrotis anchocelioides:
http://informationmanager.eeb.lsa.umich.edu/beta/node/12021

------------------------------------------------------------
Finally, here's a point-blank list of the species I've imported:
http://informationmanager.eeb.lsa.umich.edu/beta/insect

------------------------------------------------------------
Notes:
1) Taxonomic information is not perfect (Proof of Concept only!!)
2) If we ever digitize the collections, this format should be extensible. I would probably add a "Specimen Record" content type to hold the Collector, Date, etc. information and have it reference the species.
3) This should also be extensible in that we could potentially the information stored with data from EOL, GBIF, TOL. Stuff like synonyms, descriptions, authorities...

Challenges:

1) Some of our presence records are only to the Genus or Family level, how to deal with these?
2) Getting all of the species lists into order! Standardizing the taxonomic hierarchy we use.
3) Creating connections from the publications to the Species Taxonomy list.

Technical Notes:
1) One Vocabulary (call it "UMBS Species Taxonomy") is used. It is hierarchical and includes the following taxa:
Kingdom > Phylum > Class > Subclass > Infraclass > Superorder > Order > Family > Genus. See below for species.

2) One Content Type (call it "Species") is used. It contains fields such as Species Name, Source, Species Presence (i.e., is it found at UMBS proper or in the Region?) and a Content Taxonomy field that references UMBS Species Taxonomy.

Note: I'm not 100% committed to Content Taxonomy. Pluses: Allows autocomplete without free tagging, reference to a vocabulary is just another cck field. Minuses: Yet another module, others?

3) Views + Panels are used to implement search and display.

Posted by kkwaiser at 03:43 PM | Comments (0)