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


PHP db_query_range函数代码示例

本文整理汇总了PHP中db_query_range函数的典型用法代码示例。如果您正苦于以下问题:PHP db_query_range函数的具体用法?PHP db_query_range怎么用?PHP db_query_range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: match

 /**
  * {@inheritDocs}
  */
 public function match($pathinfo)
 {
     // The 'q' variable is pervasive in Drupal, so it's best to just keep
     // it even though it's very un-Symfony.
     $path = drupal_get_normal_path(substr($pathinfo, 1));
     if (variable_get('menu_rebuild_needed', FALSE) || !variable_get('menu_masks', array())) {
         menu_rebuild();
     }
     $original_map = arg(NULL, $path);
     $parts = array_slice($original_map, 0, MENU_MAX_PARTS);
     $ancestors = menu_get_ancestors($parts);
     $router_item = db_query_range('SELECT * FROM {menu_router} WHERE path IN (:ancestors) ORDER BY fit DESC', 0, 1, array(':ancestors' => $ancestors))->fetchAssoc();
     if ($router_item) {
         // Allow modules to alter the router item before it is translated and
         // checked for access.
         drupal_alter('menu_get_item', $router_item, $path, $original_map);
         // The requested path is an unalaised Drupal route.
         return array('_drupal' => true, '_controller' => function ($_router_item) {
             $router_item = $_router_item;
             if (!$router_item['access']) {
                 throw new AccessDeniedException();
             }
             if ($router_item['include_file']) {
                 require_once DRUPAL_ROOT . '/' . $router_item['include_file'];
             }
             return call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
         }, '_route' => $router_item['path']);
     }
     throw new ResourceNotFoundException();
 }
开发者ID:bangpound,项目名称:drupal-bundle,代码行数:33,代码来源:DrupalRouter.php

