I didn't try your module yet, but I think it's a great idea to work on this kind of functionnality. The only thing is that I think it's a little bit too specific.

Drupal is great for its flexibility, and I think modules in general should go the same way. I'm not a developper so maybe the way I see it is far more complex... or not, but I think this module should be less specific. Why not having a 'twitter' kinda block that wouldn't only be for user pages, but where users could type a text, and after submission, the text would be automatically added to the previous messages. Free to the developper to add whatever tag to it : your mood, your opinion on.. etc...

A separate add-on would apply that to the user page to make it facebook-like. This way, your module will be far omore flexible, and could be used any a very wide range of websites.

Comments

icecreamyou’s picture

Assigned: Unassigned » icecreamyou
Category: task » feature
Status: Active » Postponed (maintainer needs more info)

First of all, thanks for your interest. I'd like to mention that I'm pretty new to Drupal module development and I'm stuck with getting the form submission working, so if you'd like to take a look that'd be great... ;)

What you're talking about can already be done with the assistance of only CCK and Create Content Block or similar. In this case each status update would be a node, and one could use a View or the Activity module to build feeds/listings of them; also, this would allow comments like Facebook does. I intentionally made this module specific because I didn't want to go that route; I wanted this to be as lightweight as possible.

I'm also planning to look into the Activity module more - it's been awhile since I've used it, but I seem to remember that it stores all its... item... things... so you've got the food for a view there as well.

I somehow can't see "Your opinion on [blank]" changing very often, or needing this kind of text-field-based module. That sounds more like a poll. And this module basically is for your mood...

So all that is to say: yes, it's a good idea, and it would be pretty easy to implement. I'm just not convinced that it's necessary - feel free to try to convince me again. :)

francort’s picture

Nice approach. I like it.
I've fixed some problems and it works fine now.
I have changed some things, like it would be possible to do translations for the module now.
I have also written code for install. I didn't like the idea about alter core tables as such as is users. I think Drupal core won't allow that for automatic installation.

//facebook_status.install
function facebook_status_install() {
  $result = array();
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      $result[] = db_query("CREATE TABLE {facebook_status} (
        sid int(10) NOT NULL auto_increment,
        status_time int(10) NOT NULL default '0',
        status_fb varchar(64) NOT NULL default '',
        uid int(10) NOT NULL default '0',
        PRIMARY KEY  (sid)
        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");

      break;

    case 'pgsql':
      $result[] = db_query("CREATE TABLE {facebook_status} (
        sid SERIAL,
        status_time integer NOT NULL default '0',
        status_fb varchar(64) NOT NULL default '',
        uid integer NOT NULL default '0',
        PRIMARY KEY  (sid)
        );");
     
      break;

		case 'mssql':
      $result[] = db_query("CREATE TABLE {facebook_status} (
        sid int NOT NULL IDENTITY(1,1),
        status_time int NOT NULL default '0',
        status_fb varchar(64) NOT NULL default '',
        uid int NOT NULL default '0',
        PRIMARY KEY (sid)
        );");

      break;
  }

  if (count($result) != count(array_filter($result))) {
    drupal_set_message(t('The installation of the Facebook Status module was unsuccessful.'), 'error');
  }
}

/**
 * Implementation of hook_uninstall().
 */
function simplenews_uninstall() {
  db_query('DROP TABLE {facebook_status}');
}
// $Id$

/**
* Display help and module information
* @param section which section of the site we're displaying help
* @return help text for section
*/
function facebook_status_help($section='') {

  $output = '';

  switch ($section) {
    case "admin/help#facebook_status":
      $output = '<p>'.  t("This module adds a Facebook-style status block.  Please see http://drupal.org/project/facebook_status for more information."). '</p>';
      break;
  }

  return $output;
} // function facebook_status_help


/**
* Valid permissions for this module
* @return array An array of valid permissions for the facebook_status module
*/

function facebook_status_perm() {
  return array('access facebook_status', 'edit own facebook_status', 'edit all facebook_status');
} // function facebook_status_perm()


