本文整理汇总了PHP中History::save方法的典型用法代码示例。如果您正苦于以下问题:PHP History::save方法的具体用法?PHP History::save怎么用?PHP History::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类History
的用法示例。
在下文中一共展示了History::save方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionUnban
public function actionUnban($id)
{
$ban_model = $this->loadModel($id);
if (!Webadmins::checkAccess('bans_unban', $ban_model->admin_nick)) {
throw new CHttpException(403, "У Вас недостаточно прав");
}
$history_model = new History();
$history_model->unsetAttributes();
$history_model->player_ip = $ban_model->player_ip;
$history_model->player_id = $ban_model->player_id;
$history_model->player_nick = $ban_model->player_nick;
$history_model->admin_ip = $ban_model->admin_ip;
$history_model->admin_id = $ban_model->admin_id;
$history_model->admin_nick = $ban_model->admin_nick;
$history_model->ban_type = $ban_model->ban_type;
$history_model->ban_reason = $ban_model->ban_reason;
$history_model->ban_created = $ban_model->ban_created;
$history_model->ban_length = $ban_model->ban_length;
$history_model->server_ip = $ban_model->server_ip;
$history_model->server_name = $ban_model->server_name;
$history_model->unban_created = time();
$history_model->unban_reason = 'Разбанен с сайта';
$history_model->unban_admin_nick = Yii::app()->user->name;
if ($history_model->save()) {
if ($ban_model->delete()) {
Yii::app()->end('Игрок разбанен');
}
}
Yii::app()->end(CHtml::errorSummary($ban_model));
}
示例2: download
/**
* Find photos and download them
* @return bool True if the execution is successful
*/
public function download()
{
$unsplash = new Unsplash();
$photos = $this->getPhotos($unsplash);
$success = $this->downloadAllPhotos($photos);
$this->history->save();
return $success;
}
示例3: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'show' page.
*/
public function actionCreate()
{
$model = new History();
if (isset($_POST['History'])) {
$model->attributes = $_POST['History'];
$model->save();
}
}
示例4: actionCreate
/**
* Creates a new model.
* If creation is successful, the browser will be redirected to the 'view' page.
*/
public function actionCreate()
{
$model = new History();
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if (isset($_POST['History'])) {
$model->attributes = $_POST['History'];
if ($model->save()) {
$this->redirect(array('view', 'id' => $model->history_id));
}
}
$this->render('create', array('model' => $model));
}
示例5: createFor
static function createFor(HistoricalObjectI $object)
{
$data = $object->getDataForHistory();
if (!is_array($data)) {
$data = array($data);
}
foreach ($data as $historyDataEntry) {
$history = new History();
$history->setUserId($historyDataEntry->getUserId());
$history->setEntityType(get_class($object));
$history->setData(serialize($historyDataEntry->getData()));
$history->save();
}
}
示例6: fire
/**
* Execute the console command.
*
* @return mixed
*/
public function fire()
{
$log = new Process();
$log->name = "make-history";
$log->status = "running";
$log->save();
$today = Carbon::today();
$topToday = array();
$newspapers = Newspaper::select('id')->get();
$tags = Tag::select('id')->get();
foreach ($newspapers as $key => $n) {
$top = $this->getTopLink($today, $n->id, false);
if ($top) {
$topToday[] = $top;
}
}
foreach ($tags as $key => $t) {
$top = $this->getTopLink($today, false, $t->id);
if ($top) {
$topToday[] = $top;
}
}
$topToday = array_unique($topToday);
//Remove links for today
History::where('date', '=', $today)->delete();
//Save history
foreach ($topToday as $key => $t) {
$this->info($t->title);
try {
$h = new History();
$h->id_ref = $t->id;
unset($t->id);
$h->fill($t->toArray());
$h->date = $today;
$h->save();
} catch (Exception $e) {
}
}
$log->status = "finished";
$log->save();
}
示例7: Log
public static function Log($event,$datetime,$login,$client_id){
$history = new History();
$history->User_Login = $login;
$history->Timestamp = $datetime;
$history->Event_Type_ID = $event;
$history->Client_ID = $client_id;
$history->save();
}
示例8: actiondownload
/**
* Executes any command triggered on the admin page.
*/
public function actiondownload()
{
if (isset($_GET['name'])) {
$downloadfilename = $_GET['name'];
// is there an associated downloadable file ?
if (strlen($downloadfilename) > 0) {
$history = new History();
$history->file = $downloadfilename;
if (isset($_POST['downloadfrom'])) {
$history->category = $_POST['downloadfrom'];
} else {
$history->category = 'DOWNLOAD_PUBLIC';
}
if ($history->validate()) {
$history->save();
}
$d_downloadurl = Yii::app()->baseUrl . '/uploads/' . Yii::app()->params['sitefileName'] . '/' . $downloadfilename;
$d_loaderpathname = Yii::app()->lib_tools->get_downloader();
$d_loaderFullUrl = $d_loaderpathname . '?filename=' . $downloadfilename;
$this->redirect($d_loaderFullUrl);
}
// end downloadable
}
}
示例9: History
function add_to_history($message)
{
$h = new History();
$h->message = $message;
$h->save($this->auth_user_id);
}
示例10: explode
function manage_content($content_id, $method = 'post', $match_album_visibility = false)
{
if (strpos($content_id, ',') !== FALSE) {
$ids = explode(',', $content_id);
} else {
$ids = array($content_id);
}
$h = new History();
if ($this->album_type == 0) {
$c = new Content();
$members = $this->contents->select('id,lg_preview')->get_iterated();
$member_ids = array();
foreach ($members as $member) {
$member_ids[] = $member->id;
}
$contents = $c->where_in('id', $ids)->order_by('id ASC')->get_iterated();
$added_ids = array();
foreach ($contents as $content) {
if (!$content->exists()) {
return false;
}
$covers_count = $this->covers->count();
switch ($method) {
case 'post':
if ($this->save($content)) {
if (!in_array($content->id, $member_ids)) {
if ($covers_count < 3 && ($content->visibility == 0 && ($content->file_type == 0 || $content->lg_preview))) {
$this->save_cover($content);
}
$this->update_counts(false);
$this->save();
$this->set_join_field($content, 'order', $this->total_count);
}
$added_ids[] = $content->id;
}
break;
case 'delete':
if (in_array($content->id, $member_ids)) {
$this->delete($content);
$this->delete_cover($content);
$this->save();
$this->reset_covers();
}
break;
}
}
if (count($added_ids) && !is_null($this->visibility) && $match_album_visibility) {
$change = new Content();
$change->where_in('id', $added_ids)->where('visibility !=', $this->visibility)->where('visibility <', 2)->update(array('visibility' => $this->visibility));
}
if (count($ids) == 1) {
$message = 'content:move';
$c = $content->filename;
} else {
$message = 'content:move:multiple';
$c = count($ids);
}
} else {
$a = new Album();
switch ($method) {
case 'post':
case 'delete':
$this->db->trans_begin();
foreach ($ids as $move_id) {
$d = new Album();
$dest_copy = $d->select('level,left_id,right_id')->get_by_id($this->id);
$move_copy = $a->select('visibility,level,left_id,right_id')->get_by_id($move_id);
if ($method == 'post') {
$destination_left = $dest_copy->right_id;
$delta = $dest_copy->level - $move_copy->level + 1;
$delta = $delta >= 0 ? '+ ' . $delta : '- ' . abs($delta);
$level_delta = 'level ' . $delta;
if (isset($_POST['match_album_visibility']) && $_POST['match_album_visibility'] > 0) {
$this->_do_match_visibility(array('left_id' => $move_copy->left_id, 'right_id' => $move_copy->right_id, 'visibility' => $this->visibility));
}
} else {
// For removals, we simply move the object back to the root
$max = new Album();
$max->select_max('right_id')->get();
$destination_left = $max->right_id;
$level_delta = 'level - ' . abs(1 - $move_copy->level);
$destination_left++;
}
$left = $move_copy->left_id;
$right = $move_copy->right_id;
$size = $right - $left + 1;
$a->shift_tree_values($destination_left, $size, $this->visibility);
if ($move_copy->left_id >= $destination_left && $move_copy->visibility == $this->visibility) {
$left += $size;
$right += $size;
}
$delta = $destination_left - $left;
$delta = $delta >= 0 ? '+ ' . $delta : '- ' . abs($delta);
$a->where('left_id >=', $left)->where('right_id <=', $right)->where('visibility', $move_copy->visibility)->update(array('left_id' => "left_id {$delta}", 'right_id' => "right_id {$delta}", 'visibility' => $this->visibility, 'level' => $level_delta), false);
$a->where('visibility', 1)->where('published_on', NULL)->update(array('published_on' => time()));
$a->shift_tree_values($right + 1, -$size, $move_copy->visibility);
}
$this->update_set_counts();
$this->db->trans_complete();
break;
//.........这里部分代码省略.........
示例11: amend
public function amend($post_id, $content)
{
$block = new SuccessBlock();
$block->data->prev_path = sprintf("/s/%s/posts/%d", $this->getSectionTitleFromId($post_id), $post_id);
if ($block->success) {
if (Auth::user()->points < 1) {
$block->success = false;
$block->errors[] = "not enough points";
}
}
if ($block->success) {
$post = $this->findOrFail($post_id);
if ($post->user_id != Auth::user()->id) {
$block->success = false;
$block->errors[] = 'This post does not have the same user id as you';
}
}
if ($block->success) {
$data['user_id'] = Auth::user()->id;
$data['data'] = $content;
$data['markdown'] = $data['data'];
$data['data'] = Markdown::defaultTransform(e($data['markdown']));
$rules = array('user_id' => 'required|numeric', 'markdown' => 'required|max:' . Constant::POST_MAX_MARKDOWN_LENGTH);
$validate = Validator::make($data, $rules);
if ($validate->fails()) {
$block->success = false;
foreach ($validate->messages()->all() as $v) {
$block->errors[] = $v;
}
}
}
if ($block->success) {
$history = new History();
$history->data = $post->data;
$history->markdown = $post->markdown;
$history->user_id = Auth::user()->id;
$history->type = Constant::POST_TYPE;
$history->type_id = $post->id;
$history->save();
$post->markdown = $data['markdown'];
$post->data = $data['data'];
$post->save();
}
return $block;
}
示例12: amend
public function amend($comment_id, $content)
{
$block = new SuccessBlock();
if ($block->success) {
if (Auth::user()->points < 1) {
$block->success = false;
$block->errors[] = 'You need at least one point to edit a comment';
}
}
if ($block->success) {
$comment = $this->findOrFail($comment_id);
if ($comment->user_id != Auth::user()->id) {
$block->success = true;
$block->errors[] = 'This comment does not have the same user id as you';
}
}
if ($block->success) {
$data['user_id'] = Auth::user()->id;
$data['data'] = Markdown::defaultTransform(e($content));
$data['markdown'] = $content;
$rules = array('user_id' => 'required|numeric', 'markdown' => 'required|max:' . Constant::COMMENT_MAX_MARKDOWN_LENGTH);
$validate = Validator::make($data, $rules);
if ($validate->fails()) {
$block->success = false;
foreach ($validate->messages()->all() as $v) {
$block->errors[] = $v;
}
}
}
if ($block->success) {
$history = new History();
$history->data = $comment->data;
$history->markdown = $comment->markdown;
$history->user_id = Auth::user()->id;
$history->type = Constant::COMMENT_TYPE;
$history->type_id = $comment->id;
$history->save();
Cache::forget(Constant::COMMENT_CACHE_NEWLIST_NAME . $comment->post_id);
$comment->markdown = $data['markdown'];
$comment->data = $data['data'];
$comment->save();
}
return $block;
}
示例13: array
case 'transformation':
include '../../../include/header.php';
$conflictsMap = array();
$uploadsMap = getUploadsMap($conflictsMap);
$filesystemErrors = array();
$filesystemWarnings = array();
$filesystemValid = filesystemValidator($filesystemErrors, $filesystemWarnings, $conflictsMap);
// todo: check for variables!
// todo: rs braucht "name" für "Anmerkungen"
$excel = new Excel($mediaPath . $_REQUEST['userfile']);
$tableErrors = array();
$tableWarnings = array();
$tableValid = tableValidator($tableErrors, $tableWarnings, $excel);
$mapper = new Mapper($excel, $_REQUEST);
$template = $_REQUEST['remarktemplate'];
History::save($excel, $_REQUEST['keyfield'], $template, $_REQUEST);
$filenameCol = $mapper->getColByName("filename");
if ($filenameCol == null) {
View::debug("Filename not provided", 1);
}
// check for files to exist
// $ret = checkForFiles( $excel, $mapper->getColByName( "filename" ), $uploadsMap );
// if( $ret !== 0 ) {
// View::debug( "Could not find file ".$ret, 1 );
// // break;
// }
$xml_source = null;
$md5r = null;
// generate all Resources
$rowErrors = array();
$rowWarnings = array();