Index: /unk/test/unit/KarmaTest.php =================================================================== --- /trunk/test/unit/KarmaTest.php (revision 2) +++ (revision ) @@ -1,56 +1,0 @@ -initialize(); -$con = Propel::getConnection(); - -$niko = sfGuardUserPeer::retrieveByUsername('niko'); - -$t = new lime_test(6, new lime_output_color()); -$t->isa_ok($niko, 'sfGuardUser', 'User is an instance of sfGuardUser'); -$t->is($niko->getUsername(), 'niko', 'getUsermame() retrieves correct username'); -$karma = $niko->getKarma(); -$t->diag(sprintf('Actual karma is %d', $karma)); - -sfLucenePropelBehavior::setLock(true); - -$job1 = new Job(); -$job1->setTitle('Test job #1'); -$job1->setContactId($niko->getId()); -$job1->save(); - -$niko = sfGuardUserPeer::retrieveByUsername('niko'); -$t->diag(sprintf('Adding a job, new karma is %d', $niko->getKarma())); -$karma += sfConfig::get('app_karma_job_submitted'); -$t->is($niko->getKarma(), $karma, 'Adding a job increase karma correctly'); - -$job1->delete(); -$niko = sfGuardUserPeer::retrieveByUsername('niko'); -$t->diag(sprintf('Deleting a job, new karma is %d', $niko->getKarma())); -$karma -= sfConfig::get('app_karma_job_submitted'); -$t->is($niko->getKarma(), $karma, 'Deleting a job decrease karma correctly'); - -$company1 = new Company(); -$company1->setName('Company #1'); -$company1->setEmail('email@domain.tld'); -$company1->setSubmitterId($niko->getId()); -$company1->save(); - -$niko = sfGuardUserPeer::retrieveByUsername('niko'); -$t->diag(sprintf('Adding a company, new karma is %d', $niko->getKarma())); -$karma += sfConfig::get('app_karma_companies_submitted'); -$t->is($niko->getKarma(), $karma, 'Adding a company increase karma correctly'); - -$company1->delete(); -$niko = sfGuardUserPeer::retrieveByUsername('niko'); -$t->diag(sprintf('Deleting a company, new karma is %d', $niko->getKarma())); -$karma -= sfConfig::get('app_karma_companies_submitted'); -$t->is($niko->getKarma(), $karma, 'Deleting a company decrease karma correctly'); - -sfLucenePropelBehavior::setLock(false); Index: /trunk/apps/main/config/factories.yml =================================================================== --- /trunk/apps/main/config/factories.yml (revision 48) +++ /trunk/apps/main/config/factories.yml (revision 49) @@ -43,2 +43,6 @@ session_cookie_domain: . session_cookie_lifetime: + user: + class: myUser + param: + timeout: Index: /trunk/apps/main/config/settings.yml =================================================================== --- /trunk/apps/main/config/settings.yml (revision 48) +++ /trunk/apps/main/config/settings.yml (revision 49) @@ -4,5 +4,4 @@ no_script_name: on cache: on - timeout: 180000000 dev: @@ -13,5 +12,4 @@ no_script_name: off etag: off - timeout: 86400 search: @@ -22,5 +20,4 @@ no_script_name: off etag: off - timeout: 86400 staging: @@ -31,5 +28,4 @@ no_script_name: off etag: off - timeout: 86400 test: Index: /trunk/lib/model/CompanyPerson.php =================================================================== --- /trunk/lib/model/CompanyPerson.php (revision 2) +++ /trunk/lib/model/CompanyPerson.php (revision 49) @@ -13,9 +13,4 @@ $modified = $this->isModified(); $save = parent::save($con); - - if ($this->getsfGuardUser()) - { - $this->getsfGuardUser()->updateKarma(true); - } // Create "person recommended" event object Index: /trunk/lib/model/Application.php =================================================================== --- /trunk/lib/model/Application.php (revision 48) +++ /trunk/lib/model/Application.php (revision 49) @@ -242,8 +242,4 @@ $this->save(); $delete = parent::delete($con); - if ($this->getsfGuardUser()) - { - $this->getsfGuardUser()->updateKarma(true); - } return $delete; } @@ -260,10 +256,4 @@ $modified = $this->isModified(); $save = parent::save($con); - - // Update user karma - if ($this->getsfGuardUser()) - { - $this->getsfGuardUser()->updateKarma(true); - } // Create "app created" event object Index: /trunk/lib/model/Recommendation.php =================================================================== --- /trunk/lib/model/Recommendation.php (revision 2) +++ /trunk/lib/model/Recommendation.php (revision 49) @@ -8,18 +8,9 @@ { - public function delete($con = null) - { - $delete = parent::delete($con); - if ($this->getsfGuardUserRelatedByRecommenderId()) - { - $this->getsfGuardUserRelatedByRecommenderId()->updateKarma(true); - } - if ($this->getsfGuardUserRelatedByRecommendedId()) - { - $this->getsfGuardUserRelatedByRecommendedId()->updateKarma(true); - } - return $delete; - } - + /** + * Retrieves recommended user + * + * @return sfGuardUser + */ public function getRecommended() { @@ -27,4 +18,9 @@ } + /** + * Retrieves recommended user display name + * + * @return string + */ public function getRecommendedName() { @@ -32,4 +28,9 @@ } + /** + * Retrieves recommender + * + * @return sfGuardUser + */ public function getRecommender() { @@ -37,4 +38,9 @@ } + /** + * Retrieves recommender display name + * + * @return string + */ public function getRecommenderName() { @@ -42,4 +48,9 @@ } + /** + * Saves object + * + * @return int + */ public function save($con = null) { @@ -47,14 +58,4 @@ $modified = $this->isModified(); $save = parent::save($con); - - if ($this->getsfGuardUserRelatedByRecommenderId()) - { - $this->getsfGuardUserRelatedByRecommenderId()->updateKarma(true); - } - - if ($this->getsfGuardUserRelatedByRecommendedId()) - { - $this->getsfGuardUserRelatedByRecommendedId()->updateKarma(true); - } // Create "person recommended" event object Index: /trunk/lib/model/Company.php =================================================================== --- /trunk/lib/model/Company.php (revision 48) +++ /trunk/lib/model/Company.php (revision 49) @@ -182,20 +182,4 @@ /** - * Deletes Company instance - * - * @param Connection $con - * @return int - */ - public function delete($con = null) - { - $delete = parent::delete($con); - if ($this->getsfGuardUser()) - { - $this->getsfGuardUser()->updateKarma(true); - } - return $delete; - } - - /** * Saves Company instance * @@ -208,9 +192,4 @@ $modified = $this->isModified(); $affectedRows = parent::save($con); - - if ($affectedRows > 0 && $this->getsfGuardUser()) - { - $this->getsfGuardUser()->updateKarma(true); - } // Create "company created" event object Index: /trunk/lib/model/PluginsfGuardUser.php =================================================================== --- /trunk/lib/model/PluginsfGuardUser.php (revision 48) +++ /trunk/lib/model/PluginsfGuardUser.php (revision 49) @@ -700,89 +700,4 @@ /** - * Calculates new karma value and possibly saves the record - * - * @param boolean $save - * @param string $con - * @return mixed - */ - public function updateKarma($save = false, $con = null) - { - $karma_points = 0; - - // Has an avatar - if ($this->getAvatarPath()) - { - $karma_points += sfConfig::get('app_karma_avatar'); - } - - // Has an address - if ($this->hasAddress()) - { - $karma_points += sfConfig::get('app_karma_address'); - } - - // Has a trac username - if ($this->getTracUsername()) - { - $karma_points += sfConfig::get('app_karma_trac_username'); - } - - // Applications submitted - $app_submitted = $this->countApplications(); - if ($app_submitted > 0) - { - $karma_points += $app_submitted * sfConfig::get('app_karma_app_submitted'); - } - - // Applications related - $app_related = $this->countApplicationDevelopers(); - if ($app_related > 0) - { - $karma_points += $app_related * sfConfig::get('app_karma_app_related'); - } - - // Jobs submitted - $job_submitted = $this->countJobs(); - if ($job_submitted > 0) - { - $karma_points += $job_submitted * sfConfig::get('app_karma_job_submitted'); - } - - // Companies submitted - $companies_submitted = $this->countCompanys(); - if ($companies_submitted > 0) - { - $karma_points += $companies_submitted * sfConfig::get('app_karma_companies_submitted'); - } - - // Recommendations sent - $recommendations_sent = $this->countRecommendationsRelatedByRecommenderId(); - if ($recommendations_sent > 0) - { - $karma_points += $recommendations_sent * sfConfig::get('app_karma_recommendation_sent'); - } - - // Recommendations received - $recommendations_received = $this->countRecommendationsRelatedByRecommendedId(); - if ($recommendations_received > 0) - { - $karma_points += $recommendations_received * sfConfig::get('app_karma_recommendation_get'); - } - - parent::setKarma($karma_points); - sfContext::getInstance()->getLogger()->info(sprintf('karmadebug: %s\'s karma updated to %d', - $this->getUsername(), - $karma_points)); - $affectedRows = false; - if (true === $save) - { - $this->justKarma = true; - $affectedRows = $this->save($con); - $this->justKarma = false; - } - return $affectedRows; - } - - /** * Saves current user record * Index: /trunk/lib/model/ApplicationDeveloper.php =================================================================== --- /trunk/lib/model/ApplicationDeveloper.php (revision 2) +++ /trunk/lib/model/ApplicationDeveloper.php (revision 49) @@ -8,14 +8,4 @@ { - public function delete($con = null) - { - $delete = parent::delete($con); - if ($this->getsfGuardUser()) - { - $this->getsfGuardUser()->updateKarma(true); - } - return $delete; - } - public function save($con = null) { @@ -23,9 +13,4 @@ $modified = $this->isModified(); $save = parent::save($con); - - if ($this->getsfGuardUser()) - { - $this->getsfGuardUser()->updateKarma(true); - } // Create "person recommended" event object Index: /trunk/lib/model/Job.php =================================================================== --- /trunk/lib/model/Job.php (revision 48) +++ /trunk/lib/model/Job.php (revision 49) @@ -73,14 +73,4 @@ } - public function delete($con = null) - { - $delete = parent::delete($con); - if ($this->getsfGuardUser()) - { - $this->getsfGuardUser()->updateKarma(true); - } - return $delete; - } - public function save($con = null) { @@ -89,15 +79,10 @@ $affectedRows = parent::save($con); - if ($affectedRows > 0 && $this->getsfGuardUser()) - { - $this->getsfGuardUser()->updateKarma(true); - } - if ($this->getCompanyId() && !$this->getCompany()->getAllowContact()) { $this->getCompany()->setAllowContact(true); $this->getCompany()->save(); - sfContext::getInstance()->getLogger()->info(sprintf('Company "%s" has now email contact enabled', - $this->getCompany()->getName())); + //sfContext::getInstance()->getLogger()->info(sprintf('Company "%s" has now email contact enabled', + // $this->getCompany()->getName())); } Index: /trunk/lib/model/Event.php =================================================================== --- /trunk/lib/model/Event.php (revision 48) +++ /trunk/lib/model/Event.php (revision 49) @@ -129,5 +129,5 @@ if (!$this->getType()) { - sfContext::getInstance()->getLogger()->err('No type specified for event'); + //sfContext::getInstance()->getLogger()->err('No type specified for event'); return 0; } @@ -139,5 +139,5 @@ $this->setOccuredAt(time()); - $context = @sfContext::getInstance(); + /*$context = @sfContext::getInstance(); if (!is_null($context)) { @@ -152,5 +152,5 @@ } } - } + }*/ return parent::save($con); }