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()); } }
/** * 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); }