/**
  * This function returns the ViewGeneration options for a given entityClass
  *
  * @access protected
  * @global $_ARRAYLANG
  * @param $entityClassName contains the FQCN from entity
  * @return array with options
  */
 protected function getViewGeneratorOptions($entityClassName)
 {
     global $_ARRAYLANG;
     $classNameParts = explode('\\', $entityClassName);
     $classIdentifier = end($classNameParts);
     $langVarName = 'TXT_' . strtoupper($this->getType() . '_' . $this->getName() . '_ACT_' . $classIdentifier);
     $header = '';
     if (isset($_ARRAYLANG[$langVarName])) {
         $header = $_ARRAYLANG[$langVarName];
     }
     switch ($entityClassName) {
         case 'Cx\\Modules\\Order\\Model\\Entity\\Order':
             return array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_ACT_DEFAULT'], 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false), 'fields' => array('contactId' => array('header' => 'contactId', 'table' => array('parse' => function ($value) {
                 global $_ARRAYLANG;
                 $userId = \Cx\Modules\Crm\Controller\CrmLibrary::getUserIdByCrmUserId($value);
                 $userName = \FWUser::getParsedUserTitle($userId);
                 $crmDetailLink = "<a href='index.php?cmd=Crm&amp;act=customers&amp;tpl=showcustdetail&amp;id={$value}'\n                                                    title='{$_ARRAYLANG['TXT_MODULE_ORDER_CRM_CONTACT']}'>\n                                                    <img\n                                                        src='" . \Env::get('cx')->getCodeBaseCoreWebPath() . "/Core/View/Media/navigation_level_1_189.png'\n                                                        width='16' height='16'\n                                                        alt='{$_ARRAYLANG['TXT_MODULE_ORDER_CRM_CONTACT']}'\n                                                    />\n                                                </a>";
                 $url = "<a href='index.php?cmd=Access&amp;act=user&amp;tpl=modify&amp;id={$userId}'\n                                       title='{$_ARRAYLANG['TXT_MODULE_ORDER_MODIY_USER_ACCOUNT']}'>" . $userName . "</a>" . $crmDetailLink;
                 return $url;
             })), 'subscriptions' => array('header' => 'subscriptions', 'table' => array('parse' => function ($subscriptions) {
                 $result = array();
                 foreach ($subscriptions as $subscription) {
                     $productEntity = $subscription->getProductEntity();
                     if (!$productEntity) {
                         continue;
                     }
                     $productEntityName = $subscription->getProduct()->getName();
                     $productEditLink = $productEntity;
                     if (method_exists($productEntity, 'getEditLink')) {
                         $productEditLink = $productEntity->getEditLink();
                     }
                     $subscriptionEditUrl = '<a href=​index.php?cmd=Order&act=subscription&editid=' . $subscription->getId() . '>' . $productEntityName . '</a>';
                     $result[] = $subscriptionEditUrl . ' (' . $productEditLink . ')';
                 }
                 return implode(', ', $result);
             }))));
             break;
         case 'Cx\\Modules\\Order\\Model\\Entity\\Subscription':
             return array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_ACT_SUBSCRIPTION'], 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false), 'fields' => array('id' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_ID']), 'subscriptionDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_DATE']), 'expirationDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_EXPIRATION_DATE']), 'productEntityId' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_PRODUCT_ENTITY'], 'table' => array('parse' => function ($value, $rowData) {
                 $subscriptionRepo = \Env::get('em')->getRepository('Cx\\Modules\\Order\\Model\\Entity\\Subscription');
                 $subscription = $subscriptionRepo->findOneBy(array('id' => $rowData['id']));
                 $productEntity = $subscription->getProductEntity();
                 if (!$productEntity) {
                     return;
                 }
                 $productEditLink = $productEntity;
                 if (method_exists($productEntity, 'getEditLink')) {
                     $productEditLink = $productEntity->getEditLink();
                 }
                 return $productEditLink;
             })), 'paymentAmount' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_PAYMENT_AMOUNT'], 'table' => array('parse' => function ($value, $rowData) {
                 if (\FWValidator::isEmpty(floatval($value))) {
                     return null;
                 }
                 $subscriptionRepo = \Env::get('em')->getRepository('Cx\\Modules\\Order\\Model\\Entity\\Subscription');
                 $subscription = $subscriptionRepo->findOneBy(array('id' => $rowData['id']));
                 $currency = '';
                 $order = $subscription->getOrder();
                 if ($order) {
                     $currency = !\FWValidator::isEmpty($order->getCurrency()) ? $order->getCurrency() : '';
                 }
                 $paymentInterval = $subscription->getRenewalUnit();
                 return $value . ' ' . $currency . ' / ' . $paymentInterval;
             })), 'renewalUnit' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_RENEWAL_UNIT'], 'table' => array('parse' => function ($value, $rowData) {
                 if (empty($value)) {
                     return null;
                 }
                 $subscriptionRepo = \Env::get('em')->getRepository('Cx\\Modules\\Order\\Model\\Entity\\Subscription');
                 $subscription = $subscriptionRepo->findOneBy(array('id' => $rowData['id']));
                 $renewalDate = '';
                 if ($subscription->getRenewalDate()) {
                     $renewalDate = $subscription->getRenewalDate();
                     $quantifier = $subscription->getRenewalQuantifier();
                     $renewalDate->modify("-{$quantifier} {$value}");
                     return $renewalDate->format('d.M.Y H:i:s');
                 }
                 return $renewalDate;
             })), 'renewalQuantifier' => array('showOverview' => false), 'renewalDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_RENEWAL_DATE']), 'description' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_DESCRIPTION']), 'state' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_STATE']), 'terminationDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_TERMI_DATE']), 'note' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_NOTE']), 'product' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_PRODUCT'], 'table' => array('parse' => function ($value, $rowData) {
                 $subscriptionRepo = \Env::get('em')->getRepository('Cx\\Modules\\Order\\Model\\Entity\\Subscription');
                 $subscription = $subscriptionRepo->findOneBy(array('id' => $rowData['id']));
                 $product = $subscription->getProduct();
                 if (!$product) {
                     return;
                 }
                 return $product->getName();
             })), 'paymentState' => array('showOverview' => false), 'externalSubscriptionId' => array('showOverview' => false), 'order' => array('showOverview' => false)));
             break;
         default:
             return array('header' => $header, 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false));
     }
 }
 /**
  * Create a new Order 
  * 
  * @param integer $productId            productId
  * @param object  $objUser              \User object
  * @param string  $transactionReference transactionReference
  * @param array   $subscriptionOptions  subscriptionOptions
  * 
  * @return boolean
  * @throws OrderRepositoryException
  */
 public function createOrder($productId, \Cx\Modules\Crm\Model\Entity\Currency $currency, \User $objUser, $transactionReference, $subscriptionOptions = array())
 {
     if (\FWValidator::isEmpty($productId) || \FWValidator::isEmpty($subscriptionOptions) || \FWValidator::isEmpty($transactionReference) || \FWValidator::isEmpty($currency)) {
         return;
     }
     $contactId = $objUser->getCrmUserId();
     if (\FWValidator::isEmpty($contactId)) {
         return;
     }
     try {
         $order = new \Cx\Modules\Order\Model\Entity\Order();
         $order->setContactId($contactId);
         $order->setCurrency($currency);
         $productRepository = \Env::get('em')->getRepository('Cx\\Modules\\Pim\\Model\\Entity\\Product');
         $product = $productRepository->findOneBy(array('id' => $productId));
         //create subscription
         $subscription = $order->createSubscription($product, $subscriptionOptions);
         // set discount price for first payment period of subscription
         if (!empty($subscriptionOptions['oneTimeSalePrice'])) {
             $subscription->setPaymentAmount($subscriptionOptions['oneTimeSalePrice']);
         }
         $order->billSubscriptions();
         $invoices = $order->getInvoices();
         if (!empty($invoices)) {
             \DBG::msg(__METHOD__ . ": order has invoices");
             $paymentRepo = \Env::get('em')->getRepository('\\Cx\\Modules\\Order\\Model\\Entity\\Payment');
             foreach ($invoices as $invoice) {
                 if (!$invoice->getPaid()) {
                     \DBG::msg(__METHOD__ . ": lookup payment with transaction-reference {$transactionReference} and amount " . $invoice->getAmount());
                     $payment = $paymentRepo->findOneByCriteria(array('amount' => $invoice->getAmount(), 'transactionReference' => $transactionReference, 'invoice' => null));
                     if ($payment) {
                         \DBG::msg(__METHOD__ . ": payment found");
                         //set subscription-id to Subscription::$externalSubscriptionId
                         if ($subscription) {
                             \DBG::msg(__METHOD__ . ": trying to link to new subscription to the external subscription ID");
                             $referenceArry = explode('|', $payment->getTransactionReference());
                             if (isset($referenceArry[4]) && !empty($referenceArry[4])) {
                                 $subscription->setExternalSubscriptionId($referenceArry[4]);
                             }
                         }
                         $transactionData = $payment->getTransactionData();
                         if (!\FWValidator::isEmpty($transactionData) && isset($transactionData['contact']) && isset($transactionData['contact']['id'])) {
                             \DBG::msg(__METHOD__ . ": set externalPaymentCustomerIdProfileAttributeId of user to " . $transactionData['contact']['id']);
                             $objUser->setProfile(array(\Cx\Core\Setting\Controller\Setting::getValue('externalPaymentCustomerIdProfileAttributeId', 'MultiSite') => array(0 => $transactionData['contact']['id'])), true);
                             if (!$objUser->store()) {
                                 \DBG::msg('Order::createOrder() Updating user failed: ' . $objUser->getErrorMsg());
                             }
                         }
                         $invoice->addPayment($payment);
                         $payment->setInvoice($invoice);
                         \Env::get('em')->persist($invoice);
                         \Env::get('em')->persist($payment);
                         break;
                     }
                 }
             }
         }
         \Env::get('em')->persist($order);
         \Env::get('em')->flush();
         return $order;
     } catch (\Exception $e) {
         throw new OrderRepositoryException($e->getMessage());
     }
 }
 /**
  * Get currencyId by crm id
  *
  * @param integer $crmId crm id
  *
  * @return mixed null or currencyId
  */
 public static function getCurrencyIdByCrmId($crmId)
 {
     if (\FWValidator::isEmpty($crmId)) {
         return null;
     }
     $db = \Env::get('cx')->getDb()->getAdoDb();
     $currencyId = $db->GetOne("SELECT `customer_currency` FROM `" . DBPREFIX . "module_crm_contacts` WHERE `id` = " . intval($crmId));
     return $currencyId;
 }
 /**
  * Terminate expired Subscriptions
  *
  * This method does call the method Subscription::terminate() on all Subscriptions
  * that are expired (Subscription::$expirationDate < now), but are still
  * active (Subscription::$state = active) or have been cancelled (Subscription::$state = cancelled).
  * Expired Subscriptions that are inactive (Subscription::$state = inactive) are not
  * terminated as long as they are inactive. This allows a Subscription to be re-activated
  * and resetting a new expiration date without having the Subscription automatically
  * being terminated.
  */
 public function terminateExpiredSubscriptions()
 {
     $subscriptionRepo = \Env::get('em')->getRepository('Cx\\Modules\\Order\\Model\\Entity\\Subscription');
     $subscriptions = $subscriptionRepo->getExpiredSubscriptions(array(\Cx\Modules\Order\Model\Entity\Subscription::STATE_ACTIVE, \Cx\Modules\Order\Model\Entity\Subscription::STATE_CANCELLED));
     if (\FWValidator::isEmpty($subscriptions)) {
         return;
     }
     foreach ($subscriptions as $subscription) {
         $subscription->terminate();
     }
     \Env::get('em')->flush();
 }
