User:Zhenya

= Identity = Name: Yevhenii Vlasenko University: Chernihiv Technological University (Ukraine) Project title: "Extension: SocialProfile - UserStatus feature" Contact information:
 * IRC: Zheee
 * GTalk/GMail: benjamin22.987[at]gmail.com
 * Skype: Zhenya_987
 * Facebook: www.facebook.com/profile.php?id=1342047659

Project summary
The aim of the project is to create a UserStatus module for the SocialProfile extension at MediaWiki. This module will allow MediaWiki users to write short "status updates" on user profile pages. It will allow Wiki users to share their thoughts, ideas or just the facts of their life. The project will have a history of UserStatuses and will allow everyone of just the user itself (depending on the settings) to look through it. = How it`s going = Today (06.10.2011) I am starting a kind of the development diary, to show how my work is going, my results, and the problems/questions that I meet in the development of the UserStatus feature. Hope that this diary will help people who are going participate in GSoC.

06.10.2011 Friday
Because of the exams I had a lack of time, but anyway some things I have already done.

The SQL script for the database of Mediawiki:

CREATE TABLE /*_*/`user_status` ( `us_id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,  `us_user_id` int(11) NOT NULL default '0',  `us_timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,  `us_status` varchar(140) NOT NULL default '' )/*$wgDBTableOptions*/;

The JavaScript that implements the interface of UserStatus (ofc it will be reworked, but when the time will come for 'History' development): function toEditMode(elem) { document.getElementById(elem).innerHTML =  ' Save Cancel'; } function toShowMode(elem,status) { document.getElementById(elem).innerHTML = status + 'Edit'; } Also i started to write the main class of the UserStatus: class UserStatus { /*    * #@+     * @private */

var $user_id;  # Text form (spaces not underscores) of the main part var $user_name;  # Text form (spaces not underscores) of the main part

/**    * Constructor * @private */   /* private */

function __construct { }

/*    * Fuction that imlements the request for the status to the db     * */   public function getStatus($u_id) { $dbr = wfGetDB(DB_SLAVE); $sql = "SELECT *               FROM `user_status`                WHERE us_user_id=$u_id"; $res = $dbr->query($sql, __METHOD__); $message = array; foreach ($res as $row) { $message = array(               'us_user_id' => $row->us_user_id,                'us_status' => ( $row->us_status ),            ); }       return $message; } } Tried to use this class in UserProfilePage.php, everything seemd to work fine. The links I really needed to read were: http://www.mediawiki.org/wiki/Manual:Database_access http://www.mediawiki.org/wiki/Manual:Global_object_variables

P.S.For future GSoCers: If your exams fall on GSoC time, dont get afraid. You will always be able to talk about it to your mentor and everything will be okay, as different universities have different session time. For example I still have 3 exams to pass.

06.11.2011 Saturday
UserProfilePage.php: 512 $us_class = new UserStatus; 513 $user_status_array =$us_class->getStatus($this->user_id); 514 $user_status = $user_status_array['us_status'];

SocialProfile.php: 52 $wgAutoloadClasses['UserStatus'] = $dir. 'UserStatus/UserStatusClass.php'; ... 195 $wgUserStatusScripts = "$wgScriptPath/extensions/SocialProfile/UserStatus"; ... 235 efSocialProfileDBUpdate( $updater, 'user_status', "$dir/UserStatus/userstatus$dbExt.sql" );

06.11.2011 Sunday
Today I did write a funсtion for adding/uзdating status in the db. Had a problem with converting html => text. For example: user writes a status "text here" and in this way he gets a hypertext link on the resourse helloworld.com. In this way he can write a sript to get anything from db, knowing the way to access it. For this point I used __htmlspecialchars($string)__ function, so the special symbols were converted. public function setStatus($u_id, $message) { if ( strlen($message) > 140) { //ERROR. Message lenth is too long return; }       $dbw = wfGetDB(DB_MASTER); $sql = "SELECT *               FROM `user_status`                WHERE us_user_id=$u_id"; $res = $dbw->query($sql, __METHOD__); $i = 0; foreach ($res as $row) $i++; if ($i == 0) { $dbw->insert(                   'user_status',                    /* SET */ array( 'us_user_id' => $u_id, 'us_status' => $message,), __METHOD__           ); } else { $dbw->update(                   'user_status',                    /* SET */ array('us_status' => $message),                    /* WHERE */ array('us_user_id' => $u_id), __METHOD__            ); return; }   } Testing it: $us_class = new UserStatus; //its WORKS too!It makes me cry!Yeah!:"(               $mess1='text here';                $u_two =$us_class->setStatus($this->user_id,$mess1);                //it works                $user_status_array = $us_class->getStatus($this->user_id);                $user_status = $user_status_array['us_status'].$u_two;