/**
  * Adds the privilege to the given user
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Aimeos context object
  * @param \Aimeos\MShop\Customer\Item\Iface $user Aimeos customer object
  * @param string $privilege Unique customer group code
  */
 protected function addPrivilege(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $privilege)
 {
     $this->info(sprintf('Add "%1$s" privilege to user "%2$s" for sites', $privilege, $user->getCode()));
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
     foreach ($this->getSiteItems($context, $this->argument('site')) as $siteItem) {
         $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false);
         $lcontext = clone $context;
         $lcontext->setLocale($localeItem);
         $this->info('- ' . $siteItem->getCode());
         $groupItem = $this->getGroupItem($lcontext, $privilege);
         $this->addListItem($lcontext, $user->getId(), $groupItem->getId());
     }
 }
 /**
  * Adds the group to the given user
  *
  * @param InputInterface $input Input object
  * @param OutputInterface $output Output object
  * @param \Aimeos\MShop\Context\Item\Iface $context Aimeos context object
  * @param \Aimeos\MShop\Customer\Item\Iface $user Aimeos customer object
  * @param string $group Unique customer group code
  */
 protected function addGroup(InputInterface $input, OutputInterface $output, \Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $user, $group)
 {
     $output->writeln(sprintf('Add "%1$s" group to user "%2$s" for sites', $group, $user->getCode()));
     $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
     foreach ($this->getSiteItems($context, $input) as $siteItem) {
         $localeItem = $localeManager->bootstrap($siteItem->getCode(), '', '', false);
         $lcontext = clone $context;
         $lcontext->setLocale($localeItem);
         $output->writeln('- ' . $siteItem->getCode());
         $groupItem = $this->getGroupItem($lcontext, $group);
         $this->addListItem($lcontext, $user->getId(), $groupItem->getId());
     }
 }
Exemple #3
0
 /**
  * Adds the customer and address data to the given customer item
  *
  * @param \Aimeos\MShop\Customer\Item\Iface $customer Customer object
  * @param \Aimeos\MShop\Common\Item\Address\Iface $address Billing address object
  * @return \Aimeos\MShop\Customer\Item\Iface Customer object filled with data
  */
 protected function addCustomerData(\Aimeos\MShop\Customer\Item\Iface $customer, \Aimeos\MShop\Common\Item\Address\Iface $address, $code, $password)
 {
     $label = $address->getLastname();
     if (($part = $address->getFirstname()) !== '') {
         $label = $part . ' ' . $label;
     }
     if (($part = $address->getCompany()) !== '') {
         $label .= ' (' . $part . ')';
     }
     $customer->setPaymentAddress($address);
     $customer->setCode($code);
     $customer->setPassword($password);
     $customer->setLabel($label);
     $customer->setStatus(1);
     return $customer;
 }
Exemple #4
0
 /**
  * Adds the customer to the groups listed in the customer item
  *
  * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item
  */
 protected function addGroups(\Aimeos\MShop\Customer\Item\Iface $item)
 {
     if (count($item->getGroups()) === 0) {
         return;
     }
     $listMap = array();
     $manager = $this->getSubManager('lists');
     $typeManager = $manager->getSubManager('type');
     $typeId = $typeManager->findItem('default', array(), 'customer/group', 'default')->getId();
     $listItem = $manager->createItem();
     $listItem->setParentId($item->getId());
     $listItem->setDomain('customer/group');
     $listItem->setTypeId($typeId);
     $listItem->setStatus(1);
     $search = $manager->createSearch();
     $expr = array($search->compare('==', 'customer.lists.parentid', $item->getId()), $search->compare('==', 'customer.lists.domain', 'customer/group'), $search->compare('==', 'customer.lists.type.domain', 'customer/group'), $search->compare('==', 'customer.lists.type.code', 'default'));
     $search->setConditions($search->combine('&&', $expr));
     $search->setSlice(0, 0x7fffffff);
     foreach ($manager->searchItems($search) as $listid => $listItem) {
         $listMap[$listItem->getRefId()] = $listid;
     }
     $pos = count($listMap);
     foreach ($item->getGroups() as $gid) {
         if (isset($listMap[$gid])) {
             unset($listMap[$gid]);
             continue;
         }
         $listItem->setId(null);
         $listItem->setRefId($gid);
         $listItem->setPosition($pos++);
         $manager->saveItem($listItem, false);
     }
     $manager->deleteItems($listMap);
 }
Exemple #5
0
 /**
  * Adds the customer and address data to the given customer item
  *
  * @param \Aimeos\MShop\Customer\Item\Iface $customer Customer object
  * @param \Aimeos\MShop\Common\Item\Address\Iface $address Billing address object
  * @param string $code Unique customer code, e.g. user name or e-mail address
  * @param string $password Plain-text password for the customer
  * @return \Aimeos\MShop\Customer\Item\Iface Customer object filled with data
  */
 protected function addCustomerData(\Aimeos\MShop\Customer\Item\Iface $customer, \Aimeos\MShop\Common\Item\Address\Iface $address, $code, $password)
 {
     $extra = $this->getContext()->getSession()->get('client/html/checkout/standard/address/extra');
     $label = $address->getLastname();
     if (($part = $address->getFirstname()) !== '') {
         $label = $part . ' ' . $label;
     }
     if (($part = $address->getCompany()) !== '') {
         $label .= ' (' . $part . ')';
     }
     $customer->setPaymentAddress($address);
     $customer->setPassword($password);
     $customer->setLabel($label);
     $customer->setCode($code);
     $customer->setStatus(1);
     try {
         $customer->setBirthday((string) $extra['customer.birthday']);
     } catch (\Aimeos\MShop\Exception $e) {
         // don't break on invalid birthdays
     }
     /** client/html/checkout/standard/order/account/standard/groupids
      * List of groups new customers should be assigned to
      *
      * Newly created customers will be assigned automatically to the groups
      * given by their IDs. This is especially useful if those groups limit
      * functionality for those users.
      *
      * @param array List of group IDs
      * @since 2016.03
      * @category User
      * @category Developer
      */
     $config = $this->getContext()->getConfig();
     $gids = (array) $config->get('client/html/checkout/standard/order/account/standard/groupids', array());
     $customer->setGroups($gids);
     return $customer;
 }
Exemple #6
0
 /**
  * Sends the account creation e-mail to the e-mail address of the customer
  *
  * @param \Aimeos\MShop\Context\Item\Iface $context Context item object
  * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object
  * @param string $password Customer clear text password
  */
 protected function sendEmail(\Aimeos\MShop\Context\Item\Iface $context, \Aimeos\MShop\Customer\Item\Iface $item, $password)
 {
     $address = $item->getPaymentAddress();
     $view = $context->getView();
     $view->extAddressItem = $address;
     $view->extAccountCode = $item->getCode();
     $view->extAccountPassword = $password;
     $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $context->getI18n($address->getLanguageId()));
     $view->addHelper('translate', $helper);
     $mailer = $context->getMail();
     $message = $mailer->createMessage();
     $helper = new \Aimeos\MW\View\Helper\Mail\Standard($view, $message);
     $view->addHelper('mail', $helper);
     $client = $this->getClient($context);
     $client->setView($view);
     $client->getHeader();
     $client->getBody();
     $mailer->send($message);
 }