UpgradingToLiberty

A list of changes that were performed to convert a Bonnie package to ReleaseOne/Liberty

Created by: Stephan Borg, Last modification: 29 Dec 2005 (03:36 UTC)

Convert permissions

Global variables are deprecated and the verifyPermission function can be used to go to an error page on failure, removing duplicate code and standardising on an error page.

<?php
if ($tiki_p_admin_cms == 'y') {
?>

becomes

<?php
if ($gTikiUser->hasPermission('tiki_p_admin_cms')) {
?>

and

<?php
if ( !$gTikiUser->hasPermission'tiki_p_view' )) {
  
$smarty->assign('msg',tra("Permission denied you cannot view pages"));
  
$gTikiSystem->display'error.tpl' );
  die;
}
?>

becomes

<?php
$gTikiSystem
->verifyPermission'tiki_p_view' );
?>


Convert preferences

Function standardisation rename.

<?php
$gTikiSystem
->get_preference("maxArticles"10)
?>

becomes

<?php
$gTikiSystem
->getPreference("maxArticles"10)
?>


Convert enabled packages and features

Global variables are deprecated and the isPackageActive and isFeatureActive functions can be used to go to an error page on failure, removing duplicate code and standardising on an error page.

<?php
if ($feature_articles == 'y') {
?>

becomes

<?php
if ($gTikiSystem->isPackageActive'articles' )) {
?>

and

<?php
if($feature_listPages != 'y') {
   
$smarty->assign('msg',tra("This feature is disabled"));
   
$gTikiSystem->display'error.tpl' );
   die;
}
?>

becomes

<?php
$gTikiSystem
->verifyFeature'feature_listPages' );
?>

and conversion of package active checks at start of pages.

<?php
if ( $feature_articles != 'y' ) {
    
$smarty->assign'msg'tra"This feature is disabled" ) . ": feature_articles" );
    
$smarty->display"error.tpl" );
    die;
}
?>

becomes

<?php
$gTikiSystem
->verifyPackage'articles' );
?>


Register packages

Package name should be lowercase

<?php
$gTikiSystem
->registerPackage'articles'dirname__FILE__ ).'/' );
?>


Convert dependent packages

When errors occur due to missing packages, the follow check code should be inserted in appropriate places.

<?php
if ($gTikiSystem->isPackageActive'categories' )) {
        include_once( 
CATEGORIES_PKG_PATH.'categ_lib.php');
}
?>


Comments_lib has moved


<?php
include_once( KERNEL_PKG_PATH 'comments_lib.php' );
?>

becomes

<?php
include_once( LIBERTY_PKG_PATH 'comments_lib.php' );
?>


Convert db_byte_encode

New location for this function.

<?php
$this
->db_byte_encode$imgdata )
?>

becomes

<?php
$this
->mDb->db_byte_encode$imgdata )
?>


Convert error pages


<?php
$smarty
->display"error.tpl" )
?>

becomes

<?php
$gTikiSystem
->fatalError"Any error message you want" )
?>


Convert error pages


<?php
$smarty
->display"error.tpl" )
?>

becomes

<?php
$gTikiSystem
->display"error.tpl" )
?>


Convert browser title


<?php
$gTikiSystem
->setBrowserTitletra("articles") );
?>

has moved to the display() function, usually on the last line.

<?php
$gTikiSystem
->display'tikipackage:articles/list_articles.tpl'tra("articles") );
?>


Convert User

This is a little complicated, as $user what a text string with the username, where as mUserId is a numerical identifier.

<?php
$user
?>

becomes

<?php
$gTikiUser
->mUserId
?>


Standardise Find

Use minifind to standardise find in lists.

<?php
<table class="find">
<
tr><td>{tr}Find{/tr}</td>
   <
td>
   <
form method="get" action="{$gTikiLoc.SAMPLES_PKG_URL}list_samples.php">
     <
input type="text" name="find" value="{$control.find|escape}/>
     <
input type="submit" name="search" value="{tr}find{/tr}" />
     <
input type="hidden" name="sort_mode" value="{$control.sort_mode|escape}/>
   </
form>
   </
td>
</
tr>
</
table>
?>

becomes

<?php
{minifind sort_mode=$sort_mode}
?>


Smarty tpl changes

Checking for active packages and features


<?php
{include file="tikipackage:categories/categorize.tpl"}
?>

becomes

<?php
{if $gTikiSystem->isPackageActive'categories' )}
  {include 
file="tikipackage:categories/categorize.tpl"}
{/if}
?>


Smarty Menu Templates

Use of
  • and
  • .
    
    <?php
    <class="menuoption" href="{$gTikiLoc.KERNEL_PKG_URL}admin/index.php?page=articles">{tr}Articles Settings{/tr}</a>
    <
    class="menuoption" href="{$gTikiLoc.ARTICLES_PKG_URL}admin/admin_topics.php">{tr}Topics{/tr}</a>
    <
    class="menuoption" href="{$gTikiLoc.ARTICLES_PKG_URL}article_types.php">{tr}Types{/tr}</a>
    ?>

    becomes
    
    <?php
    {strip}
    <
    ul>
      <
    li><class="item" href="{$gTikiLoc.KERNEL_PKG_URL}admin/index.php?page=articles">{tr}Articles Settings{/tr}</a></li>
      <
    li><class="item" href="{$gTikiLoc.ARTICLES_PKG_URL}admin/admin_topics.php">{tr}Topics{/tr}</a></li>
      <
    li><class="item" href="{$gTikiLoc.ARTICLES_PKG_URL}admin/admin_types.php">{tr}Types{/tr}</a></li>
    </
    ul>
    {/
    strip}
    ?>


    Checking for permissions

    
    <?php
    {if $tiki_p_read_article eq 'y'}
      <
    class="menuoption" href="{$gTikiLoc.ARTICLES_PKG_URL}index.php">{tr}Articles home{/tr}</a>
      <
    class="menuoption" href="{$gTikiLoc.ARTICLES_PKG_URL}list.php">{tr}List articles{/tr}</a>
    {/if}
    ?>

    becomes
    
    <?php
    {if $gTikiUser->hasPermission'tiki_p_read_article' )}
      <
    li><class="item" href="{$gTikiLoc.ARTICLES_PKG_URL}index.php">{tikicon ipackage=liberty iname=home iexplain="articles home"} {tr}Articles Home{/tr}</a></li>
      <
    li><class="item" href="{$gTikiLoc.ARTICLES_PKG_URL}list.php">{tikicon ipackage=liberty iname=list iexplain="list articles"} {tr}List articles{/tr}</a></li>
    {/if}
    ?>