public function __construct($id = null) { parent::__construct($id); if ($id < 1) { throw new Exception("Email template identified as {$id} does not exist."); } }
/** * Modifies registration form. * * If currently loaded form is registration form then this function does few things: * - removes Username field (field with name "user_login") * - moves password fields to the end of the form * - validates user_email field as a usersname (and email) to make sure this email * is not already being used as a username * * @since 1.0 * @param Daq_Form_ObjectAbstract $form * @return Daq_Form_ObjectAbstract */ function register_using_email_as_login($form) { if ($form->getId() > 0) { return $form; } if ($form->hasElement("user_login")) { $form->removeElement("user_login"); } if ($form->getGroup("auth") !== null) { $form->getGroup("auth")->setOrder(10000); } if ($form->hasElement("user_email")) { $form->getElement("user_email")->addValidator(new Daq_Validate_WP_Username()); } return $form; }
public function isValid($values) { if ($values["type"] == 1) { $inArr = array(); foreach ($this->_validatorArr() as $arr) { $inArr[] = $arr[0]; } $this->getElement("type")->addValidator(new Daq_Validate_InArray($inArr)); } if ($values["field_for"] == 2) { $this->getElement("type")->addOption(5, 5, ""); } $isValid = parent::isValid($values); if ($values["type"] == 4) { if (!isset($values['option']) || count($values['option']) < 1) { $this->getElement("type")->pushError(__("Field type of Dropdown has to have at least one option.", WPJB_DOMAIN)); return false; } foreach ($values['option'] as $option) { if (strlen(trim($option)) == 0) { $this->getElement("type")->pushError(__("One of options is empty", WPJB_DOMAIN)); return false; } } } return $isValid; }
public function save() { $file = $this->getElement("company_logo"); parent::save(); if ($file->fileSent()) { $file->setDestination(Wpjb_List_Path::getPath("company_logo")); $file->upload("logo_" . $this->getObject()->getId() . "." . $file->getExt()); } }
public function save() { $image = null; if ($this->hasElement("image")) { $image = $this->getElement("image"); } $file = null; if ($this->hasElement("file")) { $file = $this->getElement("file"); } $valueList = $this->getValues(); parent::save(); $this->_saveAdditionalFields($valueList); if ($image && $image->fileSent()) { $image->setDestination(Wpjb_List_Path::getPath("resume_photo")); $image->upload("photo_" . $this->getObject()->getId() . "." . $image->getExt()); } if ($file && $file->fileSent()) { $file->setDestination(Wpjb_List_Path::getPath("resume_photo")); $file->upload("file_" . $this->getObject()->getId() . "." . $file->getExt()); } apply_filters("wpja_form_save_resume", $this); $this->reinit(); }
public function _isValid($values) { if ($this->hasElement("resume_id") && is_numeric($values["resume_id"])) { $this->getElement("resume_id")->setValue($values["resume_id"]); $isValid = $this->getElement("resume_id")->validate(); } else { $isValid = parent::isValid($values); $e = __("You have to send CV file if you want to leave this field empty", WPJB_DOMAIN); if ($this->hasElement("cv_file") && $this->hasElement("cv_text")) { $file = $this->getElement("cv_file"); $text = $this->getElement("cv_text"); if (!$file->fileSent() && strlen(trim($text->getValue())) == 0) { $this->getElement("cv_text")->pushError($e); return false; } } } return $isValid; }
public function isValid($values) { if ($values["type"] == 1) { $this->getElement("discount")->addValidator(new Daq_Validate_Float(0, 100)); } return parent::isValid($values); }
/** * Adds registration fields to Wpjb_Form_Resume form. * * The form needs additional registration fields as by default it is not equipped * to handle user registration. * * Functiona is applied using wpjr_form_init_resume filter. * * @see wpjr_form_init_resume filter * * @since 1.0 * @param Daq_Form_ObjectAbstract $form * @return Daq_Form_ObjectAbstract */ function full_candidate_register_form_init($form) { if ($form->getId() > 0) { return $form; } $form->addGroup("auth", __("Account", "wpjobboard"), 0); $e = $form->create("_wpjb_action", "hidden"); $e->setValue("reg_candidate_alt"); $form->addElement($e, "_internal"); $e = $form->create("user_login"); $e->setOrder(1); $e->setLabel(__("Username", "wpjobboard")); $e->setRequired(true); $e->addFilter(new Daq_Filter_Trim()); $e->addFilter(new Daq_Filter_WP_SanitizeUser()); $e->addValidator(new Daq_Validate_WP_Username()); $form->addElement($e, "auth"); $e = $form->create("user_password", "password"); $e->setOrder(1.01); $e->setLabel(__("Password", "wpjobboard")); $e->addFilter(new Daq_Filter_Trim()); $e->addValidator(new Daq_Validate_StringLength(4, 32)); $e->addValidator(new Daq_Validate_PasswordEqual("user_password2")); $e->setRequired(true); $form->addElement($e, "auth"); $e = $form->create("user_password2", "password"); $e->setOrder(1.02); $e->setLabel(__("Password (repeat)", "wpjobboard")); $e->setRequired(true); $form->addElement($e, "auth"); return $form; }