January 24, 2013

How to install Drush on ITS servers

How to install Drush on ITS servers

--------------------
See http://drupal.org/project/drush README.txt
--------------------

1. SSH into ITS servers via the PHP-enabled host
$ ssh [uniqname]@[email webmaster@umich.edu for the hostname]

2. Go to your group or personal AFS space to install Drush. This document uses the personal space.
$ cd /afs/umich.edu/user/[]/[]/[uniqname]/Private

3. Download and unpack the latest, appropriate version of Drush given your Drupal install. Drush5 works for Drupal 6 and Drupal 7
$ wget http://ftp.drupal.org/files/projects/drush-7.x-5.8.tar.gz
$ tar -xzf drush-7.x-5.8.tar.gz
$ ls drush

4. Make the 'drush' command executable
- Note this diverges from the Drush README considerably because the "export PATH=" command is "bash" (Bourne Again SHell) syntax.
and the default shell on the PHP-enable host is the C-shell ("csh").

a) Add this command to you .login file
$ cd ~
$ nano .login
At bottom of file (where is specifies for customizations) add

set path=($path /afs/umich.edu/user/[]/[]/[uniqName]/Private/drush )

This command could also go into your ~/.cshrc file

b) Alternatively, if you already have a "~/bin/" directory, you could use the "ln -s"
command to create a symbolic file link (sym-link) in there for "drush"
with:

ln -s ~/Private/drush/drush ~/bin/drush

5. Test that Drush works

$ cd /path/to/drupal/install
$ drush help

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

Install or Move CKFinder Libraries so sites/all/libraries

$ sudo drush up

CKeditor is broken. Fix it.

1) How to install CKEditor Library

$ cd sites/all
$ mkdir libraries
$ wget http://download.cksource.com/CKEditor/CKEditor/CKEditor%204.0.1/ckeditor_4.0.1_standard.tar.gz
$ sudo tar -xzf ckeditor_4.0.1_standard.tar.gz

Probably some other steps here...

2) How to install CKFinder

$ sudo wget http://download.cksource.com/CKFinder/CKFinder%20for%20PHP/2.3.1/ckfinder_php_2.3.1.tar.gz
$ sudo tar -xzf ckfinder_php_2.3.1.tar.gz


Edit ckfinder/config.php

Comment out the entire "function CheckAuthentication(){ blah}" function

Add this require_once line below the $baseDir variable. Note, I do not know why it goes up so many directories but it works:

$baseDir = resolveUrl($baseUrl);
require_once '../../../../../modules/ckeditor/includes/filemanager.config.php';

Add/remove/modify the directories that will appear in the CKFinder window when users upload. This is found in the $config['ResourceType'][] = Array() arrays.

Edit the CKEditor profiles (admin/config/content/ckeditor)
- CKEditor Global Settings- make sure the paths to CKFinder and CKEditor point to the sites/all/libraries directory.

- For the Editor Profiles, make sure CKFinder is selected for file management options

Edit permissions (admin/people/permissions)
- Make sure the appropriate roles have access to CKEditor and CKFinder
- Note, if CKFinder access does not appear on this page then the library likely has not been located correctly.

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

January 23, 2013

CKFinder error bookmark

This link may come in handy later.

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

Changing the default upload directory for CKFinder

I inherited a site to maintain (and develop a bit) and it uses CKFinder with CKEditor to allow content managers to upload files via the WYIWYG. One problem with the default settings was the file url that was produced after upload. The file path took the form http://mysite.edu/sites/default/files/files/readme.pdf.

To get rid of the extraneous 'files' you need to go into sites/all/modules/ckeditor/ckfinder/config.php and find the section where $config['ResourceType'] statements occur. The URL should have only the $baseURL whereas the site I am working on had $baseUrl . 'files' .

Fin

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

Change site from sites/default to site/customDirectory

h/t to Eric London for another another useful post.

1. Install and patch the Site Directory Migrate module.

$ cd sites/all/modules/sitedir_migrate
$ wget http://drupal.org/files/1568538-d7_fix-2.patch
$ git apply 1568538-d7_fix-2.patch

- enable submodules as appropriate

2. Visit admin/config/system/sitedir_migrate and set From and To values accordingly. Example From:default To:newDir > Save Configuration

3. Create newDir in sites folder
$ sudo mkdir sites/newDir

4. Update file systems settings admin/config/media/file-system. Example: sites/newDir/files > Save

