Rules

イベントトリガーでさまざまアクションが作れる便利で高機能なRulesモジュール

概要: 

Rulesモジュールは、Drupal内部でのイベント発生(再アクティブもしくはECA [Evennt Conditosn Action] ルールと言われる)をもとに条件にもとづいてアクションを起こすことができる機能です。 Drupal 7 コアにあるトリガー機能を、より高機能にしたモジュールです。

モジュールのページ: 

ダウンロード: 

必要なモジュール: 

Drupal 7の場合 Entity API https://drupal.org/project/entity

役立つ情報: 

技術資料

RulesのData Selectionについて解説 https://drupal.org/node/1300042

Itangalo's sandbox: Rules Mastery

DrupalCon Denver 2012 でRulesチュートリアルをしたときの内容とコード

Sandboxの状態ですが。 https://drupal.org/sandbox/itangalo/1445770

gitでのダウンロード情報は https://drupal.org/project/1445770/git-instructions

 

ビデオチュートリアル

Rulesトレーニングマニュアル(DrupalCon Denver 2012)とビデオ

DrupalCon Denver, March 19th 2012 で使われたトレーニング資料とその動画です。

資料は以下のサイトからPDFをダウンロード

http://archive.org/download/TheTinydrupalBookOfRules/book-of-rules-v2.pdf

動画は以下のYouTubeにすべてあります。

https://www.youtube.com/playlist?list=PL84B6FFA4F7ACAD57&feature=view_all

 

以前は、nodeone社のビデオサイトは大変役立ちましたが、現在は、Learn the Rules frameworkで見れます。

Learn the Rules framework ここから

 

The Rules way of life, Rules exercise for DrupalCamp Berlin Sep 17-18, 2011

http://drupalcity.de/session/rules-way-life

 

Rules関連モジュール

Rules Examples :  https://drupal.org/project/rules_example

Rules 2 プラグインのためのサンプルコードです。インストールはコアに追加されます。

Rules Link :  https://drupal.org/project/rules_link

Rulesで定義した機能のリンクを設定できます。設定はViewsと連携して行います。

Rules List Conditons :  https://drupal.org/project/rules_list_conditions

Views Rules :  https://drupal.org/project/views_rules

Rules Forms Support :  https://drupal.org/project/rules_forms

Conditional Rules :  https://drupal.org/project/rules_conditional

Rules Transformers :  https://drupal.org/project/transformers

Transformers Actions と Yahoo Pipe を使うTranformaers Pipelines の2つの機能があります。

 

 

 

Rules_FAQ

Rule モジュール関連

Rulesモジュールおよび関連のモジュールや使い方、学び方、FAQなど。

FAQ

drushコマンドでアップデイト時にエラーになる、例えば、xxxxx/modules/rules/modules/node.rules.inc, line 147 などで止まってしまう場合

参考にしたサイト https://drupal.org/node/2090463

環境: Drupal 7.23

まずエラーのRulesモジュールを削除  rm -rf rules

drush cron

drush dl registry_rebuild

drush rr   <--- registry-rebuild

最新版のRulesモジュールを再インストール  drush pm-download rules

drush updb  <-- updatedb

drush cc all

drush cron   

以上でRulesモジュールをデータベースに再設定できることになります。最後の段階で、もし、ccやcronなどでエラーになる場合は、一度、rulesモジュールをモジュールのディレクトリから削除して。アップデイトやその他の作業を行い、正常動作を確認してから最新版のrulesモジュールをダウンロードします。

用語の説明: 

registry-rebuild

Rebuild the registry table (for classes) and the syste table (for module locations) in a Drupal install.

updatedb (updb)

Apply any database updates required (as with running update.php).

Registry-Rebuild  <--- モジュールではありません

https://drupal.org/project/registry_rebuild

There are times in Drupal 7 when the registry gets hopelessly hosed and you need to rebuild the registry (a list of PHP classes and the files they go with). Sometimes, though, you can't do this regular cache-clear activity because some class is required when the system is trying to bootstrap.

When would you need Registry Rebuild?

You might get something like:

「PHP Fatal error: Class 'EntityAPIControllerExportable' not found in ...sites/all/modules/rules/includes/rules.core.inc on line 11"PHP Fatal error: Class 'EntityAPIControllerExportable' not found in ...sites/all/modules/rules/includes/rules.core.inc on line 11"」

