dmBridge PHP API
DMCPModuleController.php
00001 <?php
00002 #
00003 # dmBridge: a data access framework for CONTENTdm(R)
00004 #
00005 # Copyright © 2009, 2010, 2011 Board of Regents of the Nevada System of Higher
00006 # Education, on behalf of the University of Nevada, Las Vegas
00007 #
00008 
00013 class DMCPModuleController extends DMCPAdminController {
00014 
00015    public function index() {
00016       $this->preFlightCheck();
00017 
00018       $mm = DMModuleManager::getInstance();
00019 
00020       if (DMHTTPRequest::getCurrent()->getMethod() == DMHTTPMethod::POST) {
00021          $rep = DMHTTPRequest::getCurrent()->getRepresentation();
00022          if (is_array($rep->getFormValue("name"))) {
00023             $enabled = (substr($rep->getFormValue("action"), 0, 6) == "Enable");
00024             try {
00025                foreach ($rep->getFormValue("name") as $name) {
00026                   $module = $mm->getModuleByName($name);
00027                   $mm->setModuleEnabled($module, $enabled);
00028                }
00029             } catch (DMModuleActivationException $e) {
00030                DMHTTPRequest::getCurrent()->getSession()->setFlash(
00031                      new DMFlash($e->getMessage(), false));
00032                DMHTTPRequest::reload();
00033                die;
00034             }
00035 
00036             DMConfigXML::getInstance()->save();
00037             $msg_key = $enabled ? "MODULES_ENABLED" : "MODULES_DISABLED";
00038             DMHTTPRequest::getCurrent()->getSession()->setFlash(
00039                   new DMFlash(
00040                         DMLocalizedString::getString($msg_key), true));
00041             DMHTTPRequest::reload();
00042             die;
00043          }
00044       }
00045 
00046       $this->tpl_vars['manager'] = $mm;
00047       $this->tpl_vars['modules'] = $mm->getAllModules();
00048 
00049       $this->renderTemplate("/templates/module/index.html.php");
00050       die;
00051    }
00052 
00053 }
 All Data Structures Functions Variables