本文整理汇总了PHP中log::activity方法的典型用法代码示例。如果您正苦于以下问题:PHP log::activity方法的具体用法?PHP log::activity怎么用?PHP log::activity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类log
的用法示例。
在下文中一共展示了log::activity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
public function add()
{
if ($_POST) {
$post = new Validation($_POST);
$post->add_rules('title', 'required');
$post->add_rules('seoURL', 'required');
if ($post->validate()) {
$page = ORM::factory('page');
foreach ($post as $key => $val) {
// Set user data
$page->{$key} = $val;
}
if ($page->save()) {
$this->index();
$this->__throw_success("Page \"" . $page->title . "\" has been created.");
log::activity($this->user->username . " has created a new page " . $page->title, $this->user->username . " (" . $this->user->email . ") has created a new page.");
} else {
$this->index();
$this->__throw_error("Sorry, there has been an error, please try again.");
}
} else {
$this->index();
$this->__throw_error("Please make sure that both title and SEO URL are filled out correctly");
}
} else {
$this->index();
}
}
示例2: __user_form
private function __user_form($form_fields = null)
{
$username = "";
$email = "";
if (!$form_fields) {
$form_fields = array('username' => '', 'email' => '', 'password' => '', 'role' => '', 'type' => 'new');
}
if (isset($form_fields['id'])) {
$id = $form_fields['id'];
}
// copy the form as errors, so the errors will be stored with keys corresponding to the form field names
$form_type = $form_fields['type'];
if ($_POST) {
$errors = $form_fields;
$post = new Validation($_POST);
// Add some filters
$post->pre_filter('trim', TRUE);
$post->add_rules('username', 'required');
$post->add_rules('email', 'required');
if ($form_fields['type'] == 'new') {
$post->add_rules('password', 'required');
}
$user = ORM::factory('user');
if ($post->validate()) {
$array = array();
$array['email'] = $post->email;
$array['username'] = $post->username;
$array['password'] = $post->password;
if ($post->password == "") {
unset($array['password']);
}
$role = $post->role;
if ($form_fields['type'] == 'edit') {
// Create new user
$user = ORM::factory('user', $form_fields['id']);
} else {
$user = ORM::factory('user');
}
if (!$user->username_exists($array['username']) || strtolower($form_fields['username']) == strtolower($array['username'])) {
foreach ($array as $key => $val) {
// Set user data
$user->{$key} = $val;
}
if ($form_fields['type'] == 'new') {
if ($user->add(ORM::factory('role', $role)) && $user->save()) {
$this->template->success_message = "New user, " . $post->username . ", has been created.";
log::activity($this->user->username . " has created a new user " . $post->username, $this->user->username . " (" . $this->user->email . ") has created a new user.");
}
}
if ($form_fields['type'] == 'edit') {
$arr = $user->roles;
foreach ($arr as $role) {
$user->remove(ORM::factory('role', $role));
}
if ($user->add(ORM::factory('role', $post->role)) and $user->save()) {
$this->template->success_message = "User " . $post->username . " has been updated.";
url::redirect('admin/users');
}
}
} else {
$form_fields = arr::overwrite($form_fields, $post->as_array());
$errors = arr::overwrite($errors, $post->errors('form_error_messages'));
if ($user->username_exists($array['username']) || $form_fields['username'] == $array['username']) {
$this->template->error_message = "That username has been taken! Please try again!";
}
}
} else {
$form_fields = arr::overwrite($form_fields, $post->as_array());
$errors = arr::overwrite($errors, $post->errors('form_error_messages'));
$this->template->error_message = "There has been an error! Please try again!";
}
}
if ($form_type == "new") {
$form = form::open("admin/users/#tab2", array('class' => 'valid_form'));
}
if ($form_type == "edit") {
$form = form::open("admin/users/edit/" . $id, array('class' => 'valid_form'));
}
$form .= "<label for='username'>Username</label>";
$form .= empty($errors['username']) ? '' : "<p class='error'>Please make sure you enter a unique username</p>";
$form .= form::input('username', $form_fields['username'], 'class="required fullWidth"');
$form .= "<label for='email'>Email</label>";
$form .= empty($errors['email']) ? '' : "<p class='error'>Please enter a valid email address</p>";
$form .= form::input('email', $form_fields['email'], 'class="required email fullWidth"');
$form .= "<label for='password'>Password</label>";
$form .= empty($errors['password']) ? '' : "<p class='error'>Please enter a password</p>";
$form .= form::password('password', $form_fields['password'], 'class="fullWidth required"');
$form .= "<label for='role'>User Type</label>";
$this->session = Session::instance();
$user = $this->session->get('user');
$superuser = FALSE;
$roles = $user->roles;
$arr = array();
foreach ($roles as $role) {
if ($role->id == 1) {
$superuser = TRUE;
}
}
$roles = ORM::factory('role')->find_all();
foreach ($roles as $role) {
//.........这里部分代码省略.........