Example #1
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 #2
0
 public function getAddEditForm($target = '/admin/Menu')
 {
     require_once 'Menu.php';
     if (isset($_REQUEST['id'])) {
         $item = new MenuItem($_REQUEST['id']);
     }
     $status = array('active' => 'Active', 'disabled' => 'Disabled');
     $defaultValues['status'] = @array($item->status);
     $menu = new Menu();
     $parent = $menu->toArray();
     $defaultValues['parent'] = @array($item->parent);
     $form = new Form('menu_addedit', 'POST', $target, '', array('class' => 'admin'));
     if (@$item) {
         $form->setConstants(array('id' => $item->getId(), 'section' => 'addedit'));
         $form->addElement('hidden', 'id');
         $links = $menu->getLinkables($item->module_id);
     } else {
         $form->setConstants(array('section' => 'addedit'));
     }
     $form->addElement('hidden', 'section');
     $form->addElement('text', 'display', 'Display Name', array('value' => @$item->display));
     $active = Config::getActiveModules();
     $linkableType = array();
     foreach ($active as $module) {
         $modulename = 'Module_' . $module['module'];
         include_once SITE_ROOT . '/modules/' . $module['module'] . '/' . $module['module'] . '.php';
         $obj = new $modulename();
         $test = new ReflectionClass($modulename);
         if ($test->hasMethod('getValidLinks')) {
             $linkableType[$module['id']] = $obj->linkType();
         }
     }
     if (@(!$item)) {
         $keys = array_keys($linkableType);
         $links = $menu->getLinkables($keys[0]);
     }
     $defaultValues['link'] = @array($item->link_id);
     $defaultValues['linktype'] = @array($item->module_id);
     $defaultValues['target'] = @array($item->target);
     $form->addElement('select', 'status', 'Status', $status);
     $form->addElement('select', 'linktype', 'Link Type', $linkableType);
     $form->addElement('select', 'link', 'Link To', $links);
     $form->addElement('select', 'target', 'Open In', array('same' => 'Same Window', 'new' => 'New Window'));
     $form->addElement('select', 'parent', 'Parent Item', $parent);
     $form->addElement('submit', 'submit', 'Save');
     $form->applyFilter('display', 'trim');
     $form->addRule('display', 'Please enter a display name', 'required', null, 'client');
     $form->addRule('parent', 'Please choose a parent', 'required', null, 'client');
     $form->addRule('linktype', 'Please choose a link type', 'required', null, 'client');
     $form->addRule('link', 'Please choose a link page', 'required', null, 'client');
     $form->addRule('target', 'Please choose a target', 'required', null, 'client');
     $form->addRule('status', 'Please choose a status', 'required', null, 'client');
     $form->setDefaults($defaultValues);
     if (isset($_REQUEST['submit']) && $form->validate()) {
         $this->template = 'admin/menu.tpl';
         $this->doMenuSubmit();
         return false;
     } else {
         if (isset($_REQUEST['submit'])) {
             $formArray['errors'] = $form->_errors;
         }
     }
     return $form;
 }
