|
Felix Laate
|
Monday 20 March 2006 12:37:47 pm
Comment45535
Hi guys, thank you for answering.. Here the full code:
include_once( 'lib/ezutils/classes/ezhttptool.php' );
include_once( 'kernel/common/template.php' );
include_once( 'kernel/classes/ezcontentobject.php' );
include_once( "kernel/classes/ezcontentobjecttreenode.php" );
include_once( 'lib/ezutils/classes/ezini.php' );
include_once( 'lib/ezutils/classes/ezmail.php' );
include_once( 'lib/ezutils/classes/ezmailtransport.php' );
$http =& eZHTTPTool::instance();
$tpl =& templateInit();
$ini =& eZINI::instance( 'notifyme.ini.php' );
$Module =& $Params["Module"];
$navn = $http->postVariable( 'navn' );
$epost = $http->postVariable( 'epost' );
$utvalg = $http->postVariable( 'utvalg' );
if ( $Module->isCurrentAction( 'Create' ) )
{
$parentNodeID = 224;
$params = array( 'ClassFilterType' => 'include',
'ClassFilterArray' => array( 'abonent_epost' ),
'AttributeFilter' => array( array( 'abonent_epost/epost', '=', $epost ) ) );
$objects =& eZContentObjectTreeNode::subtree( $params, $parentNodeID );
if (count($objects) == 1)
{
// Skriv til logg
$logtext = 'ABO FINNES FRA FØR';
WriteToLog($logtext);
}
else
{
$contentClassId = 40;
$class =& eZContentClass::fetch( $contentClassId );
$userID = 1;
$contentObject =& $class->instantiate( $userID, 1 );
$name = $sender;
$contentObject->setAttribute( 'name', $name );
//$parentNodeID = 224; // choose where to put the user
$nodeAssignment =& eZNodeAssignment::create( array('contentobject_id' => $contentObject->attribute( 'id' ), 'contentobject_version' => $contentObject->attribute( 'current_version' ), 'parent_node' => $parentNodeID, 'sort_field' => 2, 'sort_order' => 0, 'is_main' => 1 ));
$nodeAssignment->store();
$version =& $contentObject->version( 1 );
$version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );
$version->store();
$contentObjectID = $contentObject->attribute( 'id' );
$contentObjectAttributes =& $version->contentObjectAttributes();
$contentObjectAttributes[0]->setAttribute( 'data_text', $navn );
$contentObjectAttributes[0]->store();
$contentObjectAttributes[1]->setAttribute( 'data_text', $epost );
$contentObjectAttributes[1]->store();
$utvalgString = implode( '-', $utvalg );
$contentObjectAttributes[2]->setAttribute( 'data_text', $utvalgString );
$contentObjectAttributes[2]->store();
$contentObject->store();
// Publish it
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,'version' => 1 ) );
I really appreciate you people helping me out. After 3 years of developing ez sites I'm finally able to enjoy making extensions and I'm loving it.. Felix
Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com
|