diff --git a/admin.php b/admin.php index 0ef016e..01268b1 100644 --- a/admin.php +++ b/admin.php @@ -58,6 +58,7 @@ function Render() { echo "
  • edit compo types
  • "; echo "
  • edit faq items
  • "; + echo "
  • edit cdcs
  • "; } echo "\n"; echo "\n"; diff --git a/admin_cdc.php b/admin_cdc.php new file mode 100644 index 0000000..3827931 --- /dev/null +++ b/admin_cdc.php @@ -0,0 +1,175 @@ +IsModerator()) +{ + redirect("index.php"); + exit(); +} + +class PouetBoxAdminAddCDC extends PouetBoxEditConnectionsBase +{ + public static $slug = "CDC"; + function __construct( ) + { + parent::__construct(); + $this->uniqueID = "pouetbox_admineditcdc"; + $this->title = "edit cdcs"; + $this->headers = array("prod","groups","added date"); + + $s = new BM_Query(); + $s->AddTable("cdc"); + $s->AddField("cdc.id"); + $s->AddField("cdc.addedDate"); + $s->attach(array("cdc"=>"which"),array("prods as prod"=>"id")); + $s->AddOrder("cdc.addedDate"); + $this->data = $s->perform(); + + $a = array(); + foreach($this->data as $v) $a[] = &$v->prod; + PouetCollectPlatforms($a); + } + use PouetForm; + function Commit($data) + { + if ($data["delAffil"]) + { + SQLLib::Query("delete from cdc where id=".(int)$data["delCDC"]); + return array(); + } + + $a = array(); + $a["which"] = $data["which"]; + $a["addedDate"] = $data["addedDate"]; + if ($data["editCDCID"]) + { + SQLLib::UpdateRow("cdc",$a,"id=".(int)$data["editCDCID"]); + $a["id"] = $data["editCDCID"]; + } + else + { + $a["id"] = SQLLib::InsertRow("cdc",$a); + } + + @unlink(POUET_ROOT_LOCAL . 'cache/pouetbox_cdc.cache' ); + + if ($data["partial"]) + { + $o = toObject($a); + $o->prod = PouetProd::Spawn($a["which"]); + $this->RenderNormalRow($o); + $this->RenderNormalRowEnd($o); + exit(); + } + + return array(); + } + function RenderEditRow($row) + { + echo " \n"; + echo " \n"; + } + function RenderNormalRow($v) + { + echo "\n"; + echo $v->prod->RenderTypeIcons(); + echo $v->prod->RenderPlatformIcons(); + echo "".$v->prod->RenderLink()."\n"; + echo "\n"; + + echo "\n"; + echo $v->prod->RenderGroupsShortProdlist(); + echo "\n"; + + echo "\n"; + echo $v->addedDate; + echo "\n"; + } + function RenderBody() + { + parent::RenderBody(); +?> + +CanEditItems()) +{ + // ajax responses + $prod = new stdClass(); + $prod->id = $_GET["which"]; + foreach($boxen as $class) + { + if ($_GET["edit" . $class::$slug]) + { + $box = new $class( $prod ); + $box->RenderEditRow( $box->GetRow( $_GET["edit" . $class::$slug] ) ); + $box->RenderEditRowEnd( $box->GetRow( $_GET["edit" . $class::$slug] ) ); + } + if ($_GET["new" . $class::$slug]) + { + $box = new $class( $prod ); + $box->RenderEditRow( new stdClass() ); + $box->RenderEditRowEnd( new stdClass() ); + } + } + exit(); +} + +$form = new PouetFormProcessor(); + +$form->SetSuccessURL( "admin_cdc.php", true ); + +$form->Add( "prod", new PouetBoxAdminAddCDC() ); +if ($currentUser && $currentUser->CanEditItems()) + $form->Process(); + +$TITLE = "edit faq"; + +require_once("include_pouet/header.php"); +require("include_pouet/menu.inc.php"); + +echo "
    \n"; + +if (get_login_id()) +{ + $form->Display(); +} +else +{ + require_once("include_pouet/box-login.php"); + $box = new PouetBoxLogin(); + $box->Render(); +} + +echo "
    \n"; + +require("include_pouet/menu.inc.php"); +require_once("include_pouet/footer.php"); + +?> diff --git a/cdc.php b/cdc.php index a529559..877c2cd 100644 --- a/cdc.php +++ b/cdc.php @@ -25,8 +25,6 @@ function RenderBody() { echo "\n\n"; echo "\n"; - $lastYear = 0; - $lastCategory = ""; foreach ($this->cdcs as $row) { $p = $row->prod;