public function __construct(NarroUser $objUser, $objParentObject, $strControlId = null) { // Call the Parent try { parent::__construct($objParentObject, $strControlId); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } $this->strTemplate = dirname(__FILE__) . '/' . __CLASS__ . '.tpl.php'; $this->objUser = $objUser; $this->pnlTranslatedPerProjectPie = new QDatabasePieChart($this); $this->pnlTranslatedPerProjectPie->Query = sprintf(' SELECT narro_project.project_name AS label, COUNT(narro_suggestion.suggestion_id) AS cnt FROM narro_suggestion, narro_context, narro_project WHERE narro_context.text_id = narro_suggestion.text_id AND narro_project.project_id = narro_context.project_id AND narro_suggestion.language_id=%d AND narro_suggestion.user_id=%d GROUP BY narro_context.project_id', QApplication::GetLanguageId(), $this->objUser->UserId); $intSuggestionCount = NarroSuggestion::CountByUserId($this->objUser->UserId); $this->pnlTranslatedPerProjectPie->Total = $intSuggestionCount; $this->pnlTranslatedPerProjectPie->MinimumDataValue = 0; $this->pnlApprovedPie = new QPieChart($this); $this->pnlApprovedPie->Total = $this->pnlTranslatedPerProjectPie->Total; $this->pnlApprovedPie->MinimumDataValue = 0; $objDatabase = NarroContextInfo::GetDatabase(); $strQuery = sprintf("\n SELECT\n DISTINCT narro_context_info.valid_suggestion_id\n FROM\n narro_context_info, narro_suggestion\n WHERE\n narro_context_info.valid_suggestion_id=narro_suggestion.suggestion_id AND\n narro_suggestion.user_id=%d", $this->objUser->UserId); $objDbResult = $objDatabase->Query($strQuery); $intValidSuggestionCount = $objDbResult->CountRows(); $this->pnlApprovedPie->Data = array(t('Approved') => $intValidSuggestionCount, t('Not approved') => $intSuggestionCount - $intValidSuggestionCount); $this->tabActivity = new QTabs($this); $this->dtgSuggestions_Create(); $arrHeaders[] = t('Translations'); $this->dtgReviews_Create(); $arrHeaders[] = t('Reviews'); $this->dtgComments_Create(); $arrHeaders[] = t('Comments'); $this->dtgVotes_Create(); $arrHeaders[] = t('Votes'); if (QApplication::HasPermissionForThisLang('Administrator') || QApplication::GetUserId() == $this->objUser->UserId) { $this->dtgLog_Create(); $arrHeaders[] = t('Logged messages'); } $this->tabActivity->Headers = $arrHeaders; }
/** * Counts all associated NarroSuggestionsAsUser * @return int */ public function CountNarroSuggestionsAsUser() { if (is_null($this->intUserId)) { return 0; } return NarroSuggestion::CountByUserId($this->intUserId); }