/**
* Generate HTML for the facebook_status block
* @param op the operation from the URL
* @param delta offset
* @returns block HTML
*/
function facebook_status_block($op='list', $delta=0) {
  // listing of blocks, such as on the admin/block page
  if ($op == "list") {
     $block[0]["info"] = t('Facebook Status');
     return $block;
  }
  else if ($op == 'view') {
    //TO DO: permissions
    $block_content = '<div class="facebook_status_block">';
    if (arg(1) == 'user' && is_numeric(arg(1))) {
      $uname = db_result(db_query("SELECT name FROM {users} WHERE uid = %d", arg(1)));
      $block_content .= htmlspecialchars($uname, ENT_NOQUOTES); //htmlspecialchars instead of the usual check_plain because names sometimes have quotes in them; however, this means that you have to be careful when writing database queries.
      $sm = db_fetch_array(db_query("SELECT status_fb, status_time FROM {facebook_status} WHERE uid = %d", arg(1))); //grabs the status of the user who's profile is being viewed
    } else {
      global $user;
      $block_content .= htmlspecialchars($user->name, ENT_NOQUOTES); //htmlspecialchars instead of the usual check_plain because names sometimes have quotes in them; however, this means that you have to be careful when writing database queries.
      $sm = db_fetch_array(db_query("SELECT status_fb, status_time FROM {facebook_status} WHERE uid = %d", $user->uid)); //grabs the status of the current user if the block is not on a user profile page
    }
    if($sm['status_time']) { //if the user has posted her status before
      $block_content .= " " . $sm['status_fb'] . "<br />" . format_date($sm['status_time'], 'small'); //print the status with the time it was posted
    }
    $block_content .= facebook_status_form_display();
    $block_content .= '</div>';
    // set up the block 
    $block['subject'] = 'Status'; 
    $block['content'] = $block_content;
    return $block;
  }

} // end facebook_status_block


//builds the status submission form
function facebook_status_update_form() {
  $status = facebook_status_get_status();
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => 'Status',
    '#size' => 30,
    '#maxlength' => 256,
    '#description' => t('Enter your status'),
    '#default_value' => ((!empty( $status['status_fb'] ) ) ? $status['status_fb'] : t('is ')),
  );
  $form['submit'] = array('#type' => 'submit', '#value' => t('Save') );
  return $form;
}

//renders the status submission form; call this if you want to display it arbitrarily
function facebook_status_form_display() {
  return drupal_get_form('facebook_status_update_form');
}

//the submit function, tells Drupal what to do when the status is submitted
function facebook_status_update_form_submit($form, $form_values) {
	global $user;
  if( db_query("UPDATE {facebook_status} SET status_fb = '%s' , status_time = %d WHERE uid = %d", $form_values['name'], time(), $user->uid) )
  	drupal_set_message(t('Your status has been updated.'));
  else
    drupal_set_message(t('Your status has been not updated.'), 'error');
  return '';
}

function facebook_status_get_status(){
	global $user;
	$result = array();
	$result = db_fetch_array(db_query("SELECT status_fb, status_time FROM {facebook_status} WHERE uid = %d", $user->uid)); //grabs the status of the current user if the block is not on a user profile page
	return $result;
}
icecreamyou’s picture

Status: Postponed (maintainer needs more info) » Needs review

Awesome, thanks! It looks like it'll need a few tweaks, but I'll test it today and update the files on my server for a quick, direct download...

Now if only I could figure out CVS... and on that point, I'm happy to give someone CVS access to help me out with that. ;)

And just 'by the way,' I think I'm going to add a way for an arbitrary UID to be passed in instead of trying to detect it ourselves; then I'll write a function that will detect it if nothing else is passed in. That way we can do things like show the status of a node's author.

icecreamyou’s picture

Status: Needs review » Postponed (maintainer needs more info)

I made some changes to fix bugs, improve security, and raise functionality. The module is now fully functional, although the permissions don't do anything yet.

This issue is more for widening the audience of the module, however, so I'm setting back to active (needs more info). If no one presents a convincing argument with specific actions needed to widen this module's audience within the next two weeks or so, I'll mark this as fixed.

icecreamyou’s picture

Status: Postponed (maintainer needs more info) » Postponed

After some consideration, I think I'm going to add this in at some point. It will happen after I get the 'edit all facebook_status' permission, the configuration page, and the AJAX working... it shouldn't take more than two weeks, but I'm marking as 'postponed' because I won't be working on it right away.

icecreamyou’s picture

Status: Postponed » Fixed

