public function editDetailsObject($a_show_confirm = false)
 {
     global $ilToolbar;
     if (!(int) $_GET['pobject_id']) {
         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
         return $this->objectsObject();
     }
     $this->__initPaymentObject((int) $_GET['pobject_id']);
     $this->ctrl->setParameter($this, 'pobject_id', (int) $_GET['pobject_id']);
     $ilToolbar->addButton($this->lng->txt('paya_edit_details'), $this->ctrl->getLinkTarget($this, 'editDetails'));
     $ilToolbar->addButton($this->lng->txt('paya_edit_prices'), $this->ctrl->getLinkTarget($this, 'editPrices'));
     $ilToolbar->addButton($this->lng->txt('pay_edit_abstract'), $this->ctrl->getLinkTargetByClass(array('ilshoppagegui'), 'edit'));
     $this->tpl->addBlockfile('ADM_CONTENT', 'adm_content', 'tpl.main_view.html', 'Services/Payment');
     $tmp_obj = ilObjectFactory::getInstanceByRefId($this->pobject->getRefId(), false);
     if ($tmp_obj) {
         $tmp_object['title'] = $tmp_obj->getTitle();
         $tmp_object['type'] = $tmp_obj->getType();
     } else {
         $tmp_object['title'] = $this->lng->txt('object_not_found');
         $tmp_object['type'] = '';
     }
     if ($a_show_confirm) {
         include_once './Services/Utilities/classes/class.ilConfirmationGUI.php';
         $oConfirmationGUI = new ilConfirmationGUI();
         // set confirm/cancel commands
         $oConfirmationGUI->setFormAction($this->ctrl->getFormAction($this, "performObjectDelete"));
         $oConfirmationGUI->setHeaderText($this->lng->txt("paya_sure_delete_object"));
         $oConfirmationGUI->setCancel($this->lng->txt("cancel"), "objects");
         $oConfirmationGUI->setConfirm($this->lng->txt("confirm"), "performObjectDelete");
         $oConfirmationGUI->addItem('', $tmp_object['title'], $tmp_object['title']);
         $this->tpl->setVariable('CONFIRMATION', $oConfirmationGUI->getHTML());
         return true;
     }
     $oForm = new ilPropertyFormGUI();
     $oForm->setFormAction($this->ctrl->getFormAction($this, 'updateDetails'));
     $oForm->setTitle($tmp_object['title']);
     // repository path
     $oPathGUI = new ilNonEditableValueGUI($this->lng->txt('path'));
     $oPathGUI->setValue($this->__getHTMLPath($this->pobject->getRefId()));
     $oForm->addItem($oPathGUI);
     // number of purchasers
     $oPurchasersGUI = new ilNonEditableValueGUI($this->lng->txt('paya_count_purchaser'));
     $oPurchasersGUI->setValue(ilPaymentBookings::_getCountBookingsByObject((int) $_GET['pobject_id']));
     $oForm->addItem($oPurchasersGUI);
     // vendors
     $oVendorsGUI = new ilSelectInputGUI($this->lng->txt('paya_vendor'), 'vendor');
     $oVendorsGUI->setOptions($this->__getVendors());
     $oVendorsGUI->setValue($this->pobject->getVendorId());
     $oForm->addItem($oVendorsGUI);
     // status
     $oStatusGUI = new ilSelectInputGUI($this->lng->txt('status'), 'status');
     $oStatusGUI->setOptions($this->__getStatus());
     $oStatusGUI->setValue($this->pobject->getStatus());
     $oForm->addItem($oStatusGUI);
     // pay methods
     $oPayMethodsGUI = new ilSelectInputGUI($this->lng->txt('paya_pay_method'), 'pay_method');
     $oPayMethodsGUI->setOptions(ilPayMethods::getPayMethodsOptions('not_specified'));
     $oPayMethodsGUI->setValue($this->pobject->getPayMethod());
     $oForm->addItem($oPayMethodsGUI);
     // topics
     include_once './Services/Payment/classes/class.ilShopTopics.php';
     ilShopTopics::_getInstance()->read();
     if (is_array($topics = ilShopTopics::_getInstance()->getTopics()) && count($topics)) {
         $oTopicsGUI = new ilSelectInputGUI($this->lng->txt('topic'), 'topic_id');
         ilShopTopics::_getInstance()->read();
         $topic_options = array();
         $topic_options[''] = $this->lng->txt('please_choose');
         foreach ($topics as $oTopic) {
             $topic_options[$oTopic->getId()] = $oTopic->getTitle();
         }
         $oTopicsGUI->setOptions($topic_options);
         $oTopicsGUI->setValue($this->pobject->getTopicId());
         $oForm->addItem($oTopicsGUI);
     }
     // vats
     $oShopVatsList = new ilShopVatsList();
     $oShopVatsList->read();
     if ($oShopVatsList->hasItems()) {
         $oVatsGUI = new ilSelectInputGUI($this->lng->txt('vat_rate'), 'vat_id');
         $vats_options = array();
         foreach ($oShopVatsList as $oVAT) {
             $vats_options[$oVAT->getId()] = ilShopUtils::_formatVAT($oVAT->getRate()) . ' -> ' . $oVAT->getTitle();
         }
         $oVatsGUI->setOptions($vats_options);
         $oVatsGUI->setValue($this->pobject->getVatId());
         $oForm->addItem($oVatsGUI);
     } else {
         $oVatsGUI = new ilNonEditableValueGUI($this->lng->txt('vat_rate'));
         $oVatsGUI->setValue($this->lng->txt('paya_no_vats_assigned'));
         $oForm->addItem($oVatsGUI);
     }
     $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail');
     $oFile = new ilFileDataShop($this->pobject->getPobjectId());
     if (($webpath_file = $oFile->getCurrentImageWebPath()) !== false) {
         $oThumbnail->setImage($webpath_file);
     }
     $oForm->addItem($oThumbnail);
     // buttons
     $oForm->addCommandButton('updateDetails', $this->lng->txt('save'));
     $oForm->addCommandButton('deleteObject', $this->lng->txt('delete'));
     $this->tpl->setVariable('FORM', $oForm->getHTML());
     return true;
 }
 /**
  * @param $cur_obj_type
  * @param $item
  * @return array
  */
 private function getObjectListItem($cur_obj_type, $item)
 {
     if ($cur_obj_type != $item['type']) {
         include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
         $item_list_gui = ilObjectListGUIFactory::_getListGUIByType($item['type']);
     }
     $item_list_gui->initItem($item['ref_id'], $item['obj_id'], $item['title'], $item['description'], ilObjectListGUI::CONTEXT_SHOP);
     $item_list_gui->enableDelete(false);
     $item_list_gui->enableCut(false);
     $item_list_gui->enableCopy(false);
     $item_list_gui->enableLink(false);
     $item_list_gui->enableSubscribe(false);
     $item_list_gui->enablePayment(true);
     $item_list_gui->enableCommands(true);
     $item_list_gui->enablePath(false);
     $item_list_gui->insertCommands();
     $item_list_gui->enableInfoScreen(false);
     $item_list_gui->enableSubstitutions(false);
     $item_list_gui->enableNoticeProperties(false);
     $item_list_gui->enablePreconditions(false);
     $item_list_gui->enableProperties(false);
     $item_list_gui->setBoldTitle(true);
     if (ilPaymentObject::_hasAccess($item['ref_id'])) {
         $item_list_gui->enableInfoScreen(true);
         $item_list_gui->enableCommands(true);
     }
     //		else
     //		{
     switch ($item['type']) {
         case 'sahs':
             $demo_link = 'ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=' . $item['ref_id'] . '&purchasetype=demo';
             break;
         case 'lm':
             $demo_link = 'ilias.php?baseClass=ilLMPresentationGUI&ref_id=' . $item['ref_id'] . '&purchasetype=demo';
             break;
         case 'exc':
             $demo_link = $this->ctrl->getLinkTargetByClass('ilshoppurchasegui', 'showDemoVersion') . '&purchasetype=demo&ref_id=' . $item["ref_id"];
             break;
         default:
             $demo_link = $this->ctrl->getLinkTargetByClass('ilshoppurchasegui', 'showDemoVersion') . '&purchasetype=demo&ref_id=' . $item["ref_id"];
             break;
     }
     $item['title'] = '<a href="' . $demo_link . '">' . $item["title"] . '</a>';
     //		}
     $tpl_pinfo = new ilTemplate('tpl.shop_item_info.html', true, true, 'Services/Payment');
     if ($item['price_string'] != '') {
         $tpl_pinfo->setCurrentBlock('ploop');
         $tpl_pinfo->setVariable('PROPERTY', $this->lng->txt('price_a'));
         $tpl_pinfo->setVariable('VALUE', $item['price_string']);
         $tpl_pinfo->parseCurrentBlock();
     }
     if ($item['author'] != '') {
         $tpl_pinfo->setCurrentBlock('ploop');
         $tpl_pinfo->setVariable('PROPERTY', $this->lng->txt('author'));
         $tpl_pinfo->setVariable('VALUE', $item['author']);
         $tpl_pinfo->parseCurrentBlock();
     }
     $oFile = new ilFileDataShop(ilPaymentObject::_lookupPobjectId($item['ref_id']));
     if (($webpath_file = $oFile->getCurrentImageWebPath()) !== false) {
         $tpl_pinfo->setCurrentBlock('image');
         $tpl_pinfo->setVariable('SRC', $webpath_file);
         $tpl_pinfo->setVariable('ALT', strip_tags($item['title']));
         $tpl_pinfo->parseCurrentBlock();
     }
     $item_list_gui->addSubItemHTML($tpl_pinfo->get());
     $html = $item_list_gui->getListItemHTML($item['ref_id'], $item['obj_id'], $item['title'], $item['description'], false, false, "", ilObjectListGUI::CONTEXT_SHOP);
     return array($item, $html);
 }
 private function renderItems($oContainerTpl, $results, $topic)
 {
     // main shop_content
     global $ilUser;
     $items_counter = 0;
     $cur_obj_type = '';
     $tpl = $this->newBlockTemplate();
     $first = true;
     foreach ($this->type_ordering as $act_type) {
         $item_html = array();
         if (count($results[$topic['id']][$act_type])) {
             foreach ($results[$topic['id']][$act_type] as $key => $item) {
                 // price presentation
                 $oPaymentObject = new ilPaymentObject($ilUser, ilPaymentObject::_lookupPobjectId($item['ref_id']));
                 $oPrice = new ilPaymentPrices((int) $oPaymentObject->getPobjectId());
                 $lowest_price = $oPrice->getLowestPrice();
                 $special_icon = ' ';
                 if ($oPaymentObject->getSpecial() == '1') {
                     $special_icon = ilShopUtils::_getSpecialObjectSymbol();
                 }
                 $results[$topic['id']][$act_type][$key]['title'] = $item['title'] . ' ' . ($results[$topic['id']][$act_type][$key]['special_icon'] = $special_icon);
                 $results[$topic['id']][$act_type][$key]['price'] = $lowest_price['price'];
                 $paymethod_icon = ilShopUtils::_getPaymethodSymbol($oPaymentObject->getPayMethod());
                 //					if(!ilPaymentObject::_hasAccess($item['ref_id']))
                 //					{
                 $shoppingcart_icon = ilShopUtils::_addToShoppingCartSymbol($act_type, $item['ref_id']);
                 //					}
                 //					else $shoppingcart_icon = '';
                 $results[$topic['id']][$act_type][$key]['price_string'] = ($oPrice->getNumberOfPrices() > 1 ? $this->lng->txt('price_from') . ' ' : '') . ilPaymentPrices::_formatPriceToString($lowest_price['price']) . ' ' . ($results[$topic['id']][$act_type][$key]['shoppingcart_icon'] = $shoppingcart_icon . ' ' . ($results[$topic['id']][$act_type][$key]['paymethod_icon'] = $paymethod_icon));
                 // authors
                 include_once 'Services/MetaData/classes/class.ilMD.php';
                 $md_obj = new ilMD($item['obj_id'], 0, $item['type']);
                 if (is_object($md_section = $md_obj->getLifecycle())) {
                     $sep = $ent_str = "";
                     foreach ($ids = $md_section->getContributeIds() as $con_id) {
                         $md_con = $md_section->getContribute($con_id);
                         if ($md_con->getRole() == "Author") {
                             foreach ($ent_ids = $md_con->getEntityIds() as $ent_id) {
                                 $md_ent = $md_con->getEntity($ent_id);
                                 $ent_str = $ent_str . $sep . $md_ent->getEntity();
                                 $sep = ", ";
                             }
                         }
                     }
                     $results[$topic['id']][$act_type][$key]['author'] = $ent_str;
                 }
             }
             $results[$topic['id']][$act_type] = $this->sortResult($results[$topic['id']][$act_type]);
             foreach ($results[$topic['id']][$act_type] as $key => $item) {
                 // get list gui class for each object type
                 if ($cur_obj_type != $item['type']) {
                     include_once 'Services/Object/classes/class.ilObjectListGUIFactory.php';
                     $item_list_gui = ilObjectListGUIFactory::_getListGUIByType($item['type']);
                 }
                 $item_list_gui->initItem($item['ref_id'], $item['obj_id'], $item['title'], $item['description'], ilObjectListGUI::CONTEXT_SHOP);
                 $item_list_gui->enableDelete(false);
                 $item_list_gui->enableCut(false);
                 $item_list_gui->enableCopy(false);
                 $item_list_gui->enableLink(false);
                 $item_list_gui->enableSubscribe(false);
                 $item_list_gui->enablePayment(true);
                 $item_list_gui->enableCommands(true);
                 $item_list_gui->enablePath(false);
                 $item_list_gui->insertCommands();
                 $item_list_gui->enableInfoScreen(false);
                 $item_list_gui->enableSubstitutions(false);
                 $item_list_gui->enableNoticeProperties(false);
                 $item_list_gui->enablePreconditions(false);
                 $item_list_gui->enableProperties(false);
                 $item_list_gui->setBoldTitle(true);
                 if (ilPaymentObject::_hasAccess($item['ref_id'])) {
                     $item_list_gui->enableInfoScreen(true);
                     $item_list_gui->enableCommands(true);
                 } else {
                     switch ($item['type']) {
                         case 'sahs':
                             $demo_link = 'ilias.php?baseClass=ilSAHSPresentationGUI&ref_id=' . $item['ref_id'] . '&purchasetype=demo';
                             break;
                         case 'lm':
                             $demo_link = 'ilias.php?baseClass=ilLMPresentationGUI&ref_id=' . $item['ref_id'] . '&purchasetype=demo';
                             break;
                         case 'exc':
                             $demo_link = $this->ctrl->getLinkTargetByClass('ilshoppurchasegui', 'showDemoVersion') . '&purchasetype=demo&ref_id=' . $item["ref_id"];
                             break;
                         default:
                             $demo_link = $this->ctrl->getLinkTargetByClass('ilshoppurchasegui', 'showDemoVersion') . '&purchasetype=demo&ref_id=' . $item["ref_id"];
                             break;
                     }
                     $item['title'] = '<a href="' . $demo_link . '">' . $item["title"] . '</a>';
                 }
                 $tpl_pinfo = new ilTemplate('tpl.shop_item_info.html', true, true, 'Services/Payment');
                 if ($item['price_string'] != '') {
                     $tpl_pinfo->setCurrentBlock('ploop');
                     $tpl_pinfo->setVariable('PROPERTY', $this->lng->txt('price_a'));
                     $tpl_pinfo->setVariable('VALUE', $item['price_string']);
                     $tpl_pinfo->parseCurrentBlock();
                 }
                 if ($item['author'] != '') {
                     $tpl_pinfo->setCurrentBlock('ploop');
                     $tpl_pinfo->setVariable('PROPERTY', $this->lng->txt('author'));
                     $tpl_pinfo->setVariable('VALUE', $item['author']);
                     $tpl_pinfo->parseCurrentBlock();
                 }
                 $oFile = new ilFileDataShop(ilPaymentObject::_lookupPobjectId($item['ref_id']));
                 if (($webpath_file = $oFile->getCurrentImageWebPath()) !== false) {
                     $tpl_pinfo->setCurrentBlock('image');
                     $tpl_pinfo->setVariable('SRC', $webpath_file);
                     $tpl_pinfo->setVariable('ALT', strip_tags($item['title']));
                     $tpl_pinfo->parseCurrentBlock();
                 }
                 $item_list_gui->addSubItemHTML($tpl_pinfo->get());
                 $html = $item_list_gui->getListItemHTML($item['ref_id'], $item['obj_id'], $item['title'], $item['description'], false, false, "", ilObjectListGUI::CONTEXT_SHOP);
                 if ($html) {
                     $html = $this->__appendChildLinks($html, $item, $item_list_gui);
                     $item_html[$item['ref_id']] = $html;
                 }
             }
             // output block for resource type
             if (count($item_html) > 0) {
                 // separator row
                 if (!$first) {
                     $this->addSeparatorRow($tpl);
                 }
                 $first = false;
                 // add a header for each resource type
                 $this->addHeaderRow($tpl, $act_type);
                 $this->resetRowType();
                 // content row
                 foreach ($item_html as $ref_id => $html) {
                     $this->addStandardRow($tpl, $html, $ref_id);
                 }
                 ++$items_counter;
             }
         }
     }
     if ($items_counter > 0) {
         $oContainerTpl->setCurrentBlock('loop');
         $oContainerTpl->setVariable('TOPIC_TITLE', $topic['title']);
         $oContainerTpl->setVariable('COTAINER_LIST_BLOCK', $tpl->get());
         $oContainerTpl->parseCurrentBlock();
         global $tpl;
         $tpl->setContent($oContainerTpl->get());
     }
 }
