I don't find this learning curve nice. I may just have an off day today, but it seems that I can't get any thing to work or to understand.
So here goes; I've looked on the forum, in the doc and some code:
1. Why does my onAfterLogin not work? (See code snippet 1 below - the onUserActive works)
2. How do I do a form that will set my own values in the database (not using CB fields) - (See code snippet 2 below) - The question here is what should the name of the input field be?
Code snippet 1:
[code:1]$_PLUGINS->registerFunction('onUserActive', 'myUserActivated', 'getSugarCubesTab' );
$_PLUGINS->registerFunction('onAfterLogin', 'myAfterLogin', 'getSugarCubesTab' );
class getSugarCubesTab extends cbTabHandler
{
//--->8-- Snip --8<---
function myAfterLogin($user, $success)
{
//Not sure if all of these globals are needed
global $ueConfig, $mosConfig_absolute_path, $mosConfig_uniquemail, $database;
/**ReportToTest BEGIN**/
$str = "myAfterLogin";
$qa = "INSERT INTO `#__sugarcubes_test` VALUES(NULL,'";
$qa .= $str;
$qa .= "')";
$database->setQuery($qa);
$database->query();
/**ReportToTest END**/
}
//--->8-- Snip --8<---
}
[/code:1]
Code snippet 2 (Same file as above code snippet):
[code:1]
class getSugarCubesManagementTab extends cbTabHandler
{
//--->8-- Snip --8<---
function getDisplayTab($tab,$user,$ui)
{
global $my,$mainframe,$mosConfig_lang;
global $database;
//$this->_getLanguageFile();
//$tabparams=$this->_pgGetTabParameters($user);
$htmltext1 = "";
//if (!$tabparams["pgmanagementtabenabled"]) return $htmltext1;
// Is user a moderator?
$isModerator=isModerator($my->id);
if(!$isModerator) return $htmltext1;
$htmltext1 = "<H1>Edit points for:</H1>";
$base_url = $this->_getAbsURLwithParam(array());
//$pgitemtitle = $_POST[$this->_getPagingParamName("pgitemtitle"«»)];
$htmltext1 .= "<form action=\"$base_url\" method=\"GET\" >";
$htmltext1 .= "<TABLE BORDER=1><TR><TD><B>#</B></TD><TD><B>Point name</B></TD><TD><B>Description</B></TD><TD><B>Points per action</B></TD></TR>";
$q = "SELECT * from `#__sugarcubes_points_config`";
$database->setQuery($q);
$rs = $database->loadAssocList();
foreach($rs as $r)
{
$htmltext1 .= '<TR><TD>'. $r. '</TD><TD>' . $r . '</TD><TD>' . $r . '</TD><TD ALIGN=RIGHT><INPUT SIZE="5" TYPE="text" NAME="SUGARCUBEPOINTID_'. $r . '" VALUE="' . $r . '"></TD></TR>';
}
$htmltext1 .= "</TABLE>";
$htmltext1 .= "<input type=\"submit\" value=\"Update\" class=\"button\" />";
$htmltext1 .= "</form>";
return $htmltext1;
}
//--->8-- Snip --8<---
}
[/code:1]