Example #1
2
 /**
  * @abstract Displays and processes the edit news form
  * @param integer $id
  * @access public
  */
 public function edit($id = false)
 {
     if (!files()->setUploadDirectory()) {
         sml()->say("The file upload directory does not appear to be writable. Please create the folder and set proper permissions.");
     }
     $form = new Form('news', $id);
     if (!$id) {
         $form->setCurrentValue('timestamp', date("Y-m-d H:i:s"));
     }
     // if form has been submitted
     if ($form->isSubmitted()) {
         $file = files()->upload('pdf_filename');
         if (is_array($file) && !empty($file[0])) {
             $form->setCurrentValue('pdf_filename', $file[0]['file_name']);
         }
         if ($form->save($id)) {
             sml()->say('News entry has successfully been updated.');
             router()->redirect('view');
         }
     }
     // make sure the template has access to all current values
     $data['form'] = $form;
     template()->addCss('admin/datepicker.css');
     template()->addJs('admin/datepicker.js');
     template()->addJs('edit.js');
     template()->display($data);
 }
Example #2
0
 /**
  * Loads our index/default welcome/dashboard screen
  */
 public function view()
 {
     $form = new Form('config');
     // add all config variables to our form
     $sql = sprintf('SELECT * FROM config');
     $model = model()->open('config');
     $records = $model->results();
     if ($records) {
         foreach ($records as $record) {
             $value = $record['current_value'] == '' ? $record['default_value'] : $record['current_value'];
             $form->addField($record['config_key'], $value, $value);
         }
     }
     // process the form if submitted
     if ($form->isSubmitted()) {
         foreach (app()->params->getRawSource('post') as $field => $value) {
             $model->update(array('current_value' => $value), $field, 'config_key');
         }
         sml()->say('Website settings have been updated successfully.');
         router()->redirect('view');
     }
     $data['form'] = $form;
     $model = model()->open('pages');
     $model->where('page_is_live', 1);
     $data['pages'] = $model->results();
     //		$data['mods'] = app()->moduleControls();
     $data['themes'] = $this->listThemes();
     $data['live'] = settings()->getConfig('active_theme');
     template()->addCss('style.css');
     template()->addJs('admin/jquery.qtip.js');
     template()->addJs('view.js');
     template()->display($data);
 }
Example #3
0
 public function getRegisterForm($target = '/Vote/register')
 {
     $form = new Form('group_register', 'POST', $target, '', array('class' => 'admin'));
     $form->addElement('text', 'first_name', 'First Name');
     $form->addElement('text', 'last_name', 'Last Name');
     $form->addElement('text', 'company', 'Company/Group');
     $form->addElement('text', 'email', 'E-mail');
     $form->addElement('text', 'phone', 'Work Phone');
     $form->addElement('text', 'cell_phone', 'Cell Phone');
     $form->addElement('submit', 'register_submit', 'Submit');
     $form->addRule('first_name', 'Please enter your first name', 'required');
     $form->addRule('last_name', 'Please enter your last name', 'required');
     $form->addRule('company', 'Please enter your company/group', 'required');
     $form->addRule('email', 'Please enter your e-mail address', 'required');
     $form->addRule('email', 'Please enter a valid email address', 'email');
     $form->addRule('phone', 'Please enter your phone number', 'required');
     if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['register_submit'])) {
         $body = "New registration request: \n\n";
         $body .= "Name: " . $form->exportValue('last_name') . ', ' . $form->exportValue('first_name');
         $body .= "\nCompany/Group: " . $form->exportValue('company');
         $body .= "\nE-mail address: " . $form->exportValue('email');
         $body .= "\nPhone number(s): Work - " . $form->exportValue('phone') . ', Cell - ' . $form->exportValue('cell_phone');
         $body .= "\n\nRequest sent on " . date("w F jS \\a\\t g:ia");
         mail('*****@*****.**', 'Safeballot: New Request', $body, 'From: no-reply@safeballot.com');
     }
     return $form;
 }
Example #4
0
 /**
  * @abstract Displays and processes the edit news form
  * @param integer $id
  * @access public
  */
 public function edit($id = false)
 {
     $form = new Form('forms', $id);
     if ($form->isSubmitted()) {
         if ($form->save($id)) {
             sml()->say('Form has been updated successfully.');
             router()->redirect('view');
         }
     }
     $data['form'] = $form;
     template()->addJs('edit.js');
     template()->display($data);
 }
