The problem: During Drupal admin work, for example after importing a bulk of posts from another source, you might want to assign many of them to Drupal group (provided by the Organic Groups module). In the admin backend, there is no other way than editing every node individually and entering the group's name into the "Groups: Your groups" or "Groups: Other groups" fields. There has to be a faster way for this, though.

My solution with SQL

I'm going to solve this on the database level, as all the other options do not (yet) work for me, see below.

  1. Create a backup of your Drupal database.
  2. Save this little script into a new PHP file on your server:

    <?php
      // PHP Script to generate a set of SQL statements that assign a set of posts
      // to a group in Drupal 7.

      // Node ID of the group to assign the nodes below to.
      $group_id = "366";

      // Node IDs of the nodes to assign to group with node ID $group_id.
      // (One mode to get the right set relatively fast is by copying the "System" column
      // from the "URL aliases" Drupal view at http://example.com/admin/config/search/path .)
      $node_ids = array(183, 357, 358, 360, 361); //
     
      foreach ($node_ids as $node_id) {
        echo("INSERT
          INTO og_membership (type, etid, entity_type, gid, group_type, state, created, field_name, language)
          VALUES ('og_membership_type_default', $node_id, 'node', $group_id, 'node', 1, 1359419168, 'og_group_ref', 'en');\n\n"
        );
      }
    ?>

  3. Adapt the script to contain the proper group node ID and the proper node IDs for nodes you want to assign to this group.
  4. Execute the script with: php generate-bulkassign-sql.php.
  5. Clear the Drupal cache by calling this in your website's document root directory: drush cc. Else, you might not see some changes as Drupal would read from the cache instead where possible.

Non-Working or Should-Be-Working Alternatives

Views Bulk Operations and og_actions

Views Bulk Operations is a Drupal module that can execute a configurable action on a selected set of content nodes. The node-to-group mass assignment should be possible together with the og_actions module, providing relevant VBO actions for groups, and whose functionality is said to be integrated into the core og (Organic Groups) module as of Drupal 6 [source]. However, the relevant action "Modify Group Content" action resp. "Add the node to the specified group…" action did not show up for me. So there seems to be no pure UI way (for me) to mass-assign content to a group in Drupal 7.

Views Bulk Operations and "Execute arbitrary PHP script"

There is another way to use Views Bulk Operations: together with own PHP code that performs the action on every entity (here: node) it is called on. An introduction to this technique is at "Copying data between fields with VBO".

