Пример #1
0
 /**
  * 
  * Move one resource up
  * @param \GK\Stdapp\Domain\Model\Resource $resource
  */
 public function moveUpAction(\GK\Stdapp\Domain\Model\Resource $resource)
 {
     $resources = $this->resourceRepository->findByType($this->type, $this->portalUser->getCustomer()->_loadRealInstance());
     foreach ($resources as $res) {
         if ($res == $resource && $lastres != NULL) {
             $pos = $res->getSort();
             $lastpos = $lastres->getSort();
             if ($pos == $lastpos) {
                 $res->setSort($pos);
                 $lastres->setSort($pos + 1);
             } else {
                 $res->setSort($lastpos);
                 $lastres->setSort($pos);
             }
             $this->resourceRepository->update($res);
             $this->resourceRepository->update($lastres);
             break;
         }
         $lastres = $res;
     }
     $this->flashMessageContainer->add('Your Resource was moved.');
     $this->redirect('edit');
 }
Пример #2
0
 /**
  * action updateSubmitMsg
  *
  * @param \GK\Stdapp\Domain\Model\Resource $resource
  * @return void
  */
 public function updateSubmitMsgAction(\GK\Stdapp\Domain\Model\Resource $resource)
 {
     $this->resourceRepository->update($resource);
     $this->flashMessageContainer->add('Your Resource was updated.');
     $this->redirect('edit');
 }
Пример #3
0
 /**
  * action delete
  *
  * @param \GK\Stdapp\Domain\Model\Resource $resource
  * @return void
  */
 public function deleteAction(\GK\Stdapp\Domain\Model\Resource $resource)
 {
     $this->resourceRepository->remove($resource);
     $this->flashMessageContainer->add('Your Resource was removed.');
     $this->redirect('list');
 }
Пример #4
0
 /**
  * action config
  *
  * @param string $identifier
  * @param string $token
  * @return string
  */
 public function configAction($identifier, $token = NULL)
 {
     $configs = array();
     $customer = $this->customerRepository->findOneByIdentifier($identifier);
     if ($customer == NULL) {
         die("Customer not eligible");
     }
     $this->portalUserRepository = $this->objectManager->get('\\GK\\Stdapp\\Domain\\Repository\\PortalUserRepository');
     $portalUser = $this->portalUserRepository->findOneByCustomer($customer);
     if ($token != NULL) {
         $this->updateSubscriber($customer, $token);
     }
     $configs['version'] = $this->settings['version'];
     //'0.2'
     $configs['status'] = $customer->getStatus();
     $configs['offerEmail'] = $customer->getEnquiryEmail();
     //'*****@*****.**';
     $configs['senderEmail'] = $this->settings['senderEmail'];
     $configs['longitude'] = $customer->getLongitude();
     $configs['latitude'] = $customer->getLatitude();
     $configs['txtColorHeader'] = $customer->getTxtColorHeader();
     $configs['txtTransparencyHeader'] = $customer->getTxtTransparencyHeader();
     $configs['baseURL'] = $this->settings['baseUrl'] . $this->settings['uploadPath'] . strtoupper($identifier) . '/';
     $configs['smtpServer'] = $this->settings['smtpServer'];
     $configs['smtpUsername'] = $this->settings['smtpUsername'];
     $configs['smtpPassword'] = $this->settings['smtpPassword'];
     //"Aw5FUw4OBkI="
     $configs['langDefault'] = $customer->getDefaultLanguage()->getUid();
     $configs['name'] = $portalUser->getCompany();
     $configs['address'] = $portalUser->getAddress();
     $configs['zip'] = $portalUser->getZip();
     $configs['city'] = $portalUser->getCity();
     $configs['telephone'] = $portalUser->getTelephone();
     $configs['fax'] = $portalUser->getFax();
     $configs['mailbox'] = $customer->getContactEmail();
     $configs['hrNumber'] = $customer->getHrNumber();
     $configs['www'] = $portalUser->getWww();
     $langs = array();
     foreach ($customer->getLanguages() as $language) {
         $langs[] = array('uid' => $language->getUid(), 'code' => $language->getCode(), 'name' => $language->getTitle());
     }
     $configs['language'] = $langs;
     $itemNames = array();
     foreach ($customer->getTypenames() as $typename) {
         $lang = $typename->getSysLanguageUid();
         $itemNames[$lang != NULL ? $lang->getUid() : $configs['langDefault']][$typename->getType()->getUid()] = $typename->getName();
     }
     $configs['itemName'] = $itemNames;
     $setups = array();
     foreach ($this->customerSubtypeRepository->findForApi($identifier)->toArray() as $config) {
         $resourceType = $config->getResourceType();
         $typeUid = $resourceType->getUid();
         $subtype = $config->getSubtype();
         switch ($subtype) {
             case 0:
                 $data = str_replace(array('{name}', '{address}', '{zip}', '{city}', '{telephone}', '{fax}', '{mailbox}', '{hr_number}', '{www}', '{baseurl}'), array($configs['name'], $configs['address'], $configs['zip'], $configs['city'], $configs['telephone'], $configs['fax'], $configs['mailbox'], $configs['hrNumber'], $configs['www'], $this->settings['baseUrl']), $config->getData());
                 break;
             case 1:
                 // if no resources, switch to default
                 if ($resourceType->getAction() == "resource" && $this->resourceRepository->countForApi($identifier, $typeUid) == 0) {
                     $data = str_replace(array('{name}', '{address}', '{zip}', '{city}', '{telephone}', '{fax}', '{mailbox}', '{hr_number}', '{www}', '{baseurl}'), array($configs['name'], $configs['address'], $configs['zip'], $configs['city'], $configs['telephone'], $configs['fax'], $configs['mailbox'], $configs['hrNumber'], $configs['www'], $this->settings['baseUrl']), $config->getData());
                     $subtype = 0;
                 } else {
                     $data = $this->settings['baseUrl'] . '/' . $resourceType->getAction() . '/' . $identifier . '/' . $typeUid;
                 }
                 break;
             case 2:
                 $data = str_replace('{baseurl}', $this->settings['baseUrl'], $config->getUrl());
                 break;
         }
         $setups[] = array('type' => $typeUid, 'subtype' => $subtype, 'data' => $data);
     }
     $configs['setup'] = $setups;
     $subjects = array();
     foreach ($this->resourceRepository->findByType(9, $customer)->toArray() as $subject) {
         $lang = $subject->getSysLanguageUid();
         $subjects[$lang != NULL ? $lang->getUid() : $configs['langDefault']][] = array('uid' => $subject->getUid(), 'title' => $subject->getTitle());
     }
     $configs['offerSubject'] = $subjects;
     $contactSubmitMsg = array();
     foreach ($this->resourceRepository->findByType(10, $customer)->toArray() as $subject) {
         $lang = $subject->getSysLanguageUid();
         $contactSubmitMsg[$lang != NULL ? $lang->getUid() : $configs['langDefault']][] = array('uid' => $subject->getUid(), 'title' => $subject->getTitle(), 'content' => $subject->getContent());
     }
     $configs['contactSubmitMsg'] = $contactSubmitMsg;
     $offerSubmitMsg = array();
     foreach ($this->resourceRepository->findByType(11, $customer)->toArray() as $subject) {
         $lang = $subject->getSysLanguageUid();
         $offerSubmitMsg[$lang != NULL ? $lang->getUid() : $configs['langDefault']][] = array('uid' => $subject->getUid(), 'title' => $subject->getTitle(), 'content' => $subject->getContent());
     }
     $configs['offerSubmitMsg'] = $offerSubmitMsg;
     return json_encode($configs);
 }