Example #5
0
 private function exampleForm()
 {
     $countries = array('Select your country', 'Europe' => array('CZ' => 'Czech Republic', 'FR' => 'France', 'DE' => 'Germany', 'GR' => 'Greece', 'HU' => 'Hungary', 'IE' => 'Ireland', 'IT' => 'Italy', 'NL' => 'Netherlands', 'PL' => 'Poland', 'SK' => 'Slovakia', 'ES' => 'Spain', 'CH' => 'Switzerland', 'UA' => 'Ukraine', 'GB' => 'United Kingdom'), 'AU' => 'Australia', 'CA' => 'Canada', 'EG' => 'Egypt', 'JP' => 'Japan', 'US' => 'United States', '?' => 'other');
     $sex = array('m' => 'male', 'f' => 'female');
     // Step 1: Define form with validation rules
     $form = new Form();
     // group Personal data
     $form->addGroup('Personal data')->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.');
     $form->addText('name', 'Your name:', 35)->addRule(Form::FILLED, 'Enter your name');
     $form->addText('age', 'Your age:', 5)->addRule(Form::FILLED, 'Enter your age')->addRule(Form::INTEGER, 'Age must be numeric value')->addRule(Form::RANGE, 'Age must be in range from %.2f to %.2f', array(9.9, 100));
     $form->addRadioList('gender', 'Your gender:', $sex);
     $form->addText('email', 'E-mail:', 35)->setEmptyValue('@')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Incorrect E-mail Address');
     // ... then check email
     // group Shipping address
     $form->addGroup('Shipping address')->setOption('embedNext', TRUE);
     $form->addCheckbox('send', 'Ship to address')->addCondition(Form::EQUAL, TRUE)->toggle('sendBox');
     // toggle div #sendBox
     // subgroup
     $form->addGroup()->setOption('container', Html::el('div')->id('sendBox'));
     $form->addText('street', 'Street:', 35);
     $form->addText('city', 'City:', 35)->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Enter your shipping address');
     $form->addSelect('country', 'Country:', $countries)->skipFirst()->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Select your country');
     // group Your account
     $form->addGroup('Your account');
     $form->addPassword('password', 'Choose password:'******'Choose your password')->addRule(Form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3);
     $form->addPassword('password2', 'Reenter password:'******'password'], Form::VALID)->addRule(Form::FILLED, 'Reenter your password')->addRule(Form::EQUAL, 'Passwords do not match', $form['password']);
     $form->addFile('avatar', 'Picture:')->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Uploaded file is not image', 'image/*');
     $form->addHidden('userid');
     $form->addTextArea('note', 'Comment:', 30, 5);
     // group for buttons
     $form->addGroup();
     $form->addSubmit('submit1', 'Send');
     // Step 2: Check if form was submitted?
     if ($form->isSubmitted()) {
         // Step 2c: Check if form is valid
         if ($form->isValid()) {
             echo '<h2>Form was submitted and successfully validated</h2>';
             $values = $form->getValues();
             Debug::dump($values);
             // this is the end, my friend :-)
             if (empty($disableExit)) {
                 exit;
             }
         }
     } else {
         // not submitted, define default values
         $defaults = array('name' => 'John Doe', 'userid' => 231, 'country' => 'CZ');
         $form->setDefaults($defaults);
     }
     return $form;
 }
Example #6
0
 /**
  * @abstract Edits an event recprd
  * @param integer $id
  * @access public
  */
 public function edit($id = false)
 {
     $form = new Form('courses', $id);
     // grab existing groups settings
     $model = model()->open('course_groups_link');
     $model->where('course_id', $id);
     $group_records = $model->results();
     $groups = array();
     if ($group_records) {
         foreach ($group_records as $course_record) {
             $groups[] = $course_record['group_id'];
         }
     }
     $form->addField('groups', $groups, $groups);
     // proces the form if submitted
     if ($form->isSubmitted()) {
         // validation
         if (!$form->isFilled('title')) {
             $form->addError('title', 'You must enter a course title.');
         }
         // if we have no errors, process sql
         if (!$form->error()) {
             if ($res_id = $form->save($id)) {
                 $id = $id ? $id : $res_id;
                 // update course groups
                 $model->delete('course_groups_link', $id, 'course_id');
                 $groups = $form->cv('groups');
                 foreach ($groups as $group) {
                     $sql = sprintf('INSERT INTO course_groups_link (course_id, group_id) VALUES ("%s", "%s")', $id, $group);
                     $model->query($sql);
                 }
                 // if successful insert, redirect to the list
                 sml()->say('The course has successfully been saved.');
                 router()->redirect('view');
             }
         }
     }
     $data['form'] = $form;
     template()->addView(template()->getTemplateDir() . DS . 'header.tpl.php');
     template()->addView(template()->getModuleTemplateDir() . DS . 'edit.tpl.php');
     template()->addView(template()->getTemplateDir() . DS . 'footer.tpl.php');
     template()->display($data);
 }
Example #7
0
 /**
  * @abstract Add a new page
  * @access public
  */
 public function add()
 {
     $form = new Form('pages');
     // process the form if submitted
     if ($form->isSubmitted()) {
         $form->setCurrentValue('page_sort_order', $model->quickValue('SELECT MAX(page_sort_order) FROM pages', 'MAX(page_sort_order)') + 1);
         // form field validation
         if (!$form->isFilled('page_title')) {
             $form->addError('page_title', 'You must enter a page title.');
         }
         // if we have no errors, save the record
         if (!$form->error()) {
             // set the link text field to the page title if blank
             if (!$form->isFilled('page_link_text')) {
                 $form->setCurrentValue('page_link_text', $form->cv('page_title'));
             }
             return $form->save();
         }
     }
     return false;
 }
Example #8
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartTaxRate_addedit', 'post', $target);
     $form->setConstants(array('section' => 'tax_rates'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('carttaxrate_tax_rates_id' => $this->getId()));
         $form->addElement('hidden', 'carttaxrate_tax_rates_id');
         $defaultValues['carttaxrate_zone'] = $this->getZone();
         $defaultValues['carttaxrate_taxClass'] = $this->getTaxClass()->getId();
         //$defaultValues ['carttaxrate_tax_priority'] = $this->getTax_priority();
         $defaultValues['carttaxrate_rate'] = $this->getRate();
         $defaultValues['carttaxrate_description'] = $this->getDescription();
         //$defaultValues ['carttaxrate_last_modified'] = $this->getLast_modified();
         //$defaultValues ['carttaxrate_date_added'] = $this->getDate_added();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('select', 'carttaxrate_zone', 'Zone', Form::getStatesArray());
     $form->addElement('select', 'carttaxrate_taxClass', 'Tax Class', CartTaxClass::toArray());
     //$form->addElement('text', 'carttaxrate_tax_priority', 'tax_priority');
     $form->addElement('text', 'carttaxrate_rate', 'Tax Rate (%)');
     $form->addElement('text', 'carttaxrate_description', 'Description');
     //$form->addElement('text', 'carttaxrate_last_modified', 'last_modified');
     //$form->addElement('text', 'carttaxrate_date_added', 'date_added');
     $form->addElement('submit', 'carttaxrate_submit', 'Submit');
     $form->addRule('carttaxrate_rate', 'Please enter a Tax Rate', 'required', null);
     $form->addRule('carttaxrate_description', 'Please enter a Description', 'required', null);
     if ($form->validate() && $form->isSubmitted()) {
         $this->setZone($form->exportValue('carttaxrate_zone'));
         $this->setTaxClass($form->exportValue('carttaxrate_taxClass'));
         //$this->setTax_priority($form->exportValue('carttaxrate_tax_priority'));
         $this->setRate($form->exportValue('carttaxrate_rate'));
         $this->setDescription($form->exportValue('carttaxrate_description'));
         //$this->setLast_modified($form->exportValue('carttaxrate_last_modified'));
         //$this->setDate_added($form->exportValue('carttaxrate_date_added'));
         $this->save();
     }
     return $form;
 }
Example #9
0
 public static function getCSVForm($target = '/admin/Campaigns&section=recipcsvup')
 {
     $form = new Form('csv_add', 'POST', $target, '', array('class' => 'admin'));
     $form->addElement('file', 'csv_file', 'CSV File');
     $form->addElement('submit', 'submit', 'Upload');
     $form->addRule('csv_file', 'Please upload a csv file', 'uploaded');
     if ($form->validate() && $form->isSubmitted() && $_POST['submit']) {
         Campaign::parseCsv($_FILES['csv_file']['tmp_name']);
     }
     return $form;
 }
