Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 699 lines (609 sloc) 26.739 kb
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
1 <?php
2 /**
9dbee19 Strip down CVS keywords.
cvs2git authored
3 * @version $Header$
0153f3d @lsces Correct documentation package name to articles
lsces authored
4 * @package articles
d403bf6 @lsces Add PHPDoc headings to package
lsces authored
5 *
6 * Copyright( c )2004 bitweaver.org
7 * Copyright( c )2003 tikwiki.org
8 * Copyright( c )2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
28d8e3d @tekimaki remove ref to non-existant copyright.txt file
tekimaki authored
9 * All Rights Reserved. See below for details and a complete list of authors.
1117b0f @tekimaki fix LGPL license ref from non-existant license.txt file to lgpl url
tekimaki authored
10 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
d403bf6 @lsces Add PHPDoc headings to package
lsces authored
11 *
9dbee19 Strip down CVS keywords.
cvs2git authored
12 * $Id$
d403bf6 @lsces Add PHPDoc headings to package
lsces authored
13 *
14 * Article class is used when accessing BitArticles. It is based on TikiSample
15 * and builds on core bitweaver functionality, such as the Liberty CMS engine.
16 *
17 * created 2004/8/15
18 * @author wolffy <wolff_borg@yahoo.com.au>
9dbee19 Strip down CVS keywords.
cvs2git authored
19 * @version $Revision$
d403bf6 @lsces Add PHPDoc headings to package
lsces authored
20 */
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
21
22 /**
d403bf6 @lsces Add PHPDoc headings to package
lsces authored
23 * Required setup
24 */
04136bd get article submissions working
Max Kremmel authored
25 require_once( ARTICLES_PKG_PATH.'BitArticleTopic.php' );
26 require_once( ARTICLES_PKG_PATH.'BitArticleType.php' );
0a8c72a migrate articles to LibertyMime
Max Kremmel authored
27 require_once( LIBERTY_PKG_PATH.'LibertyMime.php' );
04136bd get article submissions working
Max Kremmel authored
28 require_once( LIBERTY_PKG_PATH.'LibertyComment.php' );
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
29
ab5236a @tekimaki define constant in class file like other pkgs
tekimaki authored
30 define( 'BITARTICLE_CONTENT_TYPE_GUID', 'bitarticle' );
31
6e1bd68 @lsces Tidy phpdoc tags for classes, and heading block
lsces authored
32 /**
0153f3d @lsces Correct documentation package name to articles
lsces authored
33 * @package articles
6e1bd68 @lsces Tidy phpdoc tags for classes, and heading block
lsces authored
34 */
0a8c72a migrate articles to LibertyMime
Max Kremmel authored
35 class BitArticle extends LibertyMime {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
36 /**
7f0e5d8 more work on getting articles going
Max Kremmel authored
37 * Primary key for articles
cf7b087 add some documentation
Max Kremmel authored
38 * @access public
7f0e5d8 more work on getting articles going
Max Kremmel authored
39 */
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
40 var $mArticleId;
41 var $mTypeId;
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
42 var $mTopicId;
cf7b087 add some documentation
Max Kremmel authored
43
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
44 /**
ec0a861 add some more documentation
Max Kremmel authored
45 * Initiate the articles class
cf7b087 add some documentation
Max Kremmel authored
46 * @param $pArticleId article id of the article we want to view
47 * @param $pContentId content id of the article we want to view
48 * @access private
7f0e5d8 more work on getting articles going
Max Kremmel authored
49 **/
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
50 function BitArticle( $pArticleId=NULL, $pContentId=NULL ) {
35844b7 @spiderr replace all PHP4 style calls to LibertyMime base constructors with paren...
spiderr authored
51 parent::__construct();
f7e71d3 Add m(Admin|Edit|View)ContentPermission to various classes. update Liber...
Max Kremmel authored
52 $this->registerContentType(
53 BITARTICLE_CONTENT_TYPE_GUID, array(
4cc93bb @tekimaki define the content type guid in class constructor like other pkgs
tekimaki authored
54 'content_type_guid' => BITARTICLE_CONTENT_TYPE_GUID,
9dc138a @tekimaki SCHEMA CHANGE - liberty_content_types - change content_description to co...
tekimaki authored
55 'content_name' => 'Article',
f7e71d3 Add m(Admin|Edit|View)ContentPermission to various classes. update Liber...
Max Kremmel authored
56 'handler_class' => 'BitArticle',
57 'handler_package' => 'articles',
58 'handler_file' => 'BitArticle.php',
59 'maintainer_url' => 'http://www.bitweaver.org'
60 ));
61 $this->mContentId = $pContentId;
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
62 $this->mArticleId = $pArticleId;
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
63 $this->mTypeId = NULL;
64 $this->mTopicId = NULL;
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
65 $this->mContentTypeGuid = BITARTICLE_CONTENT_TYPE_GUID;
65c3c47 @lsces Tidy BitDate initialisation
lsces authored
66 $this->mDate = new BitDate();
67 $offset = $this->mDate->get_display_offset();
f7e71d3 Add m(Admin|Edit|View)ContentPermission to various classes. update Liber...
Max Kremmel authored
68
69 // Permission setup
70 $this->mViewContentPerm = 'p_articles_read';
c0f6195 @tekimaki CORE CHANGE: cleave Create permission from Edit permission so that they ...
tekimaki authored
71 $this->mCreateContentPerm = 'p_articles_submit';
9de6d0a @spiderr BIG CHANGE: migrate p_*_edit permissions to p_*_update permission naming...
spiderr authored
72 $this->mUpdateContentPerm = 'p_articles_update';
f7e71d3 Add m(Admin|Edit|View)ContentPermission to various classes. update Liber...
Max Kremmel authored
73 $this->mAdminContentPerm = 'p_articles_admin';
1f9adbe make "read more" links conditional, depending on whether there is more t...
Max Kremmel authored
74 }
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
75
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
76 /**
7f0e5d8 more work on getting articles going
Max Kremmel authored
77 * Load the data from the database
cf7b087 add some documentation
Max Kremmel authored
78 * @access public
7f0e5d8 more work on getting articles going
Max Kremmel authored
79 **/
6e30c33 @lsces Tidy up to remove 'STRICT' warnings
lsces authored
80 function load( $pContentId = NULL, $pPluginParams = NULL ) {
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
81 if( @$this->verifyId( $this->mArticleId ) || @$this->verifyId( $this->mContentId ) ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
82 // LibertyContent::load()assumes you have joined already, and will not execute any sql!
83 // This is a significant performance optimization
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
84 $lookupColumn = @$this->verifyId( $this->mArticleId ) ? 'article_id' : 'content_id';
ce4e5d1 use correct hash in query()
Max Kremmel authored
85 $bindVars[] = $lookupId = @BitBase::verifyId( $this->mArticleId ) ? $this->mArticleId : $this->mContentId;
3556172 rename content_load_function to content_load_sql_function
Max Kremmel authored
86 $this->getServicesSql( 'content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars );
838a838 @lsces Add ServicesSQL facility
lsces authored
87
309a5f8 fetch hits as well
bitweaver.org authored
88 $query = "SELECT a.*, lc.*, atype.*, atopic.*, lch.hits,
ce4e5d1 use correct hash in query()
Max Kremmel authored
89 uue.`login` AS `modifier_user`, uue.`real_name` AS `modifier_real_name`,
90 uuc.`login` AS `creator_user`, uuc.`real_name` AS `creator_real_name` ,
6852c98 @lsces Modify to use file_name/source_file shanges in attachments
lsces authored
91 la.`attachment_id` AS `primary_attachment_id`, lf.`file_name` AS `image_attachment_path` $selectSql
ce4e5d1 use correct hash in query()
Max Kremmel authored
92 FROM `".BIT_DB_PREFIX."articles` a
93 LEFT OUTER JOIN `".BIT_DB_PREFIX."article_types` atype ON( atype.`article_type_id` = a.`article_type_id` )
94 LEFT OUTER JOIN `".BIT_DB_PREFIX."article_topics` atopic ON( atopic.`topic_id` = a.`topic_id` )
5a7c858 get articles working with recent schema update
Max Kremmel authored
95 INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id` = a.`content_id` )
c8de5c1 add parenthesis to SQL statements
Max Kremmel authored
96 LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_content_hits` lch ON( lch.`content_id` = lc.`content_id` )
97 LEFT OUTER JOIN `".BIT_DB_PREFIX."users_users` uue ON( uue.`user_id` = lc.`modifier_user_id` )
98 LEFT OUTER JOIN `".BIT_DB_PREFIX."users_users` uuc ON( uuc.`user_id` = lc.`user_id` )
99 LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_attachments` la ON( la.`content_id` = lc.`content_id` AND la.`is_primary` = 'y' )
100 LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_files` lf ON( lf.`file_id` = la.`foreign_id` )
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attachmen...
Max Kremmel authored
101 $joinSql
5a7c858 get articles working with recent schema update
Max Kremmel authored
102 WHERE a.`$lookupColumn`=? $whereSql";
ce4e5d1 use correct hash in query()
Max Kremmel authored
103 $result = $this->mDb->query( $query, $bindVars );
7f0e5d8 more work on getting articles going
Max Kremmel authored
104
105 global $gBitSystem;
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
106 if( $result && $result->numRows() ) {
b548033 @spiderr fix ->fields calls
spiderr authored
107 $this->mInfo = $result->fetchRow();
b99c416 get topic image on load()
Max Kremmel authored
108
8c5f309 clean up articles custom image upload stuff
Max Kremmel authored
109 // if a custom image for the article exists, use that, then use an attachment, then use the topic image
4505032 @nickpalmer Hack articles to use the new primary_attachment_id.
nickpalmer authored
110 $isTopicImage = false;
b99c416 get topic image on load()
Max Kremmel authored
111
b548033 @spiderr fix ->fields calls
spiderr authored
112 $this->mContentId = $this->mInfo['content_id'];
113 $this->mArticleId = $this->mInfo['article_id'];
114 $this->mTopicId = $this->mInfo['topic_id'];
115 $this->mTypeId = $this->mInfo['article_type_id'];
7f0e5d8 more work on getting articles going
Max Kremmel authored
116
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attachmen...
Max Kremmel authored
117 $this->mInfo['thumbnail_url'] = BitArticle::getImageThumbnails( $this->mInfo );
118 $this->mInfo['creator'] = ( !empty( $this->mInfo['creator_real_name'] ) ? $this->mInfo['creator_real_name'] : $this->mInfo['creator_user'] );
119 $this->mInfo['editor'] = ( !empty( $this->mInfo['modifier_real_name'] ) ? $this->mInfo['modifier_real_name'] : $this->mInfo['modifier_user'] );
1102d74 @lsces Roll back getContentUrl to alternate static getDisplayUrl fix
lsces authored
120 $this->mInfo['display_url'] = $this->getDisplayUrl();
067be4c move deprecated image functions to the bottom of the file to issulstrate...
Max Kremmel authored
121 // we need the raw data to display in the textarea
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attachmen...
Max Kremmel authored
122 $this->mInfo['raw'] = $this->mInfo['data'];
067be4c move deprecated image functions to the bottom of the file to issulstrate...
Max Kremmel authored
123 // here we have the displayed data without the ...split... stuff
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attachmen...
Max Kremmel authored
124 $this->mInfo['data'] = preg_replace( LIBERTY_SPLIT_REGEX, "", $this->mInfo['data'] );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
125
0153f3d @lsces Correct documentation package name to articles
lsces authored
126 $comment = new LibertyComment();
fa7948e concatenate whereSql
Max Kremmel authored
127 $this->mInfo['num_comments'] = $comment->getNumComments( $this->mInfo['content_id'] );
adcc311 get html per article working as well and reduce load by only parsing con...
Max Kremmel authored
128
0a8c72a migrate articles to LibertyMime
Max Kremmel authored
129 LibertyMime::load();
adcc311 get html per article working as well and reduce load by only parsing con...
Max Kremmel authored
130
2c96393 make better use of LibertyMime features
Max Kremmel authored
131 if( !empty( $this->mInfo['primary_attachment_id'] ) && !empty( $this->mStorage[$this->mInfo['primary_attachment_id']] )) {
132 $this->mInfo['primary_attachment'] = &$this->mStorage[$this->mInfo['primary_attachment_id']];
133 }
134
edd21fa fix hashkeys and generally get articles working again
Max Kremmel authored
135 $this->mInfo['parsed'] = $this->parseData();
838a838 @lsces Add ServicesSQL facility
lsces authored
136 } else {
137 $this->mArticleId = NULL;
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
138 }
139 }
c58fe86 @nickpalmer Fixed bug with load of article with no hits.
nickpalmer authored
140
5e14ed2 clean up author name code
Max Kremmel authored
141 return( count( $this->mInfo ) );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
142 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
143
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
144 /**
ec0a861 add some more documentation
Max Kremmel authored
145 * Store article data after submission
cf7b087 add some documentation
Max Kremmel authored
146 * @param array pParamHash of values that will be used to store the page
7f0e5d8 more work on getting articles going
Max Kremmel authored
147 * @return bool TRUE on success, FALSE if store could not occur. If FALSE, $this->mErrors will have reason why
148 * @access public
149 **/
ee831c6 get custom article image working
Max Kremmel authored
150 function store( &$pParamHash ) {
151 global $gBitSystem;
d3c05a7 @nickpalmer Move StartTrans() before the calls to LibertyXXX::store() so that rollba...
nickpalmer authored
152 $this->mDb->StartTrans();
0a8c72a migrate articles to LibertyMime
Max Kremmel authored
153 if( $this->verify( $pParamHash )&& LibertyMime::store( $pParamHash ) ) {
f210a14 massive table de-tikification. changed all tiki_ table prefixes with teh...
bitweaver.org authored
154 $table = BIT_DB_PREFIX."articles";
ee831c6 get custom article image working
Max Kremmel authored
155
5a59732 use $this->isValid() to check for $this->mArticleId
Max Kremmel authored
156 if( $this->isValid() ) {
6ce2052 use class package id instead of hashvalue - who can trust anything that ...
Max Kremmel authored
157 $result = $this->mDb->associateUpdate( $table, $pParamHash['article_store'], array( "article_id" => $this->mArticleId ));
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
158 } else {
159 $pParamHash['article_store']['content_id'] = $pParamHash['content_id'];
160 if( isset( $pParamHash['article_id'] )&& is_numeric( $pParamHash['article_id'] ) ) {
ee831c6 get custom article image working
Max Kremmel authored
161 // if pParamHash['article_id'] is set, someone is requesting a particular article_id. Use with caution!
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
162 $pParamHash['article_store']['article_id'] = $pParamHash['article_id'];
163 } else {
f210a14 massive table de-tikification. changed all tiki_ table prefixes with teh...
bitweaver.org authored
164 $pParamHash['article_store']['article_id'] = $this->mDb->GenID( 'articles_article_id_seq' );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
165 }
166 $this->mArticleId = $pParamHash['article_store']['article_id'];
167 $result = $this->mDb->associateInsert( $table, $pParamHash['article_store'] );
168 }
169
170 $this->mDb->CompleteTrans();
171 $this->load();
172 }
6f9ed7a add a link to remove a custom image
Max Kremmel authored
173 return ( count( $this->mErrors ) == 0 );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
174 }
175
176 /**
7f0e5d8 more work on getting articles going
Max Kremmel authored
177 * Make sure the data is safe to store
178 * @param pParamHash be sure to pass by reference in case we need to make modifcations to the hash
179 * @param array pParams reference to hash of values that will be used to store the page, they will be modified where necessary
180 * @return bool TRUE on success, FALSE if verify failed. If FALSE, $this->mErrors will have reason why
181 * @access private
182 **/
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
183 function verify( &$pParamHash ) {
184 global $gBitUser, $gBitSystem;
7f0e5d8 more work on getting articles going
Max Kremmel authored
185
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
186 // make sure we're all loaded up of we have a mArticleId
187 if( $this->mArticleId && empty( $this->mInfo ) ) {
188 $this->load();
189 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
190
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
191 if( @$this->verifyId( $this->mInfo['content_id'] ) ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
192 $pParamHash['content_id'] = $this->mInfo['content_id'];
193 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
194
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
195 // It is possible a derived class set this to something different
04136bd get article submissions working
Max Kremmel authored
196 if( empty( $pParamHash['content_type_guid'] )&& !empty( $this->mContentTypeGuid ) ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
197 $pParamHash['content_type_guid'] = $this->mContentTypeGuid;
198 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
199
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
200 if( @$this->verifyId( $pParamHash['content_id'] ) ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
201 $pParamHash['article_store']['content_id'] = $pParamHash['content_id'];
202 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
203
04136bd get article submissions working
Max Kremmel authored
204 if( !empty( $pParamHash['author_name'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
205 $pParamHash['article_store']['author_name'] = $pParamHash['author_name'];
206 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
207
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
208 if( @$this->verifyId( $pParamHash['topic_id'] ) ) {
04136bd get article submissions working
Max Kremmel authored
209 $pParamHash['article_store']['topic_id'] =( int )$pParamHash['topic_id'];
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
210 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
211
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
212 if( @$this->verifyId( $pParamHash['article_type_id'] ) ) {
04136bd get article submissions working
Max Kremmel authored
213 $pParamHash['article_store']['article_type_id'] =( int )$pParamHash['article_type_id'];
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
214 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
215
216 if( !empty( $pParamHash['format_guid'] ) ) {
217 $pParamHash['content_store']['format_guid'] = $pParamHash['format_guid'];
218 }
219
220 // we do the substr on load. otherwise we need to store the same data twice.
04136bd get article submissions working
Max Kremmel authored
221 if( !empty( $pParamHash['edit'] ) ) {
4158723 fix article preview
Max Kremmel authored
222 $pParamHash['content_store']['data'] = $pParamHash['edit'];
223 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
224
04136bd get article submissions working
Max Kremmel authored
225 if( !empty( $pParamHash['rating'] ) ) {
226 $pParamHash['article_store']['rating'] =( int )( $pParamHash['rating'] );
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
227 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
228
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
229 // check for name issues, first truncate length if too long
230 if( !empty( $pParamHash['title'] ) ) {
5a59732 use $this->isValid() to check for $this->mArticleId
Max Kremmel authored
231 if( !$this->isValid() ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
232 if( empty( $pParamHash['title'] ) ) {
8e16677 change the error message name to title to reuse the term used in the for...
Sylvie Greverend authored
233 $this->mErrors['title'] = 'You must specify a title.';
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
234 } else {
f9dba4a support BIT_CONTENT_MAX_TITLE_LEN for hand tinkering databases to have l...
Wakeworks authored
235 $pParamHash['content_store']['title'] = substr( $pParamHash['title'], 0, BIT_CONTENT_MAX_TITLE_LEN );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
236 }
237 } else {
f9dba4a support BIT_CONTENT_MAX_TITLE_LEN for hand tinkering databases to have l...
Wakeworks authored
238 $pParamHash['content_store']['title'] =( isset( $pParamHash['title'] ))? substr( $pParamHash['title'], 0, BIT_CONTENT_MAX_TITLE_LEN ): '';
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
239 }
240 } else if( empty( $pParamHash['title'] ) ) {
241 // no name specified
8e16677 change the error message name to title to reuse the term used in the for...
Sylvie Greverend authored
242 $this->mErrors['title'] = 'You must specify a title';
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
243 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
244
04136bd get article submissions working
Max Kremmel authored
245 if( !empty( $pParamHash['publish_Month'] ) ) {
504ca59 @lsces Manage UTC dates correctly. - publishing at 10am after daylight saving w...
lsces authored
246 $dateString = $this->mDate->gmmktime(
247 $pParamHash['publish_Hour'],
248 $pParamHash['publish_Minute'],
249 isset($pParamHash['publish_Second']) ? $pParamHash['publish_Second'] : 0,
250 $pParamHash['publish_Month'],
251 $pParamHash['publish_Day'],
252 $pParamHash['publish_Year']
253 );
254
255 $timestamp = $this->mDate->getUTCFromDisplayDate( $dateString );
04136bd get article submissions working
Max Kremmel authored
256 if( $timestamp !== -1 ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
257 $pParamHash['publish_date'] = $timestamp;
258 }
259 }
5cbc7ec get permissions sorted when trying to view submitted article
Max Kremmel authored
260 if( !empty( $pParamHash['publish_date'] ) ) {
261 $pParamHash['article_store']['publish_date'] = $pParamHash['publish_date'];
262 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
263
04136bd get article submissions working
Max Kremmel authored
264 if( !empty( $pParamHash['expire_Month'] ) ) {
504ca59 @lsces Manage UTC dates correctly. - publishing at 10am after daylight saving w...
lsces authored
265 $dateString = $this->mDate->gmmktime(
266 $pParamHash['expire_Hour'],
267 $pParamHash['expire_Minute'],
268 isset($pParamHash['expire_Second']) ? $pParamHash['expire_Second'] : 0,
269 $pParamHash['expire_Month'],
270 $pParamHash['expire_Day'],
271 $pParamHash['expire_Year']
272 );
273
274 $timestamp = $this->mDate->getUTCFromDisplayDate( $dateString );
04136bd get article submissions working
Max Kremmel authored
275 if( $timestamp !== -1 ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
276 $pParamHash['expire_date'] = $timestamp;
277 }
278 }
04136bd get article submissions working
Max Kremmel authored
279 if( !empty( $pParamHash['expire_date'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
280 $pParamHash['article_store']['expire_date'] = $pParamHash['expire_date'];
281 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
282
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
283 if( @$this->verifyId( $pParamHash['status_id'] ) ) {
04136bd get article submissions working
Max Kremmel authored
284 if( $pParamHash['status_id'] > ARTICLE_STATUS_PENDING ) {
e89540d move to gContent perm functions to fully support liberty content permiss...
Max Kremmel authored
285 if( $gBitUser->hasPermission( 'p_articles_approve_submission' )) {
04136bd get article submissions working
Max Kremmel authored
286 $pParamHash['article_store']['status_id'] =( int )( $pParamHash['status_id'] );
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
287 } else {
288 $pParamHash['article_store']['status_id'] = ARTICLE_STATUS_PENDING;
289 }
290 } else {
04136bd get article submissions working
Max Kremmel authored
291 $pParamHash['article_store']['status_id'] =( int )( $pParamHash['status_id'] );
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
292 }
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
293 } elseif( @$this->verifyId( $this->mInfo['status_id'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
294 $pParamHash['article_store']['status_id'] = $this->mInfo['status_id'];
295 } else {
1987daf more permissions housekeeping and tidyup
Max Kremmel authored
296 if( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || $gBitUser->hasPermission( 'p_articles_auto_approve' ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
297 $pParamHash['article_store']['status_id'] = ARTICLE_STATUS_APPROVED;
298 } else {
299 $pParamHash['article_store']['status_id'] = ARTICLE_STATUS_PENDING; // Default status
300 }
301 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
302
adcc311 get html per article working as well and reduce load by only parsing con...
Max Kremmel authored
303 // content preferences
304 $prefs = array();
305 if( $gBitUser->hasPermission( 'p_liberty_enter_html' ) ) {
306 $prefs[] = 'content_enter_html';
307 }
308
309 foreach( $prefs as $pref ) {
310 if( !empty( $pParamHash['preferences'][$pref] ) ) {
311 $pParamHash['preferences_store'][$pref] = $pParamHash['preferences'][$pref];
312 } else {
313 $pParamHash['preferences_store'][$pref] = NULL;
314 }
315 }
316
317 if ( array_search( $pParamHash['article_store']['status_id'], array( ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING ) ) ) {
5330bc5 Merge recent changes to HEAD
Sean Lee authored
318 $this->mInfo["no_index"] = true ;
319 }
26322d2 @lsces Strip extra white space
lsces authored
320
283eabc @tekimaki call verify on parent classes if verify fails to return all errors to us...
tekimaki authored
321 // if we have an error we get them all by checking parent classes for additional errors
322 if( count( $this->mErrors ) > 0 ){
323 parent::verify( $pParamHash );
324 }
5330bc5 Merge recent changes to HEAD
Sean Lee authored
325
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
326 return( count( $this->mErrors )== 0 );
327 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
328
cf7b087 add some documentation
Max Kremmel authored
329 /**
ec0a861 add some more documentation
Max Kremmel authored
330 * Deal with images and text, modify them apprpriately that they can be returned to the form.
331 * @param $previewData data submitted by form - generally $_REQUEST
332 * @return array of data compatible with article form
333 * @access public
334 **/
7184912 use constants instead of hardcoded package names and ensure that image s...
Max Kremmel authored
335 function preparePreview( $pParamHash ) {
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored
336 global $gBitSystem, $gBitUser;
7f0e5d8 more work on getting articles going
Max Kremmel authored
337
7184912 use constants instead of hardcoded package names and ensure that image s...
Max Kremmel authored
338 $data = $pParamHash;
04136bd get article submissions working
Max Kremmel authored
339 $this->verify( $data );
7184912 use constants instead of hardcoded package names and ensure that image s...
Max Kremmel authored
340 $data = array_merge( $pParamHash, $data['content_store'], $data['article_store'] );
c24c28c fix articles preview
Max Kremmel authored
341 $data['raw'] = $data['edit'];
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored
342
04136bd get article submissions working
Max Kremmel authored
343 if( empty( $data['user_id'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
344 $data['user_id'] = $gBitUser->mUserId;
345 }
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored
346
04136bd get article submissions working
Max Kremmel authored
347 if( empty( $data['hits'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
348 $data['hits'] = 0;
349 }
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored
350
04136bd get article submissions working
Max Kremmel authored
351 if( empty( $data['publish_date'] ) ) {
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored
352 $data['publish_date'] = $gBitSystem->getUTCTime();
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
353 }
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored
354
04136bd get article submissions working
Max Kremmel authored
355 if( empty( $data['article_type_id'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
356 $data['article_type_id'] = 1;
357 }
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored
358
04136bd get article submissions working
Max Kremmel authored
359 if( empty( $data['topic_id'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
360 $data['topic_id'] = 1;
361 }
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored
362
edd21fa fix hashkeys and generally get articles working again
Max Kremmel authored
363 if( empty( $data['parsed'] ) ) {
ca235b0 allow caching to various files by allowing specification of cache file e...
Max Kremmel authored
364 $data['no_cache'] = TRUE;
edd21fa fix hashkeys and generally get articles working again
Max Kremmel authored
365 $data['parsed'] = $this->parseData( $data );
ca235b0 allow caching to various files by allowing specification of cache file e...
Max Kremmel authored
366 // replace the split syntax with a horizontal rule
edd21fa fix hashkeys and generally get articles working again
Max Kremmel authored
367 $data['parsed'] = preg_replace( LIBERTY_SPLIT_REGEX, "<hr />", $data['parsed'] );
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
368 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
369
19446b5 @lsces Tweak for PHP5.3 compatibility
lsces authored
370 $articleType = new BitArticleType( $data['article_type_id'] );
371 $articleTopic = new BitArticleTopic( $data['topic_id'] );
04136bd get article submissions working
Max Kremmel authored
372 $data = array_merge( $data, $articleType->mInfo, $articleTopic->mInfo );
7f0e5d8 more work on getting articles going
Max Kremmel authored
373
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
374 return $data;
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
375 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
376
ec0a861 add some more documentation
Max Kremmel authored
377 /**
378 * Get the URL for any given article image
379 * @param $pParamHash pass in full set of data returned from article query
380 * @return url to image
381 * @access public
382 **/
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attachmen...
Max Kremmel authored
383 function getImageThumbnails( $pParamHash ) {
384 global $gBitSystem, $gThumbSizes;
daf5fbe existing image attachment working as well now - w00t!
Max Kremmel authored
385 $ret = NULL;
d8de906 replace individual function parameters with an array of options when usi...
Max Kremmel authored
386
387 $thumbHash['mime_image'] = FALSE;
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attachmen...
Max Kremmel authored
388 if( !empty( $pParamHash['image_attachment_path'] )) {
6852c98 @lsces Modify to use file_name/source_file shanges in attachments
lsces authored
389 $thumbHash['source_file'] = $pParamHash['image_attachment_path'];
d8de906 replace individual function parameters with an array of options when usi...
Max Kremmel authored
390 $ret = liberty_fetch_thumbnails( $thumbHash );
daf5fbe existing image attachment working as well now - w00t!
Max Kremmel authored
391 } elseif( !empty( $pParamHash['has_topic_image'] ) && $pParamHash['has_topic_image'] == 'y' ) {
6852c98 @lsces Modify to use file_name/source_file shanges in attachments
lsces authored
392 $thumbHash['source_file'] = preg_replace( "#^/+#", "", BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] ));
d8de906 replace individual function parameters with an array of options when usi...
Max Kremmel authored
393 $ret = liberty_fetch_thumbnails( $thumbHash );
daf5fbe existing image attachment working as well now - w00t!
Max Kremmel authored
394 }
d8de906 replace individual function parameters with an array of options when usi...
Max Kremmel authored
395
daf5fbe existing image attachment working as well now - w00t!
Max Kremmel authored
396 return $ret;
397 }
398
ec0a861 add some more documentation
Max Kremmel authored
399 /**
400 * Removes currently loaded article
401 * @return bool TRUE on success, FALSE on failure
402 * @access public
403 **/
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored
404 function expunge() {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
405 $ret = FALSE;
406 if( $this->isValid() ) {
8c5f309 clean up articles custom image upload stuff
Max Kremmel authored
407 $this->mDb->StartTrans();
f210a14 massive table de-tikification. changed all tiki_ table prefixes with teh...
bitweaver.org authored
408 $query = "DELETE FROM `".BIT_DB_PREFIX."articles` WHERE `content_id` = ?";
8c5f309 clean up articles custom image upload stuff
Max Kremmel authored
409 $result = $this->mDb->query( $query, array( $this->mContentId ) );
0a8c72a migrate articles to LibertyMime
Max Kremmel authored
410 if( LibertyMime::expunge() ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
411 $ret = TRUE;
412 $this->mDb->CompleteTrans();
413 } else {
414 $this->mDb->RollbackTrans();
8c5f309 clean up articles custom image upload stuff
Max Kremmel authored
415 }
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
416 }
417 return $ret;
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
418 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
419
ec0a861 add some more documentation
Max Kremmel authored
420 /**
421 * Check if there is an article loaded
422 * @return bool TRUE on success, FALSE on failure
423 * @access public
424 **/
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
425 function isValid() {
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
426 return( $this->verifyId( $this->mArticleId ) && $this->verifyId( $this->mContentId ) );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
427 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
428
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
429 /**
fbe5d52 detikify liberty
Max Kremmel authored
430 * This function generates a list of records from the liberty_content database for use in a list page
ec0a861 add some more documentation
Max Kremmel authored
431 * @param $pParamHash contains an array of conditions to sort by
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
432 * @return array of articles
ec0a861 add some more documentation
Max Kremmel authored
433 * @access public
7f0e5d8 more work on getting articles going
Max Kremmel authored
434 **/
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
435 function getList( &$pParamHash ) {
b7cc1a1 add the factility to view the history of articles, and an auto approve f...
Hash9 authored
436 global $gBitSystem, $gBitUser, $gLibertySystem;
437
fe614d1 apply default sort_mode before LibertyContent::prepGetList();
Max Kremmel authored
438 if( empty( $pParamHash['sort_mode'] ) ) {
15d6f11 remove odd sort_mode if articles_auto_approve feature is set
Max Kremmel authored
439 // no idea what this is supposed to do
440 //$pParamHash['sort_mode'] = $gBitSystem->isFeatureActive('articles_auto_approve') ? 'order_key_desc' : 'publish_date_desc';
441 $pParamHash['sort_mode'] = 'publish_date_desc';
fe614d1 apply default sort_mode before LibertyContent::prepGetList();
Max Kremmel authored
442 }
443
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
444 LibertyContent::prepGetList( $pParamHash );
445
838a838 @lsces Add ServicesSQL facility
lsces authored
446 $joinSql = '';
447 $selectSql = '';
448 $bindVars = array();
449 array_push( $bindVars, $this->mContentTypeGuid );
f4772a2 make articles and wiki aware of list services
Max Kremmel authored
450 $this->getServicesSql( 'content_list_sql_function', $selectSql, $joinSql, $whereSql, $bindVars, NULL, $pParamHash );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
451
838a838 @lsces Add ServicesSQL facility
lsces authored
452 $find = $pParamHash['find'];
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
453 if( is_array( $find ) ) {
c6e286d add more options to limit getList() by
Max Kremmel authored
454 // you can use an array of articles
fa7948e concatenate whereSql
Max Kremmel authored
455 $whereSql .= " AND lc.`title` IN( ".implode( ',',array_fill( 0, count( $find ),'?' ) )." )";
962a29a @lsces Tidy array merges
lsces authored
456 $bindVars = array_merge( $bindVars, $find );
d568668 fix user_id where clause
Max Kremmel authored
457 } elseif( is_string( $find ) ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
458 // or a string
fa7948e concatenate whereSql
Max Kremmel authored
459 $whereSql .= " AND UPPER( lc.`title` ) LIKE ? ";
962a29a @lsces Tidy array merges
lsces authored
460 $bindVars[] = '%'.strtoupper( $find ).'%';
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
461 } elseif( @$this->verifyId( $pParamHash['user_id'] ) ) {
d568668 fix user_id where clause
Max Kremmel authored
462 // or gate on a user
b0b7d72 @tekimaki fix center_list_articles so it actually displays articles when included ...
tekimaki authored
463 $whereSql .= " AND lc.`user_id` = ? ";
464 $bindVars[] = (int)$pParamHash['user_id'];
d6cf45c add option to select by topic name
Max Kremmel authored
465 }
466
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
467 if( @$this->verifyId( $pParamHash['status_id'] ) ) {
838a838 @lsces Add ServicesSQL facility
lsces authored
468 $whereSql .= " AND a.`status_id` = ? ";
469 $bindVars[] = $pParamHash['status_id'];
c6e286d add more options to limit getList() by
Max Kremmel authored
470 }
471
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
472 if( @$this->verifyId( $pParamHash['type_id'] ) ) {
838a838 @lsces Add ServicesSQL facility
lsces authored
473 $whereSql .= " AND a.`article_type_id` = ? ";
474 $bindVars[] = ( int )$pParamHash['type_id'];
c6e286d add more options to limit getList() by
Max Kremmel authored
475 }
476
9090a1d @spiderr remove old spell checking
spiderr authored
477 // TODO: we need to check if the article wants to be viewed before / after respective dates
478 // someone better at SQL please get this working without an additional db call - xing
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
479 $now = $gBitSystem->getUTCTime();
47fee95 respect permissions when trying to fetch future and expired articles
Max Kremmel authored
480 if( !empty( $pParamHash['show_future'] ) && !empty( $pParamHash['show_expired'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
481 // this will show all articles at once - future, current and expired
47fee95 respect permissions when trying to fetch future and expired articles
Max Kremmel authored
482 } elseif( !empty( $pParamHash['show_future'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
483 // hide expired articles
5a8daef respect settings in article types settings regarding the show before pub...
Max Kremmel authored
484 $whereSql .= " AND ( a.`expire_date` > ? OR atype.`show_post_expire` = ? ) ";
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
485 $bindVars[] = ( int )$now;
5a8daef respect settings in article types settings regarding the show before pub...
Max Kremmel authored
486 $bindVars[] = 'y';
47fee95 respect permissions when trying to fetch future and expired articles
Max Kremmel authored
487 } elseif( !empty( $pParamHash['show_expired'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
488 // hide future articles
5a8daef respect settings in article types settings regarding the show before pub...
Max Kremmel authored
489 $whereSql .= " AND ( a.`publish_date` < ? OR atype.`show_pre_publ` = ? ) ";
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
490 $bindVars[] = ( int )$now;
5a8daef respect settings in article types settings regarding the show before pub...
Max Kremmel authored
491 $bindVars[] = 'y';
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
492 } elseif( !empty( $pParamHash['get_future'] )) {
493 // show only future
47fee95 respect permissions when trying to fetch future and expired articles
Max Kremmel authored
494 // if we're trying to view these articles, we better have the perms to do so
495 if( !$gBitUser->hasPermission( 'p_articles_admin' )) {
496 return array();
497 }
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
498 $whereSql .= " AND a.`publish_date` > ?";
499 $bindVars[] = ( int )$now;
500 } elseif( !empty( $pParamHash['get_expired'] )) {
501 // show only expired articles
47fee95 respect permissions when trying to fetch future and expired articles
Max Kremmel authored
502 // if we're trying to view these articles, we better have the perms to do so
503 if( !$gBitUser->hasPermission( 'p_articles_admin' )) {
504 return array();
505 }
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
506 $whereSql .= " AND a.`expire_date` < ? ";
507 $bindVars[] = ( int )$now;
508 } else {
47fee95 respect permissions when trying to fetch future and expired articles
Max Kremmel authored
509 // hide future and expired articles - this is the default behaviour
5a8daef respect settings in article types settings regarding the show before pub...
Max Kremmel authored
510 // we need all these AND and ORs to ensure that other conditions such as status_id are respected as well
511 $whereSql .= " AND (( a.`publish_date` > a.`expire_date` ) OR (( a.`publish_date` < ? OR atype.`show_pre_publ` = ? ) AND ( a.`expire_date` > ? OR atype.`show_post_expire` = ? ))) ";
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
512 $bindVars[] = ( int )$now;
5a8daef respect settings in article types settings regarding the show before pub...
Max Kremmel authored
513 $bindVars[] = 'y';
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
514 $bindVars[] = ( int )$now;
5a8daef respect settings in article types settings regarding the show before pub...
Max Kremmel authored
515 $bindVars[] = 'y';
9090a1d @spiderr remove old spell checking
spiderr authored
516 }
517
0b9692b merge recent changes into HEAD
Max Kremmel authored
518 if( @$this->verifyId( $pParamHash['topic_id'] ) ) {
838a838 @lsces Add ServicesSQL facility
lsces authored
519 $whereSql .= " AND a.`topic_id` = ? ";
520 $bindVars[] = ( int )$pParamHash['topic_id'];
0b9692b merge recent changes into HEAD
Max Kremmel authored
521 } elseif( !empty( $pParamHash['topic'] ) ) {
ea85f9e new API for parseData(); please view ApiChangeLog for details
Max Kremmel authored
522 $whereSql .= " AND UPPER( atopic.`topic_name` ) = ? ";
838a838 @lsces Add ServicesSQL facility
lsces authored
523 $bindVars[] = strtoupper( $pParamHash['topic'] );
0b9692b merge recent changes into HEAD
Max Kremmel authored
524 } else {
44c943d @lsces Fix reserved word field names
lsces authored
525 $whereSql .= " AND ( atopic.`active_topic` != 'n' OR atopic.`active_topic` IS NULL ) ";
526 //$whereSql .= " AND atopic.`active_topic` != 'n' ";
0b9692b merge recent changes into HEAD
Max Kremmel authored
527 }
528
42b7561 explicit column names to get around oracle pain ORA-00918
bitweaver.org authored
529 // Oracle is very particular about naming multiple columns, so need to explicity name them ORA-00918: column ambiguously defined
7de2dff @lsces Fix white space problem before list query so that it can be converted to...
lsces authored
530 $query =
531 "SELECT
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attachmen...
Max Kremmel authored
532 a.`article_id`, a.`description`, a.`author_name`, a.`publish_date`, a.`expire_date`, a.`rating`,
299e478 add missing lch.`hits`
Max Kremmel authored
533 atopic.`topic_id`, atopic.`topic_name`, atopic.`has_topic_image`, atopic.`active_topic`,
534 astatus.`status_id`, astatus.`status_name`,
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attachmen...
Max Kremmel authored
535 lch.`hits`,
6852c98 @lsces Modify to use file_name/source_file shanges in attachments
lsces authored
536 atype.*, lc.*, la.`attachment_id` AS `primary_attachment_id`, lf.`file_name` AS `image_attachment_path` $selectSql
f210a14 massive table de-tikification. changed all tiki_ table prefixes with teh...
bitweaver.org authored
537 FROM `".BIT_DB_PREFIX."articles` a
c8de5c1 add parenthesis to SQL statements
Max Kremmel authored
538 INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON( lc.`content_id` = a.`content_id` )
539 INNER JOIN `".BIT_DB_PREFIX."article_status` astatus ON( astatus.`status_id` = a.`status_id` )
540 LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_content_hits` lch ON( lc.`content_id` = lch.`content_id` )
541 LEFT OUTER JOIN `".BIT_DB_PREFIX."article_topics` atopic ON( atopic.`topic_id` = a.`topic_id` )
542 LEFT OUTER JOIN `".BIT_DB_PREFIX."article_types` atype ON( atype.`article_type_id` = a.`article_type_id` )
543 LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_attachments` la ON( la.`content_id` = lc.`content_id` AND la.`is_primary` = 'y' )
544 LEFT OUTER JOIN `".BIT_DB_PREFIX."liberty_files` lf ON( lf.`file_id` = la.`foreign_id` )
545 $joinSql
fa7948e concatenate whereSql
Max Kremmel authored
546 WHERE lc.`content_type_guid` = ? $whereSql
a39e645 rename some methods in BitDbBase to meet bitweaver standards. all change...
Max Kremmel authored
547 ORDER BY ".$this->mDb->convertSortmode( $pParamHash['sort_mode'] );
04136bd get article submissions working
Max Kremmel authored
548
f210a14 massive table de-tikification. changed all tiki_ table prefixes with teh...
bitweaver.org authored
549 $query_cant = "SELECT COUNT( * )FROM `".BIT_DB_PREFIX."articles` a
ea85f9e new API for parseData(); please view ApiChangeLog for details
Max Kremmel authored
550 INNER JOIN `".BIT_DB_PREFIX."liberty_content` lc ON lc.`content_id` = a.`content_id`
551 LEFT OUTER JOIN `".BIT_DB_PREFIX."article_topics` atopic ON atopic.`topic_id` = a.`topic_id` $joinSql
5a8daef respect settings in article types settings regarding the show before pub...
Max Kremmel authored
552 LEFT OUTER JOIN `".BIT_DB_PREFIX."article_types` atype ON atype.`article_type_id` = a.`article_type_id`
838a838 @lsces Add ServicesSQL facility
lsces authored
553 WHERE lc.`content_type_guid` = ? $whereSql";
80fa1d9 @spiderr Added uspport for multiple database backend support. This necessitates r...
spiderr authored
554
838a838 @lsces Add ServicesSQL facility
lsces authored
555 $result = $this->mDb->query( $query, $bindVars, $pParamHash['max_records'], $pParamHash['offset'] );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
556 $ret = array();
19446b5 @lsces Tweak for PHP5.3 compatibility
lsces authored
557 $comment = new LibertyComment();
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
558 while( $res = $result->fetchRow() ) {
390d6f9 make use of the parseSplit() method
Max Kremmel authored
559 // get this stuff parsed
560 $res = array_merge( $this->parseSplit( $res, $gBitSystem->getConfig( 'articles_description_length', 500 )), $res );
ddb9454 @tekimaki cleans up split parser and when hellip should be added
tekimaki authored
561
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attachmen...
Max Kremmel authored
562 $res['thumbnail_url'] = BitArticle::getImageThumbnails( $res );
563 $res['num_comments'] = $comment->getNumComments( $res['content_id'] );
83ee2ff @lsces Further tidyup on strict warnings
lsces authored
564 $res['display_url'] = self::getDisplayUrlFromHash( $res );
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attachmen...
Max Kremmel authored
565 $res['display_link'] = $this->getDisplayLink( $res['title'], $res );
566
2c96393 make better use of LibertyMime features
Max Kremmel authored
567 // fetch the primary attachment that we can display the file on the front page if needed
473cf16 @lsces Use the static loadAttachment function
lsces authored
568 $res['primary_attachment'] = LibertyMime::loadAttachment( $res['primary_attachment_id'] );
2c96393 make better use of LibertyMime features
Max Kremmel authored
569
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
570 $ret[] = $res;
571 }
7f0e5d8 more work on getting articles going
Max Kremmel authored
572
838a838 @lsces Add ServicesSQL facility
lsces authored
573 $pParamHash["cant"] = $this->mDb->getOne( $query_cant, $bindVars );
7f0e5d8 more work on getting articles going
Max Kremmel authored
574
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
575 LibertyContent::postGetList( $pParamHash );
7f0e5d8 more work on getting articles going
Max Kremmel authored
576
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
577 return $ret;
578 }
579
c32c1fa @lsces Display article using structure_id reference.
lsces authored
580 /**
581 * Returns include file that will setup vars for display
582 * @return the fully specified path to file to be included
583 */
584 function getRenderFile() {
585 return ARTICLES_PKG_PATH."display_article_inc.php";
586 }
587
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
588 /**
589 * Get a list of articles that are to be published in the future
26322d2 @lsces Strip extra white space
lsces authored
590 *
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
591 * @param array $pParamHash contains listing options - same as getList()
592 * @access public
593 * @return array of articles
594 */
595 function getFutureList( &$pParamHash ) {
596 $pParamHash['get_future'] = TRUE;
597 return( $this->getList( $pParamHash ));
598 }
599
600 /**
601 * Get list of articles that have expired and are not displayed on the site anymore
26322d2 @lsces Strip extra white space
lsces authored
602 *
6ab6b0a add options to fetch various combinations of future articles and expired...
Max Kremmel authored
603 * @param array $pParamHash contains listing options - same as getList()
604 * @access public
605 * @return array of articles
606 */
607 function getExpiredList( &$pParamHash ) {
608 $pParamHash['get_expired'] = TRUE;
609 return( $this->getList( $pParamHash ));
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
610 }
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
611
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
612 /**
cf7b087 add some documentation
Max Kremmel authored
613 * Generates the URL to the article
614 * @return the link to the full article
7f0e5d8 more work on getting articles going
Max Kremmel authored
615 */
b74dc03 @lsces Match parameter hash to base function
lsces authored
616 public static function getDisplayUrlFromHash( &$pParamHash ) {
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
617 global $gBitSystem;
618
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
619 $ret = NULL;
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
620
83ee2ff @lsces Further tidyup on strict warnings
lsces authored
621 if( @BitBase::verifyId( $pParamHash['article_id'] ) ) {
475f224 another batch of kernel_prefs name cleanup. this should be it
Max Kremmel authored
622 if( $gBitSystem->isFeatureActive( 'pretty_urls_extended' ) ) {
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
623 // Not needed since it's a number: $ret = ARTICLES_PKG_URL."view/".$this->mArticleId;
f792d72 @spiderr major migration of getDisplayUrl to ->getDisplayUrl and ::getDisplayUrlF...
spiderr authored
624 $ret = ARTICLES_PKG_URL.$pParamHash['article_id'];
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
625 } else if( $gBitSystem->isFeatureActive( 'pretty_urls' ) ) {
f792d72 @spiderr major migration of getDisplayUrl to ->getDisplayUrl and ::getDisplayUrlF...
spiderr authored
626 $ret = ARTICLES_PKG_URL.$pParamHash['article_id'];
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
627 } else {
f792d72 @spiderr major migration of getDisplayUrl to ->getDisplayUrl and ::getDisplayUrlF...
spiderr authored
628 $ret = ARTICLES_PKG_URL."read.php?article_id=".$pParamHash['article_id'];
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
629 }
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
630 }
6d30434 try to standardise getDisplayUrl accross content types a bit and add som...
Max Kremmel authored
631
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored
632 return $ret;
633 }
cf7b087 add some documentation
Max Kremmel authored
634
83ee2ff @lsces Further tidyup on strict warnings
lsces authored
635 /**
636 * Function that returns link to display an image
637 * @return the url to display the gallery.
638 */
639 public function getDisplayUrl() {
640 $info = array( 'article_id' => $this->mArticleId );
641 return self::getDisplayUrlFromHash( $info );
642 }
643
cf7b087 add some documentation
Max Kremmel authored
644 /**
645 * get a list of all available statuses
646 * @return an array of available statuses
647 * @access public
648 **/
649 function getStatusList() {
650 global $gBitSystem;
f210a14 massive table de-tikification. changed all tiki_ table prefixes with teh...
bitweaver.org authored
651 $query = "SELECT * FROM `".BIT_DB_PREFIX."article_status`";
cf7b087 add some documentation
Max Kremmel authored
652 $result = $gBitSystem->mDb->query( $query );
653 return $result->getRows();
654 }
655
656 /**
657 * set the status of an article
658 * @param $pStatusId new status id of the article
659 * @param $pArticleId of the article that is being changed - if not set, it will attemtp to change the currently loaded article
660 * @return new status of article on success - else returns NULL
661 * @access public
662 **/
5330bc5 Merge recent changes to HEAD
Sean Lee authored
663 function setStatus( $pStatusId, $pArticleId = NULL, $pContentId = NULL ) {
9090a1d @spiderr remove old spell checking
spiderr authored
664 global $gBitSystem;
cf7b087 add some documentation
Max Kremmel authored
665 $validStatuses = array( ARTICLE_STATUS_DENIED, ARTICLE_STATUS_DRAFT, ARTICLE_STATUS_PENDING, ARTICLE_STATUS_APPROVED, ARTICLE_STATUS_RETIRED );
666
667 if( !in_array( $pStatusId, $validStatuses ) ) {
668 $this->mErrors[] = "Invalid article status";
669 return FALSE;
670 }
671
5330bc5 Merge recent changes to HEAD
Sean Lee authored
672 if( empty( $pContentId ) and $this->isValid()) $pContentId = $this->mContentId ;
673 if( empty( $pArticleId ) and $this->isValid()) $pArticleId = $this->mArticleId ;
674 if( !empty( $pContentId ) and !$this->isValid()) $this->mContentId = $pContentId ;
675 if( !empty( $pArticleId ) and !$this->isValid()) $this->mArticleId = $pArticleId ;
676
cf7b087 add some documentation
Max Kremmel authored
677 if( empty( $pArticleId ) && $this->isValid() ) {
678 $pArticleId = $this->mArticleId;
679 }
680
54fb5b7 merge recent changes into HEAD
Max Kremmel authored
681 if( @$this->verifyId( $pArticleId ) ) {
f210a14 massive table de-tikification. changed all tiki_ table prefixes with teh...
bitweaver.org authored
682 $sql = "UPDATE `".BIT_DB_PREFIX."articles` SET `status_id` = ? WHERE `article_id` = ?";
cf7b087 add some documentation
Max Kremmel authored
683 $rs = $this->mDb->query( $sql, array( $pStatusId, $pArticleId ));
5330bc5 Merge recent changes to HEAD
Sean Lee authored
684 // Calling the index function for approved articles ...
685 if( $gBitSystem->isPackageActive( 'search' ) ) {
686 include_once( SEARCH_PKG_PATH.'refresh_functions.php' );
687 if ($pStatusId == ARTICLE_STATUS_APPROVED) {
688 refresh_index($this);
b7cc1a1 add the factility to view the history of articles, and an auto approve f...
Hash9 authored
689 } elseif (!$pStatusId == ARTICLE_STATUS_RETIRED) {
5330bc5 Merge recent changes to HEAD
Sean Lee authored
690 delete_index($pContentId); // delete it from the search index unless retired ...
691 }
692 }
cf7b087 add some documentation
Max Kremmel authored
693 return $pStatusId;
694 }
695 }
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
696 }
686911b final 'avail' test
bitweaver.org authored
697
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored
698 ?>
Something went wrong with that request. Please try again.