コード例 #1
0
ファイル: FormLogin.php プロジェクト: jamesread/lanlist.org
 public function __construct()
 {
     parent::__construct('formLogin', 'Login');
     $this->addElement(Element::factory('text', 'username', 'Username'));
     $this->addElement(Element::factory('password', 'password', 'Password'));
     $this->addButtons(Form::BTN_SUBMIT);
     $this->getElement('submit')->setCaption('Login');
 }
コード例 #2
0
 public function __construct()
 {
     parent::__construct('formDeleteUser', 'Delete user?');
     requirePriv('USER_DELETE');
     $this->addElement(Element::factory('hidden', 'uid', null, $_REQUEST['formDeleteUser-uid']));
     $this->addElement(Element::factory('html', 'msg', null, 'Sure?'));
     $this->addButtons(Form::BTN_SUBMIT);
 }
コード例 #3
0
 public function __construct()
 {
     parent::__construct('formRegister', 'Register a new account');
     $this->addElement(Element::factory('alphanumeric', 'username', 'Username'));
     $this->addElement(Element::factory('password', 'password1', 'Password'));
     $this->addElement(Element::factory('password', 'password2', 'Password (confirm)'));
     $this->addElement(Element::factory('text', 'email', 'E-Mail address'));
     $this->addButtons(Form::BTN_SUBMIT);
 }
コード例 #4
0
 public function __construct()
 {
     parent::__construct('formChangePassword', 'Change password');
     if (!Session::isLoggedIn()) {
         throw new Exception('You need to be logged in to change your password.');
     }
     $this->addElement(Element::factory('password', 'password1', 'New password'));
     $this->addElement(Element::factory('password', 'password2', 'Password (confirm)'));
     $this->addButtons(Form::BTN_SUBMIT);
 }
コード例 #5
0
 private function getElementOrganization()
 {
     global $db;
     $sql = 'SELECT o.id, o.title FROM organizers o WHERE o.published = 1 ORDER BY o.title ASC';
     $stmt = $db->query($sql);
     $el = Element::factory('select', 'organization', 'Organization');
     foreach ($stmt->fetchAll() as $organization) {
         $el->addOption($organization['title'], $organization['id']);
     }
     return $el;
 }
コード例 #6
0
 private function getGroupSelectionElement($currentGroup)
 {
     global $db;
     $el = Element::factory('select', 'group', 'Primary group');
     $sql = 'SELECT g.id, g.title FROM groups g';
     $stmt = $db->prepare($sql);
     $stmt->execute();
     foreach ($stmt->fetchAll() as $group) {
         $el->addOption($group['title'], $group['id']);
     }
     $el->setValue($currentGroup);
     return $el;
 }
コード例 #7
0
 private function getElementSleeping($val)
 {
     $el = Element::factory('select', 'sleeping', 'Sleeping');
     $el->addOption('Not aranged by organizer');
     $el->addOption('Not an overnight event');
     $el->addOption('Private rooms at venue');
     $el->addOption('Indoors at venue');
     $el->addOption('Indoors and camping at venue');
     $el->addOption('Indoors, camping and private rooms at venue');
     $el->addOption('Indoors at venue. Camping and hotels nearby.');
     $el->setValue($val);
     return $el;
 }
コード例 #8
0
 public function __construct($id, $isNewArticle = false)
 {
     $this->id = $id;
     Session::requirePriv('EDIT_BLOG');
     if (empty($isNewArticle)) {
         parent::__construct('editBlogPost', 'New post');
     } else {
         parent::__construct('editBlogPost', 'Edit post');
     }
     $post = $this->getPost();
     $this->addElement(Element::factory('textarea', 'title', 'Title', $post['title']));
     $this->addElement(Element::factory('textarea', 'content', 'Content', $post['content']));
     $this->addDefaultButtons();
 }
コード例 #9
0
ファイル: FormHelpers.php プロジェクト: jamesread/lanlist.org
 public static function getOrganizerList($includeNull = false)
 {
     global $db;
     $sql = 'SELECT id, title FROM organizers ORDER BY title ASC';
     $stmt = $db->prepare($sql);
     $stmt->execute();
     $el = Element::factory('select', 'organizer', 'Organizer');
     foreach ($stmt->fetchAll() as $orgie) {
         $el->addOption($orgie['title'], $orgie['id']);
     }
     if ($includeNull) {
         $el->addOption('(null)', 0);
     }
     return $el;
 }
