createBookmark() public static method

Creates a Bookmark object from the parameters
public static createBookmark ( array $bkm_fields, boolean $all_users = false ) : Bookmark | false
$bkm_fields array the properties of the bookmark to add; here, $bkm_fields['bkm_sql_query'] is urlencoded
$all_users boolean whether to make the bookmark available for all users
return Bookmark | false
Ejemplo n.º 1
0
 /**
  * Tests for Bookmark::save()
  *
  * @return void
  */
 public function testSave()
 {
     $bookmarkData = array('bkm_database' => 'phpmyadmin', 'bkm_user' => 'root', 'bkm_sql_query' => 'SELECT "phpmyadmin"', 'bkm_label' => 'bookmark1');
     $bookmark = Bookmark::createBookmark($bookmarkData);
     $this->assertfalse($bookmark->save());
 }
Ejemplo n.º 2
0
    exit;
}
// If it's a refresh console bookmarks request
if (isset($_REQUEST['console_bookmark_refresh'])) {
    $response = PMA\libraries\Response::getInstance();
    $response->addJSON('console_message_bookmark', PMA\libraries\Console::getBookmarkContent());
    exit;
}
// If it's a console bookmark add request
if (isset($_REQUEST['console_bookmark_add'])) {
    $response = PMA\libraries\Response::getInstance();
    if (isset($_REQUEST['label']) && isset($_REQUEST['db']) && isset($_REQUEST['bookmark_query']) && isset($_REQUEST['shared'])) {
        $cfgBookmark = Bookmark::getParams();
        $bookmarkFields = array('bkm_database' => $_REQUEST['db'], 'bkm_user' => $cfgBookmark['user'], 'bkm_sql_query' => urlencode($_REQUEST['bookmark_query']), 'bkm_label' => $_REQUEST['label']);
        $isShared = $_REQUEST['shared'] == 'true' ? true : false;
        $bookmark = Bookmark::createBookmark($bookmarkFields, $isShared);
        if ($bookmark !== false && $bookmark->save()) {
            $response->addJSON('message', __('Succeeded'));
            $response->addJSON('data', $bookmarkFields);
            $response->addJSON('isShared', $isShared);
        } else {
            $response->addJSON('message', __('Failed'));
        }
        die;
    } else {
        $response->addJSON('message', __('Incomplete params'));
        die;
    }
}
$format = '';
/**
Ejemplo n.º 3
0
/**
 * Function to store the query as a bookmark
 *
 * @param String  $db                     the current database
 * @param String  $bkm_user               the bookmarking user
 * @param String  $sql_query_for_bookmark the query to be stored in bookmark
 * @param String  $bkm_label              bookmark label
 * @param boolean $bkm_replace            whether to replace existing bookmarks
 *
 * @return void
 */
function PMA_storeTheQueryAsBookmark($db, $bkm_user, $sql_query_for_bookmark, $bkm_label, $bkm_replace)
{
    $bfields = array('bkm_database' => $db, 'bkm_user' => $bkm_user, 'bkm_sql_query' => urlencode($sql_query_for_bookmark), 'bkm_label' => $bkm_label);
    // Should we replace bookmark?
    if (isset($bkm_replace)) {
        $bookmarks = Bookmark::getList($db);
        foreach ($bookmarks as $bookmark) {
            if ($bookmark->getLabel() == $bkm_label) {
                $bookmark->delete();
            }
        }
    }
    $bookmark = Bookmark::createBookmark($bfields, isset($_POST['bkm_all_users']));
    $bookmark->save();
}