/[drupal]/drupal/modules/node.module
ViewVC logotype

Diff of /drupal/modules/node.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.641, Thu Apr 27 22:20:51 2006 UTC revision 1.641.2.24, Tue Dec 12 12:48:57 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: node.module,v 1.640 2006/04/23 05:22:05 drumm Exp $  // $Id: node.module,v 1.641.2.23 2006/12/05 13:16:52 killes Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 43  function node_help($section) { Line 43  function node_help($section) {
43        return t('<p>Enter a simple pattern to search for a post. This can include the wildcard character *.<br />For example, a search for "br*" might return "bread bakers", "our daily bread" and "brenda".</p>');        return t('<p>Enter a simple pattern to search for a post. This can include the wildcard character *.<br />For example, a search for "br*" might return "bread bakers", "our daily bread" and "brenda".</p>');
44    }    }
45    
46    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions') {    if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions' && !arg(3)) {
47      return t('The revisions let you track differences between multiple versions of a post.');      return t('The revisions let you track differences between multiple versions of a post.');
48    }    }
49    
# Line 160  function node_teaser($body, $format = NU Line 160  function node_teaser($body, $format = NU
160      return $body;      return $body;
161    }    }
162    
163      // If a valid delimiter has been specified, use it to chop off the teaser.
164      if ($delimiter !== FALSE) {
165        return substr($body, 0, $delimiter);
166      }
167    
168    // We check for the presence of the PHP evaluator filter in the current    // We check for the presence of the PHP evaluator filter in the current
169    // format. If the body contains PHP code, we do not split it up to prevent    // format. If the body contains PHP code, we do not split it up to prevent
170    // parse errors.    // parse errors.
# Line 170  function node_teaser($body, $format = NU Line 175  function node_teaser($body, $format = NU
175      }      }
176    }    }
177    
   // If a valid delimiter has been specified, use it to chop of the teaser.  
   if ($delimiter !== FALSE) {  
     return substr($body, 0, $delimiter);  
   }  
   
