protected function alterForm(HTMLForm $form)
 {
     $form->setId('mw-resetpass-form');
     $form->setTableId('mw-resetpass-table');
     $form->setWrapperLegendMsg('resetpass_header');
     $form->setSubmitTextMsg($this->getUser()->isLoggedIn() ? 'resetpass-submit-loggedin' : 'resetpass_submit');
     $form->addButton('wpCancel', $this->msg('resetpass-submit-cancel')->text());
     $form->setHeaderText($this->msg('resetpass_text')->parseAsBlock());
     $form->addHiddenFields($this->getRequest()->getValues('wpName', 'wpDomain', 'returnto', 'returntoquery'));
 }
Ejemplo n.º 2
0
 /**
  * Show the survey.
  * 
  * @since 0.1
  * 
  * @param Survey $survey
  */
 protected function showSurvey(Survey $survey)
 {
     $fields = array();
     $fields[] = array('type' => 'hidden', 'default' => $survey->getId(), 'name' => 'survey-id', 'id' => 'survey-id');
     $fields[] = array('type' => 'hidden', 'default' => $survey->getField('name'), 'name' => 'survey-name', 'id' => 'survey-name');
     $fields[] = array('type' => 'hidden', 'default' => $survey->getField('expiry'), 'name' => 'survey-expiry', 'id' => 'survey-expiry');
     $fields[] = array('class' => 'SurveyNameField', 'default' => $survey->getField('name'), 'label-message' => 'survey-special-label-name', 'style' => 'font-weight: bold;');
     $fields[] = array('type' => 'text', 'default' => $survey->getField('title'), 'label-message' => 'survey-special-label-title', 'id' => 'survey-title', 'name' => 'survey-title');
     $fields[] = array('type' => 'check', 'default' => $survey->getField('enabled') ? '1' : '0', 'label-message' => 'survey-special-label-enabled', 'id' => 'survey-enabled', 'name' => 'survey-enabled');
     $fields[] = array('type' => 'radio', 'default' => $survey->getField('user_type'), 'label-message' => 'survey-special-label-usertype', 'id' => 'survey-user_type', 'name' => 'survey-user_type', 'options' => array(wfMsg('survey-user-type-all') => Survey::$USER_ALL, wfMsg('survey-user-type-loggedin') => Survey::$USER_LOGGEDIN, wfMsg('survey-user-type-confirmed') => Survey::$USER_CONFIRMED, wfMsg('survey-user-type-editor') => Survey::$USER_EDITOR, wfMsg('survey-user-type-anon') => Survey::$USER_ANON));
     $fields[] = array('type' => 'select', 'default' => $survey->getField('ratio'), 'label-message' => 'survey-special-label-ratio', 'id' => 'survey-ratio', 'name' => 'survey-ratio', 'options' => $this->getNumericalOptions(array_merge(array(0.01, 0.1), range(1, 100))));
     $fields[] = array('type' => 'select', 'default' => $survey->getField('min_pages'), 'label-message' => 'survey-special-label-minpages', 'id' => 'survey-min_pages', 'name' => 'survey-min_pages', 'options' => $this->getNumericalOptions(range(0, 250)));
     $fields[] = array('type' => 'text', 'default' => $survey->getField('header'), 'label-message' => 'survey-special-label-header', 'id' => 'survey-header', 'name' => 'survey-header');
     $fields[] = array('type' => 'text', 'default' => $survey->getField('footer'), 'label-message' => 'survey-special-label-footer', 'id' => 'survey-footer', 'name' => 'survey-footer');
     $fields[] = array('type' => 'text', 'default' => $survey->getField('thanks'), 'label-message' => 'survey-special-label-thanks', 'id' => 'survey-thanks', 'name' => 'survey-thanks');
     foreach ($survey->getQuestions() as $question) {
         $fields[] = array('class' => 'SurveyQuestionField', 'options' => $question->toArray());
     }
     // getContext was added in 1.18 and since that version is
     // the second argument for the HTMLForm constructor.
     if (version_compare($GLOBALS['wgVersion'], '1.18', '>=')) {
         $form = new HTMLForm($fields, $this->getContext());
     } else {
         $form = new HTMLForm($fields);
         $form->setTitle($this->getTitle());
     }
     $form->setSubmitText(wfMsg('surveys-special-save'));
     $form->addButton('cancelEdit', wfMsg('cancel'), 'cancelEdit', array('onclick' => 'window.location="' . SpecialPage::getTitleFor('Surveys')->getFullURL() . '";return false;'));
     $form->show();
 }
