function submit($data, $form)
 {
     $member = Member::currentUser();
     if (!$member || !$member->inGroup("ADMIN")) {
         $form->setMessage("You need to be logged as an admin to send this email.", "bad");
         return Controller::curr()->redirectBack();
     }
     $data = Convert::raw2sql($data);
     $page = null;
     if (isset($data["ModuleProductID"])) {
         $page = ModuleProduct::get()->byID(intval($data["ModuleProductID"]));
     }
     if (!$page) {
         $form->setMessage("Can not find the right page for saving this email.", "bad");
         return Controller::curr()->redirectBack();
     }
     $email = new ModuleProductEmail();
     $form->saveInto($email);
     $email->write();
     if (Director::is_ajax()) {
         return "mail sent!";
     } else {
         return Controller::curr()->redirect($page->Link());
     }
 }
 /**
  * Display a wildcard in the back end
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['product_detail'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     // Set the item from the auto_item parameter
     if (!isset($_GET['items']) && $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item'])) {
         \Input::setGet('items', \Input::get('auto_item'));
     }
     $this->catalogs = $this->sortOutProtected(deserialize($this->catalogs));
     return parent::generate();
 }
Ejemplo n.º 3
0
 /**
  * Display a wildcard in the back end
  * @return string
  */
 public function generate()
 {
     if (TL_MODE == 'BE') {
         $objTemplate = new \BackendTemplate('be_wildcard');
         $objTemplate->wildcard = '### ' . utf8_strtoupper($GLOBALS['TL_LANG']['FMD']['product_list'][0]) . ' ###';
         $objTemplate->title = $this->headline;
         $objTemplate->id = $this->id;
         $objTemplate->link = $this->name;
         $objTemplate->href = 'contao/main.php?do=themes&table=tl_module&act=edit&id=' . $this->id;
         return $objTemplate->parse();
     }
     $this->catalogs = $this->sortOutProtected(deserialize($this->catalogs));
     // No catalog available
     if (!is_array($this->catalogs) || empty($this->catalogs)) {
         return '';
     }
     // Show the catalog detail if an item has been selected
     if ($this->product_detailModule > 0 && (isset($_GET['items']) || $GLOBALS['TL_CONFIG']['useAutoItem'] && isset($_GET['auto_item']))) {
         return $this->getFrontendModule($this->product_detailModule, $this->strColumn);
     }
     return parent::generate();
 }
 /**
  * Admin ONLY action
  * to view a list of all developers
  * that have not been contacted yet
  */
 function introemails()
 {
     $i = 0;
     $member = Member::currentUser();
     $dos = new ArrayList();
     if ($member && $member->inGroup("ADMIN")) {
         $modules = ModuleProduct::get()->filter(array("ShowInSearch" => 1, "ShowInMenus" => 1));
         foreach ($modules as $module) {
             if (!$module->HasEmail() && !$module->HasMemberContact()) {
                 $i++;
                 if ($i < 10) {
                     $dos->push($module);
                 } else {
                     break;
                 }
             }
         }
         return $this->customise(array("Products" => $dos));
     }
     Security::permissionFailure($this, "You need to log in as an Administrator.");
 }
 /**
  *
  * @return Object Product
  */
 function NextProduct()
 {
     return ModuleProduct::get()->where("\"Sort\" > " . $this->Sort . " AND ParentID = " . $this->ParentID)->sort("Sort", "ASC")->limit(1)->first();
 }
 /**
  * Allows validation of fields via specification of a php function for validation which is executed after
  * the form is submitted
  */
 function php($data)
 {
     $valid = true;
     if (isset($data["Code"])) {
         $type = Convert::raw2sql($data["Code"]);
         $extension = '';
         if (Versioned::current_stage() == "Live") {
             $extension = "_Live";
         }
         if (ModuleProduct::get()->filter(array("Code" => $type))->exclude("ModuleProduct", $this->currentID - 0)->count()) {
             $errorMessage = sprintf(_t('Form.CODEALREADYINUSE', "Your code %s is already in use - please check if your code is listed already or use an alternative code."), $type);
             $this->validationError($fieldName = "Code", $errorMessage, "required");
             $valid = false;
         }
     }
     if (!$valid) {
         return false;
     }
     return parent::php($data);
 }