clean() 공개 메소드

if no group is specified all cache files will be destroyed else only cache files of the specified group will be destroyed
public clean ( string $group = false, string $mode = 'ingroup' ) : boolean
$group string name of the cache group
$mode string flush cache mode : 'old', 'ingroup', 'notingroup', 'callback_myFunction'
리턴 boolean true if no problem
예제 #1
0
 public function CacheDelete($mode = TRUE)
 {
     $cacheoptions = array('automaticCleaningFactor' => '100', 'cacheDir' => dirname(__FILE__) . '/nicocache/cache/');
     $CacheLite = new Cache_Lite($cacheoptions);
     if ($mode) {
         $flag = $CacheLite->clean();
     } else {
         $flag = $CacheLite->clean(FALSE, 'old');
     }
     return $flag;
 }
예제 #2
0
 public function intercept_page(&$page)
 {
     if ($this->_in_excluded_pages()) {
         return;
     }
     $frontend = Frontend::instance();
     $logged_in = $frontend->isLoggedIn();
     $headers = $page['page']->_headers;
     $url = getCurrentPage();
     $options = array('cacheDir' => CACHE . "/", 'lifeTime' => $this->_get_lifetime());
     $cl = new Cache_Lite($options);
     if ($page['page']->_param['url-flush'] == 'site') {
         $cl->clean();
     } else {
         if (array_key_exists('url-flush', $page['page']->_param)) {
             $cl->remove($url);
         } else {
             if (!$logged_in && ($output = $cl->get($url))) {
                 # Ensure the original headers are served out
                 foreach ($headers as $header) {
                     header($header);
                 }
                 print $output;
                 if ($this->_get_comment_pref() == 'yes') {
                     echo "<!-- Cache served: " . $cl->_fileName . " -->";
                 }
                 exit;
             }
         }
     }
 }
예제 #3
0
function clean_usericoncache($user)
{
    if ($user instanceof steam_user) {
        $user->delete_value("OBJ_ICON");
        $icon = $user->get_attribute("OBJ_ICON");
        clean_iconcache($icon);
        // Clean Icon data from cache
        require_once "Cache/Lite.php";
        $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE));
        $cache->clean($user->get_name());
        // Clean profile data from cache
        $cache = get_cache_function($user->get_name(), 86400);
        $cache->drop("lms_steam::user_get_profile", $user->get_name());
        // TODO: In Menu "Your Desktop" some Icon data comes from lms_user
        // stored in session => delete/refresh this value in session here
        $portal = $GLOBALS["portal"];
        $steam_user = $portal->get_user();
        $steam_user->init_attributes();
    }
}
 /**
  * Clean cache for a group given a mode.
  *
  * group mode    : cleans all cache in the group
  * notgroup mode : cleans all cache not in the group
  *
  * @param   string  $group  The cache data group
  * @param   string  $mode   The mode for cleaning cache [group|notgroup]
  *
  * @return  boolean
  *
  * @since   11.1
  */
 public function clean($group, $mode = null)
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.filesystem.file');
     switch ($mode) {
         case 'notgroup':
             $clmode = 'notingroup';
             $success = static::$CacheLiteInstance->clean($group, $clmode);
             break;
         case 'group':
             if (is_dir($this->_root . '/' . $group)) {
                 $clmode = $group;
                 static::$CacheLiteInstance->setOption('cacheDir', $this->_root . '/' . $group . '/');
                 $success = static::$CacheLiteInstance->clean($group, $clmode);
                 // Remove sub-folders of folder; disable all filtering
                 $folders = JFolder::folders($this->_root . '/' . $group, '.', false, true, array(), array());
                 foreach ($folders as $folder) {
                     if (is_link($folder)) {
                         if (JFile::delete($folder) !== true) {
                             return false;
                         }
                     } elseif (JFolder::delete($folder) !== true) {
                         return false;
                     }
                 }
             } else {
                 $success = true;
             }
             break;
         default:
             if (is_dir($this->_root . '/' . $group)) {
                 $clmode = $group;
                 static::$CacheLiteInstance->setOption('cacheDir', $this->_root . '/' . $group . '/');
                 $success = static::$CacheLiteInstance->clean($group, $clmode);
             } else {
                 $success = true;
             }
             break;
     }
     return $success;
 }
 function showAll()
 {
     $idSite = getRequestVar('site', -1, 'int');
     if ($idSite == -1) {
         $allSiteArchive = DataModel::getSites();
     } else {
         $allSiteArchive[] = new Site($idSite);
     }
     $uniqCacheId = DataModel::getSitesSignature() . date("Y-m-d") . serialize($_GET) . '.rss';
     // Set a few options
     $options = array('cacheDir' => DIR_CACHE_RSS, 'lifeTime' => CACHE_RSS_LIFETIME);
     // Create a Cache_Lite object
     $Cache_Lite = new Cache_Lite($options);
     if (time() % 500 === 0) {
         $Cache_Lite->clean();
     }
     // Test if thereis a valide cache for this id
     if (SMARTY_DEBUG || !($allData = $Cache_Lite->get($uniqCacheId))) {
         $dataTmp = $this->data;
         $o_config =& PmvConfig::getInstance();
         $allItems = array();
         foreach ($allSiteArchive as $id => $infoSite) {
             $allArchives = $dataTmp->getLastArchives(NB_DAYS_FOR_RSS_ITEMS, 0, DATE_NORMAL, $infoSite);
             $i = 0;
             foreach ($allArchives as $date => $o_archive) {
                 //var_dump($date);
                 $this->request->setDate($o_archive->date->get());
                 $this->request->setModuleName('view_visits_rss');
                 $o_mod = new ViewVisitsRss($infoSite);
                 $o_mod->init($this->request, $this->tpl, $o_archive);
                 //var_dump($o_mod->data->archive->date->get());
                 $rssContent = $o_mod->showAll(true);
                 $dateRss = date("r", time() - 100 * $i++ - 10 * $id);
                 $item['pubDate'] = $dateRss;
                 $url = PHPMV_URL . "/?site=" . $infoSite->getId() . "&mod=view_visits&date=" . $o_archive->date->get();
                 $item['guid'] = $url;
                 //"http://www.phpmyvisites.us/".md5($dateRss);
                 $item['link'] = $url;
                 $item['title'] = vsprintf($GLOBALS['lang']['rss_titre'], array($infoSite->getName(), $date));
                 $rssContent = $item['title'] . $rssContent;
                 $item['author'] = "phpmyvisites@gmail.com (phpMyVisites)";
                 $item['date_ts'] = time() - 10 * $id;
                 $item['description'] = $rssContent;
                 $item['date_ts'] = $o_archive->date->getTimestamp();
                 $allItems[] = $item;
                 $urls[] = $url;
             }
         }
         $GLOBALS['sorting_index'] = 'date_ts';
         uasort($allItems, "sortingDataInfo");
         $channel['title'] = "phpMyVisites stats by RSS";
         $channel['link'] = "http://www.phpmyvisites.us";
         $channel['description'] = "Enjoy phpmyvisites power ! :)";
         $channel['pubDate'] = date("r");
         $channel['generator'] = "phpMyVisites";
         $channel['language'] = $GLOBALS['lang']['lang_iso'];
         $channel['lastBuildDate'] = date("r");
         foreach ($allItems as $chan) {
             unset($chan['date_ts']);
             $channel[] = $chan;
         }
         $rss = array('channel' => $channel);
         // An array of serializer options
         $serializer_options = array('addDecl' => TRUE, 'encoding' => 'UTF-8', 'indent' => '  ', 'rootName' => 'rss', 'defaultTagName' => 'item', 'rootAttributes' => array('version' => '2.0'));
         $Serializer =& new XML_Serializer($serializer_options);
         // Serialize the data structure
         $Serializer->setOption("keyAttribute", "rdf:about");
         $status = $Serializer->serialize($rss);
         $allData = $Serializer->getSerializedData();
         $Cache_Lite->save($allData);
     }
     $this->displayRss($allData);
 }
예제 #6
0
파일: PSCache.php 프로젝트: ilivanoff/www
 public function clean($group = null)
 {
     $this->LOGGER->info($group ? "Очистка кеша по группе [{$group}]" : 'Полная очистка кеша');
     $this->CACHELITE->clean($group);
     if ($group) {
         //Эту группу больше не нужно валидировать
         $this->TREE->setGroupValidated($group);
         //Очистим ключи локального хранилища
         $keys = $this->CACHE->keys();
         $removed = array();
         $prefix = $this->localCacheGroup($group);
         foreach ($keys as $key) {
             if (starts_with($key, $prefix)) {
                 $removed[] = $key;
                 $this->CACHE->remove($key);
             }
         }
         if ($removed) {
             $this->LOGGER->info('В локальном кеше были удалены следующие ключи: {}.', concat($removed));
         }
     } else {
         $this->CACHE->clear();
         $this->TREE->setAllValidated('Полная очистка кеша');
     }
 }