示例2: testWatchdog

 /**
  * Writes a log messages and retrieves it via the REST API.
  */
 public function testWatchdog()
 {
     // Write a log message to the DB.
     $this->container->get('logger.channel.rest')->notice('Test message');
     // Get the ID of the written message.
     $id = db_query_range("SELECT wid FROM {watchdog} WHERE type = :type ORDER BY wid DESC", 0, 1, array(':type' => 'rest'))->fetchField();
     // Create a user account that has the required permissions to read
     // the watchdog resource via the REST API.
     $account = $this->drupalCreateUser(array('restful get dblog'));
     $this->drupalLogin($account);
     $response = $this->httpRequest(Url::fromRoute('rest.dblog.GET.' . $this->defaultFormat, ['id' => $id, '_format' => $this->defaultFormat]), 'GET');
     $this->assertResponse(200);
     $this->assertHeader('content-type', $this->defaultMimeType);
     $log = Json::decode($response);
     $this->assertEqual($log['wid'], $id, 'Log ID is correct.');
     $this->assertEqual($log['type'], 'rest', 'Type of log message is correct.');
     $this->assertEqual($log['message'], 'Test message', 'Log message text is correct.');
     // Request an unknown log entry.
     $response = $this->httpRequest(Url::fromRoute('rest.dblog.GET.' . $this->defaultFormat, ['id' => 9999, '_format' => $this->defaultFormat]), 'GET');
     $this->assertResponse(404);
     $decoded = Json::decode($response);
     $this->assertEqual($decoded['message'], 'Log entry with ID 9999 was not found', 'Response message is correct.');
     // Make a bad request (a true malformed request would never be a route match).
     $response = $this->httpRequest(Url::fromRoute('rest.dblog.GET.' . $this->defaultFormat, ['id' => 0, '_format' => $this->defaultFormat]), 'GET');
     $this->assertResponse(400);
     $decoded = Json::decode($response);
     $this->assertEqual($decoded['message'], 'No log entry ID was provided', 'Response message is correct.');
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:31,代码来源:DbLogResourceTest.php

示例3: callback_batch_operation

/**
 * Perform a single batch operation.
 *
 * Callback for batch_set().
 *
 * @param $MULTIPLE_PARAMS
 *   Additional parameters specific to the batch. These are specified in the
 *   array passed to batch_set().
 * @param $context
 *   The batch context array, passed by reference. This contains the following
 *   properties:
 *   - 'finished': A float number between 0 and 1 informing the processing
 *     engine of the completion level for the operation. 1 (or no value
 *     explicitly set) means the operation is finished: the operation will not
 *     be called again, and execution passes to the next operation or the
 *     callback_batch_finished() implementation. Any other value causes this
 *     operation to be called again; however it should be noted that the value
 *     set here does not persist between executions of this callback: each time
 *     it is set to 1 by default by the batch system.
 *   - 'sandbox': This may be used by operations to persist data between
 *     successive calls to the current operation. Any values set in
 *     $context['sandbox'] will be there the next time this function is called
 *     for the current operation. For example, an operation may wish to store a
 *     pointer in a file or an offset for a large query. The 'sandbox' array key
 *     is not initially set when this callback is first called, which makes it
 *     useful for determining whether it is the first call of the callback or
 *     not:
 *     @code
 *       if (empty($context['sandbox'])) {
 *         // Perform set-up steps here.
 *       }
 *     @endcode
 *     The values in the sandbox are stored and updated in the database between
 *     http requests until the batch finishes processing. This avoids problems
 *     if the user navigates away from the page before the batch finishes.
 *   - 'message': A text message displayed in the progress page.
 *   - 'results': The array of results gathered so far by the batch processing.
 *     This array is highly useful for passing data between operations. After
 *     all operations have finished, this is passed to callback_batch_finished()
 *     where results may be referenced to display information to the end-user,
 *     such as how many total items were processed.
 */
function callback_batch_operation($MULTIPLE_PARAMS, &$context)
{
    if (!isset($context['sandbox']['progress'])) {
        $context['sandbox']['progress'] = 0;
        $context['sandbox']['current_node'] = 0;
        $context['sandbox']['max'] = db_query('SELECT COUNT(DISTINCT nid) FROM {node}')->fetchField();
    }
    // For this example, we decide that we can safely process
    // 5 nodes at a time without a timeout.
    $limit = 5;
    // With each pass through the callback, retrieve the next group of nids.
    $result = db_query_range("SELECT nid FROM {node} WHERE nid > %d ORDER BY nid ASC", $context['sandbox']['current_node'], 0, $limit);
    while ($row = db_fetch_array($result)) {
        // Here we actually perform our processing on the current node.
        $node = node_load($row['nid'], NULL, TRUE);
        $node->value1 = $options1;
        $node->value2 = $options2;
        node_save($node);
        // Store some result for post-processing in the finished callback.
        $context['results'][] = check_plain($node->title);
        // Update our progress information.
        $context['sandbox']['progress']++;
        $context['sandbox']['current_node'] = $node->nid;
        $context['message'] = t('Now processing %node', array('%node' => $node->title));
    }
    // Inform the batch engine that we are not finished,
    // and provide an estimation of the completion level we reached.
    if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
        $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
    }
}
开发者ID:CuBoulder,项目名称:cu-express-drops-7,代码行数:73,代码来源:form.api.php