Example #3
0
 public function getUserAddEditForm($target = '/admin/User', $admin = false)
 {
     $form = new Form('user_addedit', 'POST', $target, '', array('class' => 'admin'));
     $form->setConstants(array('section' => 'addedit'));
     $form->addElement('hidden', 'section');
     if (@$_REQUEST['id']) {
         $user = new User($_REQUEST['id']);
         $form->setConstants(array('id' => $_REQUEST['id']));
         $form->addElement('hidden', 'id');
     } else {
         $user = new User();
     }
     $statuses = array(1 => 'Active', 0 => 'Disabled');
     $form->addElement('text', 'a_username', 'Username');
     $form->addElement('password', 'a_password', 'Password');
     $form->addElement('password', 'a_password_confirm', 'Confirm Password');
     $form->addElement('text', 'a_name', 'Full Name');
     $form->addElement('text', 'a_email', 'Email Address');
     if ($admin) {
         $form->addElement('select', 'a_status', 'Active Status', $statuses);
     }
     if (isset($this->user) && $this->user->hasPerm('assigngroups')) {
         $sql = 'SELECT agp_id, agp_name from auth_groups';
         $groups = Database::singleton()->query_fetch_all($sql);
         $assignableGroup = array();
         foreach ($groups as $group) {
             $assignableGroup[$group['agp_id']] = $group['agp_name'];
         }
         if (@$user) {
             $defaultValues['a_group'] = $user->getAuthGroup();
         }
         $form->addElement('select', 'a_group', 'Member Group', $assignableGroup);
     }
     $form->addElement('submit', 'a_submit', 'Save');
     $defaultValues['a_username'] = $user->getUsername();
     $defaultValues['a_name'] = $user->getName();
     $defaultValues['a_email'] = $user->getEmail();
     $defaultValues['a_password'] = null;
     $defaultValues['a_password_confirm'] = null;
     if ($admin) {
         $defaultValues['a_status'] = $user->getActiveStatus();
     }
     $form->setDefaults($defaultValues);
     $form->addRule('a_username', 'Please enter a username', 'required', null);
     $form->addRule('a_name', 'Please enter the user\'s name', 'required', null);
     $form->addRule('a_email', 'Please enter an email address', 'required', null);
     $form->addRule('a_email', 'Please enter a valid email address', 'email', null);
     if (!isset($_REQUEST['id'])) {
         $form->addRule('a_password', 'Please enter a password', 'required', null);
         $form->addRule('a_password_confirm', 'Please confirm the passwords match', 'required', null);
     }
     $form->addRule(array('a_password', 'a_password_confirm'), 'The passwords do not match', 'compare', null);
     if (isset($_REQUEST['a_submit']) && $form->validate()) {
         $this->template = 'admin/user.tpl';
         $this->doUserSubmit();
     }
     return $form;
 }
Example #4
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 #5
0
 /**
  * Get an Add/Edit form for the object.
  *
  * @param string $target Post target for form submission
  */
 public function getAddEditForm($target = '/admin/Support')
 {
     $form = new Form('support_form', 'POST', $target, '', array('class' => 'admin'));
     $form->addElement('select', 'project', 'Project', $this->getSoapUserProjects());
     $form->addElement('select', 'type', 'Type of problem', $this->getSoapCategories());
     $form->addElement('text', 'summary', 'Summary');
     $form->addElement('textarea', 'desc', 'Description', array('rows' => '6', 'cols' => '50'));
     $form->addElement('submit', 'submit', 'Submit');
     $form->addRule('summary', 'Please enter a short summary', 'required', null, 'client');
     $form->addRule('type', 'Please choose a bug type', 'required', null, 'client');
     $form->addRule('desc', 'Please enter a description', 'required', null, 'client');
     $extraData = $_SERVER['HTTP_USER_AGENT'];
     $extraData .= "\n";
     $extraData .= 'Site: ' . $_SERVER['SERVER_NAME'] . "\n";
     $extraData .= 'Username: '******'authenticated_user']->getUsername() . "\n";
     $extraData .= 'Realname: ' . $_SESSION['authenticated_user']->getName() . "\n";
     if ($form->validate()) {
         $issue = array('id' => null, 'project' => array('id' => $_REQUEST['project'], 'name' => 'norexcms'), 'view_state' => null, 'handler' => null, 'reporter' => null, 'last_updated' => null, 'summary' => stripslashes($_REQUEST['summary']), 'description' => stripslashes($_REQUEST['desc']), 'priority' => null, 'severity' => null, 'status' => null, 'reproducibility' => null, 'version' => null, 'build' => null, 'platform' => null, 'os' => null, 'os_build' => null, 'date_submitted' => null, 'sponsorship_total' => null, 'projection' => null, 'eta' => null, 'resolution' => null, 'fixed_in_version' => null, 'steps_to_reproduce' => null, 'additional_information' => stripslashes($extraData), 'attachments' => null, 'relationships' => null, 'notes' => null, 'custom_fields' => array(array('field' => array('id' => 1, 'name' => 'site'), 'value' => $_SERVER['SERVER_NAME'])), 'category' => stripslashes($_REQUEST['type']));
         $issueID = $this->soap->__call('mc_issue_add', array('username' => MANTIS_USER, 'password' => MANTIS_PASSWORD, 'issue' => $issue));
         $this->setTicket_id($issueID);
         $this->setOwner($_SESSION['authenticated_user']->getId());
         $this->setTitle($_REQUEST['summary']);
         $this->save();
     }
     return $form;
 }