Beispiel #5
0
 /**
  * performs the registratio page
  * 
  * @return null
  */
 function showRegistrationForm()
 {
     global $_ARRAYLANG, $_CORELANG;
     $this->_objTpl->setTemplate($this->pageContent, true, true);
     $objFWUser = \FWUser::getFWUserObject();
     $objUser = $objFWUser->objUser;
     $userId = intval($objUser->getId());
     $userLogin = $objUser->login();
     $captchaCheck = true;
     if (!$userLogin && isset($_POST['submitRegistration'])) {
         $captchaCheck = \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->check();
         if (!$captchaCheck) {
             $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_ERROR' => '<span class="text-danger">' . $_ARRAYLANG['TXT_CALENDAR_INVALID_CAPTCHA_CODE'] . '</span>'));
         }
     }
     $objEvent = $this->objEventManager->eventList[0];
     if (empty($objEvent)) {
         \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, ''));
         return;
     }
     if (!$objEvent->status) {
         \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, ''));
         return;
     }
     if ($objEvent->access == 1 && !\FWUser::getFWUserObject()->objUser->login()) {
         $link = base64_encode(CONTREXX_SCRIPT_PATH . '?' . $_SERVER['QUERY_STRING']);
         \Cx\Core\Csrf\Controller\Csrf::redirect(CONTREXX_SCRIPT_PATH . "?section=Login&redirect=" . $link);
         return;
     }
     $dateForPageTitle = $objEvent->startDate;
     $this->pageTitle = $this->format2userDate($dateForPageTitle) . ": " . html_entity_decode($objEvent->title, ENT_QUOTES, CONTREXX_CHARSET);
     // Only show registration form if event lies in the future
     if (time() <= $objEvent->startDate->getTimestamp()) {
         // Only show registration form if event accepts registrations.
         // Event accepts registrations, if registration is set up and
         //     - no attendee limit is set
         //     - or if there are still free places available
         if ($objEvent->registration == CalendarEvent::EVENT_REGISTRATION_INTERNAL && (empty($objEvent->numSubscriber) || !\FWValidator::isEmpty($objEvent->getFreePlaces()))) {
             $this->_objTpl->setVariable(array($this->moduleLangVar . '_EVENT_ID' => intval($_REQUEST['id']), $this->moduleLangVar . '_FORM_ID' => intval($objEvent->registrationForm), $this->moduleLangVar . '_EVENT_DATE' => intval($_REQUEST['date']), $this->moduleLangVar . '_USER_ID' => $userId, 'TXT_' . $this->moduleLangVar . '_REGISTRATION_SUBMIT' => $_ARRAYLANG['TXT_CALENDAR_REGISTRATION_SUBMIT']));
             $objFormManager = new \Cx\Modules\Calendar\Controller\CalendarFormManager();
             $objFormManager->setEvent($objEvent);
             $objFormManager->getFormList();
             //$objFormManager->showForm($this->_objTpl,intval($objEvent->registrationForm), 2, $objEvent->ticketSales);
             // Made the ticket sales always true, because ticket functionality currently not implemented
             $objFormManager->showForm($this->_objTpl, intval($objEvent->registrationForm), 2, true);
             /* if ($this->arrSettings['paymentStatus'] == '1' && $objEvent->ticketSales && ($this->arrSettings['paymentBillStatus'] == '1' || $this->arrSettings['paymentYellowpayStatus'] == '1')) {
                                 $paymentMethods  = '<select class="calendarSelect" name="paymentMethod">';
                                 $paymentMethods .= $this->arrSettings['paymentBillStatus'] == '1' || $objEvent->price == 0 ? '<option value="1">'.$_ARRAYLANG['TXT_CALENDAR_PAYMENT_BILL'].'</option>'  : '';
                                 $paymentMethods .= $this->arrSettings['paymentYellowpayStatus'] == '1' && $objEvent->price > 0 ? '<option value="2">'.$_ARRAYLANG['TXT_CALENDAR_PAYMENT_YELLOWPAY'].'</option>' : '';
                                 $paymentMethods .= '</select>';
             
                                 $this->_objTpl->setVariable(array(
                                     'TXT_'.$this->moduleLangVar.'_PAYMENT_METHOD' => $_ARRAYLANG['TXT_CALENDAR_PAYMENT_METHOD'],
                                     $this->moduleLangVar.'_PAYMENT_METHODS'       => $paymentMethods,
                                 ));
                                 $this->_objTpl->parse('calendarRegistrationPayment');
                             } else {
                                 $this->_objTpl->hideBlock('calendarRegistrationPayment');
                             } */
             if (!$userLogin) {
                 $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_CAPTCHA' => $_CORELANG['TXT_CORE_CAPTCHA'], $this->moduleLangVar . '_CAPTCHA_CODE' => \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->getCode()));
                 $this->_objTpl->parse('calendarRegistrationCaptcha');
             } else {
                 $this->_objTpl->hideBlock('calendarRegistrationCaptcha');
             }
             if (isset($_POST['submitRegistration']) && $captchaCheck) {
                 $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration(intval($_POST['form']));
                 if ($objRegistration->save($_POST)) {
                     if ($objRegistration->saveIn == 2) {
                         $status = $_ARRAYLANG['TXT_CALENDAR_REGISTRATION_SUCCESSFULLY_ADDED_WAITLIST'];
                     } else {
                         if ($objRegistration->saveIn == 0) {
                             $status = $_ARRAYLANG['TXT_CALENDAR_REGISTRATION_SUCCESSFULLY_ADDED_SIGNOFF'];
                         } else {
                             $status = $_ARRAYLANG['TXT_CALENDAR_REGISTRATION_SUCCESSFULLY_ADDED'];
                             /* if($_POST["paymentMethod"] == 2) {
                                    $objRegistration->get($objRegistration->id);
                                    $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent($objRegistration->eventId);                                
                                    $this->getSettings();
                                    $amount  = (int) $objEvent->price * 100;
                                    $status .= \Cx\Modules\Calendar\Controller\CalendarPayment::_yellowpay(array("orderID" => $objRegistration->id, "amount" => $amount, "currency" => $this->arrSettings["paymentCurrency"], "language" => "DE"));
                                } */
                         }
                     }
                     $this->_objTpl->setVariable(array($this->moduleLangVar . '_LINK_BACK' => '<a href="' . CONTREXX_DIRECTORY_INDEX . '?section=' . $this->moduleName . '">' . $_ARRAYLANG['TXT_CALENDAR_BACK'] . '</a>', $this->moduleLangVar . '_REGISTRATION_STATUS' => $status));
                     $this->_objTpl->touchBlock('calendarRegistrationStatus');
                     $this->_objTpl->hideBlock('calendarRegistrationForm');
                 } else {
                     $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_ERROR' => '<span class="text-danger">' . $_ARRAYLANG['TXT_CALENDAR_CHECK_REQUIRED'] . '</span>'));
                     $this->_objTpl->parse('calendarRegistrationForm');
                     $this->_objTpl->hideBlock('calendarRegistrationStatus');
                 }
             } else {
                 $this->_objTpl->parse('calendarRegistrationForm');
                 $this->_objTpl->hideBlock('calendarRegistrationStatus');
             }
         } else {
             $this->_objTpl->setVariable(array($this->moduleLangVar . '_LINK_BACK' => '<a href="' . CONTREXX_DIRECTORY_INDEX . '?section=' . $this->moduleName . '">' . $_ARRAYLANG['TXT_CALENDAR_BACK'] . '</a>', $this->moduleLangVar . '_REGISTRATION_STATUS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_FULLY_BLOCKED']));
             $this->_objTpl->touchBlock('calendarRegistrationStatus');
             $this->_objTpl->hideBlock('calendarRegistrationForm');
         }
     } else {
         $this->_objTpl->setVariable(array($this->moduleLangVar . '_LINK_BACK' => '<a href="' . CONTREXX_DIRECTORY_INDEX . '?section=' . $this->moduleName . '">' . $_ARRAYLANG['TXT_CALENDAR_BACK'] . '</a>', $this->moduleLangVar . '_REGISTRATION_STATUS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_IN_PAST']));
         $this->_objTpl->touchBlock('calendarRegistrationStatus');
         $this->_objTpl->hideBlock('calendarRegistrationForm');
     }
 }
 /**
  * Sets the placeholders used for the event list view
  *
  * @param object  $objTpl Template object
  * @param integer $type   Event type
  *
  * @return null
  */
 function showEventList($objTpl, $type = '')
 {
     global $objInit, $_ARRAYLANG, $_LANGID;
     $this->getFrontendLanguages();
     //if($objInit->mode == 'backend') {
     $i = 0;
     foreach ($this->eventList as $key => $objEvent) {
         $objCategory = new \Cx\Modules\Calendar\Controller\CalendarCategory(intval($objEvent->catId));
         $showIn = explode(",", $objEvent->showIn);
         $languages = '';
         if (count(\FWLanguage::getActiveFrontendLanguages()) > 1) {
             $langState = array();
             foreach ($this->arrFrontendLanguages as $langKey => $arrLang) {
                 if (in_array($arrLang['id'], $showIn)) {
                     $langState[$langKey] = 'active';
                 }
             }
             $languages = \Html::getLanguageIcons($langState, 'index.php?cmd=Calendar&amp;act=modify_event&amp;id=' . $objEvent->id . '&amp;langId=%1$d' . ($type == 'confirm' ? "&amp;confirm=1" : ""));
             if ($type == 'confirm' && $objTpl->blockExists('txt_languages_block_confirm_list')) {
                 $objTpl->touchBlock('txt_languages_block_confirm_list');
             } elseif ($objTpl->blockExists('txt_languages_block')) {
                 $objTpl->touchBlock('txt_languages_block');
             }
         } else {
             if ($type == 'confirm' && $objTpl->blockExists('txt_languages_block_confirm_list')) {
                 $objTpl->hideBlock('txt_languages_block_confirm_list');
             } elseif ($objTpl->blockExists('txt_languages_block')) {
                 $objTpl->hideBlock('txt_languages_block');
             }
         }
         list($priority, $priorityImg) = $this->getPriorityImage($objEvent);
         $plainDescription = contrexx_html2plaintext($objEvent->description);
         if (strlen($plainDescription) > 100) {
             $points = '...';
         } else {
             $points = '';
         }
         $parts = explode("\n", wordwrap($plainDescription, 100, "\n"));
         $attachNamePos = strrpos($objEvent->attach, '/');
         $attachNamelength = strlen($objEvent->attach);
         $attachName = substr($objEvent->attach, $attachNamePos + 1, $attachNamelength);
         $hostUri = '';
         $hostTarget = '';
         if ($objEvent->external) {
             $objHost = new \Cx\Modules\Calendar\Controller\CalendarHost($objEvent->hostId);
             if (substr($objHost->uri, -1) != '/') {
                 $hostUri = $objHost->uri . '/';
             } else {
                 $hostUri = $objHost->uri;
             }
             if (substr($hostUri, 0, 7) != 'http://') {
                 $hostUri = "http://" . $hostUri;
             }
             $hostTarget = 'target="_blank"';
         }
         $copyLink = '';
         if ($objInit->mode == 'backend') {
             $editLink = 'index.php?cmd=' . $this->moduleName . '&amp;act=modify_event&id=' . $objEvent->id . ($type == 'confirm' ? "&amp;confirm=1" : "");
             $copyLink = $editLink . "&amp;copy=1";
         } else {
             $editLink = CONTREXX_DIRECTORY_INDEX . '?section=' . $this->moduleName . '&amp;cmd=edit&id=' . $objEvent->id;
         }
         $picThumb = file_exists(\Env::get('cx')->getWebsitePath() . "{$objEvent->pic}.thumb") ? "{$objEvent->pic}.thumb" : ($objEvent->pic != '' ? $objEvent->pic : '');
         $placeWebsite = $objEvent->place_website != '' ? "<a href='" . $objEvent->place_website . "' target='_blank' >" . $objEvent->place_website . "</a>" : "";
         $placeWebsiteSource = $objEvent->place_website;
         $placeLink = $objEvent->place_link != '' ? "<a href='" . $objEvent->place_link . "' target='_blank' >" . $objEvent->place_link . "</a>" : "";
         $placeLinkSource = $objEvent->place_link;
         if ($this->arrSettings['placeData'] > 1 && $objEvent->locationType == 2) {
             $objEvent->loadPlaceFromMediadir($objEvent->place_mediadir_id, 'place');
             list($placeLink, $placeLinkSource) = $objEvent->loadPlaceLinkFromMediadir($objEvent->place_mediadir_id, 'place');
         }
         $hostWebsite = $objEvent->org_website != '' ? "<a href='" . $objEvent->org_website . "' target='_blank' >" . $objEvent->org_website . "</a>" : "";
         $hostWebsiteSource = $objEvent->org_website;
         $hostLink = $objEvent->org_link != '' ? "<a href='" . $objEvent->org_link . "' target='_blank' >" . $objEvent->org_link . "</a>" : "";
         $hostLinkSource = $objEvent->org_link;
         if ($this->arrSettings['placeDataHost'] > 1 && $objEvent->hostType == 2) {
             $objEvent->loadPlaceFromMediadir($objEvent->host_mediadir_id, 'host');
             list($hostLink, $hostLinkSource) = $objEvent->loadPlaceLinkFromMediadir($objEvent->host_mediadir_id, 'host');
         }
         $startDate = $objEvent->startDate;
         $endDate = $objEvent->endDate;
         if ($objEvent->numSubscriber) {
             $freeSeats = \FWValidator::isEmpty($objEvent->getFreePlaces()) ? '0 (' . $_ARRAYLANG['TXT_CALENDAR_SAVE_IN_WAITLIST'] . ')' : $objEvent->getFreePlaces();
         } else {
             $freeSeats = $_ARRAYLANG['TXT_CALENDAR_YES'];
         }
         if (in_array($objEvent->registration, array(CalendarEvent::EVENT_REGISTRATION_NONE, CalendarEvent::EVENT_REGISTRATION_EXTERNAL))) {
             $freeSeats = $_ARRAYLANG['TXT_CALENDAR_NOT_SPECIFIED'];
         }
         $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_ROW' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_EVENT_LED' => $objEvent->status == 0 ? 'red' : 'green', $this->moduleLangVar . '_EVENT_STATUS' => $objEvent->status == 0 ? $_ARRAYLANG['TXT_CALENDAR_INACTIVE'] : $_ARRAYLANG['TXT_CALENDAR_ACTIVE'], $this->moduleLangVar . '_EVENT_ID' => $objEvent->id, $this->moduleLangVar . '_EVENT_TITLE' => $objEvent->title, $this->moduleLangVar . '_EVENT_TEASER' => $objEvent->teaser, $this->moduleLangVar . '_EVENT_PICTURE' => $objEvent->pic != '' ? '<img src="' . $objEvent->pic . '" alt="' . $objEvent->title . '" title="' . $objEvent->title . '" />' : '', $this->moduleLangVar . '_EVENT_PICTURE_SOURCE' => $objEvent->pic, $this->moduleLangVar . '_EVENT_THUMBNAIL' => $objEvent->pic != '' ? '<img src="' . $picThumb . '" alt="' . $objEvent->title . '" title="' . $objEvent->title . '" />' : '', $this->moduleLangVar . '_EVENT_PRIORITY' => $priority, $this->moduleLangVar . '_EVENT_PRIORITY_IMG' => $priorityImg, $this->moduleLangVar . '_EVENT_PLACE' => $objEvent->place, $this->moduleLangVar . '_EVENT_DESCRIPTION' => $objEvent->description, $this->moduleLangVar . '_EVENT_SHORT_DESCRIPTION' => $parts[0] . $points, $this->moduleLangVar . '_EVENT_LINK' => $objEvent->link ? "<a href='" . $objEvent->link . "' target='_blank' >" . $objEvent->link . "</a>" : "", $this->moduleLangVar . '_EVENT_LINK_SOURCE' => $objEvent->link, $this->moduleLangVar . '_EVENT_ATTACHMENT' => $objEvent->attach != '' ? '<a href="' . $hostUri . $objEvent->attach . '" target="_blank" >' . $attachName . '</a>' : '', $this->moduleLangVar . '_EVENT_ATTACHMENT_SOURCE' => $objEvent->attach, $this->moduleLangVar . '_EVENT_START' => $this->format2userDateTime($startDate), $this->moduleLangVar . '_EVENT_START_DATE' => $this->format2userDate($startDate), $this->moduleLangVar . '_EVENT_START_TIME' => $this->format2userTime($startDate), $this->moduleLangVar . '_EVENT_DATE' => $this->format2userDate($startDate), $this->moduleLangVar . '_EVENT_END' => $this->format2userDateTime($endDate), $this->moduleLangVar . '_EVENT_END_DATE' => $this->format2userDate($endDate), $this->moduleLangVar . '_EVENT_END_TIME' => $this->format2userTime($endDate), $this->moduleLangVar . '_EVENT_LANGUAGES' => $languages, $this->moduleLangVar . '_EVENT_CATEGORY' => $objCategory->name, $this->moduleLangVar . '_EVENT_EXPORT_LINK' => $hostUri . 'index.php?section=' . $this->moduleName . '&amp;export=' . $objEvent->id, $this->moduleLangVar . '_EVENT_EXPORT_ICON' => '<a href="' . $hostUri . 'index.php?section=' . $this->moduleName . '&amp;export=' . $objEvent->id . '"><img src="modules/Calendar/View/Media/ical_export.gif" border="0" title="' . $_ARRAYLANG['TXT_CALENDAR_EXPORT_ICAL_EVENT'] . '" alt="' . $_ARRAYLANG['TXT_CALENDAR_EXPORT_ICAL_EVENT'] . '" /></a>', $this->moduleLangVar . '_EVENT_EDIT_LINK' => $editLink, $this->moduleLangVar . '_EVENT_COPY_LINK' => $copyLink, $this->moduleLangVar . '_EVENT_SERIES' => $objEvent->seriesStatus == 1 ? '<img src="' . ASCMS_MODULE_WEB_PATH . '/' . $this->moduleName . '/View/Media/Repeat.png" border="0"/>' : '<i>' . $_ARRAYLANG['TXT_CALENDAR_NO_SERIES'] . '</i>', $this->moduleLangVar . '_EVENT_FREE_PLACES' => $freeSeats, $this->moduleLangVar . '_EVENT_ACCESS' => $_ARRAYLANG['TXT_CALENDAR_EVENT_ACCESS_' . $objEvent->access]));
         if ($objEvent->showDetailView) {
             $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_DETAIL_LINK' => $objEvent->type == 0 ? self::_getDetailLink($objEvent) : $objEvent->arrData['redirect'][$_LANGID], $this->moduleLangVar . '_EVENT_DETAIL_TARGET' => $objEvent->type == 0 ? '_self' : '_blank'));
             if ($objTpl->blockExists('event_detail_view')) {
                 $objTpl->touchBlock('event_detail_view');
             }
             if ($objTpl->blockExists('event_no_detail_view')) {
                 $objTpl->hideBlock('event_no_detail_view');
             }
         } else {
             $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_DETAIL_LINK' => '#', $this->moduleLangVar . '_EVENT_DETAIL_TARGET' => ''));
             if ($objTpl->blockExists('event_detail_view')) {
                 $objTpl->hideBlock('event_detail_view');
             }
             if ($objTpl->blockExists('event_no_detail_view')) {
                 $objTpl->touchBlock('event_no_detail_view');
             }
         }
         $hasPlaceMap = !empty($objEvent->place_map) && file_exists(\Env::get('cx')->getWebsitePath() . $objEvent->place_map);
         if ($hasPlaceMap) {
             $arrInfo = getimagesize(\Env::get('cx')->getWebsitePath() . $objEvent->place_map);
             $picWidth = $arrInfo[0] + 20;
             $picHeight = $arrInfo[1] + 20;
         }
         $map_thumb_name = file_exists(\Env::get('cx')->getWebsitePath() . $objEvent->place_map . ".thumb") ? $objEvent->place_map . ".thumb" : $objEvent->place_map;
         $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_LOCATION_PLACE' => $objEvent->place, $this->moduleLangVar . '_EVENT_LOCATION_ADDRESS' => $objEvent->place_street, $this->moduleLangVar . '_EVENT_LOCATION_ZIP' => $objEvent->place_zip, $this->moduleLangVar . '_EVENT_LOCATION_CITY' => $objEvent->place_city, $this->moduleLangVar . '_EVENT_LOCATION_COUNTRY' => $objEvent->place_country, $this->moduleLangVar . '_EVENT_LOCATION_WEBSITE' => $placeWebsite, $this->moduleLangVar . '_EVENT_LOCATION_WEBSITE_SOURCE' => $placeWebsiteSource, $this->moduleLangVar . '_EVENT_LOCATION_LINK' => $placeLink, $this->moduleLangVar . '_EVENT_LOCATION_LINK_SOURCE' => $placeLinkSource, $this->moduleLangVar . '_EVENT_LOCATION_PHONE' => $objEvent->place_phone, $this->moduleLangVar . '_EVENT_LOCATION_MAP_LINK' => $hasPlaceMap ? '<a href="' . $objEvent->place_map . '" onClick="window.open(this.href,\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=' . $picWidth . ',height=' . $picHeight . ',status\'); return false">' . $_ARRAYLANG['TXT_CALENDAR_MAP'] . '</a>' : "", $this->moduleLangVar . '_EVENT_LOCATION_MAP_THUMBNAIL' => $hasPlaceMap ? '<a href="' . $objEvent->place_map . '" onClick="window.open(this.href,\'\',\'resizable=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,fullscreen=no,dependent=no,width=' . $picWidth . ',height=' . $picHeight . ',status\'); return false"><img src="' . $map_thumb_name . '" border="0" alt="' . $objEvent->place_map . '" /></a>' : "", $this->moduleLangVar . '_EVENT_LOCATION_MAP_SOURCE' => $hasPlaceMap ? $objEvent->place_map : '', $this->moduleLangVar . '_EVENT_HOST' => $objEvent->org_name, $this->moduleLangVar . '_EVENT_HOST_ADDRESS' => $objEvent->org_street, $this->moduleLangVar . '_EVENT_HOST_ZIP' => $objEvent->org_zip, $this->moduleLangVar . '_EVENT_HOST_CITY' => $objEvent->org_city, $this->moduleLangVar . '_EVENT_HOST_COUNTRY' => $objEvent->org_country, $this->moduleLangVar . '_EVENT_HOST_WEBSITE' => $hostWebsite, $this->moduleLangVar . '_EVENT_HOST_WEBSITE_SOURCE' => $hostWebsiteSource, $this->moduleLangVar . '_EVENT_HOST_LINK' => $hostLink, $this->moduleLangVar . '_EVENT_HOST_LINK_SOURCE' => $hostLinkSource, $this->moduleLangVar . '_EVENT_HOST_PHONE' => $objEvent->org_phone, $this->moduleLangVar . '_EVENT_HOST_EMAIL' => $objEvent->org_email != '' ? "<a href='mailto:" . $objEvent->org_email . "' >" . $objEvent->org_email . "</a>" : "", $this->moduleLangVar . '_EVENT_HOST_EMAIL_SOURCE' => $objEvent->org_email));
         if ($objTpl->blockExists('event_location_website')) {
             if (empty($placeWebsite)) {
                 $objTpl->hideBlock('event_location_website');
             } else {
                 $objTpl->touchBlock('event_location_website');
             }
         }
         if ($objTpl->blockExists('event_location_link')) {
             if (empty($placeLink)) {
                 $objTpl->hideBlock('event_location_link');
             } else {
                 $objTpl->touchBlock('event_location_link');
             }
         }
         if ($objTpl->blockExists('event_location_phone')) {
             if (empty($objEvent->place_phone)) {
                 $objTpl->hideBlock('event_location_phone');
             } else {
                 $objTpl->touchBlock('event_location_phone');
             }
         }
         if ($objTpl->blockExists('event_location_map')) {
             if ($hasPlaceMap) {
                 $objTpl->touchBlock('event_location_map');
             } else {
                 $objTpl->hideBlock('event_location_map');
             }
         }
         if ($objTpl->blockExists('event_host_website')) {
             if (empty($hostWebsite)) {
                 $objTpl->hideBlock('event_host_website');
             } else {
                 $objTpl->touchBlock('event_host_website');
             }
         }
         if ($objTpl->blockExists('event_host_link')) {
             if (empty($hostLink)) {
                 $objTpl->hideBlock('event_host_link');
             } else {
                 $objTpl->touchBlock('event_host_link');
             }
         }
         if ($objTpl->blockExists('event_host_phone')) {
             if (empty($objEvent->org_phone)) {
                 $objTpl->hideBlock('event_host_phone');
             } else {
                 $objTpl->touchBlock('event_host_phone');
             }
         }
         if ($objTpl->blockExists('event_host_email')) {
             if (empty($objEvent->org_email)) {
                 $objTpl->hideBlock('event_host_email');
             } else {
                 $objTpl->touchBlock('event_host_email');
             }
         }
         if ($objInit->mode == 'backend') {
             $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_COUNT_REG' => $objEvent->getRegistrationCount(), $this->moduleLangVar . '_EVENT_COUNT_DEREG' => $objEvent->getCancellationCount(), $this->moduleLangVar . '_EVENT_COUNT_WAITLIST' => $objEvent->getWaitlistCount()));
         }
         $i++;
         // show date block
         if ($objTpl->blockExists('calendarDateList')) {
             $showStartDateList = $objEvent->useCustomDateDisplay ? $objEvent->showStartDateList : $this->arrSettings['showStartDateList'] == 1;
             $showEndDateList = $objEvent->useCustomDateDisplay ? $objEvent->showEndDateList : $this->arrSettings['showEndDateList'] == 1;
             $showStartTimeList = $objEvent->all_day ? false : ($objEvent->useCustomDateDisplay ? $objEvent->showStartTimeList : $this->arrSettings['showStartTimeList'] == 1);
             $showEndTimeList = $objEvent->all_day ? false : ($objEvent->useCustomDateDisplay ? $objEvent->showEndTimeList : $this->arrSettings['showEndTimeList'] == 1);
             $showTimeTypeList = $objEvent->useCustomDateDisplay ? $objEvent->showTimeTypeList : 1;
             // get date for several days format > show starttime with startdate and endtime with enddate > only if several days event and all values (dates/times) are displayed
             if ($this->format2userDate($startDate) != $this->format2userDate($endDate) && ($showStartDateList && $showEndDateList && $showStartTimeList && $showEndTimeList)) {
                 //part 1
                 $part = 1;
                 $this->getMultiDateBlock($objEvent, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorSeveralDaysList'], $this->arrSettings['showClockList'] == 1, $part);
                 $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock));
                 $objTpl->parse('calendarDateList');
                 //part 2
                 $part = 2;
                 $this->getMultiDateBlock($objEvent, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorSeveralDaysList'], $this->arrSettings['showClockList'] == 1, $part);
                 $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock));
                 $objTpl->parse('calendarDateList');
             } else {
                 // get date for single day format
                 $this->getSingleDateBlock($objEvent, $showStartDateList, $showEndDateList, $this->arrSettings['separatorDateList'], $showTimeTypeList, $showStartTimeList, $showEndTimeList, $this->arrSettings['separatorDateTimeList'], $this->arrSettings['separatorTimeList'], $this->arrSettings['showClockList'] == 1);
                 $objTpl->setVariable(array($this->moduleLangVar . '_DATE_LIST' => $this->date, $this->moduleLangVar . '_SEP_DATE_TIME_LIST' => $this->sepDateTime, $this->moduleLangVar . '_TIME_LIST' => $this->time, 'TXT_' . $this->moduleLangVar . '_CLOCK_LIST' => $this->clock));
                 $objTpl->parse('calendarDateList');
             }
         }
         if ($objInit->mode == \Cx\Core\Core\Controller\Cx::MODE_FRONTEND) {
             $this->parseRegistrationPlaceholders($objTpl, $objEvent, $hostUri, $hostTarget);
         }
         if ($type == 'confirm') {
             if ($objTpl->blockExists('eventConfirmList')) {
                 $objTpl->parse('eventConfirmList');
             }
         } else {
             if ($objTpl->blockExists('eventList')) {
                 $objTpl->parse('eventList');
             }
             if ($objTpl->blockExists('calendar_headlines_row')) {
                 $objTpl->parse('calendar_headlines_row');
             }
         }
     }
     if (count($this->eventList) == 0 && $type != 'confirm') {
         $objTpl->hideBlock('eventList');
         $objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_NO_EVENTS' => $_ARRAYLANG['TXT_CALENDAR_EVENTS_NO']));
         $objTpl->parse('emptyEventList');
     }
     //}
 }