Example #10
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     //Only the name will be displayed to the administrator
     //All the other attributes are not valid for feedstore.ca
     $form = new Form('CartProductType_addedit', 'post', $target);
     $form->setConstants(array('section' => 'product_types'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartproducttype_type_id' => $this->getId()));
         $form->addElement('hidden', 'cartproducttype_type_id');
         $defaultValues['cartproducttype_name'] = $this->getName();
         /*
         $defaultValues ['cartproducttype_handler'] = $this->getHandler();
         $defaultValues ['cartproducttype_masterType'] = $this->getMasterType();
         $defaultValues ['cartproducttype_allow_add_to_cart'] = $this->getAllow_add_to_cart();
         $defaultValues ['cartproducttype_image'] = $this->getImage()->getId();
         $defaultValues ['cartproducttype_date_added'] = $this->getDate_added();
         $defaultValues ['cartproducttype_last_modified'] = $this->getLast_modified();
         */
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartproducttype_name', 'name');
     /*
     $form->addElement('text', 'cartproducttype_handler', 'handler');
     $form->addElement('text', 'cartproducttype_masterType', 'masterType');
     $form->addElement('text', 'cartproducttype_allow_add_to_cart', 'allow_add_to_cart');
     $form->addElement('text', 'cartproducttype_image', 'image');
     $form->addElement('text', 'cartproducttype_date_added', 'date_added');
     $form->addElement('text', 'cartproducttype_last_modified', 'last_modified');
     */
     $form->addElement('submit', 'cartproducttype_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setName($form->exportValue('cartproducttype_name'));
         /*
         $this->setHandler($form->exportValue('cartproducttype_handler'));
         $this->setMasterType($form->exportValue('cartproducttype_masterType'));
         $this->setAllow_add_to_cart($form->exportValue('cartproducttype_allow_add_to_cart'));
         $this->setImage($form->exportValue('cartproducttype_image'));
         $this->setDate_added($form->exportValue('cartproducttype_date_added'));
         $this->setLast_modified($form->exportValue('cartproducttype_last_modified'));
         */
         $this->save();
     }
     return $form;
 }
Example #11
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartShippingRate_addedit', 'post', $target);
     $form->setConstants(array('section' => 'shipping'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartshippingrate_id' => $this->getId()));
         $form->addElement('hidden', 'cartshippingrate_id');
         $defaultValues['cartshippingrate_state'] = $this->getState();
         $defaultValues['cartshippingrate_country'] = $this->getCountry();
         $defaultValues['cartshippingrate_cost'] = $this->getCost();
         $form->setDefaults($defaultValues);
     }
     $countrySelect = array('onchange' => 'selectCountry();', 'id' => 'cartshippingrate_country');
     $form->addElement('select', 'cartshippingrate_country', 'Country', Form::getCountryArray(), $countrySelect);
     $form->addElement('select', 'cartshippingrate_state', 'Province/State', Form::getStatesArray("Canada"));
     $form->addElement('text', 'cartshippingrate_cost', 'Shipping Cost');
     $form->addElement('submit', 'cartshippingrate_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $selectedCountry = $form->exportValue('cartshippingrate_country');
         //Only if the selected country is Canada, insert the selected state.
         if (CartShippingRate::hasState($selectedCountry)) {
             $selectedState = $form->exportValue('cartshippingrate_state');
         } else {
             $selectedState = 0;
         }
         $this->setCountry($selectedCountry);
         $this->setState($selectedState);
         $this->setCost($form->exportValue('cartshippingrate_cost'));
         $this->save();
     }
     return $form;
 }
Example #12
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/CartOrderProduct')
 {
     $form = new Form('CartOrderProduct_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartorderproduct_orders_products_id' => $this->getId()));
         $form->addElement('hidden', 'cartorderproduct_orders_products_id');
         $defaultValues['cartorderproduct_orderId'] = $this->getOrderId();
         $defaultValues['cartorderproduct_product'] = $this->getProduct()->getId();
         $defaultValues['cartorderproduct_model'] = $this->getModel();
         $defaultValues['cartorderproduct_name'] = $this->getName();
         $defaultValues['cartorderproduct_price'] = $this->getPrice();
         $defaultValues['cartorderproduct_finalPrice'] = $this->getFinalPrice();
         $defaultValues['cartorderproduct_tax'] = $this->getTax();
         $defaultValues['cartorderproduct_quantity'] = $this->getQuantity();
         $defaultValues['cartorderproduct_oneTimeCharges'] = $this->getOneTimeCharges();
         $defaultValues['cartorderproduct_pricedByAttribute'] = $this->getPricedByAttribute();
         $defaultValues['cartorderproduct_isFree'] = $this->getIsFree();
         $defaultValues['cartorderproduct_discountType'] = $this->getDiscountType();
         $defaultValues['cartorderproduct_discountTypeFrom'] = $this->getDiscountTypeFrom();
         $defaultValues['cartorderproduct_prid'] = $this->getPrid();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartorderproduct_orderId', 'orderId');
     $form->addElement('text', 'cartorderproduct_product', 'product');
     $form->addElement('text', 'cartorderproduct_model', 'model');
     $form->addElement('text', 'cartorderproduct_name', 'name');
     $form->addElement('text', 'cartorderproduct_price', 'price');
     $form->addElement('text', 'cartorderproduct_finalPrice', 'finalPrice');
     $form->addElement('text', 'cartorderproduct_tax', 'tax');
     $form->addElement('text', 'cartorderproduct_quantity', 'quantity');
     $form->addElement('text', 'cartorderproduct_oneTimeCharges', 'oneTimeCharges');
     $form->addElement('text', 'cartorderproduct_pricedByAttribute', 'pricedByAttribute');
     $form->addElement('text', 'cartorderproduct_isFree', 'isFree');
     $form->addElement('text', 'cartorderproduct_discountType', 'discountType');
     $form->addElement('text', 'cartorderproduct_discountTypeFrom', 'discountTypeFrom');
     $form->addElement('text', 'cartorderproduct_prid', 'prid');
     $form->addElement('submit', 'cartorderproduct_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setOrderId($form->exportValue('cartorderproduct_orderId'));
         $this->setProduct($form->exportValue('cartorderproduct_product'));
         $this->setModel($form->exportValue('cartorderproduct_model'));
         $this->setName($form->exportValue('cartorderproduct_name'));
         $this->setPrice($form->exportValue('cartorderproduct_price'));
         $this->setFinalPrice($form->exportValue('cartorderproduct_finalPrice'));
         $this->setTax($form->exportValue('cartorderproduct_tax'));
         $this->setQuantity($form->exportValue('cartorderproduct_quantity'));
         $this->setOneTimeCharges($form->exportValue('cartorderproduct_oneTimeCharges'));
         $this->setPricedByAttribute($form->exportValue('cartorderproduct_pricedByAttribute'));
         $this->setIsFree($form->exportValue('cartorderproduct_isFree'));
         $this->setDiscountType($form->exportValue('cartorderproduct_discountType'));
         $this->setDiscountTypeFrom($form->exportValue('cartorderproduct_discountTypeFrom'));
         $this->setPrid($form->exportValue('cartorderproduct_prid'));
         $this->save();
     }
     return $form;
 }