예제 #7
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //$portal = \lms_portal::get_instance();
     //$portal->initialize( GUEST_NOT_ALLOWED );
     $user = \lms_steam::get_current_user();
     //$path = $request->getPath();
     $STEAM = $GLOBALS["STEAM"];
     $weblogId = $this->params[0];
     $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId);
     //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) )
     //{
     //	include( "bad_link.php" );
     //	exit;
     //}
     if (!$weblog instanceof \steam_calendar) {
         if ($weblog instanceof \steam_container) {
             $category = $weblog;
             $categories = $category->get_environment();
             $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id());
         } elseif ($weblog instanceof \steam_date) {
             $date = $weblog;
             $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id());
         } else {
             include "bad_link.php";
             exit;
         }
     } else {
         $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId);
         define("OBJ_ID", $weblogId);
         if (!$weblog->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     $date = $weblog;
     //if(!isset($date))
     //throw new \Exception("variable date is not set.");
     //if ( $_SERVER[ "REQUEST_METHOD" ] == "POST" && $date->check_access_write( $user ) )
     if (false) {
         $values = $_POST["values"];
         if (!isset($values["delete"])) {
             $values["delete"] = false;
         }
         if ($values["delete"]) {
             require_once "Cache/Lite.php";
             $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache->clean($weblog->get_id());
             $cache->clean($date->get_id());
             $trashbin = $GLOBALS["STEAM"]->get_current_steam_user();
             if (is_object($trashbin)) {
                 $date->move($trashbin);
             } else {
                 $date->delete();
             }
         }
         header("Location: " . $values["return_to"]);
         exit;
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         //echo "hund";
         $values = $_POST["values"];
         $problem = "";
         $hint = "";
         if (isset($values["save"])) {
             $values["save"] = true;
         } else {
             $values["save"] = false;
         }
         if ($values["save"]) {
             if (empty($values["url"])) {
                 $problem = gettext("The URL is missing.") . " ";
                 $hint = gettext("Please insert the URL, starting with 'http://'") . " ";
             }
             if (empty($values["name"])) {
                 $problem .= gettext("The name is missing.");
                 $hint .= gettext("How is the title of the webpage?");
             } else {
                 if (strpos($values["name"], "/")) {
                     if (!isset($problem)) {
                         $problem = "";
                     }
                     $problem .= gettext("Please don't use the \"/\"-char in the name of the blogroll entry.");
                 }
             }
             if (empty($problem)) {
                 $environment = $weblog->get_blogroll();
                 if (!is_object($environment)) {
                     throw new \Exception("Environment is not correct.");
                 }
                 if (!$environment instanceof \steam_container) {
                     throw new \Exception("Environment is no container.");
                 }
                 if (!$environment->check_access_write($user)) {
                     throw new \Exception("No write access on this container.", E_USER_RIGHTS);
                 }
                 if (empty($problem)) {
                     $docextern = \steam_factory::create_docextern($GLOBALS["STEAM"]->get_id(), $values["name"], $values["url"], $environment, $values["desc"]);
                     header("Location: " . $values["return_to"]);
                     exit;
                 } else {
                     //TODO: PROBDESC
                     //$portal->set_problem_description( $problem, $hint );
                 }
             } else {
                 //TODO: PROBDESC
                 //$portal->set_problem_description( $problem, $hint );
             }
         }
     }
     $content = \Weblog::getInstance()->loadTemplate("weblog_blogroll.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplatefile( PATH_TEMPLATES . "weblog_blogroll.template.html" );
     if (!empty($problem)) {
         $content->setVariable("VALUE_NAME", $values["name"]);
         $content->setVariable("VALUE_URL", $values["url"]);
         $content->setVariable("VALUE_DESC", $values["desc"]);
     }
     $content->setVariable("GREETING", str_replace("%n", $_SESSION["LMS_USER"]->get_forename(), gettext("Hi %n!")));
     $help_text = "<b>" . gettext("What is a blogroll?") . "</b> " . gettext("A blogroll is a collection of links to other weblogs.") . " " . gettext("When present, blogrolls are on the front page sidebar of most weblogs.") . " " . gettext("Some blogrolls also simply consist of the list of weblogs an author reads himself.");
     $content->setVariable("HELP_TEXT", $help_text);
     $content->setVariable("YOUR_BLOGROLL_TEXT", gettext("Your Blogroll"));
     $content->setVariable("CREATE_NEW_LINK_TEXT", gettext("Create new Link"));
     $content->setVariable("FORM_ACTION", "");
     //PATH_URL . "docextern_create.php" );
     $content->setVariable("ENVIRONMENT", $weblog->get_blogroll()->get_id());
     $content->setVariable("LABEL_NAME", gettext("Name"));
     $content->setVariable("LABEL_URL", gettext("URL"));
     $content->setVariable("LABEL_DESCRIPTION", gettext("Description"));
     $content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes"));
     $content->setVariable("LABEL_BACK", gettext("back"));
     $content->setVariable("LINK_BACK", PATH_URL . "weblog/index/" . $weblog->get_id() . "/");
     $blogroll = $weblog->get_blogroll_list();
     foreach ($blogroll as $link) {
         if (!$link instanceof \steam_docextern) {
             continue;
         }
         $content->setCurrentBlock("BLOCK_LINK");
         $content->setVariable("LINK_URL", $link->get_url());
         $content->setVariable("LINK_NAME", h($link->get_name()));
         $content->setVariable("LINK_DESC", h($link->get_attribute("OBJ_DESC")));
         $content->setVariable("LABEL_EDIT", gettext("edit"));
         $content->setVariable("LINK_EDIT", PATH_URL . "docextern/" . $link->get_id() . "/edit/");
         $content->setVariable("LINK_DELETE", PATH_URL . "docextern/" . $link->get_id() . "/delete/");
         $content->setVariable("LABEL_DELETE", gettext("delete"));
         $content->parse("BLOCK_LINK");
     }
     $rootlink = \lms_steam::get_link_to_root($weblog);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/" . $weblog->get_id() . "/"), array("link" => "", "name" => gettext("Edit Blogroll")));
     //$portal->set_page_main(
     //$headline,
     //$content->get()
     //);
     //return $portal->get_html();
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
예제 #8
0
 /**
  * Performs data store cleanup (removes all expired items)
  *
  * @return	bool
  */
 public function cleanup()
 {
     return $this->cache_lite->clean('vivvo_cache', 'old') === true;
 }
예제 #9
0
 /**
  * A method to delete cached plugin data.
  *
  * @static
  * @param string $module The plugin module name (i.e. /plugins/module directory).
  * @param string $package The plugin package name (i.e. /plugins/module/package
  *                        directory).
  * @param string $name Optional name of the PHP file which contains the plugin,
  *                     otherwise the plugin with the same name as the package
  *                     is assumed.
  * @param string $mode An optional PEAR::Cache_Lite cleaning mode. Default is
  *                     'ingroup', to delete all cached data for the plugin.
  * @param array $aOptions An optional array of constructor options for
  *                        PEAR::Cache_Lite. The default values are those
  *                        obtained from {@link MAX_Plugin::prepareCacheOptions()}.
  * @return boolean True on success, false otherwise.
  */
 function cleanPluginCache($module, $package, $name = null, $mode = 'ingroup', $aOptions = null)
 {
     if (is_null($name)) {
         $name = $package;
     }
     if (is_null($aOptions)) {
         $aOptions = MAX_Plugin::prepareCacheOptions($module, $package);
     }
     $oCache = new Cache_Lite($aOptions);
     return $oCache->clean($name, $mode);
 }
                }
                $oStartDate = new Date($oConnectionDate->format('%Y-%m-%d %H:00:00'));
                $oEndDate = new Date($oConnectionDate->format('%Y-%m-%d %H:00:00'));
                $oDal->_saveSummaryUpdateWithFinanceInfo($oStartDate, $oEndDate, $data_summary_table);
                if (!is_null($plugin)) {
                    $plugin->serviceLocatorRemove();
                }
            }
        }
    }
    if ($modified) {
        // Clear cache
        include_once 'Cache/Lite.php';
        $options = array('cacheDir' => MAX_CACHE);
        $cache = new Cache_Lite($options);
        $cache->clean(OX_getHostName() . 'stats');
    }
}
$addUrl = "entity=conversions&clientid={$clientId}&campaignid={$campaignId}&bannerid={$bannerId}&affiliateid={$affiliateId}&zoneid={$zoneId}";
if (!empty($period_preset)) {
    $addUrl .= "&period_preset={$period_preset}&period_start={$period_start}&period_end={$period_end}";
}
if (!empty($day)) {
    $addUrl .= "&day={$day}";
}
if (!empty($howLong)) {
    $addUrl .= "&howLong={$howLong}";
}
if (!empty($hour)) {
    $addUrl .= "&hour={$hour}";
}
/**
 * Processes submit values of campaign form
 *
 * @param OA_Admin_UI_Component_Form $form form to process
 * @return An array of Pear::Error objects if any
 */
