[Dev] Terms Mod

A place for MOD Authors to post and receive feedback on MODs still in development. No MODs within this forum should be used within a live environment!
Scam Warning
Locked
Thunderer
Registered User
Posts: 132
Joined: Mon Apr 20, 2009 1:49 am

[Dev] Terms Mod

Post by Thunderer »

Modification Name:Terms MOD
Author:Thunderer Thunderer

Modification Description:: Adds a Page with your Forum Terms such that members have access to read them
Modification Version:: 1.0.1


I Started working on This a while ago, then shelved it and walked away as it was driving me crazy.

I have now come back to it in an effort to at least complete one MOD and complete it properly, to coding guidelines.

I did put it in for validation, but failed that on a couple of things, one of the main reasons for me leaving this alone, was the advice to include an option to edit the terms from the ACP, and also call the " board name from the configuration", which are both things I did not, and still do not know how to do.

I would like to get this at least to a stage where the intergration is there, I.E ACP editing of the Terms and calling the board name from the configuration.

I have the basic files, but what I have yet to fathom is the best way to call the board name for the configuration and what files need to be placed where for this to work.

The other thing being, of course, where do I start in terms of getting the ACP integration going?

I have put the code for each file that I have so far got below, such that any advice can be better given knowing the content.

phpbbroot/termsofservice.php

Code: Select all

<?php
/**
*
* @package phpBB3
* @version $Id: termsofservice.php Thunderer $
* @copyright (c) 2012 Thunderer
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
*/

/**
* @ignore
*/
define('IN_PHPBB', true);
$phpbb_root_path = (defined('PHPBB_ROOT_PATH')) ? PHPBB_ROOT_PATH : './';
$phpEx = substr(strrchr(__FILE__, '.T'), 1);
include($phpbb_root_path . 'common.' . $phpEx);

// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup('mods/termsofservice');

// Output page
page_header($user->lang['TERMSOFSERVICE'])
;$template->set_filenames(array('body' => 'termsofservice_body.html')
);

page_footer();

?>

phpbbroot/styles/prosilver/template/termsofservice_body.html AFTER running through W3 Validator...

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- INCLUDE overall_header.html -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="generator" content="HTML Tidy for Linux (vers 6 November 2007), see www.w3.org" />
<title></title>

<style type="text/css">
/*<![CDATA[*/
 table.c3 {border-collapse: collapse;}
 span.c2 {font-size: 120%}
 h2.c1 {text-align: center}
/*]]>*/
</style>
</head>
<body>
<table border="0" width="80%" id="table1" class="c3" cellpadding="0">
<tr>
<td height="100">
<h2 class="c1"><strong>{L_TERMSOFSERVICE_NAME}</strong></h2>
</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td align="center"><strong><span class="c2">{L_TERMSOFSERVICE_TITLE}</span></strong></td>
</tr>
<tr>
<td height="41"></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td align="left">{L_TERMSOFSERVICE_TERMS}</td>
</tr>
<tr>
<td align="left"></td>
</tr>
<tr>
<td align="left">{L_TERMSOFSERVICE_THANKS}</td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td>{L_TERMSOFSERVICE_TERMS2}</td>
</tr>
<tr>
<td></td>
</tr>
</table>
<!-- INCLUDE overall_footer.html -->
</body>
</html>

phpbbroot/styles/prosilver/template/termsofservice_body.html (Original Version)

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- INCLUDE overall_header.html -->
<p>
<div align="center">
	<table border="0" width="80%" id="table1" style="border-collapse: collapse; " cellpadding="0">
		<tr>
			<td height="100">
			<p align="center"><font size="5"><b>{L_TERMSOFSERVICE_NAME}</b></font></td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td align="center"><b><font size="4">{L_TERMSOFSERVICE_TITLE}</font></b></td>
		</tr>
		<tr>
			<td height="41">&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td align="left">{L_TERMSOFSERVICE_TERMS}</td>
		</tr>
		<tr>
			<td align="left">&nbsp;</td>
		</tr>
		<tr>
			<td align="left">{L_TERMSOFSERVICE_THANKS}</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
		<tr>
			<td>{L_TERMSOFSERVICE_TERMS2}</td>
		</tr>
		<tr>
			<td>&nbsp;</td>
		</tr>
	</table>
