Created
September 21, 2012 07:28
-
-
Save martisj/3760201 to your computer and use it in GitHub Desktop.
heinous
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private function send_timetable_add_class($event, $calendar) | |
{ | |
echo "send_timetable_add_class <br/>"; | |
$user_from = $event->get_user(); | |
$unit_info_id = $calendar->getUnit_info_id(); | |
$qb = repo('Activity')->createQueryBuilder('a'); | |
$qb->where('a.user_from_id = :ufid') | |
->andWhere('a.type = :type') | |
->groupBy('a.entity_extra') | |
->orderBy('a.date_created', 'DESC') | |
->setParameters( | |
array( | |
'ufid' => $user_from->getId(), | |
'type' => 'timetable_add_class' | |
) | |
); | |
$user_froms_activities = $qb->getQuery()->execute(); | |
// findBy(array('user_from_id' => $user_from->getId(), 'type' => 'timetable_add_class'))->groupBy(); | |
// var_doctrine($user_froms_activities); | |
// die(); | |
foreach ($user_froms_activities as $act) { | |
$ent = repo('Calendar')->findOneBy(array('id' => $act->get_entity_extra())); | |
if ( ! is_null($ent)) | |
{ | |
if ($ent->getType() != 'assessment') | |
{ | |
if (is_null($ent->getUnit_info_id()) && is_null($unit_info_id)) | |
{ | |
if ($this->_compare_timetable_events($ent, $calendar) == TRUE) | |
{ | |
return FALSE; | |
} | |
} | |
else | |
{ | |
if ($ent->getUnit_info_id() == $unit_info_id) | |
{ | |
// echo 'user has added this class time before DONT make a notification' . br(); | |
return FALSE; | |
} | |
} | |
} | |
} | |
} | |
$users_friends = repo('Connection')->findAllForUserNoSort($user_from->getId()); | |
foreach ($users_friends as $friend) | |
{ | |
$friend_id = $friend->get_friend($user_from->getId())->getId(); | |
$user = get_user($friend_id); | |
/* Save activity to user's friends */ | |
$activity = new models\Activity; | |
$activity->set_type($event->get_type()); | |
$activity->set_user_from($user_from); | |
$activity->set_user_to($user); | |
$activity->set_entity_type('Users'); | |
$activity->set_entity_id($user_from->getId()); | |
$activity->set_entity_extra($event->entity_id); | |
$activity->set_is_read(false); | |
$activity->set_date_created(new \DateTime("now")); | |
$this->em->persist($activity); | |
} | |
$this->save($event, array()); | |
$this->em->flush(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment