本文整理汇总了PHP中Notifications::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Notifications::factory方法的具体用法?PHP Notifications::factory怎么用?PHP Notifications::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notifications
的用法示例。
在下文中一共展示了Notifications::factory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action_add
public function action_add()
{
$post = $this->request->post();
if ($post) {
$this->template->data["post"] = $post;
if ($post['role'] == "") {
array_push($this->template->data["errors"], array("Role" => __("User role must be set.")));
} else {
/* automatically obtain password if user set none */
if (empty($post['password'])) {
$post['password'] = Auth::randomPassword();
$post['password_confirm'] = $post['password'];
}
try {
$user = ORM::factory('User')->create_user($post, array('email', 'password'));
$user->add('roles', ORM::factory('Role', array('name' => $post['role'])));
$this->template->data["post"] = NULL;
} catch (ORM_Validation_Exception $e) {
$this->template->data["errors"] = $e->errors('models');
}
if (empty($this->template->data["errors"])) {
Notifications::factory()->new_user_account($post['email'], $post);
$this->redirect('/admin/user/all');
}
}
}
$this->template->data["roles"] = ORM::factory("Role")->get_roles();
}
示例2: create_new
public function create_new($post, $discussion_id, $reply_comment_id = NULL)
{
$comment = NULL;
if (isset($post['text']) && isset($discussion_id)) {
$user = Auth::instance()->get_user();
$comment = Model::factory('Comment');
$values = array();
$values["text"] = $post['text'];
$values["discussion_id"] = $discussion_id;
if ($user) {
$values["user_id"] = $user->id;
} else {
if ($post['author_visitor'] != "") {
$values["author_visitor"] = $post['author_visitor'];
}
}
$values["reply_comment_id"] = $reply_comment_id;
$comment->values($values, array_keys($values));
try {
$comment->save();
Notifications::factory()->new_comment($comment->reload());
} catch (ORM_Validation_Exception $e) {
$errors = $e->errors('models');
}
}
return $comment;
}
示例3: save_note
private function save_note($post)
{
$note = new Model_Note();
$note_data = array_filter($this->parse_post_data($post));
$note->values($note_data, array_keys($note_data));
try {
$note->save();
Notifications::factory()->new_note($note->reload());
} catch (Exception $exc) {
return false;
}
return true;
}
示例4: action_add
public function action_add()
{
$error = FALSE;
if ($this->request->post()) {
$this->template->data["values"] = $this->request->post();
if ($_FILES['files']['name'][0] != "") {
for ($i = 0; $i < count($_FILES['files']['name']); $i++) {
$image = Model::factory('Image');
$discussion = new Model_Discussion();
$discussion->save();
$post = $this->request->post();
$post["filename"] = "temp";
$post["discussion_id"] = $discussion->id;
$image->values($post, array_keys($post));
try {
$image->save();
$filename = $this->_save_image(array("name" => $_FILES['files']['name'][$i], "type" => $_FILES['files']['type'][$i], "tmp_name" => $_FILES['files']['tmp_name'][$i], "error" => $_FILES['files']['error'][$i], "size" => $_FILES['files']['size'][$i]), $this->request->post("project_id"), $image->id);
// set new name into DB:
if ($filename) {
$image->filename = $filename;
$image->save();
}
$discussion->image_id = $image->id;
$discussion->save();
Notifications::factory()->new_image($image);
} catch (ORM_Validation_Exception $e) {
$this->template->data["errors"] = $e->errors('models');
$error = TRUE;
$discussion->delete();
}
}
} else {
$error = TRUE;
array_push($this->template->data["errors"], "You must choose file/s.");
}
if (!$error) {
$this->redirect('admin/projects/detail/' . $this->request->post("project_id"));
}
} else {
if (isset($_GET["project_id"])) {
$this->template->data["values"] = array("project_id" => $_GET["project_id"]);
}
}
$this->template->data["projects"] = ORM::factory("Project")->order_by('id', 'desc')->find_all()->as_array("id", "name");
}