//aro object value
$group = new usergroup($DB);
if (is_array($arr_user)) {
    if (count($arr_user)) {
        $arr_in = $group->selectInUser($arr_user['users'], 1);
        $arr_out = $group->selectInUser($arr_user['users'], 0);
    } else {
        $user = new user($DB);
        $arr_out = $user->selectAlluser(1000, 1);
    }
}
$smartyutil = new SmartyUtil();
$arr_newin = $smartyutil->toSmartyArray($arr_in, 'name', 'id');
$arr_newout = $smartyutil->toSmartyArray($arr_out, 'name', 'id');
$form = new Form('form1', 'index.php', 'post');
$form->addRule('select_all(document.form1.select2);');
$select1 =& $form->addElement('select');
$select1->setAttribute('id', 'select1');
$select1->setAttribute('name', 'newuser[]');
$select1->setAttribute('option', $arr_newout);
$select1->setAttribute('extra', 'multiple');
$select2 =& $form->addElement('select');
$select2->setAttribute('id', 'select2');
$select2->setAttribute('name', 'user[]');
$select2->setAttribute('option', $arr_newin);
$select2->setAttribute('extra', 'multiple');
$allleft =& $form->addElement('button');
$allleft->setAttribute('id', 'button1');
$allleft->setAttribute('value', '   ALL>>   ');
$allleft->setAttribute('onclick', "moveAll(this.form.elements['newuser[]'], this.form.elements['user[]'])");
$left =& $form->addElement('button');
Example #7
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 #8
0
 function getAddEditForm($target = null)
 {
     if (!$target) {
         $target = '/admin/' . get_class($this);
     }
     $formName = get_class($this) . '_addedit';
     $els = array();
     $form = new Form($formName, 'post', $target);
     $form->setConstants(array('action' => @$_REQUEST['action'], 'section' => @$_REQUEST['section']));
     $form->addElement('hidden', 'action');
     $form->addElement('hidden', 'section');
     foreach ($this->columns() as $column) {
         if ($column->noForm()) {
             continue;
         }
         $name = $column->name();
         $value =& $this->get($name);
         $id = $this->quickformPrefix() . $name;
         $formValue = $column->toForm($value);
         if ($column->hidden()) {
             $el = $form->addElement("hidden", $id);
             $el->setValue($formValue);
         } else {
             $el = $column->addElementTo(array('form' => $form, 'id' => $id, 'value' => $formValue));
         }
         if ($column->required()) {
             $form->addRule($id, "Please enter the " . $column->label(), 'required', null, 'client');
         }
         $els[$name] = $el;
     }
     $this->getAddEditFormHook($form);
     $form->addElement('submit', $this->quickformPrefix() . 'submit', 'Submit');
     if ($form->isSubmitted() && isset($_REQUEST[$this->quickformPrefix() . 'submit']) && $form->validate()) {
         $this->getAddEditFormSaveHook($form);
         foreach ($this->columns() as $column) {
             if ($column->noForm()) {
                 continue;
             }
             $name = $column->name();
             $value = $form->exportValue($this->quickformPrefix() . $name);
             $this->set($name, $column->fromForm($value));
         }
         $this->save();
         $form->setProcessed();
     }
     return $form;
 }
