File indexing completed on 2024-12-22 05:33:34
0001 <?php 0002 0003 /** 0004 * ocs-webserver 0005 * 0006 * Copyright 2016 by pling GmbH. 0007 * 0008 * This file is part of ocs-webserver. 0009 * 0010 * This program is free software: you can redistribute it and/or modify 0011 * it under the terms of the GNU Affero General Public License as 0012 * published by the Free Software Foundation, either version 3 of the 0013 * License, or (at your option) any later version. 0014 * 0015 * This program is distributed in the hope that it will be useful, 0016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0018 * GNU Affero General Public License for more details. 0019 * 0020 * You should have received a copy of the GNU Affero General Public License 0021 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0022 **/ 0023 class UserController extends Local_Controller_Action_DomainSwitch 0024 { 0025 0026 protected $_memberId; 0027 protected $_userName; 0028 /** @var Zend_Db_Table_Row */ 0029 protected $_memberSettings; 0030 0031 public function init() 0032 { 0033 parent::init(); 0034 0035 if ($this->hasParam('user_name')) { 0036 $this->_userName = $this->getParam('user_name'); 0037 $this->_userName = urldecode($this->_userName); 0038 0039 $modelMember = new Default_Model_Member(); 0040 $this->_memberId = $modelMember->fetchActiveUserByUsername($this->_userName); 0041 } else { 0042 $this->_memberId = (int)$this->getParam('member_id'); 0043 } 0044 0045 $action = $this->getRequest()->getActionName(); 0046 $title = ''; 0047 if ($action == 'index') { 0048 $title = 'aboutme'; 0049 } else { 0050 $title = $action; 0051 } 0052 $this->view->headTitle($title . ' - ' . $this->getHeadTitle(), 'SET'); 0053 } 0054 0055 public function indexAction() 0056 { 0057 0058 $this->_helper->viewRenderer('aboutme'); 0059 $this->aboutmeAction(); 0060 } 0061 0062 public function aboutmeAction() 0063 { 0064 0065 $tableMember = new Default_Model_Member(); 0066 $tableProject = new Default_Model_Project(); 0067 $earnModel = new Default_Model_StatDownload(); 0068 $helperUserRole = new Backend_View_Helper_UserRole(); 0069 $pageLimit = 500; 0070 $projectpage = (int)$this->getParam('projectpage', 1); 0071 0072 $this->view->authMember = $this->_authMember; 0073 $this->view->member = $tableMember->fetchMemberData($this->_memberId); 0074 0075 0076 if (null == $this->view->member) { 0077 $this->redirect("/"); 0078 } 0079 if ($this->view->member->is_deleted == 1 or $this->view->member->is_active == 0) { 0080 $this->redirect("/"); 0081 } 0082 0083 $this->view->headTitle($this->view->member->username . ' - ' . $this->getHeadTitle(), 'SET'); 0084 $this->view->mainProject = $this->view->member->findDependentRowset($tableProject, 'MainProject')->current(); 0085 0086 $this->view->userProjectCategories = $tableProject->getUserCreatingCategorys($this->_memberId); 0087 $this->view->aboutmeUserInfo = $this->getAboutmeUserInfo($this->_memberId, $this->view->member->username); 0088 0089 0090 $userRoleName = $helperUserRole->userRole(); 0091 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0092 $amount = $earnModel->getLastMonthEarn($this->_memberId); 0093 if ($amount && $amount['amount']) { 0094 $this->view->earnInfo = ' Last month I earned $' . number_format($amount['amount'], 2, '.', '') . '.'; 0095 } else { 0096 $this->view->earnInfo = ' Last month I earned 0.'; 0097 } 0098 } else { 0099 $this->view->earnInfo = ''; 0100 } 0101 0102 0103 // ajax load more products 0104 if ($this->getParam('projectpage', null)) { 0105 $total_records = $tableProject->countAllProjectsForMemberCatFilter($this->_memberId, true, null); 0106 $this->view->pageLimit = $pageLimit; 0107 $this->view->projectpage = $projectpage; 0108 $this->view->total_records = $total_records; 0109 0110 // get last project category id 0111 $lastproject = $tableProject->getUserActiveProjects($this->_memberId, 1, 0112 (($projectpage - 1) * $pageLimit - 1)); 0113 foreach ($lastproject as $value) { 0114 $this->view->lastcatid = $value['project_category_id']; 0115 } 0116 0117 $this->view->userProducts = 0118 $tableProject->getUserActiveProjects($this->_memberId, $pageLimit, ($projectpage - 1) * $pageLimit); 0119 0120 $this->_helper->layout->disableLayout(); 0121 $this->_helper->viewRenderer('partials/aboutmeProducts'); 0122 0123 //$this->forward('showmoreproductsajax', 'user', null, $this->getAllParams()); 0124 return; 0125 } else { 0126 0127 $total_records = $tableProject->countAllProjectsForMemberCatFilter($this->_memberId, true, null); 0128 $this->view->pageLimit = $pageLimit; 0129 $this->view->projectpage = $projectpage; 0130 $this->view->total_records = $total_records; 0131 //$this->view->userProducts = $tableProject->fetchAllProjectsForMember($this->_memberId, $pageLimit, ($projectpage - 1) * $pageLimit,true); 0132 $this->view->userProducts = 0133 $tableProject->getUserActiveProjects($this->_memberId, $pageLimit, ($projectpage - 1) * $pageLimit); 0134 0135 $this->view->userFeaturedProducts = $tableProject->fetchAllFeaturedProjectsForMember($this->_memberId); 0136 $this->view->userCollections = $tableProject->fetchAllCollectionsForMember($this->_memberId); 0137 0138 $paginationComments = $tableMember->fetchComments($this->_memberId); 0139 if ($paginationComments) { 0140 $offset = (int)$this->getParam('page'); 0141 $paginationComments->setItemCountPerPage(50); 0142 $paginationComments->setCurrentPageNumber($offset); 0143 $this->view->comments = $paginationComments; 0144 } 0145 0146 // favs Currently no paging... 0147 $this->view->paramLikePageId = (int)$this->getParam('likepage'); 0148 $model = new Default_Model_DbTable_ProjectFollower(); 0149 $offset = $this->view->paramLikePageId; 0150 $list = $model->fetchLikesForMember($this->_memberId); 0151 $list->setItemCountPerPage(1000); 0152 $list->setCurrentPageNumber($offset); 0153 $this->view->likes = $list; 0154 0155 // plings Currently no paging... 0156 $plingmodel = new Default_Model_ProjectPlings(); 0157 $offset = null; 0158 $plist = $plingmodel->fetchPlingsForMember($this->_memberId); 0159 $plist->setItemCountPerPage(1000); 0160 $plist->setCurrentPageNumber($offset); 0161 $this->view->plings = $plist; 0162 0163 // plings Currently no paging... 0164 $plingmodel = new Default_Model_ProjectPlings(); 0165 $offset = null; 0166 $pslist = $plingmodel->fetchPlingsForSupporter($this->_memberId); 0167 $pslist->setItemCountPerPage(1000); 0168 $pslist->setCurrentPageNumber($offset); 0169 $this->view->supportersplings = $pslist; 0170 0171 // rated 0172 $ratemodel = new Default_Model_DbTable_ProjectRating(); 0173 $this->view->rated = $ratemodel->getRatedForMember($this->_memberId); 0174 0175 $stat = array(); 0176 $stat['cntProducts'] = $total_records; 0177 if ($this->view->userFeaturedProducts) { 0178 $cnt = 0; 0179 foreach ($this->view->userFeaturedProducts as $tmp) { 0180 $cnt++; 0181 } 0182 $stat['cntFProducts'] = $cnt; 0183 } else { 0184 $stat['cntFProducts'] = 0; 0185 } 0186 0187 if ($this->view->userCollections) { 0188 $cnt = 0; 0189 foreach ($this->view->userCollections as $tmp) { 0190 $cnt++; 0191 } 0192 $stat['cntCollections'] = $cnt; 0193 } else { 0194 $stat['cntCollections'] = 0; 0195 } 0196 0197 $stat['cntOrinalProducts'] = $tableProject->getOriginalProjectsForMemberCnt($this->_memberId); 0198 $stat['cntComments'] = $paginationComments->getTotalItemCount(); 0199 $tblFollower = new Default_Model_DbTable_ProjectFollower(); 0200 $stat['cntLikesHeGave'] = $tblFollower->countLikesHeGave($this->_memberId); 0201 $stat['cntLikesHeGot'] = $tblFollower->countLikesHeGot($this->_memberId); 0202 0203 $tblPling = new Default_Model_DbTable_ProjectPlings(); 0204 $stat['cntPlingsHeGave'] = $tblPling->countPlingsHeGave($this->_memberId); 0205 $stat['cntPlingsHeGot'] = $tblPling->countPlingsHeGot($this->_memberId); 0206 0207 $donationinfo = $tableMember->fetchSupporterDonationInfo($this->_memberId); 0208 0209 if ($donationinfo) { 0210 $stat['donationIssupporter'] = $donationinfo['issupporter']; 0211 $stat['donationMax'] = $donationinfo['active_time_max']; 0212 $stat['donationMin'] = $donationinfo['active_time_min']; 0213 $stat['donationCnt'] = $donationinfo['cnt']; 0214 } 0215 0216 $subscriptioninfo = $tableMember->fetchSupporterSubscriptionInfo($this->_memberId); 0217 if ($subscriptioninfo) { 0218 $stat['subscriptionIssupporter'] = true; 0219 $stat['subscriptionStart'] = $subscriptioninfo['create_time']; 0220 $stat['subscriptionAmount'] = $subscriptioninfo['amount']; 0221 $stat['subscriptionPeriod'] = $subscriptioninfo['period']; 0222 if ($subscriptioninfo['period'] == 'M') { 0223 $stat['subscriptionPeriodText'] = 'monthly'; 0224 } else { 0225 if ($subscriptioninfo['period'] == 'Y') { 0226 $stat['subscriptionPeriodText'] = 'yearly'; 0227 } else { 0228 $stat['subscriptionPeriodText'] = ''; 0229 } 0230 } 0231 0232 0233 $stat['subscriptionPeriodFreq'] = $subscriptioninfo['period_frequency']; 0234 } else { 0235 $stat['subscriptionIssupporter'] = false; 0236 } 0237 // $cntmb = $tableMember->fetchCntSupporters($this->_memberId); 0238 // $stat['cntSupporters'] = $cntmb; 0239 $stat['userLastActiveTime'] = $tableMember->fetchLastActiveTime($this->_memberId); 0240 0241 $stat['cntDuplicateSourceurl'] = 0; 0242 $userRoleName = $helperUserRole->userRole(); 0243 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0244 $stat['cntDuplicateSourceurl'] = $tableProject->getCountProjectsDuplicateSourceurl($this->_memberId); 0245 $stat['cntUnpublished'] = $tableProject->getUnpublishedProjectsForMemberCnt($this->_memberId); 0246 $stat['cntDeleted'] = $tableProject->getDeletedProjectsForMemberCnt($this->_memberId); 0247 } 0248 0249 $this->view->stat = $stat; 0250 } 0251 } 0252 0253 public function getAboutmeUserInfo($member_id, $username) 0254 { 0255 $tableProject = new Default_Model_Project(); 0256 $userProjectCategories = $tableProject->getUserCreatingCategorys($member_id); 0257 $cnt = sizeof($userProjectCategories); 0258 $userinfo = ''; 0259 $isAdmin = false; 0260 $helperUserRole = new Backend_View_Helper_UserRole(); 0261 $userRoleName = $helperUserRole->userRole(); 0262 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0263 $isAdmin = true; 0264 } 0265 if ($cnt > 0) { 0266 $userinfo = "Hi, I am <b>" . $username . "</b> and I create "; 0267 if ($cnt == 1) { 0268 $userinfo = $userinfo . ' <b>' . $userProjectCategories[0]['category1'] . '</b>.'; 0269 }elseif($cnt == 2) { 0270 $userinfo = $userinfo . ' <b>' . $userProjectCategories[0]['category1'] . '</b>' 0271 . ' and <b>' . $userProjectCategories[1]['category1'] . '</b>.'; 0272 }elseif($cnt == 3) { 0273 $userinfo = $userinfo . ' <b>' . $userProjectCategories[0]['category1'] . '</b>' 0274 . ', <b>' . $userProjectCategories[1]['category1'] . '</b>' 0275 . ' and <b>' . $userProjectCategories[2]['category1'] . '</b>.'; 0276 }else{ 0277 $userinfo = $userinfo . ' <b>' . $userProjectCategories[0]['category1'] . '</b>' 0278 . ', <b>' . $userProjectCategories[1]['category1'] . '</b>' 0279 . ', <b>' . $userProjectCategories[2]['category1'] . '</b>' 0280 . ' and more.'; 0281 } 0282 }else{ 0283 $userinfo = "Hi, I am <b>" . $username . "</b>."; 0284 } 0285 0286 $mModel = new Default_Model_Member(); 0287 $supportSections = $mModel->fetchSupporterSectionInfo($member_id); 0288 if($supportSections && $supportSections['sections']) 0289 { 0290 $userinfo = $userinfo." I ".($cnt==0?" ":" also ")."support"; 0291 $sections = explode(",", $supportSections['sections']); 0292 foreach ($sections as $s) { 0293 $userinfo.=" <b>".$s."</b>, "; 0294 } 0295 0296 $userinfo = trim($userinfo); 0297 $userinfo = substr($userinfo, 0, -1); 0298 } 0299 0300 0301 0302 if(substr($userinfo, strlen($userinfo)-1) <> ".") 0303 { 0304 $userinfo.="."; 0305 } 0306 return $userinfo; 0307 } 0308 0309 public function duplicatesAction() 0310 { 0311 $tableProject = new Default_Model_Project(); 0312 $pageLimit = 1000; 0313 $projectpage = 1; 0314 $total_records = $tableProject->countAllProjectsForMemberCatFilter($this->_memberId, true, null); 0315 $this->view->pageLimit = $pageLimit; 0316 $this->view->projectpage = $projectpage; 0317 $this->view->total_records = $total_records; 0318 0319 $this->view->userProducts = 0320 $tableProject->getUserActiveProjectsDuplicatedSourceurl($this->_memberId, $pageLimit, 0321 ($projectpage - 1) * $pageLimit); 0322 0323 $this->_helper->layout->disableLayout(); 0324 $this->_helper->viewRenderer('partials/aboutmeProducts'); 0325 0326 } 0327 0328 public function unpublishedAction() 0329 { 0330 $tableProject = new Default_Model_Project(); 0331 0332 $projectpage = $this->getParam('projectpage', 1); 0333 $pageLimit = 1000; 0334 $total_records = 1000; 0335 $this->view->pageLimit = $pageLimit; 0336 $this->view->projectpage = $projectpage; 0337 $this->view->total_records = $total_records; 0338 0339 $this->view->userProducts = 0340 $tableProject->getUnpublishedProjectsForMember($this->_memberId, $pageLimit, 0341 ($projectpage - 1) * $pageLimit); 0342 0343 $this->_helper->layout->disableLayout(); 0344 $this->_helper->viewRenderer('partials/aboutmeProducts'); 0345 } 0346 0347 public function deletedAction() 0348 { 0349 $tableProject = new Default_Model_Project(); 0350 0351 $projectpage = $this->getParam('projectpage', 1); 0352 $pageLimit = 1000; 0353 $total_records = 1000; 0354 $this->view->pageLimit = $pageLimit; 0355 $this->view->projectpage = $projectpage; 0356 $this->view->total_records = $total_records; 0357 0358 $this->view->userProducts = 0359 $tableProject->getDeletedProjectsForMember($this->_memberId, $pageLimit, 0360 ($projectpage - 1) * $pageLimit); 0361 0362 $this->_helper->layout->disableLayout(); 0363 $this->_helper->viewRenderer('partials/aboutmeProducts'); 0364 } 0365 0366 public function showoriginalAction() 0367 { 0368 $tableProject = new Default_Model_Project(); 0369 $projectpage = $this->getParam('projectpage', 1); 0370 $pageLimit = 100; 0371 $total_records = $tableProject->getOriginalProjectsForMemberCnt($this->_memberId); 0372 $this->view->pageLimit = $pageLimit; 0373 $this->view->projectpage = $projectpage; 0374 $this->view->total_records = $total_records; 0375 if($projectpage>1) 0376 { 0377 $lastproject = $tableProject->getOriginalProjectsForMember($this->_memberId, 1, 0378 (($projectpage - 1) * $pageLimit - 1)); 0379 if($lastproject && is_array($lastproject)) 0380 { 0381 foreach ($lastproject as $value) { 0382 $this->view->lastcatid = $value['project_category_id']; 0383 } 0384 } 0385 } 0386 0387 $this->view->userProducts = 0388 $tableProject->getOriginalProjectsForMember($this->_memberId, $pageLimit, 0389 ($projectpage - 1) * $pageLimit); 0390 0391 $this->_helper->layout->disableLayout(); 0392 $this->_helper->viewRenderer('partials/aboutmeProducts'); 0393 } 0394 0395 /** 0396 * to get an avatar picture you can call 0397 * /member/avatar/:emailhash/:size 0398 * or 0399 * /member/u/:user_name/avatar/size/:size 0400 * 0401 * @throws Zend_Exception 0402 */ 0403 public function avatarAction() 0404 { 0405 $this->_helper->layout->disableLayout(); 0406 0407 $size = (int)$this->getParam("size", 200); 0408 $width = (int)$this->getParam("width", ($size / 2)); 0409 $emailHash = $this->getParam("emailhash", null); 0410 $username = $this->getParam('user_name', null); 0411 0412 $avatar = new Default_Model_Avatar(); 0413 $img_url = $avatar->getAvatarUrl($emailHash, $username, $width); 0414 0415 $this->redirect($img_url); 0416 } 0417 0418 public function aboutAction() 0419 { 0420 $this->forward('aboutme'); 0421 } 0422 0423 public function showmoreproductsajaxAction() 0424 { 0425 $this->_helper->layout->disableLayout(); 0426 $tableProject = new Default_Model_Project(); 0427 $pageLimit = 21; 0428 $page = (int)$this->getParam('page', 1); 0429 $total_records = $tableProject->countAllProjectsForMemberCatFilter($this->_memberId, true, null); 0430 $this->view->pageLimit = $pageLimit; 0431 $this->view->page = $page; 0432 $this->view->total_records = $total_records; 0433 $this->view->userProducts = 0434 $tableProject->fetchAllProjectsForMember($this->_memberId, $pageLimit, ($page - 1) * $pageLimit, true); 0435 $this->_helper->viewRenderer('/partials/aboutmeProducts'); 0436 } 0437 0438 public function userdataajaxAction() 0439 { 0440 $this->_helper->layout()->disableLayout(); 0441 $this->_helper->viewRenderer->setNoRender(true); 0442 $resultArray = array(); 0443 0444 header('Access-Control-Allow-Origin: *'); 0445 0446 $this->getResponse()->setHeader('Access-Control-Allow-Origin', 0447 '*')->setHeader('Access-Control-Allow-Credentials', 'true') 0448 ->setHeader('Access-Control-Allow-Methods', 'POST, GET, OPTIONS') 0449 ->setHeader('Access-Control-Allow-Headers', 'origin, content-type, accept'); 0450 0451 $userid = $this->getParam('id'); 0452 0453 $modelMember = new Default_Model_Member(); 0454 $user = $modelMember->find($userid)->current(); 0455 0456 if (Zend_Auth::getInstance()->hasIdentity()) { 0457 0458 $auth = Zend_Auth::getInstance(); 0459 $user = $auth->getStorage()->read(); 0460 0461 $resultArray['member_id'] = $user->member_id; 0462 $resultArray['username'] = $user->username; 0463 $resultArray['mail'] = $user->mail; 0464 $resultArray['avatar'] = $user->profile_image_url; 0465 } else { 0466 if (null != $userid && null != $user) { 0467 0468 $resultArray['member_id'] = $user['member_id']; 0469 $resultArray['username'] = $user['username']; 0470 $resultArray['mail'] = $user['mail']; 0471 $resultArray['avatar'] = $user['profile_image_url']; 0472 } else { 0473 $resultArray['member_id'] = null; 0474 $resultArray['username'] = null; 0475 $resultArray['mail'] = null; 0476 $resultArray['avatar'] = null; 0477 } 0478 } 0479 0480 $resultAll = array(); 0481 $resultAll['status'] = "success"; 0482 $resultAll['data'] = $resultArray; 0483 0484 $this->_helper->json($resultAll); 0485 } 0486 0487 public function followsAction() 0488 { 0489 $this->redirect($this->_helper->url('follows', 'member', null, $this->getAllParams())); 0490 } 0491 0492 public function followAction() 0493 { 0494 $this->_helper->layout->disableLayout(); 0495 0496 $this->view->authMember = $this->_authMember; 0497 $this->view->member_id = $this->_memberId; 0498 0499 if ($this->_memberId == $this->_authMember->member_id) { 0500 return; 0501 } 0502 0503 $memberFollowTable = new Default_Model_DbTable_MemberFollower(); 0504 0505 $newVals = array('member_id' => $this->_memberId, 'follower_id' => (int)$this->_authMember->member_id); 0506 $where = $memberFollowTable->select()->where('member_id = ?', $this->_memberId) 0507 ->where('follower_id = ?', $this->_authMember->member_id, 'INTEGER'); 0508 $result = $memberFollowTable->fetchRow($where); 0509 if (null === $result) { 0510 $memberFollowTable->createRow($newVals)->save(); 0511 } 0512 } 0513 0514 public function unfollowAction() 0515 { 0516 $this->_helper->layout->disableLayout(); 0517 $this->_helper->viewRenderer('follow'); 0518 0519 $memberFollowTable = new Default_Model_DbTable_MemberFollower(); 0520 0521 $memberFollowTable->delete('member_id=' . $this->_memberId . ' AND follower_id=' . $this->_authMember->member_id); 0522 0523 $this->view->authMember = $this->_authMember; 0524 $this->view->member_id = $this->_memberId; 0525 } 0526 0527 public function newsAction() 0528 { 0529 $this->productsAction(); 0530 $this->render('products'); 0531 } 0532 0533 public function productsAction() 0534 { 0535 $pageLimit = 25; 0536 $page = (int)$this->getParam('page', 1); 0537 0538 //create ppload download hash: secret + collection_id + expire-timestamp 0539 $salt = PPLOAD_DOWNLOAD_SECRET; 0540 $timestamp = time() + 3600; // one hour valid 0541 $hash = md5($salt . $timestamp); // order isn't important at all... just do the same when verifying 0542 0543 $this->view->download_hash = $hash; 0544 $this->view->download_timestamp = $timestamp; 0545 0546 $this->view->member_id = null; 0547 if (null != $this->_authMember && null != $this->_authMember->member_id) { 0548 $this->view->member_id = $this->_authMember->member_id; 0549 } 0550 0551 $modelProject = new Default_Model_Project(); 0552 $userProjects = $modelProject->fetchAllProjectsForMember($this->_authMember->member_id, $pageLimit, 0553 ($page - 1) * $pageLimit); 0554 0555 $paginator = Local_Paginator::factory($userProjects); 0556 $paginator->setItemCountPerPage($pageLimit); 0557 $paginator->setCurrentPageNumber($page); 0558 $paginator->setTotalItemCount($modelProject->countAllProjectsForMember($this->_authMember->member_id)); 0559 0560 $this->view->products = $paginator; 0561 $modelMember = new Default_Model_Member(); 0562 $this->view->member = $modelMember->fetchMemberData($this->_authMember->member_id); 0563 } 0564 0565 public function collectionsAction() 0566 { 0567 $pageLimit = 25; 0568 $page = (int)$this->getParam('page', 1); 0569 0570 $this->view->member_id = null; 0571 if (null != $this->_authMember && null != $this->_authMember->member_id) { 0572 $this->view->member_id = $this->_authMember->member_id; 0573 } 0574 0575 $modelProject = new Default_Model_Collection(); 0576 $userProjects = $modelProject->fetchAllCollectionsForMember($this->_authMember->member_id, $pageLimit, 0577 ($page - 1) * $pageLimit); 0578 0579 $paginator = Local_Paginator::factory($userProjects); 0580 $paginator->setItemCountPerPage($pageLimit); 0581 $paginator->setCurrentPageNumber($page); 0582 $paginator->setTotalItemCount($modelProject->countAllCollectionsForMember($this->_authMember->member_id)); 0583 0584 $this->view->products = $paginator; 0585 $modelMember = new Default_Model_Member(); 0586 $this->view->member = $modelMember->fetchMemberData($this->_authMember->member_id); 0587 } 0588 0589 public function activitiesAction() 0590 { 0591 $modelInfo = new Default_Model_Info(); 0592 $this->view->member = $this->_authMember; 0593 $this->view->comments = $modelInfo->getLastCommentsForUsersProjects($this->_authMember->member_id); 0594 $this->view->votes = $modelInfo->getLastVotesForUsersProjects($this->_authMember->member_id); 0595 $this->view->donations = $modelInfo->getLastDonationsForUsersProjects($this->_authMember->member_id); 0596 $this->view->featured = $modelInfo->getFeaturedProductsForUser($this->_authMember->member_id,100); 0597 } 0598 0599 public function settingsAction() 0600 { 0601 $this->_helper->layout()->setLayout('settings'); 0602 } 0603 0604 public function reportAction() 0605 { 0606 $this->_helper->layout->disableLayout(); 0607 0608 $this->_helper->viewRenderer('product/add'); 0609 0610 $this->forward('report', 'product', null, $this->getAllParams()); 0611 } 0612 0613 public function paymentsAction() 0614 { 0615 $this->view->headScript()->setFile(''); 0616 $this->view->headLink()->setStylesheet(''); 0617 0618 $member_id = $this->_authMember->member_id; 0619 $this->view->member = $this->_authMember; 0620 0621 $tableMember = new Default_Model_Member(); 0622 $this->view->hits = $tableMember->fetchPlingedProjects($member_id); 0623 } 0624 0625 public function incomeAction() 0626 { 0627 $this->view->member = $this->_authMember; 0628 $tableMember = new Default_Model_Member(); 0629 $modelPlings = new Default_Model_Pling(); 0630 $this->view->donations = $modelPlings->fetchRecentDonationsForUser($this->_authMember->member_id); 0631 } 0632 0633 public function tooltipAction() 0634 { 0635 $this->_helper->layout->disableLayout(); 0636 $info = new Default_Model_Info(); 0637 $data = $info->getTooptipForMember($this->_memberId); 0638 $this->_helper->json(array('status' => 'ok', 'data' => $data)); 0639 } 0640 0641 public function shareAction() 0642 { 0643 $this->_helper->layout->disableLayout(); 0644 0645 $modelProduct = new Default_Model_Member(); 0646 $memberInfo = $modelProduct->fetchMemberData($this->_memberId); 0647 $form = new Default_Form_ProjectShare(); 0648 $form->setAction('/member/' . $this->_memberId . '/share/'); 0649 0650 // $helperBaseUrl = new Default_View_Helper_BaseUrl(); 0651 // $helperServerUrl = new Zend_View_Helper_ServerUrl(); 0652 $helpMemberUrl = new Default_View_Helper_BuildMemberUrl(); 0653 $this->view->permaLink = $helpMemberUrl->buildMemberUrl($memberInfo->username); 0654 // $this->view->permaLink = $helperServerUrl->serverUrl() . $helperBaseUrl->baseUrl() . '/member/' . $this->_memberId . '/'; 0655 if ($this->_request->isGet()) { 0656 $this->view->form = $form; 0657 $this->renderScript('product/share.phtml'); 0658 0659 return; 0660 } 0661 0662 if (false === $form->isValid($_POST)) { // form not valid 0663 $this->view->form = $form; 0664 $dummy = $this->view->render('product/share.phtml'); 0665 $this->_helper->json(array('status' => 'ok', 'message' => $dummy)); 0666 0667 return; 0668 } 0669 0670 $values = $form->getValues(); 0671 0672 if (empty($memberInfo->firstname) and empty($memberInfo->lastname)) { 0673 $username = $memberInfo->username; 0674 } else { 0675 $username = $memberInfo->firstname . ' ' . $memberInfo->lastname; 0676 } 0677 0678 $shareMail = new Default_Plugin_SendMail('tpl_social_mail_user'); 0679 $shareMail->setTemplateVar('sender', $values['sender_mail']); 0680 $shareMail->setTemplateVar('username', $username); 0681 $shareMail->setTemplateVar('permalink', $this->view->permaLink); 0682 $shareMail->setTemplateVar('permalinktext', '<a href="' . $this->view->permaLink . '">View user\'s page</a>'); 0683 $shareMail->setReceiverMail($values['mail']); 0684 $shareMail->send(); 0685 0686 $this->_helper->json(array('status' => 'ok', 'redirect' => $this->view->permaLink)); 0687 } 0688 0689 public function plingsAction() 0690 { 0691 $tableMember = new Default_Model_Member(); 0692 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 0693 0694 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 0695 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 0696 $this->view->paypal_valid_status = $paypalValidStatus; 0697 0698 //backdoor for admins 0699 $helperUserRole = new Backend_View_Helper_UserRole(); 0700 $userRoleName = $helperUserRole->userRole(); 0701 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0702 $this->view->member = $this->view->view_member; 0703 } else { 0704 $this->view->member = $this->_authMember; 0705 } 0706 } 0707 0708 0709 public function plingsoldAction() 0710 { 0711 $tableMember = new Default_Model_Member(); 0712 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 0713 0714 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 0715 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 0716 $this->view->paypal_valid_status = $paypalValidStatus; 0717 0718 //backdoor for admins 0719 $helperUserRole = new Backend_View_Helper_UserRole(); 0720 $userRoleName = $helperUserRole->userRole(); 0721 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0722 $this->view->member = $this->view->view_member; 0723 } else { 0724 $this->view->member = $this->_authMember; 0725 } 0726 } 0727 0728 0729 public function plingsajaxAction() 0730 { 0731 $this->_helper->layout->disableLayout(); 0732 0733 $tableMember = new Default_Model_Member(); 0734 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 0735 0736 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 0737 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 0738 $this->view->paypal_valid_status = $paypalValidStatus; 0739 0740 //backdoor for admins 0741 $helperUserRole = new Backend_View_Helper_UserRole(); 0742 $userRoleName = $helperUserRole->userRole(); 0743 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0744 $this->view->member = $this->view->view_member; 0745 } else { 0746 $this->view->member = $this->_authMember; 0747 } 0748 0749 $year = null; 0750 if ($this->hasParam('year')) { 0751 $year = $this->getParam('year'); 0752 } 0753 $this->view->year = $year; 0754 0755 $this->_helper->viewRenderer('/plingsajax'); 0756 } 0757 0758 public function plingsmonthajaxAction() 0759 { 0760 $this->_helper->layout->disableLayout(); 0761 0762 $tableMember = new Default_Model_Member(); 0763 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 0764 0765 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 0766 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 0767 $this->view->paypal_valid_status = $paypalValidStatus; 0768 0769 //backdoor for admins 0770 $helperUserRole = new Backend_View_Helper_UserRole(); 0771 $userRoleName = $helperUserRole->userRole(); 0772 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0773 $this->view->member = $this->view->view_member; 0774 } else { 0775 $this->view->member = $this->_authMember; 0776 } 0777 0778 $yearmonth = null; 0779 if ($this->hasParam('yearmonth')) { 0780 $yearmonth = $this->getParam('yearmonth'); 0781 } 0782 $section_id = null; 0783 if ($this->hasParam('section_id')) { 0784 $section_id = $this->getParam('section_id'); 0785 } 0786 0787 $this->view->yearmonth = $yearmonth; 0788 $this->view->section_id = $section_id; 0789 0790 $this->_helper->viewRenderer('/plingsmonthajax'); 0791 } 0792 0793 0794 public function plingsajax3Action() 0795 { 0796 $this->_helper->layout->disableLayout(); 0797 0798 $tableMember = new Default_Model_Member(); 0799 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 0800 0801 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 0802 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 0803 $this->view->paypal_valid_status = $paypalValidStatus; 0804 0805 //backdoor for admins 0806 $helperUserRole = new Backend_View_Helper_UserRole(); 0807 $userRoleName = $helperUserRole->userRole(); 0808 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0809 $this->view->member = $this->view->view_member; 0810 } else { 0811 $this->view->member = $this->_authMember; 0812 } 0813 0814 $year = null; 0815 if ($this->hasParam('year')) { 0816 $year = $this->getParam('year'); 0817 } 0818 $this->view->year = $year; 0819 0820 $this->_helper->viewRenderer('/plingsajax3'); 0821 } 0822 0823 public function plingsmonthajax3Action() 0824 { 0825 $this->_helper->layout->disableLayout(); 0826 0827 $tableMember = new Default_Model_Member(); 0828 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 0829 0830 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 0831 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 0832 $this->view->paypal_valid_status = $paypalValidStatus; 0833 0834 //backdoor for admins 0835 $helperUserRole = new Backend_View_Helper_UserRole(); 0836 $userRoleName = $helperUserRole->userRole(); 0837 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0838 $this->view->member = $this->view->view_member; 0839 } else { 0840 $this->view->member = $this->_authMember; 0841 } 0842 0843 $yearmonth = null; 0844 if ($this->hasParam('yearmonth')) { 0845 $yearmonth = $this->getParam('yearmonth'); 0846 } 0847 $section_id = null; 0848 if ($this->hasParam('section_id')) { 0849 $section_id = $this->getParam('section_id'); 0850 } 0851 0852 $this->view->yearmonth = $yearmonth; 0853 $this->view->section_id = $section_id; 0854 0855 $this->_helper->viewRenderer('/plingsmonthajax3'); 0856 } 0857 0858 0859 public function sectionplingsmonthajaxAction() 0860 { 0861 $this->_helper->layout->disableLayout(); 0862 0863 $tableMember = new Default_Model_Member(); 0864 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 0865 0866 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 0867 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 0868 $this->view->paypal_valid_status = $paypalValidStatus; 0869 0870 //backdoor for admins 0871 $helperUserRole = new Backend_View_Helper_UserRole(); 0872 $userRoleName = $helperUserRole->userRole(); 0873 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0874 $this->view->member = $this->view->view_member; 0875 } else { 0876 $this->view->member = $this->_authMember; 0877 } 0878 0879 $yearmonth = null; 0880 if ($this->hasParam('yearmonth')) { 0881 $yearmonth = $this->getParam('yearmonth'); 0882 } 0883 $section_id = null; 0884 if ($this->hasParam('section_id')) { 0885 $section_id = $this->getParam('section_id'); 0886 } 0887 0888 $this->view->yearmonth = $yearmonth; 0889 $this->view->section_id = $section_id; 0890 0891 $this->_helper->viewRenderer('/sectionplingsmonthajax'); 0892 } 0893 0894 public function sectioncreditsmonthajaxAction() 0895 { 0896 $this->_helper->layout->disableLayout(); 0897 0898 $tableMember = new Default_Model_Member(); 0899 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 0900 0901 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 0902 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 0903 $this->view->paypal_valid_status = $paypalValidStatus; 0904 0905 //backdoor for admins 0906 $helperUserRole = new Backend_View_Helper_UserRole(); 0907 $userRoleName = $helperUserRole->userRole(); 0908 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0909 $this->view->member = $this->view->view_member; 0910 } else { 0911 $this->view->member = $this->_authMember; 0912 } 0913 0914 $yearmonth = null; 0915 if ($this->hasParam('yearmonth')) { 0916 $yearmonth = $this->getParam('yearmonth'); 0917 } 0918 $section_id = null; 0919 if ($this->hasParam('section_id')) { 0920 $section_id = $this->getParam('section_id'); 0921 } 0922 $project_id = null; 0923 if ($this->hasParam('project_id')) { 0924 $project_id = $this->getParam('project_id'); 0925 } 0926 0927 $this->view->yearmonth = $yearmonth; 0928 $this->view->section_id = $section_id; 0929 $this->view->project_id = $project_id; 0930 0931 $this->_helper->viewRenderer('/sectioncreditsmonthajax'); 0932 } 0933 0934 0935 public function sectionaffiliatesmonthajaxAction() 0936 { 0937 $this->_helper->layout->disableLayout(); 0938 0939 $tableMember = new Default_Model_Member(); 0940 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 0941 0942 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 0943 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 0944 $this->view->paypal_valid_status = $paypalValidStatus; 0945 0946 //backdoor for admins 0947 $helperUserRole = new Backend_View_Helper_UserRole(); 0948 $userRoleName = $helperUserRole->userRole(); 0949 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0950 $this->view->member = $this->view->view_member; 0951 } else { 0952 $this->view->member = $this->_authMember; 0953 } 0954 0955 $yearmonth = null; 0956 if ($this->hasParam('yearmonth')) { 0957 $yearmonth = $this->getParam('yearmonth'); 0958 } 0959 $section_id = null; 0960 if ($this->hasParam('section_id')) { 0961 $section_id = $this->getParam('section_id'); 0962 } 0963 0964 $this->view->yearmonth = $yearmonth; 0965 $this->view->section_id = $section_id; 0966 0967 $this->_helper->viewRenderer('/sectionaffiliatesmonthajax'); 0968 } 0969 0970 0971 public function sectionaffiliatesmonthdetailajaxAction() 0972 { 0973 $this->_helper->layout->disableLayout(); 0974 0975 $tableMember = new Default_Model_Member(); 0976 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 0977 0978 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 0979 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 0980 $this->view->paypal_valid_status = $paypalValidStatus; 0981 0982 //backdoor for admins 0983 $helperUserRole = new Backend_View_Helper_UserRole(); 0984 $userRoleName = $helperUserRole->userRole(); 0985 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 0986 $this->view->member = $this->view->view_member; 0987 } else { 0988 $this->view->member = $this->_authMember; 0989 } 0990 0991 $yearmonth = null; 0992 if ($this->hasParam('yearmonth')) { 0993 $yearmonth = $this->getParam('yearmonth'); 0994 } 0995 $section_id = null; 0996 if ($this->hasParam('section_id')) { 0997 $section_id = $this->getParam('section_id'); 0998 } 0999 1000 $this->view->yearmonth = $yearmonth; 1001 $this->view->section_id = $section_id; 1002 1003 $this->_helper->viewRenderer('/sectionaffiliatesmonthdetailajax'); 1004 } 1005 1006 1007 public function sectionsajaxAction() 1008 { 1009 $this->_helper->layout->disableLayout(); 1010 1011 $tableMember = new Default_Model_Member(); 1012 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1013 1014 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 1015 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 1016 $this->view->paypal_valid_status = $paypalValidStatus; 1017 1018 //backdoor for admins 1019 $helperUserRole = new Backend_View_Helper_UserRole(); 1020 $userRoleName = $helperUserRole->userRole(); 1021 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1022 $this->view->member = $this->view->view_member; 1023 } else { 1024 $this->view->member = $this->_authMember; 1025 } 1026 1027 $year = null; 1028 if ($this->hasParam('year')) { 1029 $year = $this->getParam('year'); 1030 } 1031 $this->view->year = $year; 1032 1033 $this->_helper->viewRenderer('/sectionsajax'); 1034 } 1035 1036 1037 public function affiliatesajaxAction() 1038 { 1039 $this->_helper->layout->disableLayout(); 1040 1041 $tableMember = new Default_Model_Member(); 1042 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1043 1044 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 1045 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 1046 $this->view->paypal_valid_status = $paypalValidStatus; 1047 1048 //backdoor for admins 1049 $helperUserRole = new Backend_View_Helper_UserRole(); 1050 $userRoleName = $helperUserRole->userRole(); 1051 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1052 $this->view->member = $this->view->view_member; 1053 } else { 1054 $this->view->member = $this->_authMember; 1055 } 1056 1057 $year = null; 1058 if ($this->hasParam('year')) { 1059 $year = $this->getParam('year'); 1060 } 1061 $this->view->year = $year; 1062 1063 $this->_helper->viewRenderer('/affiliatesajax'); 1064 } 1065 1066 public function sectionsmonthajaxAction() 1067 { 1068 $this->_helper->layout->disableLayout(); 1069 1070 $tableMember = new Default_Model_Member(); 1071 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1072 1073 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 1074 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 1075 $this->view->paypal_valid_status = $paypalValidStatus; 1076 1077 //backdoor for admins 1078 $helperUserRole = new Backend_View_Helper_UserRole(); 1079 $userRoleName = $helperUserRole->userRole(); 1080 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1081 $this->view->member = $this->view->view_member; 1082 } else { 1083 $this->view->member = $this->_authMember; 1084 } 1085 1086 $yearmonth = null; 1087 if ($this->hasParam('yearmonth')) { 1088 $yearmonth = $this->getParam('yearmonth'); 1089 } 1090 $this->view->yearmonth = $yearmonth; 1091 1092 $this->_helper->viewRenderer('/sectionsmonthajax'); 1093 } 1094 1095 public function downloadhistoryAction() 1096 { 1097 1098 1099 $tableMember = new Default_Model_Member(); 1100 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1101 1102 //backdore for admins 1103 $helperUserRole = new Backend_View_Helper_UserRole(); 1104 $userRoleName = $helperUserRole->userRole(); 1105 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1106 $this->view->member = $this->view->view_member; 1107 } else { 1108 $this->view->member = $this->_authMember; 1109 } 1110 1111 if ($this->view->member) { 1112 $this->view->paramPageId = (int)$this->getParam('page'); 1113 1114 //TODO do really sql paging instead of Zend_Paginator 1115 $dhistory = new Default_Model_DbTable_MemberDownloadHistory(); 1116 $offset = $this->view->paramPageId; 1117 $list = $dhistory->getDownloadhistory($this->view->member->member_id); 1118 $list->setItemCountPerPage(250); 1119 $list->setCurrentPageNumber($offset); 1120 $this->view->downloadhistory = $list; 1121 } else { 1122 $this->view->downloadhistory = array(); 1123 } 1124 } 1125 1126 public function likesAction() 1127 { 1128 1129 $tableMember = new Default_Model_Member(); 1130 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1131 1132 //backdore for admins 1133 $helperUserRole = new Backend_View_Helper_UserRole(); 1134 $userRoleName = $helperUserRole->userRole(); 1135 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1136 $this->view->member = $this->view->view_member; 1137 } else { 1138 $this->view->member = $this->_authMember; 1139 } 1140 1141 if ($this->view->member) { 1142 $this->view->paramPageId = (int)$this->getParam('page'); 1143 $model = new Default_Model_DbTable_ProjectFollower(); 1144 $offset = $this->view->paramPageId; 1145 $list = $model->fetchLikesForMember($this->view->member->member_id); 1146 $list->setItemCountPerPage(250); 1147 $list->setCurrentPageNumber($offset); 1148 $this->view->likes = $list; 1149 } else { 1150 $this->view->likes = array(); 1151 } 1152 } 1153 1154 public function supportAction() 1155 { 1156 1157 $helperUserRole = new Backend_View_Helper_UserRole(); 1158 $userRoleName = $helperUserRole->userRole(); 1159 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1160 $tableMember = new Default_Model_Member(); 1161 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1162 $this->view->member = $this->view->view_member; 1163 } else { 1164 $this->view->member = $this->_authMember; 1165 } 1166 1167 $model = new Default_Model_DbTable_Support(); 1168 $this->view->supporterlist = $model->getSupporterDonationList($this->view->member->member_id); 1169 1170 1171 } 1172 1173 public function fundingAction() 1174 { 1175 1176 $tableMember = new Default_Model_Member(); 1177 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1178 1179 //backdoor for admins 1180 $helperUserRole = new Backend_View_Helper_UserRole(); 1181 $userRoleName = $helperUserRole->userRole(); 1182 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1183 $this->view->member = $this->view->view_member; 1184 } else { 1185 $this->view->member = $this->_authMember; 1186 } 1187 1188 $model = new Default_Model_DbTable_Support(); 1189 $this->view->supporterlist = $model->getSupporterDonationList($this->view->member->member_id); 1190 1191 1192 } 1193 1194 public function payoutoldAction() 1195 { 1196 1197 $tableMember = new Default_Model_Member(); 1198 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1199 1200 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 1201 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 1202 $this->view->paypal_valid_status = $paypalValidStatus; 1203 1204 //backdoor for admins 1205 $helperUserRole = new Backend_View_Helper_UserRole(); 1206 $userRoleName = $helperUserRole->userRole(); 1207 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1208 $this->view->member = $this->view->view_member; 1209 } else { 1210 $this->view->member = $this->_authMember; 1211 } 1212 } 1213 1214 1215 public function payoutAction() 1216 { 1217 1218 $tableMember = new Default_Model_Member(); 1219 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1220 1221 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 1222 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 1223 $this->view->paypal_valid_status = $paypalValidStatus; 1224 1225 //backdoor for admins 1226 $helperUserRole = new Backend_View_Helper_UserRole(); 1227 $userRoleName = $helperUserRole->userRole(); 1228 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1229 $this->view->member = $this->view->view_member; 1230 } else { 1231 $this->view->member = $this->_authMember; 1232 } 1233 } 1234 1235 1236 public function affiliatesAction() 1237 { 1238 1239 $tableMember = new Default_Model_Member(); 1240 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1241 1242 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 1243 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 1244 $this->view->paypal_valid_status = $paypalValidStatus; 1245 1246 //backdoor for admins 1247 $helperUserRole = new Backend_View_Helper_UserRole(); 1248 $userRoleName = $helperUserRole->userRole(); 1249 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1250 $this->view->member = $this->view->view_member; 1251 } else { 1252 $this->view->member = $this->_authMember; 1253 } 1254 } 1255 1256 public function payout3Action() 1257 { 1258 1259 $tableMember = new Default_Model_Member(); 1260 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1261 1262 $paypalValidStatusTable = new Default_Model_DbTable_PaypalValidStatus(); 1263 $paypalValidStatus = $paypalValidStatusTable->find($this->view->view_member->paypal_valid_status)->current(); 1264 $this->view->paypal_valid_status = $paypalValidStatus; 1265 1266 //backdoor for admins 1267 $helperUserRole = new Backend_View_Helper_UserRole(); 1268 $userRoleName = $helperUserRole->userRole(); 1269 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1270 $this->view->member = $this->view->view_member; 1271 } else { 1272 $this->view->member = $this->_authMember; 1273 } 1274 } 1275 1276 public function payouthistoryoldAction() 1277 { 1278 1279 $tableMember = new Default_Model_Member(); 1280 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1281 1282 //backdoor for admins 1283 $helperUserRole = new Backend_View_Helper_UserRole(); 1284 $userRoleName = $helperUserRole->userRole(); 1285 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1286 $this->view->member = $this->view->view_member; 1287 } else { 1288 $this->view->member = $this->_authMember; 1289 if ($this->_memberId != $this->_authMember->member_id) { 1290 throw new Zend_Controller_Action_Exception('no authorization found'); 1291 } 1292 } 1293 1294 $model = new Default_Model_StatDownload(); 1295 $resultSet = $model->getPayoutHistory($this->view->member->member_id); 1296 1297 $this->view->payouthistory = $resultSet; 1298 1299 1300 } 1301 1302 public function payouthistoryAction() 1303 { 1304 1305 $tableMember = new Default_Model_Member(); 1306 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1307 1308 //backdoor for admins 1309 $helperUserRole = new Backend_View_Helper_UserRole(); 1310 $userRoleName = $helperUserRole->userRole(); 1311 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1312 $this->view->member = $this->view->view_member; 1313 } else { 1314 $this->view->member = $this->_authMember; 1315 if ($this->_memberId != $this->_authMember->member_id) { 1316 throw new Zend_Controller_Action_Exception('no authorization found'); 1317 } 1318 } 1319 1320 $model = new Default_Model_StatDownload(); 1321 $resultSet = $model->getPayoutHistory2($this->view->member->member_id); 1322 1323 $this->view->payouthistory2 = $resultSet; 1324 1325 1326 } 1327 1328 1329 public function _payouthistoryAction() 1330 { 1331 1332 $tableMember = new Default_Model_Member(); 1333 $this->view->view_member = $tableMember->fetchMemberData($this->_memberId); 1334 1335 //backdoor for admins 1336 $helperUserRole = new Backend_View_Helper_UserRole(); 1337 $userRoleName = $helperUserRole->userRole(); 1338 if (Default_Model_DbTable_MemberRole::ROLE_NAME_ADMIN == $userRoleName) { 1339 $this->view->member = $this->view->view_member; 1340 } else { 1341 $this->view->member = $this->_authMember; 1342 if ($this->_memberId != $this->_authMember->member_id) { 1343 throw new Zend_Controller_Action_Exception('no authorization found'); 1344 } 1345 } 1346 1347 // these are already payed 1348 $sql = "SELECT `yearmonth`, `amount` FROM `member_payout` WHERE `member_id` = :member_id ORDER BY `yearmonth` ASC"; 1349 $resultSet = Zend_Db_Table::getDefaultAdapter()->fetchAll($sql, 1350 array('member_id' => $this->view->member->member_id)); 1351 1352 1353 // there are probably payed last 2 months 1354 // current month 1355 $date = new DateTime(); 1356 $ym = $date->format('Ym'); 1357 $is_in = false; 1358 foreach ($resultSet as $value) { 1359 if ($ym == $value['yearmonth']) { 1360 $is_in = true; 1361 break; 1362 } 1363 } 1364 1365 if (!$is_in) { 1366 $model = new Default_Model_StatDownload(); 1367 $result = $model->getUserDownloadsForMonth($this->view->member->member_id, $ym); 1368 $amount = 0; 1369 foreach ($result as $value) { 1370 if ($value['is_license_missing_now'] == 1 1371 || $value['is_source_missing_now'] == 1 1372 || $value['is_pling_excluded_now'] == 1 1373 ) { 1374 continue; 1375 } 1376 $amount = $amount + $value['probably_payout_amount']; 1377 } 1378 $currentMonth = array('yearmonth' => $ym, 'amount' => $amount); 1379 1380 // test last month too 1381 $interval = new DateInterval('P1M');//2 months 1382 $lastmonthdate = $date->sub($interval); 1383 $ym = $lastmonthdate->format('Ym'); 1384 $is_in = false; 1385 foreach ($resultSet as $value) { 1386 if ($ym == $value['yearmonth']) { 1387 $is_in = true; 1388 break; 1389 } 1390 } 1391 if (!$is_in) { 1392 $model = new Default_Model_StatDownload(); 1393 $result = $model->getUserDownloadsForMonth($this->view->member->member_id, $ym); 1394 $amount = 0; 1395 foreach ($result as $value) { 1396 if ($value['is_license_missing'] == 1 1397 || $value['is_source_missing'] == 1 1398 || $value['is_pling_excluded'] == 1 1399 ) { 1400 continue; 1401 } 1402 $amount = $amount + $value['probably_payout_amount']; 1403 } 1404 $lastMonth = array('yearmonth' => $ym, 'amount' => $amount); 1405 array_push($resultSet, $lastMonth); 1406 } 1407 array_push($resultSet, $currentMonth); 1408 } 1409 1410 $this->view->payouthistory = $resultSet; 1411 1412 1413 } 1414 1415 1416 /** 1417 * @return Default_Form_Settings 1418 * @throws Zend_Form_Exception 1419 */ 1420 private function formPassword() 1421 { 1422 $form = new Default_Form_Settings(); 1423 $form->setMethod("POST")->setAttrib("id", 1424 "settingsPasswordForm")->setAction('/member/' . $this->_memberId . '/changepass'); 1425 1426 $passOld = $form->createElement('password', 'passwordOld')->setLabel('Enter old Password:')->setRequired(true) 1427 ->removeDecorator('HtmlTag')->addValidator(new Local_Validate_OldPasswordConfirm())->setDecorators(array( 1428 'ViewHelper', 1429 'Label', 1430 'Errors', 1431 array( 1432 'ViewScript', 1433 array( 1434 'viewScript' => 'settings/viewscripts/flatui_input.phtml', 1435 'placement' => false 1436 ) 1437 ) 1438 )); 1439 1440 $pass1 = $form->createElement('password', 'password1')->setLabel('Enter new Password:')->setRequired(true) 1441 ->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->removeDecorator('HtmlTag') 1442 ->setDecorators(array( 1443 'ViewHelper', 1444 'Label', 1445 'Errors', 1446 array( 1447 'ViewScript', 1448 array( 1449 'viewScript' => 'settings/viewscripts/flatui_input.phtml', 1450 'placement' => false 1451 ) 1452 ) 1453 )); 1454 1455 $pass2 = $form->createElement('password', 'password2')->setLabel('Re-enter new Password:')->setRequired(true) 1456 ->addValidator(new Zend_Validate_NotEmpty(Zend_Validate_NotEmpty::STRING))->removeDecorator('HtmlTag') 1457 ->setDecorators(array( 1458 'ViewHelper', 1459 'Label', 1460 'Errors', 1461 array( 1462 'ViewScript', 1463 array( 1464 'viewScript' => 'settings/viewscripts/flatui_input.phtml', 1465 'placement' => false 1466 ) 1467 ) 1468 )); 1469 1470 $passValid = new Local_Validate_PasswordConfirm($pass2->getValue()); 1471 $pass1->addValidator($passValid); 1472 1473 $form->addElement($passOld)->addElement($pass1)->addElement($pass2); 1474 1475 return $form; 1476 } 1477 1478 private function fetchMemberId() 1479 { 1480 if (false === Zend_Auth::getInstance()->hasIdentity()) { 1481 return null; 1482 } 1483 1484 $auth = Zend_Auth::getInstance()->getIdentity(); 1485 1486 if ($this->_userName == $auth->username) { 1487 return $auth->member_id; 1488 } 1489 1490 if (Default_Model_DbTable_Member::ROLE_ID_ADMIN == $auth->roleId) { 1491 return $this->_memberId; 1492 } 1493 } 1494 1495 }