function processCampaignForm($form, &$oComponent = null)
{
    $aFields = $form->exportValues();
    if (!empty($aFields['start'])) {
        $oDate = new Date(date('Y-m-d 00:00:00', strtotime($aFields['start'])));
        $oDate->toUTC();
        $activate = $oDate->getDate();
    } else {
        $oDate = new Date(date('Y-m-d 00:00:00'));
        $oDate->toUTC();
        $activate = $oDate->getDate();
    }
    if (!empty($aFields['end'])) {
        $oDate = new Date(date('Y-m-d 23:59:59', strtotime($aFields['end'])));
        $oDate->toUTC();
        $expire = $oDate->getDate();
    } else {
        $expire = null;
    }
    if (empty($aFields['campaignid'])) {
        // The form is submitting a new campaign, so, the ID is not set;
        // set the ID to the string "null" so that the table auto_increment
        // or sequence will be used when the campaign is created
        $aFields['campaignid'] = "null";
    } else {
        // The form is submitting a campaign modification; need to test
        // if any of the banners in the campaign are linked to an email zone,
        // and if so, if the link(s) would still be valid if the change(s)
        // to the campaign were made...
        $dalCampaigns = OA_Dal::factoryDAL('campaigns');
        $aCurrentLinkedEmalZoneIds = $dalCampaigns->getLinkedEmailZoneIds($aFields['campaignid']);
        if (PEAR::isError($aCurrentLinkedEmalZoneIds)) {
            OX::disableErrorHandling();
            $errors[] = PEAR::raiseError($GLOBALS['strErrorDBPlain']);
            OX::enableErrorHandling();
        }
        $errors = array();
        foreach ($aCurrentLinkedEmalZoneIds as $zoneId) {
            $thisLink = Admin_DA::_checkEmailZoneAdAssoc($zoneId, $aFields['campaignid'], $activate, $expire);
            if (PEAR::isError($thisLink)) {
                $errors[] = $thisLink;
                break;
            }
        }
    }
    //correct and check revenue and ecpm
    correctAdnCheckNumericFormField($aFields, $errors, 'revenue', $GLOBALS['strErrorEditingCampaignRevenue']);
    correctAdnCheckNumericFormField($aFields, $errors, 'ecpm', $GLOBALS['strErrorEditingCampaignECPM']);
    if (empty($errors)) {
        //check booked limits values
        // If this is a remnant, ecpm or exclusive campaign with an expiry date, set the target's to unlimited
        if (!empty($expire) && ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_ECPM || $aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_EXCLUSIVE)) {
            $aFields['impressions'] = $aFields['clicks'] = $aFields['conversions'] = -1;
        } else {
            if (!empty($aFields['impr_unlimited']) && $aFields['impr_unlimited'] == 't') {
                $aFields['impressions'] = -1;
            } else {
                if (empty($aFields['impressions']) || $aFields['impressions'] == '-') {
                    $aFields['impressions'] = 0;
                }
            }
            if (!empty($aFields['click_unlimited']) && $aFields['click_unlimited'] == 't') {
                $aFields['clicks'] = -1;
            } else {
                if (empty($aFields['clicks']) || $aFields['clicks'] == '-') {
                    $aFields['clicks'] = 0;
                }
            }
            if (!empty($aFields['conv_unlimited']) && $aFields['conv_unlimited'] == 't') {
                $aFields['conversions'] = -1;
            } else {
                if (empty($aFields['conversions']) || $aFields['conversions'] == '-') {
                    $aFields['conversions'] = 0;
                }
            }
        }
        //pricing model - reset fields not applicable to model to 0,
        //note that in new flow MAX_FINANCE_CPA allows all limits to be set
        if ($aFields['revenue_type'] == MAX_FINANCE_CPM) {
            $aFields['clicks'] = -1;
            $aFields['conversions'] = -1;
        } else {
            if ($aFields['revenue_type'] == MAX_FINANCE_CPC) {
                $aFields['conversions'] = -1;
            } else {
                if ($aFields['revenue_type'] == MAX_FINANCE_MT) {
                    $aFields['impressions'] = -1;
                    $aFields['clicks'] = -1;
                    $aFields['conversions'] = -1;
                }
            }
        }
        //check type and set priority
        if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_REMNANT) {
            $aFields['priority'] = 0;
            //low
        } else {
            if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_NORMAL) {
                $aFields['priority'] = isset($aFields['high_priority_value']) ? $aFields['high_priority_value'] : 5;
                //high
            } else {
                if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_CONTRACT_EXCLUSIVE) {
                    $aFields['priority'] = -1;
                    //exclusive
                } else {
                    if ($aFields['campaign_type'] == OX_CAMPAIGN_TYPE_ECPM) {
                        $aFields['priority'] = -2;
                        //ecpm
                    }
                }
            }
        }
        // Set target
        $target_impression = 0;
        $target_click = 0;
        $target_conversion = 0;
        if ($aFields['priority'] > 0) {
            // Daily targets need to be set only if the campaign doesn't have both expiration and lifetime targets
            $hasExpiration = !empty($expire);
            $hasLifetimeTargets = $aFields['impressions'] != -1 || $aFields['clicks'] != -1 || $aFields['conversions'] != -1;
            if (!($hasExpiration && $hasLifetimeTargets) && isset($aFields['target_value']) && $aFields['target_value'] != '-') {
                switch ($aFields['target_type']) {
                    case 'target_impression':
                        $target_impression = $aFields['target_value'];
                        break;
                    case 'target_click':
                        $target_click = $aFields['target_value'];
                        break;
                    case 'target_conversion':
                        $target_conversion = $aFields['target_value'];
                        break;
                }
            }
            $aFields['weight'] = 0;
        } else {
            // Set weight
            if (!isset($aFields['weight']) || $aFields['weight'] == '-' || $aFields['weight'] == '') {
                $aFields['weight'] = 0;
            }
        }
        if ($aFields['anonymous'] != 't') {
            $aFields['anonymous'] = 'f';
        }
        if ($aFields['companion'] != 1) {
            $aFields['companion'] = 0;
        }
        if ($aFields['show_capped_no_cookie'] != 1) {
            $aFields['show_capped_no_cookie'] = 0;
        }
        $new_campaign = $aFields['campaignid'] == 'null';
        if (empty($aFields['revenue']) || $aFields['revenue'] <= 0) {
            // No revenue information, set to null
            $aFields['revenue'] = OX_DATAOBJECT_NULL;
        }
        if (empty($aFields['ecpm']) || $aFields['ecpm'] <= 0) {
            // No ecpm information, set to null
            $aFields['ecpm'] = OX_DATAOBJECT_NULL;
        }
        // Get the capping variables
        $block = _initCappingVariables($aFields['time'], $aFields['capping'], $aFields['session_capping']);
        $doCampaigns = OA_Dal::factoryDO('campaigns');
        $doCampaigns->campaignname = $aFields['campaignname'];
        $doCampaigns->clientid = $aFields['clientid'];
        $doCampaigns->views = $aFields['impressions'];
        $doCampaigns->clicks = $aFields['clicks'];
        $doCampaigns->conversions = $aFields['conversions'];
        $doCampaigns->priority = $aFields['priority'];
        $doCampaigns->weight = $aFields['weight'];
        $doCampaigns->target_impression = $target_impression;
        $doCampaigns->target_click = $target_click;
        $doCampaigns->target_conversion = $target_conversion;
        $doCampaigns->min_impressions = $aFields['min_impressions'];
        $doCampaigns->ecpm = $aFields['ecpm'];
        $doCampaigns->anonymous = $aFields['anonymous'];
        $doCampaigns->companion = $aFields['companion'];
        $doCampaigns->show_capped_no_cookie = $aFields['show_capped_no_cookie'];
        $doCampaigns->comments = $aFields['comments'];
        $doCampaigns->revenue = $aFields['revenue'];
        $doCampaigns->revenue_type = $aFields['revenue_type'];
        $doCampaigns->block = $block;
        $doCampaigns->capping = $aFields['capping'];
        $doCampaigns->session_capping = $aFields['session_capping'];
        // Activation and expiration
        $doCampaigns->activate_time = isset($activate) ? $activate : OX_DATAOBJECT_NULL;
        $doCampaigns->expire_time = isset($expire) ? $expire : OX_DATAOBJECT_NULL;
        if (!empty($aFields['campaignid']) && $aFields['campaignid'] != "null") {
            $doCampaigns->campaignid = $aFields['campaignid'];
            $doCampaigns->setEcpmEnabled();
            $doCampaigns->update();
        } else {
            $doCampaigns->setEcpmEnabled();
            $aFields['campaignid'] = $doCampaigns->insert();
        }
        if ($oComponent) {
            $oComponent->processCampaignForm($aFields);
        }
        // Recalculate priority only when editing a campaign
        // or moving banners into a newly created, and when:
        //
        // - campaign changes status (activated or deactivated) or
        // - the campaign is active and target/weight are changed
        //
        if (!$new_campaign) {
            $doCampaigns = OA_Dal::staticGetDO('campaigns', $aFields['campaignid']);
            $status = $doCampaigns->status;
            switch (true) {
                case (bool) $status != (bool) $aFields['status_old']:
                    // Run the Maintenance Priority Engine process
                    OA_Maintenance_Priority::scheduleRun();
                    break;
                case $status == OA_ENTITY_STATUS_RUNNING:
                    if (!empty($aFields['target_type']) && ${$aFields['target_type']} != $aFields['target_old'] || !empty($aFields['target_type']) && $aFields['target_type_old'] != $aFields['target_type'] || $aFields['weight'] != $aFields['weight_old'] || $aFields['clicks'] != $aFields['previousclicks'] || $aFields['conversions'] != $aFields['previousconversions'] || $aFields['impressions'] != $aFields['previousimpressions']) {
                        // Run the Maintenance Priority Engine process
                        OA_Maintenance_Priority::scheduleRun();
                    }
                    break;
            }
        }
        // Rebuild cache
        // include_once MAX_PATH . '/lib/max/deliverycache/cache-'.$conf['delivery']['cache'].'.inc.php';
        // phpAds_cacheDelete();
        // Delete channel forecasting cache
        include_once 'Cache/Lite.php';
        $options = array('cacheDir' => MAX_CACHE);
        $cache = new Cache_Lite($options);
        $group = 'campaign_' . $aFields['campaignid'];
        $cache->clean($group);
        $translation = new OX_Translation();
        if ($new_campaign) {
            // Queue confirmation message
            $translated_message = $translation->translate($GLOBALS['strCampaignHasBeenAdded'], array(MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid']), htmlspecialchars($aFields['campaignname']), MAX::constructURL(MAX_URL_ADMIN, 'banner-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            OX_Admin_Redirect::redirect("advertiser-campaigns.php?clientid=" . $aFields['clientid']);
        } else {
            $translated_message = $translation->translate($GLOBALS['strCampaignHasBeenUpdated'], array(MAX::constructURL(MAX_URL_ADMIN, 'campaign-edit.php?clientid=' . $aFields['clientid'] . '&campaignid=' . $aFields['campaignid']), htmlspecialchars($aFields['campaignname'])));
            OA_Admin_UI::queueMessage($translated_message, 'local', 'confirm', 0);
            OX_Admin_Redirect::redirect("campaign-edit.php?clientid=" . $aFields['clientid'] . "&campaignid=" . $aFields['campaignid']);
        }
    }
    //return processing errors
    return $errors;
}
예제 #12
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //var_dump($GLOBALS[ "STEAM" ]->get_id());
     //		$portal = \lms_portal::get_instance();
     //		$portal->initialize( GUEST_NOT_ALLOWED );
     $user = \lms_steam::get_current_user();
     //		$path = $request->getPath();
     $STEAM = $GLOBALS["STEAM"];
     $weblogId = $this->id;
     $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId);
     //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) )
     //{
     //	include( "bad_link.php" );
     //	exit;
     //}
     if (!$weblog instanceof \steam_calendar) {
         if ($weblog instanceof \steam_container) {
             $category = $weblog;
             $categories = $category->get_environment();
             $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id());
         } elseif ($weblog instanceof \steam_date) {
             $date = $weblog;
             $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id());
         } else {
             include "bad_link.php";
             exit;
         }
     } else {
         $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId);
         define("OBJ_ID", $weblogId);
         if (!$weblog->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     $content = \Weblog::getInstance()->loadTemplate("weblog_entry_edit.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "weblog_entry_edit.template.html" );
     if ($_SERVER["REQUEST_METHOD"] == "GET") {
         $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST" && $date->check_access_write($user)) {
         $values = $_POST["values"];
         if (!empty($values["save"])) {
             $problem = "";
             $hint = "";
             if (empty($values["title"])) {
                 $problem .= gettext("The title is missing.") . "&nbsp;";
                 $hint .= gettext("Please add the missing values.");
             }
             if (empty($values["body"])) {
                 $problem .= gettext("There is no message for your readers.") . "&nbsp;";
                 $hint .= gettext("Please write your post into the text area.");
             }
             if (!empty($values["category"]) && $values["category"] != 0) {
                 $category = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $values["category"]);
                 if (!$category instanceof \steam_container) {
                     throw new \Exception("Not a valid category: " . $values["category"]);
                 }
             } else {
                 $category = "";
             }
             if (!($timestamp = strtotime($values["date"] . ":00"))) {
                 $problem .= gettext("I cannot parse the date and time.");
                 $hint .= gettext("Please verify your date and time format") . ": YYYY-MM-DD HH:MM";
             }
             if (empty($problem)) {
                 require_once "Cache/Lite.php";
                 $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
                 $cache->clean($weblog->get_id());
                 $cache->clean($date->get_id());
                 $attributes = array("DATE_START_DATE" => $timestamp, "DATE_TITLE" => $values["title"], "DATE_DESCRIPTION" => $values["body"]);
                 $date->set_attributes($attributes);
                 $weblog->categorize_entry($date, $category);
                 header("Location: " . $values["return_to"]);
                 exit;
             } else {
                 //TODO: PROBLEMDESCRIPTION
                 //$portal->set_problem_description( $problem, $hint );
             }
         }
         if ($values["preview"]) {
             $content->setCurrentBlock("BLOCK_PREVIEW");
             $content->setVariable("LABEL_PREVIEW_EDIT", gettext("Preview the edit"));
             $content->setVariable("PREVIEW_EDIT", get_formatted_output($values["body"]));
             $content->parse("BLOCK_PREVIEW");
         }
     }
     $content->setVariable("LABEL_HERE_IT_IS", "");
     $content->setVariable("LABEL_DATE", gettext("Date"));
     $content->setVariable("LABEL_SUBJECT", gettext("Subject"));
     $content->setVariable("LABEL_CATEGORY", gettext("Category"));
     $content->setVariable("CAT_NO_SELECTION", gettext("nothing selected"));
     $content->setVariable("LABEL_YOUR_POST", gettext("Your post"));
     $content->setVariable("LABEL_PREVIEW", gettext("Preview"));
     $content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes"));
     $content->setVariable("LABEL_RETURN", gettext("back"));
     $content->setVariable("LABEL_BB_BOLD", gettext("B"));
     $content->setVariable("HINT_BB_BOLD", gettext("boldface"));
     $content->setVariable("LABEL_BB_ITALIC", gettext("I"));
     $content->setVariable("HINT_BB_ITALIC", gettext("italic"));
     $content->setVariable("LABEL_BB_UNDERLINE", gettext("U"));
     $content->setVariable("HINT_BB_UNDERLINE", gettext("underline"));
     $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S"));
     $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough"));
     $content->setVariable("LABEL_BB_IMAGE", gettext("IMG"));
     $content->setVariable("HINT_BB_IMAGE", gettext("image"));
     $content->setVariable("LABEL_BB_URL", gettext("URL"));
     $content->setVariable("HINT_BB_URL", gettext("web link"));
     $content->setVariable("LABEL_BB_MAIL", gettext("MAIL"));
     $content->setVariable("HINT_BB_MAIL", gettext("email link"));
     if (isset($values) && count($values)) {
         // FORMULAR WURDE SCHON EINMAL ABGESCHICKT
         $date_value = empty($values["date"]) ? strftime("%Y-%m-%d %H:%M") : $values["date"];
         $content->setVariable("DATE_COMMENT", h($date_value));
         $content->setVariable("TEXT_COMMENT", h($values["body"]));
         $content->setVariable("TITLE_COMMENT", h($values["title"]));
         $cat = $values["category"];
         $content->setVariable("BACK_LINK", $values["return_to"]);
     } else {
         $attribs = $date->get_attributes(array("DATE_START_DATE", "DATE_TITLE", "DATE_DESCRIPTION", "DATE_CATEGORY"));
         $content->setVariable("DATE_COMMENT", strftime("%Y-%m-%d %H:%M", $attribs["DATE_START_DATE"]));
         $content->setVariable("TITLE_COMMENT", h($attribs["DATE_TITLE"]));
         $content->setVariable("TEXT_COMMENT", h($attribs["DATE_DESCRIPTION"]));
         $content->setVariable("TITLE_COMMENT", h($attribs["DATE_TITLE"]));
         $cat = is_object($attribs["DATE_CATEGORY"]) ? $attribs["DATE_CATEGORY"]->get_id() : 0;
     }
     $categories = $weblog->get_categories();
     foreach ($categories as $category) {
         $content->setCurrentBlock("BLOCK_SELECT_CAT");
         $content->setVariable("VALUE_CAT", $category->get_id());
         $content->setVariable("LABEL_CAT", h($category->get_name()));
         if ($category->get_id() == $cat) {
             $content->setVariable("CAT_SELECTED", 'selected="selected"');
         }
         $content->parse("BLOCK_SELECT_CAT");
     }
     $rootlink = \lms_steam::get_link_to_root($weblog);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/" . $weblog->get_id() . "/"), array("name" => str_replace("%NAME", h($date->get_attribute("DATE_TITLE")), gettext("Edit '%NAME'?"))));
     /*$portal->set_page_main(
     		$headline,
     		$content->get(),
     		""
     		);
     		return $portal->get_html();*/
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
예제 #13
0
$user = lms_steam::get_current_user();
if ($_SERVER["REQUEST_METHOD"] == "POST" && $object->check_access_write($user)) {
    $values = $_POST["values"];
    if ($values["delete"]) {
        $_SESSION["confirmation"] = str_replace("%NAME", h($object->get_name()), gettext("The forum '%NAME' has been deleted."));
        $workroom = $object->get_environment();
        lms_steam::delete($object);
        // Clean Cache for the deleted Forum
        require_once "Cache/Lite.php";
        $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE));
        $cache = get_cache_function(OBJ_ID, 600);
        $cache->drop("lms_steam::get_annotations", OBJ_ID);
        // Handle Related Cache-Data
        require_once "Cache/Lite.php";
        $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE));
        $cache->clean(OBJ_ID);
        // clean forum cache
        $fcache = get_cache_function(OBJ_ID, 600);
        $fcache->drop("lms_forum::get_discussions", OBJ_ID);
        // clean cache for forum RSS Feed for the Comments
        $fcache->drop("lms_steam::get_annotations", OBJ_ID);
        // clean rsscache
        $rcache = get_cache_function("rss", 600);
        $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID;
        $rcache->drop("lms_rss::get_items", $feedlink);
        // Clean communication summary cache für the group/course
        if (is_object($workroom)) {
            $cache = get_cache_function(lms_steam::get_current_user()->get_name(), 600);
            $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_MESSAGEBOARD, array("FORUM_LANGUAGE"));
            $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
        }