Example #9
0
 public function contentForm($newRev = null)
 {
     $form = new Form('page_addedit', 'POST', '/admin/Content', '', array('class' => 'admin'));
     $form->addElement('text', 'title', 'Page Title', array('value' => $newRev->getPageTitle()));
     $sql = 'select * from locale order by display_name';
     $rows = $this->db->query_fetch_all($sql);
     $languages = array();
     foreach ($rows as $language) {
         $languages[$language['id']] = $language['display_name'];
     }
     $form->addElement('select', 'language', 'Language', $languages);
     $form->addElement('text', 'access', 'Page Access');
     $defaultValues['language'] = array($newRev->getLocaleId());
     $defaultValues['access'] = $newRev->getAccess();
     $form->setDefaults($defaultValues);
     $form->setConstants(array('action' => 'updatePage', 'id' => $newRev->getId(), 'section' => 'addEdit'));
     $form->addElement('hidden', 'id');
     $form->addElement('hidden', 'section');
     $form->addElement('hidden', 'action');
     $oQFElement = HTML_Quickform::createElement('tinymce', 'editor', 'Content');
     //$oQFElement->setFCKProps ( '/core/fckeditor/', 'Default', '100%', '500', array ('SkinPath' => 'editor/skins/office2003/', 'DefaultLanguage' => 'en', 'StylesXmlPath' => '/core/fckeditor/fckstyles.xml', 'UseBROnCarriageReturn' => 'true', 'StartupFocus' => 'false',
     //		'CustomConfigurationsPath' => 'config.js', 'EditorAreaCSS' => 'fck_editorarea.css' ) );
     $oQFElement->setValue($newRev->getContent());
     $form->addElement($oQFElement);
     $form->addElement('submit', 'submit', 'Save and auto-publish', array('id' => 'submit'));
     $form->addElement('submit', 'submit_leavestatus', 'Save (but don\'t publish)');
     $form->applyFilter('urlkey', 'title');
     $form->addRule('title', 'Please enter a Page Title', 'required', null, 'client');
     $form->addRule('editor', 'Please enter some Page Content', 'required', null, 'client');
     return $form;
 }
Example #10
0
 public function getAddEditForm()
 {
     $form = new Form('page_addedit', 'POST', '/admin/Content', '', array('class' => 'admin'));
     $form->addElement('text', 'title', 'Page Title', array('value' => $this->getPageTitle()));
     $sql = 'select * from locale order by display_name';
     $rows = Database::singleton()->query_fetch_all($sql);
     $languages = array();
     foreach ($rows as $language) {
         $languages[$language['id']] = $language['display_name'];
     }
     $form->addElement('select', 'language', 'Language', $languages);
     $defaultValues['language'] = array($this->getLocaleId());
     $form->setDefaults($defaultValues);
     $form->setConstants(array('action' => 'updatePage', 'id' => $this->getId(), 'section' => 'addEdit', 'parent_id' => $this->getParentId()));
     $form->addElement('hidden', 'id');
     $form->addElement('hidden', 'section');
     $form->addElement('hidden', 'action');
     $oQFElement = HTML_Quickform::createElement('tinymce', 'editor', 'Content');
     //$oQFElement->setFCKProps ( '/core/fckeditor/', 'Default', '100%', '500', array ('SkinPath' => 'editor/skins/office2003/', 'DefaultLanguage' => 'en', 'StylesXmlPath' => '/core/fckeditor/fckstyles.xml', 'UseBROnCarriageReturn' => 'true', 'StartupFocus' => 'false',
     //		'CustomConfigurationsPath' => 'config.js', 'EditorAreaCSS' => 'fck_editorarea.css' ) );
     $oQFElement->setValue($this->getContent());
     $form->addElement($oQFElement);
     $form->addElement('submit', 'submit', 'Save and auto-publish', array('id' => 'submit'));
     $form->addElement('submit', 'submit_leavestatus', 'Save (but don\'t publish)');
     $form->applyFilter('urlkey', 'title');
     $form->addRule('title', 'Please enter a Page Title', 'required', null, 'client');
     $form->addRule('editor', 'Please enter some Page Content', 'required', null, 'client');
     if ($form->validate() && (isset($_REQUEST['submit']) || isset($_REQUEST['submit_leavestatus']))) {
         $this->setContent($_REQUEST['editor']);
         $this->setLocaleId($_REQUEST['language']);
         $this->setPageTitle($_REQUEST['title']);
         $this->setTimestamp(date('Y-m-d H:i:s'));
         if (isset($_SESSION['metadata'])) {
             $this->setMetaData($_SESSION['metadata']);
             unset($_SESSION['metadata']);
         }
         if (isset($_REQUEST['submit'])) {
             $this->setStatus(true);
         }
         $this->save();
     }
     return $form;
 }
