File indexing completed on 2025-05-25 05:31:00
0001 <?php 0002 0003 /** 0004 * 0005 * ocs-apiserver 0006 * 0007 * Copyright 2016 by pling GmbH. 0008 * 0009 * This file is part of ocs-apiserver. 0010 * 0011 * This program is free software: you can redistribute it and/or modify 0012 * it under the terms of the GNU Affero General Public License as 0013 * published by the Free Software Foundation, either version 3 of the 0014 * License, or (at your option) any later version. 0015 * 0016 * This program is distributed in the hope that it will be useful, 0017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0019 * GNU Affero General Public License for more details. 0020 * 0021 * You should have received a copy of the GNU Affero General Public License 0022 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0023 * 0024 */ 0025 class Portal_UserController extends Local_Controller_Action_Portal 0026 { 0027 protected $_memberId; 0028 protected $_userName; 0029 0030 0031 public function indexAction() 0032 { 0033 if ($this->hasParam('user_name')) { 0034 $this->_userName = $this->getParam('user_name'); 0035 $this->_userName = urldecode($this->_userName); 0036 0037 $modelMember = new Default_Model_Member(); 0038 $this->_memberId = $modelMember->fetchActiveUserByUsername($this->_userName); 0039 } else { 0040 $this->_memberId = (int)$this->getParam('member_id'); 0041 } 0042 0043 $tableMember = new Default_Model_Member(); 0044 $tableProject = new Default_Model_Project(); 0045 $earnModel = new Default_Model_StatDownload(); 0046 $helperUserRole = new Backend_View_Helper_UserRole(); 0047 $pageLimit = 500; 0048 0049 $this->view->authMember = $this->_authMember; 0050 $this->view->member = $tableMember->fetchMemberData($this->_memberId); 0051 0052 if (null == $this->view->member) { 0053 $this->redirect("/"); 0054 } 0055 if ($this->view->member->is_deleted == 1 or $this->view->member->is_active == 0) { 0056 $this->redirect("/"); 0057 } 0058 0059 $this->view->headTitle($this->view->member->username, 'SET'); 0060 $this->view->mainProject = $this->view->member->findDependentRowset($tableProject, 'MainProject')->current(); 0061 0062 $this->view->userProjectCategories = $tableProject->getUserCreatingCategorys($this->_memberId); 0063 $this->view->aboutmeUserInfo = $this->getAboutmeUserInfo($this->_memberId, $this->view->member->username); 0064 } 0065 0066 0067 public function getAboutmeUserInfo($member_id, $username) 0068 { 0069 $tableProject = new Default_Model_Project(); 0070 $userProjectCategories = $tableProject->getUserCreatingCategorys($member_id); 0071 $cnt = sizeof($userProjectCategories); 0072 $userinfo = ''; 0073 $isAdmin = false; 0074 $helperUserRole = new Backend_View_Helper_UserRole(); 0075 $userRoleName = $helperUserRole->userRole(); 0076 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0077 $isAdmin = true; 0078 } 0079 if ($cnt > 0) { 0080 $userinfo = "Hi, I am <b>" . $username . "</b> and I create "; 0081 if ($cnt == 1) { 0082 $userinfo = $userinfo . ' <b>' . $userProjectCategories[0]['category1'] . '</b>.'; 0083 }elseif($cnt == 2) { 0084 $userinfo = $userinfo . ' <b>' . $userProjectCategories[0]['category1'] . '</b>' 0085 . ' and <b>' . $userProjectCategories[1]['category1'] . '</b>.'; 0086 }elseif($cnt == 3) { 0087 $userinfo = $userinfo . ' <b>' . $userProjectCategories[0]['category1'] . '</b>' 0088 . ', <b>' . $userProjectCategories[1]['category1'] . '</b>' 0089 . ' and <b>' . $userProjectCategories[2]['category1'] . '</b>.'; 0090 }else{ 0091 $userinfo = $userinfo . ' <b>' . $userProjectCategories[0]['category1'] . '</b>' 0092 . ', <b>' . $userProjectCategories[1]['category1'] . '</b>' 0093 . ', <b>' . $userProjectCategories[2]['category1'] . '</b>' 0094 . ' and more.'; 0095 } 0096 }else{ 0097 $userinfo = "Hi, I am <b>" . $username . "</b>."; 0098 } 0099 0100 $mModel = new Default_Model_Member(); 0101 $supportSections = $mModel->fetchSupporterSectionInfo($member_id); 0102 if($supportSections && $supportSections['sections']) 0103 { 0104 $userinfo = $userinfo." I ".($cnt==0?" ":" also ")."support"; 0105 $sections = explode(",", $supportSections['sections']); 0106 foreach ($sections as $s) { 0107 $userinfo.=" <b>".$s."</b>, "; 0108 } 0109 0110 $userinfo = trim($userinfo); 0111 $userinfo = substr($userinfo, 0, -1); 0112 } 0113 0114 0115 0116 if(substr($userinfo, strlen($userinfo)-1) <> ".") 0117 { 0118 $userinfo.="."; 0119 } 0120 return $userinfo; 0121 } 0122 0123 }