<commit_before><?php
class userObjectFilter extends sfFilter
{
  public function execute($filterChain)
  {
    // get the cool stuff
    /** @var sfContext **/
    $context    = $this->getContext();
    /** @var sfController **/
    $controller = $context->getController();
    /** @var sfUser **/
    $user       = $context->getUser();
    /** @var sfRequest **/
    $request    = $context->getRequest();

    if ($request->getCookie('nsdl_registry'))
    {
      // sign in
      $user->setAuthenticated(true);
    }

    if (!$user->isAuthenticated())
    {
      //this will make sure we are really signed out
      $user->signOut();
      // we bail
      $filterChain->execute();
    }

    $key = false;

    // get the current action instance
    /** @var sfActionStackEntry **/
    $actionEntry    = $controller->getActionStack()->getLastEntry();
    $actionInstance = $actionEntry->getActionInstance();
    $action = $request->getParameter('action');

    //get the object security information
    $securityArray = $actionInstance->getSecurityConfiguration();
    $objectCredArray = myUser::parseSecurity($securityArray, $action);

    //The module is either the current module or the parent module.
    if (isset($objectCredArray['module']))
    {
      $module = $objectCredArray['module'];
    }
    else
    {
      $module = $context->getModuleName();
    }

    //object credentials are stored in
    //  $user->getAttribute($module,'','object_credentials')
    //the key for the object credentials comes from:
    //  request param
    //  the key of a stored parent object (need to know the parent object)

    //so next we need to know the key...

    //big hack because I'm frustrated:
    if ('import' == $module) {
      if ($request->getParameter('vocabulary_id')) {
        $key = $request->getParameter('vocabulary_id');
        $module = 'vocabulary';
      }
      if ($request->getParameter('schema_id')) {
        $key = $request->getParameter('schema_id');
        $module = 'schema';
      }
    }
    //Does the request parameter exist?
    if (isset($objectCredArray['request_param']))
    {
      $key = $request->getParameter($objectCredArray['request_param'],'');
      //get the correct id to check against, but only if we haven't already checked it in this request
    }
    //use the default only if we're using the current request
    elseif ($module == $context->getModuleName())
    {
      //we do the default
      $key = $request->getParameter('id');
    }

    //still no key?
    //ok, so this is definitely a hack...
    if (!$key && (('edit' == $action || 'show' == $action || 'list' == $action) || $module != $context->getModuleName()))
    {
      if ('schema' == $module)
      {
        $schema = myActionTools::findCurrentSchema();
        if ($schema)
        {
          $key = $schema->getId();
        }
      }

      if ('vocabulary' == $module)
      {
        $vocabulary = myActionTools::findCurrentVocabulary();
        if ($vocabulary)
        {
          $key = $vocabulary->getId();
        }
      }

      if ('agent' == $module)
      {
        $agent = myActionTools::findCurrentAgent();
        if ($agent)
        {
          $key = $agent->getId();
        }
      }
    }

    if ($key)
    {
      $user->buildModCredentials($key, $module);
      if ('vocabulary' == $module)
      {
        $vocabulary = myActionTools::findCurrentVocabulary();
        if ($vocabulary)
        {
          $agentId = $vocabulary->getAgentId();
          $user->buildModCredentials($agentId, 'agent', true);
        }
      }
    }
    //skip re-setting the modcredentials if the action == create
    else
    {
      $this->setdefaultCred($user);
    }

    // Execute next filter
    $filterChain->execute();
  }

  private function setdefaultCred($user)
  {
    $user->modCredentials = $user->listCredentials();
    $cred = $user->getTmpCredential();
    if ($cred)
    {
      $user->modCredentials[] = $cred;
    }
  }
}

<commit_msg>i don't wanna cookie (yet)<commit_after><?php
class userObjectFilter extends sfFilter
{
  public function execute($filterChain)
  {
    // get the cool stuff
    /** @var sfContext **/
    $context    = $this->getContext();
    /** @var sfController **/
    $controller = $context->getController();
    /** @var sfUser **/
    $user       = $context->getUser();
    /** @var sfRequest **/
    $request    = $context->getRequest();

    if ($request->getCookie('MyWebSite'))
    {
      // sign in
      $user->setAuthenticated(true);
    }

    if (!$user->isAuthenticated())
    {
      //this will make sure we are really signed out
      $user->signOut();
      // we bail
      $filterChain->execute();
    }

    $key = false;

    // get the current action instance
    /** @var sfActionStackEntry **/
    $actionEntry    = $controller->getActionStack()->getLastEntry();
    $actionInstance = $actionEntry->getActionInstance();
    $action = $request->getParameter('action');

    //get the object security information
    $securityArray = $actionInstance->getSecurityConfiguration();
    $objectCredArray = myUser::parseSecurity($securityArray, $action);

    //The module is either the current module or the parent module.
    if (isset($objectCredArray['module']))
    {
      $module = $objectCredArray['module'];
    }
    else
    {
      $module = $context->getModuleName();
    }

    //object credentials are stored in
    //  $user->getAttribute($module,'','object_credentials')
    //the key for the object credentials comes from:
    //  request param
    //  the key of a stored parent object (need to know the parent object)

    //so next we need to know the key...

    //big hack because I'm frustrated:
    if ('import' == $module) {
      if ($request->getParameter('vocabulary_id')) {
        $key = $request->getParameter('vocabulary_id');
        $module = 'vocabulary';
      }
      if ($request->getParameter('schema_id')) {
        $key = $request->getParameter('schema_id');
        $module = 'schema';
      }
    }
    //Does the request parameter exist?
    if (isset($objectCredArray['request_param']))
    {
      $key = $request->getParameter($objectCredArray['request_param'],'');
      //get the correct id to check against, but only if we haven't already checked it in this request
    }
    //use the default only if we're using the current request
    elseif ($module == $context->getModuleName())
    {
      //we do the default
      $key = $request->getParameter('id');
    }

    //still no key?
    //ok, so this is definitely a hack...
    if (!$key && (('edit' == $action || 'show' == $action || 'list' == $action) || $module != $context->getModuleName()))
    {
      if ('schema' == $module)
      {
        $schema = myActionTools::findCurrentSchema();
        if ($schema)
        {
          $key = $schema->getId();
        }
      }

      if ('vocabulary' == $module)
      {
        $vocabulary = myActionTools::findCurrentVocabulary();
        if ($vocabulary)
        {
          $key = $vocabulary->getId();
        }
      }

      if ('agent' == $module)
      {
        $agent = myActionTools::findCurrentAgent();
        if ($agent)
        {
          $key = $agent->getId();
        }
      }
    }

    if ($key)
    {
      $user->buildModCredentials($key, $module);
      if ('vocabulary' == $module)
      {
        $vocabulary = myActionTools::findCurrentVocabulary();
        if ($vocabulary)
        {
          $agentId = $vocabulary->getAgentId();
          $user->buildModCredentials($agentId, 'agent', true);
        }
      }
    }
    //skip re-setting the modcredentials if the action == create
    else
    {
      $this->setdefaultCred($user);
    }

    // Execute next filter
    $filterChain->execute();
  }

  private function setdefaultCred($user)
  {
    $user->modCredentials = $user->listCredentials();
    $cred = $user->getTmpCredential();
    if ($cred)
    {
      $user->modCredentials[] = $cred;
    }
  }
}


{'fraction_non_alphanumeric': 0.15473960284750843, 'fraction_numerical': 0.0, 'mean_word_length': 2.32972972972973, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1694017', 'n_tokens_mistral': 2357, 'n_tokens_neox': 2342, 'n_words': 569}