Example #11
0
 public function getUserProfilePicForm($page_submit = '/user/editprofilepic')
 {
     $form = new Form('account_addedit', 'post', $page_submit, '', array('onsubmit' => 'return !submitfileuploadform(this);'));
     $pic =& $form->addElement('html', '<img src="/images/image.php?id=' . $this->profile_picture . '&h=60" id="profilepic" />');
     $file =& $form->addElement('file', 'profile_pic', 'Upload new Profile Picture');
     $form->addElement('submit', 'submit', 'Update');
     $form->addRule('profile_pic', 'Choose file', 'uploadedFile');
     if ($form->validate()) {
         $this->setProfilePic($file);
         $pic->setText('<img src="/images/image.php?id=' . $this->getProfilePic() . '&h=60" id="profilepic" />');
         $this->save();
     }
     return $form;
 }
Example #12
0
 /**
  * Manage the accounts of the shoppers
  * 
  * This function allows the shoppers to manage their account
  * They can change their profile (address, email, phone number, etc), or view all the orders that they made
  *  
  * @return string
  */
 public function handleMyAccount($action)
 {
     $auth_container = new User();
     $auth = new Auth($auth_container, null, 'authInlineHTML');
     $auth->start();
     if (!$auth->checkAuth()) {
         return authInlineHTML();
     }
     $userId = $_SESSION['authenticated_user']->getId();
     switch ($action) {
         case 'MyProfile':
             //Display my profile
             //It is easier to re-generate the profile form rather than using the original one
             $form = new Form('user_profile', 'POST', '/Store/MyAccount/&action=MyProfile');
             $form->addElement('static', 'a_username', 'Username');
             $form->addElement('password', 'a_password', 'Password');
             $form->addElement('password', 'a_password_confirm', 'Confirm Password');
             $form->addElement('text', 'a_name', 'Full Name');
             //$form->addElement( 'text',  'a_email', 'Email Address');
             $form->addElement('checkbox', 'a_join_newsletter', 'Sign me up for your E-Newsletter');
             $form->addElement('submit', 'a_submit', 'Save');
             $user = new User($userId);
             $defaultValues['a_username'] = $user->getUsername();
             $defaultValues['a_name'] = $user->getName();
             //$defaultValues ['a_email'] = $user->getEmail();
             $defaultValues['a_password'] = null;
             $defaultValues['a_password_confirm'] = null;
             $defaultValues['a_join_newsletter'] = $user->getJoinNewsletter();
             $form->setDefaults($defaultValues);
             $form->addRule('a_name', 'Please enter the user\'s name', 'required', null);
             //$form->addRule( 'a_email', 'Please enter an email address', 'required', null );
             //$form->addRule( 'a_email', 'Please enter a valid email address', 'email', null );
             $form->addRule(array('a_password', 'a_password_confirm'), 'The passwords do not match', 'compare', null);
             if (isset($_REQUEST['a_submit']) && $form->validate()) {
                 if ($_REQUEST['a_password'] != '') {
                     $user->setPassword($_REQUEST['a_password']);
                 }
                 $user->setName($_REQUEST['a_name']);
                 if (!@$_REQUEST['a_join_newsletter']) {
                     $_REQUEST['a_join_newsletter'] = 0;
                 }
                 $user->setJoinNewsletter($_REQUEST['a_join_newsletter']);
                 //$user->setEmail($_REQUEST['a_email']);
                 $user->save();
                 $this->smarty->assign('profileHasBeenChanged', 1);
             }
             $this->smarty->assign('form', $form);
             //After displaying the "standard" user profile, display all the extra fields such as shipping address, billing address, and phone number
             $userDetails = UserDetails::getUserDetailsBasedOnUserId($userId);
             $this->smarty->assign('userDetails', $userDetails);
             return $this->smarty->fetch("MyProfile.tpl");
             break;
         case 'MyOrders':
             //Display all the orders that this user has made, and display the details of a particular order through an ajax call
             if (@$_REQUEST["order_id"]) {
                 $order = new Order($_REQUEST["order_id"]);
                 if ($order->getUser() != $userId) {
                     //Make sure users cannot view orders that do not belong to them
                     return 'Order does not belong to you';
                 }
                 $orderItems = OrderDetail::getAll($_REQUEST["order_id"]);
                 $orderComments = OrderComment::getAll($order->getId());
                 $this->smarty->assign('order', $order);
                 $this->smarty->assign('orderItems', $orderItems);
                 $this->smarty->assign('orderComments', $orderComments);
                 return $this->smarty->fetch("admin/OrderDetail.tpl");
             }
             $this->addJS('/js/facebox.js');
             $this->addCSS('/css/facebox.css');
             $results = Order::getAll(true, $userId);
             $this->smarty->assign('results', $results);
             return $this->smarty->fetch("MyOrders.tpl");
             break;
     }
     return $this->smarty->fetch("MyAccount.tpl");
 }