</div>
<br />
</p>
<!-- INCLUDE overall_footer.html -->
root/language/en/mods/termsofservice.php

Code: Select all

<?php
/**
*
* template[English]
*
* @package language
* @version $Id: template.php Raimon $
* @copyright (c) 2012 Thunderer
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
	exit;
}

if (empty($lang) || !is_array($lang))
{
	$lang = array();
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page The International Fellowship Of Trade Cyclists of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
//
// Some characters you may want to copy&paste:
// ’ » “ ” …
//

$lang = array_merge($lang, array(
    'TERMSOFSERVICE'         => 'Terms of service',
	'TERMSOFSERVICE_EXPLAIN' => 'View the terms of service',
	'VIEWING_TERMSOFSERVICE' => 'Viewing the terms of service',
	'TERMSOFSERVICE_NAME' => 'The ---YOUR GROUP/FORUM NAME GOES HERE---',
	'TERMSOFSERVICE_TITLE' => 'These are the Terms of service',
	'TERMSOFSERVICE_TERMS'  => '<strong>THESE ARE THE TERMS OF SERVICE THAT YOU AGREE TO WHEN SIGNING UP TO BE A MEMBER OF THE FORUM. WE HAVE PROVIDED THEM HERE IN THE HOPE THAT YOU WILL TAKE THE TIME TO PERIODICALLY REFERENCE THEM.</strong>',
	'TERMSOFSERVICE_THANKS'  => '<strong>WE THANK YOU FOR YOUR PATIENCE IN RE-READING THEM AND HOPE THAT YOU UNDERSTAND THEM.IF YOU HAVE ANY QUERIES OR QUESTIONS CONCERNING THESE TERMS OF SERVICE, PLEASE CONTACT AN ADMINISTRATOR OF THE FORUM.</strong>',
	'TERMSOFSERVICE_TERMS2' => 'YOUR TERMS GO HERE',
	));
?>
And finally, my install.mxl file

Code: Select all

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<?xml-stylesheet type="text/xsl" href="modx.prosilver.en.xsl"?>
<!--For security purposes, please check: http://www.phpbb.com/mods/ for the latest version of this MOD. Although MODs are checked before being allowed in the MODs Database there is no guarantee that there are no security problems within the MOD. No support will be given for MODs not found within the MODs Database which can be found at http://www.phpbb.com/mods/-->
<mod xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.phpbb.com/mods/xml/modx-1.2.5.xsd">
<header>
      <license>http://opensource.org/licenses/gpl-license.php GNU General Public License v2</license>
      
      <title lang="en">Terms MOD</title>
      
      <description lang="en">
    This MOD will add a new page to your forum titled "Terms Of Service" using session management (As per "Raimon's" original MOD),
	The page link is added in the same area as the "FAQ", "Members" and "login/logout" links.
      
</description>
      
      <author-notes lang="en">
      <![CDATA[
      
      This MOD is a modification, Re-compososition and expansion of "Raimon's" original "Blank Template MOD".
      
.
      ]]>
      </author-notes>
      
      <author-group>
         <author>
            <realname>Ron Whitmill</realname>
            <username>Thunderer</username>
            <homepage></homepage>
         </author>
      </author-group>
      
      <mod-version>1.0.1</mod-version>
      
      <installation>
         <level>advanced</level>
         <time>930</time>
         <target-version>3.0.10</target-version>
      </installation>
   </header>
   
   <action-group>
      <copy>
         <file from="root/termsofservice.php" to="termsofservice.php" />
         <file from="root/language/en/mods/termsofservice.php" to="language/en/mods/termsofservice.php" />
		 <file from="root/styles/prosilver/template/termsofservice_body.html" to="styles/prosilver/template/termsofservice_body.html" />
      </copy>
      <open src="viewonline.php">
         <edit>
            <find>
            <![CDATA[		case 'search':
			$location = $user->lang['SEARCHING_FORUMS'];
			$location_url = append_sid("{$phpbb_root_path}search.$phpEx");
		break;]]>
            </find>
            <action type="after-add">
            <![CDATA[      
      case 'termsofservice':
         $location = $user->lang['VIEWING_TERMSOFSERVICE'];
         $location_url = append_sid("{$phpbb_root_path}termsofservice.$phpEx");
      break;
            ]]>
            </action>
         </edit>
         
      </open>
      <open src="includes/functions.php">
         <edit>
            <find><![CDATA[
   // The following assigns all _common_ variables that may be used at any point in a template.
               ]]>
            </find>
            <action type="before-add">
               <![CDATA[
$user->add_lang('mods/termsofservice');]]>
            </action>
         </edit>
         <edit>
            <find><![CDATA[
    'U_PRIVATEMSGS'			=> append_sid("{$phpbb_root_path}ucp.$phpEx", 'i=pm&folder=inbox'),
				]]>
			</find> 		 
            <action type="before-add">
               <![CDATA[
'U_TERMSOFSERVICE'         => append_sid("{$phpbb_root_path}termsofservice.$phpEx"),
]]>
            </action>            
         </edit>
      </open>
      <open src="styles/prosilver/template/overall_header.html">
         <edit>
            <find><![CDATA[<!-- IF not S_IS_BOT -->
					
					<!-- IF not S_USER_LOGGED_IN and S_REGISTER_ENABLED and not (S_SHOW_COPPA or S_REGISTRATION) --><li class="icon-register"><a href="{U_REGISTER}">{L_REGISTER}</a></li><!-- ENDIF -->]]></find>
            <action type="before-add"><![CDATA[
            <li class="icon-faq"><a href="{U_TERMSOFSERVICE}" title="{L_TERMSOFSERVICE_EXPLAIN}">{L_TERMSOFSERVICE}</a></li>
               ]]></action>
         </edit>
      </open>
	        <open src="styles/prosilver/template/overall_footer.html">
         <edit>
            <find><![CDATA[<!-- IF U_TEAM --><a href="{U_TEAM}">{L_THE_TEAM}</a> ]]></find>
            <action type="before-add"><![CDATA[<li class="icon-faq"><a href="{U_TERMSOFSERVICE}" title="{L_TERMSOFSERVICE_EXPLAIN}">{L_TERMSOFSERVICE}</a></li>]]></action>
         </edit>
      </open>

<diy-instructions lang="en">

Don't forget to clear your cache and refresh your templates after you have installed this MOD, or you may not see the pages and links you have just installed.

Good Luck with your forum. ;)

</diy-instructions>      
   </action-group>
</mod>

If anyone has any pinters on where to start on the acp integration, I would be very grateful. I'm still learning this php and implementing ACP integration frankly scares me.
User avatar
MichaelC
Consultant
Consultant
Posts: 3642
Joined: Mon Dec 21, 2009 3:36 pm
Location: London, UK
Name: Michael Cullum
Contact:

Re: [Dev] Terms Mod

Post by MichaelC »

http://wiki.phpbb.com/Using_the_phpBB3. ... (MOD_docs) Explains about adding modules.

Also I suggest you put it up in a package with MODX. How to Package your MOD can be viewed here

Good luck. :)
:)
Formerly known as Unknown Bliss.
Formerly Website Team Lead/Manager & Development Team.
Please don't PM me for support (or stuff that belongs in the forums or tracker) but otherwise feel free
User avatar
darkonia
Registered User
Posts: 1901
Joined: Tue May 13, 2008 1:10 pm
Location: Munich, Germany
Contact:

Re: [Dev] Terms Mod

Post by darkonia »

please make a xml instruction like the rules of phpbbb
MMOG-Heaven - Das Gaming Portal
Community bedeutet Gleichgesinnte finden - MMOG-Heaven ist Deine Community! Von Spielern für Spieler bietet Dir dieses Portal genau das, was ein Spieler braucht. Bleibe ständig informiert, finde die neuesten MMORPGs, oder suche die frischesten News aus der Welt des Online Gamings - dieses und vieles mehr erwartet Dich auf MMOG-Heaven.
Thunderer
Registered User
Posts: 132
Joined: Mon Apr 20, 2009 1:49 am

Re: [Dev] Terms Mod

Post by Thunderer »

darkonia wrote:please make a xml instruction like the rules of phpbbb
Could you explain that one?


@ Unknown_bliss, Thanks for the links, something to sink my teeth into.
User avatar
MichaelC
Consultant
Consultant
Posts: 3642
Joined: Mon Dec 21, 2009 3:36 pm
Location: London, UK
Name: Michael Cullum
Contact:

Re: [Dev] Terms Mod

Post by MichaelC »

Thunderer wrote:
darkonia wrote:please make a xml instruction like the rules of phpbbb
Could you explain that one?


@ Unknown_bliss, Thanks for the links, something to sink my teeth into.
Darkonia was referring to packaging it up with MODX. :)
:)
Formerly known as Unknown Bliss.
Formerly Website Team Lead/Manager & Development Team.
Please don't PM me for support (or stuff that belongs in the forums or tracker) but otherwise feel free
Thunderer
Registered User
Posts: 132
Joined: Mon Apr 20, 2009 1:49 am

Re: [Dev] Terms Mod

Post by Thunderer »

aaah, I see.

I have that on my desk, but I really don't see a point to it until I actually get to a stage where I am happy enough with what I have to package it for "testing" on a pc / laptop (I.E non- internet) based server system running a phpbb forum.

I'm beavering away on i, I just need to get things sorted.

I'm still at a loss, despite reading, on how to call the board name from the configuration though......

I am aware that “%1$s” = Board name and that “%2$s” = Board URL, but how to call them?


The basic Idea being, that a page is created, with a link in the navigation, that contains the "Terms of use", which are nominally written in the ucp.php file.

My problem is, I can not for the life of me work out how to either call these into the new page or, for that matter, call them into the ACP module such that they can be edited.
Thunderer
Registered User
Posts: 132
Joined: Mon Apr 20, 2009 1:49 am

Re: [Dev] Terms Mod

Post by Thunderer »

Ok, so I have been working on this a little and have the following for the ACP, based on the page linked to above by "unknown bliss".

root/adm/style/acp_terms.php (I will resolve the full content once I know how to include the intended content)

Code: Select all

<!-- INCLUDE overall_header.html -->

ACP TERMS MOD CONTENT TO BE ENTERED HERE

<!-- INCLUDE overall_footer.html -->
root/includes/acp/info

Code: Select all

<?php
class acp_foo_info
{
    function module()
    {
        return array(
            'filename'    => 'acp_terms',
            'title'        => 'ACP_TERMS',
            'version'    => '1.0.0',
            'modes'        => array(
                'index'        => array('title' => 'ACP_TERMS_TITLE', 'auth' => 'acl_a_terms_auth', 'cat' => array('')),
            ),
        );
    }

    function install()
    {
    }

    function uninstall()
    {
    }
}
?>
root/includes/acp/acp_terms.php

Code: Select all

<?php
class acp_terms
{
   var $u_action;
   var $new_config;
   function main($id, $mode)
   {
      global $db, $user, $auth, $template;
      global $config, $phpbb_root_path, $phpbb_admin_path, $phpEx;
      switch($mode)
      {
         case 'index':
            $this->page_title = 'ACP_TERMS';
            $this->tpl_name = 'acp_terms';
            break;
      }

   }
}
?>
root/language/en/mods/info_acp_terms.php

Code: Select all

<?php
/**
* DO NOT CHANGE
*/
if (empty($lang) || !is_array($lang))
{
    $lang = array();
}
// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine

$lang = array_merge($lang, array(
    'ACP_TERMS_TITLE'                        => 'Forum Terms',
));
?>
I still have to figure out how to call the terms from the ucp.php file and include hem in the output page of the ACP for editing, which I am still trying to figure out and research.

My other question is, will I need to add permissions within the database by running an SQL query?
Thunderer
Registered User
Posts: 132
Joined: Mon Apr 20, 2009 1:49 am

Re: [Dev] Terms Mod

Post by Thunderer »

I'm still stuck on this.....

I have looked at a few things, but none of it makes any sense o me, nor can I work out how to call the board name & url successfully.

I really want to get this sorted.

Looks like, since I am not getting any tips on where to look, or advice, that the phpbb DEV's want me to dissapear quietly!!!!!!!!
User avatar
Elias
Registered User
Posts: 5152
Joined: Sat Feb 25, 2006 4:31 pm
Name: Elias

Re: [Dev] Terms Mod

Post by Elias »

Thunderer wrote:aaah, I see.

I have that on my desk, but I really don't see a point to it until I actually get to a stage where I am happy enough with what I have to package it for "testing" on a pc / laptop (I.E non- internet) based server system running a phpbb forum.
Your MOD has to be able to be installed with AutoMOD.
Which means, working on the UMIL files is part of the testing to see if the MOD installs with AutoMOD ;)