Example #13
0
Debug::enable();
$countries = array('Select your country', 'Europe' => array('CZ' => 'Česká republika', 'SK' => 'Slovakia'), 'AU' => 'Australia', 'CA' => 'Canada', 'EG' => 'Egypt', 'JP' => 'Japan', 'US' => 'United States', '?' => 'other');
// Step 1: Define form with validation rules
$form = new Form();
$form->encoding = 'ISO-8859-1';
// group Personal data
$form->addGroup('Personal data');
$form->addText('name', 'Your name:', 35);
$form->addMultiSelect('country', 'Country:')->skipFirst()->setItems($countries, FALSE);
$form->addHidden('userid');
$form->addTextArea('note', 'Comment:', 30, 5);
// group for buttons
$form->addGroup();
$form->addSubmit('submit1', 'Send');
// Step 2: Check if form was submitted?
if ($form->isSubmitted()) {
    // Step 2c: Check if form is valid
    if ($form->isValid()) {
        header('Content-type: text/html; charset=utf-8');
        echo '<h2>Form was submitted and successfully validated</h2>';
        $values = $form->getValues();
        Debug::dump($values);
        // this is the end, my friend :-)
        if (empty($disableExit)) {
            exit;
        }
    }
} else {
    // not submitted, define default values
    $defaults = array('name' => 'Žluťoučký kůň', 'userid' => 'kůň', 'note' => 'жед', 'country' => 'Česká republika');
    $form->setDefaults($defaults);
Example #14
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/InstantMessage')
 {
     $form = new Form('InstantMessage_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->id)) {
         $form->setConstants(array('instantmessage_id' => $this->getId()));
         $form->addElement('hidden', 'instantmessage_id');
         $defaultValues['instantmessage_from'] = $this->getFrom()->getId();
         $defaultValues['instantmessage_to'] = $this->getTo()->getId();
         $defaultValues['instantmessage_namespace'] = $this->getNamespace();
         $defaultValues['instantmessage_thread'] = $this->getThread();
         $defaultValues['instantmessage_message'] = $this->getMessage();
         $defaultValues['instantmessage_read'] = $this->getRead();
         $defaultValues['instantmessage_timestamp'] = $this->getTimestamp();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'instantmessage_from', 'from /* Fill in text */');
     $form->addElement('text', 'instantmessage_to', 'to /* Fill in text */');
     $form->addElement('text', 'instantmessage_namespace', 'namespace /* Fill in text */');
     $form->addElement('text', 'instantmessage_thread', 'thread /* Fill in text */');
     $form->addElement('text', 'instantmessage_message', 'message /* Fill in text */');
     $form->addElement('text', 'instantmessage_read', 'read /* Fill in text */');
     $form->addElement('text', 'instantmessage_timestamp', 'timestamp /* Fill in text */');
     $form->addElement('submit', 'instantmessage_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setFrom($form->exportValue('instantmessage_from'));
         $this->setTo($form->exportValue('instantmessage_to'));
         $this->setNamespace($form->exportValue('instantmessage_namespace'));
         $this->setThread($form->exportValue('instantmessage_thread'));
         $this->setMessage($form->exportValue('instantmessage_message'));
         $this->setRead($form->exportValue('instantmessage_read'));
         $this->setTimestamp($form->exportValue('instantmessage_timestamp'));
         $this->save();
     }
     return $form;
 }
Example #15
0
 /**
  * Displays and processes the forgotten password system
  * @access public
  */
 public function forgot()
 {
     $form = new Form();
     $form->addFields(array('user'));
     // process the form if submitted
     if ($form->isSubmitted()) {
         // generate a new password
         $new_pass = $this->makePassword();
         // load the account
         $auth = model()->open('users');
         $user = $auth->quickSelectSingle($form->cv('user'), 'username');
         if (is_array($user)) {
             // update the account
             $user['password'] = $user['password_confirm'] = $new_pass;
             $auth->update($user, $user['id']);
             if (app()->db->Affected_Rows()) {
                 app()->mail->AddAddress($form->cv('user'));
                 app()->mail->From = app()->config('email_sender');
                 app()->mail->FromName = app()->config('email_sender_name');
                 app()->mail->Mailer = "mail";
                 app()->mail->ContentType = 'text/html';
                 app()->mail->Subject = app()->config('password_reset_subject');
                 app()->mail->Body = str_replace('{new_pass}', $new_pass, app()->config('password_reset_body'));
                 app()->mail->Send();
                 app()->mail->ClearAddresses();
                 return 1;
             }
         } else {
             return -1;
         }
     }
     template()->set(array('form' => $form));
     return false;
 }
Example #16
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/CartProductOptionValue')
 {
     $form = new Form('CartProductOptionValue_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->get())) {
         $form->setConstants(array('cartproductoptionvalue_id' => $this->getId()));
         $form->addElement('hidden', 'cartproductoptionvalue_id');
         $defaultValues['cartproductoptionvalue_language_id'] = $this->getLanguage_id();
         $defaultValues['cartproductoptionvalue_name'] = $this->getName();
         $defaultValues['cartproductoptionvalue_sort'] = $this->getSort();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartproductoptionvalue_id', 'id');
     $form->addElement('text', 'cartproductoptionvalue_name', 'name');
     $form->addElement('text', 'cartproductoptionvalue_sort', 'sort');
     $form->addElement('submit', 'cartproductoptionvalue_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setLanguage_id($form->exportValue('cartproductoptionvalue_language_id'));
         $this->setName($form->exportValue('cartproductoptionvalue_name'));
         $this->setSort($form->exportValue('cartproductoptionvalue_sort'));
         $this->save();
     }
     return $form;
 }
Example #17
0
 /**
  * @param $bot Bot
  * @throws Exception
  * @return Form
  */
 private function _createQueueForm($bot)
 {
     $form = new Form('queue');
     if ($this->args('setup')) {
         $form->action = $bot->getUrl() . "/edit/setup";
     } else {
         $form->action = $bot->getUrl() . "/edit";
     }
     $form->add(DisplayField::name('title')->label('')->value('<h2>Queues</h2>'));
     $queueCount = 1;
     $allQueues = User::$me->getQueues()->getAll();
     $allQueueList = array(0 => '');
     foreach ($allQueues as $row) {
         /* @var $q Queue */
         $q = $row['Queue'];
         $allQueueList[$q->id] = $q->getName();
     }
     if ($form->isSubmitted($this->args())) {
         $used = array();
         foreach ($this->args() as $key => $value) {
             if (substr($key, 0, 6) === "queue-") {
                 if (!array_key_exists($value, $allQueueList)) {
                     throw new Exception("That is not your queue!");
                 }
                 if (in_array($value, $used)) {
                     continue;
                 } else {
                     $used[] = $value;
                 }
                 $form->add(SelectField::name($key)->id($key)->label('')->value($value)->options($allQueueList)->onchange('update_queues(this)'));
             }
         }
     } else {
         $queues = $bot->getQueues()->getAll();
         foreach ($queues as $row) {
             /** @var Queue $queue */
             $queue = $row['Queue'];
             $form->add(SelectField::name('queue-' . $queueCount)->id('queue-' . $queueCount)->label('')->value($queue->id)->options($allQueueList)->onchange('update_queues(this)'));
             $queueCount++;
         }
         $form->add(SelectField::name('queue-' . $queueCount)->id('queue-' . $queueCount)->label('')->value(0)->options($allQueueList)->onchange('update_queues(this)'));
     }
     return $form;
 }
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/CartOrderProductAttribute')
 {
     $form = new Form('CartOrderProductAttribute_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartorderproductattribute_orders_products_attributes_id' => $this->getId()));
         $form->addElement('hidden', 'cartorderproductattribute_orders_products_attributes_id');
         $defaultValues['cartorderproductattribute_orderid'] = $this->getOrderid();
         $defaultValues['cartorderproductattribute_productid'] = $this->getProductid();
         $defaultValues['cartorderproductattribute_products_options'] = $this->getProducts_options();
         $defaultValues['cartorderproductattribute_products_options_values'] = $this->getProducts_options_values();
         $defaultValues['cartorderproductattribute_options_values_price'] = $this->getOptions_values_price();
         $defaultValues['cartorderproductattribute_price_prefix'] = $this->getPrice_prefix();
         $defaultValues['cartorderproductattribute_product_attribute_is_free'] = $this->getProduct_attribute_is_free();
         $defaultValues['cartorderproductattribute_products_attributes_weight'] = $this->getProducts_attributes_weight();
         $defaultValues['cartorderproductattribute_products_attributes_weight_prefix'] = $this->getProducts_attributes_weight_prefix();
         $defaultValues['cartorderproductattribute_attributes_discounted'] = $this->getAttributes_discounted();
         $defaultValues['cartorderproductattribute_attributes_price_base_included'] = $this->getAttributes_price_base_included();
         $defaultValues['cartorderproductattribute_attributes_price_onetime'] = $this->getAttributes_price_onetime();
         $defaultValues['cartorderproductattribute_attributes_price_factor'] = $this->getAttributes_price_factor();
         $defaultValues['cartorderproductattribute_attributes_price_factor_offset'] = $this->getAttributes_price_factor_offset();
         $defaultValues['cartorderproductattribute_attributes_price_factor_onetime'] = $this->getAttributes_price_factor_onetime();
         $defaultValues['cartorderproductattribute_attributes_price_factor_onetime_offset'] = $this->getAttributes_price_factor_onetime_offset();
         $defaultValues['cartorderproductattribute_attributes_qty_prices'] = $this->getAttributes_qty_prices();
         $defaultValues['cartorderproductattribute_attributes_qty_prices_onetime'] = $this->getAttributes_qty_prices_onetime();
         $defaultValues['cartorderproductattribute_attributes_price_words'] = $this->getAttributes_price_words();
         $defaultValues['cartorderproductattribute_attributes_price_words_free'] = $this->getAttributes_price_words_free();
         $defaultValues['cartorderproductattribute_attributes_price_letters'] = $this->getAttributes_price_letters();
         $defaultValues['cartorderproductattribute_attributes_price_letters_free'] = $this->getAttributes_price_letters_free();
         $defaultValues['cartorderproductattribute_products_options_id'] = $this->getProducts_options_id();
         $defaultValues['cartorderproductattribute_products_options_values_id'] = $this->getProducts_options_values_id();
         $defaultValues['cartorderproductattribute_products_prid'] = $this->getProducts_prid();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartorderproductattribute_orderid', 'orderid');
     $form->addElement('text', 'cartorderproductattribute_productid', 'productid');
     $form->addElement('text', 'cartorderproductattribute_products_options', 'products_options');
     $form->addElement('text', 'cartorderproductattribute_products_options_values', 'products_options_values');
     $form->addElement('text', 'cartorderproductattribute_options_values_price', 'options_values_price');
     $form->addElement('text', 'cartorderproductattribute_price_prefix', 'price_prefix');
     $form->addElement('text', 'cartorderproductattribute_product_attribute_is_free', 'product_attribute_is_free');
     $form->addElement('text', 'cartorderproductattribute_products_attributes_weight', 'products_attributes_weight');
     $form->addElement('text', 'cartorderproductattribute_products_attributes_weight_prefix', 'products_attributes_weight_prefix');
     $form->addElement('text', 'cartorderproductattribute_attributes_discounted', 'attributes_discounted');
     $form->addElement('text', 'cartorderproductattribute_attributes_price_base_included', 'attributes_price_base_included');
     $form->addElement('text', 'cartorderproductattribute_attributes_price_onetime', 'attributes_price_onetime');
     $form->addElement('text', 'cartorderproductattribute_attributes_price_factor', 'attributes_price_factor');
     $form->addElement('text', 'cartorderproductattribute_attributes_price_factor_offset', 'attributes_price_factor_offset');
     $form->addElement('text', 'cartorderproductattribute_attributes_price_factor_onetime', 'attributes_price_factor_onetime');
     $form->addElement('text', 'cartorderproductattribute_attributes_price_factor_onetime_offset', 'attributes_price_factor_onetime_offset');
     $form->addElement('text', 'cartorderproductattribute_attributes_qty_prices', 'attributes_qty_prices');
     $form->addElement('text', 'cartorderproductattribute_attributes_qty_prices_onetime', 'attributes_qty_prices_onetime');
     $form->addElement('text', 'cartorderproductattribute_attributes_price_words', 'attributes_price_words');
     $form->addElement('text', 'cartorderproductattribute_attributes_price_words_free', 'attributes_price_words_free');
     $form->addElement('text', 'cartorderproductattribute_attributes_price_letters', 'attributes_price_letters');
     $form->addElement('text', 'cartorderproductattribute_attributes_price_letters_free', 'attributes_price_letters_free');
     $form->addElement('text', 'cartorderproductattribute_products_options_id', 'products_options_id');
     $form->addElement('text', 'cartorderproductattribute_products_options_values_id', 'products_options_values_id');
     $form->addElement('text', 'cartorderproductattribute_products_prid', 'products_prid');
     $form->addElement('submit', 'cartorderproductattribute_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setOrderid($form->exportValue('cartorderproductattribute_orderid'));
         $this->setProductid($form->exportValue('cartorderproductattribute_productid'));
         $this->setProducts_options($form->exportValue('cartorderproductattribute_products_options'));
         $this->setProducts_options_values($form->exportValue('cartorderproductattribute_products_options_values'));
         $this->setOptions_values_price($form->exportValue('cartorderproductattribute_options_values_price'));
         $this->setPrice_prefix($form->exportValue('cartorderproductattribute_price_prefix'));
         $this->setProduct_attribute_is_free($form->exportValue('cartorderproductattribute_product_attribute_is_free'));
         $this->setProducts_attributes_weight($form->exportValue('cartorderproductattribute_products_attributes_weight'));
         $this->setProducts_attributes_weight_prefix($form->exportValue('cartorderproductattribute_products_attributes_weight_prefix'));
         $this->setAttributes_discounted($form->exportValue('cartorderproductattribute_attributes_discounted'));
         $this->setAttributes_price_base_included($form->exportValue('cartorderproductattribute_attributes_price_base_included'));
         $this->setAttributes_price_onetime($form->exportValue('cartorderproductattribute_attributes_price_onetime'));
         $this->setAttributes_price_factor($form->exportValue('cartorderproductattribute_attributes_price_factor'));
         $this->setAttributes_price_factor_offset($form->exportValue('cartorderproductattribute_attributes_price_factor_offset'));
         $this->setAttributes_price_factor_onetime($form->exportValue('cartorderproductattribute_attributes_price_factor_onetime'));
         $this->setAttributes_price_factor_onetime_offset($form->exportValue('cartorderproductattribute_attributes_price_factor_onetime_offset'));
         $this->setAttributes_qty_prices($form->exportValue('cartorderproductattribute_attributes_qty_prices'));
         $this->setAttributes_qty_prices_onetime($form->exportValue('cartorderproductattribute_attributes_qty_prices_onetime'));
         $this->setAttributes_price_words($form->exportValue('cartorderproductattribute_attributes_price_words'));
         $this->setAttributes_price_words_free($form->exportValue('cartorderproductattribute_attributes_price_words_free'));
         $this->setAttributes_price_letters($form->exportValue('cartorderproductattribute_attributes_price_letters'));
         $this->setAttributes_price_letters_free($form->exportValue('cartorderproductattribute_attributes_price_letters_free'));
         $this->setProducts_options_id($form->exportValue('cartorderproductattribute_products_options_id'));
         $this->setProducts_options_values_id($form->exportValue('cartorderproductattribute_products_options_values_id'));
         $this->setProducts_prid($form->exportValue('cartorderproductattribute_products_prid'));
         $this->save();
     }
     return $form;
 }
Example #19
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/CartSpecial')
 {
     $form = new Form('CartSpecial_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartspecial_specials_id' => $this->getId()));
         $form->addElement('hidden', 'cartspecial_specials_id');
         $defaultValues['cartspecial_product'] = $this->getProduct();
         $defaultValues['cartspecial_new_products_price'] = $this->getNew_products_price();
         $defaultValues['cartspecial_date_added'] = $this->getDate_added();
         $defaultValues['cartspecial_last_modified'] = $this->getLast_modified();
         $defaultValues['cartspecial_expires_date'] = $this->getExpires_date();
         $defaultValues['cartspecial_date_status_change'] = $this->getDate_status_change();
         $defaultValues['cartspecial_status'] = $this->getStatus();
         $defaultValues['cartspecial_date_available'] = $this->getDate_available();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartspecial_product', 'product');
     $form->addElement('text', 'cartspecial_new_products_price', 'new_products_price');
     $form->addElement('text', 'cartspecial_date_added', 'date_added');
     $form->addElement('text', 'cartspecial_last_modified', 'last_modified');
     $form->addElement('text', 'cartspecial_expires_date', 'expires_date');
     $form->addElement('text', 'cartspecial_date_status_change', 'date_status_change');
     $form->addElement('text', 'cartspecial_status', 'status');
     $form->addElement('text', 'cartspecial_date_available', 'date_available');
     $form->addElement('submit', 'cartspecial_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setProduct($form->exportValue('cartspecial_product'));
         $this->setNew_products_price($form->exportValue('cartspecial_new_products_price'));
         $this->setDate_added($form->exportValue('cartspecial_date_added'));
         $this->setLast_modified($form->exportValue('cartspecial_last_modified'));
         $this->setExpires_date($form->exportValue('cartspecial_expires_date'));
         $this->setDate_status_change($form->exportValue('cartspecial_date_status_change'));
         $this->setStatus($form->exportValue('cartspecial_status'));
         $this->setDate_available($form->exportValue('cartspecial_date_available'));
         $this->save();
     }
     return $form;
 }