In "Administration -> Configuration -> System -> Actions" (http://example.com/admin/config/system/actions/manage) there is a way to create an advanced action "Execute arbitrary PHP script", specifying your own PHP code to be executed on every node you call this action on. However any action I would create this way would not show up in the list of actions on top of the content items list in the admin backend, where I would normally select some content items, select that action from the dropdown and click "Update". Other advanced actions that I created did however show up, for example those created via the convert module.

Once the action shows up correctly, one would use this PHP code to get the action done (note: untested, maybe still buggy):

<?php
  // Script to assign one node to a pre-defined group via "Execute arbitrary PHP script" action.
  //
  // Intended to be used with the VBO feature, see: http://drupal.org/node/570220
  // PHP code to be copied into the "Execute arbitrary PHP script" field
  // without the <?php ? > code wrapper!

  $gid = 6; // Node ID of the group to assign content to.

  // Source and explanations: http://drupal.org/node/1249396#comment-6778598
  // API docs: http://api.drupalize.me/api/drupal/function/og_group/7
  og_group($gid, array('entity' => $entity));

  node_save($entity);
?>

PHP script to assign all nodes to a group at once

The most comfortable way to run a short own script inside the Drupal environment is drush php-script. It will bootstrap the Drupal context for you, so you have access to Drupal classes and functions just as when inside a custom module. See also this introduction to drush php-script.

I tried to run this PHP code with the drush php-script technique, but so far it does not work ("Error: Class name must be a valid object or a string in <drupal-dir>/includes/common.inc line 7752"):

<?php
  // Script to assign a set of nodes to a pre-defined group.
  //
  // Intended to be used with the "drush php-script" command.

  $group_id = 1; // Node ID of the group to assign content to.
  $group_type = "node"; // Entity type of this group, for example "node", "comment".

  $node_ids = array(
    3, 238, 346, 123
  );

  foreach ($node_ids as $node_id) {
    $entity = node_load($node_id);

    // Source and explanations: http://drupal.org/node/1249396#comment-6778598
    // API docs: http://api.drupalize.me/api/drupal/function/og_group/7
    og_group($group_id, array('entity' => $entity));

    node_save($entity);

    // $is_member_after = og_is_member($group_type, $group_id, $entity_type = "node", $entity, $states = array(OG_STATE_ACTIVE));
    // echo("Assigned node $node_id to group $group_id. Member state now: $is_member_after.");
  }

?>

Automating the manual form editing with drupal_form_submit()

This is a new idea that I did not yet try. Like above, one would use drush php-script to execute a little PHP script, but the script would fill and submit the "node edit" form instead of dealing with the Organic Groups API directly. There is a working example for creating groups this way (not assigning nodes to groups though).

This refers to the reference Bitcoin client (bitcoin-qt), version 0.7.2. While it was catching up with the blockchain, it did cause such a high I/O waitstate load that working on the same computer alongside was very frustrating to impossible.

Setting bitcoin-qt to low CPU and IO priority helped a bit, but not too much:

ionice -c 3 -p $(pidof -s $(which bitcoin-qt))

renice -n 20 -p $(pidof -s $(which bitcoin-qt))

Additionally setting the main application(s) you work with to higher prioritoes helps more, but it won't be great still:

sudo ionice -c 2 -n 0 -p $(pidof -s firefox)

sudo renice -n -10 -p $(pidof -s firefox)

The underlying problem is the inefficient disk I/O activity of the BerkeleyDB used in the reference client bitcoin-qt. It will be solved in one of the next (after 0.7.2) releases by switching to a different DB engine [source]. Until then (or even at all) you may switch to the Blockinfo My Wallet online wallet. It does store the private keys in encrypted form, and does decryption only locally with JavaScript in the browser – so if they did an honest implementation of that, their service is not prone to theft as have been other Bitcoin online wallets before. (But: Use at your own risk anyway, do not blame me, do not put in your lifetime savings etc. …)

There are also alternative solutions for some situations like downloading the blockchain directly.

As of 2013-01-27, this is a problem because of many bugs both inside the wordpress_migrate Drupal module and the Drupal Commons 7.x-3.0 distro (which is not yet released, but making good progress). So, expect this guide to be out of date in a matter of days, then try to go along this while omitting the workaround steps (so then include tag and category migrations, and omit the patching).

Step by step guide:

  1. Empty WordPress trash. Before starting the import process, empty your trashbin in the WordPress blog. Else, already trashed posts and their comments are also exported in the WXR file, and will create confusing errors because of showing up as "Unimported" for blog entrys in "Content -> Migrate" statistics in the Drupal admin backend, and also trashed comments causing error messages "No node ID provided for comment" when trying to import comments in spite of the fact that the post was not imported.
  2. Export as WXR. Export a WXR file from your WordPress blog, using the "Tools -> Export" function.
  3. Install wordpress_migrate. Install wordpress_migrate for your Drupal Commons 7 installation. For that, execute in the document root directory of your site:
    drush dl wordpress_migrate
    drush pm-enable wordpress_migrate
  4. Clear cache. Clear the Drupal cache (this is the sign for the migrate framework to register the new migration classes):
    drush cc all
  5. Fix comment migration. There is a bug report with a submitted but not yet accepted  fix that prohibits importing comments, resulting in an error message like "Unknown data property field_target_comments. in EntityStructureWrapper->getPropertyInfo() (line 339 of commons-7.x-3.0-beta1/profiles/commons/modules/contrib/entity/includes/entity.wrapper.inc)." To prevent it, install the fix yourself:
    cd profiles/commons/modules/contrib/commons_notify;
    patch <comment_node_nogroup-1868776.patch;
    drush cc all;
    And if you attempted an unusccessful migration already, go to "Content -> Migration" in the Drupal admin backend and do a "Rollback" and then a "Reset" for the comments migration, before attempting a new one by executing the "Import" action there again.
  6. Start migration. Log into the Drupal admin backend and navigate to "Content -> WordPress migration -> Import". Here, select the following settings (also see their official documentation), then click "Import":
    • Your WXR file as source.
    • "Wordpress categorie: Do not import", "Wordpress tags: Do not import". (If your target content type like (here) "Page" has any vocabulary fields, the "Do not import" option is not available. Choosing one of the vocabularies will then make the import fail with an error message like "MigrateException: No migration found with machine name ExampleTag in MigrationBase::getInstance() (line 444 of […]/sites/all/modules/migrate/includes/base.inc).”. Or the same with “ExampleCategory”. So delete the vocabulary field before via “Structure -> Content types -> [your content type] -> manage fields").
    • "Text: Full HTML", "Comments: Full HTML". [source]
    • "Import pages to: Page" and "Import posts to: Page". [source] (Importing posts to "Post" would result in error messages like "Invalid argument supplied for foreach() File […]/commons_radioactivity.module, line 140". In contrast to pages, posts in Drupal Social Commons can belong to groups. So if you want to make posts, not pages, bulk-convert the pages to posts later with the node_convert module.)
    • Create page aliases to match the original WordPress addresses.
  7. Register migration classes, if necessary. If no importing is possible at all, it may be because on your system the drush cc all did not properly trigger the migration class registration [issue report]. Then instead, call drush migrate-auto-register [source]. This is however buggy in itself: try to access the "Content -> Migration" tab in the Drupal admin backend. It might fail with this error message: "MigrateException: Failure to sort migration list – most likely due to circular dependencies involving OgMigrateContent,OgMigrateUser,OgUiMigrateAddField,OgUiSetRoles in migrate_migrations() ". This is because the drush command erroneously registered these "Og*" names as migration classes. Undo that by deleting the rows from database table migrate_status where column machine_name starts with one of these Og* names. [source1, source2].
  8. Ignore dependencies, if needed. Now your import should run, but it might not succeed. Because, no attachments or comments are imported if even one post fails to be imported. Error messages in this case are like:
    Skipped ExampleAttachment due to unfulfilled dependencies: ExampleBlogEntry
    Skipped ExampleComment due to unfulfilled dependencies: ExampleBlogEntry
    In that case go to "Content -> Migrate" in the Drupal admin backend, select the migrations that have not run, check "Options -> Ingnore dependencies" on the bottom, choose "Import", click "Execute". This will import all comments and attachments for those posts that were properly imported.
  9. Import pingbacks too, if you want. At this time, the migration statistics in "Content -> Migrate" in the Drupal admin backend should show that everything was imported ok, except that there can be a non-zero number for unimported  comments. These are most probably pingback comments. You can check that by looking into the database table migration_map_[migrationname]comment: find some source IDs that are not listed in column sourceid1 but appear in your WXR file as comment ids between <wp:comment_id>…</wp:comment_id>. If these are all pingback comments, indicated by <wp:comment_type>pingback</wp:comment_type> in the WXR file, you know the cause and probably want to ignore these. If you want to import pingbacks, too, you have to modify the WXR file by replacing all <wp:comment_type>pingback</wp:comment_type> with <wp:comment_type></wp:comment_type> (yes, that's correct: delete the value within this tag).
  1. Mailinator. In some sense, a good idea. Namely, when it's only about cutting the link to your real-world identity when entering an e-mail address (like for registering on some site). You have to access Mailinator with TOR though or you might still get tracked down.
  2. mail.riseup.net: You need either two friends to refer you, or to wait between a day and some weeks to get approved for an e-mail account.

More on that: Section on e-mail in Tech Tools for Activism: "Signing up for an independent email address is not an immediate automated process, because of spammers. For example, aktivix.org issues email addresses though a friend-of-a-friend basis. If you know someone with an aktivix.org email address, you can fill in a the sign up form at www.aktivix.org   Alternatively, you can sign up for an account at riseup.net or autistici.org. You will need to fill in a short form letting them know why you want the email and they normally respond in 24 hours."

"Stay away from email services that make their money by collecting user data: it’s a business model that’s bad for privacy. You may have to pay a few dollars a month to a private email service that encrypts and securely stores your data. Some examples are Unspyable, Countermail, Silent Circle, or Lavabit." [source]

This documents the environment I use for software maintenance of Android phones. The emphasis is on efficient and repeatable results.

This is a work in progress!

Basic Android environment under Ubuntu Linux

  1. Install the adb and fastboot tools from Ubuntu packages according to these instructions.

Documentation

This manual lists all the steps, in logical order, to go from a physically broken phone to a great working, free and open source phone. It links to several other articles on this blog for detailing individual aspects.

Hardware

(1) Getting your hardware repair tools ready

I recommend these tools:

(2) Identifying hardware defects

 

(3) Repairing hardware defects

 

Software

(4) Getting your software tools ready

Installing WIndows drivers for the phone: For the HTC Incredible, that means installing HTC Sync (see right column there for download!). You can uninstall this again after installing.

(5) Freeing the phone: Rooting and S-OFF

  1. Follow the All in One Noob Guide For Downgrade and S Off for HTC Incredible S. Here are my own notes: [TODO]
    • To decide if you need to do the HBOOT downgrading process at all you have to determine your HBOOT verion number at first. Basicall: boot into the bootloader, it’s written there [instructions].
    • For the HBOOT downgrading and rooting process, I used these instructions because I could not find the (more comfortable, less manual) Downgradekit from the above “All in One Noob Buide”. However, one step is missing in these instructions between 6. and 7.: you have to relock the bootloader [source and instructions].
    • After HBOOT downgrading and rooting, I proceeded with the All in One Noob Guide For Downgrade and S Off already linked above.
    • I had a problem to get the “Revolutionary” tool do its job under Windows XP, probably caused by some part of the HTC Sync software that I should have deinstalled before but could not find [source]. The error message was “rawadb_open remote closed the connection looking for target”.  Using Revolutionary on Linux was immediately successful – but remember to run it as root or add appropriate udev rules to get your device detected [source].
    • I did not install Clockwork Recovery, but the 4EXT one as I like it more. Means I chose “no” when Revolutionary asked if it should flash Clockwork to the phone, and did an ” fastboot flash recovery recovery.img” with the 4EXT recovery image.
  2. Install the unofficial CyanogeMod 10 ROM. It performed very well on my device, except that it needs the workaround for video recording as mentioned by the developer. Do not forget to install Google Apps at the same time, the link is also in that post.

(6) Installing a Custom ROM

This is well explained in the HTC Incredible S installation instructions for CyanogenMod. They use Clockword Recovery there, but it works just the same with 4EXT Recovery. It’s really simple!

(7) Installing great applications

See the article How to do unattended bulk installs of Android apps? on this site.

(8) Creating backups and a backup solution

 

Knowledge Resources

Solution

This solution was tested with Froxlor 0.9.27.

  1. Create subdomain as full domain. As a Froxlor admin user, create a new domain and enter webmail.example.com as domain name. You can choose any host, ideally your main / default domain. This type fo configuration is called a "full domain", allowing full configuration like vhost file additions that are not available for subdomains created by customers.
  2. Make webmail available under your single subdomain. That is, either install your webmail package it in the default document root location provided by Froxlor, or  point that document root location with a symlink to the document root directory provided by your installation (for example /usr/share/roundcube for Roundcube installed as a Debian package).
  3. Adapt open_basedir. If you want to use the open_basedir PHP ini setting (available in the Froxlor domain configuration) for your webmail installation,  you may have to add some directories as explained here because for example, Roundcube needs to include PEAR classes, write to logs etc.. Check the Apache error log to know which ones to include. However, do not simply include the directories named in the error log, but check these paths for symlink components, and configure open_basedir with equivelanet paths that have no directory symlinks in them. It won't work otherwise! In my case it was finally:
      php_admin_value open_basedir "/usr/share/roundcube/:/var/lib/roundcube/:/var/log/roundcube/:/etc/roundcube/:/usr/share/php/:/tmp/"
  4. Add ServerAlias. Again in the "Own vHost settings" section the Froxlor domain configuration dialog of your webmail.example.com domain, add this line:
      ServerAlias webmail.*.*
  5. Make sure the webmail subdomain resolves to your server's IP for all customer domains. The simplest way to achieve this is to set "Enter as wildcard domain?: Yes" for all customer domains (that are not subdomains themselves). This option is only available when editing these domains with the customer's user in Froxlor, via "Resources -> Customers", then clicking a customer's name, which su's you to the customer's user, then editing the customer's domain. If this option is still not available it is because you have configured an insufficient number of subdomains for the respective customer in Froxlor; there has to be at least one per domain.
  6. Re-create configs. For that, do one of these:
    1. Execute this via SSH on the server:
      php /var/www/froxlor/scripts/froxlor_master_cronjob.php --force
    2. Wait until the next Froxlor cron job runs, which will also rewrite all vhost configs that need changes. (Clicking "Server -> Re-create configs" in Froxlor won't speed that up, it just queues additional config files for re-creation.)
  7. Restart Apache. Because the config changes will not be picked up in all cases automatically. So:
    service restart apache2
  8. Test. Now, a webmail subdomain should be available for every second level domain hosted on your server: webmail.example1.com, webmail.example2.com etc..

Webmail subdomains at any level?

With Froxlor, it is not easily possible to add webmail subdomains also to subdomains, like webmail.sub.example.com or webmail.subsub.sub.example.com. However, this is hardly needed anyway. The only workaround so far is to create every subdomain as a "full domain" in Froxlor, like shown above, and to disable the "Enter as wildcard domain" setting for it. Note that you can create a "full domain" only as admin, but the "Enter as wildcard domain" setting is only available when modifying this domain as customer (completely counterintuitive to have settings hidden from admins!). Of course, when hosting websites for customers, you don't want them to bother you the admin whenever they need a new subdomain, so this solution is hardly practical for those cases.

The reason for this problem is something that I see as a bug in Froxlor: it creates a wildcard ServerAlias *.sub.example.com for every subdomain created by a customer user (that is, every non-full domain). And there's no way to disable that except for patching the source code. While for all domains added as full domains, there is an option to disable that (see above, and as explained in Froxlor issue 175).

Why is there no conflict between "Enter as wildcard domain" for a customer domain, and ServerAlias webmail.*.*?

The reason that the above ServerAlias wildcard directive for webmail subdomains works together with the "Enter as wildcard domain" setting for every second level domain is that the corresponding config file is included fist by Apache, so webmail.*.* takes precedence over *.example.com because Apache works on first-match basis here. And the reason it is included first is just that third-level domains (subdomains) created as "full domains" have a config file filename starting with "21_" while second-level domains (normal domains) start with "22_", respectively. We had good luck with a bad hack here 😉

Even more strange, the "Enter as wildcard domain" setting is even required to make in Froxlor if you followed the instructions above. But not to make the webmail subdomain resolve to the same content as the customer's domain, as intended by Froxlor. Rather to force the creation of a wildcard nameserver entry that resolves th webmail subdomain to the same IP address as the server, where it will then be picked up by "ServerAlias webmail.*.*", to show the content of your webmail system.