예제 #14
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $forum_id = $this->params[0];
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     $rss_feeds = $user->get_attribute("USER_RSS_FEEDS");
     if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) {
         include "bad_link.php";
         exit;
     }
     if ($messageboard instanceof \steam_document) {
         $thread = $messageboard;
         $messageboard = $thread->get_annotating();
         define("OBJ_ID", $thread->get_id());
         if (!$thread->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     } else {
         define("OBJ_ID", $messageboard->get_id());
         if (!$messageboard->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     if (!$messageboard instanceof \steam_messageboard) {
         include "bad_link.php";
         exit;
     }
     $is_watching = FALSE;
     if (is_array($rss_feeds)) {
         foreach (array_keys($rss_feeds) as $item) {
             if ($item == $messageboard->get_id()) {
                 $is_watching = TRUE;
             }
         }
     }
     $content = \Messageboard::getInstance()->loadTemplate("forum_post.template.html");
     $headline = gettext("Post a new topic");
     // TODO: Passt der link?
     $backlink = empty($_POST["values"]["backlink"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["backlink"];
     if ($_SERVER["REQUEST_METHOD"] == "POST") {
         $values = $_POST["values"];
         $problems = "";
         if (empty($values["title"])) {
             $problems = gettext("Please enter a subject for your message.");
         }
         if (empty($values["body"])) {
             $problems .= empty($problems) ? gettext("Please enter your message.") : "<br>" . gettext("Please enter your message.");
         }
         if (get_magic_quotes_gpc()) {
             if (!empty($values['title'])) {
                 $values['title'] = stripslashes($values['title']);
             }
             if (!empty($values['body'])) {
                 $values['body'] = stripslashes($values['body']);
             }
         }
         if (!empty($problems)) {
             $portal->set_problem_description($problems);
         }
         if (!empty($values["preview_comment"])) {
             $content->setCurrentBlock("BLOCK_PREVIEW_COMMENT");
             $content->setVariable("TEXT_COMMENT", get_formatted_output($values["body"]));
             $content->setVariable("LABEL_PREVIEW_YOUR_COMMENT", gettext("Preview your comment"));
             $template->parse("BLOCK_PREVIEW_COMMENT");
             $headline = gettext("Change it?");
         }
         if (!empty($values["save"]) && empty($problems)) {
             if (!strpos($values["title"], "/")) {
                 $new_thread = $messageboard->add_thread($values["title"], $values["body"]);
                 //      		$all_user = steam_factory::groupname_to_object( $GLOBALS[ "STEAM" ]->get_id(), STEAM_ALL_USER );
                 //      		$new_thread->set_acquire( FALSE );
                 //      		$new_thread->set_read_access( $all_user, TRUE );
                 //      		$new_thread->set_write_access( $all_user, FALSE );
                 //      		$new_thread->set_annotate_access( $all_user, TRUE );
                 // Handle Related Cache-Data
                 require_once "Cache/Lite.php";
                 $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
                 $cache->clean(OBJ_ID);
                 // clean forumcache
                 $fcache = get_cache_function($forum_id, 600);
                 $fcache->drop("lms_forum::get_discussions", $forum_id);
                 // clean rsscache of the forum
                 // TODO: Passt der link?
                 $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . $forum_id;
                 $rcache = get_cache_function("rss", 600);
                 $rcache->drop("lms_rss::get_items", $feedlink);
                 header("Location: " . PATH_URL . "messageboard/viewDiscussion/" . $new_thread->get_id() . "/");
                 exit;
             } else {
                 $portal->set_problem_description(gettext("Please don't use the \"/\"-char in the title."));
             }
         }
         if (!empty($values["preview"]) && !empty($values['body'])) {
             // PREVIEW
             $content->setCurrentBlock("BLOCK_PREVIEW");
             $content->setVariable("LABEL_PREVIEW_EDIT", gettext("Preview the edit"));
             $content->setVariable("PREVIEW_EDIT", get_formatted_output($values["body"]));
             $content->parse("BLOCK_PREVIEW");
             $headline = gettext("Change it?");
         }
     }
     $subject = isset($values["title"]) ? htmlentities($values["title"], ENT_NOQUOTES, "utf-8") : "";
     $text = isset($values["body"]) ? htmlentities($values["body"], ENT_NOQUOTES, "utf-8") : "";
     $content->setVariable("INFO_TEXT", $headline);
     $content->setVariable("LABEL_TOPIC", gettext("Topic"));
     $content->setVariable("LABEL_YOUR_POST", gettext("Your Post"));
     $content->setVariable("TEXT_COMMENT", $text);
     $content->setVariable("TITLE_COMMENT", $subject);
     $content->setVariable("LABEL_PREVIEW", gettext("Preview"));
     $content->setVariable("LABEL_SAVE_CHANGES", gettext("Create entry"));
     $content->setVariable("VALUE_BACKLINK", $backlink);
     $content->setVariable("BACKLINK", "<a href=\"{$backlink}\">" . gettext("back") . "</a>");
     $content->setVariable("LABEL_BB_BOLD", gettext("B"));
     $content->setVariable("HINT_BB_BOLD", gettext("boldface"));
     $content->setVariable("LABEL_BB_ITALIC", gettext("I"));
     $content->setVariable("HINT_BB_ITALIC", gettext("italic"));
     $content->setVariable("LABEL_BB_UNDERLINE", gettext("U"));
     $content->setVariable("HINT_BB_UNDERLINE", gettext("underline"));
     $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S"));
     $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough"));
     $content->setVariable("LABEL_BB_IMAGE", gettext("IMG"));
     $content->setVariable("HINT_BB_IMAGE", gettext("image"));
     $content->setVariable("LABEL_BB_URL", gettext("URL"));
     $content->setVariable("HINT_BB_URL", gettext("web link"));
     $content->setVariable("LABEL_BB_MAIL", gettext("MAIL"));
     $content->setVariable("HINT_BB_MAIL", gettext("email link"));
     $portal->set_rss_feed(PATH_URL . "services/feeds/forum_public.php?id={$forum_id}", gettext("Feed"), str_replace("%l", $login, gettext("Subscribe to this forum's Newsfeed")));
     // TODO: Passt der link?
     $rootlink = \lms_steam::get_link_to_root($messageboard);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name()), array("link" => "", "name" => gettext("New Thread")));
     $frameResponseObject->setTitle("Messageboard");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
예제 #15
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //		$portal = \lms_portal::get_instance();
     //	$portal->initialize( GUEST_NOT_ALLOWED );
     $user = \lms_steam::get_current_user();
     //$path = $request->getPath();
     $STEAM = $GLOBALS["STEAM"];
     $weblogId = $this->id;
     $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId);
     //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) )
     //{
     //	include( "bad_link.php" );
     //	exit;
     //}
     if (!$weblog instanceof \steam_calendar) {
         if ($weblog instanceof \steam_container) {
             $category = $weblog;
             $categories = $category->get_environment();
             $weblog = new \steam_weblog($GLOBALS["STEAM"], $categories->get_environment()->get_id());
         } elseif ($weblog instanceof \steam_date) {
             $date = $weblog;
             $weblog = new \steam_weblog($GLOBALS["STEAM"], $date->get_environment()->get_id());
         } else {
             include "bad_link.php";
             exit;
         }
     } else {
         $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId);
         if (!defined("OBJ_ID")) {
             define("OBJ_ID", $weblogId);
         }
         if (!$weblog->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     if ($_SERVER["REQUEST_METHOD"] == "POST" && $category->check_access_write($user)) {
         $values = $_POST["values"];
         if ($values["delete"]) {
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache->clean($weblog->get_id());
             $link_objects = $category->get_inventory(CLASS_LINK);
             foreach ($link_objects as $link_object) {
                 $date_object = $link_object->get_source_object();
                 $link_object->delete();
                 if ($values["delete_all_dates"]) {
                     $date_object->delete();
                 } else {
                     $date_object->set_attribute("DATE_CATEGORY", "0");
                 }
             }
             $category->delete();
         }
         header("Location: " . PATH_URL . "weblog/" . $weblog->get_id() . "/");
         exit;
     }
     $content = \Weblog::getInstance()->loadTemplate("weblog_category_delete.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "weblog_category_delete.template.html" );
     $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure you want to delete this category?"));
     $content->setVariable("NAME_CATEGORY", h($category->get_name()));
     $content->setVariable("TEXT_CATEGORY", get_formatted_output($category->get_attribute("OBJ_DESC")));
     $content->setVariable("LABEL_DELETE_ALL_DATES", str_replace("%NO", count($category->get_inventory(CLASS_LINK)), gettext("Should all %NO entries in this category be deleted, too?")));
     $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it"));
     $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
     $content->setVariable("LABEL_RETURN", gettext("back"));
     $rootlink = \lms_steam::get_link_to_root($weblog);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/" . $weblog->get_id() . "/"), array("link" => PATH_URL . "weblog/" . $category->get_id() . "/", "name" => h($category->get_name())), array("link" => "", "name" => str_replace("%NAME", h($category->get_name()), gettext("Delete '%NAME'?"))));
     /*$portal->set_page_main(
     		$headline,
     		$content->get(),
     	""
     		);
     		return $portal->get_html();*/
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
예제 #16
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     if (!defined("OBJ_ID")) {
         define("OBJ_ID", $weblog->get_id());
     }
     $user = \lms_steam::get_current_user();
     $STEAM = $GLOBALS["STEAM"];
     $weblogId = $this->id;
     $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId);
     if (!defined("OBJ_ID")) {
         define("OBJ_ID", $weblog->get_id());
     }
     /*if ( ! $weblog = \steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) )
     		{	
     			include( "bad_link.php" );
     			exit;
     		}*/
     if (!$weblog instanceof \steam_calendar) {
         if ($weblog instanceof \steam_container) {
             $category = $weblog;
             $categories = $category->get_environment();
             $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id());
         } elseif ($weblog instanceof \steam_date) {
             $date = $weblog;
             $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id());
         } else {
             include "bad_link.php";
             exit;
         }
     } else {
         $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $weblogId);
         //define( "OBJ_ID",	$weblogId );
         if (!$weblog->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     $object = $weblog;
     $user = \lms_steam::get_current_user();
     if ($_SERVER["REQUEST_METHOD"] == "POST" && $object->check_access_write($user)) {
         $values = $_POST["values"];
         if ($values["delete"]) {
             $_SESSION["confirmation"] = str_replace("%NAME", h($object->get_name()), gettext("The weblog '%NAME' has been deleted."));
             $workroom = $object->get_environment();
             \lms_steam::delete($object);
             // Clean Cache for the deleted Weblog
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache = get_cache_function(OBJ_ID, 600);
             $cache->drop("lms_steam::get_annotations", OBJ_ID);
             // Handle Related Cache-Data
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache->clean(OBJ_ID);
             // clean weblog cache (not used by weblog)
             // $fcache = get_cache_function( OBJ_ID, 600 );
             //$fcache->drop( "lms_forum::get_discussions",  OBJ_ID );
             // clean cache for Weblog RSS Feed for the Comments (not used by weblog)
             // $fcache->drop( "lms_steam::get_annotations", OBJ_ID );
             // clean rsscache
             $rcache = get_cache_function("rss", 600);
             $feedlink = PATH_URL . "services/feeds/weblog_public.php?id=" . OBJ_ID;
             $rcache->drop("lms_rss::get_items", $feedlink);
             // Clean communication summary cache für the group/course
             if (is_object($workroom)) {
                 $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600);
                 $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_CALENDAR, array("WEBLOG_LANGUAGE"));
                 $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
             }
             header("Location: " . $values["return_to"]);
             exit;
         }
     }
     $content = \Weblog::getInstance()->loadTemplate("object_delete.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "object_delete.template.html" );
     if ($object->check_access_write($user)) {
         $content->setVariable("LABEL_ARE_YOU_SURE", str_replace("%NAME", h($object->get_name()), gettext("Are you sure you want to delete the weblog '%NAME' ?")));
         $rootlink = \lms_steam::get_link_to_root($object);
         $content->setVariable("DELETE_BACK_LINK", $rootlink[1]["link"] . "communication/");
         $content->setCurrentBlock("BLOCK_DELETE");
         $content->setVariable("FORM_ACTION", $_SERVER["REQUEST_URI"]);
         $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it"));
         $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
         $content->setVariable("LABEL_RETURN", gettext("back"));
         $content->parse("BLOCK_DELETE");
     } else {
         $content->setVariable("LABEL_ARE_YOU_SURE", gettext("You have no rights to delete this weblog!"));
     }
     $content->setVariable("TEXT_INFORMATION", gettext("The weblog and all its entries will be deleted."));
     $creator = $object->get_creator();
     $creator_data = $creator->get_attributes(array("USER_FULLNAME", "USER_FIRSTNAME", "OBJ_ICON"));
     $content->setVariable("LABEL_FROM_AND_AGO", str_replace("%N", "<a href=\"" . PATH_URL . "/user/" . $creator->get_name() . "/\">" . h($creator_data["USER_FIRSTNAME"]) . " " . h($creator_data["USER_FULLNAME"]) . "</a>", gettext("by %N")) . "," . how_long_ago($object->get_attribute("OBJ_CREATION_TIME")));
     $icon = $creator_data["OBJ_ICON"];
     if ($icon instanceof steam_object) {
         $icon_id = $icon->get_id();
     } else {
         $icon_id = 0;
     }
     $content->setVariable("ICON_SRC", PATH_URL . "get_document.php?id=" . $icon_id);
     $rootlink = \lms_steam::get_link_to_root($object);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($object->get_name()), "link" => PATH_URL . "weblog/" . $object->get_id() . "/"), array("name" => gettext("Delete weblog")));
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
     /*$portal->set_page_main(
     		$headline,
     		$content->get(),
     		""
     		);
     		$portal->show_html();*/
 }
