Skip to content
Newer
Older
100644 699 lines (609 sloc) 26.1 KB
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
1 <?php
2 /**
9dbee19 Strip down CVS keywords.
cvs2git authored Jun 9, 2010
3 * @version $Header$
0153f3d @lsces Correct documentation package name to articles
lsces authored Jun 19, 2008
4 * @package articles
d403bf6 @lsces Add PHPDoc headings to package
lsces authored Oct 30, 2005
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 Oct 1, 2009
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 Oct 1, 2009
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 Oct 30, 2005
11 *
9dbee19 Strip down CVS keywords.
cvs2git authored Jun 9, 2010
12 * $Id$
d403bf6 @lsces Add PHPDoc headings to package
lsces authored Oct 30, 2005
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 Jun 9, 2010
19 * @version $Revision$
d403bf6 @lsces Add PHPDoc headings to package
lsces authored Oct 30, 2005
20 */
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
21
22 /**
d403bf6 @lsces Add PHPDoc headings to package
lsces authored Oct 30, 2005
23 * Required setup
24 */
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
25 require_once( ARTICLES_PKG_PATH.'BitArticleTopic.php' );
26 require_once( ARTICLES_PKG_PATH.'BitArticleType.php' );
0a8c72a migrate articles to LibertyMime
Max Kremmel authored May 31, 2008
27 require_once( LIBERTY_PKG_PATH.'LibertyMime.php' );
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
28 require_once( LIBERTY_PKG_PATH.'LibertyComment.php' );
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
29
ab5236a @tekimaki define constant in class file like other pkgs
tekimaki authored Feb 26, 2008
30 define( 'BITARTICLE_CONTENT_TYPE_GUID', 'bitarticle' );
31
6e1bd68 @lsces Tidy phpdoc tags for classes, and heading block
lsces authored Jun 22, 2007
32 /**
0153f3d @lsces Correct documentation package name to articles
lsces authored Jun 19, 2008
33 * @package articles
6e1bd68 @lsces Tidy phpdoc tags for classes, and heading block
lsces authored Jun 22, 2007
34 */
0a8c72a migrate articles to LibertyMime
Max Kremmel authored May 31, 2008
35 class BitArticle extends LibertyMime {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
36 /**
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
37 * Primary key for articles
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
38 * @access public
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
39 */
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
40 var $mArticleId;
41 var $mTypeId;
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
42 var $mTopicId;
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
43
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
44 /**
ec0a861 add some more documentation
Max Kremmel authored Sep 11, 2005
45 * Initiate the articles class
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
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 Aug 13, 2005
49 **/
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
50 function BitArticle( $pArticleId=NULL, $pContentId=NULL ) {
35844b7 @spiderr replace all PHP4 style calls to LibertyMime base constructors with pa…
spiderr authored May 6, 2012
51 parent::__construct();
f7e71d3 Add m(Admin|Edit|View)ContentPermission to various classes. update Li…
Max Kremmel authored Jul 16, 2007
52 $this->registerContentType(
53 BITARTICLE_CONTENT_TYPE_GUID, array(
4cc93bb @tekimaki define the content type guid in class constructor like other pkgs
tekimaki authored May 18, 2008
54 'content_type_guid' => BITARTICLE_CONTENT_TYPE_GUID,
9dc138a @tekimaki SCHEMA CHANGE - liberty_content_types - change content_description to…
tekimaki authored Apr 17, 2010
55 'content_name' => 'Article',
f7e71d3 Add m(Admin|Edit|View)ContentPermission to various classes. update Li…
Max Kremmel authored Jul 16, 2007
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 Aug 26, 2005
62 $this->mArticleId = $pArticleId;
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
63 $this->mTypeId = NULL;
64 $this->mTopicId = NULL;
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
65 $this->mContentTypeGuid = BITARTICLE_CONTENT_TYPE_GUID;
65c3c47 @lsces Tidy BitDate initialisation
lsces authored Apr 26, 2009
66 $this->mDate = new BitDate();
67 $offset = $this->mDate->get_display_offset();
f7e71d3 Add m(Admin|Edit|View)ContentPermission to various classes. update Li…
Max Kremmel authored Jul 16, 2007
68
69 // Permission setup
70 $this->mViewContentPerm = 'p_articles_read';
c0f6195 @tekimaki CORE CHANGE: cleave Create permission from Edit permission so that th…
tekimaki authored Oct 3, 2008
71 $this->mCreateContentPerm = 'p_articles_submit';
9de6d0a @spiderr BIG CHANGE: migrate p_*_edit permissions to p_*_update permission nam…
spiderr authored Oct 20, 2008
72 $this->mUpdateContentPerm = 'p_articles_update';
f7e71d3 Add m(Admin|Edit|View)ContentPermission to various classes. update Li…
Max Kremmel authored Jul 16, 2007
73 $this->mAdminContentPerm = 'p_articles_admin';
1f9adbe make "read more" links conditional, depending on whether there is mor…
Max Kremmel authored Aug 25, 2005
74 }
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
75
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
76 /**
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
77 * Load the data from the database
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
78 * @access public
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
79 **/
6e30c33 @lsces Tidy up to remove 'STRICT' warnings
lsces authored Apr 16, 2012
80 function load( $pContentId = NULL, $pPluginParams = NULL ) {
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
81 if( @$this->verifyId( $this->mArticleId ) || @$this->verifyId( $this->mContentId ) ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
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 Dec 26, 2005
84 $lookupColumn = @$this->verifyId( $this->mArticleId ) ? 'article_id' : 'content_id';
ce4e5d1 use correct hash in query()
Max Kremmel authored Feb 14, 2006
85 $bindVars[] = $lookupId = @BitBase::verifyId( $this->mArticleId ) ? $this->mArticleId : $this->mContentId;
3556172 rename content_load_function to content_load_sql_function
Max Kremmel authored Feb 14, 2006
86 $this->getServicesSql( 'content_load_sql_function', $selectSql, $joinSql, $whereSql, $bindVars );
838a838 @lsces Add ServicesSQL facility
lsces authored Feb 10, 2006
87
309a5f8 fetch hits as well
bitweaver.org authored Jan 23, 2009
88 $query = "SELECT a.*, lc.*, atype.*, atopic.*, lch.hits,
ce4e5d1 use correct hash in query()
Max Kremmel authored Feb 14, 2006
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 Apr 16, 2012
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 Feb 14, 2006
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 Sep 15, 2007
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 Oct 6, 2007
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_attach…
Max Kremmel authored Sep 19, 2007
101 $joinSql
5a7c858 get articles working with recent schema update
Max Kremmel authored Sep 15, 2007
102 WHERE a.`$lookupColumn`=? $whereSql";
ce4e5d1 use correct hash in query()
Max Kremmel authored Feb 14, 2006
103 $result = $this->mDb->query( $query, $bindVars );
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
104
105 global $gBitSystem;
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
106 if( $result && $result->numRows() ) {
b548033 @spiderr fix ->fields calls
spiderr authored Jan 25, 2006
107 $this->mInfo = $result->fetchRow();
b99c416 get topic image on load()
Max Kremmel authored Aug 26, 2005
108
8c5f309 clean up articles custom image upload stuff
Max Kremmel authored Aug 28, 2005
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 Jun 13, 2007
110 $isTopicImage = false;
b99c416 get topic image on load()
Max Kremmel authored Aug 26, 2005
111
b548033 @spiderr fix ->fields calls
spiderr authored Jan 25, 2006
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 Aug 13, 2005
116
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attach…
Max Kremmel authored Sep 19, 2007
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 Apr 29, 2012
120 $this->mInfo['display_url'] = $this->getDisplayUrl();
067be4c move deprecated image functions to the bottom of the file to issulstr…
Max Kremmel authored Jul 13, 2007
121 // we need the raw data to display in the textarea
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attach…
Max Kremmel authored Sep 19, 2007
122 $this->mInfo['raw'] = $this->mInfo['data'];
067be4c move deprecated image functions to the bottom of the file to issulstr…
Max Kremmel authored Jul 13, 2007
123 // here we have the displayed data without the ...split... stuff
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attach…
Max Kremmel authored Sep 19, 2007
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 Aug 26, 2005
125
0153f3d @lsces Correct documentation package name to articles
lsces authored Jun 19, 2008
126 $comment = new LibertyComment();
fa7948e concatenate whereSql
Max Kremmel authored Feb 14, 2006
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 …
Max Kremmel authored Apr 29, 2006
128
0a8c72a migrate articles to LibertyMime
Max Kremmel authored May 31, 2008
129 LibertyMime::load();
adcc311 get html per article working as well and reduce load by only parsing …
Max Kremmel authored Apr 29, 2006
130
2c96393 make better use of LibertyMime features
Max Kremmel authored Jul 10, 2008
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 Jun 15, 2007
135 $this->mInfo['parsed'] = $this->parseData();
838a838 @lsces Add ServicesSQL facility
lsces authored Feb 10, 2006
136 } else {
137 $this->mArticleId = NULL;
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
138 }
139 }
c58fe86 @nickpalmer Fixed bug with load of article with no hits.
nickpalmer authored Nov 28, 2006
140
5e14ed2 clean up author name code
Max Kremmel authored Aug 30, 2005
141 return( count( $this->mInfo ) );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
142 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
143
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
144 /**
ec0a861 add some more documentation
Max Kremmel authored Sep 11, 2005
145 * Store article data after submission
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
146 * @param array pParamHash of values that will be used to store the page
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
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 Aug 26, 2005
150 function store( &$pParamHash ) {
151 global $gBitSystem;
d3c05a7 @nickpalmer Move StartTrans() before the calls to LibertyXXX::store() so that rol…
nickpalmer authored Jan 24, 2008
152 $this->mDb->StartTrans();
0a8c72a migrate articles to LibertyMime
Max Kremmel authored May 31, 2008
153 if( $this->verify( $pParamHash )&& LibertyMime::store( $pParamHash ) ) {
f210a14 massive table de-tikification. changed all tiki_ table prefixes with …
bitweaver.org authored Jan 31, 2006
154 $table = BIT_DB_PREFIX."articles";
ee831c6 get custom article image working
Max Kremmel authored Aug 26, 2005
155
5a59732 use $this->isValid() to check for $this->mArticleId
Max Kremmel authored Aug 28, 2005
156 if( $this->isValid() ) {
6ce2052 use class package id instead of hashvalue - who can trust anything th…
Max Kremmel authored Jul 7, 2008
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 Aug 26, 2005
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 Aug 26, 2005
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 Aug 26, 2005
162 $pParamHash['article_store']['article_id'] = $pParamHash['article_id'];
163 } else {
f210a14 massive table de-tikification. changed all tiki_ table prefixes with …
bitweaver.org authored Jan 31, 2006
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 Aug 26, 2005
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 Aug 28, 2005
173 return ( count( $this->mErrors ) == 0 );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
174 }
175
176 /**
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
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 Aug 26, 2005
183 function verify( &$pParamHash ) {
184 global $gBitUser, $gBitSystem;
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
185
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
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 Aug 13, 2005
190
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
191 if( @$this->verifyId( $this->mInfo['content_id'] ) ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
192 $pParamHash['content_id'] = $this->mInfo['content_id'];
193 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
194
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
195 // It is possible a derived class set this to something different
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
196 if( empty( $pParamHash['content_type_guid'] )&& !empty( $this->mContentTypeGuid ) ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
197 $pParamHash['content_type_guid'] = $this->mContentTypeGuid;
198 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
199
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
200 if( @$this->verifyId( $pParamHash['content_id'] ) ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
201 $pParamHash['article_store']['content_id'] = $pParamHash['content_id'];
202 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
203
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
204 if( !empty( $pParamHash['author_name'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
205 $pParamHash['article_store']['author_name'] = $pParamHash['author_name'];
206 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
207
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
208 if( @$this->verifyId( $pParamHash['topic_id'] ) ) {
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
209 $pParamHash['article_store']['topic_id'] =( int )$pParamHash['topic_id'];
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
210 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
211
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
212 if( @$this->verifyId( $pParamHash['article_type_id'] ) ) {
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
213 $pParamHash['article_store']['article_type_id'] =( int )$pParamHash['article_type_id'];
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
214 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
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 Aug 26, 2005
221 if( !empty( $pParamHash['edit'] ) ) {
4158723 fix article preview
Max Kremmel authored Aug 13, 2005
222 $pParamHash['content_store']['data'] = $pParamHash['edit'];
223 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
224
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
225 if( !empty( $pParamHash['rating'] ) ) {
226 $pParamHash['article_store']['rating'] =( int )( $pParamHash['rating'] );
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
227 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
228
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
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 Aug 28, 2005
231 if( !$this->isValid() ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
232 if( empty( $pParamHash['title'] ) ) {
8e16677 change the error message name to title to reuse the term used in the …
Sylvie Greverend authored May 5, 2006
233 $this->mErrors['title'] = 'You must specify a title.';
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
234 } else {
f9dba4a support BIT_CONTENT_MAX_TITLE_LEN for hand tinkering databases to hav…
Wakeworks authored Jun 15, 2006
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 Aug 26, 2005
236 }
237 } else {
f9dba4a support BIT_CONTENT_MAX_TITLE_LEN for hand tinkering databases to hav…
Wakeworks authored Jun 15, 2006
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 Aug 26, 2005
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 …
Sylvie Greverend authored May 5, 2006
242 $this->mErrors['title'] = 'You must specify a title';
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
243 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
244
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
245 if( !empty( $pParamHash['publish_Month'] ) ) {
504ca59 @lsces Manage UTC dates correctly. - publishing at 10am after daylight savin…
lsces authored Dec 5, 2008
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 Aug 26, 2005
256 if( $timestamp !== -1 ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
257 $pParamHash['publish_date'] = $timestamp;
258 }
259 }
5cbc7ec get permissions sorted when trying to view submitted article
Max Kremmel authored Aug 26, 2005
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 Aug 13, 2005
263
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
264 if( !empty( $pParamHash['expire_Month'] ) ) {
504ca59 @lsces Manage UTC dates correctly. - publishing at 10am after daylight savin…
lsces authored Dec 5, 2008
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 Aug 26, 2005
275 if( $timestamp !== -1 ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
276 $pParamHash['expire_date'] = $timestamp;
277 }
278 }
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
279 if( !empty( $pParamHash['expire_date'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
280 $pParamHash['article_store']['expire_date'] = $pParamHash['expire_date'];
281 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
282
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
283 if( @$this->verifyId( $pParamHash['status_id'] ) ) {
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
284 if( $pParamHash['status_id'] > ARTICLE_STATUS_PENDING ) {
e89540d move to gContent perm functions to fully support liberty content perm…
Max Kremmel authored Jul 6, 2007
285 if( $gBitUser->hasPermission( 'p_articles_approve_submission' )) {
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
286 $pParamHash['article_store']['status_id'] =( int )( $pParamHash['status_id'] );
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
287 } else {
288 $pParamHash['article_store']['status_id'] = ARTICLE_STATUS_PENDING;
289 }
290 } else {
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
291 $pParamHash['article_store']['status_id'] =( int )( $pParamHash['status_id'] );
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
292 }
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
293 } elseif( @$this->verifyId( $this->mInfo['status_id'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
294 $pParamHash['article_store']['status_id'] = $this->mInfo['status_id'];
295 } else {
1987daf more permissions housekeeping and tidyup
Max Kremmel authored Apr 11, 2006
296 if( $gBitUser->hasPermission( 'p_articles_approve_submission' ) || $gBitUser->hasPermission( 'p_articles_auto_approve' ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
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 Aug 13, 2005
302
adcc311 get html per article working as well and reduce load by only parsing …
Max Kremmel authored Apr 29, 2006
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 Feb 20, 2006
318 $this->mInfo["no_index"] = true ;
319 }
26322d2 @lsces Strip extra white space
lsces authored Apr 29, 2012
320
283eabc @tekimaki call verify on parent classes if verify fails to return all errors to…
tekimaki authored Oct 28, 2008
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 Feb 20, 2006
325
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
326 return( count( $this->mErrors )== 0 );
327 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
328
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
329 /**
ec0a861 add some more documentation
Max Kremmel authored Sep 11, 2005
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 imag…
Max Kremmel authored Sep 14, 2005
335 function preparePreview( $pParamHash ) {
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored Aug 28, 2005
336 global $gBitSystem, $gBitUser;
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
337
7184912 use constants instead of hardcoded package names and ensure that imag…
Max Kremmel authored Sep 14, 2005
338 $data = $pParamHash;
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
339 $this->verify( $data );
7184912 use constants instead of hardcoded package names and ensure that imag…
Max Kremmel authored Sep 14, 2005
340 $data = array_merge( $pParamHash, $data['content_store'], $data['article_store'] );
c24c28c fix articles preview
Max Kremmel authored Dec 13, 2006
341 $data['raw'] = $data['edit'];
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored Aug 28, 2005
342
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
343 if( empty( $data['user_id'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
344 $data['user_id'] = $gBitUser->mUserId;
345 }
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored Aug 28, 2005
346
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
347 if( empty( $data['hits'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
348 $data['hits'] = 0;
349 }
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored Aug 28, 2005
350
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
351 if( empty( $data['publish_date'] ) ) {
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored Aug 28, 2005
352 $data['publish_date'] = $gBitSystem->getUTCTime();
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
353 }
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored Aug 28, 2005
354
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
355 if( empty( $data['article_type_id'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
356 $data['article_type_id'] = 1;
357 }
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored Aug 28, 2005
358
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
359 if( empty( $data['topic_id'] ) ) {
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
360 $data['topic_id'] = 1;
361 }
4fea283 get image upload working with preview and subsequent save
Max Kremmel authored Aug 28, 2005
362
edd21fa fix hashkeys and generally get articles working again
Max Kremmel authored Jun 15, 2007
363 if( empty( $data['parsed'] ) ) {
ca235b0 allow caching to various files by allowing specification of cache fil…
Max Kremmel authored Jun 20, 2006
364 $data['no_cache'] = TRUE;
edd21fa fix hashkeys and generally get articles working again
Max Kremmel authored Jun 15, 2007
365 $data['parsed'] = $this->parseData( $data );
ca235b0 allow caching to various files by allowing specification of cache fil…
Max Kremmel authored Jun 20, 2006
366 // replace the split syntax with a horizontal rule
edd21fa fix hashkeys and generally get articles working again
Max Kremmel authored Jun 15, 2007
367 $data['parsed'] = preg_replace( LIBERTY_SPLIT_REGEX, "<hr />", $data['parsed'] );
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
368 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
369
19446b5 @lsces Tweak for PHP5.3 compatibility
lsces authored Apr 4, 2010
370 $articleType = new BitArticleType( $data['article_type_id'] );
371 $articleTopic = new BitArticleTopic( $data['topic_id'] );
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
372 $data = array_merge( $data, $articleType->mInfo, $articleTopic->mInfo );
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
373
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
374 return $data;
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
375 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
376
ec0a861 add some more documentation
Max Kremmel authored Sep 11, 2005
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_attach…
Max Kremmel authored Sep 19, 2007
383 function getImageThumbnails( $pParamHash ) {
384 global $gBitSystem, $gThumbSizes;
daf5fbe existing image attachment working as well now - w00t!
Max Kremmel authored Aug 28, 2005
385 $ret = NULL;
d8de906 replace individual function parameters with an array of options when …
Max Kremmel authored Jun 23, 2008
386
387 $thumbHash['mime_image'] = FALSE;
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attach…
Max Kremmel authored Sep 19, 2007
388 if( !empty( $pParamHash['image_attachment_path'] )) {
6852c98 @lsces Modify to use file_name/source_file shanges in attachments
lsces authored Apr 16, 2012
389 $thumbHash['source_file'] = $pParamHash['image_attachment_path'];
d8de906 replace individual function parameters with an array of options when …
Max Kremmel authored Jun 23, 2008
390 $ret = liberty_fetch_thumbnails( $thumbHash );
daf5fbe existing image attachment working as well now - w00t!
Max Kremmel authored Aug 28, 2005
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 Apr 16, 2012
392 $thumbHash['source_file'] = preg_replace( "#^/+#", "", BitArticleTopic::getTopicImageStorageUrl( $pParamHash['topic_id'] ));
d8de906 replace individual function parameters with an array of options when …
Max Kremmel authored Jun 23, 2008
393 $ret = liberty_fetch_thumbnails( $thumbHash );
daf5fbe existing image attachment working as well now - w00t!
Max Kremmel authored Aug 28, 2005
394 }
d8de906 replace individual function parameters with an array of options when …
Max Kremmel authored Jun 23, 2008
395
daf5fbe existing image attachment working as well now - w00t!
Max Kremmel authored Aug 28, 2005
396 return $ret;
397 }
398
ec0a861 add some more documentation
Max Kremmel authored Sep 11, 2005
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 Aug 28, 2005
404 function expunge() {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
405 $ret = FALSE;
406 if( $this->isValid() ) {
8c5f309 clean up articles custom image upload stuff
Max Kremmel authored Aug 28, 2005
407 $this->mDb->StartTrans();
f210a14 massive table de-tikification. changed all tiki_ table prefixes with …
bitweaver.org authored Jan 31, 2006
408 $query = "DELETE FROM `".BIT_DB_PREFIX."articles` WHERE `content_id` = ?";
8c5f309 clean up articles custom image upload stuff
Max Kremmel authored Aug 28, 2005
409 $result = $this->mDb->query( $query, array( $this->mContentId ) );
0a8c72a migrate articles to LibertyMime
Max Kremmel authored May 31, 2008
410 if( LibertyMime::expunge() ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
411 $ret = TRUE;
412 $this->mDb->CompleteTrans();
413 } else {
414 $this->mDb->RollbackTrans();
8c5f309 clean up articles custom image upload stuff
Max Kremmel authored Aug 28, 2005
415 }
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
416 }
417 return $ret;
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
418 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
419
ec0a861 add some more documentation
Max Kremmel authored Sep 11, 2005
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 Aug 26, 2005
425 function isValid() {
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
426 return( $this->verifyId( $this->mArticleId ) && $this->verifyId( $this->mContentId ) );
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
427 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
428
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
429 /**
fbe5d52 detikify liberty
Max Kremmel authored Feb 1, 2006
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 Sep 11, 2005
431 * @param $pParamHash contains an array of conditions to sort by
6ab6b0a add options to fetch various combinations of future articles and expi…
Max Kremmel authored Jun 13, 2007
432 * @return array of articles
ec0a861 add some more documentation
Max Kremmel authored Sep 11, 2005
433 * @access public
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
434 **/
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
435 function getList( &$pParamHash ) {
b7cc1a1 add the factility to view the history of articles, and an auto approv…
Hash9 authored Aug 29, 2006
436 global $gBitSystem, $gBitUser, $gLibertySystem;
437
fe614d1 apply default sort_mode before LibertyContent::prepGetList();
Max Kremmel authored Sep 11, 2005
438 if( empty( $pParamHash['sort_mode'] ) ) {
15d6f11 remove odd sort_mode if articles_auto_approve feature is set
Max Kremmel authored Oct 8, 2007
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 Sep 11, 2005
442 }
443
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
444 LibertyContent::prepGetList( $pParamHash );
445
838a838 @lsces Add ServicesSQL facility
lsces authored Feb 10, 2006
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 Aug 23, 2007
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 Aug 26, 2005
451
838a838 @lsces Add ServicesSQL facility
lsces authored Feb 10, 2006
452 $find = $pParamHash['find'];
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
453 if( is_array( $find ) ) {
c6e286d add more options to limit getList() by
Max Kremmel authored Aug 31, 2005
454 // you can use an array of articles
fa7948e concatenate whereSql
Max Kremmel authored Feb 14, 2006
455 $whereSql .= " AND lc.`title` IN( ".implode( ',',array_fill( 0, count( $find ),'?' ) )." )";
962a29a @lsces Tidy array merges
lsces authored Feb 10, 2006
456 $bindVars = array_merge( $bindVars, $find );
d568668 fix user_id where clause
Max Kremmel authored Sep 4, 2005
457 } elseif( is_string( $find ) ) {
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
458 // or a string
fa7948e concatenate whereSql
Max Kremmel authored Feb 14, 2006
459 $whereSql .= " AND UPPER( lc.`title` ) LIKE ? ";
962a29a @lsces Tidy array merges
lsces authored Feb 10, 2006
460 $bindVars[] = '%'.strtoupper( $find ).'%';
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
461 } elseif( @$this->verifyId( $pParamHash['user_id'] ) ) {
d568668 fix user_id where clause
Max Kremmel authored Sep 4, 2005
462 // or gate on a user
b0b7d72 @tekimaki fix center_list_articles so it actually displays articles when includ…
tekimaki authored Jun 15, 2007
463 $whereSql .= " AND lc.`user_id` = ? ";
464 $bindVars[] = (int)$pParamHash['user_id'];
d6cf45c add option to select by topic name
Max Kremmel authored Aug 30, 2005
465 }
466
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
467 if( @$this->verifyId( $pParamHash['status_id'] ) ) {
838a838 @lsces Add ServicesSQL facility
lsces authored Feb 10, 2006
468 $whereSql .= " AND a.`status_id` = ? ";
469 $bindVars[] = $pParamHash['status_id'];
c6e286d add more options to limit getList() by
Max Kremmel authored Aug 31, 2005
470 }
471
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
472 if( @$this->verifyId( $pParamHash['type_id'] ) ) {
838a838 @lsces Add ServicesSQL facility
lsces authored Feb 10, 2006
473 $whereSql .= " AND a.`article_type_id` = ? ";
474 $bindVars[] = ( int )$pParamHash['type_id'];
c6e286d add more options to limit getList() by
Max Kremmel authored Aug 31, 2005
475 }
476
9090a1d @spiderr remove old spell checking
spiderr authored Apr 10, 2006
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 expi…
Max Kremmel authored Jun 13, 2007
479 $now = $gBitSystem->getUTCTime();
47fee95 respect permissions when trying to fetch future and expired articles
Max Kremmel authored Jul 27, 2007
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 expi…
Max Kremmel authored Jun 13, 2007
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 Jul 27, 2007
482 } elseif( !empty( $pParamHash['show_future'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
6ab6b0a add options to fetch various combinations of future articles and expi…
Max Kremmel authored Jun 13, 2007
483 // hide expired articles
5a8daef respect settings in article types settings regarding the show before …
Max Kremmel authored Jul 27, 2007
484 $whereSql .= " AND ( a.`expire_date` > ? OR atype.`show_post_expire` = ? ) ";
6ab6b0a add options to fetch various combinations of future articles and expi…
Max Kremmel authored Jun 13, 2007
485 $bindVars[] = ( int )$now;
5a8daef respect settings in article types settings regarding the show before …
Max Kremmel authored Jul 27, 2007
486 $bindVars[] = 'y';
47fee95 respect permissions when trying to fetch future and expired articles
Max Kremmel authored Jul 27, 2007
487 } elseif( !empty( $pParamHash['show_expired'] ) && $gBitUser->hasPermission( 'p_articles_admin' )) {
6ab6b0a add options to fetch various combinations of future articles and expi…
Max Kremmel authored Jun 13, 2007
488 // hide future articles
5a8daef respect settings in article types settings regarding the show before …
Max Kremmel authored Jul 27, 2007
489 $whereSql .= " AND ( a.`publish_date` < ? OR atype.`show_pre_publ` = ? ) ";
6ab6b0a add options to fetch various combinations of future articles and expi…
Max Kremmel authored Jun 13, 2007
490 $bindVars[] = ( int )$now;
5a8daef respect settings in article types settings regarding the show before …
Max Kremmel authored Jul 27, 2007
491 $bindVars[] = 'y';
6ab6b0a add options to fetch various combinations of future articles and expi…
Max Kremmel authored Jun 13, 2007
492 } elseif( !empty( $pParamHash['get_future'] )) {
493 // show only future
47fee95 respect permissions when trying to fetch future and expired articles
Max Kremmel authored Jul 27, 2007
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 expi…
Max Kremmel authored Jun 13, 2007
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 Jul 27, 2007
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 expi…
Max Kremmel authored Jun 13, 2007
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 Jul 27, 2007
509 // hide future and expired articles - this is the default behaviour
5a8daef respect settings in article types settings regarding the show before …
Max Kremmel authored Jul 27, 2007
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 expi…
Max Kremmel authored Jun 13, 2007
512 $bindVars[] = ( int )$now;
5a8daef respect settings in article types settings regarding the show before …
Max Kremmel authored Jul 27, 2007
513 $bindVars[] = 'y';
6ab6b0a add options to fetch various combinations of future articles and expi…
Max Kremmel authored Jun 13, 2007
514 $bindVars[] = ( int )$now;
5a8daef respect settings in article types settings regarding the show before …
Max Kremmel authored Jul 27, 2007
515 $bindVars[] = 'y';
9090a1d @spiderr remove old spell checking
spiderr authored Apr 10, 2006
516 }
517
0b9692b merge recent changes into HEAD
Max Kremmel authored Jan 26, 2006
518 if( @$this->verifyId( $pParamHash['topic_id'] ) ) {
838a838 @lsces Add ServicesSQL facility
lsces authored Feb 10, 2006
519 $whereSql .= " AND a.`topic_id` = ? ";
520 $bindVars[] = ( int )$pParamHash['topic_id'];
0b9692b merge recent changes into HEAD
Max Kremmel authored Jan 26, 2006
521 } elseif( !empty( $pParamHash['topic'] ) ) {
ea85f9e new API for parseData(); please view ApiChangeLog for details
Max Kremmel authored Feb 16, 2006
522 $whereSql .= " AND UPPER( atopic.`topic_name` ) = ? ";
838a838 @lsces Add ServicesSQL facility
lsces authored Feb 10, 2006
523 $bindVars[] = strtoupper( $pParamHash['topic'] );
0b9692b merge recent changes into HEAD
Max Kremmel authored Jan 26, 2006
524 } else {
44c943d @lsces Fix reserved word field names
lsces authored Feb 19, 2006
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 Jan 26, 2006
527 }
528
42b7561 explicit column names to get around oracle pain ORA-00918
bitweaver.org authored Feb 27, 2006
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…
lsces authored Jun 15, 2007
530 $query =
531 "SELECT
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attach…
Max Kremmel authored Sep 19, 2007
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 Dec 5, 2006
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_attach…
Max Kremmel authored Sep 19, 2007
535 lch.`hits`,
6852c98 @lsces Modify to use file_name/source_file shanges in attachments
lsces authored Apr 16, 2012
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 …
bitweaver.org authored Jan 31, 2006
537 FROM `".BIT_DB_PREFIX."articles` a
c8de5c1 add parenthesis to SQL statements
Max Kremmel authored Oct 6, 2007
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 Feb 14, 2006
546 WHERE lc.`content_type_guid` = ? $whereSql
a39e645 rename some methods in BitDbBase to meet bitweaver standards. all cha…
Max Kremmel authored Jan 6, 2007
547 ORDER BY ".$this->mDb->convertSortmode( $pParamHash['sort_mode'] );
04136bd get article submissions working
Max Kremmel authored Aug 26, 2005
548
f210a14 massive table de-tikification. changed all tiki_ table prefixes with …
bitweaver.org authored Jan 31, 2006
549 $query_cant = "SELECT COUNT( * )FROM `".BIT_DB_PREFIX."articles` a
ea85f9e new API for parseData(); please view ApiChangeLog for details
Max Kremmel authored Feb 16, 2006
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 …
Max Kremmel authored Jul 27, 2007
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 Feb 10, 2006
553 WHERE lc.`content_type_guid` = ? $whereSql";
80fa1d9 @spiderr Added uspport for multiple database backend support. This necessitate…
spiderr authored Jan 25, 2006
554
838a838 @lsces Add ServicesSQL facility
lsces authored Feb 10, 2006
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 Aug 26, 2005
556 $ret = array();
19446b5 @lsces Tweak for PHP5.3 compatibility
lsces authored Apr 4, 2010
557 $comment = new LibertyComment();
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
558 while( $res = $result->fetchRow() ) {
390d6f9 make use of the parseSplit() method
Max Kremmel authored Jun 10, 2007
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 Mar 1, 2007
561
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attach…
Max Kremmel authored Sep 19, 2007
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 Apr 29, 2012
564 $res['display_url'] = self::getDisplayUrlFromHash( $res );
83d19b8 SCHEMA CHANGE: move image_attachment_id information to liberty_attach…
Max Kremmel authored Sep 19, 2007
565 $res['display_link'] = $this->getDisplayLink( $res['title'], $res );
566
2c96393 make better use of LibertyMime features
Max Kremmel authored Jul 10, 2008
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 Apr 17, 2012
568 $res['primary_attachment'] = LibertyMime::loadAttachment( $res['primary_attachment_id'] );
2c96393 make better use of LibertyMime features
Max Kremmel authored Jul 10, 2008
569
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
570 $ret[] = $res;
571 }
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
572
838a838 @lsces Add ServicesSQL facility
lsces authored Feb 10, 2006
573 $pParamHash["cant"] = $this->mDb->getOne( $query_cant, $bindVars );
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
574
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
575 LibertyContent::postGetList( $pParamHash );
7f0e5d8 more work on getting articles going
Max Kremmel authored Aug 13, 2005
576
6ab6b0a add options to fetch various combinations of future articles and expi…
Max Kremmel authored Jun 13, 2007
577 return $ret;
578 }
579
c32c1fa @lsces Display article using structure_id reference.
lsces authored Jul 14, 2007
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 expi…
Max Kremmel authored Jun 13, 2007
588 /**
589 * Get a list of articles that are to be published in the future
26322d2 @lsces Strip extra white space
lsces authored Apr 29, 2012
590 *
6ab6b0a add options to fetch various combinations of future articles and expi…
Max Kremmel authored Jun 13, 2007
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 Apr 29, 2012
602 *
6ab6b0a add options to fetch various combinations of future articles and expi…
Max Kremmel authored Jun 13, 2007
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 Aug 26, 2005
610 }
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
611
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
612 /**
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
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 Aug 13, 2005
615 */
b74dc03 @lsces Match parameter hash to base function
lsces authored Apr 29, 2012
616 public static function getDisplayUrlFromHash( &$pParamHash ) {
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
617 global $gBitSystem;
618
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
619 $ret = NULL;
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
620
83ee2ff @lsces Further tidyup on strict warnings
lsces authored Apr 29, 2012
621 if( @BitBase::verifyId( $pParamHash['article_id'] ) ) {
475f224 another batch of kernel_prefs name cleanup. this should be it
Max Kremmel authored Feb 13, 2006
622 if( $gBitSystem->isFeatureActive( 'pretty_urls_extended' ) ) {
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
623 // Not needed since it's a number: $ret = ARTICLES_PKG_URL."view/".$this->mArticleId;
f792d72 @spiderr major migration of getDisplayUrl to ->getDisplayUrl and ::getDisplayU…
spiderr authored Apr 18, 2012
624 $ret = ARTICLES_PKG_URL.$pParamHash['article_id'];
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
625 } else if( $gBitSystem->isFeatureActive( 'pretty_urls' ) ) {
f792d72 @spiderr major migration of getDisplayUrl to ->getDisplayUrl and ::getDisplayU…
spiderr authored Apr 18, 2012
626 $ret = ARTICLES_PKG_URL.$pParamHash['article_id'];
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
627 } else {
f792d72 @spiderr major migration of getDisplayUrl to ->getDisplayUrl and ::getDisplayU…
spiderr authored Apr 18, 2012
628 $ret = ARTICLES_PKG_URL."read.php?article_id=".$pParamHash['article_id'];
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
629 }
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
630 }
6d30434 try to standardise getDisplayUrl accross content types a bit and add …
Max Kremmel authored Sep 10, 2007
631
47d932a parsed_description only needed when loading articles front page
Max Kremmel authored Aug 26, 2005
632 return $ret;
633 }
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
634
83ee2ff @lsces Further tidyup on strict warnings
lsces authored Apr 29, 2012
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 Sep 4, 2005
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 …
bitweaver.org authored Jan 31, 2006
651 $query = "SELECT * FROM `".BIT_DB_PREFIX."article_status`";
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
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 Feb 20, 2006
663 function setStatus( $pStatusId, $pArticleId = NULL, $pContentId = NULL ) {
9090a1d @spiderr remove old spell checking
spiderr authored Apr 10, 2006
664 global $gBitSystem;
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
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 Feb 20, 2006
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 Sep 4, 2005
677 if( empty( $pArticleId ) && $this->isValid() ) {
678 $pArticleId = $this->mArticleId;
679 }
680
54fb5b7 merge recent changes into HEAD
Max Kremmel authored Dec 26, 2005
681 if( @$this->verifyId( $pArticleId ) ) {
f210a14 massive table de-tikification. changed all tiki_ table prefixes with …
bitweaver.org authored Jan 31, 2006
682 $sql = "UPDATE `".BIT_DB_PREFIX."articles` SET `status_id` = ? WHERE `article_id` = ?";
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
683 $rs = $this->mDb->query( $sql, array( $pStatusId, $pArticleId ));
5330bc5 Merge recent changes to HEAD
Sean Lee authored Feb 20, 2006
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 approv…
Hash9 authored Aug 29, 2006
689 } elseif (!$pStatusId == ARTICLE_STATUS_RETIRED) {
5330bc5 Merge recent changes to HEAD
Sean Lee authored Feb 20, 2006
690 delete_index($pContentId); // delete it from the search index unless retired ...
691 }
692 }
cf7b087 add some documentation
Max Kremmel authored Sep 4, 2005
693 return $pStatusId;
694 }
695 }
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
696 }
686911b final 'avail' test
bitweaver.org authored Jul 31, 2008
697
75f897b IMPORT TikiPro CLYDE FINAL
bitweaver.org authored Jun 30, 2005
698 ?>
Something went wrong with that request. Please try again.