Ejemplo n.º 3
0
 protected function alterForm(HTMLForm $form)
 {
     $form->setId('mw-botpasswords-form');
     $form->setTableId('mw-botpasswords-table');
     $form->addPreText($this->msg('botpasswords-summary')->parseAsBlock());
     $form->suppressDefaultSubmit();
     if ($this->par !== null) {
         if ($this->botPassword->isSaved()) {
             $form->setWrapperLegendMsg('botpasswords-editexisting');
             $form->addButton(['name' => 'op', 'value' => 'update', 'label-message' => 'botpasswords-label-update', 'flags' => ['primary', 'progressive']]);
             $form->addButton(['name' => 'op', 'value' => 'delete', 'label-message' => 'botpasswords-label-delete', 'flags' => ['destructive']]);
         } else {
             $form->setWrapperLegendMsg('botpasswords-createnew');
             $form->addButton(['name' => 'op', 'value' => 'create', 'label-message' => 'botpasswords-label-create', 'flags' => ['primary', 'constructive']]);
         }
         $form->addButton(['name' => 'op', 'value' => 'cancel', 'label-message' => 'botpasswords-label-cancel']);
     }
 }
 /**
  * (non-PHPdoc)
  * @see FormSpecialPage::getForm()
  * @return HTMLForm|null
  */
 protected function getForm()
 {
     $fields = $this->getFormFields();
     if ($this->isNew()) {
         $fields['isnew'] = array('type' => 'hidden', 'default' => 1);
     }
     $form = new HTMLForm($fields, $this->getContext());
     $form->setSubmitCallback(array($this, 'handleSubmission'));
     $form->setSubmitText(wfMsg('educationprogram-org-submit'));
     $action = $this->isNew() ? 'add' : 'edit';
     $form->setWrapperLegend($this->msg(strtolower($this->getName()) . '-' . $action . '-legend'));
     $form->addButton('cancelEdit', wfMsg('cancel'), 'cancelEdit', array('target-url' => SpecialPage::getTitleFor($this->listPage)->getFullURL()));
     //		$form->addButton(
     //			'deleteEdit',
     //			wfMsg( 'delete' ),
     //			'deleteEdit'
     //		);
     return $form;
 }