Example #20
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Mail')
 {
     $form = new Form('MailContent_addedit', 'post', $target);
     $form->setConstants(array('section' => 'content'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('mailcontent_mail_id' => $this->getId()));
         $form->addElement('hidden', 'mailcontent_mail_id');
         $defaultValues['mailcontent_subject'] = $this->getSubject();
         $defaultValues['mailcontent_content'] = $this->getContent();
         //$defaultValues ['mailcontent_lastMod'] = $this->getLastMod();
         $defaultValues['mailcontent_fromName'] = $this->getFromName();
         $defaultValues['mailcontent_fromAddress'] = $this->getFromAddress();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'mailcontent_subject', 'Mail Subject Line');
     $form->addElement('text', 'mailcontent_fromName', 'From Name');
     $form->addElement('text', 'mailcontent_fromAddress', 'From Address');
     $form->addElement('tinymce', 'mailcontent_content', 'Mail Content', array('style' => 'width: 100px;'));
     //$form->addElement('text', 'mailcontent_lastMod', 'Last Modified');
     $form->addElement('submit', 'mailcontent_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setSubject($form->exportValue('mailcontent_subject'));
         $this->setContent($form->exportValue('mailcontent_content'));
         //$this->setLastMod($form->exportValue('mailcontent_lastMod'));
         $this->setFromName($form->exportValue('mailcontent_fromName'));
         $this->setFromAddress($form->exportValue('mailcontent_fromAddress'));
         $this->save();
     }
     return $form;
 }
