当前位置: 首页>>代码示例>>PHP>>正文


PHP Bookmark::save方法代码示例

本文整理汇总了PHP中Bookmark::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Bookmark::save方法的具体用法?PHP Bookmark::save怎么用?PHP Bookmark::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bookmark的用法示例。


在下文中一共展示了Bookmark::save方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addDel

 /**
  * Add or Delete Bookmark.
  */
 public function addDel($postId)
 {
     $row = Bookmark::model()->find('postId=:postId and userId=:userId', array(':postId' => $postId, ':userId' => Yii::app()->user->id));
     if (empty($row)) {
         $row = new Bookmark();
         $row->postId = $postId;
         $row->userId = Yii::app()->user->id;
         $row->save();
         return true;
     } else {
         $row->delete();
         return false;
     }
 }
开发者ID:Greka163,项目名称:Yii-blog-new,代码行数:17,代码来源:Bookmark.php

示例2: testIdentityMapAndRecordStatus

 /**
  * This test case demonstrates an issue with the identity case in the
  * Doctrine_Table class.  The brief summary is that if you create a
  * record, then delete it, then create another record with the same
  * primary keys, the record can get into a state where it is in the
  * database but may appear to be marked as TCLEAN under certain
  * circumstances (such as when it comes back as part of a collection).
  * This makes the $record->exists() method return false, which prevents
  * the record from being deleted among other things.
  */
 public function testIdentityMapAndRecordStatus()
 {
     // load our user and our collection of pages
     $user = Doctrine_Query::create()->query('SELECT * FROM BookmarkUser u WHERE u.name=?', array('Anonymous'))->getFirst();
     $pages = Doctrine_Query::create()->query('SELECT * FROM Page');
     // bookmark the pages (manually)
     foreach ($pages as $page) {
         $bookmark = new Bookmark();
         $bookmark['page_id'] = $page['id'];
         $bookmark['user_id'] = $user['id'];
         $bookmark->save();
     }
     // select all bookmarks
     $bookmarks = Doctrine_Manager::connection()->query('SELECT * FROM Bookmark b');
     $this->assertEqual(count($bookmarks), 1);
     // verify that they all exist
     foreach ($bookmarks as $bookmark) {
         $this->assertTrue($bookmark->exists());
     }
     // now delete them all.
     $user['Bookmarks']->delete();
     // verify count when accessed directly from database
     $bookmarks = Doctrine_Query::create()->query('SELECT * FROM Bookmark');
     $this->assertEqual(count($bookmarks), 0);
     // now recreate bookmarks and verify they exist:
     foreach ($pages as $page) {
         $bookmark = new Bookmark();
         $bookmark['page_id'] = $page['id'];
         $bookmark['user_id'] = $user['id'];
         $bookmark->save();
     }
     // select all bookmarks for the user
     $bookmarks = Doctrine_Manager::connection()->query('SELECT * FROM Bookmark b');
     $this->assertEqual(count($bookmarks), 1);
     // verify that they all exist
     foreach ($bookmarks as $bookmark) {
         $this->assertTrue($bookmark->exists());
     }
 }
开发者ID:swk,项目名称:bluebox,代码行数:49,代码来源:587TestCase.php

