本文整理汇总了PHP中action::add_success方法的典型用法代码示例。如果您正苦于以下问题:PHP action::add_success方法的具体用法?PHP action::add_success怎么用?PHP action::add_success使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类action
的用法示例。
在下文中一共展示了action::add_success方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: post
/**
* inserts a new idea in the database
*
* @param string $title title of the idea
* @param string $message message of the idea
* @param string $anonymization tells if idea is to be anonymized
* @param integer $category id of the category for the idea
* @param string $login login of the poster
* @param integer $valid says if the idea needs to be moderated (default 0 = needs moderation)
* @return array
*/
function post($title, $message, $anonymization, $category, $login, $valid = 0)
{
$action = new action();
$action->result = False;
$check_1 = isset($title) && !empty($title);
$check_2 = isset($message) && !empty($message);
$check_3 = !isset($anonymization) || $anonymization == "on";
$check_4 = isset($category) && is_numeric($category) && $category > 0;
// V�rification des arguments
if ($check_1) {
$title_prec = $title;
} else {
$action->add_warning(_('Titre incorrect'));
}
if ($check_2) {
$text_prec = $message;
} else {
$action->add_warning(_('Message incorrect'));
}
if ($check_3) {
if (isset($anonymization)) {
$anon_prec = "on";
}
} else {
$action->add_warning(_('Incorrect anonymization value'));
}
if ($check_4) {
$cate_prec = $category;
} else {
$action->add_warning(_('Catégorie incorrecte'));
}
if ($check_1 && $check_2 && $check_3 && $check_4) {
$title_prec_sec = mysql_real_escape_string($title_prec);
$text_prec_sec = mysql_real_escape_string($text_prec);
$cate_prec_sec = mysql_real_escape_string($cate_prec);
$rand_prop = mt_rand(0, 65535);
$hash_prop = sha1($login . $rand_prop);
if ($anon_prec == "on") {
$name_print = "";
} else {
$name_print = mysql_real_escape_string(construct_name_from_session());
}
if (@mysql_query("INSERT INTO `thread` (`thread_id`,`rand_prop`,`hash_prop`,`title`,`text`,`date`,`category`,`is_valid`,`possibly_name`) VALUES (NULL, '{$rand_prop}', '{$hash_prop}','{$title_prec_sec}','{$text_prec_sec}',CURRENT_TIMESTAMP,'{$cate_prec_sec}',{$valid},'{$name_print}')")) {
$action->add_success(_('Ta proposition a bien été ajoutée et est en attente de modération'));
$action->result = True;
} else {
$action->add_warning(_('Ta proposition n\'a pas pu être ajoutée suite à une erreur de transfert.'));
}
}
return $action;
}
示例2: post
/**
* inserts a new idea in the database
*
* @param string $title title of the idea
* @param string $message message of the idea
* @param string $anonymization tells if idea is to be anonymized
* @param integer $category id of the category for the idea
* @param string $login login of the poster
* @param integer $valid says if the idea needs to be moderated (default 0 = needs moderation)
* @return array
*/
function post($title, $message, $anonymization, $category, $login, $valid = 0, $output = '', $latitude = 0, $longitude = 0)
{
$action = new action();
$action->set_result(False);
$check_1 = isset($title) && !empty($title);
$check_2 = isset($message) && !empty($message);
$check_3 = !isset($anonymization) || $anonymization == "on";
$check_4 = isset($category) && is_numeric($category) && $category > 0;
// Vérification des arguments
if ($check_1) {
$title_prec = $title;
} else {
$action->add_warning(_('Incorrect title'));
}
if ($check_2) {
$text_prec = $message;
} else {
$action->add_warning(_('Incorrect message'));
}
if ($check_3) {
if (isset($anonymization)) {
$anon_prec = "on";
}
} else {
$action->add_warning(_('Incorrect anonymization value'));
}
if ($check_4) {
$cate_prec = $category;
} else {
$action->add_warning(_('Incorrect category'));
}
if ($check_1 && $check_2 && $check_3 && $check_4) {
$title_prec_sec = mysql_real_escape_string($title_prec);
$text_prec_sec = mysql_real_escape_string($text_prec);
$cate_prec_sec = mysql_real_escape_string($cate_prec);
$rand_prop = mt_rand(0, 65535);
$hash_prop = sha1($login . $rand_prop);
if ($anon_prec == "on") {
$name_print = "";
} else {
$name_print = mysql_real_escape_string(construct_name_from_session());
}
if ($latitude != 0 && $longitude != 0) {
$geolocalization = ',`latitude`,`longitude`';
$geolocalization_values = ",{$latitude},{$longitude}";
} else {
$geolocalization = '';
$geolocalization_values = '';
}
if (@mysql_query("INSERT INTO `thread` (`thread_id`,`rand_prop`,`hash_prop`,`title`,`text`,`date`,`category`,`is_valid`,`already_mod`,`possibly_name`" . $geolocalization . ") VALUES (NULL, '{$rand_prop}', '{$hash_prop}','{$title_prec_sec}','{$text_prec_sec}',CURRENT_TIMESTAMP,'{$cate_prec_sec}',{$valid},{$valid},'{$name_print}'" . $geolocalization_values . ")")) {
$action->add_success(_('The idea was added to Refresh and now has to be moderated'));
$action->set_result(True);
} else {
$action->add_warning(_('The idea could not be added due to a database error'));
}
}
$action->output_result($output);
return $action;
}