예제 #17
0
     $portal->set_problem_description(gettext("Please enter your message."));
 }
 if (!empty($values["save"]) && !empty($values["body"])) {
     $new_comment = steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), "Re: " . $thread->get_name(), $values["body"]);
     //		$all_user = steam_factory::groupname_to_object( $GLOBALS[ "STEAM" ]->get_id(), STEAM_ALL_USER );
     //		$new_comment->set_acquire( FALSE );
     //		$new_comment->set_read_access( $all_user, TRUE );
     //		$new_comment->set_write_access( $all_user, FALSE );
     //		$new_comment->set_annotate_access( $all_user, TRUE );
     $thread->add_annotation($new_comment);
     $new_comment->set_acquire($thread);
     $mbid = $messageboard->get_id();
     // Handle Related Cache-Data
     require_once "Cache/Lite.php";
     $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE));
     $cache->clean($mbid);
     // clean forumcache
     $fcache = get_cache_function($_GET["id"], 600);
     $fcache->drop("lms_forum::get_discussions", $_GET["id"]);
     // clean forumcache
     $fcache = get_cache_function($mbid, 600);
     $fcache->drop("lms_forum::get_discussions", $mbid);
     // clean rsscache of the forum
     $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID;
     $rcache = get_cache_function("rss", 600);
     $rcache->drop("lms_rss::get_items", $feedlink);
 } else {
     if (empty($values["save"]) && !empty($values["body"])) {
         // PREVIEW
         $content->setCurrentBlock("BLOCK_PREVIEW_COMMENT");
         $content->setVariable("LABEL_PREVIEW_COMMENT", gettext("Preview the edit"));
예제 #18
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //CODE FOR ALL COMMANDS OF THIS PACKAGE START
     $user = \lms_steam::get_current_user();
     // Disable caching
     // TODO: Work on cache handling. An enabled cache leads to bugs
     // if used with the wiki.
     \CacheSettings::disable_caching();
     if (!($wiki_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id))) {
         include "bad_link.php";
         exit;
     }
     if (!$wiki_container instanceof \steam_container) {
         $wiki_doc = $wiki_container;
         $wiki_container = $wiki_doc->get_environment();
         if ($wiki_doc->get_attribute(DOC_MIME_TYPE) != "text/wiki") {
             include "bad_link.php";
             exit;
         }
     }
     //CODE FOR ALL COMMANDS OF THIS PACKAGE END
     $object = $wiki_container;
     $user = \lms_steam::get_current_user();
     if ($_SERVER["REQUEST_METHOD"] == "POST" && $object->check_access_write($user)) {
         $values = $_POST["values"];
         if ($values["delete"]) {
             $_SESSION["confirmation"] = str_replace("%NAME", h($object->get_name()), gettext("The wiki '%NAME' has been deleted."));
             $workroom = $object->get_environment();
             \lms_steam::delete($object);
             $wid = $object->get_id();
             // Clean Cache for the deleted wiki
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache = get_cache_function($wid, 600);
             $cache->drop("lms_steam::get_items", $wid);
             // Handle Related Cache-Data
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache->clean($wid);
             // clean wiki cache (not used by wiki)
             $fcache = get_cache_function($object->get_id(), 600);
             $fcache->drop("lms_wiki::get_items", $object->get_id());
             // Clean communication summary cache für the group/course
             if (is_object($workroom)) {
                 $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600);
                 $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_CONTAINER | CLASS_ROOM, array("OBJ_TYPE", "WIKI_LANGUAGE"));
                 $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
                 // clean rsscache
                 $rcache = get_cache_function("rss", 600);
                 $feedlink = PATH_URL . "services/feeds/wiki_public.php?id=" . $wid;
                 $rcache->drop("lms_rss::get_items", $feedlink);
             }
             header("Location: " . $values["return_to"]);
             exit;
         }
     }
     $content = \Wiki::getInstance()->loadTemplate("object_delete.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "object_delete.template.html" );
     if ($object->check_access_write($user)) {
         $content->setVariable("LABEL_ARE_YOU_SURE", str_replace("%NAME", h($object->get_name()), gettext("Are you sure you want to delete the wiki '%NAME' ?")));
         $rootlink = \lms_steam::get_link_to_root($object);
         $content->setVariable("DELETE_BACK_LINK", $rootlink[1]["link"] . "communication/");
         $content->setCurrentBlock("BLOCK_DELETE");
         $content->setVariable("FORM_ACTION", $_SERVER["REQUEST_URI"]);
         $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it"));
         $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
         $content->setVariable("LABEL_RETURN", gettext("back"));
         $content->parse("BLOCK_DELETE");
     } else {
         $content->setVariable("LABEL_ARE_YOU_SURE", gettext("You have no rights to delete this wiki!"));
     }
     $content->setVariable("TEXT_INFORMATION", gettext("The Wiki and all its entries will be deleted."));
     $creator = $object->get_creator();
     $creator_data = $creator->get_attributes(array("USER_FULLNAME", "USER_FIRSTNAME", "OBJ_ICON"));
     $content->setVariable("LABEL_FROM_AND_AGO", str_replace("%N", "<a href=\"" . PATH_URL . "/user/" . $creator->get_name() . "/\">" . h($creator_data["USER_FIRSTNAME"]) . " " . h($creator_data["USER_FULLNAME"]) . "</a>", gettext("by %N")) . "," . how_long_ago($object->get_attribute("OBJ_CREATION_TIME")));
     $icon = $creator_data["OBJ_ICON"];
     if ($icon instanceof \steam_object) {
         $icon_id = $icon->get_id();
     } else {
         $icon_id = 0;
     }
     $content->setVariable("ICON_SRC", PATH_URL . "get_document.php?id=" . $icon_id);
     $rootlink = \lms_steam::get_link_to_root($wiki_container);
     WIKI_FULL_HEADLINE ? $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("name" => gettext("Delete wiki"), "link" => "")) : ($headline = array(array("name" => h($wiki_container->get_name()), "link" => PATH_URL . "wiki/index/" . $wiki_container->get_id() . "/"), array("name" => gettext("Delete wiki"), "link" => "")));
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
     /*
     		 $portal->set_page_main(
     		 $headline,
     		 $content->get(),
     		 ""
     		 );
     		 $portal->show_html();*/
 }
예제 #19
0
function serendipity_cleanCache()
{
    include_once 'Cache/Lite.php';
    if (!class_exists('Cache_Lite')) {
        return false;
    }
    $options = array('cacheDir' => $serendipity['serendipityPath'] . 'templates_c/', 'lifeTime' => 3600, 'hashedDirectoryLevel' => 2);
    $cache = new Cache_Lite($options);
    $successFetch = $cache->clean("fetchEntries");
    $successPrint = $cache->clean("printEntries");
    return $successFetch && $successPrint;
}
예제 #20
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $forum_id = $this->params[0];
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     $rss_feeds = $user->get_attribute("USER_RSS_FEEDS");
     if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) {
         include "bad_link.php";
         exit;
     }
     if ($messageboard instanceof \steam_document) {
         $thread = $messageboard;
         $messageboard = $thread->get_annotating();
         define("OBJ_ID", $thread->get_id());
         if (!$thread->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     } else {
         define("OBJ_ID", $messageboard->get_id());
         if (!$messageboard->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     if (!$messageboard instanceof \steam_messageboard) {
         include "bad_link.php";
         exit;
     }
     $is_watching = FALSE;
     if (is_array($rss_feeds)) {
         foreach (array_keys($rss_feeds) as $item) {
             if ($item == $messageboard->get_id()) {
                 $is_watching = TRUE;
             }
         }
     }
     $content = \Messageboard::getInstance()->loadTemplate("forum_discussion.template.html");
     $content->setVariable("REPLY_LABEL", gettext("Reply to this topic?"));
     if ($_SERVER["REQUEST_METHOD"] == "POST" && $thread->check_access_annotate(\lms_steam::get_current_user())) {
         $values = $_POST["values"];
         if (empty($values["body"])) {
             $portal->set_problem_description(gettext("Please enter your message."));
         }
         if (!empty($values["save"]) && !empty($values["body"])) {
             $new_comment = \steam_factory::create_textdoc($GLOBALS["STEAM"]->get_id(), "Re: " . $thread->get_name(), $values["body"]);
             //		$all_user = steam_factory::groupname_to_object( $GLOBALS[ "STEAM" ]->get_id(), STEAM_ALL_USER );
             //		$new_comment->set_acquire( FALSE );
             //		$new_comment->set_read_access( $all_user, TRUE );
             //		$new_comment->set_write_access( $all_user, FALSE );
             //		$new_comment->set_annotate_access( $all_user, TRUE );
             $thread->add_annotation($new_comment);
             $new_comment->set_acquire($thread);
             $mbid = $messageboard->get_id();
             // Handle Related Cache-Data
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache->clean($mbid);
             // clean forumcache
             $fcache = get_cache_function($forum_id, 600);
             $fcache->drop("lms_forum::get_discussions", $forum_id);
             // clean forumcache
             $fcache = get_cache_function($mbid, 600);
             $fcache->drop("lms_forum::get_discussions", $mbid);
             // clean rsscache of the forum
             // TODO: Passt der link?
             $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID;
             $rcache = get_cache_function("rss", 600);
             $rcache->drop("lms_rss::get_items", $feedlink);
         } else {
             if (empty($values["save"]) && !empty($values["body"])) {
                 // PREVIEW
                 $content->setCurrentBlock("BLOCK_PREVIEW_COMMENT");
                 $content->setVariable("LABEL_PREVIEW_COMMENT", gettext("Preview the edit"));
                 $content->setVariable("VALUE_PREVIEW_COMMENT", get_formatted_output($values["body"]));
                 $content->setVariable("TEXT_COMMENT", h($values["body"]));
                 $content->parse("BLOCK_PREVIEW_COMMENT");
                 $content->setVariable("REPLY_LABEL", gettext("Change it?"));
             }
         }
     }
     if (isset($_GET["action"]) && $_GET["action"] == "bookmark_rss") {
         \lms_steam::user_add_rssfeed($messageboard->get_id(), PATH_URL . "services/feeds/forum_public.php?id=" . $messageboard->get_id(), "discussion board", \lms_steam::get_link_to_root($messageboard));
         $_SESSION["confirmation"] = str_replace("%NAME", h($messageboard->get_name()), gettext("You are keeping an eye on '%NAME' from now on."));
         header("Location: " . PATH_URL . "forums/" . $thread->get_id() . "/");
         exit;
     }
     if (isset($_GET["action"]) && $_GET["action"] == "delete_bookmark") {
         $user = \lms_steam::get_current_user();
         $id = (int) $_GET["unsubscribe"];
         $feeds = $user->get_attribute("USER_RSS_FEEDS");
         if (!is_array($feeds)) {
             $feeds = array();
         }
         unset($feeds[$id]);
         $user->set_attribute("USER_RSS_FEEDS", $feeds);
         $_SESSION["confirmation"] = str_replace("%NAME", h($messageboard->get_name()), gettext("subscription of '%NAME' canceled."));
         header("Location: " . PATH_URL . "forums/" . $thread->get_id() . "/");
         exit;
     }
     $content->setVariable("CURRENT_DISCUSSIONS_LABEL", gettext("Current Thread"));
     $cache = get_cache_function($messageboard->get_id(), 600);
     $discussions = $cache->call("lms_forum::get_discussions", $messageboard->get_id());
     $max_discussions = 12;
     foreach ($discussions as $discussion) {
         $max_discussions--;
         if ($max_discussions == 0) {
             $content->setCurrentBlock("BLOCK_TOPIC_INFO");
             $content->setVariable("TOPIC_LINK", PATH_URL . "forums/" . $messageboard->get_id() . "/");
             $content->setVariable("TOPIC_TITLE", gettext("More..."));
             $content->parse("BLOCK_TOPIC_INFO");
             break;
         }
         $content->setCurrentBlock("BLOCK_TOPIC_INFO");
         if (time() - $discussion["LATEST_POST_TS"] > $_SESSION["last_login"]) {
             $content->setCurrentBlock("BLOCK_TOPIC_NEW");
             $content->setVariable("NEW_LABEL", gettext("New"));
             $content->parse("BLOCK_TOPIC_NEW");
         }
         $content->setVariable("TOPIC_LINK", PATH_URL . "messageboard/viewDiscussion/" . $discussion["OBJ_ID"] . "/");
         $content->setVariable("TOPIC_TITLE", h($discussion["OBJ_NAME"]));
         $content->setVariable("TOPIC_LAST_ENTRY", gettext("Latest:") . how_long_ago($discussion["LATEST_POST_TS"]));
         $content->parse("BLOCK_TOPIC_INFO");
     }
     $content->setVariable("LABEL_TOPICS_POSTED", gettext("Topics you've posted in"));
     $content->setVariable("LINK_AUTHOR", PATH_URL . "forums/" . $messageboard->get_id() . "/?author=" . \lms_steam::get_current_user()->get_name());
     $content->setVariable("LABEL_POST_NEW", gettext("Post a new topic"));
     $content->setVariable("LINK_POST_NEW", PATH_URL . "messageboard/newDiscussion/" . $messageboard->get_id());
     $content->setCurrentBlock("BLOCK_WATCH");
     if ($is_watching) {
         $content->setVariable("LABEL_BOOKMARK", gettext("End watching"));
         $content->setVariable("LINK_BOOKMARK", PATH_URL . "forums/" . $thread->get_id() . "/?action=delete_bookmark&unsubscribe=" . $messageboard->get_id());
     } else {
         $content->setVariable("LABEL_BOOKMARK", gettext("Watch this forum"));
         $content->setVariable("LINK_BOOKMARK", PATH_URL . "forums/" . $thread->get_id() . "/?action=bookmark_rss");
     }
     $content->parse("BLOCK_WATCH");
     $content->setVariable("DISCUSSION_SUBJECT", h($thread->get_name()));
     $author = $thread->get_creator();
     $author_data = $author->get_attributes(array("OBJ_NAME", "USER_FIRSTNAME", "USER_FULLNAME", "OBJ_ICON"));
     $content->setVariable("AUTHOR_LINK", PATH_URL . "user/" . $author_data["OBJ_NAME"] . "/");
     $icon = $author_data["OBJ_ICON"];
     if ($icon instanceof \steam_object) {
         $icon_id = $icon->get_id();
     } else {
         $icon_id = 0;
     }
     $content->setVariable("AUTHOR_IMAGE", PATH_URL . "cached/get_document.php?id=" . $icon_id . "&type=usericon&width=60&height=70");
     $content->setVariable("NAME_SAYS_LABEL", str_replace("%n", "<a href=\"" . PATH_URL . "user/" . $author_data["OBJ_NAME"] . "/\">" . h($author_data["USER_FIRSTNAME"]) . " " . h($author_data["USER_FULLNAME"]) . "</a>", gettext("%n says:")));
     $content->setVariable("DISCUSSION_TEXT", get_formatted_output($thread->get_content(), 65, "\n"));
     $ts = $thread->get_attribute("OBJ_CREATION_TIME");
     $content->setVariable("DISCUSSION_STARTED_TS", gettext("Posted at") . " " . strftime("%H:%M", $ts) . " | " . strftime("%d. %B %Y", $ts));
     $content->setVariable("DISCUSSION_PERMALINK", PATH_URL . 'forums/' . $discussion['OBJ_ID'] . '/');
     $content->setVariable("DISCUSSION_PERMALINK_TEXT", gettext("permalink"));
     $steam_user = \lms_steam::get_current_user();
     if ($thread->check_access_write($steam_user)) {
         $content->setCurrentBlock("BLOCK_OWN_DISCUSSION");
         $content->setVariable("DISCUSSION_LINK_DELETE", PATH_URL . "messageboard/deleteComment/" . $messageboard->get_id() . "/" . $thread->get_id());
         $content->setVariable("DISCUSSION_LABEL_DELETE", gettext("delete"));
         $content->setVariable("DISCUSSION_LINK_EDIT", PATH_URL . "messageboard/editComment/" . $thread->get_id() . "/" . $thread->get_id());
         $content->setVariable("DISCUSSION_LABEL_EDIT", gettext("edit"));
         $content->parse("BLOCK_OWN_DISCUSSION");
     }
     $annotations = \lms_steam::get_annotations($thread->get_id());
     $annotations = array_reverse($annotations);
     $access_tnr = array();
     foreach ($annotations as $annotation) {
         $steam_obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $annotation["OBJ_ID"], CLASS_OBJECT);
         $access_tnr[$steam_obj->get_id()] = $steam_obj->check_access_write($steam_user, TRUE);
     }
     $access_result = $GLOBALS["STEAM"]->buffer_flush();
     foreach ($annotations as $annotation) {
         $content->setCurrentBlock("REPLY");
         $content->setVariable('REPLY_ID', $annotation['OBJ_ID']);
         $content->setVariable("REPLYER_LINK", PATH_URL . "user/" . $annotation["OBJ_CREATOR_LOGIN"] . "/");
         $content->setVariable("REPLYER_IMAGE", PATH_URL . "cached/get_document.php?id=" . $annotation["OBJ_ICON"] . "&type=usericon&width=60&height=70");
         $content->setVariable("REPLYER_SAYS_LABEL", str_replace("%n", "<a href=\"" . PATH_URL . "user/" . $annotation["OBJ_CREATOR_LOGIN"] . "/\">" . h($annotation["OBJ_CREATOR"]) . "</a>", gettext("%n says:")));
         //$content->setVariable( "REPLYERS_SAYS_LABEL", str_replace );
         $content->setVariable("REPLY_CONTENT", get_formatted_output($annotation["CONTENT"], 60, "\n"));
         $content->setVariable("REPLY_TS", how_long_ago($annotation["OBJ_CREATION_TIME"]));
         $content->setVariable("REPLY_PERMALINK", PATH_URL . 'forums/' . $thread->get_id() . '/#comment' . $annotation['OBJ_ID']);
         $content->setVariable("REPLY_PERMALINK_TEXT", gettext("permalink"));
         $steam_obj = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $annotation["OBJ_ID"], CLASS_OBJECT);
         if ($access_result[$access_tnr[$steam_obj->get_id()]]) {
             $content->setCurrentBlock("BLOCK_OWN_REPLY");
             $content->setVariable("REPLY_LINK_DELETE", PATH_URL . "messageboard/deleteComment/" . $thread->get_id() . "/" . $annotation["OBJ_ID"] . "/");
             $content->setVariable("REPLY_LABEL_DELETE", gettext("delete"));
             $content->setVariable("REPLY_LABEL_EDIT", gettext("edit"));
             $content->setVariable("REPLY_LINK_EDIT", PATH_URL . "messageboard/editComment/" . $thread->get_id() . "/" . $annotation["OBJ_ID"] . "/");
             $content->parse("BLOCK_OWN_REPLY");
         }
         $content->parse("REPLY");
     }
     $content->setVariable("LABEL_BB_BOLD", gettext("B"));
     $content->setVariable("HINT_BB_BOLD", gettext("boldface"));
     $content->setVariable("LABEL_BB_ITALIC", gettext("I"));
     $content->setVariable("HINT_BB_ITALIC", gettext("italic"));
     $content->setVariable("LABEL_BB_UNDERLINE", gettext("U"));
     $content->setVariable("HINT_BB_UNDERLINE", gettext("underline"));
     $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S"));
     $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough"));
     $content->setVariable("LABEL_BB_IMAGE", gettext("IMG"));
     $content->setVariable("HINT_BB_IMAGE", gettext("image"));
     $content->setVariable("LABEL_BB_URL", gettext("URL"));
     $content->setVariable("HINT_BB_URL", gettext("web link"));
     $content->setVariable("LABEL_BB_MAIL", gettext("MAIL"));
     $content->setVariable("HINT_BB_MAIL", gettext("email link"));
     $content->setVariable("LABEL_PREVIEW", gettext("Preview"));
     $content->setVariable("LABEL_OR", gettext("or"));
     $content->setVariable("LABEL_POST_NOW", gettext("Post now"));
     $portal->set_rss_feed(PATH_URL . "services/feeds/discussion_public.php?id=" . OBJ_ID, gettext("Feed"), gettext("Subscribe to this forum's Newsfeed"));
     // TODO: Passt der link?
     $rootlink = \lms_steam::get_link_to_root($messageboard);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name()), array("link" => "", "name" => gettext("Discussion")));
     $frameResponseObject->setTitle("Messageboard");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
