Example #1
0
 /**
  * Creates the user and rights group tables, adds a user into both as
  * admin, then adds that user to the session.
  *
  * @since 2.0
  */
 protected function setUp()
 {
     $_POST = array();
     $_GET = array();
     $_COOKIE = array();
     $config = ConfigProvider::getInstance();
     $config->set('session.provider.name', 'Alpha\\Util\\Http\\Session\\SessionProviderArray');
     $action = new ActionLog();
     $action->rebuildTable();
     $person = new Person();
     $person->rebuildTable();
     $rights = new Rights();
     $rights->rebuildTable();
     $rights->set('name', 'Standard');
     $rights->save();
     $rights = new Rights();
     $rights->set('name', 'Admin');
     $rights->save();
     $person = $this->createPersonObject('loggedin');
     $person->save();
     if (!$person->inGroup('Admin')) {
         $adminGroup = new Rights();
         $adminGroup->loadByAttribute('name', 'Admin');
         $lookup = $adminGroup->getMembers()->getLookup();
         $lookup->setValue(array($person->getID(), $adminGroup->getID()));
         $lookup->save();
     }
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     $session->set('currentUser', $person);
 }
 /**
  * Set up tests.
  *
  * @since 2.0
  */
 protected function setUp()
 {
     $config = ConfigProvider::getInstance();
     $config->set('session.provider.name', 'Alpha\\Util\\Http\\Session\\SessionProviderArray');
     $action = new ActionLog();
     $action->rebuildTable();
     $tag = new Tag();
     $tag->rebuildTable();
     $denum = new DEnum();
     $denum->rebuildTable();
     $item = new DEnumItem();
     $item->rebuildTable();
     // create a default article DEnum category
     $denum = new DEnum('Alpha\\Model\\Article::section');
     $item->set('value', 'Main');
     $item->set('DEnumID', $denum->getID());
     $item->save();
     $article = new Article();
     $article->rebuildTable();
     $articleVote = new ArticleVote();
     $articleVote->rebuildTable();
     $articleComment = new ArticleComment();
     $articleComment->rebuildTable();
     $person = new Person();
     $person->rebuildTable();
     $rights = new Rights();
     $rights->rebuildTable();
     $rights->set('name', 'Standard');
     $rights->save();
     $rights = new Rights();
     $rights->set('name', 'Admin');
     $rights->save();
 }
Example #3
0
 /**
  * Log an action carried out by a person to the ActionLog table.
  *
  * @param string $message
  *
  * @since 1.1
  */
 public function action($message)
 {
     $config = ConfigProvider::getInstance();
     $sessionProvider = $config->get('session.provider.name');
     $session = SessionProviderFactory::getInstance($sessionProvider);
     if ($session->get('currentUser') != null) {
         $action = new ActionLog();
         $action->set('client', $this->request->getUserAgent());
         $action->set('IP', $this->request->getIP());
         $action->set('message', $message);
         $action->save();
     }
 }