コード例 #10
0
 public function __construct()
 {
     parent::__construct('newOrganizer', 'New Organizer');
     if (Session::getUser()->hasPriv('CREATE_ORGANIZERS')) {
         $this->addElement(Element::factory('html', 'description', null, 'This will appear in the organizers list as soon as you submit the form.'));
     } else {
         $currentOrganizer = Session::getUser()->getData('organization');
         if (empty($currentOrganizer) && $currentOrganizer != 0) {
             throw new PermissionException('Cannot create another organizer, you already have one aginst your account');
         }
         $this->addElement(Element::factory('html', 'description', null, 'This will not appear in the organizers list immidiately, it will first have to be approved by one of our smiling friendly admins - they accept bribes in the form of cake.'));
     }
     $this->addElement(Element::factory('text', 'title', 'Title'));
     $this->addElement(Element::factory('text', 'websiteUrl', 'Website URL'));
     $this->addElement(Element::factory('textarea', 'blurb', 'Blurb', null, 'A blurb describes the organizer, prehaps the year you started, how experienced you are, or if you like cake. Its best to leave event specific information to when you go to create events.'));
     $this->addButtons(Form::BTN_SUBMIT);
 }
コード例 #11
0
 public function __construct()
 {
     parent::__construct('formEditVenue', 'Edit Venue');
     $venue = $this->getVenue();
     if (Session::getUser()->getData('organization') != $venue['organizer']) {
         Session::requirePriv('EDIT_VENUE');
     }
     $this->addElement(Element::factory('hidden', 'id', null, $venue['id']));
     $this->addElement(Element::factory('text', 'title', 'Title', $venue['title']));
     $this->addElement(Element::factory('text', 'lat', 'Lat', $venue['lat']));
     $this->getElement('lat')->setMinMaxLengths(1, 10);
     $this->addElement(Element::factory('text', 'lng', 'Lng', $venue['lng']));
     $this->getElement('lng')->setMinMaxLengths(1, 10);
     $this->addElement(FormHelpers::getElementCountry($venue['country']));
     $this->addElement(FormHelpers::getOrganizerList());
     $this->getElement('organizer')->setValue($venue['organizer']);
     $this->addButtons(Form::BTN_SUBMIT);
 }
コード例 #12
0
 public function __construct()
 {
     parent::__construct('newVenue', 'New Venue');
     $this->addElement(Element::factory('html', 'desc', null, 'A venue is a physical place where an event will be hosted, this may be a convention centre, a hall or just your house. You can specify detail such as sleeping arangements when the event is created.'));
     $this->addElement(Element::factory('text', 'title', 'Title', null, 'eg: Budleigh Salterton town hall, Cheltenham Racecourse, etc.'));
     $this->addElement(FormHelpers::getElementCountry('United Kingdom'));
     $this->addElement(Element::factory('html', 'locationDesc', null, '<br />The geodetic (WGS84) latitude/longitude of your venue. This can be awkward, but it allows us to put a pin on the map. We cannot use post/zip codes because many countries do not have them! <a href = "http://www.getlatlon.com/">http://getlatlong.com</a> will convert an address to a rough lat/lng. '));
     $this->addElement(Element::factory('numeric', 'lat', 'Latitude'))->setAllowNegative(true);
     $this->addElement(Element::factory('numeric', 'lng', 'Longitude'))->setAllowNegative(true);
     if (Session::hasPriv('NEW_VENUE')) {
         $this->addElement(FormHelpers::getOrganizerList());
         if (isset($_REQUEST['formNewVenue-organizer'])) {
             $this->getElement('organizer')->setValue($_REQUEST['formNewVenue-organizer']);
         }
     }
     $this->addButtons(Form::BTN_SUBMIT);
     $this->requireFields(array('title', 'lat', 'lng', 'country'));
 }