Example #13
0
 public function getUserAddEditForm($target = '/admin/User', $admin = false, $addSection = true)
 {
     $form = new Form('user_addedit', 'POST', $target);
     if ($addSection) {
         $form->setConstants(array('section' => 'addedit'));
         $form->addElement('hidden', 'section');
     }
     if (@$_REQUEST['id']) {
         $this->__construct($_REQUEST['id']);
         $form->setConstants(array('id' => $_REQUEST['id']));
         $form->addElement('hidden', 'id');
     } elseif (!@$this->getId()) {
         $this->__construct();
     }
     $statuses = array(1 => 'Active', 0 => 'Disabled');
     $form->addElement('header', 'general', 'General Info');
     if (!$admin && @$_REQUEST['id']) {
         //The user is editing their profile, Do not edit the username
         $form->addElement('static', 'a_username_label', 'Username (Email address)', $this->getUsername());
         $form->setConstants(array('a_username' => $this->getUsername()));
         $form->addElement('hidden', 'a_username');
     } else {
         $form->addElement('text', 'a_username', 'Username (Email address)');
         $form->addRule('a_username', 'Please enter a username', 'required', null, 'client');
         $form->addRule('a_username', 'Please enter a valid email address for the username', 'email', null, 'client');
     }
     $form->addElement('password', 'a_password', 'Password');
     $form->addElement('password', 'a_password_confirm', 'Confirm Password');
     $form->addElement('text', 'a_name', 'Full Name');
     //$form->addElement( 'text',  'a_email', 'Email Address');
     $form->addElement('text', 'a_phone', 'Phone number');
     $form->addElement('advcheckbox', 'a_join_newsletter', 'Sign me up for your E-Newsletter');
     $form->addElement('header', 'billing_address_header', 'Billing Address');
     $form->addElement('text', 'a_address', 'Address');
     $form->addElement('text', 'a_city', 'City');
     $form->addElement('text', 'a_postalcode', 'Postal Code');
     $form->setConstants(array('a_state' => '1'));
     //31 is the ID of Alberta. It should be a SiteConfig variable
     $form->addElement('hidden', 'a_state');
     $form->addElement('static', 'a_state1', 'State / Province', 'Alberta');
     $form->setConstants(array('a_country' => '31'));
     //31 is the ID of Canada. It should be a SiteConfig variable
     $form->addElement('hidden', 'a_country');
     $form->addElement('static', 'a_country1', 'Country', 'Canada');
     $form->addElement('header', 'shipping_address_header', 'Shipping Address');
     $form->addElement('text', 'shipping_address', 'Address');
     $form->addElement('text', 'shipping_city', 'City');
     $form->addElement('text', 'shipping_postalcode', 'Postal Code');
     $form->setConstants(array('shipping_state' => '1'));
     //31 is the ID of Alberta. It should be a SiteConfig variable
     $form->addElement('hidden', 'shipping_state');
     $form->addElement('static', 'shipping_state1', 'State / Province', 'Alberta');
     $form->setConstants(array('shipping_country' => '31'));
     //31 is the ID of Canada. It should be a SiteConfig variable
     $form->addElement('hidden', 'shipping_country');
     $form->addElement('static', 'shipping_country1', 'Country', 'Canada');
     $form->addElement('header', 'save', 'Save');
     if ($admin) {
         $form->addElement('select', 'a_status', 'Active Status', $statuses);
     }
     $form->addElement('submit', 'a_submit', 'Save');
     $form->addElement('reset', 'a_cancel', 'Cancel');
     if (isset($this->user) && $this->user->hasPerm('assigngroups')) {
         $sql = 'SELECT agp_id, agp_name from auth_groups';
         $groups = Database::singleton()->query_fetch_all($sql);
         $assignableGroup = array();
         foreach ($groups as $group) {
             $assignableGroup[$group['agp_id']] = $group['agp_name'];
         }
         if (@$this) {
             $defaultValues['a_group'] = $this->getAuthGroup();
         }
         $form->addElement('select', 'a_group', 'Member Group', $assignableGroup);
     }
     $defaultValues['a_username'] = $this->getUsername();
     $defaultValues['a_name'] = $this->getName();
     //$defaultValues ['a_email'] = $this->getEmail();
     $defaultValues['a_phone'] = $this->getPhone();
     $defaultValues['a_join_newsletter'] = $this->getJoinNewsletter();
     $defaultValues['a_password'] = null;
     $defaultValues['a_password_confirm'] = null;
     if (@$this->getAddress()) {
         $defaultValues['a_address'] = @$this->getAddress()->getStreetAddress();
         $defaultValues['a_city'] = @$this->getAddress()->getCity();
         $defaultValues['a_postalcode'] = @$this->getAddress()->getPostalCode();
     }
     if (@$this->getShippingAddress()) {
         $defaultValues['shipping_address'] = @$this->getShippingAddress()->getStreetAddress();
         $defaultValues['shipping_city'] = @$this->getShippingAddress()->getCity();
         $defaultValues['shipping_postalcode'] = @$this->getShippingAddress()->getPostalCode();
     }
     if ($admin) {
         $defaultValues['a_status'] = $this->getActiveStatus();
     }
     $form->setDefaults($defaultValues);
     $form->addRule('a_name', 'Please enter the user\'s name', 'required', null, 'client');
     //$form->addRule( 'a_email', 'Please enter an email address', 'required', null, 'client' );
     //$form->addRule( 'a_email', 'Please enter a valid email address', 'email', null, 'client' );
     $form->addRule('a_phone', 'Please enter a phone number', 'required', null, 'client');
     $form->addRule('a_address', 'Please enter a billing address', 'required', null, 'client');
     $form->addRule('a_city', 'Please enter a billing address city', 'required', null, 'client');
     $form->addRule('a_postalcode', 'Please enter a billing address postal code', 'required', null, 'client');
     $form->addRule('shipping_address', 'Please enter a shipping address', 'required', null, 'client');
     $form->addRule('shipping_city', 'Please enter a shipping address city', 'required', null, 'client');
     $form->addRule('shipping_postalcode', 'Please enter a shipping address postal code', 'required', null, 'client');
     if (!isset($_REQUEST['id'])) {
         $form->addRule('a_password', 'Please enter a password', 'required', null, 'client');
         $form->addRule('a_password_confirm', 'Please confirm the passwords match', 'required', null, 'client');
     }
     $form->addRule(array('a_password', 'a_password_confirm'), 'The passwords do not match', 'compare', null, 'client');
     if (isset($_REQUEST['a_submit']) && $form->validate()) {
         $this->setPassword($_REQUEST['a_password']);
         if ($admin || @(!$_REQUEST['id'])) {
             $this->setUsername($_REQUEST['a_username']);
             $this->setEmail($_REQUEST['a_username']);
         }
         $this->setActiveStatus(1);
         $this->setPhone($_REQUEST['a_phone']);
         $this->setName($_REQUEST['a_name']);
         $this->setJoinNewsletter(@$_REQUEST['a_join_newsletter']);
         if (@$this->getAddress()) {
             $billingTemp = new Address(@$this->getAddress()->getId());
         } else {
             $billingTemp = new Address();
         }
         $billingTemp->setStreetAddress($_REQUEST['a_address']);
         $billingTemp->setCity($_REQUEST['a_city']);
         $billingTemp->setPostalCode($_REQUEST['a_postalcode']);
         $billingTemp->setState($_REQUEST['a_state']);
         $billingTemp->setCountry($_REQUEST['a_country']);
         $billingTemp->save();
         $this->setAddress($billingTemp);
         if (@$this->getShippingAddress()) {
             $shippingTemp = new Address(@$this->getShippingAddress()->getId());
         } else {
             $shippingTemp = new Address();
         }
         $shippingTemp->setStreetAddress($_REQUEST['shipping_address']);
         $shippingTemp->setCity($_REQUEST['shipping_city']);
         $shippingTemp->setPostalCode($_REQUEST['shipping_postalcode']);
         $shippingTemp->setState($_REQUEST['shipping_state']);
         $shippingTemp->setCountry($_REQUEST['shipping_country']);
         $shippingTemp->save();
         $this->setShippingAddress($shippingTemp);
         if ($this->save()) {
             $_REQUEST["user_created"] = 1;
         } else {
             $form->addElement('static', 'Message', 'Username already exists');
             $_REQUEST["username_already_exists"] = 1;
         }
     }
     return $form;
 }
