/** * * Adds a_edited array of data to Question * * @param User $user * @param string $reason reason for editing * * @return object $this */ public function setEdited(User $user, $reason = '') { if (!empty($reason)) { $reason = \strip_tags((string) $reason); } $aEdited = $this->offsetGet('a_edited'); if (empty($aEdited) || !is_array($aEdited)) { $aEdited = array(); } $aEdited[] = array('username' => $user->getDisplayName(), 'i_uid' => $user->getUid(), 'av' => $user->getAvatarSrc(), 'reason' => $reason, 'i_ts' => time(), 'hts' => date('F j, Y g:i a T')); parent::offsetSet('a_edited', $aEdited); return $this; }
/** * Approve pending resource * * @param User $Moderator User object of user who approved this Question * * @return mixed true if status was changed|int status code of question */ public function setApprovedStatus(\Lampcms\User $Moderator) { $status = $this->offsetGet(Schema::RESOURCE_STATUS_ID); if ($status === Schema::PENDING) { $this->offsetSet(Schema::RESOURCE_STATUS_ID, Schema::POSTED); $this->offsetSet(Schema::APPROVED_BY_ID, $Moderator->getUid()); $this->offsetSet(Schema::APPROVED_BY_USERNAME, $Moderator->getDisplayName()); $this->offsetSet(Schema::APPROVED_TIMESTAMP, time()); $this->touch(true); $this->save(); return true; } return $status; }
/** * Sets value of lp_u : a link to Last Poster profile * and lp_t a time of last post * * @todo should make the last answerer an array * and then just push the value there * This way if answer is deleted we can just delete * that one element from array! * * @param User $User object of type User who made the last * Answer or Comment to this question * * @param \Lampcms\Answer $Answer * * @return object $this */ public function setLatestAnswer(User $User, Answer $Answer) { $aLatest = $this->offsetGet('a_latest'); $a = array('u' => '<a href="' . $User->getProfileUrl() . '">' . $User->getDisplayName() . '</a>', 't' => date('F j, Y g:i a T', $Answer->getLastModified()), 'id' => $Answer->getResourceId()); /** * Latest answer data goes * to top of array */ \array_unshift($aLatest, $a); $this->offsetSet('a_latest', $aLatest); return $this; }