/** * overloads RoxEntityBase::loadEntity to load related data * * @param array $data * * @access protected * @return bool */ protected function loadEntity(array $data) { if ($status = parent::loadEntity($data)) { $entityFactory = new RoxEntityFactory(); $this->creator = $entityFactory->create('Member', $this->createdBy); if ($this->modifiedBy) { $this->modifier = $entityFactory->create('Member', $this->modifiedBy); } if ($this->deletedBy) { $this->deleter = $entityFactory->create('Member', $this->deletedBy); } if ($this->mutuallyExclusiveWith) { if ($this->mutuallyExclusiveWith == 'None') { $this->mutuallyExclusive = array(); } else { $this->mutuallyExclusive = explode(',', $this->mutuallyExclusiveWith); } } else { $this->mutuallyExclusive = 'All'; } // fetch rank votes for this option $query = "\n SELECT\n SUM(vote) as sumVotes\n FROM\n suggestions_option_ranks\n WHERE\n optionid = " . $this->id . "\n GROUP BY\n optionid\n "; $this->rankVotes = 0; $sql = $this->dao->query($query); if ($sql) { $row = $sql->fetch(PDB::FETCH_OBJ); if ($row) { $this->rankVotes = $row->sumVotes; } } // if member already ranked on this option get that as well $member = $this->getLoggedInMember(); if ($member) { $hash = hash_hmac('sha256', $member->id, $this->id); $query = "SELECT vote FROM suggestions_option_ranks WHERE optionid = " . $this->id . " AND memberHash = '" . $hash . "'"; $sql = $this->dao->query($query); if ($sql) { $row = $sql->fetch(PDB::FETCH_OBJ); if ($row) { $this->vote = $row->vote; } } } } return $status; }
/** * overloads RoxEntityBase::loadEntity to load related data * * @param array $data * * @access protected * @return bool */ protected function loadEntity(array $data) { if ($status = parent::loadEntity($data)) { // split date and time for start and end $startdatetime = strtotime($this->dateTimeStart); $this->dateStart = date('d.m.Y', $startdatetime); $this->timeStart = date('H:i', $startdatetime); $enddatetime = strtotime($this->dateTimeEnd); $this->dateEnd = date('d.m.Y', $enddatetime); $this->timeEnd = date('H:i', $enddatetime); // get organizers $query = "\n SELECT\n a.*,\n m.Username\n FROM\n activitiesattendees AS a,\n members AS m\n WHERE\n a.activityId = {$this->getPKValue()}\n AND a.organizer = 1\n AND a.attendeeId = m.Id\n AND m.Status IN ('Active', 'OutOfRemind')\n ORDER BY\n a.status, m.Username\n "; if ($result = $this->dao->query($query)) { $organizers = array(); while ($organizer = $result->fetch(PDB::FETCH_OBJ)) { $organizers[$organizer->attendeeId] = $organizer; } $this->organizers = $organizers; } // get attendees $query = "\n SELECT\n a.*,\n m.Username\n FROM\n activitiesattendees AS a,\n members AS m\n WHERE\n a.activityId = {$this->getPKValue()}\n AND a.attendeeId = m.Id\n AND m.Status IN ('Active', 'OutOfRemind')\n ORDER BY\n a.status, m.Username\n "; if ($result = $this->dao->query($query)) { $attendees = array(); while ($attendee = $result->fetch(PDB::FETCH_OBJ)) { $attendees[$attendee->attendeeId] = $attendee; } $this->attendees = $attendees; } // location details $entityFactory = new RoxEntityFactory(); $this->location = $entityFactory->create('Geo', $this->locationId); // get counts for yes, maybe and no attendees $this->attendeesYes = $this->getAttendeesCountByStatus(1); $this->attendeesMaybe = $this->getAttendeesCountByStatus(2); $this->attendeesNo = $this->getAttendeesCountByStatus(3); } return $status; }
public function editcreate() { $loggedInMember = $this->_model->getLoggedInMember(); if ($loggedInMember) { $id = 0; if (isset($this->route_vars['id'])) { $id = $this->route_vars['id']; $activity = new Activity($id); if (!in_array($loggedInMember->id, array_keys($activity->organizers))) { $this->redirectAbsolute($this->router->url('activities_my_activities')); } if (time() > strtotime($activity->dateTimeEnd)) { $this->redirectAbsolute($this->router->url('activities_my_activities')); } } else { $activity = new Activity(); $activity->id = 0; $activity->locationId = $loggedInMember->IdCity; $entityFactory = new RoxEntityFactory(); $activity->location = $entityFactory->create('Geo', $activity->locationId); } $page = new ActivitiesEditCreatePage(); $page->member = $loggedInMember; $page->activity = $activity; return $page; } else { return new ActivitiesNotLoggedInPage(); } }
private function postVotingEndsMessage() { $entityFactory = new RoxEntityFactory(); $suggestionsTeam = $entityFactory->create('Member')->findByUsername('SuggestionsTeam'); $text = 'Voting for the suggestion \'<a href="/suggestions/' . $this->id . '/">' . $this->summary . '</a>\' will end on ' . date('Y-m-d', strtotime($this->laststatechanged) + SuggestionsModel::DURATION_VOTING) . '.<br /><br />if you haven\'t done so yet, please cast your vote.'; $suggestions = new SuggestionsModel(); $postId = $suggestions->addPost($suggestionsTeam->id, $text, $this->threadId); $suggestions->setForumNotification($postId, 'reply'); }