Example #21
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartProductOption_addedit', 'post', $target);
     $form->setConstants(array('section' => 'attributes'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartproductoption_id' => $this->getId()));
         $form->addElement('hidden', 'cartproductoption_id');
         $defaultValues['cartproductoption_language_id'] = $this->getLanguageId();
         $defaultValues['cartproductoption_name'] = $this->getName();
         $defaultValues['cartproductoption_sort'] = $this->getSort();
         $defaultValues['cartproductoption_type'] = $this->getType();
         $defaultValues['cartproductoption_length'] = $this->getLength();
         $defaultValues['cartproductoption_comment'] = $this->getComment();
         $defaultValues['cartproductoption_size'] = $this->getSize();
         $defaultValues['cartproductoption_imagesPerRow'] = $this->getImagesPerRow();
         $defaultValues['cartproductoption_imagesStyle'] = $this->getImagesStyle();
         $defaultValues['cartproductoption_rows'] = $this->getRows();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartproductoption_name', 'Name');
     $form->addElement('text', 'cartproductoption_comment', 'Comment');
     $form->addElement('submit', 'cartproductoption_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['cartproductoption_submit'])) {
         $this->setName($form->exportValue('cartproductoption_name'));
         $this->setComment($form->exportValue('cartproductoption_comment'));
         $this->save();
     }
     return $form;
 }
Example #22
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/MailQueue')
 {
     $form = new Form('MailQueue_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->getId())) {
         $form->setConstants(array('mailqueue_id' => $this->getId()));
         $form->addElement('hidden', 'mailqueue_id');
         $defaultValues['mailqueue_sendOut'] = $this->getSendOut();
         $defaultValues['mailqueue_user'] = $this->getUser();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'mailqueue_sendOut', 'sendOut');
     $form->addElement('text', 'mailqueue_user', 'user');
     $form->addElement('submit', 'mailqueue_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setSendOut($form->exportValue('mailqueue_sendOut'));
         $this->setUser($form->exportValue('mailqueue_user'));
         $this->save();
     }
     return $form;
 }
Example #23
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Mail')
 {
     $form = new Form('MailUser_addedit', 'post', $target);
     $form->setConstants(array('section' => 'users'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('mailuser_id' => $this->getId()));
         $form->addElement('hidden', 'mailuser_id');
         $defaultValues['mailuser_email'] = $this->getEmail();
         $defaultValues['mailuser_firstName'] = $this->getFirstName();
         $defaultValues['mailuser_lastName'] = $this->getLastName();
         $defaultValues['mailuser_notes'] = $this->getNotes();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'mailuser_email', 'E-Mail Address');
     $form->addElement('text', 'mailuser_firstName', 'First Name');
     $form->addElement('text', 'mailuser_lastName', 'Last Name');
     $form->addElement('tinymce', 'mailuser_notes', 'Notes');
     $form->addElement('submit', 'mailuser_submit', 'Save');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setEmail($form->exportValue('mailuser_email'));
         $this->setFirstName($form->exportValue('mailuser_firstName'));
         $this->setLastName($form->exportValue('mailuser_lastName'));
         $this->setNotes($form->exportValue('mailuser_notes'));
         $this->save();
     }
     return $form;
 }
