Skip to content

Commit

Permalink
Misc. updates
Browse files Browse the repository at this point in the history
  • Loading branch information
olafgleba committed Dec 5, 2011
1 parent 2aaba58 commit 4c4b613
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 29 deletions.
13 changes: 10 additions & 3 deletions welcompose/core/content_classes/blogposting.class.php
Expand Up @@ -278,6 +278,10 @@ public function selectBlogPosting ($id)
`content_pages`.`optional_text` AS `page_optional_text`,
`content_pages`.`url` AS `page_url`,
`content_pages`.`protect` AS `page_protect`,
`content_pages`.`exclude` AS `page_exclude`,
`content_pages`.`index_page` AS `page_index_page`,
`content_pages`.`no_follow` AS `page_no_follow`,
`content_pages`.`draft` AS `page_draft`,
`content_pages`.`index_page` AS `page_index_page`,
`content_pages`.`image_small` AS `page_image_small`,
`content_pages`.`image_medium` AS `page_image_medium`,
Expand Down Expand Up @@ -507,6 +511,10 @@ public function selectBlogPostings ($params = array())
`content_pages`.`optional_text` AS `page_optional_text`,
`content_pages`.`url` AS `page_url`,
`content_pages`.`protect` AS `page_protect`,
`content_pages`.`exclude` AS `page_exclude`,
`content_pages`.`index_page` AS `page_index_page`,
`content_pages`.`no_follow` AS `page_no_follow`,
`content_pages`.`draft` AS `page_draft`,
`content_pages`.`index_page` AS `page_index_page`,
`content_pages`.`image_small` AS `page_image_small`,
`content_pages`.`image_medium` AS `page_image_medium`,
Expand Down Expand Up @@ -608,7 +616,6 @@ public function selectBlogPostings ($params = array())

// add sorting
if (!empty($order_macro)) {
$HELPER = load('utility:helper');
$sql .= " ORDER BY ".$HELPER->_sqlForOrderMacro($order_macro, $macros);
}

Expand Down Expand Up @@ -774,8 +781,8 @@ public function countBlogPostings ($params = array())
$current_date);
}
if (!empty($search_name)) {
$sql .= " AND `content_blog_postings`.`title` = :search_name ";
$bind_params['search_name'] = $search_name;
$sql .= " AND ".$HELPER->_searchLikewise('`content_blog_postings`.`title`',
$search_name);
}

return $this->base->db->select($sql, 'field', $bind_params);
Expand Down
2 changes: 1 addition & 1 deletion welcompose/core/content_classes/blogtag.class.php
Expand Up @@ -551,7 +551,7 @@ public function selectBlogTags ($params = array())
$bind_params['page'] = $page;
}
// exclude draft postings
$sql .= " AND `content_blog_postings`.`draft` = '0' ";
//$sql .= " AND `content_blog_postings`.`draft` = '0' ";

// aggregate result set
$sql .= " GROUP BY `content_blog_tags`.`id` ";
Expand Down
26 changes: 25 additions & 1 deletion welcompose/core/content_classes/generatorformfield.class.php
Expand Up @@ -267,7 +267,13 @@ public function selectGeneratorFormField ($id)
* <li>form, int, optional: Form id</li>
* <li>start, int, optional: row offset</li>
* <li>limit, int, optional: amount of rows to return</li>
* <li>order_marco, string, otpional: How to sort the result set.
* </ul>
* Supported macros:
* <ul>
* <li>NAME: sort by name</li>
* </ul>
* </li>
*
* @throws Content_GeneratorFormFieldException
* @param array Select params
Expand All @@ -284,6 +290,7 @@ public function selectGeneratorFormFields ($params = array())
$form = null;
$start = null;
$limit = null;
$order_macro = null;
$bind_params = array();

// input check
Expand All @@ -294,6 +301,9 @@ public function selectGeneratorFormFields ($params = array())
// import params
foreach ($params as $_key => $_value) {
switch ((string)$_key) {
case 'order_macro':
$$_key = (string)$_value;
break;
case 'form':
case 'start':
case 'limit':
Expand All @@ -304,6 +314,15 @@ public function selectGeneratorFormFields ($params = array())
}
}

// define order macros
$macros = array(
'NAME' => '`content_generator_form_fields`.`name`',
'TYPE' => '`content_generator_form_fields`.`type`'
);

// load helper class
$HELPER = load('utility:helper');

// prepare query
$sql = "
SELECT
Expand Down Expand Up @@ -348,7 +367,12 @@ public function selectGeneratorFormFields ($params = array())
$bind_params['form'] = $form;
}

$sql .= ' ORDER BY `content_generator_form_fields`.`sorting` ';
// add sorting
if (!empty($order_macro)) {
$sql .= " ORDER BY ".$HELPER->_sqlForOrderMacro($order_macro, $macros);
} else {
$sql .= ' ORDER BY `content_generator_form_fields`.`sorting` ';
}

// add limits
if (empty($start) && is_numeric($limit)) {
Expand Down
12 changes: 8 additions & 4 deletions welcompose/core/content_classes/navigation.class.php
Expand Up @@ -94,14 +94,18 @@ public function addNavigation ($sqlData)
}

// make sure that the navigation will be assigned to the right project
$sqlData['project'] = WCOM_CURRENT_PROJECT;
if (!isset($sqlData['project'])) {
$sqlData['project'] = WCOM_CURRENT_PROJECT;
}

// insert row
$insert_id = $this->base->db->insert(WCOM_DB_CONTENT_NAVIGATIONS, $sqlData);

// test if navigation belongs to current user/project
if (!$this->navigationBelongsToCurrentUser($insert_id)) {
throw new Content_NavigationException('Navigation does not belong to current user or project');
if (!isset($sqlData['project'])) {
// test if navigation belongs to current user/project
if (!$this->navigationBelongsToCurrentUser($insert_id)) {
throw new Content_NavigationException('Navigation does not belong to current user or project');
}
}

return $insert_id;
Expand Down
18 changes: 10 additions & 8 deletions welcompose/core/content_classes/simpleguestbookentry.class.php
Expand Up @@ -293,6 +293,7 @@ public function selectSimpleGuestbookEntry ($id)
* <li>DATE_MODIFIED: sorty by date modified</li>
* <li>DATE_ADDED: sort by date added</li>
* <li>RANDOM: sort by random</li>
* <li>NAME: sort by name</li>
* </ul>
* </li>
* </ul>
Expand Down Expand Up @@ -344,7 +345,8 @@ public function selectSimpleGuestbookEntries ($params = array())
$macros = array(
'DATE_ADDED' => '`content_simple_guestbook_entries`.`date_added`',
'DATE_MODIFIED' => '`content_simple_guestbook_entries`.`date_modified`',
'RANDOM' => 'rand()'
'RANDOM' => 'rand()',
'NAME' => '`content_simple_guestbook_entries`.`name`',
);

// load helper class
Expand Down Expand Up @@ -490,6 +492,9 @@ public function countSimpleGuestbookEntries ($params = array())
}
}

// load helper class
$HELPER = load('utility:helper');

// prepare query
$sql = "
SELECT
Expand Down Expand Up @@ -521,15 +526,12 @@ public function countSimpleGuestbookEntries ($params = array())
if (!empty($book) && is_numeric($book)) {
$sql .= " AND `content_simple_guestbook_entries`.`book` = :book ";
$bind_params['book'] = $book;
}

}
if (!empty($search_name)) {
$sql .= " AND `content_simple_guestbook_entries`.`name` = :search_name ";
$bind_params['search_name'] = $search_name;
$sql .= " AND ".$HELPER->_searchLikewise('`content_simple_guestbook_entries`.`name`',
$search_name);
}

if (!empty($timeframe)) {
$HELPER = load('utility:helper');
if (!empty($timeframe)) {
$sql .= " AND ".$HELPER->_sqlForTimeFrame('`content_simple_guestbook_entries`.`date_added`',
$timeframe);
}
Expand Down
Expand Up @@ -63,7 +63,7 @@ function smarty_function_global_template ($params, &$smarty)
$patterns = array(
'<project_id>',
'<project_name>',
'<global_file_name>'
'<global_template_name>'
);
ksort($patterns);

Expand Down
Expand Up @@ -383,7 +383,7 @@ public function smartyFetchGlobalTemplate ($name)
}

/**
* Fetches last modification date of global template from database for usage in the
* Fetches last modification date of global template from database for usage in the
* smarty resource plugin. Takes the global template name as first argument.
* Returns UNIX timestamp.
*
Expand Down
14 changes: 9 additions & 5 deletions welcompose/core/templating_classes/templateset.class.php
Expand Up @@ -93,15 +93,19 @@ public function addTemplateSet ($sqlData)
throw new Templating_TemplateSetException('Input for parameter sqlData is not an array');
}

// make sure that the new template set will be assigned to the current project
$sqlData['project'] = WCOM_CURRENT_PROJECT;
if (!isset($sqlData['project'])) {
// make sure that the new template set will be assigned to the current project
$sqlData['project'] = WCOM_CURRENT_PROJECT;
}

// insert row
$insert_id = $this->base->db->insert(WCOM_DB_TEMPLATING_TEMPLATE_SETS, $sqlData);

// test if template set belongs to current user/project
if (!$this->templateSetBelongsToCurrentUser($insert_id)) {
throw new Templating_TemplateSetException('Template set does not belong to current user or project');
if (!isset($sqlData['project'])) {
// test if template set belongs to current user/project
if (!$this->templateSetBelongsToCurrentUser($insert_id)) {
throw new Templating_TemplateSetException('Template set does not belong to current user or project');
}
}

return $insert_id;
Expand Down
1 change: 1 addition & 0 deletions welcompose/core/user_classes/user.class.php
Expand Up @@ -402,6 +402,7 @@ public function selectUsers ($params = array())
$sql .= " AND `user_groups`.`id` = :group ";
$bind_params['group'] = (int)$group;
}
// avoid the current user and skeleton users
if (!empty($exclude) && is_numeric($exclude)) {
$sql .= " AND `user_users`.`id` != ".WCOM_CURRENT_USER." ";
$sql .= " AND `user_users`.`email` != 'WCOM_ANONYMOUS' ";
Expand Down
10 changes: 9 additions & 1 deletion welcompose/global_template.php
Expand Up @@ -70,6 +70,14 @@

// set mime type
header(sprintf("Content-Type: %s", (!empty($template['mime_type']) ? $template['mime_type'] : 'text/plain')));
// header("Cache-Control: must-revalidate");
// $offset = 60 * 60 * 24 * 5;
// $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time() + $offset) . " GMT";
// header($ExpStr);
//
// //$offsetMod = 60 * 60 * 24 * 2;
// $ExpStrMod = "Last-Modified: " . gmdate("D, d M Y H:i:s", strtotime($template['date_modified'])) . " GMT";
// header($ExpStrMod);

// change delimiter if required
if (isset($template['change_delimiter']) && $template['change_delimiter']) {
Expand All @@ -78,7 +86,7 @@
}

// prepare the template name
define("WCOM_TEMPLATE", sprintf("wcomgtpl:%s", Base_Cnc::ifsetor($_REQUEST['name'], null)).".".WCOM_CURRENT_PROJECT);
define("WCOM_TEMPLATE", sprintf("wcomgtpl:%s", Base_Cnc::ifsetor($_REQUEST['name'], null)).".".WCOM_CURRENT_PROJECT);

// start gunzip compression
if ($BASE->_conf['output']['gunzip'] == 1) {
Expand Down
2 changes: 0 additions & 2 deletions welcompose/smarty/compiled/.gitignore

This file was deleted.

2 changes: 0 additions & 2 deletions welcompose/tmp/captchas/.gitignore

This file was deleted.

0 comments on commit 4c4b613

Please sign in to comment.