[pLog-svn] r4110 - plog/trunk/tools
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Mon Oct 9 10:44:52 GMT 2006
Author: oscar
Date: 2006-10-09 10:44:51 +0000 (Mon, 09 Oct 2006)
New Revision: 4110
Added:
plog/trunk/tools/loadcoreperms.php
Log:
added a little script to load permissions to the database
Added: plog/trunk/tools/loadcoreperms.php
===================================================================
--- plog/trunk/tools/loadcoreperms.php 2006-10-09 09:03:39 UTC (rev 4109)
+++ plog/trunk/tools/loadcoreperms.php 2006-10-09 10:44:51 UTC (rev 4110)
@@ -0,0 +1,38 @@
+<?php
+
+ if (!defined( "PLOG_CLASS_PATH" )) {
+ define( "PLOG_CLASS_PATH", dirname(__FILE__)."/../");
+ }
+
+ include_once( PLOG_CLASS_PATH."class/bootstrap.php" );
+ include_once( PLOG_CLASS_PATH."class/database/db.class.php" );
+ include_once( PLOG_CLASS_PATH."install/corepermissions.properties.php" );
+
+ // connect to the db
+ $db =& Db::getDb();
+
+ $total = 0;
+
+ // process permissions
+ foreach( $permissions as $perm ) {
+ // check if it already exists
+ $query = "SELECT * FROM ".Db::getPrefix()."permissions WHERE permission = '".$perm[0]."'";
+ $result = $db->Execute( $query );
+ if( !$result || $result->RowCount() < 1 ) {
+ // permission needs to be added
+ $corePerm = ( $perm[2] == true ? 1 : 0 );
+ $adminOnly = ( $perm[3] == true ? 1 : 0 );
+
+ $query = "INSERT INTO ".Db::getPrefix()."permissions (permission,description,core_perm,admin_only) ".
+ "VALUES ('".$perm[0]."','".$perm[1]."','".$corePerm."','".$adminOnly."')";
+
+ print( "Inserting permission: ".$perm[0]."<br/>" );
+
+ $db->Execute( $query );
+
+ $total++;
+ }
+ }
+
+ print("<br/>$total permissions inserted<br/>");
+?>
\ No newline at end of file
More information about the pLog-svn
mailing list