darkonia hat geschrieben:alle special items müssen die user schon selber machen, die dev umgebung ist ja deswegen eingebaut worden.
Würde ich gerne, nur leider habe ich so gut wie keine Ahnung von php
Kann mir vielleicht jemand helfen?
Also ich habe ein neues benutzerdefiniertes Feld erstellt.
FELD-KENNUNG: level
ART DES FELDES: Zahlen
Er hat das Feld auch wunderbar in der Datenbank erstellt:
Siehe Bild.
Jetzt habe ich die vorgefertigte Datei user_posts_100.php genommen und versucht nach meinen Wünschen zu ändern...
Zuerst habe ich sie kopiert und in level_1.php umbenannt.
Ich habe zum einen oben den Wert geändert:
find:
replace with:
Und zu anderen den Block unten modifiziert:
find:
Code: Alles auswählen
function use_item()
{
global $user, $shop, $db, $phpEx, $phpbb_root_path;
$this->remove_item();
$posts = $user->data['user_posts'] + 100;
$sql_ary = array(
'user_posts ' => $posts,
);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . (int) $user->data['user_id'];
$db->sql_query($sql);
}
replace with:
Code: Alles auswählen
function use_item()
{
global $user, $shop, $db, $phpEx, $phpbb_root_path;
$this->remove_item();
$level = $user->data['pf_level'] + 1;
$sql_ary = array(
'pf_level ' => $level,
);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . (int) $user->data['user_id'];
$db->sql_query($sql);
}
Als ich das Item benutzen wollte, kam folgende Fehlermeldung:
Code: Alles auswählen
Allgemeiner Fehler
SQL ERROR [ mysqli ]
Unknown column 'pf_level' in 'field list' [1054]
SQL
UPDATE phpbb_users SET pf_level = 1 WHERE user_id = 2
BACKTRACE
FILE: includes/db/mysqli.php
LINE: 163
CALL: dbal->sql_error()
FILE: includes/shop/items/level_1.php
LINE: 59
CALL: dbal_mysqli->sql_query()
FILE: includes/shop/functions_shop.php
LINE: 159
CALL: level_1->use_item()
FILE: includes/ucp/ucp_shop.php
LINE: 58
CALL: item->action_handler()
FILE: includes/functions_module.php
LINE: 507
CALL: ucp_shop->main()
FILE: ucp.php
LINE: 321
CALL: p_master->load_active()
Weiß jemand, was ich falsch gemacht habe bzw., was ich ändern muss?
Hier noch ein Mal die originale Datei user_posts_100.php
Code: Alles auswählen
<?php
/**
*
* @package - phpbb3 UPS Easy Shop
* @version $Id: user_posts_100.php 79 2010-02-09 08:12:15Z femu $
* @copyright (c) Wuerzi (http://spieleresidenz.de), (c) femu (http://die-muellers.org)
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/*
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class user_posts_100 extends item
{
function init()
{
}
function get_actions()
{
global $user;
$actions = array();
//In most cases, items that have an action with them should use the "use" action.
//To enable it, uncomment the following code:
$actions['use'] = array(
'name' => $user->lang['ITEM_USE'],
'confirm' => sprintf($user->lang['ITEM_CONFIRM_USE'], $this->data['name']),
'function' => 'use_item'
);
$actions = array_merge($actions, parent::get_actions());
return $actions;
}
function use_item()
{
global $user, $shop, $db, $phpEx, $phpbb_root_path;
$this->remove_item();
$posts = $user->data['user_posts'] + 100;
$sql_ary = array(
'user_posts ' => $posts,
);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . (int) $user->data['user_id'];
$db->sql_query($sql);
}
}
?>
Hier noch ein Mal meine Datei level_1.php
Code: Alles auswählen
<?php
/**
*
* @package - phpbb3 UPS Easy Shop
* @version $Id: user_posts_100.php 79 2010-02-09 08:12:15Z femu $
* @copyright (c) Wuerzi (http://spieleresidenz.de), (c) femu (http://die-muellers.org)
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
/*
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
class level_1 extends item
{
function init()
{
}
function get_actions()
{
global $user;
$actions = array();
//In most cases, items that have an action with them should use the "use" action.
//To enable it, uncomment the following code:
$actions['use'] = array(
'name' => $user->lang['ITEM_USE'],
'confirm' => sprintf($user->lang['ITEM_CONFIRM_USE'], $this->data['name']),
'function' => 'use_item'
);
$actions = array_merge($actions, parent::get_actions());
return $actions;
}
function use_item()
{
global $user, $shop, $db, $phpEx, $phpbb_root_path;
$this->remove_item();
$level = $user->data['pf_level'] + 1;
$sql_ary = array(
'pf_level ' => $level,
);
$sql = 'UPDATE ' . USERS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) . '
WHERE user_id = ' . (int) $user->data['user_id'];
$db->sql_query($sql);
}
}
?>
Ich bin sehr dankbar für jegliche Hilfe..
MfG Peter3