Example #24
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartTaxClass_addedit', 'post', $target);
     $form->setConstants(array('section' => 'tax_classes'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('carttaxclass_tax_class_id' => $this->getId()));
         $form->addElement('hidden', 'carttaxclass_tax_class_id');
         $defaultValues['carttaxclass_title'] = $this->getTitle();
         $defaultValues['carttaxclass_description'] = $this->getDescription();
         $defaultValues['carttaxclass_last_modified'] = $this->getLast_modified();
         $defaultValues['carttaxclass_date_added'] = $this->getDate_added();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'carttaxclass_title', 'Title');
     $text = $form->addElement('textarea', 'carttaxclass_description', 'Description');
     $text->setCols(60);
     $text->setRows(10);
     $form->addElement('text', 'carttaxclass_last_modified', 'Last Modified');
     $form->addElement('text', 'carttaxclass_date_added', 'Date Added');
     $form->addElement('submit', 'carttaxclass_submit', 'Submit');
     $form->addRule('carttaxclass_title', 'Please enter a Title', 'required', null);
     $form->addRule('carttaxclass_description', 'Please enter a Description', 'required', null);
     if ($form->validate() && $form->isSubmitted()) {
         $this->setTitle($form->exportValue('carttaxclass_title'));
         $this->setDescription($form->exportValue('carttaxclass_description'));
         $this->setLast_modified($form->exportValue('carttaxclass_last_modified'));
         $this->setDate_added($form->exportValue('carttaxclass_date_added'));
         $this->save();
     }
     return $form;
 }
Example #25
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Analytics')
 {
     $form = new Form('analytics_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->getId())) {
         $form->setConstants(array('analytics_id' => $this->getId()));
         $form->addElement('hidden', 'analytics_id');
         $defaultValues['analytics_content'] = $this->getContent();
         $defaultValues['analytics_timestamp'] = $this->getTimestamp();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('html', '<br /><span style="color:red; padding-left:125px;">Paste your code below</span>');
     $form->addElement('textarea', 'analytics_content', 'content', array('rows' => 15, 'cols' => 80));
     //$form->addElement('text', 'analytics_timestamp', 'timestamp');
     $form->addElement('submit', 'analytics_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setContent($form->exportValue('analytics_content'));
         $this->setTimestamp($form->exportValue('analytics_timestamp'));
         $this->save();
     }
     return $form;
 }
Example #26
0
 public function getAddEditForm($target = '/admin/DMS')
 {
     $form = new Form('DataStorage_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->id)) {
         $form->setConstants(array('datastorage_id' => $this->getId()));
         $form->addElement('hidden', 'datastorage_id');
         //$defaultValues ['datastorage_tags'] = $this->getTags();
         $defaultValues['datastorage_description'] = $this->getDescription();
         $form->setDefaults($defaultValues);
     }
     $fupload = $form->addElement('file', 'datastorage_file', 'File');
     //$form->addElement('select', 'datastorage_tags', 'Tags', array('sdf', 'sdfsdf'));
     $form->addElement('textarea', 'datastorage_description', 'Description');
     $form->addElement('submit', 'datastorage_submit', 'Submit');
     if (is_null($this->id)) {
         $form->addRule('datastorage_file', 'Please upload a file', 'uploadedfile');
     }
     if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['datastorage_submit'])) {
         //$this->setTags(trim($form->exportValue('datastorage_tags')));
         $this->setDescription($_REQUEST['datastorage_description']);
         if ($fupload->isUploadedFile() && isset($_FILES['datastorage_file'])) {
             $this->insert($_FILES['datastorage_file']);
         }
         $this->save();
     }
     return $form;
 }
