コード例 #1
0
 protected function getDirectlyRelatedRecords(&$record)
 {
     $creditsPackageDAO = new CreditsPackageDAO();
     $downloadDAO = new DownloadDAO();
     $clipboardDAO = new ClipboardDAO();
     $fileDAO = new FileDAO();
     $forumThreadDAO = new ForumThreadDAO();
     $forumPostDAO = new ForumPostDAO();
     $authorDAO = new AuthorDAO();
     return array('CreditsPackageDAO' => $creditsPackageDAO->getListByForeignKey('userId', $record['id']), 'DownloadDAO' => $downloadDAO->getListByForeignKey('userId', $record['id']), 'ClipboardDAO' => $clipboardDAO->getListByForeignKey('userId', $record['id']), 'FileDAO' => $fileDAO->getListByRecord('user', $record['id']), 'ForumThreadDAO' => $forumThreadDAO->getListByForeignKey('userId', $record['id']), 'ForumPostDAO' => $forumPostDAO->getListByForeignKey('userId', $record['id']), 'AuthorDAO' => $authorDAO->getListByForeignKey('userId', $record['id']));
 }
コード例 #2
0
 protected function changeUserCredits(&$user, $change, $newPackageId = null)
 {
     $user = $this->userDAO->getRecordById($user['id']);
     // nie chcemy nulla...
     if (empty($user['userCredits'])) {
         $user['userCredits'] = 0;
     }
     $userOld = $user;
     // kopia, nie referencja
     $package = $this->creditsPackageDAO->getLastActiveCreditsPackage($user['id'], $newPackageId);
     if (empty($package['id'])) {
         $user['userCredits'] = 0;
     }
     if ($user['userCredits'] + $change < 0) {
         if ($userOld != $user) {
             $this->userDAO->save($user);
         }
         return false;
     }
     $user['userCredits'] = $user['userCredits'] + $change;
     $this->userDAO->save($user);
     return true;
 }