示例4: testNewDefaultThemeBlocks

 /**
  * Check the enabled Garland blocks are correctly copied over.
  */
 function testNewDefaultThemeBlocks()
 {
     // Create administrative user.
     $adminuser = $this->drupalCreateUser(array('administer themes'));
     $this->drupalLogin($adminuser);
     // Ensure no other theme's blocks are in the block table yet.
     $count = db_query_range("SELECT 1 FROM {block} WHERE theme NOT IN ('garland', 'seven')", 0, 1)->fetchField();
     $this->assertFalse($count, t('Only Garland and Seven have blocks.'));
     // Populate list of all blocks for matching against new theme.
     $blocks = array();
     $result = db_query("SELECT * FROM {block} WHERE theme = 'garland'");
     foreach ($result as $block) {
         // $block->theme and $block->bid will not match, so remove them.
         unset($block->theme, $block->bid);
         $blocks[$block->module][$block->delta] = $block;
     }
     // Turn on the Stark theme and ensure that it contains all of the blocks
     // that Garland did.
     theme_enable(array('stark'));
     variable_set('theme_default', 'stark');
     $result = db_query("SELECT * FROM {block} WHERE theme='stark'");
     foreach ($result as $block) {
         unset($block->theme, $block->bid);
         $this->assertEqual($blocks[$block->module][$block->delta], $block, t('Block %name matched', array('%name' => $block->module . '-' . $block->delta)));
     }
 }
开发者ID:pjcdawkins,项目名称:drupal7mongodb,代码行数:29,代码来源:NewDefaultThemeBlocksTest.php

示例5: cvs_to_versioncontrol_project_update_2

/**
 * Convert project repository data.
 */
function cvs_to_versioncontrol_project_update_2()
{
    // This determines how many projects will be processed in each batch run. A reasonable
    // default has been chosen, but you may want to tweak depending on your setup.
    $limit = 100;
    // Multi-part update
    if (!isset($_SESSION['cvs_to_versioncontrol_project_update_2'])) {
        $_SESSION['cvs_to_versioncontrol_project_update_2'] = 0;
        $_SESSION['cvs_to_versioncontrol_project_update_2_max'] = db_result(db_query("SELECT COUNT(*) FROM {cvs_projects}"));
    }
    // Pull the next batch of users.
    $projects = db_query_range("SELECT p.nid, p.rid, p.directory, r.modules FROM {cvs_projects} p INNER JOIN {cvs_repositories} r ON p.rid = r.rid ORDER BY p.nid", $_SESSION['cvs_to_versioncontrol_project_update_2'], $limit);
    // Loop through each project.
    while ($project = db_fetch_object($projects)) {
        // Add the repo module, and chop off the trailing slash.
        $directory = '/' . trim($project->modules) . drupal_substr($project->directory, 0, drupal_strlen($project->directory) - 1);
        db_query("INSERT INTO {versioncontrol_project_projects} (nid, repo_id, directory) VALUES (%d, %d, '%s')", $project->nid, $project->rid, $directory);
        $_SESSION['cvs_to_versioncontrol_project_update_2']++;
    }
    if ($_SESSION['cvs_to_versioncontrol_project_update_2'] >= $_SESSION['cvs_to_versioncontrol_project_update_2_max']) {
        $count = $_SESSION['cvs_to_versioncontrol_project_update_2_max'];
        unset($_SESSION['cvs_to_versioncontrol_project_update_2']);
        unset($_SESSION['cvs_to_versioncontrol_project_update_2_max']);
        return array(array('success' => TRUE, 'query' => t('Converted @count project repository entries.', array('@count' => $count))));
    }
    return array('#finished' => $_SESSION['cvs_to_versioncontrol_project_update_2'] / $_SESSION['cvs_to_versioncontrol_project_update_2_max']);
}
开发者ID:haxney,项目名称:versioncontrol_project,代码行数:30,代码来源:cvs_to_versioncontrol_project_update.php