Example #14
0
 public function getForm($target = '/admin/Content')
 {
     $form = new Form('content_addedit', 'POST', $target, '', array('class' => 'admin'));
     $form->addElement('text', 'urlkey', 'Page URL Key');
     if (Module_Content::hasRestriction()) {
         $form->addElement('select', 'access', 'Page Access', array('public' => 'Public', 'restricted' => 'Restricted'));
     } else {
         $form->addElement('hidden', 'access', 'public');
     }
     $form->addElement('text', 'metatitle', 'SEO Title', array('style' => 'width: 70%;'));
     $form->addElement('text', 'metadesc', 'SEO Description', array('style' => 'width: 70%;'));
     $form->addElement('text', 'metakeywords', 'SEO Keywords', array('style' => 'width: 70%;'));
     $form->applyFilter('urlkey', 'trim');
     $form->addRule('urlkey', 'Please enter a URL key', 'required', null, 'client');
     $form->addElement('submit', 'submit', 'Continue');
     if ($form->validate() && isset($_REQUEST['submit'])) {
         $this->setPageName($form->exportValue('urlkey'));
         $this->setTimestamp(date('Y-m-d H:i:s'));
         $metadata['title'] = $form->exportValue('metatitle');
         $metadata['description'] = $form->exportValue('metadesc');
         $metadata['keywords'] = $form->exportValue('metakeywords');
         $_SESSION['metadata'] = $metadata;
         $this->setAccess($form->exportValue('access'));
         $this->save();
     }
     return $form;
 }