If this happens when you're trying to run update.php, and happens when you're trying to clear your cache, well, you have some trouble. That's what Registry Rebuild is for.

It also may happen that you've moved some module that Drupal requires to bootstrap, and you get a horrible error. Registry Rebuild will also rebuild the system table to get the modules in the right place so you can bootstrap.

How To Use Registry Rebuild With Drush

This is the preferred technique, and it should work with multisite installs.

You can just drush dl registry_rebuild and drush will download it into your .drush folder. (Alternately, you can obtain the package another way and copy the folder into .drush yourself.)

Make a backup of your database.

On a multisite install, cd into the site you're rebuilding, as in cd sites/mymultisite

drush rrdrush rrdrush rrdrush rrdrush rr

 

 

 

CMS: 

User Points

User Pointsモジュール

概要: 

サイト内でさまざまアクションによりユーザのポイントを付加・削除することができるAPIとして機能します。

Category: 

Rules

モジュールのページ: 

ダウンロード: 

必要なモジュール: 

特になし

インストール: 

スクリーンショット

member1というユーザのポイント設定管理画面

ユーザ権限

 

備考: 

パッチや改善情報

Voting APIを使って、投票する場合、ユーザが一度、投票したかをデータベースに保存していないようなので、保存するようにするパッチの情報です。この機能は、Voting API の 7.x-2.x-dev 版でサポートされているように思いますが、インストールしてみるとワーニングとmy Votes results などの機能で不具合がありました。

エラーサンプル

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IS NOT NULL ) AND (.uid = '1' ) )) ORDER BY timestamp DESC' at line 1

7.x-3.x-devもページ表示が白くなる不具合がありました。2014年4月15日現在、Voting APIのバージョンがいくつかあります。結局、7.x-2.11を使います。

 [1]  :  7.x-3.x-dev  -  2013-Oct-19  -  Supported, Development
 [2]  :  7.x-2.x-dev  -  2014-Feb-27  -  Development
 [3]  :  7.x-2.11     -  2013-Mar-22  -  Supported, Recommended,

https://drupal.org/node/1269614

役立つ情報: 

設定方法の説明

以下のサイトでは、Voting Rules の設定をUser Pointsと一緒に行う場合です。

http://s1l.org/userpoints-voting-rules

上記のサンプル設定を、Drupal 7.26 Voting API 7.x-2.11+8-dev  rate 7.x-1.7  Voting riles 7.x-1.0-alpha1  Rules 7.x-2.6  Userpoints7.x-1.0  Userpoints_contrib 7.x-1.x-dev などでの環境です。

実際に、Rateウィジェットで作成した投票をした場合の結果

 

 

 

Rules_Sample_1

Drupal Rulesモジュールのサンプル その1

1)ユーザがログインした時に、指定したページへ移動する

Event 「User has logged in」 Conditions 「User has roles(s)」 
-> Data selector 「account」 
-> Role , select Value, 
-> Match Roles, Value 「all」 Action 「Page redirect」 
-> URL Value 「移動したいURLのパス」

 

2) しばらくログインしていない登録ユーザにリマインダーメールを配信する

暫定的ですが、簡単なアイデアでサンプルとして、デバックしやすいよ うに最後のログアウトから20秒にメールを送る仕組みです。

{ "rules_send_reminder_email_2" : {
    "LABEL" : "send reminder email 2",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "user_logout" : [] },
    "IF" : [
      { "NOT data_is" : {
          "data" : [ "account:last-login" ],
          "value" : { "select" : "account:last-login", "date_offset" : { "value" : 20 } }
        }
      }
    ],
    "DO" : [
      { "mail" : {
          "to" : [ "account:mail" ],
          "subject" : "Reminder test 2",
          "message" : "\u30ea\u30de\u30a4\u30f3\u30c0\u30fc\u3000\u30c6\u30b9\u30c82\u3067\u3059",
          "language" : [ "account:language" ]
        }
      }
    ]
  }
}

 

Rulesで定義した状態から上記のイベント管理が動きますので、定義前のログアウトにも適応なるかは未検証です。

また、以下のサイトにも同じような機能を実行するRulesのサンプルがあります。 

http://drupal.stackexchange.com/questions/128601/how-to-send-email-in-ev...

hook_cronを使った場合は以下のサイトです。

http://drupal.stackexchange.com/questions/60785/how-can-i-send-email-to-...

 

 

タグ: 

オープンソースソフトウェア: 

CMS: