/**
  * Creates a new recipient
  * @param string  $sEMail        Specifies the e-mail adress
  * @param string  $sName         Specifies the recipient name (optional)
  * @param int     $iConfirmed    Specifies, if the recipient is confirmed (optional)
  * @param string  $sJoinID       Specifies additional recipient group ids to join (optional, e.g. 47,12,...)
  * @param int     $iMessageType  Specifies the message type for the recipient (0 = text, 1 = html)
  */
 public function create($sEMail, $sName = "", $iConfirmed = 0, $sJoinID = "", $iMessageType = 0, $bAddToDefaultGroup = true)
 {
     global $client, $lang, $auth;
     $iConfirmed = (int) $iConfirmed;
     $iMessageType = (int) $iMessageType;
     /* Check if the e-mail adress already exists */
     $email = strtolower($email);
     // e-mail always lower case
     $this->setWhere("idclient", $client);
     $this->setWhere("idlang", $lang);
     $this->setWhere("email", $sEMail);
     $this->query();
     if ($this->next()) {
         return $this->create($sEMail . "_" . substr(md5(rand()), 0, 10), $sName, 0, $sJoinID, $iMessageType);
         // 0: Deactivate 'confirmed'
     }
     $oItem = parent::create();
     $oItem->set("idclient", $client);
     $oItem->set("idlang", $lang);
     $oItem->set("name", $sName);
     $oItem->set("email", $sEMail);
     $oItem->set("hash", substr(md5(rand()), 0, 17) . uniqid(""));
     // Generating UID, 30 characters
     $oItem->set("confirmed", $iConfirmed);
     $oItem->set("news_type", $iMessageType);
     if ($iConfirmed) {
         $oItem->set("confirmeddate", date("Y-m-d H:i:s"), false);
     }
     $oItem->set("deactivated", 0);
     $oItem->set("created", date("Y-m-d H:i:s"), false);
     $oItem->set("author", $auth->auth["uid"]);
     $oItem->store();
     $iIDRcp = $oItem->get("idnewsrcp");
     // Getting internal id of new recipient
     if ($bAddToDefaultGroup) {
         // Add this recipient to the default recipient group (if available)
         $oGroups = new RecipientGroupCollection();
         $oGroupMembers = new RecipientGroupMemberCollection();
         $oGroups->setWhere("idclient", $client);
         $oGroups->setWhere("idlang", $lang);
         $oGroups->setWhere("defaultgroup", 1);
         $oGroups->query();
         while ($oGroup = $oGroups->next()) {
             $iIDGroup = $oGroup->get("idnewsgroup");
             $oGroupMembers->create($iIDGroup, $iIDRcp);
         }
     }
     // Add to other recipient groups as well? Do so!
     if ($sJoinID != "") {
         $aJoinID = explode(",", $sJoinID);
         if (count($aJoinID) > 0) {
             foreach ($aJoinID as $iIDGroup) {
                 $oGroupMembers->create($iIDGroup, $iIDRcp);
             }
         }
     }
     return $oItem;
 }
     $oRGroups->setWhere("groupname", $sGroupName);
     $oRGroups->setWhere("idclient", $client);
     $oRGroups->setWhere("idlang", $lang);
     $oRGroups->setWhere($oRGroup->primaryKey, $oRGroup->get($oRGroup->primaryKey), "!=");
     $oRGroups->query();
     if ($oRGroups->next()) {
         $aMessages[] = i18n("Could not set new group name: Group already exists", $plugin_name);
     } else {
         $bReload = true;
         $oRGroup->set("groupname", $sGroupName);
     }
 }
 if (count($_REQUEST["adduser"]) > 0) {
     foreach ($_REQUEST["adduser"] as $iRcpID) {
         if (is_numeric($iRcpID)) {
             $oRGroupMembers->create($_REQUEST["idrecipientgroup"], $iRcpID);
         }
     }
 }
 if ($oRGroup->get("defaultgroup") != (int) $_REQUEST["defaultgroup"]) {
     $bReload = true;
     $oRGroup->set("defaultgroup", $_REQUEST["defaultgroup"]);
 }
 $oRGroup->store();
 if ($bReload) {
     $oPage->setReload();
 }
 // Removing users from group (if specified)
 //print_r ($_REQUEST["deluser"]);
 if ($perm->have_perm_area_action($area, "recipientgroup_recipient_delete") && is_array($_REQUEST["deluser"])) {
     foreach ($_REQUEST["deluser"] as $iRcpID) {
                 }
                 break;
             case "plugin":
                 // type may be mentioned here, also, but as plugins currently can't
                 // specify the type, just treat everything as string
                 // There may be plugins which store more than one value per plugin_store-
                 // function. As the plugin_store parameter is an array of values, collect
                 // all values in an array for later storing... unfortunately, that means,
                 // that we have to go through the fields array second time per item *sigh*
                 $aPluginValue[$aDetails["link"]][$sKey] = trim($aParts[$aDetails["col"]]);
                 break;
             case "group":
                 // Add recipient to group
                 $sValue = strtolower(trim($aParts[$aDetails["col"]]));
                 if ($sValue == "yes" || $sValue == i18n("yes", $plugin_name) || $sValue == "true" || is_numeric($sValue) && $sValue > 0) {
                     $oGroupMembers->create(htmlentities($aDetails["link"], ENT_COMPAT, $encoding[$lang]), $iID);
                 }
                 break;
         }
     }
 }
 // Store all base data
 $recipient->store();
 // Store plugin data (to store plugin data, only, where the column has been found in the data
 // should be faster than going through all plugins and store mostly empty arrays)
 $sCurrentPlugin = "";
 foreach ($aFieldDetails as $sKey => $aDetails) {
     if ($aDetails["col"] > -1 && $aDetails["fieldtype"] == "plugin" && $aDetails["link"] !== $sCurrentPlugin) {
         $sCurrentPlugin = $aDetails["link"];
         call_user_func("recipients_" . $sCurrentPlugin . "_store", $aPluginValue[$sCurrentPlugin]);
     }