예제 #21
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $forum_id = $this->params[0];
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     $rss_feeds = $user->get_attribute("USER_RSS_FEEDS");
     if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) {
         include "bad_link.php";
         exit;
     }
     if ($messageboard instanceof \steam_document) {
         $thread = $messageboard;
         $messageboard = $thread->get_annotating();
         define("OBJ_ID", $thread->get_id());
         if (!$thread->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     } else {
         define("OBJ_ID", $messageboard->get_id());
         if (!$messageboard->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     if (!$messageboard instanceof \steam_messageboard) {
         include "bad_link.php";
         exit;
     }
     $is_watching = FALSE;
     if (is_array($rss_feeds)) {
         foreach (array_keys($rss_feeds) as $item) {
             if ($item == $messageboard->get_id()) {
                 $is_watching = TRUE;
             }
         }
     }
     $object = $messageboard;
     $user = \lms_steam::get_current_user();
     if ($_SERVER["REQUEST_METHOD"] == "POST" && $object->check_access_write($user)) {
         $values = $_POST["values"];
         if ($values["delete"]) {
             $_SESSION["confirmation"] = str_replace("%NAME", h($object->get_name()), gettext("The forum '%NAME' has been deleted."));
             $workroom = $object->get_environment();
             \lms_steam::delete($object);
             // Clean Cache for the deleted Forum
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache = get_cache_function(OBJ_ID, 600);
             $cache->drop("lms_steam::get_annotations", OBJ_ID);
             // Handle Related Cache-Data
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache->clean(OBJ_ID);
             // clean forum cache
             $fcache = get_cache_function(OBJ_ID, 600);
             $fcache->drop("lms_forum::get_discussions", OBJ_ID);
             // clean cache for forum RSS Feed for the Comments
             $fcache->drop("lms_steam::get_annotations", OBJ_ID);
             // clean rsscache
             $rcache = get_cache_function("rss", 600);
             // TODO: Passt der link?
             $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID;
             $rcache->drop("lms_rss::get_items", $feedlink);
             // Clean communication summary cache für the group/course
             if (is_object($workroom)) {
                 $cache = get_cache_function(\lms_steam::get_current_user()->get_name(), 600);
                 $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_MESSAGEBOARD, array("FORUM_LANGUAGE"));
                 $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
             }
             header("Location: " . PATH_URL . "group/index");
             exit;
         }
     }
     $content = \Messageboard::getInstance()->loadTemplate("object_delete.template.html");
     if ($object->check_access_write($user)) {
         $content->setVariable("LABEL_ARE_YOU_SURE", str_replace("%NAME", h($object->get_name()), gettext("Are you sure you want to delete the forum '%NAME' ?")));
         // TODO: Passt der link?
         $rootlink = \lms_steam::get_link_to_root($object);
         $content->setVariable("DELETE_BACK_LINK", $rootlink[1]["link"] . "communication/");
         $content->setCurrentBlock("BLOCK_DELETE");
         $content->setVariable("FORM_ACTION", $_SERVER["REQUEST_URI"]);
         $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it"));
         $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
         $content->setVariable("LABEL_RETURN", gettext("back"));
         $content->parse("BLOCK_DELETE");
     } else {
         $content->setVariable("LABEL_ARE_YOU_SURE", gettext("You have no rights to delete this forum!"));
     }
     $content->setVariable("TEXT_INFORMATION", gettext("The forum and all its entries be deleted."));
     $creator = $object->get_creator();
     $creator_data = $creator->get_attributes(array("USER_FULLNAME", "USER_FIRSTNAME", "OBJ_ICON"));
     $content->setVariable("LABEL_FROM_AND_AGO", str_replace("%N", "<a href=\"" . PATH_URL . "/user/" . $creator->get_name() . "/\">" . h($creator_data["USER_FIRSTNAME"]) . " " . h($creator_data["USER_FULLNAME"]) . "</a>", gettext("by %N")) . "," . how_long_ago($object->get_attribute("OBJ_CREATION_TIME")));
     $icon = $creator_data["OBJ_ICON"];
     if ($icon instanceof \steam_object) {
         $icon_id = $icon->get_id();
     } else {
         $icon_id = 0;
     }
     $content->setVariable("ICON_SRC", PATH_URL . "get_document.php?id=" . $icon_id);
     // TODO: Passt der Link?
     $rootlink = \lms_steam::get_link_to_root($object);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($object->get_name()), "link" => PATH_URL . "forums/" . $object->get_id() . "/"), array("name" => gettext("Delete forum")));
     $frameResponseObject->setTitle("Messageboard");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
