<?xml version="1.0" encoding="UTF-8"  standalone="yes" ?>
<rss version="2.0">
	<channel>
		<title>社群: Web Programming - 文件區(Action)</title>
		<description>台灣數位學習數位教學平台 RSS feed provider</description>
		<language>zh-tw</language>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doclist&amp;folderID=1233</link>
	<item>
		<title>Create a new action</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5690</link>
		<description>1. hook_action_info() - describe the action to Drupal 
&amp;nbsp;
function user_action_info()&amp;nbsp;&amp;nbsp; return array(&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;user_block_user_action&#039; =&amp;gt; array(&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;description&#039; =&amp;gt; t(&#039;Block current user&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;type&#039; =&amp;gt; &#039;user&#039;,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;configurable&#039; =&amp;gt; FALSE,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;hooks&#039; =&amp;gt; array(&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;nodeapi&#039; =&amp;gt; array(&#039;presave&#039;, &#039;delete&#039;, &#039;insert&#039;, &#039;update&#039;, &#039;view&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;comment&#039; =&amp;gt; array(&#039;view&#039;, &#039;insert&#039;, &#039;update&#039;, &#039;delete&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;user&#039; =&amp;gt; array(&#039;logout&#039;),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ),&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ),
&amp;nbsp;&amp;nbsp;&amp;nbsp; &#039;user_block_ip_action&#039; =&amp;gt; array(&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;...&amp;nbsp;&amp;nbsp;&amp;nbsp; ),&amp;nbsp; );}
&amp;nbsp;
1. http://drupal6/admin/settings/actions&amp;nbsp;
2. &#039;user_block_user_action&#039;
function name of the action (key)
modulename + description of what the function does + &#039;_action&#039;
user + block user + action
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
2. Writing an action
function user_block_user_action(&amp;amp;$object, $context = array()) {&amp;nbsp; // get the uid from the object&amp;nbsp; if (isset($object-&amp;gt;uid)) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $uid = $object-&amp;gt;uid;&amp;nbsp; }&amp;nbsp; elseif (isset($context[&#039;uid&#039;])) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $uid = $context[&#039;uid&#039;];&amp;nbsp; }&amp;nbsp; else {&amp;nbsp;&amp;nbsp;&amp;nbsp; global $user;&amp;nbsp;&amp;nbsp;&amp;nbsp; $uid = $user-&amp;gt;uid;&amp;nbsp; }&amp;nbsp; // make sure we have a user record&amp;nbsp; if ($uid) {&amp;nbsp;&amp;nbsp;&amp;nbsp; $user = user_load($uid);&amp;nbsp;&amp;nbsp;&amp;nbsp; // block the user&amp;nbsp;&amp;nbsp;&amp;nbsp; db_query(&quot;UPDATE {users} SET status = 0 WHERE uid = %d&quot;, $uid);&amp;nbsp;&amp;nbsp;&amp;nbsp; // log out the user&amp;nbsp;&amp;nbsp;&amp;nbsp; sess_destroy_uid($uid);&amp;nbsp;&amp;nbsp;&amp;nbsp; // record a message noting the action taken&amp;nbsp;&amp;nbsp;&amp;nbsp; watchdog(&#039;action&#039;, &#039;Blocked user %name / uid=%uid.&#039;, array(&#039;%name&#039; =&amp;gt; check_plain($user-&amp;gt;name), &#039;%uid&#039; =&amp;gt; $uid));&amp;nbsp; }}?&amp;gt; </description>
		<pubDate>Sat, 30 Apr 2011 11:03:31 +0800</pubDate>
	</item>
	<item>
		<title>Code place</title>
		<link>http://lms.xms.com.tw/board.php?courseID=100&amp;f=doc&amp;cid=5688</link>
		<description>1. includes/actions.inc The actions engine, which executes actions
&amp;nbsp;
2. modules/trigger.moduleThe dispatcher for actions
&amp;nbsp;
3. modules/system.moduleThe configuration screens for adding, removing, and configuring individual actions
&amp;nbsp;
4. modules/trigger.moduleThe interface for assigning actions to events (that is, hooks)
&amp;nbsp;
5. individual modulesThe hook that describes actions (hook_actions_info()) and the actions themselves live inEx. Actions that affect nodes, like the &quot;Publish node&quot; action, live in node.module </description>
		<pubDate>Sat, 30 Apr 2011 10:40:49 +0800</pubDate>
	</item>
	</channel>
	</rss>
