本文整理汇总了PHP中sfWebRequest::getPostParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP sfWebRequest::getPostParameter方法的具体用法?PHP sfWebRequest::getPostParameter怎么用?PHP sfWebRequest::getPostParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfWebRequest
的用法示例。
在下文中一共展示了sfWebRequest::getPostParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeIndex
/**
* Performs the logic for logging into the LWS backend CMS.
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->setLayout('login');
if ($request->isMethod('POST')) {
$dao = new DAO();
$pw = md5($dao->getEscapedSQLString(trim($request->getPostParameter('pw'))));
$email = $dao->getEscapedSQLString(trim(strtolower($request->getPostParameter('email'))));
$dao->query("\n \t\t\tSELECT be_user.*, role \n \t\t\tFROM be_user INNER JOIN be_role USING(role_id) \n \t\t\tWHERE email='{$email}' AND password='{$pw}' LIMIT 1\n \t\t");
if ($dao->queryOK()) {
$user = $dao->next();
$dao->query("SELECT last_login_ts FROM be_user WHERE email='{$user['email']}'");
// I know that there is a record in the DB with this email, so no need to check
$ts_row = $dao->next();
$last_login = is_null($ts_row['last_login_ts']) ? 'N/A' : date('M jS Y @ g:i A', $ts_row['last_login_ts']);
$dao->query("UPDATE be_user SET last_login_ts=UNIX_TIMESTAMP() WHERE email='{$user['email']}'");
$this->getUser()->setAttribute('be_user', array('first_name' => $user['first_name'], 'last_name' => $user['last_name'], 'full_name' => "{$user['first_name']} {$user['last_name']}", 'email' => $user['email'], 'role' => $user['role'], 'phone' => $user['phone'], 'phone_ext' => $user['phone_ext'], 'last_login' => $last_login, 'password' => $user['password']));
$this->getUser()->setAuthenticated(true);
$this->getUser()->addCredential($user['role']);
} else {
if ($this->getUser()->hasAttribute('be_user')) {
$this->getUser()->getAttributeHolder()->remove('be_user');
}
$this->getUser()->setAuthenticated(false);
$this->getUser()->setFlash('login_error', 'Invalid email and/or password!');
}
// allows users to go directly to requested page after login
$uri = $this->getContext()->getRouting()->getCurrentInternalUri(true);
$this->redirect($uri);
}
return sfView::SUCCESS;
}
示例2: executeCreate
public function executeCreate(sfWebRequest $request)
{
$this->form = new ServersForm();
if ($request->getMethod() == sfWebRequest::POST) {
$this->form->bind($request->getPostParameter($this->form->getName()));
if ($this->form->isValid()) {
if (!preg_match("!^\\d+.\\d+.\\d+.\\d+:\\d+\$!", $this->form->getValue("ip"))) {
$datas = $request->getPostParameter($this->form->getName());
$added = array();
$counter = 1;
$name = $this->form->getValue("hostname");
if (preg_match("!^(\\d+).(\\d+).(\\d+).(?<start>\\d+)\\-(?<end>\\d+):(\\d+)\$!", $this->form->getValue("ip"), $match)) {
for ($i = $match["start"]; $i <= $match["end"]; $i++) {
$ip = $match[1] . "." . $match[2] . "." . $match[3] . "." . $i . ":" . $match[6];
$datas["ip"] = $ip;
$datas["hostname"] = $name . " #" . $counter++;
$this->form = new ServersForm();
$this->form->bind($datas);
$this->form->save();
$added[] = $ip;
}
} elseif (preg_match("!^(\\d+).(\\d+).(\\d+).(?<start>\\d+)\\-(?<end>\\d+):(?<port>[0-9\\-]+)\$!", $this->form->getValue("ip"), $match)) {
$ports = explode("-", $match["port"]);
for ($i = $match["start"]; $i <= $match["end"]; $i++) {
foreach ($ports as $port) {
$ip = $match[1] . "." . $match[2] . "." . $match[3] . "." . $i . ":" . $port;
$datas["ip"] = $ip;
$datas["hostname"] = $name . " #" . $counter++;
$this->form = new ServersForm();
$this->form->bind($datas);
$this->form->save();
$added[] = $ip;
}
}
} elseif (preg_match("!^(\\d+).(\\d+).(\\d+).(\\d+):(?<port>[0-9\\-]+)\$!", $this->form->getValue("ip"), $match)) {
$ports = explode("-", $match["port"]);
foreach ($ports as $port) {
$ip = $match[1] . "." . $match[2] . "." . $match[3] . "." . $match[4] . ":" . $port;
$datas["ip"] = $ip;
$datas["hostname"] = $name . " #" . $counter++;
$this->form = new ServersForm();
$this->form->bind($datas);
$this->form->save();
$added[] = $ip;
}
} else {
$this->getUser()->setFlash("notification_error", $this->__("Unknown Server-Format"));
}
if (count($added) > 0) {
$this->getUser()->setFlash("notification_ok", count($added) . $this->__(" server were added ") . "(" . implode(", ", $added) . ")");
$this->redirect("servers_create");
}
} else {
$server = $this->form->save();
$this->getUser()->setFlash("notification_ok", $this->__("1 Server was added with IP (") . $server->getIp() . ")");
$this->redirect("servers_create");
}
}
}
}
示例3: executeNew
public function executeNew(sfWebRequest $request)
{
if ($request->getMethod() != "POST") {
return;
}
$this->username = $request->getPostParameter("username");
if (!$this->username) {
return $this->setErrorMsg("Username is a required field!");
}
$this->user = UserDAO::getUser($this->username);
if ($this->user) {
return $this->setErrorMsg("That username is already in use!");
}
$this->password1 = $request->getPostParameter("password1");
$this->password2 = $request->getPostParameter("password2");
if (!$this->password1 || !$this->password2) {
return $this->setErrorMsg("Password is a required field");
}
if ($this->password1 != $this->password2) {
return $this->setErrorMsg("Password and password confirm must match!");
}
$this->email = $request->getPostParameter("email");
$this->user = UserDAO::createUser($this->username, $this->password1, $this->email);
$this->login($this->user);
$this->redirect("dashboard/index");
}
示例4: execute
/**
* Action permettant d'enregistrer ou de mettre à jour automatiquement un device
*
* @param sfWebRequest $request
*/
public function execute($request)
{
$this->getResponse()->setContentType('application/json');
$this->setLayout(false);
if ($request->getPostParameter('drivers') == null) {
$response = array("error" => "Error with the post parameters drivers.", "success" => false);
} else {
$JSONArray = json_decode($request->getPostParameter('drivers'));
//die("json: ".$JSONArray. " / error:".json_last_error());
$device_identifier = $request->getParameter('device_identifier');
$device_type_name = $request->getParameter('device_type');
$response = array("error" => "An error occured when we try to create / update the device.", "success" => false);
try {
$device = Doctrine_Core::getTable("EiDevice")->findOneBy("device_identifier", $device_identifier);
if ($device != null) {
/* Si le device existe, on efface ses drivers (les browsers sont effacés en cascade) */
$device_drivers = $device->getEiDeviceDriver();
foreach ($device_drivers as $device_driver) {
$device_driver->delete();
}
} else {
/* Sinon on créé ce device */
$device = new EiDevice();
$device->setDeviceIdentifier($device_identifier);
$device_type = Doctrine_Core::getTable('EiDeviceType')->findOneBy('hidden_name', $device_type_name);
$device->setDeviceTypeId($device_type);
$device->save();
}
/* On créé les drivers et browsers de ces drivers pour le device */
foreach ($JSONArray as $driver) {
$driver_type_name = $driver->{'driver_type'};
$driver_type = Doctrine_Core::getTable("EiDriverType")->findOneBy("hidden_name", $driver_type_name);
$device_driver = new EiDeviceDriver();
$device_driver->setDeviceId($device->getId());
$device_driver->setDriverTypeId($driver_type->getId());
$device_driver->save();
foreach ($driver->{'browsers'} as $browser_name) {
$browser_type = Doctrine_Core::getTable("EiBrowserType")->findOneBy("hidden_name", $browser_name);
$driver_browser = new EiDriverBrowser();
$driver_browser->setDeviceDriverId($device_driver->getId());
$driver_browser->setBrowserTypeId($browser_type->getId());
$driver_browser->save();
}
}
unset($response["error"]);
$response["success"] = true;
} catch (Exception $e) {
$response = array("error" => "Exception : An error occured when we try to create / update the device: " . $e->getMessage());
}
}
return $this->renderText(json_encode($response));
}
示例5: executeSearch
public function executeSearch(sfWebRequest $request)
{
if ($request->getParameter('flag') == 'movie') {
$q = Doctrine_Query::create()->select('DISTINCT a.id')->from('Actor a, MovieActor m')->where('a.id = m.actor_id')->andWhere('a.name LIKE ?', $request->getPostParameter('value'))->orderBy('a.name ASC');
$this->actors = $q->execute();
$this->flag = 'movies';
} else {
$q = Doctrine_Query::create()->select('DISTINCT a.id')->from('Actor a, TVShowActor m')->where('a.id = m.actor_id')->andWhere('a.name LIKE ?', $request->getPostParameter('value'))->orderBy('a.name ASC');
$this->actors = $q->execute();
$this->flag = 'tvshows';
}
$this->setTemplate('index');
}
示例6: executeEdit
public function executeEdit(sfWebRequest $request)
{
$this->config = $this->getRoute()->getObject();
$this->form = new configsForm($this->config);
if ($request->getMethod() == sfWebRequest::POST) {
$this->form->bind($request->getPostParameter($this->form->getName()));
if ($this->form->isValid()) {
$config = $this->form->save();
$config->setContent($request->getPostParameter('config'));
$config->save();
$this->getUser()->setFlash("notification_ok", $this->__("Config edited successfully."));
$this->redirect("configs/index");
}
}
}
示例7: executeReturn
public function executeReturn(sfWebRequest $request)
{
//--------------------------------------------------------------------------
// if txn_id is posted, we can assume that PDT (Payment Data Transfer) is
// inactive and return method has been set to 2
// PDT is not tested yet and requires additional investigation
//--------------------------------------------------------------------------
if ($request->getPostParameter('txn_id')) {
//--------------------------------------------------------------------------
// instanciate application specific Paypal Interface
//--------------------------------------------------------------------------
$pp_class = sfConfig::get('app_es_paypal_plugin_handler', 'esPaypalHandler');
$pp = new $pp_class();
//--------------------------------------------------------------------------
// handle data posted by Paypal (store as transaction)
//--------------------------------------------------------------------------
$transaction = $pp->handleReturn($request->getPostParameters());
$this->data = $request->getPostParameters();
$this->relatedEntity = $pp->getRelatedEntity();
$this->transaction = $transaction;
} else {
$this->data = $request->getGetParameters();
}
$this->handleReturn($this->data);
}
示例8: executeUpload
public function executeUpload(sfWebRequest $request)
{
$language = LanguageTable::getInstance()->find($request->getParameter('id'));
/* @var $language Language */
if (!$language) {
return $this->notFound();
}
if ($request->getPostParameter('csrf_token') == UtilCSRF::gen('language_upload', $language->getId())) {
$this->ajax()->setAlertTarget('#upload', 'append');
$file = $request->getFiles('file');
if ($file && $file['tmp_name']) {
$parser = new sfMessageSource_XLIFF();
if ($parser->loadData($file['tmp_name'])) {
$dir = dirname($language->i18nFileWidget());
if (!file_exists($dir)) {
mkdir($dir);
}
move_uploaded_file($file['tmp_name'], $language->i18nFileWidget());
$language->i18nCacheWidgetClear();
return $this->ajax()->alert('Language file updated.', '', null, null, false, 'success')->render(true);
}
return $this->ajax()->alert('File invalid.', '', null, null, false, 'error')->render(true);
}
return $this->ajax()->alert('Upload failed.', '', null, null, false, 'error')->render(true);
}
return $this->notFound();
}
示例9: executeSelectorNodeForm
public function executeSelectorNodeForm(sfWebRequest $request)
{
$versionId = $request->getParameter("ei_version_id") ? $request->getParameter("ei_version_id") : $this->ei_version_id;
/** @var EiVersion $version */
$version = Doctrine_Core::getTable("EiVersion")->find($versionId);
$tree = null;
$selected = null;
if ($request->getMethod() === "POST") {
$blockForeach = $request->getPostParameter("ei_block_foreach");
if ($blockForeach != null && isset($blockForeach["Iterator"]["ei_dataset_structure_id"])) {
$selected = $blockForeach["Iterator"]["ei_dataset_structure_id"];
}
} elseif (isset($this->block) && $this->block instanceof EiBlockForeach) {
$selected = $this->block->getIteratorMapping()->getEiDataSetStructureMapping()->getId();
}
if ($version != null && $version->getId() != "") {
/** @var EiDataSetStructureTable $tableStructure */
$tableStructure = Doctrine_Core::getTable("EiDataSetStructure");
// Réupération de la structure du scénario.
$structures = $tableStructure->getTreeArrayForITree($version->getEiScenarioId(), array(EiDataSetStructure::$TYPE_NODE));
// Création du TreeViewer.
$treeViewer = new TreeViewer("EiDataSetStructure");
$treeViewer->import($structures);
// TreeViewer pour le mapping.
$tree = new TreeView($treeViewer, new ModeSelectInHiddenInputTreeStrategy(), array("id" => "select_node_iterator_" . time(), "formats" => array("node" => EiNodeDataSet::getFormNameFormat(), "leaf" => EiLeafDataSet::getFormNameFormat()), "inputTarget" => "ei_block_foreach_Iterator_ei_dataset_structure_id", "selected" => $selected, "actions" => array()));
}
$this->tree = $tree;
}
示例10: executePriceUpdate
public function executePriceUpdate(sfWebRequest $request)
{
if ($request->isMethod('POST')) {
$display = $request->getPostParameter('display');
$part_no = $request->getPostParameter('part_no');
$dao = new BE_DAO();
$dao->query("UPDATE store set display={$display} WHERE part_no='{$part_no}'");
if ($dao->UpdateOK()) {
$cp_msg = "{$part_no} pricing has been updated successfully.";
} else {
$err = $dao->getError();
$cp_msg = "There was an error trying to update the price for {$part_no}.<br />MySQL Error: {$err}";
}
$this->getUser()->setFlash('cp_msg', $cp_msg);
$this->redirect('@control_panel');
}
return sfView::NONE;
}
示例11: executeFilters
public function executeFilters(sfWebRequest $request)
{
$this->filter = new MatchsFormFilter();
$this->filter->bind($request->getPostParameter($this->filter->getName()));
if ($this->filter->isValid()) {
$this->setFilters($this->filter->getValues());
}
$this->redirect($request->getReferer());
}
示例12: executeCreateBooking
public function executeCreateBooking(sfWebRequest $request)
{
if ($this->getUser()->isAuthenticated()) {
$app = Doctrine_Core::getTable('Apartment')->find($request->getPostParameter('apid'));
$date_from = $request->getPostParameter('date_from');
$date_to = $request->getPostParameter('date_to');
$pax = $request->getPostParameter('pax');
$booking = new Booking();
$booking->Apartment = $app;
$booking->pax = $pax;
$booking->date_from = $date_from;
$booking->date_to = $date_to;
$booking->DoBooking($this->getUser()->getGuardUser());
$this->success = true;
} else {
return sfView::NONE;
/* Log this !*/
}
}
示例13: execute
/**
* Action permettant de récupérer l'arbre des jeux de données.
*
* @param sfWebRequest $request
*/
public function execute($request)
{
$this->logger = sfContext::getInstance()->getLogger();
$this->logger->info("----------------------------------------------------------");
$this->logger->info("--- DEBUT RECUPERATION ARBRE DATA SET");
$this->getResponse()->setContentType('application/json');
$this->setLayout(false);
$response = array("error" => "An error occured when we try to create your directory.");
try {
$this->getUser()->signIn($this->user, true);
/** @var EiNodeTable $tableEiNode */
$tableEiNode = Doctrine_Core::getTable("EiNode");
// Récupération des données.
$nom = $request->getPostParameter("name");
$parentNodeId = $request->getPostParameter("parent_node_id");
if ($nom == null || $parentNodeId == null) {
$response["error"] = "You have to select a parent directory and type a valid directory name";
} else {
/** @var EiNode $parentNode Récupération du noeud parent. */
$parentNode = $tableEiNode->find($parentNodeId);
if ($parentNode != null && $parentNode->getId() != "" && $parentNode->getEiScenarioNode()->getObjId() == $this->scenario->getId()) {
try {
$folder = new EiNode();
$folder->setName($nom);
$folder->setType(EiNode::$TYPE_DATASET_FOLDER);
$folder->setProjectId($parentNode->getProjectId());
$folder->setProjectRef($parentNode->getProjectRef());
$folder->setRootId($parentNode->getId());
$folder->save();
unset($response["error"]);
$response["id"] = $folder->getId();
} catch (Exception $exc) {
$response["error"] = "An error occured when we tried to create directory : " . $exc->getMessage();
}
} else {
$response["error"] = "We are not able to accommodate your request.";
}
}
} catch (Exception $e) {
$response = array();
}
return $this->renderText(json_encode($response));
}
示例14: executeAddToCart
public function executeAddToCart(sfWebRequest $request)
{
$product = timpanyProductTable::getInstance()->findOneBySlug($request->getParameter('product'));
$count = $request->getPostParameter('timpany_add_to_cart[count]', 1);
$this->cart = timpanyCart::getInstance($this->getUser());
$this->cart->addProduct($product, $count);
$this->cart->save();
$this->getUser()->setFlash('last_added_product', $product->getSlug());
$this->redirect('@timpany_cart');
}
示例15: executeAddWallpost
public function executeAddWallpost(sfWebRequest $request)
{
$message = $request->getPostParameter('message');
$source_id = $this->getUser()->getAttribute('viewing_profile_id');
$actor_id = $this->getUser()->getAttribute('id');
$stream = new Stream();
$stream->message = $message;
$stream->actor_id = $actor_id;
$stream->source_id = $source_id;
$stream->save();
$this->redirect('profile/index?uid=' . $source_id);
}