Beispiel #7
0
 /**
  * Get the user details link
  *
  * @param mixed $user \User or
  *                    \Cx\Core\User\Model\Entity\User or
  *                    $userId (Id of a user)
  *
  * @return string Returns the parsed user detail link(crm and access)
  */
 public static function getParsedUserLink($user)
 {
     global $_CORELANG;
     if ($user instanceof \Cx\Core\User\Model\Entity\User) {
         $user = self::getFWUserObject()->objUser->getUser($user->getId());
     }
     if (!is_object($user)) {
         $user = self::getFWUserObject()->objUser->getUser($user);
     }
     if (!$user instanceof \User) {
         return '';
     }
     $crmDetailImg = '';
     if (!\FWValidator::isEmpty($user->getCrmUserId())) {
         $crmDetailImg = "<a href='index.php?cmd=Crm&amp;act=customers&amp;tpl=showcustdetail&amp;id={$user->getCrmUserId()}'\n                                title='{$_CORELANG['TXT_CORE_EDIT_USER_CRM_ACCOUNT']}'>\n                                <img\n                                    src='../core/Core/View/Media/navigation_level_1_189.png'\n                                    width='16' height='16'\n                                    alt='{$_CORELANG['TXT_CORE_EDIT_USER_CRM_ACCOUNT']}'\n                                />\n                            </a>";
     }
     return "<a href='index.php?cmd=Access&amp;act=user&amp;tpl=modify&amp;id={$user->getId()}'\n                    title='{$_CORELANG['TXT_EDIT_USER_ACCOUNT']}'>" . self::getParsedUserTitle($user) . "</a>" . $crmDetailImg;
 }
