/*!
\return custom email for the given order
775854
function email( $order )
    {
        $email = false;
        $xmlString = $order->attribute( 'data_text_1' );
        if ( $xmlString != null )
        {
            $dom = new DOMDocument( '1.0', 'utf-8' );
            $success = $dom->loadXML( $xmlString );
            $emailNode = $dom->getElementsByTagName( 'email' )->item( 0 );
            if ( $emailNode )
            {
                $email = $emailNode->textContent;
            }
        }

        return $email;
    }
807188
function checkemail(next) {
      if (user.email) {
        userent.load$({ email: user.email }, function(err, userfound) {
          if (err) return done(err, { ok: false, user: user })
          if (userfound)
            return done(null, {
              ok: false,
              why: 'email-exists',
              nick: args.nick
            })
          next()
        })
        return
      }
      next()
    }
439121
function order($order)
	{
		$parsed_order = array();
		foreach(explode(',', $order) as $property_name)
		{
			$property_name = trim($property_name);
			if(preg_match('/^-(.+)/', $property_name, $m))
			{
				$property_name = $m[1];
				$dir = ' DESC';
			}
			else
				$dir = '';

			$property_name = $this->first_parse($property_name);
			$property_name = $this->stack_parse($property_name);
			$property_name = $this->class_parse($property_name);

			$parsed_order[] = "$property_name$dir";
		}

		$this->_where['*raw_order'] = "ORDER BY ".join(', ', $parsed_order);

		return $this;
	}
60336
public function sendNotification($order)
    {
        // Deal with customer email
        if ($order->Email && ($this->SendNotificationTo == 'Customer' || $this->SendNotificationTo == "Both")) {
            if ($this->CustomSubject) {
                $subject = $this->CustomSubject;
            } else {
                $subject = _t('Orders.Order', 'Order') . " {$order->FullRef} {$order->Status}";
            }

            $email = Email::create()
                ->setSubject($subject)
                ->setTo($order->Email)
                ->setHTMLTemplate("\\SilverCommerce\\OrdersAdmin\\Email\\OrderNotificationEmail_Customer")
                ->setData([
                    "Order" => $order,
                    "SiteConfig" => $this->Parent(),
                    "Notification" => $this
                ]);

            if ($this->FromEmail) {
                $email->setFrom($this->FromEmail);
            }
            
            $this->extend("augmentEmailCustomer", $email, $order);
            
            $email->send();
        }

        // Deal with vendor email
        if ($this->VendorEmail && ($this->SendNotificationTo == 'Vendor' || $this->SendNotificationTo == "Both")) {
            if ($this->CustomSubject) {
                $subject = $this->CustomSubject;
            } else {
                $subject = _t('Orders.Order', 'Order') . " {$order->FullRef} {$order->Status}";
            }
            
            $email = Email::create()
                ->setSubject($subject)
                ->setTo($this->VendorEmail)
                ->setHTMLTemplate("\\SilverCommerce\\OrdersAdmin\\Email\\OrderNotificationEmail_Vendor")
                ->setData([
                    "Order" => $order,
                    "Notification" => $this
                ]);

            if ($this->FromEmail) {
                $email->setFrom($this->FromEmail);
            }
            
            $this->extend("augmentEmailVendor", $email, $order);
            
            $email->send();
        }
        
        $this->extend("augmentSend", $order);
    }
15828
function getOverriddenEmail(email: string): string {
  if (!cfg.email.devEmail) {
    throw new Error("Email failed to send: cfg.email.devEmail is not set");
  }
  const devEmailParts = cfg.email.devEmail.split("@");
  return `${devEmailParts[0]}+${email.replace("@", ".at.")}@${
    devEmailParts[1]
  }`;
}
896586
public function prepareOrderParam() {

        if (isset($this->request['order']) and ! empty($this->request['order'])) {
            $paramOrder = $this->request['order'];
            $returnOrder = Array();
            if (strlen($paramOrder) > 3) {
                if (is_int(strpos($paramOrder, "[")) and is_int(strpos($paramOrder, "]"))) {
                    $matches2 = $matches = null;
                    preg_match_all("/\[[^\]].*?\]/", $paramOrder, $matches, PREG_PATTERN_ORDER);
                    preg_match_all('/\=(.+)/s', $paramOrder, $matches2);
                    $returnOrder[0]['indexColumn'] = str_replace("]", '', str_replace("[", '', $matches[0][0]));
                    $returnOrder[0]['valueColumn'] = str_replace("=", '', $matches2[1][0]);
                }
            }
            return $returnOrder;
        } else {
            return null;
        }
    }
966962
protected function _prepareFromAddress($email)
    {
        $from = $email->getReturnPath();
        if (empty($from)) {
            $from = $email->getFrom();
        }

        return $from;
    }
211760
private function getOrderNormalizer()
    {
        return function(Options $options, $order) {
            foreach ($order as $field => $sort) {
                if (!is_string($sort) || !is_string($field) || !in_array(strtolower($sort), ['asc', 'desc'])) {
                    throw new Exception(
                        'Order value should be an array of string (["field" => $key]), got '.gettype($sort)
                    );
                }
            }

            return $order;
        };
    }
605941
public static function stripEmail($email) {
		if (strpos($email, '<') && substr($email, -1) == '>') {
			return substr($email, strpos($email, '<') + 1, (strlen($email) - strpos($email, '<')) - 2);
		}
		return $email;
	}
1371487
public static function create($order)
    {
        $data = OpenPayU_Util::buildJsonFromArray($order);

        if (empty($data)) {
            throw new OpenPayU_Exception('Empty message OrderCreateRequest');
        }

        try {
            $authType = self::getAuth();
        } catch (OpenPayU_Exception $e) {
            throw new OpenPayU_Exception($e->getMessage(), $e->getCode());
        }

        $pathUrl = OpenPayU_Configuration::getServiceUrl() . self::ORDER_SERVICE;

        $result = self::verifyResponse(OpenPayU_Http::doPost($pathUrl, $data, $authType), 'OrderCreateResponse');

        return $result;
    }
389983
public function withEmail($email)
    {
        $request = clone $this;
        $request->email = $email instanceof Email ? $email : new Email($email);

        return $request;
    }
714427
public function getOrder($orderCode = false)
    {
        if (empty($orderCode) || !is_string($orderCode)) {
            Error::throwError('ip', Error::$errors['orderInput']['orderCode']);
        }
        $response = OrderService::getOrder($orderCode);

        if (!isset($response["orderCode"])) {
            Error::throwError("apierror");
        }
        return $response;
    }
1054878
public function email($field)
    {
        return (filter_var(trim($this->get($field)), FILTER_VALIDATE_EMAIL) !== false) ?: $this->error($field,
            __FUNCTION__);
    }
1356879
public function AllowSendingMailForOrder($oUser, $aOrder)
    {
        $bAllowSendingMail = true;

        // make sure the order is a DE order
        if ($aOrder['cms_language_id'] != $this->sLanguageID) {
            $bAllowSendingMail = false;
        }

        if ($this->SendCustomersMailOnlyOnce()) {
            $query = "SELECT * FROM `pkg_shop_rating_service_history`
                   WHERE `data_extranet_user_id` = '".MySqlLegacySupport::getInstance()->real_escape_string($oUser->id)."'
                 ";

            if ($this->bDebug) {
                echo __LINE__.': '.$query."\n<br />\n";
            }

            $tRes = MySqlLegacySupport::getInstance()->query($query);
            if (MySqlLegacySupport::getInstance()->num_rows($tRes) > 0) {
                $bAllowSendingMail = false;
            }
        }

        if ($this->bDebug) {
            if ($bAllowSendingMail) {
                echo __LINE__.': bAllowSendingMail = true'."\n<br />\n";
            } else {
                echo __LINE__.': bAllowSendingMail = false'."\n<br />\n";
            }
        }

        return $bAllowSendingMail;
    }
155403
public function orderItems(Order $order)
    {
        return response()->json([
            'errors' => false,
            'data' => $order->items->map(function($item) {
                $item->product->load('options');
                return $item;
            }),
        ]);
    }
1013333
public function sendOrderEmailToUser($oOrder, $sSubject = null)
    {
        self::$blSendToUserWasCalled = true;
        self::$oUserOrder = $oOrder;

        return self::$blRetValue;
    }
1193895
public function applyOrder($order)
    {
        switch ($order) {
            case 'time':
                $this->orderBy(['created_at' => SORT_ASC]);
                break;

            case 'supports':
            default:
                $this->orderBy(['(supports / pow((((UNIX_TIMESTAMP(NOW()) - created_at) / 3600) + 2),1.8) )' => SORT_DESC]);
                break;
        }

        return $order;
    }