I added a "Facebook Mode" checkbox to the configuration page. Un-checking it will remove usernames from the front of statuses (and other places) so the module can be used as more of an "express your thoughts" type thing.

A lot of other fixes as well as some extra theming power have gone into the latest version (updated just now), so I recommend you use it if you've been using this module at all. I just wish I could figure out how to get CVS working so I could add an official release! :(

Anonymous’s picture

Ahh CVS hell, I myself am going through a hard time with it by adding some themes. Here are the articles that kinda helped me to figure things out :

http://drupal.org/handbook/cvs/quickstart
http://www.angrydonuts.com/my_informal_take_on_using_the_ne

few main advices :

- first, commit the code to create HEAD
- create a drupal5/6/... BRANCH
- make sure there is no hidden files in your commit (on mac there is always a hidden file...)
- make sure you add all files in all subfolder (cvs add mymodule | cvs add mymodule/* | ...
- do not tag a release (make it 'stable') until you're sure it IS stable

I think that the cv documentation is pretty bad, and for a desiner like me it was hell to figure it out, so I think that I might write some posts about this to make it clearer for non-savvy users...

icecreamyou’s picture

I can't even commit code. I can get as far as logging in and that's about it. :D

I'm seriously to the point where I'm just happy to let someone else update CVS for me... if anyone wants to help, I'll maintain the code and someone else can do the uploading.

francort’s picture

maybe it is time to start a post for CVS :)

I don't know how to use it, i have never tried

icecreamyou’s picture

I added a request for help to the module page.

By the way, if any of you have been using the module: I strongly recommend you upgrade to the latest version (updated just now). I've been incrementally adding features and fixing bugs over the last few days. As of now, everything works and is themable, stable, and secure. Let me know of course if you find any bugs and I'd love for someone to run this through coder.module.

naheemsays’s picture

Apart from tagging a release, I found smartcvs the easiest to use.

It lacks a few features (tagging is not compatible, and it lacks patch support), but makes up for most with its simplicity.

For tags (for stable releases - branching works well in smartcvs) and patches I use cygwin.

icecreamyou’s picture

Thanks for the suggestion - smartcvs is indeed much easier to use.

It seems that it's not working 100% though... we'll see if a release gets generated within the next 12 hours, but it doesn't look like there are any files in the directory to generate a release from.

naheemsays’s picture

From what I can see (http://drupal.org/project/cvs/287027), the files have not been committed.

What you need to do is go into the {yourdocuments}/SmartCVS... {find your module folder - potentially located at drupal-contrib/contributions/modules/facebook_status}. make sure it contains the relevant files. copy them there from where ever you normally store them.

Then in Smart CVS, select them all, click the commit button, give a note. Something simple like initicial commit.

icecreamyou’s picture

Great, thanks - I think I actually got it this time! I apparently didn't add or commit the files after I'd created the folder. I guess we'll see soon. :D

naheemsays’s picture

Releases are not automatic - on the project page you need to create a release. If this is aimed at a branch (HEAD, DRUPAL-5, DRUPAL-6--1), it will update automatically. If it is aimed at a tag (DRUPAL-6--1-1), it will not.

icecreamyou’s picture

It worked, but the release isn't showing up on the project's front page--you have to go to releases to see it. :/

I seem to remember that I have to tag the release... will look into it, although I'm not sure how that will work if SmartCVS is incompatible as you say.

Anonymous’s picture

If you tag the release, it'll make it an official release, not a dev, and you might want to make sure your module is stable before doing that. Apparently your code is there as a dev version, the only thing you have to do is to click on 'administer releases' no the project page, and check 'supported', recommended, and 'Show snapshot release'.

That should display the release :)

icecreamyou’s picture

Great, thanks.

All that's needed before an 'official' release is more testing, so we'll see about getting that up too.

icecreamyou’s picture

Version: » 5.x-1.x-dev
Status: Fixed » Closed (fixed)

Changing to 5.x-1.x-dev because 5.x-0.x-dev is hopefully being deleted. Closing the issue while I'm at it since it's been fixed for awhile now.

naheemsays’s picture

Just a note - release tagging seems to work properly in smartcvs Version 7 - I have used it successfully. Just make sure the options to force a tag, or to check for newer files are both unchecked.

icecreamyou’s picture

I suspected this was the case but I haven't had reason to try it. Thanks.