コード例 #13
0
 public function process()
 {
     global $db;
     $sql = 'INSERT INTO events (title, dateStart, dateFinish, organizer, venue, published, website, createdDate, createdBy) VALUES (:title, :dateStart, :dateFinish, :organizer, :venue, :published, :website, :createdDate, :createdBy)';
     $stmt = $db->prepare($sql);
     $stmt->bindValue(':title', $this->getElementValue('title'));
     $stmt->bindValue(':dateStart', $this->getElementValue('dateStart'));
     $stmt->bindValue(':dateFinish', $this->getElementValue('dateFinish'));
     $stmt->bindValue(':website', $this->getElementValue('eventWebsite'));
     $stmt->bindValue(':createdDate', date(DATE_ATOM));
     $stmt->bindValue(':createdBy', Session::getUser()->getId());
     if (Session::getUser()->hasPriv('CREATE_EVENTS')) {
         $this->addElement(Element::factory('html', 'msg', null, 'Hi superuser.'));
         $stmt->bindValue(':organizer', $this->getElementValue('organizer'));
         $stmt->bindValue(':published', 1);
         $stmt->bindValue(':venue', $this->getElementValue('venue'));
     } else {
         if (Session::getUser()->getData('organization') != null) {
             $stmt->bindValue(':venue', $this->getElementValue('venue'));
             $organizer = fetchOrganizer(Session::getUser()->getData('organization'));
             if ($organizer['published']) {
                 $this->addElement(Element::factory('html', 'msg', null, 'You are authorized to create public events for your organization.'));
                 $stmt->bindValue(':organizer', $organizer['id']);
                 $stmt->bindValue(':published', 1);
             } else {
                 $this->addElement(Element::factory('html', 'msg', null, 'Your event will be linked to your organization, but will not be public until your organization has been approved.'));
                 $stmt->bindValue(':organizer', $organizer['id']);
                 $stmt->bindValue(':published', 0);
             }
         } else {
             $this->addElement(Element::factory('html', 'msg', null, 'You can create events, but they will not appear in public lists until approved.'));
             $stmt->bindValue(':organizer', '');
             $stmt->bindValue(':published', 0);
             $stmt->bindValue(':venue', '');
         }
     }
     $stmt->execute();
     $eventId = $db->lastInsertId();
     Logger::messageDebug('Event ' . $this->getElementValue('title') . ' created by: ' . Session::getUser()->getUsername(), LocalEventType::CREATE_EVENT);
     redirect('viewEvent.php?id=' . $eventId, 'Event created.');
 }
コード例 #14
0
 public function __construct()
 {
     parent::__construct('formSendEmailToUser', 'Send email to user');
     Session::requirePriv('SEND_EMAIL');
     $uid = $_REQUEST['formSendEmailToUser-uid'];
     $uid = intval($uid);
     $this->user = User::getUserById($uid);
     $sql = 'SELECT o.* FROM users u LEFT JOIN organizers o ON u.organization = o.id WHERE u.id = :userId LIMIT 1';
     $stmt = DatabaseFactory::getInstance()->prepare($sql);
     $stmt->bindValue(':userId', $this->user->getId());
     $stmt->execute();
     if ($stmt->numRows()) {
         $this->organizer = $stmt->fetchRow();
     } else {
         $this->organizer = array('title' => '???', 'id' => '0');
     }
     $this->addElement(Element::factory('hidden', 'uid', null, $uid));
     $this->addElement(Element::factory('text', 'email', 'Send to', $this->user->getData('email'), 'User: <a href = "viewUser.php?id=' . $this->user->getId() . '">' . $this->user->getData('username') . '</a> Organizer: <a href = "viewOrganizer.php?id=' . $this->organizer['id'] . '">' . $this->organizer['title'] . '</a>'));
     $this->addElement(Element::factory('text', 'subject', 'Subject', 'Message from a human!'));
     $this->addElement(Element::factory('textarea', 'body', 'Body', 'Hey ' . $this->user->getUsername() . ', ' . "\n\n" . 'Your message here.' . "\n\n- lanlist.org ", 'No footer will be appended. From: mailer@lanlist.org'));
     $this->loadTemplate();
     $this->addButtons(Form::BTN_SUBMIT);
 }
