本文整理汇总了PHP中form::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP form::validate方法的具体用法?PHP form::validate怎么用?PHP form::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类form
的用法示例。
在下文中一共展示了form::validate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
private function process()
{
$this->commonProcess();
$config = services::getService('config');
$lang = services::getService('lang');
$params = services::getService('pageParams');
$pool = new pools();
$pool->get($params->getParam('pool_id'));
$this->pool = $pool;
if ($pool->isMember($this->user->id)) {
$thread = new forumThreads();
$thread->id = $params->getParam('thread');
$thread->find();
$thread->fetch();
// new/change entry
if ($params->getParam('action') == 'new_entry') {
// formular
$form = new form('forum_entry');
$form->addElement('textarea', 'entrytext', $lang->getMsg('home_news_text'), array('rows' => 15, 'cols' => 70));
$form->addElement('hidden', 'action', 'new_entry');
$form->addElement('hidden', 'pool_id', $pool->id);
$form->addElement('hidden', 'thread', $thread->id);
$form->addElement('submit', 'entrysubmit', $lang->getMsg('home_news_submit'));
$form->addRule('entrytext', $lang->getMsg('showpool_forum_text_required'), 'required');
// write entry
if ($form->validate()) {
$new_entry = new forumEntries();
$new_entry->thread_id = $thread->id;
$new_entry->text = $form->exportValue('entrytext');
$new_entry->user_id = $this->user->id;
$new_entry->date = time();
$threads = clone $thread;
$threads->act_date = $new_entry->date;
$thread->delete();
$threads->insert();
$new_entry->insert();
$this->switchPage('threadbrowser&pool_id=' . $pool->id . '&thread=' . $threads->id . '&msg=msg_forum_entry_made');
}
$this->form = $form;
}
// build forum-tabledata
$this->thread = $thread;
// fetch entries
$entries = new forumEntries();
$entries->thread_id = $thread->id;
$entries->find();
while ($entries->fetch()) {
$entries->fetchUser();
$this->entries[$entries->id] = clone $entries;
}
} else {
$this->switchPage('showpool&pool_id=' . $pool->id . '&msg=msg_nice_try');
}
}
示例2: loginform
public function loginform($parameters = array())
{
require FRAMEWORK . DS . 'conf' . DS . 'auth.php';
require FRAMEWORK . DS . 'conf' . DS . 'dispatcher.php';
$currentuser = myauth::getCurrentuser();
$groups = $currentuser->getGroupid();
$groupfound = false;
foreach ($groups as $groupname => $groupid) {
if (isset($defaultPageids[$groupname])) {
$groupfound = true;
$defaultPageid = $defaultPageids[$groupname];
}
}
if (!$groupfound) {
$defaultPageid = $defaultPageids['default'];
}
if ($currentuser->getId() == $defaultUserid) {
$form = new form($parameters);
$username = new textField('username', 'Gebruiker', '', array('required'));
$password = new passwordField('password', 'Wachtwoord', array('required'));
$form->addField($username);
$form->addField($password);
$form->setSubmittext('Log in');
$form->setResettext('Herbegin');
$template = new ui($this);
if ($form->validate()) {
$usermodel = new userModel();
$authuser = $usermodel->auth($parameters['username'], $parameters['password']);
if ($authuser instanceof userObject) {
myauth::setCurrentuser($authuser);
// Refresh the page
$this->response->redirect('?pageid=' . $defaultPageid);
} else {
$this->response->assign('formerror_' . $form->getId(), 'innerHTML', 'De ingevulde gegevens zijn niet correct.', true);
}
} elseif (!$form->isSent()) {
$template->assign('form', $form);
$this->response->assign($this->self, 'innerHTML', $template->fetch($parameters['viewprefix'] . 'myauth_loginform.tpl'));
} else {
$this->response->assign('formerror_' . $form->getId(), 'innerHTML', 'Alle velden moeten ingevuld worden.', true);
}
} else {
$template = new ui($this);
$defrequest = new pagerequest($defaultPageid);
$template->assign('defrequest', $defrequest);
$template->assign('logoutRequest', myauth::getLogoutrequest());
$template->assign('currentuser', $currentuser);
$this->response->assign($this->self, 'innerHTML', $template->fetch($parameters['viewprefix'] . 'myauth_loginform_loggedin.tpl'));
//$this->response->assign($this->self , 'innerHTML' , '');
}
}
示例3: adddokter
public function adddokter($parameters = array())
{
require FRAMEWORK . DS . 'conf' . DS . 'mydhcpcc.php';
$view = new ui($this);
$form = new form($parameters);
$form->addField(new textField('mac', 'Mac', '', array('required', 'mac')));
$form->addField(new textField('desc', 'Omschrijving', '', array('required')));
if ($form->validate()) {
$output = array();
$lastline = exec('c:' . DS . 'plink.exe ' . $siecarehost . ' -l ' . $siecareuser . ' -i ' . $siecareppk . ' sudo /usr/sbin/adddokter ' . $form->getFieldvalue('mac') . ' ' . $form->getFieldvalue('desc') . ' && exit', $output);
if ($lastline == 'Starting dhcpd: [ OK ]') {
$form->clear();
}
$output = implode('<br />', $output);
$this->response->assign('formerror_' . $form->getId(), 'innerHTML', $output, true);
} elseif (!$form->isSent()) {
$view->assign('form', $form);
$this->response->assign($this->self, 'innerHTML', $view->fetch('mydhcpcc_adddokter.tpl'));
}
}
示例4:
/*******************************************************************************
* Action : add
*******************************************************************************/
if ($act == "add") {
$admlib->set_aktip("tourcms_destinasi");
$admlib->validate('tour_add');
$formix->init();
if ($step == 1) {
$formix->populate($form);
//print_r($app[me]);
include "tmp_add.php";
exit;
}
if ($step == 2) {
$formix->serialize_form();
$formix->validate('', 'p_nama,p_desk,p_slogan,p_alamat');
// $formix->validate('email', "p_email");
## check duplicate destinasi
$nama = $dbu->lookup("nama", "destinasi_bahasa", "nama ='" . $p_nama . "'");
if ($nama) {
$_SESSION['msg'] .= "Nama {$p_nama} sudah terpakai di Destinasi lain <br/>";
$_SESSION['alt'] = "warning";
}
##cek long lat
if ($p_poslat != "" and $p_poslong != "") {
$nama = $dbu->lookup("id", "destinasi", "pos_lat ='" . $p_poslat . "' AND pos_long ='" . $p_poslong . "'");
if ($nama) {
$_SESSION['msg'] .= "Letak Longitude Dan Latitude destinasi {$p_nama} = destinasi " . $dbu->lookup("nama", "destinasi_bahasa", "id_destinasi = {$nama}") . " <br/>";
$_SESSION['alt'] = "warning";
}
} else {
示例5: wikieditarticle
public function wikieditarticle($parameters = array())
{
$view = new ui($this);
if (!$parameters['history']) {
$this->response->addWaypoint('myarticle', 'wikieditarticle', 'wiki_' . $parameters['section'], $parameters);
}
$articlemodel = new myarticleModel();
$versionmodel = new myarticleversionModel();
$article = $articlemodel->getfromId($parameters['id']);
$closerequest = new ajaxrequest('myarticle', 'followwikibreadcrumb', array('id' => $parameters['id'], 'section' => $parameters['section']));
$view->assign('closerequest', $closerequest);
$section = new myarticlesectionObject();
$section->setId($parameters['section']);
if (count($article) == 1) {
$article = $article[0];
$view->assign('article', $article);
$aliasform = new form($parameters);
$aliasform->addField(new textField('alias', 'Werktitel', $article->getAlias(), array('required')));
$aliasform->addField(new hiddenField('id', $parameters['id']));
$aliasform->addField(new hiddenField('section', $parameters['section']));
if ($aliasform->validate()) {
$article->setAlias($aliasform->getFieldvalue('alias'));
$flash = new popupController();
try {
$articlemodel->save($article);
} catch (Exception $e) {
$flash->createflash(array('name' => 'error', 'type' => 'error', 'content' => 'De aanpassing werd niet doorgevoerd! Contacteer de informaticadienst.'));
}
$flash->createflash(array('name' => 'error', 'type' => 'success', 'content' => 'De aanpassing werd goed doorgevoerd.'));
$this->followwikibreadcrumb(array('id' => $parameters['id'], 'section' => $parameters['section']));
return true;
} elseif (!$aliasform->isSent()) {
$view->assign('aliasform', $aliasform);
}
$versionsids = $article->getVersion();
$grid = new mygrid('articleversions-' . $article->getId());
$grid->setModel(new myarticleversionModel());
$idcond = array('articleid' => array('mode' => '=', 'value' => $parameters['id']));
$grid->setDefaultconditions($idcond);
$grid->setDefaultorder(array('fields' => array('state', 'creationdate'), 'type' => 'DESC'));
$grid->registerEditrequest('myarticle', 'wikieditversion', array('id' => '{id}', 'articleid' => $parameters['id'], 'title' => 'Versie aanpassen', 'myacl' => array('target' => $section, 'right' => 'manage_articlelinks', 'default' => false)));
$view->assign('grid', $grid);
$this->response->assign('wiki_' . $parameters['section'], 'innerHTML', $view->fetch('myarticle_wiki_editarticle.tpl'));
}
}
示例6: header
}
/*******************************************************************************
* Action : add
*******************************************************************************/
if ($act == "add") {
$admlib->set_aktip("sett_conbhs");
$admlib->validate('sett_add');
$formix->init();
if ($step == 1) {
$formix->populate($form);
include "tmp_add.php";
exit;
}
if ($step == 2) {
$formix->serialize_form();
$formix->validate('', 'p_headline');
// $formix->validate('email', "p_email");
## check duplicate provinsi
$nama = $dbu->lookup("headline", "konfig_bahasa", "headline ='" . $p_headline . "' AND id_bahasa ='" . $p_bahasa . "'");
if ($nama) {
$_SESSION['msg'] .= "headline {$p_headline} sudah terpakai dengan bahasa yang sama <br/>";
$_SESSION['alt'] = "warning";
}
if ($formix->is_error()) {
$_SESSION['msg'] .= "Isi Semua Inputan ....";
$_SESSION['alt'] = "warning";
}
if ($_SESSION['msg'] != "") {
header("location: index.php?act=add&referer=" . $urlx->get_referer());
exit;
}
示例7: showstatus
public function showstatus($parameters = array())
{
$view = new ui($this);
$dienstmodel = new keukendienstModel();
$kamermodel = new keukenkamerModel();
$diensten = $dienstmodel->get();
$adiensten = array();
$kamercond = array();
foreach ($diensten as $dienst) {
if (myacl::isAllowed(myauth::getCurrentuser(), $dienst, 'view')) {
$adiensten[$dienst->getId()] = $dienst;
}
}
if (count($adiensten > 1)) {
$form = new form($parameters);
$select = new selectField('dienst', 'Dienst', array('required'), true);
$select->addOption(new selectoptionField('Alles', '_all_', true));
foreach ($adiensten as $id => $dienst) {
$select->addOption(new selectoptionField($dienst->getName(), $id));
}
$form->addField($select);
$continue = true;
if ($form->validate()) {
$all = false;
foreach ($form->getFieldvalue('dienst') as $id) {
$chosendienst[$id] = $adiensten[$id];
if ($id == '_all_') {
$all = true;
break;
}
}
if (!$all) {
$adiensten = $chosendienst;
}
$view->assign('form', $form);
} elseif (!$form->isSent()) {
$view->assign('form', $form);
} else {
$continue = false;
}
}
if ($continue) {
foreach ($adiensten as $id => $dienst) {
$kamers = $kamermodel->getfromDienstid($id);
foreach ($kamers as $kamer) {
$kamercond[] = array('kamer' => array('mode' => '=', 'value' => $kamer->getKamernr()));
}
}
if (count($kamercond) > 0) {
$kamercond = array('OR' => $kamercond);
} else {
//Geen kamers, lege lijst voorzien
$kamercond = array('kamer' => array('mode' => '=', 'value' => '-1'));
}
$model = new keukenpatientModel();
$count = $model->getcount($kamercond);
$view->assign('count', $count);
$grid = new mygrid('keukenstatus');
$grid->setModel($model);
$grid->setDefaultconditions($kamercond);
$grid->setDefaultorder(array('fields' => array('kamer', 'bed'), 'type' => 'ASC'));
$grid->registerEditrequest('keukenpakket', 'editPatient', array('title' => 'Maaltijdfiche aanpassen', 'id' => '{id}'));
$grid->setPagesize(999);
$view->assign('grid', $grid);
$this->response->assign($this->self, 'innerHTML', $view->fetch('keukenpakket_showstatus.tpl'));
}
}
示例8: form
<?php
include '../rolisz.php';
$form1 = new form(array('id' => 'test1'));
$form1->input('text', array('name' => 'user', 'pattern' => '.{6,}'))->input('password', array('name' => 'pass', 'pattern' => '[0-9]{3,5}'))->input('textarea', array('name' => 'textareaname', 'value' => 'value'))->input('select', array('name' => 'selectname', 'options' => array('o' => 'opt', 'n' => 'noopt')));
$form2 = new form(array('id' => 'test2', 'action' => 'testare'));
$form2->input('text', array('name' => 'user'))->input('password', array('name' => 'pass'))->input('radio', array('name' => 'radio'))->textarea(array('name' => 'textareaname', 'value' => 'value'))->input('select', array('name' => 'selectname', 'options' => array('o' => 'opt', 'n' => 'noopt')));
//var_dump($form1->getString());
//var_dump($form2->getString());
//$form1->show();
//$form2->show();
//$form1->validate();
$posts = rolisz::connect('MySQLi', 'localhost', 'root', '', 'rolisz');
$posts = rolisz::table('posts', 1);
$form3 = new form(array('id' => 'test3'), $posts);
$form3->input('text', array('name' => 'author', 'pattern' => function ($arg) {
if ($arg == 'rolisz') {
return true;
}
return false;
}));
$form3->removeInput('title');
var_dump($form3->getString());
$form3->show();
if (isset($_GET['send'])) {
$form3->validate();
}
示例9: adddoktervanwacht
public function adddoktervanwacht($parameters = array())
{
$view = new ui($this);
if ($parameters['history'] != 'history') {
$this->response->addWaypoint('mydoktervanwacht', 'adddoktervanwacht', 'adddoktervanwacht', array('specid' => $parameters['specid'], 'startofmonth' => $parameters['startofmonth'], 'endofmonth' => $parameters['endofmonth']));
}
$form = new form($parameters);
$form->addField(new hiddenField('specid', $parameters['specid']));
$select = new selectField('dokter', 'Dokter');
$wdokterModel = new wdokterModel();
$specmodel = new wdokterspecialismeModel();
$maindocs = $wdokterModel->getfromSpecialisme($parameters['specid']);
$mainspec = $specmodel->getfromId($parameters['specid']);
$mainoptgroup = new selectoptgroupField($mainspec[0]->getName());
foreach ($maindocs as $maindok) {
$mainoptgroup->addOption(new selectoptionField('Dr. ' . $maindok->getNaam() . ' ' . $maindok->getVoornaam(), $maindok->getId()));
}
$select->addOptgroup($mainoptgroup);
$specs = $specmodel->get(array(), array('fields' => array('name'), 'type' => 'ASC'));
foreach ($specs as $spec) {
if ($spec->getId() != $parameters['specid']) {
$tmp = new selectoptgroupField($spec->getName());
$tmpdocs = $wdokterModel->getfromSpecialisme($spec->getId());
foreach ($tmpdocs as $tmpdok) {
$tmp->addOption(new selectoptionField('Dr. ' . $tmpdok->getNaam() . ' ' . $tmpdok->getVoornaam(), $tmpdok->getId()));
}
$select->addOptgroup($tmp);
}
}
$form->addField($select);
$form->addField(new datepickerField('start', 'Start', true, mktime(0, 0, 0, date('m', $parameters['start']), date('d', $parameters['start']), date('Y', $parameters['start'])), array('required')));
$form->addField(new datepickerField('stop', 'Stop', true, mktime(23, 59, 0, date('m', $parameters['start']), date('d', $parameters['start']), date('Y', $parameters['start'])), array('required')));
$startofmonth = isset($parameters['startofmonth']) ? $parameters['startofmonth'] : mktime(00, 00, 00, date('m'), 01, date('Y'));
$endofmonth = isset($parameters['endofmonth']) ? $parameters['endofmonth'] : mktime(00, 00, 00, date('m') + 1, 01, date('Y')) - 1;
for ($i = $startofmonth; $i < $endofmonth; $i += 86400) {
$boxes[$i]['name'] = date('d/m/Y', $i);
$boxes[$i]['selected'] = false;
}
$form->addField(new checkboxgroupField('day', 'Dag', $boxes));
$form->addField(new hiddenField('startofmonth', $startofmonth));
$form->addField(new hiddenField('endofmonth', $endofmonth));
if ($form->validate()) {
if ($form->getFieldvalue('start') < $form->getFieldvalue('stop')) {
$wachtdokterModel = new wachtdokterModel();
$start = $form->getFieldvalue('start');
$stop = $form->getFieldvalue('stop');
// Overlap
//contained
$contained = array('AND' => array(array('start' => array('mode' => '<', 'value' => $start)), array('stop' => array('mode' => '>', 'value' => $stop))));
//stop after start
$stopstart = array('AND' => array(array('start' => array('mode' => '<', 'value' => $start)), array('stop' => array('mode' => '>', 'value' => $start))));
//start before stop
$startstop = array('AND' => array(array('start' => array('mode' => '<', 'value' => $stop)), array('stop' => array('mode' => '>', 'value' => $stop))));
$big = array('AND' => array(array('start' => array('mode' => '>', 'value' => $start)), array('stop' => array('mode' => '<', 'value' => $stop))));
$timecond = array('OR' => array($contained, $startstop, $stopstart, $big));
$speccond = array('specialisme' => array('mode' => '=', 'value' => $parameters['specid']));
$cond = array('AND' => array($speccond, $timecond));
$test = $wachtdokterModel->get($cond);
if (count($test) > 0) {
$this->response->assign('formerror_' . $form->getId(), 'innerHTML', 'Er mogen geen overlappingen zijn.', true);
$overlap = true;
} else {
$wachtdokter = new wachtdokterObject();
$wachtdokter->setDokter($form->getFieldvalue('dokter'));
$wachtdokter->setStart($form->getFieldvalue('start'));
$wachtdokter->setStop($form->getFieldvalue('stop'));
$wachtdokter->setSpecialisme($form->getFieldvalue('specid'));
try {
$wachtdokterModel->save($wachtdokter);
} catch (Exception $e) {
$flash = new popupController();
$flash->createflash(array('name' => 'erroredit', 'type' => 'error', 'content' => 'De gegevens werden niet aangepast! Raadpleeg de informaticadienst.'));
}
$flash = new popupController();
$flash->createflash(array('name' => 'flash_edit_' . $parameters['-gridid-'], 'type' => 'success', 'content' => 'De gegevens zijn goed aangepast.'));
$this->showspecdetails($parameters);
}
} else {
$this->response->assign('formerror_' . $form->getId(), 'innerHTML', 'Einduur moet na het beginuur liggen.', true);
}
} elseif (!$form->isSent()) {
$view->assign('form', $form);
$output = array();
$closerequest = new ajaxrequest('mydoktervanwacht', 'showspecdetails', array('specid' => $parameters['specid'], 'startofmonth' => $parameters['startofmonth'], 'endofmonth' => $parameters['endofmonth']));
$view->assign('closerequest', $closerequest);
$wachtdokterModel = new wachtdokterviewModel();
$speccond = array('specialisme' => array('mode' => '=', 'value' => $parameters['specid']));
for ($i = $startofmonth; $i < $endofmonth; $i += 86400) {
$start = array('start' => array('mode' => 'BETWEEN', 'value' => $i + 1, 'topvalue' => $i + 86400 - 1));
$stop = array('stop' => array('mode' => 'BETWEEN', 'value' => $i, 'topvalue' => $i + 86400 - 1));
$cond = array('OR' => array($start, $stop));
$dokters = $wachtdokterModel->get(array('AND' => array($speccond, $cond)));
$tmp = array();
$tmp['dokters'] = $dokters;
$tmp['start'] = $i;
$output[] = $tmp;
}
$view->assign('list', $output);
$view->assign('specialisme', $mainspec[0]);
$this->response->assign($this->self, 'innerHTML', $view->fetch('mydoktervanwacht_edit.tpl'));
//.........这里部分代码省略.........
示例10: addTicket
public function addTicket($parameters = array())
{
require FRAMEWORK . DS . 'conf' . DS . 'myticket.php';
require FRAMEWORK . DS . 'conf' . DS . 'mycafetaria.php';
$view = new ui($this);
$form = new form($parameters);
$currentuser = myauth::getCurrentuser();
$currentname = '';
$groups = $currentuser->getGroupid();
if (!isset($groups[$algemenegebruikers])) {
$currentname = $currentuser->getName();
}
if (!isset($groups[$externgroup])) {
$pricefield = 'price';
} else {
$pricefield = 'price2';
}
$form->addField(new suggesttextField('myticket', 'listusers', 'contact', 'Uw naam', $currentname, array('required')));
$dienstveld = new selectField('dienst', 'Dienst', array('required'));
$groupmodel = new groupModel();
$diensten = array();
foreach ($groups as $groupid) {
$group = $groupmodel->getfromId($groupid);
if (count($group) == 1) {
$group = $group[0];
$groupmemberof = $group->getMemberof();
$flipped = array_flip($groupmemberof);
if (isset($flipped[$meldinggroep])) {
$diensten[$group->getId()] = $group->getDescription();
}
}
}
if (count($diensten) > 1) {
$dienstveld->addOption(new selectoptionField('', '', true));
asort($diensten);
foreach ($diensten as $id => $desc) {
$dienstveld->addOption(new selectoptionField($desc, $id, false));
}
} else {
foreach ($diensten as $id => $desc) {
$dienstveld->addOption(new selectoptionField($desc, $id, true));
}
}
$form->addField($dienstveld);
$to = new selectField('to', 'Melding aan', array('required'));
$to->addOption(new selectoptionField('', ''));
$meldingdienstenmodel = new meldingdienstenModel();
$meldingdiensten = $meldingdienstenmodel->get();
foreach ($meldingdiensten as $meldingdienst) {
$to->addOption(new selectoptionField($meldingdienst->getName(), $meldingdienst->getId()));
}
$form->addField($to);
$form->addField(new textField('titel', 'Titel', '', array('required')));
$form->addField(new textareaField('message', 'Melding', '', array('required')));
if ($form->validate()) {
$ticket = new myticketObject();
$ticket->setDienstid($form->getFieldvalue('dienst'));
$ticket->setTo($form->getFieldvalue('to'));
$ticket->setContact($form->getFieldvalue('contact'));
$ticket->setTitel($form->getFieldvalue('titel'));
$ticket->setMessage($form->getFieldvalue('message'));
$ticket->setPlacedby($currentuser->getId());
$ticket->setTime(time());
$ticket->setStatus('Created');
$ticket->setUser($currentuser->getName());
$dienst = $groupmodel->getfromId($form->getFieldvalue('dienst'));
$ticket->setDienst($dienst[0]->getDescription());
$to = $meldingdienstenmodel->getfromId($form->getFieldvalue('to'));
$ticket->setToname($to[0]->getName());
$ticketmodel = new myticketModel();
$saved = true;
try {
$ticketmodel->save($ticket);
} catch (Exception $e) {
$saved = false;
}
$mailed = $this->mail($ticket);
if ($mailed) {
$ticket->setStatus('Mailed');
$ticketmodel->save($ticket);
}
$this->listmytickets();
$message = new ui($this);
$message->assign('saved', $saved);
$message->assign('mailed', $mailed);
if ($saved && $mailed) {
$type = 'success';
} elseif ($saved) {
$type = 'error';
} elseif ($mailed) {
$type = 'warning';
} else {
$type = 'error';
}
$popupcontroller = new popupController();
$popupcontroller->createflash(array('name' => 'flash_melding', 'type' => $type, 'content' => $message->fetch('myticket_saveflash.tpl')));
} elseif (!$form->isSent()) {
$view->assign('form', $form);
$this->response->assign($this->self, 'innerHTML', $view->fetch('myticket_addTicket.tpl'));
}
//.........这里部分代码省略.........
示例11: process
private function process()
{
$this->commonProcess();
$config = services::getService('config');
$lang = services::getService('lang');
$params = services::getService('pageParams');
$mail = services::getService('mail');
$categories = services::getService('cats');
$pool = new pools();
if ($pool->get($params->getParam('pool_id'))) {
// become member
if ($params->getParam('action') == 'become_member') {
if ($params->getParam('become_member_submit') || $pool->is_public) {
$new_membership = new poolsUser();
$new_membership->user_id = $this->user->id;
$new_membership->pool_id = $pool->id;
if (!$pool->is_public) {
$new_membership->wait = 1;
} else {
$new_membership->res_to_free = 1;
$new_membership->wait = 0;
}
if ($params->getParam('become_member_comments')) {
$new_membership->comments = $params->getParam('become_member_comments');
}
$new_membership->insert();
// compose E-Mails
if (!$pool->is_public) {
$tos = $pool->getAdmins();
foreach ($tos as $to) {
$mail->send('new_member', $to, $pool, $this->user, $new_membership->comments);
}
} else {
$this->switchPage('mysite&new_pool=' . $pool->id);
}
} else {
$this->become_member_form = true;
}
}
// are you waiting?
if ($pool->isWaiting($this->user->id)) {
$this->user_is_waiting = true;
}
// loose membership
if ($params->getParam('action') == 'no_member') {
// the last admin can't leave the pool
if (!$pool->isLastAdmin($this->user->id)) {
$pool->removeMember($this->user->id);
$this->addMsg('msg_leave_pool');
} else {
$this->addMsg('msg_leave_pool_last_admin');
}
}
// build tabledata
if ($pool->isMember($this->user->id)) {
$showcats = $categories->getChildren(0);
foreach ($showcats as $cat_id => $cat_name) {
$show_res = new resFetcher();
$show_res->_cat = $cat_id;
$show_res->_pools = array($pool->id);
$rescounter = $show_res->count();
if ($rescounter > 0) {
$this->cats[$cat_id] = array("name" => $cat_name, "count" => $rescounter);
}
}
$allcount = 0;
foreach ($this->cats as $cat) {
$allcount += $cat['count'];
}
$this->cats[0] = array("name" => $lang->getMsg('cat_all'), "count" => $allcount);
} else {
if (!$pool->isMember($this->user->id, true)) {
$this->not_member = true;
}
$res_counter = new poolsResources();
$res_counter->pool_id = $pool->id;
$this->res_counter = 0;
$res_counter->find();
while ($res_counter->fetch()) {
++$this->res_counter;
}
}
// build forum-tabledata
if ($pool->isMember($this->user->id)) {
// new/change entry
if ($params->getParam('action') == 'new_entry') {
// formular
$form = new form('forum_entry');
$form->addElement('text', 'entryheader', $lang->getMsg('showpool_forum_headline'), array('size' => 30, 'maxlength' => 100));
$form->addElement('textarea', 'entrytext', $lang->getMsg('home_news_text'), array('rows' => 15, 'cols' => 70));
$form->addElement('hidden', 'action', 'new_entry');
$form->addElement('hidden', 'pool_id', $pool->id);
$form->addElement('hidden', 'thread', $thread->id);
$form->addElement('submit', 'entrysubmit', $lang->getMsg('home_news_submit'));
$form->addRule('entryheader', $lang->getMsg('showpool_forum_headline_required'), 'required');
$form->addRule('entrytext', $lang->getMsg('showpool_forum_text_required'), 'required');
// write entry
if ($form->validate()) {
$new_thread = new forumThreads();
$new_thread->pool_id = $pool->id;
//.........这里部分代码省略.........
示例12: setObjectorder
public function setObjectorder($parameters = array())
{
$id = $parameters['id'];
$gridid = $parameters['gridid'];
$popup = new popupController();
$grid = new mygrid($gridid);
$model = $grid->getModel();
$linkmodel = $grid->getModel();
$object = $model->getfromId($id);
if (count($object) == 1) {
$object = $object[0];
$view = new ui($this);
$form = new form($parameters);
$form->addField(new hiddenField('gridid', $gridid));
$form->addField(new hiddenField('id', $id));
$form->addField(new textField('order', 'Order', $object->_get($grid->getOrderfield()), array('required', 'numeric', 'range:1<->' . $model->getMax($grid->getOrderfield(), $grid->getConditions()))));
if ($form->validate()) {
$curlink = $object;
if ($object->_get($grid->getOrderfield()) > $form->getFieldvalue('order')) {
$cond = array($grid->getOrderfield() => array('mode' => 'BETWEEN', 'value' => $form->getFieldvalue('order'), 'topvalue' => $object->_get($grid->getOrderfield())));
$links = $linkmodel->get(array('AND' => array($cond, $grid->getConditions())));
try {
foreach ($links as $link) {
$link->setOrder($link->getOrder() + 1);
$linkmodel->save($link);
}
$curlink->setOrder($form->getFieldvalue('order'));
$linkmodel->save($curlink);
} catch (Exception $e) {
$popup->createflash(array('name' => 'error', 'type' => 'error', 'content' => 'De wijziging is niet doorgevoerd! Raadpleeg de informaticadienst.'));
return false;
}
} elseif ($object->_get($grid->getOrderfield()) < $form->getFieldvalue('order')) {
$cond = array($grid->getOrderfield() => array('mode' => 'BETWEEN', 'value' => $object->_get($grid->getOrderfield()), 'topvalue' => $form->getFieldvalue('order')));
$links = $linkmodel->get(array('AND' => array($cond, $grid->getConditions())));
try {
foreach ($links as $link) {
$link->setOrder($link->getOrder() - 1);
$linkmodel->save($link);
}
$curlink->setOrder($form->getFieldvalue('order'));
$linkmodel->save($curlink);
} catch (Exception $e) {
$popup->createflash(array('name' => 'error', 'type' => 'error', 'content' => 'De wijziging is niet doorgevoerd! Raadpleeg de informaticadienst.'));
return false;
}
} else {
$popup->createflash(array('name' => 'warning', 'type' => 'warning', 'content' => 'De nieuwe plaats was dezelfde als de oude plaats. Er is dus niets gewijzigd.'));
$this->response->assign('gridextra_' . $gridid, 'innerHTML', '');
return false;
}
$popup->createflash(array('name' => 'success', 'type' => 'success', 'content' => 'De wijziging is goed doorgevoerd.'));
$gridcontr = new mygridController();
$gridcontr->reloadgrid($gridid);
$this->response->assign('gridextra_' . $gridid, 'innerHTML', '');
} elseif (!$form->isSent()) {
$view->assign('form', $form);
$view->assign('closeextra', new ajaxrequest('mygrid', 'closeextra', array('id' => 'gridextra_' . $gridid)));
$this->response->assign('gridextra_' . $gridid, 'innerHTML', $view->fetch($parameters['viewprefix'] . 'mygrid_setobjectorder.tpl'));
}
}
}
示例13: managepages
public function managepages($parameters = array())
{
$view = new ui($this);
if (!isset($parameters['parentid'])) {
$parentid = 0;
} else {
$parentid = $parameters['parentid'];
}
$pagemodel = new pageModel();
if ($parentid != 0) {
$currentpage = $pagemodel->getfromId($parentid);
if (count($currentpage) == 1) {
$currentpage = $currentpage[0];
if (!$parameters['history']) {
$this->response->addWaypoint('mypageadmin', 'managepages', 'pageadmin', $parameters);
}
}
}
$grid = new mygrid('pagelist_' . $parentid);
$grid->setModel($pagemodel);
$grid->setDefaultconditions(array('parentid' => array('mode' => '=', 'value' => $parentid)));
$grid->setDefaultorder(array('fields' => array('order'), 'type' => 'ASC'));
$grid->setOrderfield('order');
$grid->registerRequest('title', 'mypageadmin', 'managepages', array('parentid' => '{id}'));
if ($currentpage instanceof pageObject) {
$add = myacl::isAllowed(myauth::getCurrentuser(), $currentpage, 'addpage');
} else {
$add = myacl::isAllowed(myauth::getCurrentuser(), new securitytarget('pagemanagement'), 'addrootpage');
}
if ($add) {
$grid->registerAddrequest('mypageadmin', 'addpage', array('title' => 'Pagina toevoegen', 'parentid' => $parentid));
}
$view->assign('grid', $grid);
$pageid = $currentpage instanceof pageObject ? $currentpage->getId() : -1;
$areamodel = new areaModel();
$areas = $areamodel->get();
$modules = array();
$idcond = array('pageid' => array('mode' => '=', 'value' => $pageid));
foreach ($areas as $area) {
$areacond = array('areaid' => array('mode' => '=', 'value' => $area->getId()));
$grid = new mygrid('modules_page_' . $pageid . '_area_' . $area->getId());
$grid->setModel(new processedmodulepageModel());
$grid->setDefaultconditions(array('AND' => array($idcond, $areacond)));
$grid->setDefaultorder(array('fields' => array('order'), 'type' => 'ASC'));
$grid->setOrderfield('order');
$grid->registerAddrequest('mypageadmin', 'addmodulepagelink', array('title' => 'Module aan pagina toevoegen', 'areaid' => $area->getId(), 'pageid' => $pageid));
$modules[$area->getName()] = $grid;
}
$view->assign('modules', $modules);
if ($currentpage instanceof pageObject) {
$aclcontroller = new myaclController();
$acl = $aclcontroller->listacl(array('targetoutput' => '_return_', 'objecttype' => 'pageObject', 'objectid' => $currentpage->getId()));
$view->assign('acl', $acl);
$titleform = new form($parameters);
$titleform->addField(new textField('title', 'Titel', $currentpage->getTitle(), array('required')));
$titleform->addField(new hiddenField('parentid', $currentpage->getId()));
if ($titleform->validate()) {
$flash = new popupController();
if ($titleform->getFieldvalue('title') != $currentpage->getTitle()) {
$currentpage->setTitle($titleform->getFieldvalue('title'));
try {
$pagemodel->save($currentpage);
} catch (Exception $e) {
$flash->createflash(array('name' => 'err', 'type' => 'error', 'content' => 'De gegevens zijn niet goed bewaard! Raadpleeg de informaticadienst.'));
return false;
}
$flash->createflash(array('name' => 'success', 'type' => 'success', 'content' => 'De gegevens zijn goed bewaard.'));
} else {
$flash->createflash(array('name' => 'warning', 'type' => 'warning', 'content' => 'De nieuwe titel is gelijk aan de vorige titel.'));
}
$view->assign('titleform', $titleform);
} elseif (!$titleform->isSent()) {
$view->assign('titleform', $titleform);
} else {
return false;
}
}
$theparentid = $parentid;
$path = array();
while ($theparentid != 0) {
$parent = $pagemodel->getfromId($theparentid);
if (count($parent) == 1) {
$parent = $parent[0];
$tmp = array();
$tmp['page'] = $parent;
$tmp['request'] = new ajaxrequest('mypageadmin', 'managepages', array('parentid' => $theparentid));
$path[] = $tmp;
$theparentid = $parent->getParentid();
} else {
$theparentid = 0;
}
}
$rootpage = new pageObject();
$rootpage->setTitle('Root');
$root['page'] = $rootpage;
$root['request'] = new ajaxrequest('mypageadmin', 'managepages', array('parentid' => 0));
$path[] = $root;
$view->assign('path', array_reverse($path));
$view->assign('currentpage', $currentpage);
$this->response->assign($this->self, 'innerHTML', $view->fetch('mypageadmin_managepages.tpl'));
//.........这里部分代码省略.........
示例14: header
<?php
if (!defined('PROPER_START')) {
header("HTTP/1.0 403 Forbidden");
exit;
}
if (preg_match("/^[0-9]{2,30}\$/", $_POST['id']) != 1) {
raise(new SecurityException(iSeverity::CRITICAL, $lang['ABNORMAL_PARAMETER_VALUE']));
}
$form = new form('edit_domain');
$form->checkReferer();
$form->reset();
$form->importValues($_POST);
$form->setCheck('dir', $lang['check_dir'], formCheck::ALLTEXT, 2, 30, true);
if (preg_match("/(^\\/?\\.\\.|\\/\\.\\.\\/?\$|\\/\\.\\.\\/|\\\\|\\s)/", $_POST['dir']) > 0) {
$form->setError('dir', $lang['check_dir']);
}
$form->validate();
$home = '/dns/com/olympe-network/' . security::get('user') . '/' . $form->getValue('dir');
$sql = "UPDATE domain SET homeDirectory = '" . security::encode($home, false) . "' WHERE uid = '{$_POST['id']}'";
$userapi->query($sql, iDatabase::NO_ROW);
// LOG ACTION IN HISTORY
$sql = "SELECT Hostname FROM domain WHERE uid = '{$_POST['id']}'";
$domain = $userapi->query($sql);
$data = array('domain' => $domain['Hostname'], 'dir' => $form->getValue('dir'));
$logger = new logger();
$logger->log($data);
$form->cleanup();
$template->redirect('/panel/domains/edit?done&id=' . $_POST['id']);
示例15: header
header("location: {$app['webmin']}/index.php?act=home");
} elseif ($_SESSION['membersession']) {
header("location: {$app['webmin']}/index.php?act=member");
} else {
include "dsp_login.php";
}
exit;
}
/*******************************************************************************
* login
* gambaran : validasi login
*******************************************************************************/
if ($act == "login") {
$formix->init();
$formix->serialize_form();
$formix->validate('', 'p_uname,p_pwdx');
if ($formix->is_error()) {
$msgx->build_msg();
header("location: index.php");
exit;
}
if ($dbu->anti_sql_injection($_POST['p_uname']) and $dbu->anti_sql_injection($_POST['p_uname'])) {
// lakukan proses login
$passwordhash = md5(serialize($p_pwdx));
$sql = "select *\n\t\t\t\tfrom " . $app['table']['pengguna'] . "\n\t\t\t\twhere username = '{$p_uname}'\n\t\t\t\t\t and password = '{$passwordhash}' and status = 'aktif'\n\t\t\t\tlimit 1";
$dbu->query($sql, $rs['login'], $nr['login']);
//echo $nr['login'];exit;
if ($nr['login']) {
$formix->reset();
// $_SESSION['inline_edit'] = "on";
$_SESSION['adminsession'] = $appx->serialize64($dbu->fetch($rs['login']));