예제 #22
0
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //$portal = \lms_portal::get_instance();
     //$portal->initialize( GUEST_NOT_ALLOWED );
     $user = \lms_steam::get_current_user();
     //$path = $request->getPath();
     $STEAM = $GLOBALS["STEAM"];
     $weblogId = $this->id;
     $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId);
     //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) )
     //{
     //	include( "bad_link.php" );
     //	exit;
     //}
     if (!$weblog instanceof \steam_calendar) {
         if ($weblog instanceof \steam_container) {
             $category = $weblog;
             $categories = $category->get_environment();
             $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id());
         } elseif ($weblog instanceof \steam_date) {
             $date = $weblog;
             $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id());
         } else {
             include "bad_link.php";
             exit;
         }
     } else {
         $weblog = new \steam_weblog($GLOBALS["STEAM"]->get_id(), $weblogId);
         define("OBJ_ID", $weblogId);
         if (!$weblog->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     if (!isset($date)) {
         throw new \Exception("variable date is not set.");
     }
     //$date = $weblog;
     if ($_SERVER["REQUEST_METHOD"] == "POST" && $date->check_access_write($user)) {
         $values = $_POST["values"];
         if ($values["delete"]) {
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache->clean($weblog->get_id());
             $cache->clean($date->get_id());
             $trashbin = $GLOBALS["STEAM"]->get_current_steam_user();
             if (is_object($trashbin)) {
                 $date->move($trashbin);
             } else {
                 $date->delete();
             }
         }
         header("Location: " . $values["return_to"]);
         exit;
     }
     $content = \Weblog::getInstance()->loadTemplate("weblog_entry_delete.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "weblog_entry_delete.template.html" );
     $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure you want to delete this entry?"));
     $content->setVariable("TEXT_COMMENT", get_formatted_output($date->get_attribute("DATE_DESCRIPTION")));
     $creator = $date->get_creator();
     $creator_data = $creator->get_attributes(array("USER_FULLNAME", "USER_FIRSTNAME", "OBJ_ICON"));
     $content->setVariable("LABEL_FROM_AND_AGO", str_replace("%N", "<a href=\"" . PATH_URL . "/user/index/" . $creator->get_name() . "/\">" . h($creator_data["USER_FIRSTNAME"]) . " " . h($creator_data["USER_FULLNAME"]) . "</a>", gettext("by %N")) . "," . how_long_ago($date->get_attribute("OBJ_CREATION_TIME")));
     $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it"));
     $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
     $content->setVariable("LABEL_RETURN", gettext("back"));
     $content->setVariable("ICON_SRC", PATH_URL . "get_document.php?id=" . $creator_data["OBJ_ICON"]->get_id());
     $rootlink = \lms_steam::get_link_to_root($weblog);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => "", "name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/index/" . $weblog->get_id() . "/"), array("name" => str_replace("%NAME", h($date->get_attribute("DATE_TITLE")), gettext("Delete '%NAME'?"))));
     /*$portal->set_page_main(
     	 $headline,
     	 $content->get(),
     	 ""
     	 );
     	 return $portal->get_html();*/
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
 /**
  * Clears all cached data
  * @return boolean
  */
 public function clear()
 {
     return $this->cache->clean(self::$group);
 }
예제 #24
0
 public function cleanCache($group = null)
 {
     $this->IMPL->clean($group);
 }
예제 #25
0
파일: wiki_delete.php 프로젝트: rolwi/koala
if ($_SERVER["REQUEST_METHOD"] == "POST" && $object->check_access_write($user)) {
    $values = $_POST["values"];
    if ($values["delete"]) {
        $_SESSION["confirmation"] = str_replace("%NAME", h($object->get_name()), gettext("The wiki '%NAME' has been deleted."));
        $workroom = $object->get_environment();
        lms_steam::delete($object);
        $wid = $object->get_id();
        // Clean Cache for the deleted wiki
        require_once "Cache/Lite.php";
        $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE));
        $cache = get_cache_function($wid, 600);
        $cache->drop("lms_steam::get_items", $wid);
        // Handle Related Cache-Data
        require_once "Cache/Lite.php";
        $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE));
        $cache->clean($wid);
        // clean wiki cache (not used by wiki)
        $fcache = get_cache_function($object->get_id(), 600);
        $fcache->drop("lms_wiki::get_items", $object->get_id());
        // Clean communication summary cache für the group/course
        if (is_object($workroom)) {
            $cache = get_cache_function(lms_steam::get_current_user()->get_name(), 600);
            $cache->drop("lms_steam::get_inventory_recursive", $workroom->get_id(), CLASS_CONTAINER | CLASS_ROOM, array("OBJ_TYPE", "WIKI_LANGUAGE"));
            $cache->drop("lms_steam::get_group_communication_objects", $workroom->get_id(), CLASS_MESSAGEBOARD | CLASS_CALENDAR | CLASS_CONTAINER | CLASS_ROOM);
        }
        header("Location: " . $values["return_to"]);
        exit;
    }
}
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "object_delete.template.html");
예제 #26
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $forum_id = $this->params[0];
     $comment_id = $this->params[1];
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     $rss_feeds = $user->get_attribute("USER_RSS_FEEDS");
     if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) {
         include "bad_link.php";
         exit;
     }
     if ($messageboard instanceof \steam_document) {
         $thread = $messageboard;
         $messageboard = $thread->get_annotating();
         define("OBJ_ID", $thread->get_id());
         if (!$thread->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     } else {
         define("OBJ_ID", $messageboard->get_id());
         if (!$messageboard->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     if (!$messageboard instanceof \steam_messageboard) {
         include "bad_link.php";
         exit;
     }
     $is_watching = FALSE;
     if (is_array($rss_feeds)) {
         foreach (array_keys($rss_feeds) as $item) {
             if ($item == $messageboard->get_id()) {
                 $is_watching = TRUE;
             }
         }
     }
     // no direct call
     /* TODO: Soll das rein?
     		if (!defined('_VALID_KOALA')) {
     			header("location:/");
     			exit;
     		}
     		*/
     $comment = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $comment_id);
     $user = \lms_steam::get_current_user();
     if ($_SERVER["REQUEST_METHOD"] == "POST" && $comment->check_access_write($user)) {
         $values = $_POST["values"];
         if ($values["delete"]) {
             $_SESSION["confirmation"] = str_replace("%NAME", h($comment->get_name()), gettext("The comment '%NAME' has been deleted."));
             $annotating = $comment->get_annotating();
             $annotating->remove_annotation($comment);
             \lms_steam::delete($comment);
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache = get_cache_function(OBJ_ID, 600);
             $cache->drop("lms_steam::get_annotations", OBJ_ID);
             // Handle Related Cache-Data
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache->clean(OBJ_ID);
             // clean forumcache
             $fcache = get_cache_function(OBJ_ID, 600);
             $fcache->drop("lms_forum::get_discussions", OBJ_ID);
             // clean cache for Weblog RSS Feed for the Comments
             $fcache->drop("lms_steam::get_annotations", OBJ_ID);
             // clean rsscache
             $rcache = get_cache_function("rss", 600);
             // TODO: Passt der link?
             $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID;
             $rcache->drop("lms_rss::get_items", $feedlink);
             // TODO: Passt der link?
             $feedlink = PATH_URL . "services/feeds/weblog_public.php?id=" . OBJ_ID;
             $rcache->drop("lms_rss::get_items", $feedlink);
             header("Location: " . PATH_URL . "messageboard/viewDiscussion/" . $forum_id);
             exit;
         }
     }
     $content = \Messageboard::getInstance()->loadTemplate("comment_delete.template.html");
     if ($comment->check_access_write($user)) {
         $content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure you want to delete this comment?"));
         if (isset($document)) {
             // TODO: Passt der link?
             $content->setVariable("DELETE_BACK_LINK", PATH_URL . "doc/" . OBJ_ID . "/");
         } else {
             if (isset($weblog)) {
                 // TODO: Passt der link?
                 $content->setVariable("DELETE_BACK_LINK", PATH_URL . "weblog/" . OBJ_ID . "/");
             } else {
                 // TODO: Passt der link?
                 $content->setVariable("DELETE_BACK_LINK", PATH_URL . "forums/" . OBJ_ID . "/");
             }
         }
         $content->setCurrentBlock("BLOCK_DELETE");
         $content->setVariable("FORM_ACTION", $_SERVER["REQUEST_URI"]);
         $content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it"));
         $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
         $content->setVariable("LABEL_RETURN", gettext("back"));
         $content->parse("BLOCK_DELETE");
     } else {
         $content->setVariable("LABEL_ARE_YOU_SURE", gettext("You have no rights to delete this comment!"));
     }
     $content->setVariable("TEXT_COMMENT", get_formatted_output($comment->get_content()));
     $creator = $comment->get_creator();
     $creator_data = $creator->get_attributes(array("USER_FULLNAME", "USER_FIRSTNAME", "OBJ_ICON"));
     $content->setVariable("LABEL_FROM_AND_AGO", str_replace("%N", "<a href=\"" . PATH_URL . "/user/" . $creator->get_name() . "/\">" . h($creator_data["USER_FIRSTNAME"]) . " " . h($creator_data["USER_FULLNAME"]) . "</a>", gettext("by %N")) . "," . how_long_ago($comment->get_attribute("OBJ_CREATION_TIME")));
     $icon = $creator_data["OBJ_ICON"];
     if ($icon instanceof \steam_object) {
         $icon_id = $icon->get_id();
     } else {
         $icon_id = 0;
     }
     $content->setVariable("ICON_SRC", PATH_URL . "get_document.php?id=" . $icon_id);
     // TODO: Passt der link?
     $rootlink = \lms_steam::get_link_to_root($messageboard);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name()), array("link" => "", "name" => gettext("Delete comment")));
     $frameResponseObject->setTitle("Messageboard");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
예제 #27
0
 public function logout()
 {
     if (!isset($this->lms_user)) {
         // PORTAL NOT INITIALIZED YET
         $this->initialize(GUEST_NOT_ALLOWED);
     }
     require_once "Cache/Lite.php";
     $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE));
     $cache->clean($this->lms_user->get_login());
     $this->lms_user->logout();
     $_SESSION = array();
     session_destroy();
     ob_end_clean();
     header("Location: " . PATH_URL);
 }
