Exemplo n.º 1
0
 function init()
 {
     $this->_configure();
     $this->display = '';
     if ($this->use_sheet_characters && !$this->allow_any_character && $_SESSION['user_id'] <= 0) {
         return $this->display .= VoodooError::displayError('No permission');
     }
     require_once CLASSES . 'TableFactory.php';
     $hash = isset($_GET['hash']) ? $_GET['hash'] : false;
     $limit = isset($this->args[0]) ? $this->args[0] : 12;
     if (!empty($_POST['name']) || !empty($_POST['character'])) {
         if (empty($_POST['action']) || empty($_POST['number'])) {
             $this->display .= VoodooError::displayError('Character, Action and Dice Pool are required fields');
         } else {
             $postvars = array('character' => $_POST['name'] ? $_POST['name'] : $_POST['character'], 'action' => $_POST['action']);
             $sgdr = new SheetgenDiceRoller($this->formatter->db, $postvars);
             $difficulty = $this->variable_difficulty && isset($_POST['difficulty']) ? $_POST['difficulty'] : $this->default_difficulty;
             if (!$sgdr->roll((int) $_POST['number'], $_POST['type'], isset($_POST['substract']), $difficulty)) {
                 $this->display .= VoodooError::displayError('Incorrect usage of the Diceroller');
             } else {
                 header(sprintf('Location: http://%s%s/wiki/%s?hash=%s', $_SERVER['SERVER_NAME'], PATH_TO_DOCROOT, $this->formatter->action, $sgdr->hash));
                 exit;
             }
         }
     }
     $sgdr = new SheetgenDiceRoller($this->formatter->db);
     $t =& VoodooTemplate::getInstance();
     $old = $t->getDir();
     $t->setDir(SHEETGEN_TEMPLATES);
     if (!$hash) {
         $chars = false;
         $args = array('prepath' => PATH_TO_DOCROOT, 'page' => $this->formatter->action);
         $args['name'] = isset($_POST['name']) ? $_POST['name'] : '';
         $args['action'] = isset($_POST['action']) ? $_POST['action'] : '';
         $args['number'] = isset($_POST['number']) ? $_POST['number'] : '';
         if ($this->use_sheet_characters) {
             $chars = $sgdr->getCharacters($_SESSION['user_id']);
             if (sizeof($chars) == 0 && !$this->allow_any_character) {
                 $this->display .= VoodooError::displayError('No characters available, please create one first.');
                 return;
             }
         }
         $chars && ($args['use_sheet_characters'] = $chars);
         if ($this->allow_any_character && !($this->mutually_exclusive && $chars)) {
             $args['allow_any_character'] = $this->allow_any_character;
         }
         $args['variable_difficulty'] = $this->variable_difficulty;
         $args['difficulty'] = isset($_POST['difficulty']) ? $_POST['difficulty'] : $this->default_difficulty;
         $this->display .= $t->parse('diceroller', $args);
     }
     $q = $sgdr->getOverview($limit, $hash);
     require_once CLASSES . 'TableFactory.php';
     $tf = new TableFactory($q);
     $tf->setHiddenField(array('User', 'ROLL_ID', 'number', 'successes', 'roll_character', 'action', 'rolls', 'rerolls', 'difficulty', 'substract'));
     $tf->setValueProcessor(array('Result', 'Link', 'Roll Description'), array($this, 'tfValueProcessor'));
     $this->display .= $tf->getXHTMLTable('list report diceroller');
     $this->display .= sprintf('<a href="%s/wiki/%s">Refresh</a>', PATH_TO_DOCROOT, $this->formatter->action);
     $t->template_dir = $old;
 }
Exemplo n.º 2
0
 function init()
 {
     if ($_SESSION['user_id'] <= 0) {
         return $this->setError('Please Register First');
     }
     require_once CLASSES . 'TableFactory.php';
     $sql = "SELECT U.USER_NAME as Owner, SU.NAME as 'Character Name', \r\n\t\t\t\tSU.SHEET_TYPE as Type, SHEET_ID as View, 'edit' as Modify\r\n\t\t\tFROM TBL_SHEET_USER as SU \r\n\t\t\tINNER JOIN TBL_USER as U\r\n\t\t\t\tON SU.USER_ID = U.USER_ID\r\n\t\t\t" . ($_SESSION['access'] < ADMIN_ACCESSLEVEL ? " WHERE SU.USER_ID = " . $_SESSION['user_id'] . " " : "") . "\r\n\t\t\tORDER BY SU.NAME";
     $q = $this->formatter->db->query($sql);
     $q->execute();
     if (!$q->rows()) {
         return $this->setError('You currently do not have any sheets');
     }
     $tf = new TableFactory($q);
     // TODO: make callback
     if ($_SESSION['access'] < ADMIN_ACCESSLEVEL) {
         $tf->setHiddenField('Owner');
     }
     $tf->setValueProcessor('View', "return '<a href=\"'.PATH_TO_DOCROOT.'/sheet/'.\$col.'\">'.\$col.'</a>';");
     $tf->setValueProcessor('Modify', "return '<a href=\"'.PATH_TO_DOCROOT.'/sheet/modify/'.\$row['View'].'\">'.\$col.'</a>';");
     $this->display = $tf->getXHTMLTable('list report');
 }
 function init()
 {
     $conf = VoodooIni::load('sheetgen');
     $this->_map = $conf['sheets'];
     $sql = "SELECT COUNT(SHEET_ID) as cnt FROM TBL_SHEET_USER";
     $q = $this->formatter->db->query($sql);
     $q->execute();
     $r = $q->fetch();
     $total = $r->cnt;
     $sql = "SELECT SHEET_TYPE as Game, COUNT(SHEET_ID) as `Absolute`, COUNT(SHEET_ID) as `Share`, " . $total . " as Total FROM TBL_SHEET_USER GROUP BY SHEET_TYPE ORDER BY `Share` DESC";
     $q = $this->formatter->db->query($sql);
     $q->execute();
     require_once CLASSES . 'TableFactory.php';
     $tf = new TableFactory($q);
     $tf->setHiddenField('Total');
     $tf->setValueProcessor(array('Game', 'Share'), array($this, 'tfValueProcessor'));
     $this->display = $tf->getXHTMLTable('list report', substr(md5('WikiMySheets'), 0, 5));
 }
Exemplo n.º 4
0
 /**
  * @param array $actionlist
  */
 function dispatch($actionlist)
 {
     if (!$this->hasRights($_SESSION['access'], 'admin', 'view')) {
         return VoodooPrivileges::displayError('Permission Denied');
     }
     if (!count($actionlist)) {
         return $this->configuration();
     }
     switch ($actionlist[0]) {
         case 'Sitemap.xml':
             $this->sitemaps();
             break;
         case 'users':
             require_once CLASSES . 'TableFactory.php';
             $user = new User($this->controller->db);
             $q = $user->getUserOverview();
             $tf = new TableFactory($q);
             $tf->setValueProcessor('USER_IMG', 'return substr(htmlentities($col),0,30)."...";');
             return array('User Overview', $tf->getXHTMLTable('list report'));
             break;
         case 'ControllerUnavailable':
             return array('Controller Unavailable', VoodooError::displayError('This Controller is unavailable.'));
             break;
         case 'config':
             return $this->configuration(isset($actionlist[1]) ? $actionlist[1] : null);
             break;
     }
 }