mirror of
https://github.com/phpbb/phpbb.git
synced 2025-02-13 12:35:06 +01:00
git-svn-id: file:///svn/phpbb/trunk@7020 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
e8e47bac0c
commit
66b18be324
@ -235,7 +235,7 @@ $auth = new auth();
|
||||
<p>The <code>acl</code> method is the initialisation routine for all the acl functions. If you intend calling any acl method you must first call this. The method takes as its one and only required parameter an associative array containing user information as stored in the database. This array must contain at least the following information; user_id, user_permissions and user_type. It is called in the following way:</p>
|
||||
|
||||
<blockquote><pre>
|
||||
$auth->acl(<code>userdata</code>);
|
||||
$auth->acl(<code>userdata</code>);
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Where userdata is the array containing the aforementioned data.</p>
|
||||
@ -252,7 +252,7 @@ $auth->acl(<code>userdata</code>);
|
||||
<p>This method is the primary way of determining what a user can and cannot do for a given option globally or in a given forum. The method should be called in the following way:</p>
|
||||
|
||||
<blockquote><pre>
|
||||
$result = $auth->acl_get(<code>option</code>[, <code>forum</code>]);
|
||||
$result = $auth->acl_get(<code>option</code>[, <code>forum</code>]);
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Where option is a string representing the required option, e.g. 'f_list', 'm_edit', 'a_adduser', etc. By adding a ! in front of the option, e.g. '!f_list' the result of this method will be negated. The optional forum term is the integer forum_id.</p>
|
||||
@ -277,7 +277,7 @@ $result = $auth->acl_get(<code>option</code>[, <code>forum</code>]);
|
||||
<p>The method should be called thus:</p>
|
||||
|
||||
<blockquote><pre>
|
||||
$result = $auth->acl_gets(<code>option1</code>[, <code>option2</code>, ..., <code>optionN</code>, <code>forum</code>]);
|
||||
$result = $auth->acl_gets(<code>option1</code>[, <code>option2</code>, ..., <code>optionN</code>, <code>forum</code>]);
|
||||
</pre></blockquote>
|
||||
|
||||
<p>As with the <code>acl_get</code> method the options are strings representing the required permissions to check. The forum again is an integer representing a given forum_id.</p>
|
||||
@ -296,7 +296,7 @@ $result = $auth->acl_gets(<code>option1</code>[, <code>option2</code>, ..., <cod
|
||||
<p>This method is used to find out in which forums a user is allowed to carry out an operation or to find out in which forums he is not allowed to carry out an operation. The method should be called in the following way:</p>
|
||||
|
||||
<blockquote><pre>
|
||||
$result = $auth->acl_getf(<code>option</code>[, <code>clean</code>]);
|
||||
$result = $auth->acl_getf(<code>option</code>[, <code>clean</code>]);
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Just like in the <code>acl_get</code> method the option is a string specifying the permission which has to be checked (negation using ! is allowed). The second parameter is a boolean. If it is set to false this method returns all forums with either zero or a positive integer. If it is set to true only those forums with a positive integer as the result will be returned.</p>
|
||||
@ -304,7 +304,7 @@ $result = $auth->acl_getf(<code>option</code>[, <code>clean</code>]);
|
||||
<p>The method returns an associative array of the form:</p>
|
||||
|
||||
<blockquote><pre>
|
||||
array(<em>forum_id1</em> => array(<em>option</em> => <em>integer</em>), <em>forum_id2</em> => ...)
|
||||
array(<em>forum_id1</em> => array(<em>option</em> => <em>integer</em>), <em>forum_id2</em> => ...)
|
||||
</pre></blockquote>
|
||||
|
||||
<p>Where option is the option passed to the method and integer is either zero or a positive integer and the same <code>acl_get(option, forum_id)</code> would return.</p>
|
||||
|
@ -598,7 +598,7 @@ if (isset($forum)) ...
|
||||
if (isset($forum) && $forum == 5)
|
||||
</pre></blockquote>
|
||||
|
||||
<p>The <code>empty()</code> function is useful if you want to check if a variable is not set or being empty (an empty string, 0 as an integer or string, NULL, false, an empty array or a variable declared, but without a value in a class). Therefore empty should be used in favor of <code>isset($array) && sizeof($array) > 0</code> - this can be written in a shorter way as <code>!empty($array)</code>.</p>
|
||||
<p>The <code>empty()</code> function is useful if you want to check if a variable is not set or being empty (an empty string, 0 as an integer or string, NULL, false, an empty array or a variable declared, but without a value in a class). Therefore empty should be used in favor of <code>isset($array) && sizeof($array) > 0</code> - this can be written in a shorter way as <code>!empty($array)</code>.</p>
|
||||
|
||||
<h3>Switch statements:</h3>
|
||||
<p>Switch/case code blocks can get a bit long sometimes. To have some level of notice and being in-line with the opening/closing brace requirement (where they are on the same line for better readability), this also applies to switch/case code blocks and the breaks. An example:</p>
|
||||
@ -769,9 +769,9 @@ $sql = 'SELECT *
|
||||
|
||||
<blockquote><pre>
|
||||
$sql_ary = array(
|
||||
'somedata' => $my_string,
|
||||
'otherdata' => $an_int,
|
||||
'moredata' => $another_int
|
||||
'somedata' => $my_string,
|
||||
'otherdata' => $an_int,
|
||||
'moredata' => $another_int
|
||||
);
|
||||
|
||||
$db->sql_query('INSERT INTO ' . SOME_TABLE . ' ' . $db->sql_build_array('INSERT', $sql_ary));
|
||||
@ -781,9 +781,9 @@ $db->sql_query('INSERT INTO ' . SOME_TABLE . ' ' . $db->sql_build_array('I
|
||||
|
||||
<blockquote><pre>
|
||||
$sql_ary = array(
|
||||
'somedata' => $my_string,
|
||||
'otherdata' => $an_int,
|
||||
'moredata' => $another_int
|
||||
'somedata' => $my_string,
|
||||
'otherdata' => $an_int,
|
||||
'moredata' => $another_int
|
||||
);
|
||||
|
||||
$sql = 'UPDATE ' . SOME_TABLE . '
|
||||
@ -850,24 +850,24 @@ SELECT FROM phpbb_forums WHERE forum_id <strong><></strong> 1
|
||||
|
||||
<blockquote><pre>
|
||||
$sql_array = array(
|
||||
'SELECT' => 'f.*, ft.mark_time',
|
||||
'SELECT' => 'f.*, ft.mark_time',
|
||||
|
||||
'FROM' => array(
|
||||
FORUMS_WATCH_TABLE => 'fw',
|
||||
FORUMS_TABLE => 'f'
|
||||
'FROM' => array(
|
||||
FORUMS_WATCH_TABLE => 'fw',
|
||||
FORUMS_TABLE => 'f'
|
||||
),
|
||||
|
||||
'LEFT_JOIN' => array(
|
||||
'LEFT_JOIN' => array(
|
||||
array(
|
||||
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'
|
||||
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'
|
||||
)
|
||||
),
|
||||
|
||||
'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '
|
||||
'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '
|
||||
AND f.forum_id = fw.forum_id',
|
||||
|
||||
'ORDER_BY' => 'left_id'
|
||||
'ORDER_BY' => 'left_id'
|
||||
);
|
||||
|
||||
$sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
@ -877,25 +877,25 @@ $sql = $db->sql_build_query('SELECT', $sql_array);
|
||||
|
||||
<blockquote><pre>
|
||||
$sql_array = array(
|
||||
'SELECT' => 'f.*',
|
||||
'SELECT' => 'f.*',
|
||||
|
||||
'FROM' => array(
|
||||
FORUMS_WATCH_TABLE => 'fw',
|
||||
FORUMS_TABLE => 'f'
|
||||
'FROM' => array(
|
||||
FORUMS_WATCH_TABLE => 'fw',
|
||||
FORUMS_TABLE => 'f'
|
||||
),
|
||||
|
||||
'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '
|
||||
'WHERE' => 'fw.user_id = ' . $user->data['user_id'] . '
|
||||
AND f.forum_id = fw.forum_id',
|
||||
|
||||
'ORDER_BY' => 'left_id'
|
||||
'ORDER_BY' => 'left_id'
|
||||
);
|
||||
|
||||
if ($config['load_db_lastread'])
|
||||
{
|
||||
$sql_array['LEFT_JOIN'] = array(
|
||||
array(
|
||||
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'
|
||||
'FROM' => array(FORUMS_TRACK_TABLE => 'ft'),
|
||||
'ON' => 'ft.user_id = ' . $user->data['user_id'] . ' AND ft.forum_id = f.forum_id'
|
||||
)
|
||||
);
|
||||
|
||||
@ -984,7 +984,7 @@ $mark_array = request_var('mark', array(0));
|
||||
|
||||
<p class="good">// Getting an array, keys are strings, value defaults to 0</p>
|
||||
<blockquote><pre>
|
||||
$action_ary = request_var('action', array('' => 0));
|
||||
$action_ary = request_var('action', array('' => 0));
|
||||
</pre></blockquote>
|
||||
|
||||
<h3>Login checks/redirection: </h3>
|
||||
@ -999,12 +999,12 @@ $action_ary = request_var('action', array('' => 0));
|
||||
<p>Sessions should be initiated on each page, as near the top as possible using the following code:</p>
|
||||
|
||||
<blockquote><pre>
|
||||
$user->session_begin();
|
||||
$auth->acl($user->data);
|
||||
$user->setup();
|
||||
$user->session_begin();
|
||||
$auth->acl($user->data);
|
||||
$user->setup();
|
||||
</pre></blockquote>
|
||||
|
||||
<p>The <code>$user->setup()</code> call can be used to pass on additional language definition and a custom style (used in viewforum).</p>
|
||||
<p>The <code>$user->setup()</code> call can be used to pass on additional language definition and a custom style (used in viewforum).</p>
|
||||
|
||||
<h3>Errors and messages: </h3>
|
||||
<p>All messages/errors should be outputed by calling <code>trigger_error()</code> using the appropriate message type and language string. Example:</p>
|
||||
@ -1328,7 +1328,7 @@ div
|
||||
<p>You are even able to check the number of items within a loop by comparing it with values within the IF condition:</p>
|
||||
|
||||
<blockquote><pre>
|
||||
<span class="comment"><!-- IF .loop > 2 --></span>
|
||||
<span class="comment"><!-- IF .loop > 2 --></span>
|
||||
<span class="comment"><!-- BEGIN loop --></span>
|
||||
markup
|
||||
<span class="comment"><!-- END loop --></span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user