예제 #28
0
파일: Post.class.php 프로젝트: rolwi/koala
 public function execute(\FrameResponseObject $frameResponseObject)
 {
     //$portal = \lms_portal::get_instance();
     //$portal->initialize( GUEST_NOT_ALLOWED );
     //$portal->set_confirmation();
     $user = \lms_steam::get_current_user();
     //$path = $request->getPath();
     $STEAM = $GLOBALS["STEAM"];
     $weblogId = $this->id;
     $weblog = \steam_factory::get_object($STEAM->get_id(), $weblogId);
     //if ( ! $weblog = steam_factory::get_object( $STEAM->get_id(), $_GET[ "id" ] ) )
     //{
     //	include( "bad_link.php" );
     //	exit;
     //}
     if (!$weblog instanceof \steam_calendar) {
         if ($weblog instanceof \steam_container) {
             $category = $weblog;
             $categories = $category->get_environment();
             $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $categories->get_environment()->get_id());
         } elseif ($weblog instanceof \steam_date) {
             $date = $weblog;
             $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $date->get_environment()->get_id());
         } else {
             include "bad_link.php";
             exit;
         }
     } else {
         $weblog = new \steam_weblog((string) $GLOBALS["STEAM"]->get_id(), $weblogId);
         define("OBJ_ID", $weblogId);
         if (!$weblog->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     $content = \Weblog::getInstance()->loadTemplate("weblog_post.template.html");
     //$content = new HTML_TEMPLATE_IT();
     //$content->loadTemplateFile( PATH_TEMPLATES . "weblog_post.template.html" );
     $headline = gettext("Post a new entry");
     if ($_SERVER["REQUEST_METHOD"] == "GET") {
         $content->setVariable("VALUE_BACK_LINK", $_SERVER["HTTP_REFERER"]);
     } else {
         $values = $_POST["values"];
         if (get_magic_quotes_gpc()) {
             if (!empty($values['title'])) {
                 $values['title'] = stripslashes($values['title']);
             }
             if (!empty($values['body'])) {
                 $values['body'] = stripslashes($values['body']);
             }
         }
         if (!empty($values["save"])) {
             $problem = "";
             $hint = "";
             if (empty($values["title"])) {
                 $problem .= gettext("The title is missing.") . "&nbsp;";
                 $hint .= gettext("Please add the missing values.");
             }
             if (empty($values["body"])) {
                 $problem .= gettext("There is no message for your readers.") . "&nbsp;";
                 $hint .= gettext("Please write your post into the text area.");
             }
             if (!empty($values["category"]) && $values["category"] != 0) {
                 $category = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $values["category"]);
                 if (!$category instanceof \steam_container) {
                     throw new \Exception("Not a valid category: " . $values["category"]);
                 }
             } else {
                 $category = "";
             }
             if (!($timestamp = strtotime($values["date"] . ":00"))) {
                 $problem .= gettext("I cannot parse the date and time.");
                 $hint .= gettext("Please verify your date and time format") . ": YYYY-MM-DD HH:MM";
             }
             if (strpos($values["title"], "/")) {
                 if (!isset($problem)) {
                     $problem = "";
                 }
                 $problem .= gettext("Please don't use the \"/\"-char in the subject of your post.");
             }
             if (empty($problem)) {
                 $new_entry = $weblog->create_entry($values["title"], $values["body"], $category, array(), $timestamp);
                 if ($values["podcast"] != 0) {
                     $new_entry->set_attribute("DATE_PODCAST", $values["podcast"]);
                 }
                 // Handle Related Cache-Data
                 require_once "Cache/Lite.php";
                 $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
                 $cache->clean(OBJ_ID);
                 // clean weblogcache
                 $bcache = get_cache_function($_GET["id"], 600);
                 $bcache->drop("lms_weblog::get_items", $_GET["id"]);
                 // clean rsscache of the weblog
                 $feedlink = PATH_URL . "services/feeds/weblog_public.php?id=" . $_GET["id"];
                 $rcache = get_cache_function("rss", 600);
                 $rcache->drop("lms_rss::get_items", $feedlink);
                 header("Location: " . PATH_URL . "weblog/index/" . $weblog->get_id() . "/");
                 exit;
             } else {
                 // TODO:THERE IS A PROBLEM
                 //$portal->set_problem_description( $problem, $hint );
                 $content->setVariable("TEXT_COMMENT", h($values["body"]));
                 $content->setVariable("TITLE_COMMENT", h($values["title"]));
             }
         } else {
             // PREVIEW
             $content->setCurrentBlock("BLOCK_PREVIEW");
             $content->setVariable("LABEL_PREVIEW_EDIT", gettext("Preview the edit"));
             $content->setVariable("PREVIEW_EDIT", get_formatted_output($values["body"]));
             $content->parse("BLOCK_PREVIEW");
             $headline = gettext("Change it?");
             $content->setVariable("TEXT_COMMENT", h($values["body"]));
             $content->setVariable("TITLE_COMMENT", h($values["title"]));
         }
     }
     $backlink = empty($_POST["values"]["return_to"]) ? $_SERVER["HTTP_REFERER"] : $_POST["values"]["return_to"];
     $content->setVariable("VALUE_BACK_LINK", $backlink);
     $content->setVariable("POST_NEW_ENTRY_TEXT", $headline);
     $content->setVariable("INFO_TEXT", "some hints about blogging");
     $content->setVariable("LABEL_DATE", gettext("Date"));
     $content->setVariable("INFO_FORMAT", gettext("Format: YYYY-MM-DD HH:MM"));
     $date = empty($values["date"]) ? strftime("%Y-%m-%d %H:%M") : $values["date"];
     $content->setVariable("DATE_COMMENT", h($date));
     $content->setVariable("LABEL_SUBJECT", gettext("Subject"));
     $content->setVariable("LABEL_YOUR_POST", gettext("Your Post"));
     $content->setVariable("LABEL_CATEGORY", gettext("Category"));
     $content->setVariable("LINK_NEW_CATEGORY", PATH_URL . "weblog/categorycreate/" . $weblog->get_id());
     $content->setVariable("LABEL_NEW_CATEGORY", gettext("Want to add a new category?"));
     $content->setVariable("CAT_NO_SELECTION", gettext("nothing selected"));
     $categories = $weblog->get_categories();
     $selection = empty($values["category"]) ? isset($_GET["category"]) ? $_GET["category"] : '' : $values["category"];
     foreach ($categories as $category) {
         $content->setCurrentBlock("BLOCK_SELECT_CAT");
         $content->setVariable("VALUE_CAT", $category->get_id());
         $content->setVariable("LABEL_CAT", h($category->get_name()));
         if ($category->get_id() == $selection) {
             $content->setVariable("CAT_SELECTED", 'selected="selected"');
         }
         $content->parse("BLOCK_SELECT_CAT");
     }
     /*
     $content->setVariable( "LABEL_PODCAST", gettext( "Podcast") );
     $content->setVariable( "PODCAST_NO_SELECTION", gettext( "nothing selected" ) );
     $content->setVariable( "LINK_UPLOAD_MULTIMEDIA", PATH_URL . "weblog/" . $weblog->get_id() . "/podcast/" );
     $content->setVariable( "LABEL_UPLOAD_MULTIMEDIA", gettext( "Want to upload an audio or video file?" ) );
     $files_in_podspace = $weblog->get_podspace()->get_inventory( CLASS_DOCUMENT );
     foreach( $files_in_podspace as $file )
     {
     $content->setCurrentBlock( "BLOCK_MULTIMEDIA" );
     $content->setVariable( "VALUE_MULTIMEDIA", $file->get_id() );
     if ( ( $file->get_id() == $_GET[ "podcast" ] ) || ( $file->get_id() == $values[ "podcast" ] ) )
     {
     $content->setVariable( "MULTIMEDIA_SELECTED", 'selected="selected"' );
     }
     $content->setVariable( "LABEL_MULTIMEDIA", h($file->get_name()) );
     $content->parse( "BLOCK_MULTIMEDIA" );
     }
     */
     $content->setVariable("LABEL_BB_BOLD", gettext("B"));
     $content->setVariable("HINT_BB_BOLD", gettext("boldface"));
     $content->setVariable("LABEL_BB_ITALIC", gettext("I"));
     $content->setVariable("HINT_BB_ITALIC", gettext("italic"));
     $content->setVariable("LABEL_BB_UNDERLINE", gettext("U"));
     $content->setVariable("HINT_BB_UNDERLINE", gettext("underline"));
     $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S"));
     $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough"));
     $content->setVariable("LABEL_BB_IMAGE", gettext("IMG"));
     $content->setVariable("HINT_BB_IMAGE", gettext("image"));
     $content->setVariable("LABEL_BB_URL", gettext("URL"));
     $content->setVariable("HINT_BB_URL", gettext("web link"));
     $content->setVariable("LABEL_BB_MAIL", gettext("MAIL"));
     $content->setVariable("HINT_BB_MAIL", gettext("email link"));
     $content->setVariable("LABEL_PREVIEW", gettext("Preview"));
     $content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes"));
     $content->setVariable("LABEL_RETURN", gettext("back"));
     //TODO:RSS-FEED
     //$portal->set_rss_feed( PATH_URL . "services/feeds/weblog_public.php?id=" . $weblog->get_id(), gettext( "Feed" ), str_replace( "%l", (isset($login))?$login:'', gettext( "Subscribe to this forum's Newsfeed" ) ) );
     $rootlink = \lms_steam::get_link_to_root($weblog);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("name" => h($weblog->get_name()), "link" => PATH_URL . "weblog/" . $weblog->get_id() . "/"), array("link" => "", "name" => gettext("New Post")));
     /*$portal->set_page_main(
     			$headline,
     			$content->get()
     		);
     		return $portal->get_html();*/
     $frameResponseObject->setHeadline($headline);
     $widget = new \Widgets\RawHtml();
     $widget->setHtml($content->get());
     $frameResponseObject->addWidget($widget);
     return $frameResponseObject;
 }
예제 #29
0
 public function frameResponse(\FrameResponseObject $frameResponseObject)
 {
     $forum_id = $this->params[0];
     $comment_id = $this->params[1];
     $portal = \lms_portal::get_instance();
     $user = \lms_steam::get_current_user();
     $rss_feeds = $user->get_attribute("USER_RSS_FEEDS");
     if (!($messageboard = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $forum_id))) {
         include "bad_link.php";
         exit;
     }
     if ($messageboard instanceof \steam_document) {
         $thread = $messageboard;
         $messageboard = $thread->get_annotating();
         define("OBJ_ID", $thread->get_id());
         if (!$thread->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     } else {
         define("OBJ_ID", $messageboard->get_id());
         if (!$messageboard->check_access_read($user)) {
             throw new \Exception("No rights to view this.", E_USER_RIGHTS);
         }
     }
     if (!$messageboard instanceof \steam_messageboard) {
         include "bad_link.php";
         exit;
     }
     $is_watching = FALSE;
     if (is_array($rss_feeds)) {
         foreach (array_keys($rss_feeds) as $item) {
             if ($item == $messageboard->get_id()) {
                 $is_watching = TRUE;
             }
         }
     }
     $comment = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $comment_id);
     $content = \Messageboard::getInstance()->loadTemplate("comment_edit.template.html");
     if ($_SERVER["REQUEST_METHOD"] == "GET") {
         $content->setVariable("LABEL_HERE_IT_IS", "");
         $content->setVariable("TEXT_COMMENT", h($comment->get_content()));
         $content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);
     } else {
         $values = $_POST["values"];
         if (!empty($values["save"])) {
             $comment->set_content($values["message"]);
             require_once "Cache/Lite.php";
             // Handle Related Cache-Data (for the case that the subject may be editable in the future)
             require_once "Cache/Lite.php";
             $cache = new \Cache_Lite(array("cacheDir" => PATH_CACHE));
             $cache->clean(OBJ_ID);
             // clean forumcache
             $fcache = get_cache_function(OBJ_ID, 600);
             $fcache->drop("lms_forum::get_discussions", OBJ_ID);
             // clean cache for Weblog RSS Feed for the Comments
             $cache = get_cache_function(OBJ_ID, 600);
             $discussions = $cache->drop("lms_steam::get_annotations", OBJ_ID);
             // clean rsscache
             $rcache = get_cache_function("rss", 600);
             // TODO: Passt der link?
             $feedlink = PATH_URL . "services/feeds/forum_public.php?id=" . OBJ_ID;
             $rcache->drop("lms_rss::get_items", $feedlink);
             // TODO: Passt der link?
             $feedlink = PATH_URL . "services/feeds/weblog_public.php?id=" . OBJ_ID;
             $rcache->drop("lms_rss::get_items", $feedlink);
             header("Location: " . $values["return_to"]);
             exit;
         } else {
             // PREVIEW
             $content->setCurrentBlock("BLOCK_PREVIEW");
             $content->setVariable("LABEL_PREVIEW_EDIT", gettext("Preview the edit"));
             $content->setVariable("PREVIEW_EDIT", get_formatted_output($values["message"]));
             $content->parse("BLOCK_PREVIEW");
             $content->setVariable("LABEL_HERE_IT_IS", gettext("Change it?"));
             $content->setVariable("TEXT_COMMENT", h($values["message"]));
             $content->setVariable("BACK_LINK", $values["return_to"]);
         }
     }
     $content->setVariable("LABEL_BB_BOLD", gettext("B"));
     $content->setVariable("HINT_BB_BOLD", gettext("boldface"));
     $content->setVariable("LABEL_BB_ITALIC", gettext("I"));
     $content->setVariable("HINT_BB_ITALIC", gettext("italic"));
     $content->setVariable("LABEL_BB_UNDERLINE", gettext("U"));
     $content->setVariable("HINT_BB_UNDERLINE", gettext("underline"));
     $content->setVariable("LABEL_BB_STRIKETHROUGH", gettext("S"));
     $content->setVariable("HINT_BB_STRIKETHROUGH", gettext("strikethrough"));
     $content->setVariable("LABEL_BB_IMAGE", gettext("IMG"));
     $content->setVariable("HINT_BB_IMAGE", gettext("image"));
     $content->setVariable("LABEL_BB_URL", gettext("URL"));
     $content->setVariable("HINT_BB_URL", gettext("web link"));
     $content->setVariable("LABEL_BB_MAIL", gettext("MAIL"));
     $content->setVariable("HINT_BB_MAIL", gettext("email link"));
     $content->setVariable("LABEL_PREVIEW", gettext("Preview"));
     $content->setVariable("LABEL_SAVE_CHANGES", gettext("Save changes"));
     $content->setVariable("LABEL_RETURN", gettext("back"));
     // TODO: Passt der link?
     $rootlink = \lms_steam::get_link_to_root($messageboard);
     $headline = array($rootlink[0], $rootlink[1], array("link" => $rootlink[1]["link"] . "communication/", "name" => gettext("Communication")), array("link" => PATH_URL . "forums/" . $messageboard->get_id() . "/", "name" => $messageboard->get_name()), array("link" => "", "name" => gettext("Edit a comment")));
     $frameResponseObject->setTitle("Messageboard");
     $rawHtml = new \Widgets\RawHtml();
     $rawHtml->setHtml($content->get());
     $frameResponseObject->addWidget($rawHtml);
     return $frameResponseObject;
 }
예제 #30
0
<?php

if ($_SERVER["REQUEST_METHOD"] == "POST" && $category->check_access_write($user)) {
    $values = $_POST["values"];
    if ($values["delete"]) {
        require_once "Cache/Lite.php";
        $cache = new Cache_Lite(array("cacheDir" => PATH_CACHE));
        $cache->clean($weblog->get_id());
        $link_objects = $category->get_inventory(CLASS_LINK);
        foreach ($link_objects as $link_object) {
            $date_object = $link_object->get_source_object();
            $link_object->delete();
            if ($values["delete_all_dates"]) {
                $date_object->delete();
            } else {
                $date_object->set_attribute("DATE_CATEGORY", "0");
            }
        }
        $category->delete();
    }
    header("Location: " . PATH_URL . "weblog/" . $weblog->get_id() . "/");
    exit;
}
$content = new HTML_TEMPLATE_IT();
$content->loadTemplateFile(PATH_TEMPLATES . "weblog_category_delete.template.html");
$content->setVariable("LABEL_ARE_YOU_SURE", gettext("Are you sure you want to delete this category?"));
$content->setVariable("NAME_CATEGORY", h($category->get_name()));
$content->setVariable("TEXT_CATEGORY", get_formatted_output($category->get_attribute("OBJ_DESC")));
$content->setVariable("LABEL_DELETE_ALL_DATES", str_replace("%NO", count($category->get_inventory(CLASS_LINK)), gettext("Should all %NO entries in this category be deleted, too?")));
$content->setVariable("LABEL_DELETE_IT", gettext("yes, delete it"));
$content->setVariable("BACK_LINK", $_SERVER["HTTP_REFERER"]);