function init()
 {
     parent::init();
     //actions page policy
     $oContentField = new AnwContentFieldSettings_radio(self::FIELD_POLICY);
     $asEnumValues = array(self::POLICY_ALL_ACTIONS => $this->getComponent()->t_contentfieldsettings("policy_all_actionspage"), self::POLICY_SELECTED_ACTIONS => $this->getComponent()->t_contentfieldsettings("policy_selected_actionspage"));
     $oContentField->setEnumValues($asEnumValues);
     $oContentField->setDefaultValue(self::POLICY_SELECTED_ACTIONS);
     $this->addContentField($oContentField);
     //actions page selection
     $oContentField = new AnwContentFieldSettings_checkboxGroup(self::FIELD_ACTIONS);
     $asActions = AnwComponent::getEnabledComponents(AnwComponent::TYPE_ACTION);
     $asEnumValues = array();
     foreach ($asActions as $sAction) {
         if (AnwAction::isActionPage($sAction) && !AnwAction::isMagicAclAction($sAction)) {
             $asEnumValues[$sAction] = $sAction;
         }
     }
     $oContentField->setEnumValues($asEnumValues);
     $oMultiplicity = new AnwContentMultiplicity_multiple();
     $oMultiplicity->setSortable(false);
     $oContentField->setMultiplicity($oMultiplicity);
     $this->addContentField($oContentField);
 }
Beispiel #2
0
 function runAndOutput()
 {
     try {
         AnwDebug::startbench("action runAndOutput", true);
         //captcha request?
         if (AnwEnv::_GET(self::GET_CAPTCHA)) {
             $this->doCaptcha();
             exit;
         }
         //make sure this action is enabled in configuration
         if (!in_array($this->getName(), AnwComponent::getEnabledComponents(AnwComponent::TYPE_ACTION))) {
             throw new AnwAclException("Trying to execute an action which is not enabled");
         }
         //is it an admin action?
         if ($this instanceof AnwAdminAction) {
             if (!AnwCurrentSession::getUser()->isAdminAllowed()) {
                 throw new AnwAclException("Admin is not allowed");
             }
         }
         //does action require https if available?
         if (self::isHttpsAction($this->getName())) {
             //do we need to redirect to https?
             if (self::globalCfgHttpsEnabled() && !AnwEnv::isHttps()) {
                 //redirect to https
                 self::debug("Redirecting to https...");
                 AnwUtils::httpPostToSession();
                 $asParams = $_GET;
                 $sLink = AnwUtils::alink($this->getName(), $asParams);
                 AnwUtils::redirect($sLink);
                 //should automatically use https
             }
         }
         if (AnwCurrentSession::needsReauth()) {
             //reauth processing
             if (AnwEnv::_POST("reauth")) {
                 self::debug("Processing reauth request...");
                 try {
                     //check password and reset reauth
                     $this->doReauth(AnwEnv::_POST("reauth"));
                     self::debug("Reauth request success!");
                 } catch (AnwException $e) {
                     //reauth failed, show reauth form again
                     self::debug("Reauth success failed.");
                     $this->doReauthForm();
                     //post data is already in session
                     exit;
                 }
             }
             //must the user reauth for this action? - do this after reauth processing
             if ($this instanceof AnwHarmlessAction) {
                 //ok, user is authorized to run action without reauthenticating
             } else {
                 //user needs to reauthenticate
                 $this->checkReauth();
             }
         }
         //restore POST if any in session
         AnwUtils::restoreHttpPostFromSession();
         $this->initializeAction();
         //run the action
         $this->init();
         $this->run();
         AnwDebug::stopbench("action runAndOutput");
         $this->output();
     } catch (AnwLockException $e) {
         $aoLocks = $e->getLocks();
         $asLockInfos = array();
         foreach ($aoLocks as $oLock) {
             $nLockType = $oLock->getLockType();
             switch ($nLockType) {
                 case AnwLock::TYPE_PAGEONLY:
                     $sTranslation = "err_ex_lock_details_pageonly";
                     break;
                 case AnwLock::TYPE_PAGEGROUP:
                     $sTranslation = "err_ex_lock_details_pagegroup";
                     break;
                 default:
                     throw new AnwUnexpectedException("lock type unknown");
                     break;
             }
             $asLockInfos[] = self::g_($sTranslation, array("user" => '<b>' . AnwUtils::xText($oLock->getLockUser()->getDisplayName()) . '</b>', "pagename" => '<i>' . AnwUtils::xText($oLock->getLockPage()->getName()) . '</i>', "timestart" => Anwi18n::dateTime($oLock->getLockTime()), "timeseen" => Anwi18n::dateTime($oLock->getLockTimeLast()), "timeexpire" => Anwi18n::dateTime($oLock->getLockTimeLast() + self::globalCfgLocksExpiry())));
         }
         $this->headJs($this->tpl()->errorLock_js());
         $this->out = $this->tpl()->errorLock($asLockInfos);
         $this->output();
     } catch (AnwException $e) {
         $nErrorNumber = false;
         if ($e instanceof AnwAclPhpEditionException) {
             $sTitle = self::g_("err_ex_acl_t");
             $sExplain = self::g_("err_ex_acl_php_p");
             $sImageSrc = AnwUtils::pathImg("warning.gif");
         } else {
             if ($e instanceof AnwAclJsEditionException) {
                 $sTitle = self::g_("err_ex_acl_t");
                 $sExplain = self::g_("err_ex_acl_js_p");
                 $sImageSrc = AnwUtils::pathImg("warning.gif");
             } else {
                 if ($e instanceof AnwAclMinTranslatedPercentException) {
                     $sTitle = self::g_("err_ex_acl_t");
                     $sExplain = self::g_("err_ex_acl_mintranslatedpercent_p", array('percent' => $e->getTranslatedPercent()));
                     $sImageSrc = AnwUtils::pathImg("warning.gif");
                 } else {
                     if ($e instanceof AnwAclException) {
                         $sTitle = self::g_("err_ex_acl_t");
                         if (AnwCurrentSession::isLoggedIn()) {
                             $sExplain = self::g_("err_ex_acl_loggedin_p");
                         } else {
                             $sExplain = self::g_("err_ex_acl_loggedout_p");
                         }
                         $sImageSrc = AnwUtils::pathImg("warning.gif");
                     } else {
                         if ($e instanceof AnwBadCallException) {
                             $sTitle = self::g_("err_ex_badcall_t");
                             $sExplain = self::g_("err_ex_badcall_p");
                             $sImageSrc = AnwUtils::pathImg("warning.gif");
                         } else {
                             if ($e instanceof AnwDbConnectException) {
                                 $sTitle = self::g_("err_ex_dbconnect_t");
                                 $sExplain = self::g_("err_ex_dbconnect_p");
                                 $sImageSrc = AnwUtils::pathImg("error.gif");
                                 $nErrorNumber = AnwDebug::reportError($e);
                             } else {
                                 $sTitle = self::g_("err_ex_unexpected_t");
                                 $sExplain = self::g_("err_ex_unexpected_p");
                                 $sImageSrc = AnwUtils::pathImg("error.gif");
                                 $nErrorNumber = AnwDebug::reportError($e);
                             }
                         }
                     }
                 }
             }
         }
         $this->out = $this->tpl()->errorException($sTitle, $sExplain, $sImageSrc, $nErrorNumber);
         //self::output(); //not use $this to avoid potential errors if it's an ActionPage
         $this->output();
     }
 }