Beispiel #8
0
 /**
  *
  * @global type $_POST
  * @param \settingsManager $settingsManager
  * @param \ADONewConnection $objDb 
  */
 public function save($objDb)
 {
     \Cx\Core\Setting\Controller\Setting::init('Config', 'license', 'Yaml');
     // core
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('installationId')) {
         \Cx\Core\Setting\Controller\Setting::add('installationId', $this->getInstallationId(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'core');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('installationId', $this->getInstallationId());
     }
     // license
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseKey')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseKey', $this->getLicenseKey(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseKey', $this->getLicenseKey());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseState')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseState', $this->getState(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseState', $this->getState());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseValidTo')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseValidTo', $this->getValidToDate(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_DATETIME, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseValidTo', $this->getValidToDate());
     }
     // we must encode the serialized objects to prevent that non-ascii chars
     // get written into the config/settings.php file
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseMessage')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseMessage', base64_encode(serialize($this->getMessages())), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseMessage', base64_encode(serialize($this->getMessages())));
     }
     // see comment above why we encode the serialized data here
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licensePartner')) {
         \Cx\Core\Setting\Controller\Setting::add('licensePartner', base64_encode(serialize($this->getPartner())), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licensePartner', base64_encode(serialize($this->getPartner())));
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseCustomer')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseCustomer', base64_encode(serialize($this->getCustomer())), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseCustomer', base64_encode(serialize($this->getCustomer())));
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('upgradeUrl')) {
         \Cx\Core\Setting\Controller\Setting::add('upgradeUrl', $this->getUpgradeUrl(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('upgradeUrl', $this->getUpgradeUrl());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseCreatedAt')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseCreatedAt', $this->getCreatedAtDate(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_DATE, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseCreatedAt', $this->getCreatedAtDate());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseDomains')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseDomains', base64_encode(serialize($this->getRegisteredDomains())), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseDomains', base64_encode(serialize($this->getRegisteredDomains())));
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('availableComponents')) {
         \Cx\Core\Setting\Controller\Setting::add('availableComponents', base64_encode(serialize($this->getAvailableComponents())), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('availableComponents', base64_encode(serialize($this->getAvailableComponents())));
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('dashboardMessages')) {
         \Cx\Core\Setting\Controller\Setting::add('dashboardMessages', base64_encode(serialize($this->getDashboardMessages())), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('dashboardMessages', base64_encode(serialize($this->getDashboardMessages())));
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('isUpgradable')) {
         \Cx\Core\Setting\Controller\Setting::add('isUpgradable', $this->isUpgradable() ? 'on' : 'off', 1, \Cx\Core\Setting\Controller\Setting::TYPE_RADIO, 'on:Activated,off:Deactivated', 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('isUpgradable', $this->isUpgradable() ? 'on' : 'off');
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseGrayzoneMessages')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseGrayzoneMessages', base64_encode(serialize($this->getGrayzoneMessages())), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseGrayzoneMessages', base64_encode(serialize($this->getGrayzoneMessages())));
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseGrayzoneTime')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseGrayzoneTime', $this->getGrayzoneTime(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseGrayzoneTime', $this->getGrayzoneTime());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseLockTime')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseLockTime', $this->getFrontendLockTime(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseLockTime', $this->getFrontendLockTime());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseUpdateInterval')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseUpdateInterval', $this->getRequestInterval(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseUpdateInterval', $this->getRequestInterval());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseFailedUpdate')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseFailedUpdate', $this->getFirstFailedUpdateTime(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseFailedUpdate', $this->getFirstFailedUpdateTime());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('licenseSuccessfulUpdate')) {
         \Cx\Core\Setting\Controller\Setting::add('licenseSuccessfulUpdate', $this->getLastSuccessfulUpdateTime(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'license');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('licenseSuccessfulUpdate', $this->getLastSuccessfulUpdateTime());
     }
     // release
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsEdition')) {
         \Cx\Core\Setting\Controller\Setting::add('coreCmsEdition', $this->getEditionName(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'release');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('coreCmsEdition', $this->getEditionName());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsVersion')) {
         \Cx\Core\Setting\Controller\Setting::add('coreCmsVersion', $this->getVersion()->getNumber(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'release');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('coreCmsVersion', $this->getVersion()->getNumber());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsCodeName')) {
         \Cx\Core\Setting\Controller\Setting::add('coreCmsCodeName', $this->getVersion()->getCodeName(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'release');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('coreCmsCodeName', $this->getVersion()->getCodeName());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsStatus')) {
         \Cx\Core\Setting\Controller\Setting::add('coreCmsStatus', $this->getVersion()->getState(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'release');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('coreCmsStatus', $this->getVersion()->getState());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsReleaseDate')) {
         \Cx\Core\Setting\Controller\Setting::add('coreCmsReleaseDate', $this->getVersion()->getReleaseDate(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_DATE, null, 'release');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('coreCmsReleaseDate', $this->getVersion()->getReleaseDate());
     }
     if (!\Cx\Core\Setting\Controller\Setting::isDefined('coreCmsName')) {
         \Cx\Core\Setting\Controller\Setting::add('coreCmsName', $this->getVersion()->getName(), 1, \Cx\Core\Setting\Controller\Setting::TYPE_TEXT, null, 'release');
     } else {
         \Cx\Core\Setting\Controller\Setting::set('coreCmsName', $this->getVersion()->getName());
     }
     \Cx\Core\Setting\Controller\Setting::updateAll();
     $query = '
         UPDATE
             ' . DBPREFIX . 'modules
         SET
             `is_licensed` = \'0\' , 
             `additional_data` = NULL
         WHERE
             `distributor` = \'Cloudrexx AG\'
     ';
     $objDb->Execute($query);
     $query = '
         UPDATE
             ' . DBPREFIX . 'modules
         SET
             `is_licensed` = \'1\'
         WHERE
             `name` IN(\'' . implode('\', \'', $this->getLegalComponentsList()) . '\')
     ';
     $objDb->Execute($query);
     //Save legal components additional data values.
     if (!\FWValidator::isEmpty($this->getLegalComponentsAdditionalData())) {
         foreach ($this->getLegalComponentsAdditionalData() as $componentName => $additionalData) {
             if (empty($componentName)) {
                 continue;
             }
             $query = "\n                    UPDATE \n                        " . DBPREFIX . "modules\n                    SET \n                        `additional_data` = '" . contrexx_raw2db(json_encode($additionalData)) . "'\n                    WHERE \n                        `name` = '" . contrexx_raw2db($componentName) . "'\n                    ";
             $objDb->Execute($query);
         }
     }
 }
 /**
  * Update CodeBase
  * 
  * @param string $newCodeBaseVersion   latest codeBase version
  * @param string $installationRootPath installationRoot path
  * @param string $oldCodeBaseVersion   old codeBase version
  */
 public function updateCodeBase($newCodeBaseVersion, $installationRootPath, $oldCodeBaseVersion = '')
 {
     //change installation root
     $objConfigData = new \Cx\Lib\FileSystem\File(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteConfigPath() . '/configuration.php');
     $configData = $objConfigData->getData();
     if (!\FWValidator::isEmpty($oldCodeBaseVersion)) {
         $matches = array();
         preg_match('/\\$_PATHCONFIG\\[\'ascms_installation_root\'\\] = \'(.*?)\';/', $configData, $matches);
         $installationRootPath = str_replace($newCodeBaseVersion, $oldCodeBaseVersion, $matches[1]);
         $newCodeBaseVersion = $oldCodeBaseVersion;
     }
     $newConfigData = preg_replace('/\\$_PATHCONFIG\\[\'ascms_installation_root\'\\] = \'.*?\';/', '$_PATHCONFIG[\'ascms_installation_root\'] = \'' . $installationRootPath . '\';', $configData);
     $objConfigData->write($newConfigData);
     //change code base
     \Cx\Core\Setting\Controller\Setting::init('Config', '', 'Yaml');
     \Cx\Core\Setting\Controller\Setting::set('coreCmsVersion', $newCodeBaseVersion);
     \Cx\Core\Setting\Controller\Setting::update('coreCmsVersion');
 }
Beispiel #10
0
 /**
  * Store user account
  *
  * This stores the metadata of the user, which includes the username,
  * password, email, language ID, activ status and the administration status,
  * to the database.
  * If it is a new user, it also sets the registration time to the current time.
  * @global ADONewConnection
  * @global array
  * @return boolean
  */
 public function store()
 {
     global $objDatabase, $_CORELANG, $_LANGID;
     //for calling postPersist and postUpdate based on $callPostUpdateEvent
     $callPostUpdateEvent = $this->id;
     $generatedPassword = '';
     // Track if a user account change is being flushed to the database.
     // If so, we'll trigger the postUpdate event, but only in that case.
     // Explanation: A flush would indicate that the user object has actually been altered.
     // This is a pseudo emulation of doctrine's own event system behavior which triggers
     // the postUpdate event on an entity only in case the entity has actually been altered.
     $userChangeStatus = null;
     if (!$this->validateUsername()) {
         return false;
     }
     if (!$this->validateEmail()) {
         return false;
     }
     if ($this->networks) {
         $this->networks->save();
     }
     if ($this->id) {
         // update existing account
         \Env::get('cx')->getEvents()->triggerEvent('model/preUpdate', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
         $this->updateUser($userChangeStatus);
     } else {
         // add new account
         if (\FWValidator::isEmpty($this->getHashedPassword())) {
             $generatedPassword = $this->make_password();
             $this->setPassword($generatedPassword);
         }
         \Env::get('cx')->getEvents()->triggerEvent('model/prePersist', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
         $this->createUser();
         if (!\FWValidator::isEmpty($generatedPassword)) {
             $this->sendUserAccountInvitationMail($generatedPassword);
         }
     }
     if (!$this->storeGroupAssociations($userChangeStatus)) {
         $this->error_msg[] = $_CORELANG['TXT_ARRAY_COULD_NOT_SET_GROUP_ASSOCIATIONS'];
         return false;
     }
     if (!$this->storeNewsletterSubscriptions($userChangeStatus)) {
         $this->error_msg[] = $_CORELANG['TXT_ARRAY_COULD_NOT_SET_NEWSLETTER_ASSOCIATIONS'];
         return false;
     }
     if (!$this->storeProfile($userChangeStatus)) {
         $this->error_msg[] = $_CORELANG['TXT_ACCESS_FAILED_STORE_PROFILE'];
         return false;
     }
     if (!empty($callPostUpdateEvent)) {
         // only trigger postUpdate event in case an actual change on the user object has been flushed to the database
         if ($userChangeStatus) {
             \Env::get('cx')->getEvents()->triggerEvent('model/postUpdate', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
         }
     } else {
         \Env::get('cx')->getEvents()->triggerEvent('model/postPersist', array(new \Doctrine\ORM\Event\LifecycleEventArgs($this, \Env::get('em'))));
     }
     return true;
 }
 /**
  * This function is used to convert the entity object into array.
  * 
  * @param  mixed Single or array of entity objects     
  * 
  * @return array  return as array
  */
 public function import($data)
 {
     // convert data into a array if its not an array
     if (!is_array($data)) {
         $data = array($data);
     }
     //create array from objects
     $resultArr = array();
     foreach ($data as $object) {
         if (!is_object($object) && !$object instanceof \Cx\Model\Base\EntityBase) {
             return;
         }
         $em = \Env::get('em');
         $associationEntityColumns = array();
         $entityClassMetaData = $em->getClassMetadata(get_class($object));
         $associationMappings = $entityClassMetaData->getAssociationMappings();
         if (!empty($associationMappings)) {
             foreach ($associationMappings as $field => $associationMapping) {
                 if ($entityClassMetaData->isSingleValuedAssociation($field) && in_array('get' . ucfirst($field), get_class_methods($object))) {
                     $associationObject = $object->{'get' . ucfirst($field)}();
                     if ($associationObject) {
                         //get association columns
                         $associationEntityColumn = $this->getColumnNamesByEntity($associationObject);
                         $associationEntityColumns[$field] = !\FWValidator::isEmpty($associationEntityColumn) ? $associationEntityColumn : '';
                     }
                 }
             }
         }
         //get entity columns
         $entityColumns = $this->getColumnNamesByEntity($object);
         $resultData = array_merge($entityColumns, $associationEntityColumns);
         $resultData['virtual'] = $object->isVirtual();
         $resultArr[] = $resultData;
     }
     return $resultArr;
 }
 public function showSubscriptions()
 {
     global $_ARRAYLANG;
     $term = isset($_GET['term']) ? contrexx_input2raw($_GET['term']) : '';
     $filterProduct = isset($_GET['filter_product']) ? contrexx_input2raw($_GET['filter_product']) : array();
     $filterState = isset($_GET['filter_state']) ? contrexx_input2raw($_GET['filter_state']) : array();
     if (!empty($term) || !empty($filterProduct) || !empty($filterState)) {
         $filter = array('term' => $term, 'filterProduct' => $filterProduct, 'filterState' => $filterState);
         $subscriptions = $this->subscriptionRepo->findSubscriptionsBySearchTerm($filter);
     } else {
         $subscriptions = $this->subscriptionRepo->getSubscriptionsByCriteria(null, array('s.id' => 'DESC'));
     }
     $products = \Env::get('em')->getRepository('Cx\\Modules\\Pim\\Model\\Entity\\Product')->findAll();
     $this->getSearchFilterDropDown($products, $filterProduct, 'product');
     $subscriptionStates = array(\Cx\Modules\Order\Model\Entity\Subscription::STATE_ACTIVE, \Cx\Modules\Order\Model\Entity\Subscription::STATE_INACTIVE, \Cx\Modules\Order\Model\Entity\Subscription::STATE_TERMINATED, \Cx\Modules\Order\Model\Entity\Subscription::STATE_CANCELLED);
     $this->getSearchFilterDropDown($subscriptionStates, $filterState, 'state');
     $view = new \Cx\Core\Html\Controller\ViewGenerator($subscriptions, array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_ACT_SUBSCRIPTION'], 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false), 'fields' => array('id' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_ID']), 'subscriptionDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_DATE']), 'expirationDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_EXPIRATION_DATE']), 'productEntityId' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_PRODUCT_ENTITY'], 'table' => array('parse' => function ($value, $rowData) {
         $subscription = $this->subscriptionRepo->findOneBy(array('id' => $rowData['id']));
         $productEntity = $subscription->getProductEntity();
         if (!$productEntity) {
             return;
         }
         $productEditLink = $productEntity;
         if (method_exists($productEntity, 'getEditLink')) {
             $productEditLink = $productEntity->getEditLink();
         }
         return $productEditLink;
     })), 'paymentAmount' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_PAYMENT_AMOUNT'], 'table' => array('parse' => function ($value, $rowData) {
         if (\FWValidator::isEmpty(floatval($value))) {
             return null;
         }
         $subscription = $this->subscriptionRepo->findOneBy(array('id' => $rowData['id']));
         $currency = '';
         $order = $subscription->getOrder();
         if ($order) {
             $currency = !\FWValidator::isEmpty($order->getCurrency()) ? $order->getCurrency() : '';
         }
         $paymentInterval = $subscription->getRenewalUnit();
         return $value . ' ' . $currency . ' / ' . $paymentInterval;
     })), 'renewalUnit' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_RENEWAL_UNIT'], 'table' => array('parse' => function ($value, $rowData) {
         if (empty($value)) {
             return null;
         }
         $subscription = $this->subscriptionRepo->findOneBy(array('id' => $rowData['id']));
         $renewalDate = '';
         if ($subscription->getRenewalDate()) {
             $renewalDate = $subscription->getRenewalDate();
             $quantifier = $subscription->getRenewalQuantifier();
             $renewalDate->modify("-{$quantifier} {$value}");
             return $renewalDate->format('d.M.Y H:i:s');
         }
         return $renewalDate;
     })), 'renewalQuantifier' => array('showOverview' => false), 'renewalDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_RENEWAL_DATE']), 'description' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_DESCRIPTION']), 'state' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_STATE']), 'terminationDate' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_TERMI_DATE']), 'note' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_NOTE']), 'product' => array('header' => $_ARRAYLANG['TXT_MODULE_ORDER_SUBSCRIPTION_PRODUCT'], 'table' => array('parse' => function ($value, $rowData) {
         $subscription = $this->subscriptionRepo->findOneBy(array('id' => $rowData['id']));
         $product = $subscription->getProduct();
         if (!$product) {
             return;
         }
         return $product->getName();
     })), 'paymentState' => array('showOverview' => false), 'externalSubscriptionId' => array('showOverview' => false), 'order' => array('showOverview' => false))));
     $this->template->setVariable(array('TXT_ORDER_SUBSCRIPTIONS_FILTER' => $_ARRAYLANG['TXT_MODULE_ORDER_FILTER'], 'TXT_ORDER_SUBSCRIPTIONS_SEARCH' => $_ARRAYLANG['TXT_MODULE_ORDER_SEARCH'], 'TXT_ORDER_SUBSCRIPTIONS_SEARCH_TERM' => $_ARRAYLANG['TXT_MODULE_ORDER_SEARCH_TERM'], 'ORDER_SUBSCRIPTIONS_SEARCH_VALUE' => contrexx_raw2xhtml($term)));
     if (isset($_GET['editid']) && !empty($_GET['editid']) || isset($_GET['add']) && !empty($_GET['add'])) {
         $this->template->hideBlock("subscription_filter");
     }
     $this->template->setVariable('SUBSCRIPTIONS_CONTENT', $view->render());
 }