5. Copy file directory and settings.php over to newDir
$ cd sites
$ sudo cp -rfp default/settings.php newDir/
$ sudo cp -rfp default/files/ newDir/

6. Clear site cache
$ drush cc

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

June 29, 2012

Update D7 Core and Contrib Modules

Notes follow -

Step 1. Update these modules and test functionality:

$ ls -alh *.tar.gz
-rw-r--r--. 1 root root 161K Apr 10 13:55 colorbox-7.x-1.3.tar.gz
-rw-r--r--. 1 root root 393K Mar 28 15:20 ctools-7.x-1.0.tar.gz
-rw-r--r--. 1 root root 187K Jun 5 19:51 devel-7.x-1.3.tar.gz
-rw-r--r--. 1 root root 389K May 15 20:31 nodequeue-7.x-3.x-dev.tar.gz
-rw-r--r--. 1 root root 38K May 13 19:06 pathauto-7.x-1.1.tar.gz
-rw-r--r--. 1 root root 42K May 15 16:56 token-7.x-1.1.tar.gz

Step 2. Update two more sensitive modules and test:

Lightweight Directory Access Protocol (http://drupal.org/project/ldap)
"
7.x-1.x will only have bug fixes on it from here on out. The current dev will become 7.x-1.0-beta11. It is recommended to stick with whatever version of it you have working currently until 7.x-2.0 betas come out. If you are starting out, use 7.x-1.0-dev. Special thanks to Oxfordshire County Council for funding the final work on this branch as well as a good deal of the 2.x branch.
"
Version and Releases Status Updates - http://drupal.org/node/1115704 - notes on different releases
- I'm going to assumer "whatever version" is actually referring to "whatever branch".
Entity API
This issue outlines potential upgrade issues with D7.14 and Entity API rc3: http://drupal.org/node/1559516. Looks minor (error message) but is unresolved.

LDAP DB Update Messages:

ldap_servers module
Update #7102
No database changes made.

Update #7103
"group_object_category" field added to ldap_servers table

Update #7104
"search_pagination" field added to ldap_servers table
"search_page_size" field added to ldap_servers table

Update #7105
"account_name_attr" field added to ldap_servers table

ldap_query module
Update #7101
ldap_query table field "filter" changed to type "text"

Step 3. Upgrade Drupal Core

$ cd /var/www/dct-dev.lsa.umich.edu

#copy the whole damn website to the Desktop just in case
$ sudo cp -rf ~/Desktop/sites/ html

$ sudo wget http://ftp.drupal.org/files/projects/drupal-7.14.tar.gz
$ sudo tar -xzf drupal-7.14.tar.gz
$ sudo cp drupal-7.14/* html
$ sudo rm -rf html/sites/
$ sudo cp -rf ~/Desktop/sites/ html

#this diff showed a few comment differences between the 7.12 and 7.14 versions but I'm ignoring those and copying settings.php over from the 7.12 site because Kevin has a bunch of git modifications made.
$ diff drupal-7.14/sites/default/default.settings.php html/sites/default/default.settings.php
$ sudo cp ~/Desktop/.htaccess html
$ sudo cp ~/Desktop/.gitignore html
$ sudo cp ~/Desktop/cron.php html
$ sudo cp ~/Desktop/favicon.ico html

#Created a tar of the 7.12 site in my Home folder. Cleaned up Desktop.
$ sudo tar -czf dpt_june27.tar.gz Desktop/*

After visiting ~/update.php the following updates were run:

system module
7073 - Add binary to {file_managed}, in case system_update_7034() was run without it.

field module
7002 - Split the all-inclusive field_bundle_settings variable per bundle.

node module
7013 - Change {node}.vid default value from 0 to NULL to avoid deadlock issues on MySQL.

trigger module
7001 - Increase the length of the "hook" field to 78 characters. This is a separate

function for those who ran an older version of trigger_update_7000() that did not do this.
7002 - Renames nodeapi to node.

user module
7018 - Ensure there is an index on {users}.picture.

Initial testing didn't reveal any broken components.

Step 4. Fix Permissions

Permissions for CTools CSS and sites/default/files . I've asked Mark M. to advise me on this with the hope of getting the permissions set correctly. There is no www-data user and folders are all owned by Root. I could chmod the folders to 777 but that is not the correct setting.

Solution was to limit user apache (i.e. www-data) to the most restricted permissions possible via these commands to allow default/files/ctools/css to be created:
$ sudo chown -R apache sites/default/files/ctools
$ sudo chmod -R u+rwX,go-rwx sites/default/files/ctools
$ sudo chcon -R -t httpd_sys_rw_content_t sites/default/files/ctools

Documentation from Mark Montague:

For example, from what I know, the most common reason for Drupal to need to write to sites/default/files is if you are going to allow end-users to upload files via/into Drupal. If you need to let users upload files, you would grant Drupal write access to sites/default/files but otherwise you would keep sites/default/files so that Drupal can only read from it, not write to it. (Unless, of course, you have another reason that you want Drupal to be able to write files there).

If you *do* need to allow Drupal to modify its own files, then the best way to do this is to change the owner of sites/default/files and everything underneath that to "apache" and set the permissions of all directories from that point down to 700 and all files from that point down to 600. Also tell SELinux that it's OK if the web server tries to write things there. The commands to do this are:

sudo chown -R apache sites/default/files
sudo chmod -R u+rwX,go-rwx sites/default/files
sudo chcon -R -t httpd_sys_rw_content_t sites/default/files

If you determine that you really do need Drupal to be able to write there for some reason -- again, it's best to avoid this unless you actually do need it -- and would like me to set things up for you, just let me know and I'll be happy to do so.

Note that "www-data" is an example username that is used in Drupal documentation such as https://drupal.org/node/244924 This user does not exist on our systems, the corresponding user on our systems is "apache"

I don't know why Drupal is complaining about /var/tmp. You may have better luck with /tmp. If this doesn't work either, and you need it, let me know and I'll look into whether the problem is caused by SELinux or not.

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

Trigger Rules Action based on URL

In Drupal 6, I used the Path Rules module but it appears this is not going to be ported because the functionality exists in the base Rules module.

How to do this in D7 Rules?

Events to use:

1) If the page to be viewed is a Node then you can use "Content is Viewed".

2) If the page to be viewed is not a node but is a view or panels page then use "Drupal is initializing". Note that this fires every time someone looks at a page and probably engenders a performance hit. In Rules Bonus Pack, there is also a possibility to use Page manager's custom pages as Rules triggers.

Conditions

Using the Text Comparison is the way to go. For example I used
site:current-page:path under Data Selector and data/\d+/summary under the Matching Text with the Comparison Operation set to Regular Expression. This allows for use of a wildcard. That regex is equivalent to data/*/summary where * is an NID argument.
If your URL is dynamically constructed with an argument, you

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

June 01, 2012

Upgrading to D7

A link from a SNRED who works with Drupal.

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

February 24, 2012

Upgrading to D7?

It's a Friday. And I want to be productive but I don't want to do any of the things I usually do. This is when I usually spend some time exploring my options re: drupal. Today I'm looking at how hard it will be to upgrade to Drupal 7 using Drupal's Upgrade Status module.

Here's a summary.

Modules in use: 84(!)(!)(!)
Stable for D7: 27
In D7 Core: 9
Dev for D7: 27
No D7 releases: 20

-----------------
Now, the last figure is the most important. It looks like 10 of those 20 have ready D7 substitutes available. Of the 10 that have no port available, 5 of those are deal breakers - meaning they supply absolutely necessary functionality that I don't currently have a substitute for. Here are the details:

Substitute Available:

Views Bonus Pack
-> Creates export to CSV functionality
-> EML Modules uses this
-> See Views Data Export
-> Need Level: 10

Private Download
-> Used to keep some data files private
-> Drupal 7 has can do both public/private file types out of the box
-> Need Level: 10

Content Profile
-> I attach a Person node to a User account
-> Port thread
-> Profile2 if you "don't need nodes in D7"
-> Need Level: 10

Node Relationships
-> Usability module allowing creation of nodes within Modal Frames.
-> No port activity
-> References Dialog as a potential substitute
-> Need Level: 7

CCK Fieldgroup Tabs
-> Recommends Fieldgroup Module (Stable D7)
-> Usability module to break up node/add forms
-> Need Level: 5

Tabs (jQuery UI tabs)
-> Deprecated in favor of Elements
-> Usability module to break up node/add forms
-> Need level: 5

Views Custom Field
-> Allows use of custom PHP in a views field
-> See Views PHP for substitute
-> Need Level: 5?

Taxonomy Role
-> Used to bar/grant access to vocabularies
-> Port thread indicates Field Permissions is a substitute
-> Need Level: 4

Table Wizard
-> Used sparingly to store data in database tables
-> Data as potential substitute. D7 development has picked up with new maintainer.
-> Need Level: 1

Node import
-> Use Feeds instead
-> Need level: 1

Path Rules
-> Used to check the URL path and trigger a rule to do something
-> I could probably stop using this module right now but custom PHP within Rules should do the same thing
-> I think this is now part of Rules Core
-> Need Level: 1


No Substitute:

Filefield Stats
-> Part of the Download Data form, used by the Squeeze Module
-> Need level: 10

Squeeze
-> Part of the Download Data form,
-> Need level: 10

Views Bonus EML
-> Allows export of metadata to EML compliant format
-> No port thread
-> Need Level: 10

Workflow Required Fields
-> Used in the REU application form to make certain fields required by state
-> Port thread
-> Need Level: 8

CCK Required by Role
-> Port Thread
-> Use: Multiple user roles may add content, this allows for variability in the required fields for each role
-> No port issue open
-> Need level: 8

Unitag
-> Used to put user entries into vocabularies into a moderation queue (i.e. protect the keywords list)
-> This module has mysteriously stopped working so I'm a bit frustrated with it
-> Port thread
-> Need Level: 6 (if it works)

Chaos tool custom plugins for Panels
-> Add images/links to Panes
-> No port issue open
-> Need level: 5

CCK Tweak Button
-> Hack to theme the "Add Another" buttons on node/add forms
-> If I can manage a proper theming job, this should become obsolete
-> Need level: 3

Views Date Range Filter D6
-> Usability module for viewing housing applications
-> No plans to port
-> Need Level: 2

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

January 31, 2012

Reverse Node References in Drupal

My understanding is the this Views patch and this References patch combined give the ability to reverse node reference directions in a view.

Once I get those versions in front of me, I will return with documentation.

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

December 05, 2011

Long Text vs Long Text With Summary

'Long text and summary' field was created, which contains a textarea for the body along with an optional textarea for the teaser. This new field has options to display the teaser using either the text that is in the teaser field or as a snippet from the body text of a stated size.

source

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

How to add Taxonomy field to a custom content type in drupal 7

Wouldn't have expected this to trip me up:

When you add a field to the content type select Term reference from the list titled "Select a field type".

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

July 14, 2011

Set up OpenLayers on Drupal 7

First Drupal 7 How to post!!

Enough celebration.

Goal: Get basic CMS GIS capabilities running on D7 using an opensource approach. I've used GMap on D6 but want to switch - partially because of the source issue but also because OpenLayers can handle bounding boxes, WKT, etc.

Assumptions: I'm past the point of writing for complete newbies. Sorry, because I know what it is like when items are shortchanged but there is only so much time in the day.

Steps:

1) Install Drupal 7 - that's all the help you get. Hint, it's pretty much the same as D6.

