/**
  * Recalculate user and content reputation every hour
  * Only do this in spaces where reputation module is enabled
  *
  * @param $event
  * @throws CException
  */
 public static function onCronHourlyRun($event)
 {
     Yii::import('application.modules.reputation.models.*');
     $cron = $event->sender;
     foreach (Space::model()->findAll() as $space) {
         if ($space->isModuleEnabled('reputation')) {
             $cronJobEnabled = SpaceSetting::Get($space->id, 'cron_job', 'reputation', ReputationBase::DEFAULT_CRON_JOB);
             if ($cronJobEnabled) {
                 print "- Recalculating reputation for space: {$space->id}  {$space->name}\n";
                 ReputationUser::model()->updateUserReputation($space, true);
                 ReputationContent::model()->updateContentReputation($space, true);
             }
         }
     }
 }
 public function testSet()
 {
     SpaceSetting::Set(1, 'globalSetting', 'xyz2');
     $this->assertEquals(SpaceSetting::Get(1, 'globalSetting', 'core'), 'xyz2');
 }
 /**
  * Initialize configuration view
  * Allows the user to set a bunch of parameters for reputation settings inside this space
  *
  * @throws CException
  */
 public function actionConfiguration()
 {
     Yii::import('reputation.forms.*');
     $form = new ConfigureForm();
     $space = Yii::app()->getController()->getSpace();
     $spaceId = $space->id;
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'configure-form') {
         echo CActiveForm::validate($form);
         Yii::app()->end();
     }
     if (isset($_POST['ConfigureForm'])) {
         $_POST['ConfigureForm'] = Yii::app()->input->stripClean($_POST['ConfigureForm']);
         $form->attributes = $_POST['ConfigureForm'];
         if ($form->validate()) {
             $form->functions = SpaceSetting::Set($spaceId, 'functions', $form->functions, 'reputation');
             $form->logarithmBase = SpaceSetting::Set($spaceId, 'logarithm_base', $form->logarithmBase, 'reputation');
             $form->create_content = SpaceSetting::Set($spaceId, 'create_content', $form->create_content, 'reputation');
             $form->smb_likes_content = SpaceSetting::Set($spaceId, 'smb_likes_content', $form->smb_likes_content, 'reputation');
             $form->smb_favorites_content = SpaceSetting::Set($spaceId, 'smb_favorites_content', $form->smb_favorites_content, 'reputation');
             $form->smb_comments_content = SpaceSetting::Set($spaceId, 'smb_comments_content', $form->smb_comments_content, 'reputation');
             $form->daily_limit = SpaceSetting::Set($spaceId, 'daily_limit', $form->daily_limit, 'reputation');
             $form->decrease_weighting = SpaceSetting::Set($spaceId, 'decrease_weighting', $form->decrease_weighting, 'reputation');
             $form->cron_job = SpaceSetting::Set($spaceId, 'cron_job', $form->cron_job, 'reputation');
             $form->lambda_short = SpaceSetting::Set($spaceId, 'lambda_short', $form->lambda_short, 'reputation');
             $form->lambda_long = SpaceSetting::Set($spaceId, 'lambda_long', $form->lambda_long, 'reputation');
             ReputationUser::model()->updateUserReputation($space, true);
             ReputationContent::model()->updateContentReputation($space, true);
             $this->redirect($this->createContainerUrl('//reputation/adminReputation/configuration'));
         }
     } else {
         $form->functions = SpaceSetting::Get($spaceId, 'functions', 'reputation', ReputationBase::DEFAULT_FUNCTION);
         $form->logarithmBase = SpaceSetting::Get($spaceId, 'logarithm_base', 'reputation', ReputationBase::DEFAULT_LOGARITHM_BASE);
         $form->create_content = SpaceSetting::Get($spaceId, 'create_content', 'reputation', ReputationBase::DEFAULT_CREATE_CONTENT);
         $form->smb_likes_content = SpaceSetting::Get($spaceId, 'smb_likes_content', 'reputation', ReputationBase::DEFAULT_SMB_LIKES_CONTENT);
         $form->smb_favorites_content = SpaceSetting::Get($spaceId, 'smb_favorites_content', 'reputation', ReputationBase::DEFAULT_SMB_FAVORITES_CONTENT);
         $form->smb_comments_content = SpaceSetting::Get($spaceId, 'smb_comments_content', 'reputation', ReputationBase::DEFAULT_SMB_COMMENTS_CONTENT);
         $form->daily_limit = SpaceSetting::Get($spaceId, 'daily_limit', 'reputation', ReputationBase::DEFAULT_DAILY_LIMIT);
         $form->decrease_weighting = SpaceSetting::Get($spaceId, 'decrease_weighting', 'reputation', ReputationBase::DEFAULT_DECREASE_WEIGHTING);
         $form->cron_job = SpaceSetting::Get($spaceId, 'cron_job', 'reputation', ReputationBase::DEFAULT_CRON_JOB);
         $form->lambda_short = SpaceSetting::Get($spaceId, 'lambda_short', 'reputation', ReputationBase::DEFAULT_LAMBDA_SHORT);
         $form->lambda_long = SpaceSetting::Get($spaceId, 'lambda_long', 'reputation', ReputationBase::DEFAULT_LAMBDA_LONG);
     }
     $this->render('adminReputationSettings', array('model' => $form, 'space' => $space));
 }
 /**
  * Get an SpaceSetting Value
  * 
  * @param String $name of setting
  * @param String $moduleId of setting
  * @param String $default value when no setting exists
  * @return String
  */
 public function getSetting($name, $moduleId = "core", $default = "")
 {
     return SpaceSetting::Get($this->getOwner()->id, $name, $moduleId, $default);
 }
 /**
  * Return an array with all space settings
  * @param $space
  * @return array
  */
 protected function getSpaceSettings($space)
 {
     $function = SpaceSetting::Get($space->id, 'functions', 'reputation', ReputationBase::DEFAULT_FUNCTION);
     $logarithmBase = SpaceSetting::Get($space->id, 'logarithm_base', 'reputation', ReputationBase::DEFAULT_LOGARITHM_BASE);
     $create_content = SpaceSetting::Get($space->id, 'create_content', 'reputation', ReputationBase::DEFAULT_CREATE_CONTENT);
     $smb_likes_content = SpaceSetting::Get($space->id, 'smb_likes_content', 'reputation', ReputationBase::DEFAULT_SMB_LIKES_CONTENT);
     $smb_favorites_content = SpaceSetting::Get($space->id, 'smb_favorites_content', 'reputation', ReputationBase::DEFAULT_SMB_FAVORITES_CONTENT);
     $smb_comments_content = SpaceSetting::Get($space->id, 'smb_comments_content', 'reputation', ReputationBase::DEFAULT_SMB_COMMENTS_CONTENT);
     $daily_limit = SpaceSetting::Get($space->id, 'daily_limit', 'reputation', ReputationBase::DEFAULT_DAILY_LIMIT);
     $decrease_weighting = SpaceSetting::Get($space->id, 'decrease_weighting', 'reputation', ReputationBase::DEFAULT_DECREASE_WEIGHTING);
     $lambda_short = SpaceSetting::Get($space->id, 'lambda_short', 'reputation', ReputationBase::DEFAULT_LAMBDA_SHORT);
     $lambda_long = SpaceSetting::Get($space->id, 'lambda_long', 'reputation', ReputationBase::DEFAULT_LAMBDA_LONG);
     $ranking_new_period = SpaceSetting::Get($space->id, 'ranking_new_period', 'reputation', ReputationBase::DEFAULT_RANKING_NEW_PERIOD);
     $spaceSettings = array($function, $logarithmBase, $create_content, $smb_likes_content, $smb_favorites_content, $smb_comments_content, $daily_limit, $decrease_weighting, $lambda_short, $lambda_long, $ranking_new_period);
     return $spaceSettings;
 }
                <?php 
    $space = $reputation->space;
    if ($space == null || $reputation->visibility == 0 && Yii::app()->user->id != $reputation->user_id) {
        continue;
    }
    ?>

                <?php 
    // Hidden field to get users on this page
    echo CHtml::hiddenField("reputationUsers[" . $reputation->space_id . "]", $reputation->space_id);
    // Hidden field to get users on this page
    echo CHtml::hiddenField('reputationUser_' . $reputation->space_id . "[placeholder]", 1);
    ?>

                <?php 
    $function = SpaceSetting::Get($space->id, 'functions', 'reputation', ReputationUser::DEFAULT_FUNCTION);
    ?>

                <tr>
                    <td width="28px" style="vertical-align: middle">
                        <a href="<?php 
    echo $user->getUrl();
    ?>
">

                            <img class="media-object img-rounded"
                                 src="<?php 
    echo $space->getProfileImage()->getUrl();
    ?>
" width="24"
                                 height="24" alt="24x24" data-src="holder.js/24x24"