Ejemplo n.º 4
0
 public function delete()
 {
     if ($this->getPobjectId()) {
         include_once 'Services/Payment/classes/class.ilFileDataShop.php';
         $oFileData = new ilFileDataShop($this->getPobjectId());
         $oFileData->deassignFileFromPaymentObject();
         $statement = $this->db->manipulateF('DELETE FROM payment_objects WHERE pobject_id = %s', array('integer'), array($this->getPobjectId()));
         return true;
     }
     return false;
 }
 public function updateDetails()
 {
     if (!$_GET['pobject_id']) {
         ilUtil::sendInfo($this->lng->txt('paya_no_object_selected'));
         $this->showObjects();
         return true;
     }
     $this->__initPaymentObject((int) $_GET['pobject_id']);
     $this->ctrl->setParameter($this, 'pobject_id', (int) $_GET['pobject_id']);
     // read old settings
     $old_status = $this->pobject->getStatus();
     // check status changed from not_buyable
     if ($old_status == $this->pobject->STATUS_NOT_BUYABLE and (int) $_POST['status'] != $old_status) {
         // check pay_method edited
         switch ((int) $_POST['pay_method']) {
             case $this->pobject->PAY_METHOD_NOT_SPECIFIED:
                 ilUtil::sendInfo($this->lng->txt('paya_select_pay_method_first'));
                 $this->editDetails();
                 return false;
             default:
         }
         // check minimum one price
         include_once './Services/Payment/classes/class.ilPaymentPrices.php';
         $prices_obj = new ilPaymentPrices((int) $_GET['pobject_id']);
         if (!count($prices_obj->getPrices())) {
             ilUtil::sendInfo($this->lng->txt('paya_edit_prices_first'));
             $this->editDetails();
             return false;
         }
     }
     if ((int) $_POST['status'] == 0) {
         // Status: not buyable -> delete depending shoppingcart entries
         include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
         ilPaymentShoppingCart::_deleteShoppingCartEntries($this->pobject->getPobjectId());
     }
     $this->pobject->setStatus((int) $_POST['status']);
     $this->pobject->setVendorId((int) $_POST['vendor']);
     $this->pobject->setPayMethod((int) $_POST['pay_method']);
     $this->pobject->setTopicId((int) $_POST['topic_id']);
     $this->pobject->setVatId((int) $_POST['vat_id']);
     $this->pobject->setSubtype((string) $_POST['exc_subtype']);
     $this->pobject->setSpecial((int) $_POST['is_special']);
     if ((int) $_POST['thumbnail_delete']) {
         $oFile = new ilFileDataShop($this->pobject->getPobjectId());
         $oFile->deassignFileFromPaymentObject();
     } else {
         if ($_FILES['thumbnail']['tmp_name'] != '') {
             $this->lng->loadLanguageModule('form');
             include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
             $oThumbnail = new ilImageFileInputGUI($this->lng->txt('pay_thumbnail'), 'thumbnail');
             if ($oThumbnail->checkInput()) {
                 $oFile = new ilFileDataShop($this->pobject->getPobjectId());
                 if ($oFile->storeUploadedFile($_FILES['thumbnail']) !== false) {
                     $oFile->assignFileToPaymentObject();
                 }
             } else {
                 ilUtil::sendInfo($oThumbnail->getAlert());
                 return $this->editDetails();
             }
         }
     }
     $this->pobject->update();
     ilUtil::sendInfo($this->lng->txt('paya_details_updated'));
     $this->showObjects();
     return true;
 }