Ejemplo n.º 1
0
 function action_revision($args)
 {
     global $manager, $tree, $user, $lang;
     /* Decode argumenst */
     $id = array_shift($args);
     $item =& $tree->getItemById($id);
     $id = $item['id'];
     if (!$tree->_hasRights('admin', $item['rights'])) {
         header('Location: ' . url::item($id));
         exit;
     }
     if (count($args)) {
         $action = array_shift($args);
         if ($action == 'create') {
             revisions::doCreateRevision($id);
             if ($_REQUEST['return']) {
                 header('Location: ' . $_REQUEST['return']);
                 exit;
             }
         }
         if ($action == 'publish') {
             revisions::doPublishRevision($id, $_REQUEST['revision']);
             if ($_REQUEST['return']) {
                 header('Location: ' . $_REQUEST['return']);
                 exit;
             }
         }
     }
     // Redirect
     header("Location: " . url::item());
     exit;
 }
Ejemplo n.º 2
0
 function action_page($args)
 {
     global $manager, $tree, $user, $lang;
     /* Decode argumenst */
     $id = array_shift($args);
     $item =& $tree->getItemById($id);
     $id = $item['id'];
     if (!$tree->_hasRights('admin', $item['rights'])) {
         exit;
     }
     if (count($args)) {
         $action = array_shift($args);
         if ($action == 'publishDraft') {
             $res = sql::query("\r\n\t\t\t\t\t\tUPDATE\r\n\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents \r\n\t\t\t\t\t\tSET\r\n\t\t\t\t\t\t\t`status` = 1,\r\n\t\t\t\t\t\t\t`published` = " . time() . "\r\n\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\t`ID` = " . $id . "\r\n\t\t\t\t\t");
             exit;
         }
         if ($action == 'applyRights') {
             $res = sql::query("\r\n\t\t\t\t\t\tUPDATE \r\n\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\t\t\tSET \r\n\t\t\t\t\t\t\t`r_view` = " . intval($_REQUEST['view']) . ", \r\n\t\t\t\t\t\t\t`r_view_inv` = 0\r\n\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\t`ID` = '" . $id . "'\r\n\t\t\t\t\t");
             exit;
         }
         if ($action == 'changeType') {
             $res = sql::query("\r\n\t\t\t\t\t\tUPDATE \r\n\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\t\t\tSET \r\n\t\t\t\t\t\t\t`type` = '" . addslashes($_REQUEST['type']) . "'\r\n\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\t`ID` = '" . $id . "'\r\n\t\t\t\t\t");
             if ($_REQUEST['return']) {
                 header('Location: ' . $_REQUEST['return']);
                 exit;
             }
         }
         if ($action == 'createRevision') {
             revisions::doCreateRevision($id);
             if ($_REQUEST['return']) {
                 header('Location: ' . $_REQUEST['return']);
                 exit;
             }
         }
         if ($action == 'publishRevision') {
             revisions::doPublishRevision($id, $_REQUEST['revision']);
             if ($_REQUEST['return']) {
                 header('Location: ' . $_REQUEST['return']);
                 exit;
             }
         }
         if ($action == 'advancedDate') {
             $tpl = new Template($this->getTemplate('date.template'));
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 if ($_POST['activation_type'] == 'always') {
                     $activation = 0;
                 } else {
                     $activation = mktime(0, 0, 0, $_POST['activation_month'], $_POST['activation_day'], $_POST['activation_year']);
                 }
                 if ($_POST['expiration_type'] == 'never') {
                     $expiration = 0;
                 } else {
                     $expiration = mktime(0, 0, 0, $_POST['expiration_month'], $_POST['expiration_day'], $_POST['expiration_year']);
                 }
                 $res = sql::query("\r\n\t\t\t\t\t\t\tUPDATE \r\n\t\t\t\t\t\t\t\t" . _TABLE_PREFIX_ . "contents\r\n\t\t\t\t\t\t\tSET \r\n\t\t\t\t\t\t\t\tactivation = '" . $activation . "',\r\n\t\t\t\t\t\t\t\texpiration = '" . $expiration . "',\r\n\t\t\t\t\t\t\t\tstatus = 1\r\n\t\t\t\t\t\t\tWHERE \r\n\t\t\t\t\t\t\t\tID='" . $id . "'\r\n\t\t\t\t\t\t");
                 if ($_REQUEST['return']) {
                     header('Location: ' . $_REQUEST['return']);
                     exit;
                 }
             }
             if ($item['date']['activation'] == 0) {
                 $activation_timestamp = time();
             } else {
                 $activation_timestamp = $item['date']['activation'];
             }
             $tpl->set('activation_day', date('j', $activation_timestamp));
             $tpl->set('activation_month', date('n', $activation_timestamp));
             $tpl->set('activation_year', date('Y', $activation_timestamp));
             $tpl->set('activation_max', date('Y') + 4);
             if ($item['date']['expiration'] == 0) {
                 $expiration_timestamp = time();
             } else {
                 $expiration_timestamp = $item['date']['expiration'];
             }
             $tpl->set('expiration_day', date('j', $expiration_timestamp));
             $tpl->set('expiration_month', date('n', $expiration_timestamp));
             $tpl->set('expiration_year', date('Y', $expiration_timestamp));
             $tpl->set('expiration_max', date('Y') + 4);
             $tpl->set('months', $lang->months());
             $tpl->set('item', $item);
             $tpl->set('id', $id);
             $tpl->set('return', $_REQUEST['return']);
             echo $tpl->fetch();
         }
         if ($action == 'advancedRights') {
             $tpl = new Template($this->getTemplate('rights.template'));
             if ($_SERVER['REQUEST_METHOD'] == 'POST') {
                 $rights['author'] = $_POST['author'];
                 $rights['view'] = $_POST['view'];
                 $rights['edit'] = $_POST['edit'];
                 $rights['create'] = $_POST['create'];
                 $rights['admin'] = $_POST['admin'];
                 $rights['view_inv'] = isset($_POST['view_inv']) ? $_POST['view_inv'] : 0;
                 $rights['edit_inv'] = isset($_POST['edit_inv']) ? $_POST['edit_inv'] : 0;
                 $rights['create_inv'] = isset($_POST['create_inv']) ? $_POST['create_inv'] : 0;
                 $rights['admin_inv'] = isset($_POST['admin_inv']) ? $_POST['admin_inv'] : 0;
                 if ($user->memberof(6)) {
                     $this->_setrights($id, $rights, $_POST['recursive'] == 'yes');
                 } else {
                     $this->_setrights($id, $rights);
                 }
                 if ($_REQUEST['return']) {
                     header('Location: ' . $_REQUEST['return']);
                     exit;
                 }
             }
             // Get groups...
             $groups = array();
             $res = sql::query("SELECT * FROM " . _TABLE_PREFIX_ . "groups");
             while ($row = sql::fetch_array($res)) {
                 $groups[] = $row;
             }
             // Get authors...
             $authors = array();
             $res = sql::query("SELECT * FROM " . _TABLE_PREFIX_ . "users ORDER BY lastname");
             while ($row = sql::fetch_array($res)) {
                 $authors[] = $row;
             }
             $tpl->set("page_authors", $authors);
             $tpl->set("view_groups", $groups);
             $tpl->set("edit_groups", $groups);
             $tpl->set("create_groups", $groups);
             $tpl->set("admin_groups", $groups);
             $tpl->set('item', $item);
             $tpl->set('id', $id);
             $tpl->set('return', $_REQUEST['return']);
             echo $tpl->fetch();
             exit;
         }
     }
     exit;
 }