/**
* Subscribe array of users to the object
*
* If $replace is set to true, all subscriptions for this object will be
* dropped and $users will be subscribed to it
*
* @param array $users
* @param ProjectObject $object
* @param boolean $replace
* @return boolean
*/
function subscribeUsers($users, $object, $replace = true) {
db_begin_work();
$object_id = (integer) $object->getId();
if($object_id) {
$subscriptions_table = TABLE_PREFIX . 'subscriptions';
if($replace) {
Subscriptions::deleteByParent($object); // cleanup
} // if
$to_subscribe = array();
if(is_foreachable($users)) {
foreach($users as $user) {
if(instance_of($user, 'User')) {
$user_id = (integer) $user->getId();
} else {
$user_id = (integer) $user;
} // if
if($user_id) {
if(isset($to_subscribe[$user_id])) {
continue; // duplicate user ID!
} else {
if(!$replace && array_var(db_execute_one("SELECT COUNT(*) AS 'row_count' FROM $subscriptions_table WHERE user_id = ? AND parent_id = ?", $user_id, $object_id), 'row_count') > 0) {
continue; // Make sure that we do not have this user already subscribed
} // if
cache_remove("user_subscriptions_$user_id");
$to_subscribe[$user_id] = "($user_id, $object_id)";
} // if
} // if
} // foreach
} // if
// Insert subscriptions
if(is_foreachable($to_subscribe)) {
$insert = db_execute("INSERT INTO $subscriptions_table VALUES " . implode(', ', $to_subscribe));
if(!$insert || is_error($insert)) {
db_rollback();
return $insert;
} // if
} // if
} // if
db_commit();
return true;
} // subscribeUsers// Clean up assignments cache
clean_assignments_cache();
// Check if object is reassigned
if(!$is_new) {// Clean up assignments cache
clean_assignments_cache();
// Make sure that all assignees are subscribed
Subscriptions::subscribeUsers($assignees, $this, false);
// Check if object is reassigned
if(!$is_new) {
So I'm the project leader... I automatically get subscribed to tickets. So does the person who created it.
Well if it gets assigned to a 3rd party, the creator and myself are subscribed... but not the assignee? That makes no sense!
Tell me I'm missing some setting....