Example #27
0
 /**
  * @abstract Processes the registration
  * @access public
  */
 public function process_registration()
 {
     $form = new Form('users', false, array('groups'));
     $form->addField('password_confirm');
     if ($form->isSubmitted()) {
         if ($form->save()) {
             $this->mail->AddAddress($form->cv('username'));
             $this->mail->From = $this->config('email_sender');
             $this->mail->FromName = $this->config('email_sender_name');
             $this->mail->Mailer = "mail";
             $this->mail->ContentType = 'text/html';
             $this->mail->Subject = $this->website_title() . " Registration Confirmation";
             $body = $this->config('registration_email_body');
             $body = str_replace('{website}', $this->website_title(), $body);
             $body = str_replace('{user}', $form->cv('username'), $body);
             $body = str_replace('{pass}', post()->getRaw('password'), $body);
             $this->mail->Body = $body;
             $this->mail->Send();
             $this->mail->ClearAddresses();
             // send to thanks page
             $thanks = $this->cms_lib->url($this->config('registration_thanks_page_id'));
             header("Location: " . (empty($thanks) ? 'index.php' : $thanks));
             exit;
         }
     }
     return $form;
 }
Example #28
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Content')
 {
     $form = new Form('ContentTemplate_addedit', 'post', $target);
     $form->setConstants(array('section' => 'templates'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->id)) {
         $form->setConstants(array('contenttemplate_id' => $this->getId()));
         $form->addElement('hidden', 'contenttemplate_id');
         $defaultValues['contenttemplate_name'] = $this->getName();
         $defaultValues['contenttemplate_description'] = $this->getDescription();
         $defaultValues['contenttemplate_content'] = $this->getContent();
         $defaultValues['contenttemplate_preview_image'] = $this->getPreview_image();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'contenttemplate_name', 'name /* Fill in text */');
     $form->addElement('text', 'contenttemplate_description', 'description /* Fill in text */');
     $form->addElement('text', 'contenttemplate_content', 'content /* Fill in text */');
     $form->addElement('text', 'contenttemplate_preview_image', 'preview_image /* Fill in text */');
     $form->addElement('submit', 'contenttemplate_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setName($form->exportValue('contenttemplate_name'));
         $this->setDescription($form->exportValue('contenttemplate_description'));
         $this->setContent($form->exportValue('contenttemplate_content'));
         $this->setPreview_image($form->exportValue('contenttemplate_preview_image'));
         $this->save();
     }
     return $form;
 }
Example #29
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Cart')
 {
     $form = new Form('CartCategory_addedit', 'post', $target);
     $form->setConstants(array('section' => 'categories'));
     $form->addElement('hidden', 'section');
     $form->setConstants(array('action' => 'addedit'));
     $form->addElement('hidden', 'action');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartcategory_categories_id' => $this->getId()));
         $form->addElement('hidden', 'cartcategory_categories_id');
         $defaultValues['cartcategory_name'] = $this->getName();
         $defaultValues['cartcategory_description'] = $this->getDescription();
         $defaultValues['cartcategory_image'] = $this->getImage();
         $defaultValues['cartcategory_parent_id'] = $this->getParent_id();
         $defaultValues['cartcategory_date_added'] = $this->getDate_added();
         $defaultValues['cartcategory_last_modified'] = $this->getLast_modified();
         $defaultValues['cartcategory_status'] = $this->getStatus();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartcategory_name', 'Name');
     $description = $form->addElement('textarea', 'cartcategory_description', 'Description');
     $description->setCols(80);
     $description->setRows(10);
     $newImage = $form->addElement('file', 'cartcategory_image_upload', 'Category Image');
     $curImage = $form->addElement('dbimage', 'cartcategory_image', $this->getImage());
     $form->addElement('select', 'cartcategory_parent_id', 'Parent Category', self::toArray());
     $added = $form->addElement('text', 'cartcategory_date_added', 'Date Added');
     $added->freeze();
     $modified = $form->addElement('text', 'cartcategory_last_modified', 'Date Last Modified');
     $modified->freeze();
     $form->addElement('select', 'cartcategory_status', 'Status', Form::statusArray());
     $form->addElement('submit', 'cartcategory_submit', 'Submit');
     if (isset($_REQUEST['cartcategory_submit']) && $form->validate() && $form->isSubmitted()) {
         $this->setName($form->exportValue('cartcategory_name'));
         $this->setDescription($form->exportValue('cartcategory_description'));
         $this->setImage($form->exportValue('cartcategory_image'));
         $this->setParent_id($form->exportValue('cartcategory_parent_id'));
         $this->setDate_added($form->exportValue('cartcategory_date_added'));
         $this->setLast_modified($form->exportValue('cartcategory_last_modified'));
         $this->setStatus($form->exportValue('cartcategory_status'));
         if ($newImage->isUploadedFile()) {
             $im = new Image();
             $id = $im->insert($newImage->getValue());
             $this->setImage($im);
             $curImage->setSource($this->getImage()->getId());
         }
         $this->save();
     }
     return $form;
 }
Example #30
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/CartBasketAttribute')
 {
     $form = new Form('CartBasketAttribute_addedit', 'post', $target);
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (!is_null($this->getId())) {
         $form->setConstants(array('cartbasketattribute_customers_basket_attributes_id' => $this->getId()));
         $form->addElement('hidden', 'cartbasketattribute_customers_basket_attributes_id');
         $defaultValues['cartbasketattribute_user'] = $this->getUser()->getId();
         $defaultValues['cartbasketattribute_product'] = $this->getProduct();
         $defaultValues['cartbasketattribute_optionsId'] = $this->getOptionsId();
         $defaultValues['cartbasketattribute_valueId'] = $this->getValueId();
         $defaultValues['cartbasketattribute_valueText'] = $this->getValueText();
         $defaultValues['cartbasketattribute_sort'] = $this->getSort();
         $form->setDefaults($defaultValues);
     }
     $form->addElement('text', 'cartbasketattribute_user', 'user');
     $form->addElement('text', 'cartbasketattribute_product', 'product');
     $form->addElement('text', 'cartbasketattribute_optionsId', 'optionsId');
     $form->addElement('text', 'cartbasketattribute_valueId', 'valueId');
     $form->addElement('text', 'cartbasketattribute_valueText', 'valueText');
     $form->addElement('text', 'cartbasketattribute_sort', 'sort');
     $form->addElement('submit', 'cartbasketattribute_submit', 'Submit');
     if ($form->validate() && $form->isSubmitted()) {
         $this->setUser($form->exportValue('cartbasketattribute_user'));
         $this->setProduct($form->exportValue('cartbasketattribute_product'));
         $this->setOptionsId($form->exportValue('cartbasketattribute_optionsId'));
         $this->setValueId($form->exportValue('cartbasketattribute_valueId'));
         $this->setValueText($form->exportValue('cartbasketattribute_valueText'));
         $this->setSort($form->exportValue('cartbasketattribute_sort'));
         $this->save();
     }
     return $form;
 }