示例3: lang

    if ($title == "") {
        $validinfo = false;
        $error .= "<li>" . lang('nofieldgiven', array(lang('title'))) . "</li>";
    }
    if ($myurl == "") {
        $validinfo = false;
        $error .= "<li>" . lang('nofieldgiven', array(lang('url'))) . "</li>";
    }
    if ($validinfo) {
        cmsms()->GetBookmarkOperations();
        $markobj = new Bookmark();
        $markobj->bookmark_id = $bookmark_id;
        $markobj->title = $title;
        $markobj->url = $myurl;
        $markobj->user_id = $userid;
        $result = $markobj->save();
        if ($result) {
            redirect("listbookmarks.php" . $urlext);
            return;
        } else {
            $error .= "<li>" . lang('errorupdatingbookmark') . "</li>";
        }
    }
} else {
    if ($bookmark_id != -1) {
        $query = "SELECT * from " . cms_db_prefix() . "admin_bookmarks WHERE bookmark_id = ?";
        $result = $db->Execute($query, array($bookmark_id));
        $row = $result->FetchRow();
        $myurl = $row["url"];
        $title = $row["title"];
    }
开发者ID:RTR-ITF,项目名称:usse-cms,代码行数:31,代码来源:editbookmark.php

示例4: executeConfirmEmail

 public function executeConfirmEmail($request)
 {
     // we only accept GET method
     $this->forward404Unless($request->isMethod('get'));
     $email = EmailPeer::getFromField(EmailPeer::CONFIRM_CODE, $this->getRequestParameter('confirm_code'));
     if ($email) {
         if ($email->getIsPrimary() && !$email->getActualEmail()) {
             // if invited, send acceptance email and add to quick contact
             $user = $email->getUser();
             if ($user->getInvitedBy()) {
                 // add to bookmark
                 $b = new Bookmark();
                 $b->setUser($user->getUserRelatedByInvitedBy());
                 $b->setTag($user->retrievePrimaryJotag());
                 $b->save();
                 // give credit to the inviter
                 $credits = $user->getUserRelatedByInvitedBy()->giveCredit(OptionPeer::retrieveOption('BONUS_ACCEPT_CREDIT'));
                 Mailer::sendEmail($user->getUserRelatedByInvitedBy()->getPrimaryEmail(), 'inviteAccepted', array('owner' => $user->getUserRelatedByInvitedBy(), 'user' => $user, 'email' => $email, 'credits' => $credits), $user->getUserRelatedByInvitedBy()->getPreferedLanguage());
             }
             // activate primary jotag
             $jotag = $email->getUser()->retrievePrimaryJotag();
             $jotag->setStatus(TagPeer::ST_ACTIVE);
             $jotag->save();
             $this->setMessage('ACCOUNT_CONFIRM', 'SUCCESS');
         } else {
             $this->setMessage('EMAIL_CONFIRM', 'SUCCESS');
         }
         $email->setIsConfirmed(true);
         $email->setConfirmCode(null);
         $email->setActualEmail(null);
         $email->save();
     } else {
         $this->setMessage('EMAIL_CONFIRM_ERROR', 'ERROR');
     }
     $this->redirect('@homepage');
 }
开发者ID:psskhal,项目名称:symfony-sample,代码行数:36,代码来源:actions.class.php

示例5: cmsms

#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#$Id: makebookmark.php 7647 2012-01-01 15:28:10Z calguy1000 $
global $CMS_ADMIN_PAGE;
$CMS_ADMIN_PAGE = 1;
require_once '../include.php';
$urlext = '?' . CMS_SECURE_PARAM_NAME . '=' . $_SESSION[CMS_USER_KEY];
include_once "header.php";
check_login();
$config = cmsms()->GetConfig();
$link = $_SERVER['HTTP_REFERER'];
$newmark = new Bookmark();
$newmark->user_id = get_userid();
$newmark->url = $link;
$newmark->title = $_GET['title'];
$result = $newmark->save();
if ($result) {
    header('HTTP_REFERER: ' . $config['admin_url'] . '/index.php');
    redirect($link);
} else {
    include_once "header.php";
    echo "<h3>" . lang('erroraddingbookmark') . "</h3>";
}
开发者ID:RTR-ITF,项目名称:usse-cms,代码行数:31,代码来源:makebookmark.php

示例6: set

 /**
  * Ставит закладку на перевод/фрагмент
  * Если закладка была, то редактируется $note (если указано)
  * Если не было, то создаётся с min(ord) - 1
  **/
 public static function set($book_id, $orig_id = null, $note = null)
 {
     if (Yii::app()->user->isGuest) {
         return false;
     }
     $pk = array("user_id" => Yii::app()->user->id, "book_id" => $book_id);
     if ($orig_id) {
         $pk["orig_id"] = $orig_id;
     }
     $bm = Bookmark::model()->findByAttributes($pk);
     if (!$bm) {
         $bm = new Bookmark();
         $bm->user_id = Yii::app()->user->id;
         $bm->book_id = $book_id;
         if ($orig_id) {
             $bm->orig_id = $orig_id;
         }
         $bm->ord = Yii::app()->db->createCommand("SELECT MAX(ord) FROM bookmarks WHERE user_id = :user_id AND orig_id IS NULL")->queryScalar(array(":user_id" => Yii::app()->user->id)) + 1;
     }
     if ($note !== null) {
         $bm->note = $note;
     }
     return $bm->save();
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:29,代码来源:Bookmark.php

示例7: bookmark

 /**
  * Добавление в закладки
  */
 public function bookmark()
 {
     if (!Request::ajax()) {
         App::redirect('/');
     }
     $token = Request::input('token', true);
     $topic_id = Request::input('id');
     if (User::check() && $token == $_SESSION['token']) {
         /* Проверка темы на существование */
         if ($topic = Topic::find_by_id($topic_id)) {
             /* Добавление темы в закладки */
             if ($bookmark = Bookmark::find_by_topic_id_and_user_id($topic_id, User::get('id'))) {
                 if ($bookmark->delete()) {
                     exit(json_encode(['status' => 'deleted']));
                 }
             } else {
                 $bookmark = new Bookmark();
                 $bookmark->topic_id = $topic->id;
                 $bookmark->user_id = User::get('id');
                 $bookmark->posts = $topic->postCount();
                 if ($bookmark->save()) {
                     exit(json_encode(['status' => 'added']));
                 }
             }
         }
     }
     exit(json_encode(['status' => 'error']));
 }
开发者ID:visavi,项目名称:rotorcms,代码行数:31,代码来源:ForumController.php

示例8: actionBookmark_set

 public function actionBookmark_set()
 {
     if (!is_array($_POST["B"])) {
         throw new CHttpException(500, "Неверный запрос.");
     }
     // Есть ли уже такая закладка?
     $bookmark = Bookmark::model()->findByAttributes(array("user_id" => Yii::app()->user->id, "typ" => substr($_POST["B"]["typ"], 0, 1), "obj_id" => (int) $_POST["B"]["obj_id"]));
     if (!$bookmark) {
         $bookmark = new Bookmark();
         $bookmark->user_id = Yii::app()->user->id;
     }
     $bookmark->setAttributes($_POST["B"]);
     if ($bookmark->typ == "o") {
         $orig = Orig::model()->with("chap.book")->findByPk($bookmark->obj_id);
         if (!$orig) {
             throw new CHttpException(404, "Фрагмент оригинала удалён.");
         }
         $bookmark->url = $orig->url;
     } elseif ($bookmark->typ == "c") {
         $chap = Chapter::model()->with("book")->findByPk($bookmark->obj_id);
         if (!$chap) {
             throw new CHttpException(404, "Глава удалена");
         }
         $bookmark->url = $chap->url;
     } elseif ($bookmark->typ == "b") {
         $book = Book::model()->findByPk($bookmark->obj_id);
         if (!$book) {
             throw new CHttpException(404, "Глава удалена");
         }
         $bookmark->url = $book->url;
     } else {
         throw new CHttpException(500, "Неверный запрос. Если вам интересны грязные подробности, то я не знаю, что такое тип закладки '{$bookmark->typ}'.");
     }
     if ($bookmark->isNewRecord) {
         $bookmark->ord = Yii::app()->db->createCommand("SELECT MAX(ord) FROM bookmarks WHERE typ = :typ AND user_id = :user_id")->queryScalar(array(":typ" => $bookmark->typ, ":user_id" => Yii::app()->user->id)) + 1;
     }
     if (!$bookmark->save()) {
         throw new CHttpException(500, $bookmark->getErrorsString());
     }
     $json = array("id" => $bookmark->id, "title" => $bookmark->title);
     echo json_encode($json);
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:42,代码来源:MyController.php

示例9: actionSet

 public function actionSet()
 {
     $book_id = (int) $_POST["book_id"];
     $orig_id = (int) $_POST["orig_id"];
     $pk = array("user_id" => Yii::app()->user->id, "book_id" => $book_id);
     if ($orig_id) {
         $pk["orig_id"] = $orig_id;
     }
     $bm = Bookmark::model()->findByAttributes($pk);
     if (!$bm) {
         $bm = new Bookmark();
         $bm->user_id = Yii::app()->user->id;
         $bm->book_id = $book_id;
         if ($orig_id) {
             $bm->orig_id = $orig_id;
         }
     }
     if (isset($_POST["note"])) {
         $post = $_POST;
         unset($post["book_id"]);
         unset($post["orig_id"]);
         $bm->setAttributes($post);
         $bm->watch = (int) $_POST["watch"];
         $new_ord = Yii::app()->db->createCommand("SELECT MAX(ord) FROM bookmarks WHERE user_id = :user_id AND orig_id IS NULL")->queryScalar(array(":user_id" => Yii::app()->user->id)) + 1;
         if ($orig_id) {
             // А есть ли закладка на перевод?
             if (!Yii::app()->db->createCommand("SELECT 1 FROM bookmarks WHERE user_id = :user_id AND book_id = :book_id AND orig_id IS NULL")->queryScalar(array(":user_id" => Yii::app()->user->id, ":book_id" => $book_id))) {
                 Yii::app()->db->createCommand("INSERT INTO bookmarks (user_id, book_id, ord) VALUES (:user_id, :book_id, :ord)")->execute(array(":user_id" => Yii::app()->user->id, ":book_id" => $book_id, ":ord" => $new_ord));
             }
         } else {
             $bm->ord = $new_ord;
         }
         if (!$bm->save()) {
             throw new CHttpException(500, $bm->getErrorsString());
         }
         echo json_encode(array("book_id" => (int) $bm->book_id, "orig_id" => (int) $bm->orig_id, "note" => $bm->note, "status" => "set"));
     } else {
         $this->renderPartial("set", array("bm" => $bm));
     }
 }
开发者ID:norayr,项目名称:notabenoid,代码行数:40,代码来源:BookmarksController.php


注:本文中的Bookmark::save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。