public function actionReputation() { $query = new Query(); $query2 = new Query(); $query->addSelect('*')->from('reputation r'); $fullrep = $query->all(); $query2->select('id, user_id, rep_id, timestamp')->from('`reputation_history`')->where('user_id = ' . $this->getUser()->getId()); $myrep = $query2->all(); $sum = ReputationHistory::getReputationHistorySum($this->contentContainer->getId()); return $this->render('reputation', ['user' => $this->contentContainer->attributes, 'rep' => $fullrep, 'myrep' => $myrep, 'sum' => $sum]); }
public function getReputationHistoryForAReputation($repid, $user_id) { $fields = array(); $query = ReputationHistory::find(); $query->orderBy('sort_order'); if ($repid !== null) { $query->andWhere(['rep_id' => $repid]); } // foreach ($query->all() as $field) { // // if ($field['user_id'] === $user_id) { // $fields[] = $field; // } // } return $fields; }
/** * When a user clicks on the Accept Invite Link, this action is called. * After this the user should be member of this workspace. * Reputation id is 6 for inviter * * */ public function actionInviteAccept() { $reputation_id = 6; $this->forcePostRequest(); $space = $this->getSpace(); // Load Pending Membership $membership = $space->getMembership(); if ($membership == null) { throw new HttpException(404, Yii::t('SpaceModule.controllers_SpaceController', 'There is no pending invite!')); } // Check there are really an Invite if ($membership->status == Membership::STATUS_INVITED) { $space->addMember(Yii::$app->user->id); ReputationHistory::addReputation($membership->originator_user_id, $reputation_id); } return $this->redirect($space->getUrl()); }