本文整理汇总了PHP中Notify::notifyAuthorNewBook方法的典型用法代码示例。如果您正苦于以下问题:PHP Notify::notifyAuthorNewBook方法的具体用法?PHP Notify::notifyAuthorNewBook怎么用?PHP Notify::notifyAuthorNewBook使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Notify
的用法示例。
在下文中一共展示了Notify::notifyAuthorNewBook方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add_author
function add_author()
{
global $current_user;
$this->ca();
$id_person = (int) $_POST['id_author'];
$id_book = (int) $_POST['id'];
$id_role = (int) $_POST['id_role'];
if ($id_role && $id_person && $id_book) {
$persons = Persons::getInstance()->getByIdsLoaded(array($id_person));
if (!isset($persons[$id_person]) || !$persons[$id_person]->id) {
$this->data['item_id'] = $id_person;
$this->data['success'] = 0;
$this->data['error'] = 'Нет такого автора';
return;
}
$query = 'INSERT INTO `book_persons` SET `id_book`=' . $id_book . ' , `id_person`=' . $id_person . ', `person_role`=' . $id_role;
$r = Database::query($query, false);
if ($r) {
$this->data['success'] = 1;
$this->data['item_id'] = $id_person;
$this->data['name'] = $persons[$id_person]->getName();
$this->data['role'] = Config::$person_roles[$id_role];
BookLog::addLog(array('id_person' => $id_person, 'person_role' => $id_role), array('id_person' => 0, 'person_role' => 0), $id_book);
$log_id = BookLog::saveLog($id_book, BookLog::TargetType_book, $current_user->id, BiberLog::BiberLogType_bookEditPerson);
BookLog::saveLogLink($log_id, $id_person, BookLog::TargetType_person, $current_user->id, BiberLog::BiberLogType_bookEditPerson, $copy = 1);
$search = Search::getInstance();
/* @var $search Search */
$search->updateBook(new Book($id_book));
Notify::notifyAuthorNewBook($id_person, $id_book);
} else {
$this->data['error'] = 'Автор уже есть в списке авторов';
}
return;
}
$this->data['item_id'] = $id_person;
$this->data['success'] = 0;
}
示例2: newBook
function newBook()
{
// добавляем книгу
global $current_user;
/* @var $current_user CurrentUser */
$fields = array('title' => 'title', 'subtitle' => 'subtitle', 'isbn' => 'ISBN', 'year' => 'year', 'lang_code' => 'id_lang', 'annotation' => 'description', 'rightholder' => 'id_rightholder');
Request::$post['lang_code'] = Config::$langs[Request::$post['lang_code']];
Request::$post['title'] = trim(prepare_review(Request::$post['title'], ''));
Request::$post['annotation'] = trim(prepare_review(Request::$post['annotation'], false, '<img>'));
if (!Request::$post['title']) {
throw new Exception('title missed');
}
foreach ($fields as $field => $bookfield) {
if (!isset(Request::$post[$field])) {
throw new Exception('field missed #' . $field);
}
$to_update[$bookfield] = Request::$post[$field];
}
if (Request::$post['n'] && Request::$post['m']) {
$to_update['book_type'] = Book::BOOK_TYPE_MAGAZINE;
$to_update['title'] = Database::sql2single('SELECT `title` FROM `magazines` WHERE `id`=' . (int) Request::$post['m']);
}
$q = array();
foreach ($to_update as $field => $value) {
if (in_array($field, array('year'))) {
$value = (int) $value;
}
$q[] = '`' . $field . '`=' . Database::escape($value) . '';
}
if (count($q)) {
$q[] = '`add_time`=' . time();
$query = 'INSERT INTO `book` SET ' . implode(',', $q);
Database::query($query);
if ($lid = Database::lastInsertId()) {
if (Request::$post['n'] && Request::$post['m']) {
// журнал - вставляем
$query = 'INSERT INTO `book_magazines` SET `id_book`=' . $lid . ',id_magazine=' . (int) Request::$post['m'] . ',`year`=' . $to_update['year'] . ',`n`=' . (int) Request::$post['n'];
Database::query($query, false);
$query = 'UPDATE `magazines` SET `books_count`=(SELECT COUNT(1) FROM `book_magazines` WHERE `id_magazine`=' . (int) Request::$post['m'] . ')
WHERE `id`=' . (int) Request::$post['m'];
Database::query($query);
}
if (isset(Request::$post['author_id']) && Request::$post['author_id']) {
$query = 'INSERT INTO `book_persons` SET `id_book`=' . $lid . ',`id_person`=' . (int) Request::$post['author_id'] . ',`person_role`=' . Book::ROLE_AUTHOR;
Database::query($query, false);
BookLog::addLog(array('id_person' => (int) Request::$post['author_id'], 'person_role' => Book::ROLE_AUTHOR), array('id_person' => 0, 'person_role' => 0), $lid);
BookLog::saveLog($lid, BookLog::TargetType_book, $current_user->id, BiberLog::BiberLogType_bookEditPerson);
Notify::notifyAuthorNewBook((int) Request::$post['author_id'], $lid);
}
if (isset($_FILES['cover']) && $_FILES['cover']['tmp_name']) {
$folder = Config::need('static_path') . '/upload/covers/' . ceil($lid / 5000);
@mkdir($folder);
// inserting new cover
$query = 'INSERT INTO `book_covers` SET `id_book`=' . $lid;
Database::query($query);
$cover_id = Database::lastInsertId();
// generating file names
$filename_normal = $folder . '/default_' . $lid . '_' . $cover_id . '.jpg';
$filename_small = $folder . '/small_' . $lid . '_' . $cover_id . '.jpg';
$filename_big = $folder . '/big_' . $lid . '_' . $cover_id . '.jpg';
$filename_orig = $folder . '/orig_' . $lid . '_' . $cover_id . '.jpg';
$to_update['is_cover'] = $cover_id;
$thumb = new Thumb();
$thumb->createThumbnails($_FILES['cover']['tmp_name'], array($filename_small, $filename_normal, $filename_big, $filename_orig), self::$cover_sizes);
$query = 'UPDATE `book` SET `is_cover`=' . $cover_id . ' WHERE `id`=' . $lid;
Database::query($query);
$current_user->gainActionPoints('books_add_cover', $lid, BiberLog::TargetType_book);
}
// file loading
if (isset($_FILES['file']) && isset($_FILES['file']['tmp_name']) && $_FILES['file']['tmp_name']) {
$filetype_ = explode('.', $_FILES['file']['name']);
$filetype_ = isset($filetype_[count($filetype_) - 1]) ? $filetype_[count($filetype_) - 1] : '';
$fts = Config::need('filetypes');
$filetype = false;
foreach ($fts as $ftid => $ftname) {
if ($ftname == $filetype_) {
$filetype = $ftid;
}
}
if (!$filetype) {
throw new Exception('wrong filetype:' . $filetype_);
}
$destinationDir = Config::need('files_path') . DIRECTORY_SEPARATOR . getBookFileDirectory($book->id, $filetype);
@mkdir($destinationDir, 0755);
// добавляем запись в базу
$filesize = $_FILES['file']['size'];
$query = 'INSERT INTO `book_files` SET
`id_book`=' . $book->id . ',
`filetype`=' . $filetype . ',
`id_file_author`=' . $current_user->id . ',
`modify_time`=' . time() . ',
`filesize`=' . $filesize;
Database::query($query);
$id_file = Database::lastInsertId();
BookLog::addLog(array('id_file' => $id_file, 'filetype' => $filetype, 'id_file_author' => $current_user->id, 'filesize' => $filesize), array('id_file' => 0, 'filetype' => 0, 'id_file_author' => 0, 'filesize' => 0), $lid);
$to_update_ = array();
if ($id_file) {
$to_update_['id_main_file'] = $id_file;
$destinationFile = getBookFilePath($id_file, $book->id, $filetype, Config::need('files_path'));
if (!move_uploaded_file($_FILES['file']['tmp_name'], $destinationFile)) {
//.........这里部分代码省略.........