2) Install OpenLayers

$ cd sites/all/modules
$ sudo wget http://ftp.drupal.org/files/projects/openlayers-7.x-blah.tar.gz
$ sudo tar -xzf openlayers-7.x-blah.tar.gz

3) Install GeoField and Libraries
- OpenLayers does not support fields (CCK) in D7. It is recommended that you use GeoField.
- As of July 14th, 2011 you need the dev version of GeoField!!
- GeoField should give us the ability to add, well, a geo field to our content types

4) Enable Modules
- Visit admin/modules
- OpenLayers UI, OpenLayers, Geofield, Libraries

- Note: I don't have Views on this install yet but OpenLayers Views will be used at a later date.

5) Configuration Notes
- Openlayers is found at admin/structure/openlayers and admin/people/permissions#module-openlayers_ui
- I didn't immediately find config spots for GeoField and Libraries

6) Add a GeoField to a content type
- Visit Content Type Structure (admin/structure/types)
- Pick a CT and add a new GeoField (Widget = Well Known Text) - I'm not 100% certain on the other Widgets but feel free to experiment.

Notes: I hit these messages:
- "Plot Location has no field settings."
(I saved past this but recommend going back in to check your settings.)

- "Unable to load geoPHP library. Not all values will be computer [sic] correctly"
(Hmmm...this looks potentially troublesome, especially if geoPHP doesn't ship with whatever version of PHP we are using)


Further Notes:
I changed the widget to OpenLayers Map because I need a map interface to input WKT values. I got a map but lost WKT. I also got this error:
Notice: Trying to get property of non-object in geofield_form_latlon_map()

(line 166 of /var/drupal7/sites/all/modules/geofield/geofield.widgets.inc).

7) Create a node with a GeoField field.

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