static function create($name = '', $userID = false, $newsletterTypeID) { if ($userID === false) { $userID = eZUser::currentUserID(); } $user = eZUser::fetch($userID, true); $userObject = $user->contentObject(); $data_map = $userObject->attribute('data_map'); $userEmail = $user->attribute('email'); $userMobile = ""; if (isset($data_map['mobile_number'])) { $userMobile = $data_map['mobile_number']->DataText; } $newsletter_type = eZNewsletterType::fetch($newsletterTypeID); $send_date_modifier = $newsletter_type->attribute('send_date_modifier'); $pretext = $newsletter_type->attribute('pretext'); $posttext = $newsletter_type->attribute('posttext'); $newsletter = new eZNewsletter(array('created' => time(), 'send_date' => time() + $send_date_modifier, 'newslettertype_id' => $newsletter_type->attribute('id'), 'pretext' => $pretext, 'posttext' => $posttext, 'creator_id' => $userID, 'preview_email' => $userEmail, 'preview_mobile' => $userMobile, 'name' => $name, 'hash' => md5(time() . '-' . mt_rand()), 'status' => eZNewsletter::StatusDraft)); $newsletter->store(); return $newsletter; }