Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* no longer show tasks on profile page

* show private projects and activity on profile pages for fellow members
* show hidden events for admins
* fade old events/highlight new events since last login
* format event for sending messages
* don't show public projects the user has already joined
  • Loading branch information...
commit 64dcdcee4695946c9ff1204aa33da3a2cadec2f2 1 parent e6a25ba
@kluther authored
View
6 controller/site/find_c.php
@@ -3,7 +3,11 @@
$soup = new Soup();
-$projects = Project::getPublicProjects();
+if(Session::isLoggedIn()) {
+ $projects = Project::getPublicProjects(Session::getUserID());
+} else {
+ $projects = Project::getPublicProjects();
+}
$soup->set('projects', $projects);
$soup->render('site/page/find');
View
2  controller/site/index_c.php
@@ -5,7 +5,7 @@
if(Session::isLoggedIn()) {
// dashboard
- $yourProjects = Project::getByUserID(Session::getUserID());
+ $yourProjects = ProjectUser::getProjectsByUserID(Session::getUserID());
$publicProjects = Project::getPublicProjects(10); // projects to join
//$user = User::load(Session::getUserID());
$events = Event::getDashboardEvents(Session::getUserID(), 10);
View
10 controller/site/user_c.php
@@ -10,13 +10,15 @@
exit();
}
-$events = Event::getUserEvents($user->getID(), false, 10);
-$tasks = Task::getByUserID($user->getID(), null, false);
-$projects = Project::getByUserID($user->getID(), false);
+$events = Event::getUserEvents($user->getID(), 10);
+//$tasks = Task::getByUserID($user->getID(), null, false);
+
+$projects = ProjectUser::getProjectsByUserID($user->getID());
+
$soup = new Soup();
$soup->set('user', $user);
$soup->set('events', $events);
-$soup->set('tasks', $tasks);
+//$soup->set('tasks', $tasks);
$soup->set('projects', $projects);
$soup->render('site/page/user');
View
13 database.sql
@@ -3,7 +3,7 @@
-- http://www.phpmyadmin.net
--
-- Host: localhost
--- Generation Time: Nov 18, 2011 at 09:16 PM
+-- Generation Time: Nov 21, 2011 at 05:11 PM
-- Server version: 5.1.44
-- PHP Version: 5.3.1
@@ -204,7 +204,7 @@ INSERT INTO `event_type` (`id`, `description`, `group`, `css_class`, `diffable`,
('lock_discussion', NULL, 4, 'lock-discussion', 0, 0, 0),
('read_message', NULL, NULL, NULL, 1, 1, 0),
('release_task', NULL, 3, 'task', 0, 0, 0),
-('send_message', NULL, NULL, NULL, 1, 1, 0),
+('send_message', NULL, NULL, 'message', 1, 1, 0),
('trust_member', NULL, 5, 'people', 0, 0, 0),
('unban_user', NULL, 5, 'people', 0, 0, 0),
('unfollow_project', NULL, 5, 'people', 0, 1, 0),
@@ -350,11 +350,11 @@ CREATE TABLE IF NOT EXISTS `task` (
CREATE TABLE IF NOT EXISTS `theme` (
`id` int(11) NOT NULL AUTO_INCREMENT,
- `name` varchar(128) NOT NULL,
- `pipeline_stylesheet` varchar(128) NOT NULL,
- `jqueryui_stylesheet` varchar(128) NOT NULL,
+ `name` varchar(128) CHARACTER SET latin1 NOT NULL,
+ `pipeline_stylesheet` varchar(128) CHARACTER SET latin1 NOT NULL,
+ `jqueryui_stylesheet` varchar(128) CHARACTER SET latin1 NOT NULL,
PRIMARY KEY (`id`)
-) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;
+) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
--
-- Dumping data for table `theme`
@@ -454,6 +454,7 @@ CREATE TABLE IF NOT EXISTS `user` (
`admin` tinyint(3) unsigned NOT NULL DEFAULT '0',
`date_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`last_login` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
+ `second_last_login` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=50 ;
View
51 model/classes/event.class.php
@@ -310,20 +310,30 @@ public static function getPeopleEventsByProjectID($projectID=null, $limit=null)
return (self::getByProjectID($projectID, PEOPLE_ID, $limit));
}
- public static function getUserEvents($userID=null, $private=null, $limit=null) {
+ public static function getUserEvents($userID=null, $limit=null) {
if($userID == null) return null;
+ $loggedInUserID = Session::getUserID();
$query = "SELECT e.id AS id FROM ".self::DB_TABLE." e";
$query .= " INNER JOIN ".EventType::DB_TABLE." et ON ";
$query .= " e.event_type_id = et.id";
- $query .= " INNER JOIN ".Project::DB_TABLE." p ON ";
- $query .= " p.id = e.project_id";
+ $query .= " LEFT OUTER JOIN ".Project::DB_TABLE." p ON ";
+ $query .= " e.project_id = p.id";
$query .= " WHERE e.user_1_id = ".$userID;
- $query .= " AND et.hidden = 0";
- if($private === true) {
- $query .= " AND p.private=1";
- } elseif($private === false) {
- $query .= " AND p.private=0";
+ // let admins see hidden events
+ if(!Session::isAdmin())
+ $query .= " AND et.hidden = 0";
+ // let fellow members see private project events
+ if(!empty($loggedInUserID)) {
+ $query .= " AND (p.private = 0";
+ $query .= " OR p.id IN (";
+ $query .= " SELECT project_id FROM ".ProjectUser::DB_TABLE;
+ $query .= " WHERE user_id = ".$loggedInUserID;
+ $query .= " AND relationship != ".ProjectUser::BANNED;
+ $query .= " ) OR (e.project_id IS NULL) )";
+ } else {
+ $query .= " AND ( (p.private = 0) OR";
+ $query .= " (e.project_id IS NULL) )";
}
$query .= " ORDER BY e.date_created DESC";
if($limit != null)
@@ -366,10 +376,35 @@ public static function getByProjectID($projectID=null, $eventTypeGroup=null, $li
return $events;
}
+ /* determine if event is new since user's last login */
+ public function isNew() {
+ $loggedInUser = Session::getUser();
+
+ if(!empty($loggedInUser)) {
+ $lastLogin = strtotime($loggedInUser->getSecondLastLogin());
+ $eventTime = strtotime($this->getDateCreated());
+
+ if($lastLogin < $eventTime) {
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return true;
+ }
+ }
+
public function getCssClass()
{
$et = EventType::load($this->getEventTypeID());
$cssClass = $et->getCssClass();
+
+ if($this->isNew()) {
+ $cssClass.=" new";
+ } else {
+ $cssClass.=" old";
+ }
+
return $cssClass;
}
View
97 model/classes/project.class.php
@@ -159,8 +159,17 @@ public static function getAllProjects($limit=null) {
}
public static function getPublicProjects($limit=null) {
+ $userID = Session::getUserID();
+
$query = "SELECT id FROM ".self::DB_TABLE;
$query .= " WHERE private = 0";
+ // don't include projects the user is affiliated with
+ if(!empty($userID)) {
+ $query .= " AND id NOT IN (";
+ $query .= " SELECT project_id FROM ".ProjectUser::DB_TABLE;
+ $query .= " WHERE user_id = ".$userID;
+ $query .= " )";
+ }
$query .= " ORDER BY status DESC, ISNULL(deadline) ASC, title ASC";
if($limit != null)
$query .= " LIMIT ".$limit;
@@ -176,49 +185,51 @@ public static function getPublicProjects($limit=null) {
return $projects;
}
- public static function getByUserID($userID=null, $private=null, $limit=null) {
- if($userID === null) return null;
-
- $query = "SELECT DISTINCT id FROM ".self::DB_TABLE;
- // creator
- $query .= " WHERE (creator_id = ".$userID;
- // follower, organizer
- $query .= " OR id IN (";
- $query .= " SELECT DISTINCT project_id FROM ".ProjectUser::DB_TABLE;
- $query .= " WHERE user_id = ".$userID;
- $query .= " AND relationship != ".ProjectUser::BANNED;
- $query .= " )";
- // contributor
- $query .= " OR id IN (";
- $query .= " SELECT DISTINCT project_id FROM ".Accepted::DB_TABLE;
- $query .= " WHERE creator_id = ".$userID;
- //$query .= " OR user_2_id = ".$userID;
- $query .= "))";
- // not banned
- $query .= " AND id NOT IN (";
- $query .= " SELECT DISTINCT project_id FROM ".ProjectUser::DB_TABLE;
- $query .= " WHERE user_id = ".$userID;
- $query .= " AND relationship = ".ProjectUser::BANNED;
- $query .= " )";
- if($private === true) {
- $query .= " AND private=1";
- } elseif($private === false) {
- $query .= " AND private=0";
- }
- $query .= " ORDER BY ISNULL(deadline) ASC, title ASC";
- //echo $query;
- if($limit != null)
- $query .= " LIMIT ".$limit;
-
- $db = Db::instance();
- $result = $db->lookup($query);
- if(!mysql_num_rows($result)) return null;
-
- $projects = array();
- while($row = mysql_fetch_assoc($result))
- $projects[$row['id']] = self::load($row['id']);
- return $projects;
- }
+ // used on profile page
+// public static function getByUserID($userID=null, $private=null, $limit=null) {
+// if($userID === null) return null;
+//
+// $query = "SELECT id FROM ".self::DB_TABLE;
+// $query .= " WHERE
+// // creator
+// $query .= " WHERE (creator_id = ".$userID;
+// // follower, organizer
+// $query .= " OR id IN (";
+// $query .= " SELECT DISTINCT project_id FROM ".ProjectUser::DB_TABLE;
+// $query .= " WHERE user_id = ".$userID;
+// $query .= " AND relationship != ".ProjectUser::BANNED;
+// $query .= " )";
+// // contributor
+// $query .= " OR id IN (";
+// $query .= " SELECT DISTINCT project_id FROM ".Accepted::DB_TABLE;
+// $query .= " WHERE creator_id = ".$userID;
+// //$query .= " OR user_2_id = ".$userID;
+// $query .= "))";
+// // not banned
+// $query .= " AND id NOT IN (";
+// $query .= " SELECT DISTINCT project_id FROM ".ProjectUser::DB_TABLE;
+// $query .= " WHERE user_id = ".$userID;
+// $query .= " AND relationship = ".ProjectUser::BANNED;
+// $query .= " )";
+// if($private === true) {
+// $query .= " AND private=1";
+// } elseif($private === false) {
+// $query .= " AND private=0";
+// }
+// $query .= " ORDER BY ISNULL(deadline) ASC, title ASC";
+// //echo $query;
+// if($limit != null)
+// $query .= " LIMIT ".$limit;
+//
+// $db = Db::instance();
+// $result = $db->lookup($query);
+// if(!mysql_num_rows($result)) return null;
+//
+// $projects = array();
+// while($row = mysql_fetch_assoc($result))
+// $projects[$row['id']] = self::load($row['id']);
+// return $projects;
+// }
public static function getProjectFromSlug($slug=null)
{
View
156 model/classes/projectUser.class.php
@@ -87,21 +87,40 @@ public static function find($userID=null, $projectID=null) {
return (self::load($row['id']));
}
- // public static function changeRelationship($projectID=null, $userID=null, $relationship=null) {
- // if( ($projectID === null) ||
- // ($userID === null) ||
- // ($relationship === null) ) {
- // return null;
- // }
+ // used on profile page
+ public static function getProjectsByUserID($userID=null, $limit=null) {
+ if($userID === null) return null;
+ $loggedInUserID = Session::getUserID();
- // $query = "UPDATE ".self::DB_TABLE;
- // $query .= " SET relationship = ".$relationship;
- // $query .= " WHERE user_id = ".$userID;
- // $query .= " AND project_id = ".$projectID;
+ $query = " SELECT pu.project_id AS id FROM ".self::DB_TABLE." pu";
+ $query .= " INNER JOIN ".Project::DB_TABLE." p ON";
+ $query .= " pu.project_id = p.id";
+ $query .= " WHERE pu.user_id = ".$userID;
+ $query .= " AND pu.relationship != ".self::BANNED;
+ // only show private projects if logged-in user is also a member
+ if(!empty($loggedInUserID)) {
+ $query .= " AND (p.private = 0";
+ $query .= " OR pu.project_id IN (";
+ $query .= " SELECT project_id FROM ".self::DB_TABLE;
+ $query .= " WHERE user_id = ".$loggedInUserID;
+ $query .= " AND relationship != ".self::BANNED;
+ $query .= " ))";
+ } else {
+ $query .= " AND p.private = 0";
+ }
+ $query .= " ORDER BY p.title ASC";
+ if(!empty($limit))
+ $query .= " LIMIT ".$limit;
- // $db = Db::instance();
- // $db->execute($query);
- // }
+ $db = Db::instance();
+ $result = $db->lookup($query);
+ if(!mysql_num_rows($result)) return array();
+
+ $projects = array();
+ while($row = mysql_fetch_assoc($result))
+ $projects[$row['id']] = Project::load($row['id']);
+ return $projects;
+ }
public static function getAllMembers($projectID=null) {
if($projectID === null) return null;
@@ -236,28 +255,6 @@ public static function getByProjectID($projectID=null, $relationship=null) {
$users[$row['id']] = User::load($row['id']);
return $users;
}
-
- // doesn't really belong here but what the hey
- // public static function isCreator($userID=null, $projectID=null)
- // {
- // if( ($userID == null) || ($projectID == null) ) return null;
-
- // $project = Project::load($projectID);
- // if($project->getCreatorID() == $userID)
- // return true;
- // else
- // return false;
- // }
-
- // doesn't really belong here but what the hey
- // public static function isContributor($userID=null, $projectID=null) {
- // return (Accepted::hasAccepted($userID, $projectID));
- // }
-
- // public static function isOrganizer($userID=null, $projectID=null)
- // {
- // return (self::hasRelationship($userID,$projectID,self::ORGANIZER));
- // }
public static function isCreator($userID=null, $projectID=null) {
return (self::hasRelationship($userID,$projectID,self::CREATOR));
@@ -285,14 +282,6 @@ public static function isAffiliated($userID=null, $projectID=null) {
return (self::hasRelationship($userID,$projectID));
}
- // public static function isAffiliated($userID=null, $projectID=null) {
- // if (self::hasRelationship($userID, $projectID) ||
- // self::isCreator($userID, $projectID) ||
- // self::isContributor($userID, $projectID) )
- // return true;
- // else return false;
- // }
-
// avoid calling this... use one of the aliased functions above instead
public static function hasRelationship($userID=null, $projectID=null, $relationship=null) {
if( ($userID === null) || ($projectID === null) ) return null;
@@ -311,88 +300,7 @@ public static function hasRelationship($userID=null, $projectID=null, $relations
else
return true;
}
-
-// ---------------------------------------------------------------------------- //
-
- // public static function getBanned($projectID=null)
- // {
- // return (self::getUsersByRelationship($projectID,self::BANNED));
- // }
-
- // public static function getFollowers($projectID=null)
- // {
- // return (self::getUsersByRelationship($projectID,self::FOLLOWER));
- // }
-
- // public static function getContributors($projectID=null) {
- // // return (self::getUsersByRelationship($projectID,self::CONTRIBUTOR));
- // return (Accepted::getUsersByProjectID($projectID));
- // }
-
- // get users who have accepted any task in this project
- // public static function getOnlyContributors($projectID=null, $limit=null) {
- // if($projectID == null) return null;
- // $project = Project::load($projectID);
- // $projectCreator = $project->getCreator();
-
- // $query = "SELECT creator_id AS id FROM ".Accepted::DB_TABLE;
- // $query .= " WHERE project_id = ".$projectID;
- // $query .= " AND status != ".Accepted::STATUS_RELEASED;
- // $query .= " AND creator_id NOT IN (";
- // $query .= " SELECT user_id FROM ".self::DB_TABLE;
- // $query .= " WHERE project_id = ".$projectID;
- // $query .= " AND relationship != ".self::FOLLOWER;
- // $query .= " )";
- // $query .= " AND creator_id != ".$projectCreator->getID();
- // $query .= " ORDER BY status DESC, date_created DESC";
- // if($limit != null)
- // $query .= " LIMIT ".$limit;
-
- // $db = Db::instance();
- // $result = $db->lookup($query);
- // if(!mysql_num_rows($result)) return array();
-
- // $users = array();
- // while($row = mysql_fetch_assoc($result))
- // $users[$row['id']] = User::load($row['id']);
- // return $users;
- // }
-
- // public static function getOrganizers($projectID=null)
- // {
- // return (self::getUsersByRelationship($projectID,self::ORGANIZER));
- // }
-
- // avoid calling this... use one of the aliased functions above instead
- // public static function getUsersByRelationship($projectID=null, $relationship=null) {
- // if($projectID == null) return null;
- // $project = Project::load($projectID);
- // $projectCreator = $project->getCreator();
-
- // $query = "SELECT pu.user_id AS user_id FROM ".self::DB_TABLE." pu";
- // $query .= " INNER JOIN ".User::DB_TABLE." u ON ";
- // $query .= " pu.user_id = u.id";
- // $query .= " WHERE pu.project_id = ".$projectID;
- // $query .= " AND pu.user_id NOT IN (";
- // $query .= "SELECT creator_id FROM ".Accepted::DB_TABLE;
- // $query .= " WHERE project_id = ".$projectID;
- // $query .= " AND status != ".Accepted::STATUS_RELEASED;
- // $query .= " )";
- // $query .= " AND pu.user_id != ".$projectCreator->getID();
- // if($relationship !== null)
- // $query .= " AND pu.relationship = ".$relationship;
- // $query .= " ORDER BY u.username ASC"; // alphabetical
- // //echo $query;
-
- // $db = Db::instance();
- // $result = $db->lookup($query);
- // if(!mysql_num_rows($result)) return array();
- // $users = array();
- // while($row = mysql_fetch_assoc($result))
- // $users[$row['user_id']] = User::load($row['user_id']);
- // return $users;
- // }
// --- only getters and setters below here --- //
View
1  model/classes/session.class.php
@@ -20,6 +20,7 @@ public static function signIn($userInfo)
$user = User::loadByUserName($userInfo);
// last login
+ $user->setSecondLastLogin($user->getLastLogin());
$user->setLastLogin(date("Y-m-d H:i:s"));
$user->save();
View
19 model/classes/user.class.php
@@ -30,6 +30,7 @@ class User extends DbObject
protected $admin;
protected $dateCreated;
protected $lastLogin;
+ protected $secondLastLogin;
const DB_TABLE = 'user';
@@ -68,7 +69,8 @@ public function __construct($args = array())
'notify_mass_email' => 1,
'admin' => 0,
'date_created' => null,
- 'last_login' => null
+ 'last_login' => null,
+ 'second_last_login' => null
);
$args += $defaultArgs; // combine the arrays
@@ -101,6 +103,7 @@ public function __construct($args = array())
$this->admin = $args['admin'];
$this->dateCreated = $args['date_created'];
$this->lastLogin = $args['last_login'];
+ $this->secondLastLogin = $args['second_last_login'];
}
public static function load($id)
@@ -184,7 +187,8 @@ public function save()
'notify_receive_message' => $this->notifyReceiveMessage,
'notify_mass_email' => $this->notifyMassEmail,
'admin' => $this->admin,
- 'last_login' => $this->lastLogin
+ 'last_login' => $this->lastLogin,
+ 'second_last_login' => $this->secondLastLogin
);
$db->store($this, __CLASS__, self::DB_TABLE, $db_properties);
}
@@ -585,4 +589,15 @@ public function setLastLogin($newLastLogin)
$this->modified = true;
$this->lastLogin = $newLastLogin;
}
+
+ public function getSecondLastLogin()
+ {
+ return ($this->secondLastLogin);
+ }
+
+ public function setSecondLastLogin($newSecondLastLogin)
+ {
+ $this->modified = true;
+ $this->secondLastLogin = $newSecondLastLogin;
+ }
}
View
12 static/styles/basic.css
@@ -714,7 +714,17 @@ ul.activity li.unlock-discussion {
}
ul.activity li.people {
background-image: url(./../images/icons/users.png);
- }
+ }
+ul.activity li.message {
+ background-image: url(./../images/icons/mail.png);
+ }
+
+ul.activity li.new {
+ opacity: 1;
+ }
+ul.activity li.old {
+ opacity: 0.8;
+ }
/* NOTIFICATIONS */
View
6 views/site/helper/formatEvents.php
@@ -11,6 +11,12 @@ function formatEvent($event, $showProject=false)
'<a href="'.Url::base().'">'.PIPELINE_NAME.'</a>'
);
break;
+ case 'send_message':
+ $formatted = sprintf("%s sent a message to %s.",
+ formatUserLink($event->getUser1ID()),
+ formatUserLink($event->getUser2ID())
+ );
+ break;
case 'accept_member_invitation':
$predicate = ($showProject) ? 'the project '.formatProjectLink($event->getProjectID()) : "this project";
$formatted = sprintf("%s accepted %s's invitation to join %s.",
View
16 views/site/page/user.tpl.php
@@ -1,10 +1,10 @@
<?php
$user = $SOUP->get('user');
-$tasks = $SOUP->get('tasks');
+// $tasks = $SOUP->get('tasks');
$fork = $SOUP->fork();
-$fork->set('pageTitle', $user->getUsername());
+$fork->set('pageTitle', 'Profile');
$fork->set('headingURL', Url::user($user->getID()));
$fork->startBlockSet('body');
@@ -27,12 +27,12 @@
?>
<?php
- $SOUP->render('project/partial/tasks', array(
- 'user' => $user,
- 'tasks' => $tasks,
- 'hasPermission' => false,
- 'title' => $user->getUsername().'\'s Tasks'
- ));
+// $SOUP->render('project/partial/tasks', array(
+// 'user' => $user,
+// 'tasks' => $tasks,
+// 'hasPermission' => false,
+// 'title' => $user->getUsername().'\'s Tasks'
+// ));
?>
</td>
View
5 views/site/partial/page.tpl.php
@@ -14,7 +14,12 @@
if(Session::isLoggedIn()) {
$user = Session::getUser();
+ // update last login
+ $user->setLastLogin(date("Y-m-d H:i:s"));
+ $user->save();
+ // load unread messages
$numUnread = $user->getNumUnreadMessages();
+ // load custom theme, if specified
if($user->getThemeID() != null) {
$theme = Theme::load($user->getThemeID());
} else {
View
2  views/site/partial/profile.tpl.php
@@ -472,7 +472,7 @@ function initializeUploader() {
}
echo '</p>';
?>
-<p>last login <?= formatTimeTag($user->getLastLogin()) ?></p>
+<p>last login <?= formatTimeTag($user->getSecondLastLogin()) ?></p>
<?php
// biography
Please sign in to comment.
Something went wrong with that request. Please try again.