Changeset 49
- Timestamp:
- 05/24/08 14:04:33
- Files:
-
- trunk/apps/main/config/factories.yml (modified) (1 diff)
- trunk/apps/main/config/settings.yml (modified) (4 diffs)
- trunk/lib/model/Application.php (modified) (2 diffs)
- trunk/lib/model/ApplicationDeveloper.php (modified) (2 diffs)
- trunk/lib/model/Company.php (modified) (2 diffs)
- trunk/lib/model/CompanyPerson.php (modified) (1 diff)
- trunk/lib/model/Event.php (modified) (3 diffs)
- trunk/lib/model/Job.php (modified) (2 diffs)
- trunk/lib/model/PluginsfGuardUser.php (modified) (1 diff)
- trunk/lib/model/Recommendation.php (modified) (6 diffs)
- trunk/test/unit/KarmaTest.php (deleted)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/apps/main/config/factories.yml
r48 r49 43 43 session_cookie_domain: .<?php echo SYMFONIANS_MAIN_DOMAIN."\n" ?> 44 44 session_cookie_lifetime: <?php echo (30 * 86400)."\n" ?> 45 user: 46 class: myUser 47 param: 48 timeout: <?php echo (30 * 86400)."\n" ?> trunk/apps/main/config/settings.yml
r48 r49 4 4 no_script_name: on 5 5 cache: on 6 timeout: 1800000007 6 8 7 dev: … … 13 12 no_script_name: off 14 13 etag: off 15 timeout: 8640016 14 17 15 search: … … 22 20 no_script_name: off 23 21 etag: off 24 timeout: 8640025 22 26 23 staging: … … 31 28 no_script_name: off 32 29 etag: off 33 timeout: 8640034 30 35 31 test: trunk/lib/model/Application.php
r48 r49 242 242 $this->save(); 243 243 $delete = parent::delete($con); 244 if ($this->getsfGuardUser())245 {246 $this->getsfGuardUser()->updateKarma(true);247 }248 244 return $delete; 249 245 } … … 260 256 $modified = $this->isModified(); 261 257 $save = parent::save($con); 262 263 // Update user karma264 if ($this->getsfGuardUser())265 {266 $this->getsfGuardUser()->updateKarma(true);267 }268 258 269 259 // Create "app created" event object trunk/lib/model/ApplicationDeveloper.php
r2 r49 8 8 { 9 9 10 public function delete($con = null)11 {12 $delete = parent::delete($con);13 if ($this->getsfGuardUser())14 {15 $this->getsfGuardUser()->updateKarma(true);16 }17 return $delete;18 }19 20 10 public function save($con = null) 21 11 { … … 23 13 $modified = $this->isModified(); 24 14 $save = parent::save($con); 25 26 if ($this->getsfGuardUser())27 {28 $this->getsfGuardUser()->updateKarma(true);29 }30 15 31 16 // Create "person recommended" event object trunk/lib/model/Company.php
r48 r49 182 182 183 183 /** 184 * Deletes Company instance185 *186 * @param Connection $con187 * @return int188 */189 public function delete($con = null)190 {191 $delete = parent::delete($con);192 if ($this->getsfGuardUser())193 {194 $this->getsfGuardUser()->updateKarma(true);195 }196 return $delete;197 }198 199 /**200 184 * Saves Company instance 201 185 * … … 208 192 $modified = $this->isModified(); 209 193 $affectedRows = parent::save($con); 210 211 if ($affectedRows > 0 && $this->getsfGuardUser())212 {213 $this->getsfGuardUser()->updateKarma(true);214 }215 194 216 195 // Create "company created" event object trunk/lib/model/CompanyPerson.php
r2 r49 13 13 $modified = $this->isModified(); 14 14 $save = parent::save($con); 15 16 if ($this->getsfGuardUser())17 {18 $this->getsfGuardUser()->updateKarma(true);19 }20 15 21 16 // Create "person recommended" event object trunk/lib/model/Event.php
r48 r49 129 129 if (!$this->getType()) 130 130 { 131 sfContext::getInstance()->getLogger()->err('No type specified for event');131 //sfContext::getInstance()->getLogger()->err('No type specified for event'); 132 132 return 0; 133 133 } … … 139 139 140 140 $this->setOccuredAt(time()); 141 $context = @sfContext::getInstance();141 /*$context = @sfContext::getInstance(); 142 142 if (!is_null($context)) 143 143 { … … 152 152 } 153 153 } 154 } 154 }*/ 155 155 return parent::save($con); 156 156 } trunk/lib/model/Job.php
r48 r49 73 73 } 74 74 75 public function delete($con = null)76 {77 $delete = parent::delete($con);78 if ($this->getsfGuardUser())79 {80 $this->getsfGuardUser()->updateKarma(true);81 }82 return $delete;83 }84 85 75 public function save($con = null) 86 76 { … … 89 79 $affectedRows = parent::save($con); 90 80 91 if ($affectedRows > 0 && $this->getsfGuardUser())92 {93 $this->getsfGuardUser()->updateKarma(true);94 }95 96 81 if ($this->getCompanyId() && !$this->getCompany()->getAllowContact()) 97 82 { 98 83 $this->getCompany()->setAllowContact(true); 99 84 $this->getCompany()->save(); 100 sfContext::getInstance()->getLogger()->info(sprintf('Company "%s" has now email contact enabled',101 $this->getCompany()->getName()));85 //sfContext::getInstance()->getLogger()->info(sprintf('Company "%s" has now email contact enabled', 86 // $this->getCompany()->getName())); 102 87 } 103 88 trunk/lib/model/PluginsfGuardUser.php
r48 r49 700 700 701 701 /** 702 * Calculates new karma value and possibly saves the record703 *704 * @param boolean $save705 * @param string $con706 * @return mixed707 */708 public function updateKarma($save = false, $con = null)709 {710 $karma_points = 0;711 712 // Has an avatar713 if ($this->getAvatarPath())714 {715 $karma_points += sfConfig::get('app_karma_avatar');716 }717 718 // Has an address719 if ($this->hasAddress())720 {721 $karma_points += sfConfig::get('app_karma_address');722 }723 724 // Has a trac username725 if ($this->getTracUsername())726 {727 $karma_points += sfConfig::get('app_karma_trac_username');728 }729 730 // Applications submitted731 $app_submitted = $this->countApplications();732 if ($app_submitted > 0)733 {734 $karma_points += $app_submitted * sfConfig::get('app_karma_app_submitted');735 }736 737 // Applications related738 $app_related = $this->countApplicationDevelopers();739 if ($app_related > 0)740 {741 $karma_points += $app_related * sfConfig::get('app_karma_app_related');742 }743 744 // Jobs submitted745 $job_submitted = $this->countJobs();746 if ($job_submitted > 0)747 {748 $karma_points += $job_submitted * sfConfig::get('app_karma_job_submitted');749 }750 751 // Companies submitted752 $companies_submitted = $this->countCompanys();753 if ($companies_submitted > 0)754 {755 $karma_points += $companies_submitted * sfConfig::get('app_karma_companies_submitted');756 }757 758 // Recommendations sent759 $recommendations_sent = $this->countRecommendationsRelatedByRecommenderId();760 if ($recommendations_sent > 0)761 {762 $karma_points += $recommendations_sent * sfConfig::get('app_karma_recommendation_sent');763 }764 765 // Recommendations received766 $recommendations_received = $this->countRecommendationsRelatedByRecommendedId();767 if ($recommendations_received > 0)768 {769 $karma_points += $recommendations_received * sfConfig::get('app_karma_recommendation_get');770 }771 772 parent::setKarma($karma_points);773 sfContext::getInstance()->getLogger()->info(sprintf('karmadebug: %s\'s karma updated to %d',774 $this->getUsername(),775 $karma_points));776 $affectedRows = false;777 if (true === $save)778 {779 $this->justKarma = true;780 $affectedRows = $this->save($con);781 $this->justKarma = false;782 }783 return $affectedRows;784 }785 786 /**787 702 * Saves current user record 788 703 * trunk/lib/model/Recommendation.php
r2 r49 8 8 { 9 9 10 public function delete($con = null) 11 { 12 $delete = parent::delete($con); 13 if ($this->getsfGuardUserRelatedByRecommenderId()) 14 { 15 $this->getsfGuardUserRelatedByRecommenderId()->updateKarma(true); 16 } 17 if ($this->getsfGuardUserRelatedByRecommendedId()) 18 { 19 $this->getsfGuardUserRelatedByRecommendedId()->updateKarma(true); 20 } 21 return $delete; 22 } 23 10 /** 11 * Retrieves recommended user 12 * 13 * @return sfGuardUser 14 */ 24 15 public function getRecommended() 25 16 { … … 27 18 } 28 19 20 /** 21 * Retrieves recommended user display name 22 * 23 * @return string 24 */ 29 25 public function getRecommendedName() 30 26 { … … 32 28 } 33 29 30 /** 31 * Retrieves recommender 32 * 33 * @return sfGuardUser 34 */ 34 35 public function getRecommender() 35 36 { … … 37 38 } 38 39 40 /** 41 * Retrieves recommender display name 42 * 43 * @return string 44 */ 39 45 public function getRecommenderName() 40 46 { … … 42 48 } 43 49 50 /** 51 * Saves object 52 * 53 * @return int 54 */ 44 55 public function save($con = null) 45 56 { … … 47 58 $modified = $this->isModified(); 48 59 $save = parent::save($con); 49 50 if ($this->getsfGuardUserRelatedByRecommenderId())51 {52 $this->getsfGuardUserRelatedByRecommenderId()->updateKarma(true);53 }54 55 if ($this->getsfGuardUserRelatedByRecommendedId())56 {57 $this->getsfGuardUserRelatedByRecommendedId()->updateKarma(true);58 }59 60 60 61 // Create "person recommended" event object