コード例 #15
0
 public function __construct()
 {
     parent::__construct('formEditOrganizer', 'Edit Organizer');
     $organizer = fetchOrganizer($_REQUEST['formEditOrganizer-id']);
     if (Session::getUser()->hasPriv('PUBLISH_ORGANIZERS')) {
         $this->addElement(Element::factory('checkbox', 'published', 'Published', $organizer['published']));
     }
     $this->addElement(Element::factory('text', 'title', 'Title', $organizer['title']));
     $this->addElement(Element::factory('hidden', 'id', null, $organizer['id']));
     $this->addElement(Element::factory('text', 'websiteUrl', 'Website', $organizer['websiteUrl']));
     $this->addElement(Element::factory('date', 'assumedStale', 'Assumed stale since', $organizer['assumedStale']));
     $this->addElement(Element::factory('text', 'steamGroupUrl', 'Steam group URL', htmlify($organizer['steamGroupUrl'])));
     $this->getElement('steamGroupUrl')->setMinMaxLengths(0, 255);
     $this->addElement(Element::factory('textarea', 'blurb', 'Blurb', $organizer['blurb']));
     $this->addElement(Element::factory('file', 'banner', 'Banner image', null, 'Your organizer banner image. Preferably a PNG, maximum image size is 468x160'));
     $this->getElement('banner')->destinationDir = 'resources/images/organizer-logos/';
     $this->getElement('banner')->destinationFilename = $organizer['id'] . '.jpg';
     $this->getElement('banner')->setMaxImageBounds(468, 160);
     if (!Session::hasPriv('EDIT_ORGANIZER') && Session::getUser()->getData('organization') != $organizer['id']) {
         throw new PermissionsException();
     }
     $this->addButtons(Form::BTN_SUBMIT);
 }
コード例 #16
0
 public function __construct()
 {
     parent::__construct('formPrivsUser');
     $this->addElement(Element::factory('text', 'uid', null));
 }
コード例 #17
0
ファイル: formHandler.php プロジェクト: jamesread/lanlist.org
        }
    }
    if (!isset($form)) {
        throw new SimpleFatalError('Uh oh, form not specified!');
    }
    if (!preg_match('/^[a-z]{6,32}$/i', $form)) {
        throw new Exception('That form name looks a bit funky, please kindly poke off.');
    }
    if (!file_exists('includes/classes/' . $form . '.php')) {
        throw new Exception('Oh, I looked for that form but could not find it. Imagine my disapointment.... ');
    }
    require_once 'includes/classes/' . $form . '.php';
    if (!class_exists($form)) {
        throw new Exception('Okay now that IS weird, the file exists, but there is no class, hmm.');
    }
    $form = new $form();
    if (!$form instanceof Form) {
        throw new Exception('After all the work I went to of instanciating a form, it was not a Form.');
    }
    return $form;
}
$f = getFormUsingMagic();
$f->addElement(Element::factory('hidden', 'formClazz', null, get_class($f)));
if ($f->validate()) {
    $f->process();
    throw new Exception('Processed the form, but it didnt know what to do next... now I am sat here looking silly.');
}
define('TITLE', 'Form: ' . $f->getTitle());
require_once 'includes/widgets/header.php';
$f->display();
require_once 'includes/widgets/footer.php';
コード例 #18
0
ファイル: layout.php プロジェクト: happydemon/s4k
</head>

<body class="preview" id="top">
	<div class="navbar navbar-inverse navbar-fixed-top">
		<div class="navbar-inner">
			<div class="container">
				<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
					<span class="icon-bar"></span>
				</button>
				<a class="brand" href="#">Sentry for Kohana</a>
				<div class="nav-collapse collapse pull-right">
					<?php 
echo Element::factory('sentry')->render('Menu', null, true);
?>
				</div><!--/.nav-collapse -->
			</div>
		</div>
	</div>

	<div id="wrap">
		<div id="push"></div>
		<div class="container">
			<?php 
echo $hints;
?>
			<?php 
echo $content;
?>
コード例 #19
0
 public function __construct()
 {
     parent::__construct('formSetLocation', 'Set My Location', 'eventsMap.php');
     $this->addElement(Element::factory('text', 'location', 'Your location (postcode)'));
     $this->addButtons(Form::BTN_SUBMIT);
 }