webmaster@1: changed to avoid future timestamps. webmaster@1: */ webmaster@1: function comment_update_1() { webmaster@1: // Change any future last comment timestamps to now. webmaster@1: db_query('UPDATE {node_comment_statistics} SET last_comment_timestamp = %d WHERE last_comment_timestamp > %d', time(), time()); webmaster@1: webmaster@1: // Unstuck node indexing timestamp if needed. webmaster@1: if (($last = variable_get('node_cron_last', FALSE)) !== FALSE) { webmaster@1: variable_set('node_cron_last', min(time(), $last)); webmaster@1: } webmaster@1: return array(); webmaster@1: } webmaster@1: webmaster@1: function comment_update_6001() { webmaster@1: $ret[] = update_sql("ALTER TABLE {comments} DROP score"); webmaster@1: $ret[] = update_sql("ALTER TABLE {comments} DROP users"); webmaster@1: return $ret; webmaster@1: } webmaster@1: webmaster@1: /** webmaster@1: * Changed comment settings from global to per-node -- copy global webmaster@1: * settings to all node types. webmaster@1: */ webmaster@1: function comment_update_6002() { webmaster@1: // Comment module might not be enabled when this is run, but we need the webmaster@1: // constants defined by the module for this update. webmaster@1: drupal_load('module', 'comment'); webmaster@1: $settings = array( webmaster@1: 'comment_default_mode' => COMMENT_MODE_THREADED_EXPANDED, webmaster@1: 'comment_default_order' => COMMENT_ORDER_NEWEST_FIRST, webmaster@1: 'comment_default_per_page' => 50, webmaster@1: 'comment_controls' => COMMENT_CONTROLS_HIDDEN, webmaster@1: 'comment_anonymous' => COMMENT_ANONYMOUS_MAYNOT_CONTACT, webmaster@1: 'comment_subject_field' => 1, webmaster@1: 'comment_preview' => COMMENT_PREVIEW_REQUIRED, webmaster@1: 'comment_form_location' => COMMENT_FORM_SEPARATE_PAGE, webmaster@1: ); webmaster@1: $types = node_get_types(); webmaster@1: foreach ($settings as $setting => $default) { webmaster@1: $value = variable_get($setting, $default); webmaster@1: foreach ($types as $type => $object) { webmaster@1: variable_set($setting .'_'. $type, $value); webmaster@1: } webmaster@1: variable_del($setting); webmaster@1: } webmaster@1: return array(array('success' => TRUE, 'query' => 'Global comment settings copied to all node types.')); webmaster@1: } webmaster@1: webmaster@1: /** webmaster@1: * Add index to parent ID field. webmaster@1: */ webmaster@1: function comment_update_6003() { webmaster@1: $ret = array(); webmaster@1: db_add_index($ret, 'comments', 'pid', array('pid')); webmaster@1: return $ret; webmaster@1: } webmaster@1: webmaster@1: webmaster@1: /** webmaster@1: * Implementation of hook_schema(). webmaster@1: */ webmaster@1: function comment_schema() { webmaster@1: $schema['comments'] = array( webmaster@1: 'description' => t('Stores comments and associated data.'), webmaster@1: 'fields' => array( webmaster@1: 'cid' => array( webmaster@1: 'type' => 'serial', webmaster@1: 'not null' => TRUE, webmaster@1: 'description' => t('Primary Key: Unique comment ID.'), webmaster@1: ), webmaster@1: 'pid' => array( webmaster@1: 'type' => 'int', webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => 0, webmaster@1: 'description' => t('The {comments}.cid to which this comment is a reply. If set to 0, this comment is not a reply to an existing comment.'), webmaster@1: ), webmaster@1: 'nid' => array( webmaster@1: 'type' => 'int', webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => 0, webmaster@1: 'description' => t('The {node}.nid to which this comment is a reply.'), webmaster@1: ), webmaster@1: 'uid' => array( webmaster@1: 'type' => 'int', webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => 0, webmaster@1: 'description' => t('The {users}.uid who authored the comment. If set to 0, this comment was created by an anonymous user.'), webmaster@1: ), webmaster@1: 'subject' => array( webmaster@1: 'type' => 'varchar', webmaster@1: 'length' => 64, webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => '', webmaster@1: 'description' => t('The comment title.'), webmaster@1: ), webmaster@1: 'comment' => array( webmaster@1: 'type' => 'text', webmaster@1: 'not null' => TRUE, webmaster@1: 'size' => 'big', webmaster@1: 'description' => t('The comment body.'), webmaster@1: ), webmaster@1: 'hostname' => array( webmaster@1: 'type' => 'varchar', webmaster@1: 'length' => 128, webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => '', webmaster@1: 'description' => t("The author's host name."), webmaster@1: ), webmaster@1: 'timestamp' => array( webmaster@1: 'type' => 'int', webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => 0, webmaster@1: 'description' => t('The time that the comment was created, or last edited by its author, as a Unix timestamp.'), webmaster@1: ), webmaster@1: 'status' => array( webmaster@1: 'type' => 'int', webmaster@1: 'unsigned' => TRUE, webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => 0, webmaster@1: 'size' => 'tiny', webmaster@1: 'description' => t('The published status of a comment. (0 = Published, 1 = Not Published)'), webmaster@1: ), webmaster@1: 'format' => array( webmaster@1: 'type' => 'int', webmaster@1: 'size' => 'small', webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => 0, webmaster@1: 'description' => t('The {filter_formats}.format of the comment body.'), webmaster@1: ), webmaster@1: 'thread' => array( webmaster@1: 'type' => 'varchar', webmaster@1: 'length' => 255, webmaster@1: 'not null' => TRUE, webmaster@1: 'description' => t("The vancode representation of the comment's place in a thread."), webmaster@1: ), webmaster@1: 'name' => array( webmaster@1: 'type' => 'varchar', webmaster@1: 'length' => 60, webmaster@1: 'not null' => FALSE, webmaster@1: 'description' => t("The comment author's name. Uses {users}.name if the user is logged in, otherwise uses the value typed into the comment form."), webmaster@1: ), webmaster@1: 'mail' => array( webmaster@1: 'type' => 'varchar', webmaster@1: 'length' => 64, webmaster@1: 'not null' => FALSE, webmaster@1: 'description' => t("The comment author's e-mail address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."), webmaster@1: ), webmaster@1: 'homepage' => array( webmaster@1: 'type' => 'varchar', webmaster@1: 'length' => 255, webmaster@1: 'not null' => FALSE, webmaster@1: 'description' => t("The comment author's home page address from the comment form, if user is anonymous, and the 'Anonymous users may/must leave their contact information' setting is turned on."), webmaster@1: ) webmaster@1: ), webmaster@1: 'indexes' => array( webmaster@1: 'pid' => array('pid'), webmaster@1: 'nid' => array('nid'), webmaster@1: 'status' => array('status'), // This index is probably unused webmaster@1: ), webmaster@1: 'primary key' => array('cid'), webmaster@1: ); webmaster@1: webmaster@1: $schema['node_comment_statistics'] = array( webmaster@1: 'description' => t('Maintains statistics of node and comments posts to show "new" and "updated" flags.'), webmaster@1: 'fields' => array( webmaster@1: 'nid' => array( webmaster@1: 'type' => 'int', webmaster@1: 'unsigned' => TRUE, webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => 0, webmaster@1: 'description' => t('The {node}.nid for which the statistics are compiled.'), webmaster@1: ), webmaster@1: 'last_comment_timestamp' => array( webmaster@1: 'type' => 'int', webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => 0, webmaster@1: 'description' => t('The Unix timestamp of the last comment that was posted within this node, from {comments}.timestamp.'), webmaster@1: ), webmaster@1: 'last_comment_name' => array( webmaster@1: 'type' => 'varchar', webmaster@1: 'length' => 60, webmaster@1: 'not null' => FALSE, webmaster@1: 'description' => t('The name of the latest author to post a comment on this node, from {comments}.name.'), webmaster@1: ), webmaster@1: 'last_comment_uid' => array( webmaster@1: 'type' => 'int', webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => 0, webmaster@1: 'description' => t('The user ID of the latest author to post a comment on this node, from {comments}.uid.'), webmaster@1: ), webmaster@1: 'comment_count' => array( webmaster@1: 'type' => 'int', webmaster@1: 'unsigned' => TRUE, webmaster@1: 'not null' => TRUE, webmaster@1: 'default' => 0, webmaster@1: 'description' => t('The total number of comments on this node.'), webmaster@1: ), webmaster@1: ), webmaster@1: 'primary key' => array('nid'), webmaster@1: 'indexes' => array( webmaster@1: 'node_comment_timestamp' => array('last_comment_timestamp') webmaster@1: ), webmaster@1: ); webmaster@1: webmaster@1: return $schema; webmaster@1: } webmaster@1: