示例#1
0
 /**
  * Retrieve a value from the request (GET/POST/REQUEST)
  *
  * @param string $name name of the variable to be retrieved
  * @param string $type  type of the variable (see CRM_Utils_Type for details)
  * @param stdClass $store session scope where variable is stored
  * @param bool $abort is this variable required
  * @param mixed $default default value of the variable if not present
  * @param string $method where should we look for the variable
  *
  * @return mixed the value of the variable
  * @access public
  * @static
  */
 static function retrieve($name, $type, &$store = NULL, $abort = FALSE, $default = NULL, $method = 'REQUEST')
 {
     // hack to detect stuff not yet converted to new style
     if (!is_string($type)) {
         CRM_Core_Error::backtrace();
         CRM_Core_Error::fatal(ts("Please convert retrieve call to use new function signature"));
     }
     $value = NULL;
     switch ($method) {
         case 'GET':
             $value = CRM_Utils_Array::value($name, $_GET);
             break;
         case 'POST':
             $value = CRM_Utils_Array::value($name, $_POST);
             break;
         default:
             $value = CRM_Utils_Array::value($name, $_REQUEST);
             break;
     }
     if (isset($value) && CRM_Utils_Type::validate($value, $type, $abort, $name) === NULL) {
         $value = NULL;
     }
     if (!isset($value) && $store) {
         $value = $store->get($name);
     }
     if (!isset($value) && $abort) {
         CRM_Core_Error::fatal(ts("Could not find valid value for %1", array(1 => $name)));
     }
     if (!isset($value) && $default) {
         $value = $default;
     }
     // minor hack for action
     if ($name == 'action' && is_string($value)) {
         $value = CRM_Core_Action::resolve($value);
     }
     if (isset($value) && $store) {
         $store->set($name, $value);
     }
     return $value;
 }
示例#2
0
文件: content.php 项目: cwcw/cms
function showArchiveSection($id = NULL, $gid, &$access, $pop, $option)
{
    global $database, $mainframe, $mosConfig_offset;
    global $Itemid;
    $noauth = !$mainframe->getCfg('shownoauth');
    // Paramters
    $year = mosGetParam($_REQUEST, 'year', date('Y'));
    $month = mosGetParam($_REQUEST, 'month', date('m'));
    $params = new stdClass();
    if ($Itemid) {
        $menu = new mosMenu($database);
        $menu->load($Itemid);
        $params =& new mosParameters($menu->params);
    } else {
        $menu = "";
        $params =& new mosParameters('');
    }
    $params->set('intro_only', 1);
    $params->set('year', $year);
    $params->set('month', $month);
    // Ordering control
    $orderby_sec = $params->def('orderby_sec', 'rdate');
    $orderby_pri = $params->def('orderby_pri', '');
    $order_sec = _orderby_sec($orderby_sec);
    $order_pri = _orderby_pri($orderby_pri);
    // used in query
    $where = _where(-1, $access, $noauth, $gid, $id, NULL, $year, $month);
    // checks to see if 'All Sections' options used
    if ($id == 0) {
        $check = '';
    } else {
        $check = 'AND a.sectionid = ' . $id;
    }
    // query to determine if there are any archived entries for the section
    $query = "SELECT a.id" . "\n FROM #__content as a" . "\n WHERE a.state = '-1'" . $check;
    $database->setQuery($query);
    $items = $database->loadObjectList();
    $archives = count($items);
    // Main Query
    $query = "SELECT a.*, ROUND(v.rating_sum/v.rating_count) AS rating, v.rating_count, u.name AS author, u.usertype, cc.name AS category, g.name AS groups" . "\n FROM #__content AS a" . "\n INNER JOIN #__categories AS cc ON cc.id = a.catid" . "\n LEFT JOIN #__users AS u ON u.id = a.created_by" . "\n LEFT JOIN #__content_rating AS v ON a.id = v.content_id" . "\n LEFT JOIN #__sections AS s ON a.sectionid = s.id" . "\n LEFT JOIN #__groups AS g ON a.access = g.id" . (count($where) ? "\n WHERE " . implode("\n AND ", $where) : '') . "\n AND s.access <= " . $gid . "\n ORDER BY " . $order_pri . $order_sec;
    $database->setQuery($query);
    $rows = $database->loadObjectList();
    // initiate form
    echo '<form action="' . sefRelToAbs('index.php?option=' . $option . '&amp;task=archivesection&amp;id=' . $id . '&amp;Itemid=' . $Itemid) . '" method="post">';
    // Dynamic Page Title
    $mainframe->SetPageTitle($menu->name);
    if (!$archives) {
        // if no archives for category, hides search and outputs empty message
        echo '<br /><div align="center">' . _CATEGORY_ARCHIVE_EMPTY . '</div>';
    } else {
        BlogOutput($rows, $params, $gid, $access, $pop, $menu, 1);
    }
    echo '</form>';
}