178    // If we have a short body, the entire body is the teaser.    // If we have a short body, the entire body is the teaser.
179    if (strlen($body) < $size) {    if (strlen($body) < $size) {
180      return $body;      return $body;
# Line 345  function node_load($param = array(), $re Line 345  function node_load($param = array(), $re
345      $nodes = array();      $nodes = array();
346    }    }
347    
348      $cachable = FALSE;
349    $arguments = array();    $arguments = array();
350    if (is_numeric($param)) {    if (is_numeric($param)) {
351      $cachable = $revision == NULL;      $cachable = $revision == NULL;
352      if ($cachable && isset($nodes[$param])) {      if ($cachable && isset($nodes[$param])) {
353        return $nodes[$param];        return is_object($nodes[$param]) ? drupal_clone($nodes[$param]) : $nodes[$param];
354      }      }
355      $cond = 'n.nid = %d';      $cond = 'n.nid = %d';
356      $arguments[] = $param;      $arguments[] = $param;
# Line 364  function node_load($param = array(), $re Line 365  function node_load($param = array(), $re
365    }    }
366    
367    // Retrieve the node.    // Retrieve the node.
368      // No db_rewrite_sql is applied so as to get complete indexing for search.
369    if ($revision) {    if ($revision) {
370      array_unshift($arguments, $revision);      array_unshift($arguments, $revision);
371      $node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, r.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE '. $cond), $arguments));      $node = db_fetch_object(db_query('SELECT n.nid, r.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.nid = n.nid AND r.vid = %d WHERE '. $cond, $arguments));
372    }    }
373    else {    else {
374      $node = db_fetch_object(db_query(db_rewrite_sql('SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE '. $cond), $arguments));      $node = db_fetch_object(db_query('SELECT n.nid, n.vid, n.type, n.status, n.created, n.changed, n.comment, n.promote, n.moderate, n.sticky, r.timestamp AS revision_timestamp, r.title, r.body, r.teaser, r.log, r.format, u.uid, u.name, u.picture, u.data FROM {node} n INNER JOIN {users} u ON u.uid = n.uid INNER JOIN {node_revisions} r ON r.vid = n.vid WHERE '. $cond, $arguments));
375    }    }
376    
377    if ($node->nid) {    if ($node->nid) {
# Line 389  function node_load($param = array(), $re Line 391  function node_load($param = array(), $re
391    }    }
392    
393    if ($cachable) {    if ($cachable) {
394      $nodes[$param] = $node;      $nodes[$param] = is_object($node) ? drupal_clone($node) : $node;
395    }    }
396    
397    return $node;    return $node;
# Line 805  function node_link($type, $node = 0, $ma Line 807  function node_link($type, $node = 0, $ma
807    $links = array();    $links = array();
808    
809    if ($type == 'node') {    if ($type == 'node') {
     if (array_key_exists('links', $node)) {  
       $links = $node->links;  
     }  
   
810      if ($main == 1 && $node->teaser && $node->readmore) {      if ($main == 1 && $node->teaser && $node->readmore) {
811        $links[] = l(t('read more'), "node/$node->nid", array('title' => t('Read the rest of this posting.'), 'class' => 'read-more'));        $links[] = l(t('read more'), "node/$node->nid", array('title' => t('Read the rest of this posting.'), 'class' => 'read-more'));
812      }      }
# Line 847  function node_menu($may_cache) { Line 845  function node_menu($may_cache) {
845      $items[] = array('path' => 'node', 'title' => t('content'),      $items[] = array('path' => 'node', 'title' => t('content'),
846        'callback' => 'node_page',        'callback' => 'node_page',
847        'access' => user_access('access content'),        'access' => user_access('access content'),
848        'type' => MENU_SUGGESTED_ITEM);        'type' => MENU_MODIFIABLE_BY_ADMIN);
849      $items[] = array('path' => 'node/add', 'title' => t('create content'),      $items[] = array('path' => 'node/add', 'title' => t('create content'),
850        'callback' => 'node_page',        'callback' => 'node_page',
851        'access' => user_access('access content'),        'access' => user_access('access content'),
# Line 884  function node_menu($may_cache) { Line 882  function node_menu($may_cache) {
882            'access' => $revisions_access,            'access' => $revisions_access,
883            'weight' => 2,            'weight' => 2,
884            'type' => MENU_LOCAL_TASK);            'type' => MENU_LOCAL_TASK);
885            $items[] = array('path' => 'node/'. arg(1) .'/revisions/' . arg(3) . '/delete',
886              'title' => t('revisions'),
887              'callback' => 'node_revisions',
888              'access' => $revisions_access,
889              'weight' => 2,
890              'type' => MENU_CALLBACK);
891            $items[] = array('path' => 'node/'. arg(1) .'/revisions/' . arg(3) . '/revert',
892              'title' => t('revisions'),
893              'callback' => 'node_revisions',
894              'access' => $revisions_access,
895              'weight' => 2,
896              'type' => MENU_CALLBACK);
897        }        }
898      }      }
899      else if (arg(0) == 'admin' && arg(1) == 'settings' && arg(2) == 'content-types' && is_string(arg(3))) {      else if (arg(0) == 'admin' && arg(1) == 'settings' && arg(2) == 'content-types' && is_string(arg(3))) {
# Line 907  function node_last_changed($nid) { Line 917  function node_last_changed($nid) {
917  function node_operations() {  function node_operations() {
918    $operations = array(    $operations = array(
919      'approve' =>   array(t('Approve the selected posts'), 'UPDATE {node} SET status = 1, moderate = 0 WHERE nid = %d'),      'approve' =>   array(t('Approve the selected posts'), 'UPDATE {node} SET status = 1, moderate = 0 WHERE nid = %d'),
920      'promote' =>   array(t('Promote the selected posts'), 'UPDATE {node} SET status = 1, promote = 1 WHERE nid = %d'),      'promote' =>   array(t('Promote the selected posts'), 'UPDATE {node} SET status = 1, promote = 1, moderate = 0 WHERE nid = %d'),
921      'sticky' =>    array(t('Make the selected posts sticky'), 'UPDATE {node} SET status = 1, sticky = 1 WHERE nid = %d'),      'sticky' =>    array(t('Make the selected posts sticky'), 'UPDATE {node} SET status = 1, sticky = 1 WHERE nid = %d'),
922      'demote' =>    array(t('Demote the selected posts'), 'UPDATE {node} SET promote = 0 WHERE nid = %d'),      'demote' =>    array(t('Demote the selected posts'), 'UPDATE {node} SET promote = 0 WHERE nid = %d'),
923      'unpublish' => array(t('Unpublish the selected posts'), 'UPDATE {node} SET status = 0 WHERE nid = %d'),      'unpublish' => array(t('Unpublish the selected posts'), 'UPDATE {node} SET status = 0 WHERE nid = %d'),
# Line 1094  function node_admin_nodes_submit($form_i Line 1104  function node_admin_nodes_submit($form_i
1104          db_query($operation, $nid);          db_query($operation, $nid);
1105        }        }
1106      }      }
1107        cache_clear_all();
1108      drupal_set_message(t('The update has been performed.'));      drupal_set_message(t('The update has been performed.'));
1109    }    }
1110  }  }
# Line 1307  function node_revision_revert($nid, $rev Line 1318  function node_revision_revert($nid, $rev
1318    $node = node_load($nid, $revision);    $node = node_load($nid, $revision);
1319    if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {    if ((user_access('revert revisions') || user_access('administer nodes')) && node_access('update', $node)) {
1320      if ($node->vid) {      if ($node->vid) {
1321        $node->revision = 1;        $form = array();
1322        $node->log = t('Copy of the revision from %date.', array('%date' => theme('placeholder', format_date($node->revision_timestamp))));        $form['nid'] = array('#type' => 'value', '#value' => $node->nid);
1323        $node->taxonomy = array_keys($node->taxonomy);        $form['vid'] = array('#type' => 'value', '#value' => $node->vid);
1324          return confirm_form('node_revision_revert_confirm', $form,
1325        node_save($node);                       t('Are you sure you want to revert %title to the revision from %revision-date?', array('%title' => theme('placeholder', $node->title), '%revision-date' => theme('placeholder', format_date($node->revision_timestamp)))),
1326                         "node/$nid/revisions", ' ', t('Revert'), t('Cancel'));
       drupal_set_message(t('%title has been reverted back to the revision from %revision-date', array('%revision-date' => theme('placeholder', format_date($node->revision_timestamp)), '%title' => theme('placeholder', check_plain($node->title)))));  
       watchdog('content', t('%type: reverted %title revision %revision.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title), '%revision' => theme('placeholder', $revision))));  
1327      }      }
1328      else {      else {
1329        drupal_set_message(t('You tried to revert to an invalid revision.'), 'error');        drupal_set_message(t('You tried to revert to an invalid revision.'), 'error');
# Line 1324  function node_revision_revert($nid, $rev Line 1333  function node_revision_revert($nid, $rev
1333    drupal_access_denied();    drupal_access_denied();
1334  }  }
1335    
1336    function node_revision_revert_confirm_submit($form_id, $form_values) {
1337      $nid = $form_values['nid'];
1338      $revision = $form_values['vid'];
1339      $node = node_load($nid, $revision);
1340      $node->revision = 1;
1341      $node->log = t('Copy of the revision from %date.', array('%date' => theme('placeholder', format_date($node->revision_timestamp))));
1342      if (module_exist('taxonomy')) {
1343        $node->taxonomy = array_keys($node->taxonomy);
1344      }
1345    
1346      node_save($node);
1347      drupal_set_message(t('%title has been reverted back to the revision from %revision-date', array('%revision-date' => theme('placeholder', format_date($node->revision_timestamp)), '%title' => theme('placeholder', check_plain($node->title)))));
1348      watchdog('content', t('%type: reverted %title revision %revision.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title), '%revision' => theme('placeholder', $revision))));
1349      return 'node/'. $nid .'/revisions';
1350    }
1351    
1352  /**  /**
1353   * Delete the revision with specified revision number. A "delete revision" nodeapi event is invoked when a   * Delete the revision with specified revision number. A "delete revision" nodeapi event is invoked when a
1354   * revision is deleted.   * revision is deleted.
# Line 1335  function node_revision_delete($nid, $rev Line 1360  function node_revision_delete($nid, $rev
1360        // Don't delete the current revision        // Don't delete the current revision
1361        if ($revision != $node->vid) {        if ($revision != $node->vid) {
1362          $node = node_load($nid, $revision);          $node = node_load($nid, $revision);
1363            $form = array();
1364          db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $nid, $revision);          $form['nid'] = array('#type' => 'value', '#value' => $nid);
1365          node_invoke_nodeapi($node, 'delete revision');          $form['vid'] = array('#type' => 'value', '#value' => $revision);
1366          drupal_set_message(t('Deleted %title revision %revision.', array('%title' => theme('placeholder', $node->title), '%revision' => theme('placeholder', $revision))));          return confirm_form('node_revision_delete_confirm', $form,
1367          watchdog('content', t('%type: deleted %title revision %revision.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title), '%revision' => theme('placeholder', $revision))));                       t('Are you sure you want to delete %title revision %revision?', array('%title' => theme('placeholder', $node->title), '%revision' => theme('placeholder', $revision))),
1368                         "node/$nid/revisions", '', t('Delete'), t('Cancel'));
1369        }        }
   
1370        else {        else {
1371          drupal_set_message(t('Deletion failed. You tried to delete the current revision.'));          drupal_set_message(t('Deletion failed. You tried to delete the current revision.'));
1372        }        }
# Line 1353  function node_revision_delete($nid, $rev Line 1378  function node_revision_delete($nid, $rev
1378        }        }
1379      }      }
1380    }    }
   
1381    drupal_access_denied();    drupal_access_denied();
1382  }  }
1383    
1384    function node_revision_delete_confirm_submit($form_id, $form_values) {
1385      $node = node_load($form_values['nid'], $form_values['vid']);
1386      db_query("DELETE FROM {node_revisions} WHERE nid = %d AND vid = %d", $node->nid, $node->vid);
1387      node_invoke_nodeapi($node, 'delete revision');
1388      drupal_set_message(t('Deleted %title revision %revision.', array('%title' => theme('placeholder', $node->title), '%revision' => theme('placeholder', $node->vid))));
1389      watchdog('content', t('%type: deleted %title revision %revision.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title), '%revision' => theme('placeholder', $node->revision))));
1390    
1391      if (db_result(db_query('SELECT COUNT(vid) FROM {node_revisions} WHERE nid = %d', $node->nid)) > 1) {
1392        return "node/$node->nid/revisions";
1393      }
1394      return "node/$node->nid";
1395    }
1396    
1397  /**  /**
1398   * Return a list of all the existing revision numbers.   * Return a list of all the existing revision numbers.
1399   */   */
# Line 1404  function node_feed($nodes = 0, $channel Line 1441  function node_feed($nodes = 0, $channel
1441    global $base_url, $locale;    global $base_url, $locale;
1442    
1443    if (!$nodes) {    if (!$nodes) {
1444      $nodes = db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, variable_get('feed_default_items', 10));      $nodes = db_query_range(db_rewrite_sql('SELECT n.nid, n.created FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, variable_get('feed_default_items', 10));
1445    }    }
1446    
1447    $item_length = variable_get('feed_item_length', 'teaser');    $item_length = variable_get('feed_item_length', 'teaser');
# Line 1430  function node_feed($nodes = 0, $channel Line 1467  function node_feed($nodes = 0, $channel
1467        node_invoke_nodeapi($item, 'view', $teaser, FALSE);        node_invoke_nodeapi($item, 'view', $teaser, FALSE);
1468      }      }
1469    
1470        // Allow modules to add additional item fields
1471        $extra = node_invoke_nodeapi($item, 'rss item');
1472        $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' =>  date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))));
1473        foreach ($extra as $element) {
1474          if ($element['namespace']) {
1475            $namespaces = array_merge($namespaces, $element['namespace']);
1476          }
1477        }
1478    
1479      // Prepare the item description      // Prepare the item description
1480      switch ($item_length) {      switch ($item_length) {
1481        case 'fulltext':        case 'fulltext':
# Line 1446  function node_feed($nodes = 0, $channel Line 1492  function node_feed($nodes = 0, $channel
1492          break;          break;
1493      }      }
1494    
     // Allow modules to add additional item fields  
     $extra = node_invoke_nodeapi($item, 'rss item');  
     $extra = array_merge($extra, array(array('key' => 'pubDate', 'value' =>  date('r', $item->created)), array('key' => 'dc:creator', 'value' => $item->name), array('key' => 'guid', 'value' => $item->nid . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))));  
     foreach ($extra as $element) {  
       if ($element['namespace']) {  
         $namespaces = array_merge($namespaces, $element['namespace']);  
       }  
     }  
1495      $items .= format_rss_item($item->title, $link, $item_text, $extra);      $items .= format_rss_item($item->title, $link, $item_text, $extra);
1496    }    }
1497    
# Line 1471  function node_feed($nodes = 0, $channel Line 1509  function node_feed($nodes = 0, $channel
1509    $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);    $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language']);
1510    $output .= "</rss>\n";    $output .= "</rss>\n";
1511    
1512    drupal_set_header('Content-Type: text/xml; charset=utf-8');    drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');
1513    print $output;    print $output;
1514  }  }
1515    
# Line 1533  function node_validate($node, $form = ar Line 1571  function node_validate($node, $form = ar
1571    }    }
1572    
1573    if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {    if (isset($node->nid) && (node_last_changed($node->nid) > $node->changed)) {
1574      form_set_error('changed', t('This content has been modified by another user; changes cannot be saved.'));      form_set_error('changed', t('This content has been modified by another user, changes cannot be saved.'));
1575    }    }
1576    
1577    if (user_access('administer nodes')) {    if (user_access('administer nodes')) {
# Line 1597  function node_form_array($node) { Line 1635  function node_form_array($node) {
1635     * Basic node information.     * Basic node information.
1636     * These elements are just values so they are not even sent to the client.     * These elements are just values so they are not even sent to the client.
1637     */     */
1638    foreach (array('nid', 'vid', 'uid', 'created', 'changed', 'type') as $key) {    foreach (array('nid', 'vid', 'uid', 'created', 'type') as $key) {
1639      $form[$key] = array('#type' => 'value', '#value' => $node->$key);      $form[$key] = array('#type' => 'value', '#value' => $node->$key);
1640    }    }
1641    
1642      // Changed must be sent to the client, for later overwrite error checking.
1643      $form['changed'] = array('#type' => 'hidden', '#default_value' => $node->changed);
1644    
1645    // Get the node-specific bits.    // Get the node-specific bits.
1646    $form = array_merge_recursive($form, node_invoke($node, 'form'));    $form = array_merge_recursive($form, node_invoke($node, 'form'));
1647    if (!isset($form['title']['#weight'])) {    if (!isset($form['title']['#weight'])) {
# Line 1659  function node_form_array($node) { Line 1700  function node_form_array($node) {
1700    return $form;    return $form;
1701  }  }
1702    
1703  function node_form_add_preview($form, $edit) {  function node_form_add_preview($form) {
1704      global $form_values;
1705    
1706    $op = isset($_POST['op']) ? $_POST['op'] : '';    $op = isset($_POST['op']) ? $_POST['op'] : '';
1707    if ($op == t('Preview')) {    if ($op == t('Preview')) {
1708      drupal_validate_form($form['form_id']['#value'], $form);      drupal_validate_form($form['form_id']['#value'], $form);
1709      if (!form_get_errors()) {      if (!form_get_errors()) {
1710        $form['node_preview'] = array('#value' => node_preview((object)$edit), '#weight' => -100);        // We pass the global $form_values here to preserve changes made during form validation
1711          $form['node_preview'] = array('#value' => node_preview((object)$form_values), '#weight' => -100);
1712      }      }
1713    }    }
1714    if (variable_get('node_preview', 0) && (form_get_errors() || $op != t('Preview'))) {    if (variable_get('node_preview', 0) && (form_get_errors() || $op != t('Preview'))) {
# Line 1674  function node_form_add_preview($form, $e Line 1718  function node_form_add_preview($form, $e
1718  }  }
1719    
1720  function theme_node_form($form) {  function theme_node_form($form) {
1721    $output = '<div class="node-form">';    $output = "\n<div class=\"node-form\">\n";
1722    if (isset($form['node_preview'])) {    if (isset($form['node_preview'])) {
1723      $output .= form_render($form['node_preview']);      $output .= form_render($form['node_preview']);
1724    }    }
1725    
1726    $output .= '  <div class="standard">';    // Admin form fields and submit buttons must be rendered first, because
1727      // they need to go to the bottom of the form, and so should not be part of
1728      // the catch-all call to form_render().
1729      $admin = '';
1730      if (isset($form['author'])) {
1731        $admin .= "    <div class=\"authored\">\n";
1732        $admin .= form_render($form['author']);
1733        $admin .= "    </div>\n";
1734      }
1735      if (isset($form['options'])) {
1736        $admin .= "    <div class=\"options\">\n";
1737        $admin .= form_render($form['options']);
1738        $admin .= "    </div>\n";
1739      }
1740      $buttons = form_render($form['preview']);
1741      $buttons .= form_render($form['submit']);
1742      $buttons .= isset($form['delete']) ? form_render($form['delete']) : '';
1743    
1744      // Everything else gets rendered here, and is displayed before the admin form
1745      // field and the submit buttons.
1746      $output .= "  <div class=\"standard\">\n";
1747    $output .= form_render($form);    $output .= form_render($form);
1748    $output .= '  </div>';    $output .= "  </div>\n";
1749    $output .= '  <div class="admin">';  
1750    $output .= '    <div class="authored">';    if (!empty($admin)) {
1751    $output .= form_render($form['author']);      $output .= "  <div class=\"admin\">\n";
1752    $output .= '    </div>';      $output .= $admin;
1753    $output .= '    <div class="options">';      $output .= "  </div>\n";
1754    $output .= form_render($form['options']);    }
1755    $output .= '    </div>';    $output .= $buttons;
1756    $output .= '  </div>';    $output .= "</div>\n";
1757    $output .= '</div>';  
1758    return $output;    return $output;
1759  }  }
1760    
# Line 1711  function node_add($type) { Line 1775  function node_add($type) {
1775    else {    else {
1776      // If no (valid) node type has been provided, display a node type overview.      // If no (valid) node type has been provided, display a node type overview.
1777      foreach (node_get_types() as $type => $name) {      foreach (node_get_types() as $type => $name) {
1778        if (module_invoke(node_get_base($type), 'access', 'create', $type)) {        if (node_access('create', $type)) {
1779          $out = '<dt>'. l($name, "node/add/$type", array('title' => t('Add a new %s.', array('%s' => $name)))) .'</dt>';          $out = '<dt>'. l($name, "node/add/$type", array('title' => t('Add a new %s.', array('%s' => $name)))) .'</dt>';
1780          $out .= '<dd>'. implode("\n", module_invoke_all('help', 'node/add#'. $type)) .'</dd>';          $out .= '<dd>'. implode("\n", module_invoke_all('help', 'node/add#'. $type)) .'</dd>';
1781          $item[$name] = $out;          $item[$name] = $out;
# Line 1719  function node_add($type) { Line 1783  function node_add($type) {
1783      }      }
1784    
1785      if (isset($item)) {      if (isset($item)) {
1786        uasort($item, 'strnatcasecmp');        uksort($item, 'strnatcasecmp');
1787        $output = t('Choose the appropriate item from the list:') .'<dl>'. implode('', $item) .'</dl>';        $output = t('Choose the appropriate item from the list:') .'<dl>'. implode('', $item) .'</dl>';
1788      }      }
1789      else {      else {
# Line 1810  function node_form_submit($form_id, $edi Line 1874  function node_form_submit($form_id, $edi
1874    if ($node->nid) {    if ($node->nid) {
1875      // Check whether the current user has the proper access rights to      // Check whether the current user has the proper access rights to
1876      // perform this operation:      // perform this operation:
1877      if (node_access('update', $node)) {      $original_node = node_load($node->nid); //check access rights using the unmodified node
1878        if (node_access('update', $original_node)) {
1879        node_save($node);        node_save($node);
1880        watchdog('content', t('%type: updated %title.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));        watchdog('content', t('%type: updated %title.', array('%type' => theme('placeholder', t($node->type)), '%title' => theme('placeholder', $node->title))), WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
1881        drupal_set_message(t('The %post was updated.', array ('%post' => node_get_name($node))));        drupal_set_message(t('The %post was updated.', array ('%post' => node_get_name($node))));
# Line 1922  function node_revisions() { Line 1987  function node_revisions() {
1987          }          }
1988          break;          break;
1989        case 'revert':        case 'revert':
1990          node_revision_revert(arg(1), arg(3));          return node_revision_revert(arg(1), arg(3));
1991          break;          break;
1992        case 'delete':        case 'delete':
1993          node_revision_delete(arg(1), arg(3));          return node_revision_delete(arg(1), arg(3));
1994          break;          break;
1995      }      }
1996    }    }
# Line 1951  function node_page_default() { Line 2016  function node_page_default() {
2016      $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));      $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
2017    }    }
2018    else {    else {
2019      $output = t("      $output = t('
2020        <p>Welcome to your new <a href=\"%drupal\">Drupal</a>-powered website. This message will guide you through your first steps with Drupal, and will disappear once you have posted your first piece of content.</p>        <h1 class="title">Welcome to your new Drupal website!</h1>
2021        <p>The first thing you will need to do is <a href=\"%register\">create the first account</a>. This account will have full administration rights and will allow you to configure your website. Once logged in, you can visit the <a href=\"%admin\">administration section</a> and <a href=\"%config\">set up your site's configuration</a>.</p>        <p>Please follow these steps to set up and start using your website:</p>
2022        <p>Drupal comes with various modules, each of which contains a specific piece of functionality. You should visit the <a href=\"%modules\">module list</a> and enable those modules which suit your website's needs.</p>        <ol>
2023        <p><a href=\"%themes\">Themes</a> handle the presentation of your website. You can use one of the existing themes, modify them or create your own from scratch.</p>          <li>
2024        <p>We suggest you look around the administration section and explore the various options Drupal offers you. For more information, you can refer to the <a href=\"%handbook\">Drupal handbooks online</a>.</p>", array('%drupal' => 'http://drupal.org/', '%register' => url('user/register'), '%admin' => url('admin'), '%config' => url('admin/settings'), '%modules' => url('admin/modules'), '%themes' => url('admin/themes'), '%handbook' => 'http://drupal.org/handbooks'));            <strong>Create your administrator account</strong>
2025              To begin, <a href="%register">create the first account</a>. This account will have full administration rights and will allow you to configure your website.
2026            </li>
2027            <li>
2028              <strong>Configure your website</strong>
2029              Once logged in, visit the <a href="%admin">administration section</a>, where you can <a href="%config">customize and configure</a> all aspects of your website.
2030            </li>
2031            <li>
2032              <strong>Enable additional functionality</strong>
2033              Next, visit the <a href="%modules">module list</a> and enable features which suit your specific needs. You can find additional modules in the <a href="%download_modules">Drupal modules download section</a>.
2034            </li>
2035            <li>
2036              <strong>Customize your website design</strong>
2037              To change the "look and feel" of your website, visit the <a href="%themes">themes section</a>. You may choose from one of the included themes or download additional themes from the <a href="%download_themes">Drupal themes download section</a>.
2038            </li>
2039            <li>
2040              <strong>Start posting content</strong>
2041              Finally, you can <a href="%content">create content</a> for your website. This message will disappear once you have published your first post.
2042            </li>
2043          </ol>
2044          <p>For more information, please refer to the <a href="%help">Help section</a>, or the <a href="%handbook">online Drupal handbooks</a>. You may also post at the <a href="%forum">Drupal forum</a>, or view the wide range of <a href="%support">other support options</a> available.</p>',
2045          array('%drupal' => 'http://drupal.org/', '%register' => url('user/register'), '%admin' => url('admin'), '%config' => url('admin/settings'), '%modules' => url('admin/modules'), '%download_modules' => 'http://drupal.org/project/modules', '%themes' => url('admin/themes'), '%download_themes' => 'http://drupal.org/project/themes', '%content' => url('node/add'), '%help' => url('admin/help'), '%handbook' => 'http://drupal.org/handbooks', '%forum' => 'http://drupal.org/forum', '%support' => 'http://drupal.org/support')
2046        );
2047        $output = '<div id="first-time">'. $output .'</div>';
2048    }    }
2049    
2050    return $output;    return $output;
# Line 2049  function node_update_index() { Line 2137  function node_update_index() {
2137    variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}'))));    variable_set('node_cron_comments_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(comment_count) FROM {node_comment_statistics}'))));
2138    variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));    variable_set('node_cron_views_scale', 1.0 / max(1, db_result(db_query('SELECT MAX(totalcount) FROM {node_counter}'))));
2139    
2140    $result = db_query_range('SELECT GREATEST(c.last_comment_timestamp, n.changed) as last_change, n.nid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND ((GREATEST(n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR (n.changed > %d OR c.last_comment_timestamp > %d)) ORDER BY GREATEST(n.changed, c.last_comment_timestamp) ASC, n.nid ASC', $last, $last_nid, $last, $last, $last, 0, $limit);    $result = db_query_range('SELECT GREATEST(IF(c.last_comment_timestamp IS NULL, 0, c.last_comment_timestamp), n.changed) as last_change, n.nid FROM {node} n LEFT JOIN {node_comment_statistics} c ON n.nid = c.nid WHERE n.status = 1 AND ((GREATEST(n.changed, c.last_comment_timestamp) = %d AND n.nid > %d) OR (n.changed > %d OR c.last_comment_timestamp > %d)) ORDER BY GREATEST(n.changed, c.last_comment_timestamp) ASC, n.nid ASC', $last, $last_nid, $last, $last, $last, 0, $limit);
2141    
2142    while ($node = db_fetch_object($result)) {    while ($node = db_fetch_object($result)) {
2143      $last_change = $node->last_change;      $last_change = $node->last_change;

Legend:
Removed from v.1.641  
changed lines
  Added in v.1.641.2.24

  ViewVC Help
Powered by ViewVC 1.1.2