Example #15
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 #16
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 #17
0
 public function getAddEditForm($target = '/admin/Campaigns&section=recipaddedit')
 {
     $form = new Form('campaign_recipient_addedit', 'POST', $target, '', array('class' => 'admin'));
     $form->addElement('text', 'name', 'Name');
     $form->addElement('text', 'email', 'E-mail');
     $chk =& $form->createElement('select', 'contact_type', 'Contact type', array("admin" => "Admin", "result" => "Result viewer", "normal" => "Normal user"));
     $form->addElement($chk);
     $form->addElement('hidden', 'group_id', $this->group);
     $form->addElement('submit', 'submit', 'Submit');
     $form->addRule('name', 'Please enter a recipient name', 'required');
     $form->addRule('email', 'Please enter an email address', 'required');
     if (!is_null($this->id)) {
         $form->setConstants(array('recipient_id' => $this->getId()));
         $form->addElement('hidden', 'recipient_id');
         $defaultValues['name'] = $this->getName();
         $defaultValues['email'] = $this->getEmail();
         $defaultValues['contact_type'] = $this->getContactType();
     } else {
         $defaultValues['contact_type'] = "normal";
     }
     $form->setDefaults($defaultValues);
     if ($form->isSubmitted() && isset($_POST['submit'])) {
         if ($form->validate()) {
             $this->name = $form->exportValue('name');
             $this->email = $form->exportValue('email');
             $this->type = $form->exportValue('contact_type');
             $this->save();
         }
     }
     return $form;
 }