Thanks
"Mystery creates wonder, and wonder is the basis of man's desire to understand." - Neil Armstrong
|Installing Extensions|Writing Extensions|Extension Validation Policy|
Thunderer
Registered User
Posts: 132
Joined: Mon Apr 20, 2009 1:49 am

Re: [Dev] Terms Mod

Post by Thunderer »

Oh I understand that fully, I just don't like to push the package while it is incomplete......

There is still the ACP side to complete before I contemplate compiling it all into an "automod" package, which is where I have hit a brick wall.

I have to work out how to include the option of editing the "Terms" in the ACP by calling them from the necessary file, which also includes adding the necessary permissions and ACP module, not to mention working out how to correctly call the board name and URL from the configuration.

As a newcomer to the ACP inclusion side of things, it's all a bit daunting, but it seems what the DEV team want, they must have, so here I am!
Thunderer
Registered User
Posts: 132
Joined: Mon Apr 20, 2009 1:49 am

Re: [Dev] Terms Mod

Post by Thunderer »

OK, I have been working on this since my last post and I am still no nearer to pulling the "Terms" from the UCP for editing in the ACP, on top of that and despite reading what seems like reams of pages of data, I am still no closer to getting the actual ACP module written.

I am so stuck, it's like I am in cment with this one.

Anyone have any ideas?
User avatar
Elias
Registered User
Posts: 5152
Joined: Sat Feb 25, 2006 4:31 pm
Name: Elias

Re: [Dev] Terms Mod

Post by Elias »

Thunderer wrote:OK, I have been working on this since my last post and I am still no nearer to pulling the "Terms" from the UCP for editing in the ACP, on top of that and despite reading what seems like reams of pages of data, I am still no closer to getting the actual ACP module written.

I am so stuck, it's like I am in cment with this one.

Anyone have any ideas?
You should ask in the MOD Writers forum since it is very hard to find your question here!

Thanks
"Mystery creates wonder, and wonder is the basis of man's desire to understand." - Neil Armstrong
|Installing Extensions|Writing Extensions|Extension Validation Policy|
Locked

Return to “[3.0.x] MODs in Development”