| // +---------------------------------------------------------------------------+ // $Id: PlanetMgr.php,v 1.2 2005/04/17 02:15:02 demian Exp $ require_once SGL_MOD_DIR .'/planet/classes/PlanetDAO.php'; /** * Manage planet links * * @package planet * @author Alexander J. Tarahchanowicz II */ class PlanetMgr extends SGL_Manager { function PlanetMgr() { SGL::logMessage(null, PEAR_LOG_DEBUG); parent::SGL_Manager(); $this->pageTitle = 'Planet Manager'; $this->template = 'planetList.html'; $this->da = PlanetDAO::singleton(); $this->_aActionsMapping = array( 'insert' => array('insert', 'redirectToDefault'), 'edit' => array('edit'), 'update' => array('update', 'redirectToDefault'), 'list' => array('list'), 'delete' => array('delete', 'redirectToDefault'), ); } function validate($req, &$input) { SGL::logMessage(null, PEAR_LOG_DEBUG); $this->validated = true; $input->error = array(); $input->pageTitle = $this->pageTitle; $input->masterTemplate = $this->masterTemplate; $input->template = $this->template; $input->action = ($req->get('action')) ? $req->get('action') : 'list'; $input->aDelete = $req->get('frmDelete'); $input->submitted = $req->get('submitted'); $input->planet = (object)$req->get('planet'); $input->planetId = $req->get('frmPlanetID'); // determine action if submitted if (!empty($input->submitted)) { switch (strtolower($input->planet->action)) { case 'update': $input->action = 'update'; break; case 'subscribe': $input->action = 'insert'; break; case 'unsubscribe': $input->action = 'delete'; break; } } // if errors have occured if (isset($aErrors) && count($aErrors)) { SGL::raiseMsg('Please fill in the indicated fields'); $input->error = $aErrors; $this->validated = false; } } function display(&$output) { if ($this->conf['PlanetMgr']['showUntranslated'] == false) { $c = &SGL_Config::singleton(); $c->set('debug', array('showUntranslated' => false)); } if ($output->action == 'list') { if (!$output->planet->hasBlog) { $output->aAction = array('subscribe' => 'Subscribe'); } else { $output->aAction = array( 'update' => 'Update', 'unsubscribe' => 'Unsubscribe', ); } } } function _cmd_list(&$input, &$output) { SGL::logMessage(null, PEAR_LOG_DEBUG); $output->template = 'planetList.html'; $output->pageTitle = 'Planet :: Manage Blog Link'; $usrId = SGL_Session::getUid(); if ($this->da->hasBlogLink($usrId)) { $oPlanet = $this->da->getBlogLinkByUsrId($usrId); $oPlanet->hasBlog = true; } else { $oPlanet->hasBlog = false; $oPlanet->usr_id = $usrId; } $output->planet = $oPlanet; } function _cmd_insert(&$input, &$output) { SGL::logMessage(null, PEAR_LOG_DEBUG); $input->planet->active = ($this->conf['PlanetMgr']['autoActivate']) ? 1 : 0; $aPlanet = (array) $input->planet; if ($this->da->addBlogLink($aPlanet) !== false) { SGL::raiseMsg('planet insert successfull', false, SGL_MESSAGE_INFO); } else { SGL::raiseError('planet insert NOT successfull', SGL_ERROR_NOAFFECTEDROWS); } } function _cmd_edit(&$input, &$output) { SGL::logMessage(null, PEAR_LOG_DEBUG); $output->template = 'planetEdit.html'; $output->pageTitle = 'Planet :: Edit Blog Link'; } function _cmd_update(&$input, &$output) { SGL::logMessage(null, PEAR_LOG_DEBUG); if ($input->planet->planet_uri != $input->planet->orig_planet_uri) { $aData = array( 'planet_link_id' => $input->planet->planet_link_id, 'planet_uri' => $input->planet->planet_uri, ); if ($this->da->updateBlogLink($aData)) { SGL::raiseMsg('planet update successfull', false, SGL_MESSAGE_INFO); } else { SGL::raiseError('planet update NOT successfull', SGL_ERROR_NOAFFECTEDROWS); } } else { SGL::raiseMsg('planet update successfull', false, SGL_MESSAGE_INFO); } } function _cmd_delete(&$input, &$output) { SGL::logMessage(null, PEAR_LOG_DEBUG); if ($this->da->deleteBlogLink($input->planet->planet_link_id) !== false) { SGL::raiseMsg('planet delete successfull', false, SGL_MESSAGE_INFO); } else { SGL::raiseError('planet delete NOT successfull', SGL_ERROR_NOAFFECTEDROWS); } } } ?>