示例6: getOrphanedItems

 /**
  * Gets a range of orphaned comment IDs.
  *
  * Orphaned comments are those which are associated with an user and / or node
  * that for some reason no longer exist on the site
  *
  * @param int $limit
  *   The number of records to retrieve.
  *
  * @return array
  *   An indexed array containing the relevant comment IDs, or an empty array
  *   if there is no result set.
  */
 protected function getOrphanedItems($limit)
 {
     return db_query_range('
   SELECT cid FROM {comment} c
   LEFT JOIN {users} u ON c.uid = u.uid
   LEFT JOIN {node} n ON c.nid = n.nid
   WHERE u.uid IS NULL OR n.nid IS NULL', 0, $limit)->fetchCol();
 }
开发者ID:robtryson,项目名称:nysits,代码行数:21,代码来源:AcsfDuplicationScrubCommentHandler.php

示例7: claimItem

 /**
  * Overrides Drupal\Core\Queue\System::claimItem().
  *
  * Unlike Drupal\Core\Queue\System::claimItem(), this method provides a
  * default lease time of 0 (no expiration) instead of 30. This allows the item
  * to be claimed repeatedly until it is deleted.
  */
 public function claimItem($lease_time = 0)
 {
     $item = db_query_range('SELECT data, item_id FROM {queue} q WHERE name = :name ORDER BY item_id ASC', 0, 1, array(':name' => $this->name))->fetchObject();
     if ($item) {
         $item->data = unserialize($item->data);
         return $item;
     }
     return FALSE;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:16,代码来源:Batch.php

示例8: post

 /**
  * Processes a payment POST from the CyberSource Hosted Order Page API.
  */
 public static function post()
 {
     if (!uc_cybersource_hop_include()) {
         \Drupal::logger('uc_cybersource_hop')->error('Unable to receive HOP POST due to missing or unreadable HOP.php file.');
         drupal_add_http_header('Status', '503 Service unavailable');
         print $this->t('The site was unable to receive a HOP post because of a missing or unreadble HOP.php');
         exit;
     }
     $verify = VerifyTransactionSignature($_POST);
     \Drupal::logger('uc_cybersource_hop')->notice('Receiving payment notification at URL for order @orderNumber', array('@orderNumber' => $_POST['orderNumber']));
     if (!isset($_POST['orderNumber'])) {
         \Drupal::logger('uc_cybersource_hop')->error('CS HOP attempted with invalid order number.');
         return;
     }
     if (!$verify) {
         \Drupal::logger('uc_cybersource_hop')->notice('Receiving invalid payment notification at URL for order @orderNumber. <pre>@debug</pre>', array('@orderNumber' => $_POST['orderNumber'], '@debug' => print_r($_POST, TRUE)));
         return;
     }
     // Assign posted variables to local variables.
     $decision = SafeMarkup::checkPlain($_POST['decision']);
     $reason_code = SafeMarkup::checkPlain($_POST['reasonCode']);
     $reason = _parse_cs_reason_code($reason_code);
     $payment_amount = SafeMarkup::checkPlain($_POST['orderAmount']);
     $payment_currency = SafeMarkup::checkPlain($_POST['paymentCurrency']);
     $request_id = SafeMarkup::checkPlain($_POST['requestID']);
     $request_token = SafeMarkup::checkPlain($_POST['orderPage_requestToken']);
     $reconciliation_id = SafeMarkup::checkPlain($_POST['reconciliationID']);
     $order_id = SafeMarkup::checkPlain($_POST['orderNumber']);
     $payer_email = SafeMarkup::checkPlain($_POST['billTo_email']);
     $order = Order::load($_POST['orderNumber']);
     switch ($decision) {
         case 'ACCEPT':
             \Drupal::logger('uc_cybersource_hop')->notice('CyberSource verified successful payment.');
             $duplicate = (bool) db_query_range('SELECT 1 FROM {uc_payment_cybersource_hop_post} WHERE order_id = :order_id AND decision = :decision', 0, 1, array(':order_id' => $order_id, ':decision' => 'ACCEPT'))->fetchField();
             if ($duplicate) {
                 \Drupal::logger('uc_cybersource_hop')->notice('CS HOP transaction for order @order-id has been processed before.', array('@order_id' => $order_id));
                 return;
             }
             db_insert('uc_payment_cybersource_hop_post')->fields(array('order_id' => $order_id, 'request_id' => $request_id, 'request_token' => $request_token, 'reconciliation_id' => $reconciliation_id, 'gross' => $payment_amount, 'decision' => $decision, 'reason_code' => $reason_code, 'payer_email' => $payer_email, 'received' => REQUEST_TIME))->execute();
             $comment = $this->t('CyberSource request ID: @txn_id', array('@txn_id' => $request_id));
             uc_payment_enter($order_id, 'cybersource_hop', $payment_amount, $order->getUserId(), NULL, $comment);
             uc_cart_complete_sale($order);
             uc_order_comment_save($order_id, 0, $this->t('Payment of @amount @currency submitted through CyberSource with request ID @rid.', array('@amount' => $payment_amount, '@currency' => $payment_currency, '@rid' => $request_id)), 'order', 'payment_received');
             break;
         case 'ERROR':
             uc_order_comment_save($order_id, 0, $this->t("Payment error:@reason with request ID @rid", array('@reason' => $reason, '@rid' => '@request_id')), 'admin');
             break;
         case 'REJECT':
             uc_order_comment_save($order_id, 0, $this->t("Payment is rejected:@reason with request ID @rid", array('@reason' => $reason, '@rid' => '@request_id')), 'admin');
             break;
         case 'REVIEW':
             $order->setStatusId('review')->save();
             uc_order_comment_save($order_id, 0, $this->t('Payment is in review & not complete: @reason. Request ID @rid', array('@reason' => $reason, '@rid' => '@request_id')), 'admin');
             break;
     }
 }
开发者ID:pedrocones,项目名称:hydrotools,代码行数:59,代码来源:HOPController.php

示例9: testRangeQuery

 /**
  * Confirms that range queries work and return the correct result.
  */
 function testRangeQuery()
 {
     // Test if return correct number of rows.
     $range_rows = db_query_range("SELECT name FROM {test} ORDER BY name", 1, 3)->fetchAll();
     $this->assertEqual(count($range_rows), 3, 'Range query work and return correct number of rows.');
     // Test if return target data.
     $raw_rows = db_query('SELECT name FROM {test} ORDER BY name')->fetchAll();
     $raw_rows = array_slice($raw_rows, 1, 3);
     $this->assertEqual($range_rows, $raw_rows);
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:13,代码来源:RangeQueryTest.php

示例10: authenticate

 /**
  * {@inheritdoc}
  *
  * @see user_login_authenticate_validate().
  */
 public function authenticate(RequestInterface $request)
 {
     $username = $request->getUser();
     $password = $request->getPassword();
     // Do not allow any login from the current user's IP if the limit has been
     // reached. Default is 50 failed attempts allowed in one hour. This is
     // independent of the per-user limit to catch attempts from one IP to log
     // in to many different user accounts.  We have a reasonably high limit
     // since there may be only one apparent IP for all users at an institution.
     if (!flood_is_allowed('failed_login_attempt_ip', variable_get('user_failed_login_ip_limit', 50), variable_get('user_failed_login_ip_window', 3600))) {
         throw new FloodException(format_string('Rejected by ip flood control.'));
     }
     if (filter_var($username, FILTER_VALIDATE_EMAIL)) {
         if (!($uid = db_query_range("SELECT uid FROM {users} WHERE LOWER(mail) = LOWER(:mail) AND status = 1", 0, 1, array(':mail' => $username))->fetchField())) {
             // Always register an IP-based failed login event.
             flood_register_event('failed_login_attempt_ip', variable_get('user_failed_login_ip_window', 3600), ip_address());
             return null;
         } else {
             $username = db_query_range("SELECT name FROM {users} WHERE LOWER(mail) = LOWER(:mail) AND status = 1", 0, 1, array(':mail' => $username))->fetchField();
         }
     } else {
         if (!($uid = db_query_range("SELECT uid FROM {users} WHERE name = :name AND status = 1", 0, 1, array(':name' => $username))->fetchField())) {
             // Always register an IP-based failed login event.
             flood_register_event('failed_login_attempt_ip', variable_get('user_failed_login_ip_window', 3600), ip_address());
             return null;
         }
     }
     if (variable_get('user_failed_login_identifier_uid_only', false)) {
         // Register flood events based on the uid only, so they apply for any
         // IP address. This is the most secure option.
         $identifier = $uid;
     } else {
         // The default identifier is a combination of uid and IP address. This
         // is less secure but more resistant to denial-of-service attacks that
         // could lock out all users with public user names.
         $identifier = $uid;
         // . '-' . ip_address();
     }
     // Don't allow login if the limit for this user has been reached.
     // Default is to allow 5 failed attempts every 6 hours.
     if (flood_is_allowed('failed_login_attempt_user', variable_get('user_failed_login_user_limit', 5), variable_get('user_failed_login_user_window', 21600), $identifier)) {
         // We are not limited by flood control, so try to authenticate.
         if ($uid = user_authenticate($username, $password)) {
             // Clear the user based flood control.
             flood_clear_event('failed_login_attempt_user', $identifier);
             $user = user_load($uid);
             return user_load($uid);
         }
         flood_register_event('failed_login_attempt_user', variable_get('user_failed_login_user_window', 3600), $identifier);
     } else {
         flood_register_event('failed_login_attempt_user', variable_get('user_failed_login_user_window', 3600), $identifier);
         throw new FloodException(format_string('Rejected by user flood control.'));
     }
 }
开发者ID:riccardoravaro,项目名称:restfull_toboggan,代码行数:59,代码来源:BasicAuthenticationToboggan.php

示例11: test2

 /**
  * Test controller action 2.
  */
 public function test2()
 {
     $result = db_query_range('SELECT * FROM node');
     $taxonomies = array('Innovation' => array('items' => array('New fans', 'New materials')), 'Current Technology' => array('items' => array('Fans')));
     $taxonomies['nodes'] = count($result);
     foreach ($result as $record) {
         // Perform operations on $record->title, etc. here.
         $taxonomies[$record->title] = $record->title;
     }
     $response = new Response();
     $response->setContent(json_encode($taxonomies));
     $response->headers->set('Content-Type', 'application/json');
     return $response;
 }
开发者ID:flesheater,项目名称:drupal8_modules_experiments,代码行数:17,代码来源:TestController.php

示例12: _notifications_node_references

/**
 * Find node title matches.
 * 
 * Some code from CCK's nodereference.module
 */
function _notifications_node_references($string, $match = 'contains', $types = array(), $limit = 10)
{
    $match_operators = array('contains' => "LIKE '%%%s%%'", 'equals' => "= '%s'", 'starts_with' => "LIKE '%s%%'");
    if ($types) {
        $where[] = 'n.type IN (' . db_placeholders($types, 'char') . ') ';
        $args = $types;
    }
    $where[] = 'n.title ' . (isset($match_operators[$match]) ? $match_operators[$match] : $match_operators['contains']);
    $args[] = $string;
    $sql = db_rewrite_sql('SELECT n.nid, n.title, n.type FROM {node} n WHERE ' . implode(' AND ', $where) . ' ORDER BY n.title, n.type');
    $result = db_query_range($sql, $args, 0, $limit);
    $references = array();
    while ($node = db_fetch_object($result)) {
        $references[$node->nid] = array('title' => $node->title, 'rendered' => check_plain($node->title));
    }
    return $references;
}
开发者ID:BenK,项目名称:notifications,代码行数:22,代码来源:code_update.php

示例13: page

    /**
     * Page callback showing ZG results.
     *
     * @return string
     *   Rendered page content.
     */
    public function page()
    {
        $limit = REQUEST_TIME - Statistics::ONEDAY * $this->days;
        drupal_set_title(t('Zeitgeist over the last @days days', array('@days' => $this->days)), PASS_THROUGH);
        $height = $this->getHeight();
        $ar_searches = array();
        $sql = <<<SQL
SELECT DISTINCT zg.search, count(zg.ts) AS nts
FROM {zeitgeist} zg
WHERE zg.ts >= :ts
GROUP BY zg.search
ORDER BY nts DESC, zg.search ASC
SQL;
        // No access control on this table.
        $results = db_query_range($sql, 0, $height * 3, array(':ts' => $limit));
        foreach ($results as $result) {
            if ($result->search == '') {
                $result->search = '&lt;vide&gt;';
            }
            $ar_searches[$result->search] = $result->nts;
        }
        $results_count = count($ar_searches);
        $break = $results_count / 3;
        $rows = array();
        $offset_in_column = 0;
        foreach ($ar_searches as $search => $count) {
            if ($offset_in_column < $break) {
                $rows[$offset_in_column] = array($search, $count, NULL, NULL, NULL, NULL);
            } elseif ($offset_in_column < 2 * $break) {
                $rows[$offset_in_column - $break][2] = $search;
                $rows[$offset_in_column - $break][3] = $count;
            } else {
                $rows[$offset_in_column - 2 * $break][4] = $search;
                $rows[$offset_in_column - 2 * $break][5] = $count;
            }
            $offset_in_column++;
        }
        $header = array(t('Search'), t('#'), t('Search'), t('#'), t('Search'), t('#'));
        $attributes = array();
        $ret = array();
        $ret['items'] = array('#theme' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => $attributes);
        $ret['note'] = array('#markup' => '<p>' . t('Searches below the pager <a href="!limit">limit</a> are not included in this list.', array('!limit' => url(ZGPATHSETTINGS))) . "</p>\n");
        return $ret;
    }
开发者ID:agroknow,项目名称:agreri,代码行数:50,代码来源:ReportMulticolumn.php

示例14: hook_autosave_prevent_alter

/**
 * Implements hook_autosave_prevent_alter().
 *
 * @param $prevent_autosave
 *   Set this to TRUE to prevent autosaving.
 *
 *   More useful parameters are in $_POST.
 */
function hook_autosave_prevent_alter(&$prevent_autosave)
{
    $path = $_POST['autosave_form_path'];
    $path_args = explode("/", $path);
    // check if node has just been saved - if it has then it's because AS ajax fired off as user was submitting
    // if it had just been submitted - no need to AS now
    //    - easy to figure out if we are submitting an edit to existing node
    //    - little harder if we have just added a node
    if ($path_args[0] == 'node') {
        // update case
        if (is_numeric($path_args[1])) {
            $submitted = node_load($path_args[1]);
        } else {
            // add case
            $submitted = db_query_range("SELECT created AS changed FROM {node} WHERE uid = :uid and type = :type ORDER BY created DESC", 0, 1, array(':uid' => $user->uid, ':type' => str_replace("-", "_", $path_args[2])))->fetchObject();
        }
        $prevent_autosave = $submitted && REQUEST_TIME - $submitted->changed < variable_get('autosave_period', 10) ? TRUE : $prevent_autosave;
    }
}
开发者ID:kreynen,项目名称:elmsln,代码行数:27,代码来源:autosave.api.php

示例15: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(array $form, FormStateInterface $form_state, AccountInterface $account = NULL)
 {
     $form['file'] = array('#type' => 'details', '#title' => $this->t('Administration'));
     // Drop out early if we don't even have any files uploaded.
     if (!db_query_range('SELECT 1 FROM {uc_files}', 0, 1)->fetchField()) {
         $form['file']['file_message'] = array('#prefix' => '<p>', '#markup' => $this->t('You must add files at the <a href=":url">Ubercart file download administration page</a> in order to attach them to a user.', [':url' => Url::fromRoute('uc_file.downloads', [], ['query' => ['destination' => 'user/' . $account->id() . '/edit']])->toString()]), '#suffix' => '</p>');
         return $form;
     }
     // Table displaying current downloadable files and limits.
     $form['file']['download']['#theme'] = 'uc_file_hook_user_file_downloads';
     $form['file']['download']['file_download']['#tree'] = TRUE;
     $downloadable_files = array();
     $file_downloads = db_query("SELECT * FROM {uc_file_users} ufu INNER JOIN {uc_files} uf ON ufu.fid = uf.fid WHERE ufu.uid = :uid ORDER BY uf.filename ASC", [':uid' => $account->id()]);
     $behavior = 0;
     foreach ($file_downloads as $file_download) {
         // Store a flat array so we can array_diff the ones already allowed when
         // building the list of which can be attached.
         $downloadable_files[$file_download->fid] = $file_download->filename;
         $form['file']['download']['file_download'][$file_download->fid] = array('fuid' => array('#type' => 'value', '#value' => $file_download->fuid), 'expiration' => array('#type' => 'value', '#value' => $file_download->expiration), 'remove' => array('#type' => 'checkbox'), 'filename' => array('#markup' => $file_download->filename), 'expires' => array('#markup' => $file_download->expiration ? \Drupal::service('date.formatter')->format($file_download->expiration, 'short') : $this->t('Never')), 'time_polarity' => array('#type' => 'select', '#default_value' => '+', '#options' => array('+' => '+', '-' => '-')), 'time_quantity' => array('#type' => 'textfield', '#size' => 2, '#maxlength' => 2), 'time_granularity' => array('#type' => 'select', '#default_value' => 'day', '#options' => array('never' => $this->t('never'), 'day' => $this->t('day(s)'), 'week' => $this->t('week(s)'), 'month' => $this->t('month(s)'), 'year' => $this->t('year(s)'))), 'downloads_in' => array('#markup' => $file_download->accessed), 'download_limit' => array('#type' => 'textfield', '#maxlength' => 3, '#size' => 3, '#default_value' => $file_download->download_limit ? $file_download->download_limit : NULL), 'addresses_in' => array('#markup' => count(unserialize($file_download->addresses))), 'address_limit' => array('#type' => 'textfield', '#maxlength' => 2, '#size' => 2, '#default_value' => $file_download->address_limit ? $file_download->address_limit : NULL));
         // Incrementally add behaviors.
         _uc_file_download_table_behavior($behavior++, $file_download->fid);
         // Store old values for comparing to see if we actually made any changes.
         $less_reading =& $form['file']['download']['file_download'][$file_download->fid];
         $less_reading['download_limit_old'] = array('#type' => 'value', '#value' => $less_reading['download_limit']['#default_value']);
         $less_reading['address_limit_old'] = array('#type' => 'value', '#value' => $less_reading['address_limit']['#default_value']);
         $less_reading['expiration_old'] = array('#type' => 'value', '#value' => $less_reading['expiration']['#value']);
     }
     // Create the list of files able to be attached to this user.
     $available_files = array();
     $files = db_query("SELECT * FROM {uc_files} ORDER BY filename ASC");
     foreach ($files as $file) {
         if (substr($file->filename, -1) != '/' && substr($file->filename, -1) != '\\') {
             $available_files[$file->fid] = $file->filename;
         }
     }
     // Dialog for uploading new files.
     $available_files = array_diff($available_files, $downloadable_files);
     if (count($available_files)) {
         $form['file']['file_add'] = array('#type' => 'select', '#multiple' => TRUE, '#size' => 6, '#title' => $this->t('Add file'), '#description' => $this->t('Select a file to add as a download. Newly added files will inherit the settings at the :url.', [':url' => Link::createFromRoute($this->t('Ubercart product settings page'), 'uc_product.settings')->toString()]), '#options' => $available_files, '#tree' => TRUE);
     }
     $form['file']['submit'] = array('#type' => 'submit', '#value' => $this->t('Save'));
     return $form;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:46,代码来源:UserForm.php


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