Ejemplo n.º 5
0
            $form->disableInput('sitereg-language_code');
        }
        if (isset($_SESSION['inputErr'])) {
            // If any errors then add them to the form
            $form->addErrors($_SESSION['inputErr']);
            unset($_SESSION['inputErr']);
        }
        $form->addInput('hidden', 'centreID', $centreEdit->getID());
        $form->addInput('hidden', 'page', $page);
        $form->addInput('hidden', 'deleteCentre', 'false');
        $form->addInput('hidden', 'regUsers', $centreEdit->getNumUsers());
        $form->addInput('hidden', 'toggleLock', '0');
        $_SESSION['csrfToken'] = $token = base64_encode(openssl_random_pseudo_bytes(32));
        $form->addInput('hidden', 'csrfToken', $token);
        if ($user->isCentralAdmin()) {
            $form->addButton('Delete site', array('btn-danger', 'hidden'));
            if ($centreEdit->isLocked()) {
                $form->addButton('Unlock site', array('btn-warning', 'hidden'));
            } else {
                $form->addButton('Lock site', array('btn-warning', 'hidden'));
            }
        }
        $form->addCancelButton('index.php?page=sitereg');
        echo $form->writeHTML();
    }
}
if ($showSearch) {
    $sql = "SELECT count(case when privilege_id <= 10 then 1 else NULL end) AS localAdmin,\n                count(user.id) as regUsers,\n                centre.id as centreID, centre.name as centreName, country.name as countryName, datalock FROM centre\n            LEFT JOIN user ON centre_id = centre.id\n            LEFT JOIN country ON country_id = country.id";
    if ($user->isRegional()) {
        $sql .= " WHERE centre.country_id = ? GROUP BY centre.id";
        $pA = array('i', $user->getCountry());
Ejemplo n.º 6
0
    } else {
        $input = $form->addInput('textarea', 'comment', nl2br(HTML::clean($comment)));
        $input->addLabel('If required add text in here to explain any omissions or errors');
        $input->addValue($trial->record->get('flag'));
        if ($trial->user->canPreSign()) {
            $input = $form->addInput('yesno', 'presignpt');
            $input->addLabel('Mark record as complete?');
        }
        if ($trial->user->canSign()) {
            $input = $form->addInput('yesno', 'signpt');
            $input->addLabel('Sign the record off as complete and accurate?');
            $locked = false;
        }
    }
    if ($trial->user->canIgnore() && isset($_SESSION['returnTo']) && $_SESSION['returnTo'] === 'signedandflagged') {
        $form->addButton('Ignore Flags', array('btn-warning', 'ignoreFlags'));
    }
    if ($trial->user->isCentralAdmin() || $trial->user->canDelete() && !$trial->record->isSigned() && $trial->user->getCentre() == $trial->record->getCentre()) {
        $form->addButton('Delete Record', array('btn-danger', 'deleteRecord'));
    }
} elseif ($page == 'audit') {
    $creator = new eCRFUser($trial->record->get('firstuser'));
    $dt = splitDateTime($trial->record->get('created'));
    $time = $dt['time'];
    $date = convertDate($dt['date']);
    echo "<p>Record created on {$date} at {$time} by {$creator}</p>";
    $audit = $trial->record->getAuditData();
    echo "<p>Click on the arrows after the entries to expand and view changes made on each user session.</p>";
    echo "<ul class=\"checklist\">";
    $counter = 0;
    foreach ($audit as $session) {
Ejemplo n.º 7
0
        $showSearch = false;
        echo "<h4>Edit the user's details below</h4>";
        $form = new HTMLForm('process.php', 'post');
        $fields = $trial->getFormFields($page);
        $form->processFields($fields, $userEdit);
        if (isset($_SESSION['inputErr'])) {
            // If any errors then add them to the form
            $form->addErrors($_SESSION['inputErr']);
            unset($_SESSION['inputErr']);
        }
        $centre = new Data($userEdit->getCentre(), 'Centre');
        $form->addInputValue('usereg-country', $centre->get('country_id'));
        $form->addInput('hidden', 'userID', $userEdit->getID());
        $form->addInput('hidden', 'page', $page);
        $form->addInput('hidden', 'deleteUser', 'false');
        $form->addButton('Delete', array('btn-danger', 'hidden'));
        $form->addCancelButton('index.php?page=usereg');
        $_SESSION['csrfToken'] = $token = base64_encode(openssl_random_pseudo_bytes(32));
        $form->addInput('hidden', 'csrfToken', $token);
        echo $form->writeHTML();
    }
}
if ($showSearch) {
    $sql = "SELECT *, user.id as userID, centre.name as centreName, country.name as countryName, privilege.name as privilegeName, privilege_id FROM user\n        LEFT JOIN centre ON centre_id = centre.id\n        LEFT JOIN country ON country_id = country.id\n        LEFT JOIN privilege ON privilege_id = privilege.id";
    if ($user->isLocal()) {
        $sql .= " WHERE centre.id = ?";
        $pA = array('i', $user->getCentre());
        $userSearch = DB::cleanQuery($sql, $pA);
    } elseif ($user->isRegional()) {
        $sql .= " WHERE centre.country_id = ?";
        $pA = array('i', $user->getCountry());
 protected function alterForm(HTMLForm $form)
 {
     $form->setId('mw-changeemail-form');
     $form->setTableId('mw-changeemail-table');
     $form->setWrapperLegendMsg('changeemail-header');
     $form->setSubmitTextMsg('changeemail-submit');
     $form->addButton('wpCancel', $this->msg('changeemail-cancel')->text());
     $form->addHiddenField('returnto', $this->getRequest()->getVal('returnto'));
 }
 protected function alterForm(HTMLForm &$form)
 {
     $form->setDisplayFormat('div');
     // Suppress default submit, so we can add one that is slightly nicer looking
     $form->suppressDefaultSubmit();
     $form->addButton('submit', $this->msg('htmlform-submit')->text(), null, array('class' => 'btn'));
 }