1
0
mirror of https://github.com/e107inc/e107.git synced 2025-10-10 20:44:48 +02:00

Merge pull request #9 from e107inc/master

.
This commit is contained in:
rica-carv
2016-04-26 17:43:07 +01:00
51 changed files with 1222 additions and 506 deletions

View File

@@ -4,6 +4,12 @@ engines:
enabled: false enabled: false
duplication: duplication:
enabled: true enabled: true
checks:
Identical code:
enabled: false
Design/TooManyPublicMethods:
enabled: false
config: config:
languages: languages:
- javascript - javascript
@@ -25,6 +31,8 @@ engines:
enabled: false enabled: false
Design/TooManyFields: Design/TooManyFields:
enabled: false enabled: false
CleanCode/BooleanArgumentFlag:
enabled: false
config: config:
file_extensions: "php" file_extensions: "php"
rulesets: "cleancode,unusedcode,codesize" rulesets: "cleancode,unusedcode,codesize"

View File

@@ -269,7 +269,7 @@ class banlist_ui extends e_admin_ui
public function timesPage() protected function timesPage()
{ {
if (!getperms('0')) if (!getperms('0'))
{ {
@@ -349,12 +349,12 @@ class banlist_ui extends e_admin_ui
} }
public function optionsPage() protected function optionsPage()
{ {
//FIXME Put Options code in here. //FIXME Put Options code in here.
} }
public function banlogPage() protected function banlogPage()
{ {
//FIXME Put LogPage code in here. //FIXME Put LogPage code in here.
} }

View File

@@ -204,7 +204,7 @@ class eurl_admin_ui extends e_admin_controller_ui
} }
//TODO Checkbox for each plugin to enable/disable //TODO Checkbox for each plugin to enable/disable
public function simplePage() protected function simplePage()
{ {
// $this->addTitle("Simple Redirects"); // $this->addTitle("Simple Redirects");
$eUrl =e107::getAddonConfig('e_url'); $eUrl =e107::getAddonConfig('e_url');
@@ -320,7 +320,7 @@ class eurl_admin_ui extends e_admin_controller_ui
} }
} }
public function SettingsPage() protected function SettingsPage()
{ {
//$this->addTitle(LAN_EURL_NAME_SETTINGS); //$this->addTitle(LAN_EURL_NAME_SETTINGS);
return $this->getUI()->urlSettings(); return $this->getUI()->urlSettings();
@@ -356,7 +356,7 @@ class eurl_admin_ui extends e_admin_controller_ui
} }
} }
public function AliasPage() protected function AliasPage()
{ {
// $this->addTitle(LAN_EURL_NAME_ALIASES); // $this->addTitle(LAN_EURL_NAME_ALIASES);
@@ -411,7 +411,7 @@ class eurl_admin_ui extends e_admin_controller_ui
} }
} }
public function ConfigPage() protected function ConfigPage()
{ {
// $this->addTitle(LAN_EURL_NAME_CONFIG); // $this->addTitle(LAN_EURL_NAME_CONFIG);
$active = e107::getPref('url_config'); $active = e107::getPref('url_config');

View File

@@ -2214,6 +2214,11 @@ class pluginBuilder
$this->createFiles = true; $this->createFiles = true;
} }
if(vartrue($_POST['step']) == 4)
{
$this->step4();
return null;
}
if(vartrue($_GET['step']) == 3) if(vartrue($_GET['step']) == 3)
{ {
@@ -2222,11 +2227,7 @@ class pluginBuilder
return null; return null;
} }
if(vartrue($_POST['step']) == 4)
{
$this->step4();
return null;
}
if(vartrue($_GET['newplugin']) && $_GET['step']==2) if(vartrue($_GET['newplugin']) && $_GET['step']==2)
@@ -2856,7 +2857,7 @@ class pluginBuilder
case 'summary-summary': case 'summary-summary':
$help = EPL_ADLAN_142."<br />".EPL_ADLAN_143; $help = EPL_ADLAN_142."<br />".EPL_ADLAN_143;
$required = true; $required = true;
$size = 100; $size = 130;
$placeholder= " "; $placeholder= " ";
$pattern = "[A-Za-z \.0-9]*"; $pattern = "[A-Za-z \.0-9]*";
$xsize = 'block-level'; $xsize = 'block-level';
@@ -3791,7 +3792,7 @@ $text .= "
// ------- Customize Create -------- // ------- Customize Create --------
public function beforeCreate(\$new_data) public function beforeCreate(\$new_data,\$old_data)
{ {
return \$new_data; return \$new_data;
} }

View File

@@ -363,6 +363,13 @@ $text .= "<div class='field-spacer'>".$tp->parseTemplate("{IMAGESELECTOR={$parms
$sLogo = siteinfo_shortcodes::sc_logo(); $sLogo = siteinfo_shortcodes::sc_logo();
*/ */
if(!empty($pref['sitebutton']) && strpos($pref['sitebutton'],'{')===false && file_exists(e_IMAGE.$pref['sitebutton']))
{
$pref['sitebutton'] = '{e_IMAGE}'.$pref['sitebutton'];
}
$text .= $frm->imagepicker('sitebutton',$pref['sitebutton'],'','help='.PRFLAN_225); $text .= $frm->imagepicker('sitebutton',$pref['sitebutton'],'','help='.PRFLAN_225);
$text .= " $text .= "

View File

@@ -35,6 +35,8 @@ class news_shortcodes extends e_shortcode
private $imageItem; private $imageItem;
public $param = array();
function __construct($eVars = null) function __construct($eVars = null)
{ {
@@ -81,6 +83,9 @@ class news_shortcodes extends e_shortcode
$tp = e107::getParser(); $tp = e107::getParser();
e107::getBB()->setClass("news"); // For automatic bbcode image resizing. e107::getBB()->setClass("news"); // For automatic bbcode image resizing.
$news_body = '';
if($parm != 'extended') if($parm != 'extended')
{ {
$news_body = $tp->toHTML($this->news_item['news_body'], true, 'BODY, fromadmin', $this->news_item['news_author']); $news_body = $tp->toHTML($this->news_item['news_body'], true, 'BODY, fromadmin', $this->news_item['news_author']);
@@ -90,7 +95,9 @@ class news_shortcodes extends e_shortcode
{ {
$news_body .= $tp->toHTML($this->news_item['news_extended'], true, 'BODY, fromadmin', $this->news_item['news_author']); $news_body .= $tp->toHTML($this->news_item['news_extended'], true, 'BODY, fromadmin', $this->news_item['news_author']);
} }
e107::getBB()->clearClass(); e107::getBB()->clearClass();
return $news_body; return $news_body;
} }
@@ -511,7 +518,8 @@ class news_shortcodes extends e_shortcode
{ {
$tp = e107::getParser(); $tp = e107::getParser();
$text = $tp->toHtml($this->news_item['news_body'],true); $text = $tp->toHtml($this->news_item['news_body'],true);
$text = str_replace("<br />","\n",$text); $breaks = array('<br />','<br>');
$text = str_replace($breaks,"\n",$text);
$text = strip_tags($text); $text = strip_tags($text);
$tmp = preg_split('/(\.\s|!|\r|\n|\?)/i', trim($text)); $tmp = preg_split('/(\.\s|!|\r|\n|\?)/i', trim($text));
$tmp = array_filter($tmp); $tmp = array_filter($tmp);
@@ -597,16 +605,23 @@ class news_shortcodes extends e_shortcode
$_src = $src = ($newsThumb[0] == '{' || $parms[1] == 'placeholder') ? e107::getParser()->replaceConstants($newsThumb, 'abs') : e_IMAGE_ABS."newspost_images/".$newsThumb; $_src = $src = ($newsThumb[0] == '{' || $parms[1] == 'placeholder') ? e107::getParser()->replaceConstants($newsThumb, 'abs') : e_IMAGE_ABS."newspost_images/".$newsThumb;
if($parms[2] || $parms[1] == 'placeholder') if(!empty($parms[2]) || $parms[1] == 'placeholder')
{ {
// $srcset = "srcset='".$tp->thumbSrcSet($src,'all')."' size='100vw' "; // $srcset = "srcset='".$tp->thumbSrcSet($src,'all')."' size='100vw' ";
$src = e107::getParser()->thumbUrl($src, $parms[2]); $attr = !empty($parms[2]) ? $parms[2] : null;
$src = e107::getParser()->thumbUrl($src, $attr);
$dimensions = e107::getParser()->thumbDimensions(); $dimensions = e107::getParser()->thumbDimensions();
} }
} }
if(empty($parms[1]))
{
$parms = array(1 => null);
}
$style = !empty($this->param['thumbnail']) ? $this->param['thumbnail'] : '';
switch($parms[1]) switch($parms[1])
@@ -616,15 +631,15 @@ class news_shortcodes extends e_shortcode
break; break;
case 'tag': case 'tag':
return "<img class='news_image ".$class."' src='".$src."' alt='' style='".$this->param['thumbnail']."' {$dimensions} {$srcset} />"; return "<img class='news_image ".$class."' src='".$src."' alt='' style='".$style."' {$dimensions} {$srcset} />";
break; break;
case 'img': case 'img':
return "<a href='".$_src."' rel='external image'><img class='news_image ".$class."' src='".$src."' alt='' style='".$this->param['thumbnail']."' {$dimensions} {$srcset} /></a>"; return "<a href='".$_src."' rel='external image'><img class='news_image ".$class."' src='".$src."' alt='' style='".$style."' {$dimensions} {$srcset} /></a>";
break; break;
default: default:
return "<a href='".e107::getUrl()->create('news/view/item', $this->news_item)."'><img class='news_image img-responsive img-rounded ".$class."' src='".$src."' alt='' style='".$this->param['thumbnail']."' {$dimensions} {$srcset} /></a>"; return "<a href='".e107::getUrl()->create('news/view/item', $this->news_item)."'><img class='news_image img-responsive img-rounded ".$class."' src='".$src."' alt='' style='".$style."' {$dimensions} {$srcset} /></a>";
break; break;
} }
} }
@@ -800,6 +815,8 @@ class news_shortcodes extends e_shortcode
$parm['type'] = 'tag'; $parm['type'] = 'tag';
} }
$style = !empty($this->param['thumbnail']) ? $this->param['thumbnail'] : '';
switch(vartrue($parm['type'])) switch(vartrue($parm['type']))
{ {
case 'src': case 'src':
@@ -807,12 +824,12 @@ class news_shortcodes extends e_shortcode
break; break;
case 'tag': case 'tag':
return "<img class='{$class}' src='".$src."' alt='' style='".$this->param['thumbnail']."' {$dimensions} {$srcset} />"; return "<img class='{$class}' src='".$src."' alt='' style='".$style."' {$dimensions} {$srcset} />";
break; break;
case 'url': case 'url':
default: default:
return "<a href='".e107::getUrl()->create('news/view/item', $this->news_item)."'><img class='{$class}' src='".$src."' alt='' style='".$this->param['thumbnail']."' {$dimensions} {$srcset} /></a>"; return "<a href='".e107::getUrl()->create('news/view/item', $this->news_item)."'><img class='{$class}' src='".$src."' alt='' style='".$style."' {$dimensions} {$srcset} /></a>";
break; break;
} }
} }

View File

@@ -185,8 +185,12 @@ class signup_shortcodes extends e_shortcode
} }
} }
/* example {SIGNUP_LOGINNAME} */
/* example {SIGNUP_LOGINNAME: class=btn input-lg} */
/* example {SIGNUP_LOGINNAME: placeholder=LAN_LOGINNAME} */
/* example {SIGNUP_LOGINNAME: class=input-lg&placeholder=LAN_LOGINNAME} */
function sc_signup_loginname() function sc_signup_loginname($parm=null)
{ {
$pref = e107::getPref(); $pref = e107::getPref();
@@ -201,13 +205,19 @@ class signup_shortcodes extends e_shortcode
$options = array('size'=>30,'required'=>1); $options = array('size'=>30,'required'=>1);
$options['title'] = str_replace("[x]",$log_name_length,LAN_SIGNUP_109); // Password must be at least $options['title'] = str_replace("[x]",$log_name_length,LAN_SIGNUP_109); // Password must be at least
$options['pattern'] = '[\S]*'; $options['pattern'] = '[\S]*';
$options['class'] = vartrue($parm['class'],'');
$options['placeholder'] = vartrue($parm['placeholder']) ? $parm['placeholder'] : '';
return e107::getForm()->text('loginname', ($_POST['loginname'] ? $_POST['loginname'] : ''), $log_name_length, $options); return e107::getForm()->text('loginname', ($_POST['loginname'] ? $_POST['loginname'] : ''), $log_name_length, $options);
} }
} }
/* example {SIGNUP_REALNAME} */
/* example {SIGNUP_REALNAME: class=btn input-lg} */
/* example {SIGNUP_REALNAME: placeholder=LAN_SIGNUP_91} */
/* example {SIGNUP_REALNAME: class=input-lg&placeholder=LAN_SIGNUP_91} */
function sc_signup_realname() function sc_signup_realname($parm=null)
{ {
$pref = e107::getPref('signup_option_realname'); $pref = e107::getPref('signup_option_realname');
if($pref < 1){ return; } if($pref < 1){ return; }
@@ -215,13 +225,19 @@ class signup_shortcodes extends e_shortcode
$options = array('size'=>30); $options = array('size'=>30);
$options['required'] = ($pref==2) ? 1 : 0; $options['required'] = ($pref==2) ? 1 : 0;
$options['title'] = LAN_SIGNUP_110; $options['title'] = LAN_SIGNUP_110;
$options['class'] = vartrue($parm['class'],'');
$options['placeholder'] = vartrue($parm['placeholder'],'');
return e107::getForm()->text('realname', ($_POST['realname'] ? $_POST['realname'] : ''), 100, $options); return e107::getForm()->text('realname', ($_POST['realname'] ? $_POST['realname'] : ''), 100, $options);
} }
/* example {SIGNUP_PASSWORD1} */
/* example {SIGNUP_PASSWORD1: class=btn input-lg} */
/* example {SIGNUP_PASSWORD1: placeholder=LAN_PASSWORD} */
/* example {SIGNUP_PASSWORD1: class=input-lg&placeholder=LAN_PASSWORD} */
function sc_signup_password1() function sc_signup_password1($parm=null)
{ {
$pref = e107::getPref('signup_option_password', 2); $pref = e107::getPref('signup_option_password', 2);
@@ -239,14 +255,20 @@ class signup_shortcodes extends e_shortcode
$options['required'] = true; $options['required'] = true;
$options['pattern'] = '(?=^.{'.$len.',}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$'; $options['pattern'] = '(?=^.{'.$len.',}$)((?=.*\d)|(?=.*\W+))(?![.\n])(?=.*[A-Z])(?=.*[a-z]).*$';
$options['autocomplete'] = 'off'; $options['autocomplete'] = 'off';
$options['class'] = vartrue($parm['class'],'');
$options['placeholder'] = vartrue($parm['placeholder'],'');
// $options['pattern'] = '\w{'.$len.',}'; // word of minimum length // $options['pattern'] = '\w{'.$len.',}'; // word of minimum length
return e107::getForm()->password('password1', '', 20, $options); return e107::getForm()->password('password1', '', 20, $options);
} }
/* example {SIGNUP_PASSWORD2} */
/* example {SIGNUP_PASSWORD2: class=btn input-lg} */
/* example {SIGNUP_PASSWORD2: placeholder=LAN_SIGNUP_84} */
/* example {SIGNUP_PASSWORD2: class=input-lg&placeholder=LAN_SIGNUP_84} */
function sc_signup_password2() function sc_signup_password2($parm=null)
{ {
$pref = e107::getPref('signup_option_password', 2); $pref = e107::getPref('signup_option_password', 2);
@@ -255,8 +277,11 @@ class signup_shortcodes extends e_shortcode
{ {
return false; return false;
} }
$options = array('size'=>30,'class'=>'e-password tbox','required'=>1);
$options['class'] = vartrue($parm['class'],'');
$options['placeholder'] = vartrue($parm['placeholder'],'');
return e107::getForm()->password('password2', '', 20, array('size'=>30,'class'=>'tbox','required'=>1)); return e107::getForm()->password('password2', '', 20, $options);
} }
@@ -269,11 +294,17 @@ class signup_shortcodes extends e_shortcode
} }
} }
/* example {SIGNUP_EMAIL} */
/* example {SIGNUP_EMAIL: class=btn input-lg} */
/* example {SIGNUP_EMAIL: placeholder=LAN_USER_60} */
/* example {SIGNUP_EMAIL: class=input-lg&placeholder=LAN_USER_60} */
function sc_signup_email() function sc_signup_email($parm=null)
{ {
$options = array('size'=>30,'required'=>1,'class'=>'tbox form-control input-text e-email'); $options = array('size'=>30,'required'=>1,'class'=>'tbox form-control input-text e-email');
$options['title'] = LAN_SIGNUP_108; // Must be a valid email address. $options['title'] = LAN_SIGNUP_108; // Must be a valid email address.
$options['class'] = vartrue($parm['class'],'');
$options['placeholder'] = vartrue($parm['placeholder'],'');
$text = e107::getForm()->email('email',vartrue($_POST['email'], ''),100,$options); $text = e107::getForm()->email('email',vartrue($_POST['email'], ''),100,$options);
$text .= "<div class='e-email-hint alert-warning' style='display:none; padding:10px' data-hint='Did you mean <b>[x]</b>?'><!-- --></div>"; $text .= "<div class='e-email-hint alert-warning' style='display:none; padding:10px' data-hint='Did you mean <b>[x]</b>?'><!-- --></div>";
@@ -281,8 +312,12 @@ class signup_shortcodes extends e_shortcode
return $text; return $text;
} }
/* example {SIGNUP_EMAIL_CONFIRM} */
/* example {SIGNUP_EMAIL_CONFIRM: class=btn input-lg} */
/* example {SIGNUP_EMAIL_CONFIRM: placeholder=LAN_SIGNUP_39} */
/* example {SIGNUP_EMAIL_CONFIRM: class=input-lg&placeholder=LAN_SIGNUP_39} */
function sc_signup_email_confirm() function sc_signup_email_confirm($parm=null)
{ {
$pref = e107::getPref('signup_option_email_confirm'); $pref = e107::getPref('signup_option_email_confirm');
if($pref < 1){ return; } if($pref < 1){ return; }
@@ -290,6 +325,8 @@ class signup_shortcodes extends e_shortcode
$options = array('size'=>30); $options = array('size'=>30);
$options['required'] = ($pref==2) ? 1 : 0; $options['required'] = ($pref==2) ? 1 : 0;
$options['class'] = 'tbox input-text e-email'; $options['class'] = 'tbox input-text e-email';
$options['class'] = vartrue($parm['class'],'tbox input-text e-email');
$options['placeholder'] = vartrue($parm['placeholder'],'');
return e107::getForm()->email('email_confirm', vartrue($_POST['email_confirm']), 100, $options); return e107::getForm()->email('email_confirm', vartrue($_POST['email_confirm']), 100, $options);

View File

@@ -672,16 +672,30 @@ class user_shortcodes extends e_shortcode
if(!empty($parm['field'])) if(!empty($parm['field']))
{ {
$ext = e107::getUserExt();
$fld = 'user_'.$parm['field']; $fld = 'user_'.$parm['field'];
if(!$ext->hasPermission($fld,'read'))
{
return false;
}
$val = $this->var[$fld]; $val = $this->var[$fld];
return e107::getUserExt()->renderValue($val); //TODO auto-detect type, from within the user-extended class.
// e107::getDebug()->log(print_a($ext,true));
return $ext->renderValue($val); //TODO auto-detect type, from within the user-extended class.
} }
return ' '; return false;
} }
function sc_user_extended_all($parm) function sc_user_extended_all($parm)
{ {
$sql = e107::getDb(); $sql = e107::getDb();

View File

@@ -112,6 +112,8 @@ $EMAIL_TEMPLATE['default']['header'] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHT
.sitebutton img { max-height: 100px; border-radius:4px; margin-right:5px } .sitebutton img { max-height: 100px; border-radius:4px; margin-right:5px }
h4.sitename { font-size: 20px; margin-bottom:5px; margin-top:0; text-decoration:none } h4.sitename { font-size: 20px; margin-bottom:5px; margin-top:0; text-decoration:none }
h4.sitename a { text-decoration:none } h4.sitename a { text-decoration:none }
.text-right { text-align: right }
.text-center { text-align: center }
a.siteurl { font-size: 14px } a.siteurl { font-size: 14px }
a { color: #428BCA } a { color: #428BCA }
@@ -133,7 +135,39 @@ $EMAIL_TEMPLATE['default']['header'] = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHT
vertical-align: top; vertical-align: top;
border-top: 1px solid #DDD; border-top: 1px solid #DDD;
} }
.alert { padding: 15px; margin-bottom: 20px; border: 1px solid transparent; border-radius: 4px; }
.alert-info { color: #31708f; background-color: #d9edf7; border-color: #bce8f1; }
.alert-warning { color: #8a6d3b; background-color: #fcf8e3; border-color: #faebcc; }
.alert-danger { color: #a94442; background-color: #f2dede; border-color: #ebccd1; }
.alert-success { color: #3c763d; background-color: #dff0d8; border-color: #d6e9c6; }
a.btn { text-decoration: none; }
.btn {
display: inline-block;
padding: 6px 12px;
margin-bottom: 0;
font-size: 14px;
font-weight: 400;
line-height: 1.42857143;
text-align: center;
white-space: nowrap;
vertical-align: middle;
-ms-touch-action: manipulation;
touch-action: manipulation;
cursor: pointer;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background-image: none;
border: 1px solid transparent;
border-radius: 4px;
}
.btn-primary { color: #fff; background-color: #337ab7; border-color: #2e6da4; }
.btn-success { color: #fff; background-color: #5cb85c; border-color: #4cae4c; }
.btn-warning { color: #fff; background-color: #f0ad4e; border-color: #eea236; }
.btn-danger { color: #fff; background-color: #d9534f; border-color: #d43f3a; }
.btn-lg { padding: 10px 16px; font-size: 18px; line-height: 1.3333333; border-radius: 6px; }
.btn-sm { padding: 5px 10px; font-size: 12px; line-height: 1.5; border-radius: 3px; }
</style> </style>
</head> </head>
@@ -146,7 +180,7 @@ $EMAIL_TEMPLATE['default']['body'] = "{BODY}<br />{MEDIA1}{MEDIA2}{MEDIA3}{MED
$EMAIL_TEMPLATE['default']['footer'] = "<br /><br /><table cellspacing='4'> $EMAIL_TEMPLATE['default']['footer'] = "<br /><br /><table cellspacing='4'>
<tr><td>{SITEBUTTON: type=email&h=60}</td> <tr><td>{SITEBUTTON: type=email&h=60}</td>
<td><h4 class='sitename'>{SITENAME=link}</h4> <td><h4 class='sitename'>{SITENAME=link}</h4>
{SITEURL}</td></tr> <small>{SITEURL}</small></td></tr>
</table> </table>
</div> </div>
</body> </body>

View File

@@ -3693,6 +3693,7 @@ class e_admin_controller_ui extends e_admin_controller
$tableSJoinArr = array(); // FROM for join tables $tableSJoinArr = array(); // FROM for join tables
$filter = array(); $filter = array();
$searchQuery = $tp->toDB($request->getQuery('searchquery', '')); $searchQuery = $tp->toDB($request->getQuery('searchquery', ''));
$searchFilter = $this->_parseFilterRequest($request->getQuery('filter_options', '')); $searchFilter = $this->_parseFilterRequest($request->getQuery('filter_options', ''));
@@ -3711,7 +3712,7 @@ class e_admin_controller_ui extends e_admin_controller
$_dataType = $this->fields[$filterField]['data']; $_dataType = $this->fields[$filterField]['data'];
$_fieldType = $this->fields[$filterField]['type']; $_fieldType = $this->fields[$filterField]['type'];
if($_fieldType === 'comma' || $_fieldType === 'checkboxes' || $_fieldType == 'userclasses') if($_fieldType === 'comma' || $_fieldType === 'checkboxes' || $_fieldType == 'userclasses' || ($_fieldType == 'dropdown' && !empty($this->fields[$filterField]['writeParms']['multiple'])))
{ {
$_dataType = 'set'; $_dataType = 'set';
} }
@@ -6328,6 +6329,9 @@ class e_admin_form_ui extends e_form
case 'dropdown': // use the array $parm; case 'dropdown': // use the array $parm;
if(!empty($parms['optArray'])) if(!empty($parms['optArray']))
{ {
$fopts = $parms; $fopts = $parms;
@@ -6339,12 +6343,16 @@ class e_admin_form_ui extends e_form
if(!is_array(varset($parms['__options']))) parse_str($parms['__options'], $parms['__options']); if(!is_array(varset($parms['__options']))) parse_str($parms['__options'], $parms['__options']);
$opts = $parms['__options']; $opts = $parms['__options'];
if(vartrue($opts['multiple'])) if(vartrue($opts['multiple']) && $type == 'batch')
{ {
// no batch support for multiple, should have some for filters soon // no batch support for multiple, should have some for filters soon
continue; continue;
} }
unset($parms['__options']); //remove element options if any unset($parms['__options']); //remove element options if any
foreach($parms as $k => $name) foreach($parms as $k => $name)
{ {
$option[$key.'__'.$k] = $name; $option[$key.'__'.$k] = $name;

View File

@@ -172,7 +172,7 @@ class ecache {
/** /**
* *
* @param string $CacheTag - name of tag for future retrieval - should NOT contain an MD5. * @param string $CacheTag - name of tag for future retrieval - should NOT contain an MD5.
* @param data $Data - data to be cached * @param string $Data - data to be cached
* @param boolean $ForceCache [optional] if TRUE, writes cache even when disabled in admin prefs. * @param boolean $ForceCache [optional] if TRUE, writes cache even when disabled in admin prefs.
* @param boolean $bRaw [optional] if TRUE, writes data exactly as provided instead of prefacing with php leadin * @param boolean $bRaw [optional] if TRUE, writes data exactly as provided instead of prefacing with php leadin
* @param boolean $syscache [optional] * @param boolean $syscache [optional]

View File

@@ -72,25 +72,22 @@ class e107_db_debug {
$this->ShowIf('Shortcodes / BBCode',$this->Show_SC_BB()); $this->ShowIf('Shortcodes / BBCode',$this->Show_SC_BB());
$this->ShowIf('Paths', $this->Show_PATH()); $this->ShowIf('Paths', $this->Show_PATH());
$this->ShowIf('Deprecated Function Usage', $this->Show_DEPRECATED()); $this->ShowIf('Deprecated Function Usage', $this->Show_DEPRECATED());
if(E107_DBG_INCLUDES) if(E107_DBG_INCLUDES)
{ {
$this->aIncList = get_included_files(); $this->aIncList = get_included_files();
} }
$this->ShowIf('Included Files: '.count($this->aIncList), $this->Show_Includes()); $this->ShowIf('Included Files: '.count($this->aIncList), $this->Show_Includes());
} }
function ShowIf($title,$str) function ShowIf($title,$str)
{ {
global $ns,$style;
$style='debug';
if (!isset($ns)) { if(!empty($str))
echo "Why did ns go away?<br />"; {
$ns = new e107table; e107::getRender()->setStyle('debug');
} e107::getRender()->tablerender($title, $str);
if (strlen($str)) {
$ns->tablerender($title, $str);
} }
} }
@@ -517,8 +514,8 @@ class e107_db_debug {
</thead> </thead>
<tbody>\n"; <tbody>\n";
$description = array(1=>'Bbcode',2=>'Shortcode',3=>'Wrapper'); $description = array(1=>'Bbcode',2=>'Shortcode',3=>'Wrapper', 4=>'Shortcode Override');
$style = array(1 => 'label-info', 2=>'label-primary', 3=>'label-warning'); $style = array(1 => 'label-info', 2=>'label-primary', 3=>'label-warning', 'label-danger');
foreach($this -> scbbcodes as $codes) foreach($this -> scbbcodes as $codes)
{ {
@@ -661,6 +658,12 @@ class e107_db_debug {
// //
function log($message,$TraceLev=1) function log($message,$TraceLev=1)
{ {
if(is_array($message))
{
$message = "<pre>".print_r($message,true)."</pre>";
}
if (!E107_DBG_BASIC){ if (!E107_DBG_BASIC){
return FALSE; return FALSE;
} }
@@ -683,8 +686,10 @@ class e107_db_debug {
} }
} }
function Show_Log(){ function Show_Log()
if (!E107_DBG_BASIC || !count($this->aLog)){ {
if (empty($this->aLog))
{
return FALSE; return FALSE;
} }
// //
@@ -697,8 +702,9 @@ class e107_db_debug {
foreach ($this->aLog as $curLog) foreach ($this->aLog as $curLog)
{ {
if (!$bRowHeaders) { if (!$bRowHeaders)
$bRowHeaders=TRUE; {
$bRowHeaders = true;
$text .= "<tr class='fcaption'><td><b>".implode("</b></td><td><b>", array_keys($curLog))."</b></td></tr>\n"; $text .= "<tr class='fcaption'><td><b>".implode("</b></td><td><b>", array_keys($curLog))."</b></td></tr>\n";
} }

View File

@@ -1180,7 +1180,7 @@ class e_form
/** /**
* User auto-complete search * User auto-complete search
* * XXX EXPERIMENTAL - subject to change.
* @param string $name_fld field name for user name * @param string $name_fld field name for user name
* @param string $id_fld field name for user id * @param string $id_fld field name for user id
* @param string $default_name default user name value * @param string $default_name default user name value
@@ -1188,6 +1188,7 @@ class e_form
* @param array|string $options [optional] 'readonly' (make field read only), 'name' (db field name, default user_name) * @param array|string $options [optional] 'readonly' (make field read only), 'name' (db field name, default user_name)
* @return string HTML text for display * @return string HTML text for display
*/ */
/*
function userpicker($name_fld, $id_fld='', $default_name, $default_id, $options = array()) function userpicker($name_fld, $id_fld='', $default_name, $default_id, $options = array())
{ {
if(!is_array($options)) if(!is_array($options))
@@ -1225,6 +1226,105 @@ class e_form
return $ret; return $ret;
} }
*/
/**
* User Field - auto-complete search
* @param string $name form element name
* @param string|array $value comma separated list of user ids or array of userid=>username pairs.
* @param array|string $options [optional]
* @param int $options['limit'] Maximum number of users
* @param string $options['id'] Custom id
* @param string $options['inline'] Inline ID.
*
* @example $frm->userpicker('author', 1);
* @example $frm->userpicker('authors', "1,2,3");
* @example $frm->userpicker('author', array('user_id'=>1, 'user_name'=>'Admin');
* @example $frm->userpicker('authors', array(0=>array('user_id'=>1, 'user_name'=>'Admin', 1=>array('user_id'=>2, 'user_name'=>'John'));
*
* @todo $options['type'] = 'select' - dropdown selections box with data returned as array instead of comma-separated.
* @return string HTML text for display
*/
function userpicker($name, $value, $options = array())
{
if(!is_array($options))
{
parse_str($options, $options);
}
$defaultItems = array();
if(is_array($value))
{
if(isset($value[0]))// multiple users.
{
foreach($value as $val)
{
$defaultItems[] = array('value'=>$val['user_id'], 'label'=>$val['user_name']);
}
}
else // single user
{
$defaultItems[] = array('value'=>$value['user_id'], 'label'=>$value['user_name']);
}
}
elseif(!empty($value)) /// comma separated with user-id lookup.
{
$tmp = explode(",", $value);
foreach($tmp as $uid)
{
if($user = e107::user($uid))
{
$defaultItems[] = array('value'=>$user['user_id'], 'label'=>$user['user_name']);
}
}
}
$parms = array(
'selectize' => array(
'loadPath' => e_BASE . 'user.php',
'create' => false,
'maxItems' => 1,
'mode' => 'multi',
'options' => $defaultItems
)
);
if(!empty($options['limit']))
{
$parms['selectize']['maxItems'] = intval($options['limit']);
}
if(!empty($options['id']))
{
$parms['id'] = $options['id'];
}
if(!empty($options['inline']))
{
$parms['selectize']['e_editable'] = $options['inline'];
}
//TODO FIXME Filter by userclass. - see $frm->userlist().
$defValues = array();
foreach($defaultItems as $val)
{
$defValues[] = $val['value'];
}
$ret = $this->text($name, implode(",",$defValues), 100, $parms);
return $ret;
}
/** /**
@@ -2034,11 +2134,15 @@ class e_form
/** /**
* Universal Userclass selector - checkboxes, dropdown, everything. * Universal Userclass selector - checkboxes, dropdown, everything.
* @param $name - form element name * @param string $name - form element name
* @param $curval - current userclass value(s) as array or comma separated. * @param int $curval - current userclass value(s) as array or comma separated.
* @param $type - 'checkbox', 'dropdown', * @param string $type - checkbox|dropdown default is dropdown.
* @param options - query string or array. 'options=admin,mainadmin,classes&vetted=1&exclusions=0' etc. * @param string|array $options - classlist or query string or key=value pair.
* @return the userclass form element * @param string $options['options'] comma-separated list of display options. 'options=admin,mainadmin,classes&vetted=1&exclusions=0' etc.
*
* @example $frm->userclass('name', 0, 'dropdown', 'classes'); // display all userclasses
* @example $frm->userclass('name', 0, 'dropdown', 'classes,matchclass'); // display only classes to which the user belongs.
* @return string form element(s)
*/ */
function userclass($name, $curval=255, $type=null, $options=null) function userclass($name, $curval=255, $type=null, $options=null)
{ {
@@ -2048,10 +2152,14 @@ class e_form
{ {
$opt = $options; $opt = $options;
} }
else elseif(strpos($options,'=')!==false)
{ {
parse_str($options,$opt); parse_str($options,$opt);
} }
else
{
$opt = array('options'=>$options);
}
} }
else else
@@ -2626,7 +2734,10 @@ class e_form
break; break;
case 'placeholder': case 'placeholder':
if($optval) $ret .= " placeholder='{$optval}'"; if($optval) {
$optval = deftrue($optval, $optval);
$ret .= " placeholder='{$optval}'";
}
break; break;
case 'wrap': case 'wrap':
@@ -3570,7 +3681,18 @@ class e_form
} }
if(!is_array($attributes['writeParms'])) parse_str($attributes['writeParms'], $attributes['writeParms']); if(!is_array($attributes['writeParms'])) parse_str($attributes['writeParms'], $attributes['writeParms']);
$value = vartrue($attributes['writeParms']['__options']['pre']).vartrue($attributes['writeParms'][$value]).vartrue($attributes['writeParms']['__options']['post']);
if(!empty($attributes['writeParms']['optArray']))
{
$radioValue = $attributes['writeParms']['optArray'][$value];
}
else
{
$radioValue = vartrue($attributes['writeParms'][$value]);
}
$value = vartrue($attributes['writeParms']['__options']['pre']).$radioValue.vartrue($attributes['writeParms']['__options']['post']);
break; break;
case 'tags': case 'tags':
@@ -4034,7 +4156,9 @@ class e_form
$fieldID = $this->name2id($field . '_' . microtime(true)); $fieldID = $this->name2id($field . '_' . microtime(true));
// Unique ID for each rows. // Unique ID for each rows.
$eEditableID = $this->name2id($fieldID . '_' . $row_id); $eEditableID = $this->name2id($fieldID . '_' . $row_id);
$tpl = $this->userpicker($field, '', $ttl, $id, array('id' => $fieldID, 'selectize' => array('e_editable' => $eEditableID))); // $tpl = $this->userpicker($field, '', $ttl, $id, array('id' => $fieldID, 'selectize' => array('e_editable' => $eEditableID)));
$tpl = $this->userpicker($fieldID, array('user_id'=>$id, 'user_name'=>$ttl), array('id' => $fieldID, 'inline' => $eEditableID));
$mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));
$value = "<a id='" . $eEditableID . "' class='e-tip e-editable editable-click editable-userpicker' data-clear='false' data-tpl='" . str_replace("'", '"', $tpl) . "' data-name='" . $field . "' title=\"" . LAN_EDIT . " " . $attributes['title'] . "\" data-type='text' data-pk='" . $row_id . "' data-value='" . $id . "' data-url='" . e_SELF . "?mode={$mode}&amp;action=inline&amp;id={$row_id}&amp;ajax_used=1' href='#'>" . $ttl . "</a>"; $value = "<a id='" . $eEditableID . "' class='e-tip e-editable editable-click editable-userpicker' data-clear='false' data-tpl='" . str_replace("'", '"', $tpl) . "' data-name='" . $field . "' title=\"" . LAN_EDIT . " " . $attributes['title'] . "\" data-type='text' data-pk='" . $row_id . "' data-value='" . $id . "' data-url='" . e_SELF . "?mode={$mode}&amp;action=inline&amp;id={$row_id}&amp;ajax_used=1' href='#'>" . $ttl . "</a>";
} }
@@ -4650,30 +4774,41 @@ class e_form
case 'user': case 'user':
//user_id expected //user_id expected
// Just temporary solution, could be changed soon // Just temporary solution, could be changed soon
if(!isset($parms['__options'])) $parms['__options'] = array(); if(!isset($parms['__options'])) $parms['__options'] = array();
if(!is_array($parms['__options'])) parse_str($parms['__options'], $parms['__options']); if(!is_array($parms['__options'])) parse_str($parms['__options'], $parms['__options']);
if((empty($value) && varset($parms['currentInit'],USERID)!=0) || vartrue($parms['current'])) // include current user by default. if((empty($value) && !empty($parms['currentInit']) && !isset($parms['default']) ) || !empty($parms['current']) || (vartrue($parms['default']) == 'USERID')) // include current user by default.
{ {
$value = USERID; $value = USERID;
if(vartrue($parms['current'])) if(vartrue($parms['current']))
{ {
$parms['__options']['readonly'] = true; $parms['__options']['readonly'] = true;
} }
} }
if(!is_array($value)) // if(!is_array($value))
{ // {
$value = $value ? e107::getSystemUser($value, true)->getUserData() : array();// e107::user($value); // $value = $value ? e107::getSystemUser($value, true)->getUserData() : array();// e107::user($value);
} // }
$colname = vartrue($parms['nameType'], 'user_name'); $colname = vartrue($parms['nameType'], 'user_name');
$parms['__options']['name'] = $colname; $parms['__options']['name'] = $colname;
if(!$value) $value = array(); // if(!$value) $value = array();
$uname = varset($value[$colname]); // $uname = varset($value[$colname]);
$value = varset($value['user_id'], 0); // $value = varset($value['user_id'], 0);
$ret = $this->userpicker(vartrue($parms['nameField'], $key), $key, $uname, $value, vartrue($parms['__options']));
if(!empty($parms['limit']))
{
$parms['__options']['limit'] = intval($parms['limit']);
}
$ret = $this->userpicker(vartrue($parms['nameField'], $key), $value, vartrue($parms['__options']));
// $ret = $this->userpicker(vartrue($parms['nameField'], $key), $key, $uname, $value, vartrue($parms['__options']));
break; break;
case 'bool': case 'bool':

View File

@@ -151,7 +151,7 @@ class MagpieRSS {
// check for a namespace, and split if found // check for a namespace, and split if found
$ns = false; $ns = false;
if ( strpos( $element, ':' ) ) { if ( strpos( $element, ':' ) ) {
list($ns, $el) = split( ':', $element, 2); list($ns, $el) = explode( ':', $element, 2);
} }
if ( $ns and $ns != 'rdf' ) { if ( $ns and $ns != 'rdf' ) {
$this->current_namespace = $ns; $this->current_namespace = $ns;

View File

@@ -947,10 +947,10 @@ class e107Email extends PHPMailer
* @param bool $eml['add_html_header'] - if TRUE, adds the 2-line DOCTYPE declaration to the front of the HTML part (but doesn't add <head>...</head>) * @param bool $eml['add_html_header'] - if TRUE, adds the 2-line DOCTYPE declaration to the front of the HTML part (but doesn't add <head>...</head>)
* @param string $eml['body'] - message body. May be HTML or text. Added according to the current state of the HTML enable flag * @param string $eml['body'] - message body. May be HTML or text. Added according to the current state of the HTML enable flag
* @param string|array $eml['attach'] - string if one file, array of filenames if one or more. * @param string|array $eml['attach'] - string if one file, array of filenames if one or more.
* @param string $eml['copy_to'] - comma-separated list of cc addresses. * @param string $eml['cc'] - comma-separated list of cc addresses.
* @param string $eml['cc_names'] - comma-separated list of cc names. Optional, used only if $eml['copy_to'] specified * @param string $eml['cc_names'] - comma-separated list of cc names. Optional, used only if $eml['cc'] specified
* @param string $eml['bcopy_to'] - comma-separated list * @param string $eml['bcc'] - comma-separated list
* @param string $eml['bcc_names'] - comma-separated list of bcc names. Optional, used only if $eml['copy_to'] specified * @param string $eml['bcc_names'] - comma-separated list of bcc names. Optional, used only if $eml['bcc'] specified
* @param string $eml['bouncepath'] - Sender field (used for bounces) * @param string $eml['bouncepath'] - Sender field (used for bounces)
* @param string $eml['returnreceipt'] - email address for notification of receipt (reading) * @param string $eml['returnreceipt'] - email address for notification of receipt (reading)
* @param array $eml['inline_images'] - array of files for inline images * @param array $eml['inline_images'] - array of files for inline images
@@ -1122,10 +1122,18 @@ class e107Email extends PHPMailer
$url = $tp->replaceConstants($url); $url = $tp->replaceConstants($url);
// resize on the fly. // resize on the fly.
if($this->debug)
{
echo "<br />Attempting Resize...".$url;
}
if($resized = e107::getMedia()->resizeImage($url, e_TEMP.basename($url),'w=800')) if($resized = e107::getMedia()->resizeImage($url, e_TEMP.basename($url),'w=800'))
{ {
$url = $resized; $url = $resized;
} }
elseif($this->debug)
{
echo "<br />Couldn't resize ".$url;
}
$delim = $images[2][$i]; // Will be single or double quote $delim = $images[2][$i]; // Will be single or double quote
$filename = basename($url); $filename = basename($url);
@@ -1139,7 +1147,7 @@ class e107Email extends PHPMailer
if ($this->debug) if ($this->debug)
{ {
echo "<br />CID file {$filename} in {$directory}. Base = ".SERVERBASE."< BaseDir = {$basedir}<br />"; echo "<br />CID file {$filename} in {$directory}. Base = ".SERVERBASE."<br />BaseDir = {$basedir}<br />";
} }
$cid = 'cid:' . md5($filename); $cid = 'cid:' . md5($filename);

View File

@@ -1472,6 +1472,11 @@ class e_media
$src = $tp->replaceConstants($src); $src = $tp->replaceConstants($src);
$dest = $tp->replaceConstants($dest); $dest = $tp->replaceConstants($dest);
if(!file_exists($src))
{
return false;
}
$maxWidth = varset($opts['w'], 800); $maxWidth = varset($opts['w'], 800);
$maxHeight = varset($opts['h'], 800); $maxHeight = varset($opts['h'], 800);

View File

@@ -440,7 +440,7 @@ class e_pref extends e_front_model
* @param boolean $force * @param boolean $force
* @return e_pref * @return e_pref
*/ */
public function load($force = false) public function load($id=null, $force = false)
{ {
global $pref; global $pref;
if($force || !$this->hasData()) if($force || !$this->hasData())

View File

@@ -70,6 +70,7 @@ class e_parse_shortcode
protected $scOverride = array(); // Array of codes found in override/shortcodes dir protected $scOverride = array(); // Array of codes found in override/shortcodes dir
protected $scBatchOverride = array(); // Array of codes found in override/shortcodes/batch dir protected $scBatchOverride = array(); // Array of codes found in override/shortcodes/batch dir
protected $ignoreCodes = array(); // Shortcodes to be ignored and remain unchanged. (ie. {THEME}, {e_PLUGIN} etc. ) protected $ignoreCodes = array(); // Shortcodes to be ignored and remain unchanged. (ie. {THEME}, {e_PLUGIN} etc. )
protected $addonOverride = array(); // Overrides coming from e_shortcode.php
/** /**
* @var e_vars * @var e_vars
*/ */
@@ -99,6 +100,8 @@ class e_parse_shortcode
$this->loadPluginSCFiles(); $this->loadPluginSCFiles();
//$this->loadCoreShortcodes(); DEPRECATED //$this->loadCoreShortcodes(); DEPRECATED
} }
/** /**
@@ -161,7 +164,7 @@ class e_parse_shortcode
else else
{ {
$codes = strtoupper($codes); $codes = strtoupper($codes);
if ((!$this->isRegistered($code) || $force == true) && !$this->isOverride($code)) if ((!$this->isRegistered($codes) || $force == true) && !$this->isOverride($codes))
{ {
$this->registered_codes[$codes] = array('type' => 'func', 'path' => $path, 'function' => $classFunc); $this->registered_codes[$codes] = array('type' => 'func', 'path' => $path, 'function' => $classFunc);
} }
@@ -245,12 +248,29 @@ class e_parse_shortcode
if (class_exists($class, false) && ($force || !$this->isScClass($class))) if (class_exists($class, false) && ($force || !$this->isScClass($class)))
{ {
$this->scClasses[$class] = new $class(); $this->scClasses[$class] = new $class();
if(method_exists($this->scClasses[$class], 'init')) if(method_exists($this->scClasses[$class], 'init'))
{ {
$this->scClasses[$class]->init(); $this->scClasses[$class]->init();
} }
if(!empty($this->scClasses[$class]->override))
{
$methods = get_class_methods($class);
foreach($methods as $meth)
{
if(substr($meth,0,3) == 'sc_')
{
$this->addonOverride[$meth] = $class;
}
}
}
return $this->scClasses[$class]; return $this->scClasses[$class];
} }
return null; return null;
} }
@@ -461,25 +481,16 @@ class e_parse_shortcode
{ {
global $register_sc; global $register_sc;
// $this->registered_codes[$code]['type'] = 'plugin';
// $this->registered_codes[$code]['function'] = strtolower($code).'_shortcode';
// $this->registered_codes[$code]['path'] = e_PLUGIN.$path.'/shortcodes/single/';
// $this->registered_codes[$code]['perms'] = $uclass;
if(deftrue('e_DEVELOPER')) // experimental, could break something. - use theme shortcodes in other templates.
{
if(file_exists(THEME."theme_shortcodes.php")) if(file_exists(THEME."theme_shortcodes.php"))
{ {
$classFunc = 'theme_shortcodes'; $classFunc = 'theme_shortcodes';
$path = THEME."theme_shortcodes.php"; $path = THEME."theme_shortcodes.php";
include_once($path); include_once($path);
$this->registerClassMethods($classFunc, $path, false); $this->registerClassMethods($classFunc, $path, false);
}
} }
if (isset($register_sc) && is_array($register_sc))
if (isset($register_sc) && is_array($register_sc)) // legacy load.
{ {
foreach ($register_sc as $code) foreach ($register_sc as $code)
{ {
@@ -641,33 +652,15 @@ class e_parse_shortcode
return $this; return $this;
} }
/**
* DEPRECATED admin_shortcodes now loaded inside admin parse function (see boot.php)
* Register Core Shortcode Batches.
* FIXME - make it smarter - currently loaded all the time (even on front-end)
*
* @return e_parse_shortcode
*/
// function loadCoreShortcodes()
// {
// $coreBatchList = array('admin_shortcodes');
//
// foreach ($coreBatchList as $cb)
// {
// $path = e_CORE.'shortcodes/batch/'.$cb.".php";
// if (include_once($path))
// {
// $this->registerClassMethods($cb, $path);
// }
// }
// return $this;
// }
function isRegistered($code) function isRegistered($code)
{ {
return array_key_exists($code, $this->registered_codes); return array_key_exists($code, $this->registered_codes);
} }
public function resetScClass($className, $object) public function resetScClass($className, $object)
{ {
if(null === $object) if(null === $object)
@@ -755,6 +748,8 @@ class e_parse_shortcode
$this->addedCodes = &$extraCodes; $this->addedCodes = &$extraCodes;
// e107::getDebug()->log("Codes".print_a($this->addedCodes,true));
// TEMPLATEID_WRAPPER support - see contact template // TEMPLATEID_WRAPPER support - see contact template
// must be registered in e_shortcode object (batch) via () method before parsing // must be registered in e_shortcode object (batch) via () method before parsing
// Do it only once per parsing cylcle and not on every doCode() loop - performance // Do it only once per parsing cylcle and not on every doCode() loop - performance
@@ -918,26 +913,39 @@ class e_parse_shortcode
$_path = ''; $_path = '';
$ret = ''; $ret = '';
$_method = 'sc_'.strtolower($code); $_method = 'sc_'.strtolower($code);
if (is_object($this->addedCodes) && method_exists($this->addedCodes, $_method)) //It is class-based batch shortcode. Class already loaded; call the method
// Display e_shortcode.php override info.
if((E107_DBG_BBSC || E107_DBG_SC) && isset($this->addonOverride[$_method]) && is_object($this->addedCodes) && method_exists($this->addedCodes, $_method))
{
$debugArr = array('class_original'=>get_class($this->addedCodes), 'class_override'=>$this->addonOverride[$_method], 'function'=>$_method);
e107::getDebug()->logCode(4, $code, null, print_a($debugArr,true));
}
if (!isset($this->addonOverride[$_method]) && is_object($this->addedCodes) && method_exists($this->addedCodes, $_method)) //It is class-based batch shortcode. Class already loaded; call the method
{ {
$ret = $this->addedCodes->$_method($parm, $sc_mode); $ret = $this->addedCodes->$_method($parm, $sc_mode);
if(E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS) if(E107_DBG_BBSC || E107_DBG_SC || E107_DBG_TIMEDETAILS)
{ {
$_class = get_class($this->addedCodes); // "(class loaded)"; // debug. $_class = get_class($this->addedCodes); // "(class loaded)"; // debug.
$_function = $_method; $_function = $_method;
$_path = "(already loaded)"; $_path = "(already loaded)";
} }
} }
elseif (is_array($this->addedCodes) && array_key_exists($code, $this->addedCodes)) // Its array-based shortcode. Load the code for evaluation later. elseif (is_array($this->addedCodes) && array_key_exists($code, $this->addedCodes)) // Its array-based shortcode. Load the code for evaluation later.
{ {
$scCode = $this->addedCodes[$code]; $ret = $this->addedCodes[$code];
// $_path = print_a($this->backTrace,true); // $_class = "n/a";
//XXX $_path = print_a($this,true); // $_function = "n/a";
$_type = 'array';
$_path = "(direct to parser)";
} }
elseif (array_key_exists($code, $this->scList)) // Check to see if we've already loaded the .sc file contents elseif (array_key_exists($code, $this->scList)) // Check to see if we've already loaded the .sc file contents
{ {
@@ -1062,7 +1070,10 @@ class e_parse_shortcode
$_path = $scFile; $_path = $scFile;
} }
} }
if ($scFile && file_exists($scFile))
if(!empty($scFile))
{
if(file_exists($scFile))
{ {
$scCode = file_get_contents($scFile); $scCode = file_get_contents($scFile);
$this->scList[$code] = $scCode; $this->scList[$code] = $scCode;
@@ -1070,11 +1081,12 @@ class e_parse_shortcode
} }
else else
{ {
// $ret = 'Missing!'; $_path .= $scFile." MISSING!";
$_path .= " MISSING!";
} }
} }
}
if (!isset($scCode)) if (!isset($scCode))
{ {
if (E107_DBG_BBSC) if (E107_DBG_BBSC)
@@ -1084,21 +1096,37 @@ class e_parse_shortcode
return $matches[0]; return $matches[0];
} }
if (E107_DBG_SC && $scFile) // if (E107_DBG_SC && $scFile)
{ // {
// echo (isset($scFile)) ? "<br />sc_file= ".str_replace(e_CORE.'shortcodes/single/', '', $scFile).'<br />' : ''; // echo (isset($scFile)) ? "<br />sc_file= ".str_replace(e_CORE.'shortcodes/single/', '', $scFile).'<br />' : '';
// echo "<br />sc= <b>$code</b>"; // echo "<br />sc= <b>$code</b>";
} // }
} }
if ($scCode) if ($scCode) // legacy shortode to be evaluated.
{
try
{ {
$ret = @eval($scCode); $ret = @eval($scCode);
}
catch (Throwable $t) { // Executed only in PHP 7, will not match in PHP 5.x
$string = print_a($scCode,true);
$string .= "<h4>Added Coded</h4>";
$string .= print_a($this->addedCodes,true);
e107::getMessage()->addDebug('Could not parse Shortcode '.$scFile.' :: {'.$code .'} '.$string);
}
catch (Exception $e)
{
echo $e->getMessage();
}
if($ret === false && E107_DEBUG_LEVEL > 0) // Error in Code. if($ret === false && E107_DEBUG_LEVEL > 0) // Error in Code.
{ {
$string = print_a($scCode,true); // $string = print_a($scCode,true);
e107::getMessage()->addDebug('Could not parse Shortcode '.$scFile.' :: {'.$code .'} '.$string); // e107::getMessage()->addDebug('Could not parse Shortcode '.$scFile.' :: {'.$code .'} '.$string);
} }
} }
@@ -1176,19 +1204,26 @@ class e_parse_shortcode
$other = array(); $other = array();
if($_class) if(!empty($_type))
{
$other['type'] = $_type;
}
if(!empty($_class))
{ {
$other['class'] = $_class; $other['class'] = $_class;
} }
if(vartrue($_function)) if(!empty($_function))
{ {
$other['function'] = $_function; $other['function'] = $_function;
} }
if(vartrue($_path)) if(!empty($_path))
{ {
$other['path'] = str_replace('../','',$_path); $other['path'] = str_replace('../','',$_path);
} }
if($this->debug_legacy) if($this->debug_legacy)
{ {
$other = $this->debug_legacy; $other = $this->debug_legacy;
@@ -1309,6 +1344,7 @@ class e_shortcode
protected $wrapper = null; // holds template/key value of the currently used wrapper (if any) - see contact_template.php for an example. protected $wrapper = null; // holds template/key value of the currently used wrapper (if any) - see contact_template.php for an example.
protected $override = false;
/** /**
* Storage for shortcode values * Storage for shortcode values
* @var e_vars * @var e_vars
@@ -1328,6 +1364,7 @@ class e_shortcode
*/ */
public function init() {} public function init() {}
/** /**
* Sets wrapper id (to be retrieved from the registry while parsing) * Sets wrapper id (to be retrieved from the registry while parsing)
* Example e107::getScBatch('contact')->wrapper('contact/form'); * Example e107::getScBatch('contact')->wrapper('contact/form');
@@ -1367,6 +1404,7 @@ class e_shortcode
/** /**
* Alias of setParserVars - Preferred use by Plugins. * Alias of setParserVars - Preferred use by Plugins.
* Sets the value of $sc->var
*/ */
public function setVars($eVars) // Alias of setParserVars(); public function setVars($eVars) // Alias of setParserVars();
{ {

View File

@@ -45,11 +45,12 @@ class e107_user_extended
private $extended_xml = FALSE; private $extended_xml = FALSE;
public $typeArray; // Cross-reference between names of field types, and numeric ID (must be public) public $typeArray; // Cross-reference between names of field types, and numeric ID (must be public)
private $reserved_names; // List of field names used in main user DB - not allowed in extended DB private $reserved_names; // List of field names used in main user DB - not allowed in extended DB
public $fieldDefinitions; // Array initialised from DB by constructor - currently all fields public $fieldDefinitions = array(); // Array initialised from DB by constructor - currently all fields
public $catDefinitions; // Categories public $catDefinitions; // Categories
private $nameIndex; // Array for field name lookup - initialised by constructor private $nameIndex = array(); // Array for field name lookup - initialised by constructor
public $systemCount = 0; // Count of system fields - always zero ATM public $systemCount = 0; // Count of system fields - always zero ATM
public $userCount = 0; // Count of non-system fields public $userCount = 0; // Count of non-system fields
private $fieldPermissions = array(); // Field Permissionss with field name as key.
public function __construct() public function __construct()
{ {
@@ -109,7 +110,6 @@ class e107_user_extended
// Read in all the field and category fields // Read in all the field and category fields
// At present we load all fields into common array - may want to split system and non-system // At present we load all fields into common array - may want to split system and non-system
$this ->catDefinitions = array(); // Categories array $this ->catDefinitions = array(); // Categories array
$this->fieldDefinitions = array(); // Field definitions array
$this->nameIndex = array(); // Index of names => field IDs $this->nameIndex = array(); // Index of names => field IDs
$this->systemCount = 0; $this->systemCount = 0;
$this->userCount = 0; $this->userCount = 0;
@@ -125,6 +125,8 @@ class e107_user_extended
else else
{ // Its a field definition { // Its a field definition
$this->fieldDefinitions[$row['user_extended_struct_id']] = $row; $this->fieldDefinitions[$row['user_extended_struct_id']] = $row;
$id = 'user_'.$row['user_extended_struct_name'];
$this->fieldPermissions[$id] = array('read'=>$row['user_extended_struct_read'], 'write'=>$row['user_extended_struct_write']);
$this->nameIndex['user_'.$row['user_extended_struct_name']] = $row['user_extended_struct_id']; // Create name to ID index $this->nameIndex['user_'.$row['user_extended_struct_name']] = $row['user_extended_struct_id']; // Create name to ID index
if ($row['user_extended_struct_text'] == '_system_') if ($row['user_extended_struct_text'] == '_system_')
{ {
@@ -139,14 +141,24 @@ class e107_user_extended
} }
} }
/**
* Check read/write access on extended user-fields
* @param string $field eg. user_something
* @param string $type read|write
* @return boolean true if
*/
public function hasPermission($field, $type='read')
{
$class = ($type == 'read') ? $this->fieldPermissions[$field]['read'] : $this->fieldPermissions[$field]['write'];
return check_class($class);
}
/** /**
* Check for reserved field names. * Check for reserved field names.
* (Names which clash with the 'normal' user table aren't allowed) * (Names which clash with the 'normal' user table aren't allowed)
*
* @param string $name - name of field bweing checked (no 'user_' prefix) * @param string $name - name of field bweing checked (no 'user_' prefix)
*
* @return boolean TRUE if disallowed name * @return boolean TRUE if disallowed name
*/ */
public function user_extended_reserved($name) public function user_extended_reserved($name)

View File

@@ -90,8 +90,8 @@ class UserHandler
$this->userVettingInfo = array( $this->userVettingInfo = array(
'user_name' => array('niceName'=> LAN_USER_01, 'fieldType' => 'string', 'vetMethod' => '1,2', 'vetParam' => 'signup_disallow_text', 'srcName' => 'username', 'stripTags' => TRUE, 'stripChars' => '/&nbsp;|\#|\=|\$/', 'fixedBlock' => 'anonymous', 'minLength' => 2, 'maxLength' => varset($pref['displayname_maxlength'],15)), // Display name 'user_name' => array('niceName'=> LAN_USER_01, 'fieldType' => 'string', 'vetMethod' => '1,2', 'vetParam' => 'signup_disallow_text', 'srcName' => 'username', 'stripTags' => TRUE, 'stripChars' => '/&nbsp;|\#|\=|\$/', 'fixedBlock' => 'anonymous', 'minLength' => 2, 'maxLength' => varset($pref['displayname_maxlength'],15)), // Display name
'user_loginname' => array('niceName'=> LAN_USER_02, 'fieldType' => 'string', 'vetMethod' => '1', 'vetParam' => '', 'srcName' => 'loginname', 'stripTags' => TRUE, 'stripChars' => '#[^a-z0-9_\.]#i', 'minLength' => 2, 'maxLength' => varset($pref['loginname_maxlength'],30)), // User name 'user_loginname' => array('niceName'=> LAN_USER_02, 'fieldType' => 'string', 'vetMethod' => '1', 'vetParam' => '', 'srcName' => 'loginname', 'stripTags' => TRUE, 'stripChars' => '#[^a-z0-9_\.]#i', 'minLength' => 2, 'maxLength' => varset($pref['loginname_maxlength'],30)), // User name
'user_login' => array('niceName'=> LAN_USER_03, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'realname', 'dbClean' => 'toDB'), // Real name (no real vetting) 'user_login' => array('niceName'=> LAN_USER_03, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'realname', 'dbClean' => 'toDB', 'stripTags' => TRUE, 'stripChars' => '#<|>#i'), // Real name (no real vetting)
'user_customtitle' => array('niceName'=> LAN_USER_04, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'customtitle', 'dbClean' => 'toDB', 'enablePref' => 'signup_option_customtitle'), // No real vetting 'user_customtitle' => array('niceName'=> LAN_USER_04, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'customtitle', 'dbClean' => 'toDB', 'enablePref' => 'signup_option_customtitle', 'stripTags' => TRUE, 'stripChars' => '#<|>#i'), // No real vetting
'user_password' => array('niceName'=> LAN_PASSWORD, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'password1', 'dataType' => 2, 'minLength' => varset($pref['signup_pass_len'],1)), 'user_password' => array('niceName'=> LAN_PASSWORD, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'password1', 'dataType' => 2, 'minLength' => varset($pref['signup_pass_len'],1)),
'user_sess' => array('niceName'=> LAN_USER_06, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'image', 'imagePath' => e_AVATAR_UPLOAD, 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120)), // Photo 'user_sess' => array('niceName'=> LAN_USER_06, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'image', 'imagePath' => e_AVATAR_UPLOAD, 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120)), // Photo
'user_image' => array('niceName'=> LAN_USER_07, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'image', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'avatar'), //, 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120) resized on-the-fly // Avatar 'user_image' => array('niceName'=> LAN_USER_07, 'fieldType' => 'string', 'vetMethod' => '0', 'vetParam' => '', 'srcName' => 'image', 'stripChars' => "#\"|'|(|)#", 'dbClean' => 'avatar'), //, 'maxHeight' => varset($pref['im_height'], 100), 'maxWidth' => varset($pref['im_width'], 120) resized on-the-fly // Avatar

View File

@@ -952,7 +952,7 @@ class e_user_model extends e_admin_model
if(false !== $ret && null !== $this->_extended_model) // don't load extended fields if not already used if(false !== $ret && null !== $this->_extended_model) // don't load extended fields if not already used
{ {
$ret_e = $this->_extended_model->save($force, $session); $ret_e = $this->_extended_model->save(true, $force, $session);
if(false !== $ret_e) if(false !== $ret_e)
{ {
return ($ret_e + $ret); return ($ret_e + $ret);
@@ -2290,7 +2290,7 @@ class e_user_extended_model extends e_admin_model
* @see e_model#load($id, $force) * @see e_model#load($id, $force)
* @return e_user_extended_model * @return e_user_extended_model
*/ */
public function load($force = false) public function load($id=null, $force = false)
{ {
if ($this->getId() && !$force) if ($this->getId() && !$force)
return $this; return $this;
@@ -2434,7 +2434,7 @@ class e_user_extended_model extends e_admin_model
* Build data types and rules on the fly and save * Build data types and rules on the fly and save
* @see e_front_model::save() * @see e_front_model::save()
*/ */
public function save($force = false, $session = false) public function save($from_post = true, $force = false, $session = false)
{ {
// when not loaded from db, see the construct check // when not loaded from db, see the construct check
if(!$this->getId()) if(!$this->getId())
@@ -2730,7 +2730,7 @@ class e_user_pref extends e_front_model
* @param boolean $force * @param boolean $force
* @return e_user_pref * @return e_user_pref
*/ */
public function load($force = false) public function load($id = null, $force = false)
{ {
if($force || !$this->hasData()) if($force || !$this->hasData())
{ {
@@ -2785,13 +2785,13 @@ class e_user_pref extends e_front_model
} }
/** /**
* Remove & apply user prefeferences, optionally - save to DB * Remove & apply user preferences, optionally - save to DB
* @return boolean success * @return boolean success
*/ */
public function delete($save = false) public function delete($ids, $destroy = true, $session_messages = false) // replaced $save = false for PHP7 fix.
{ {
$this->removeData()->apply(); $this->removeData()->apply();
if($save) return $this->save(); // if($save) return $this->save(); //FIXME adjust within the context of the variables in the method.
return true; return true;
} }
} }

View File

@@ -15,6 +15,7 @@ if(!defined('e107_INIT'))
class _blank_shortcodes extends e_shortcode class _blank_shortcodes extends e_shortcode
{ {
public $override = false; // when set to true, existing core/plugin shortcodes matching methods below will be overridden.
// Example: {_BLANK_CUSTOM} shortcode - available site-wide. // Example: {_BLANK_CUSTOM} shortcode - available site-wide.
function sc__blank_custom($parm = null) // Naming: "sc_" + [plugin-directory] + '_uniquename' function sc__blank_custom($parm = null) // Naming: "sc_" + [plugin-directory] + '_uniquename'

View File

@@ -108,4 +108,4 @@ class banner_shortcodes extends e_shortcode
return $text; return $text;
} }
} }
?>

View File

@@ -20,6 +20,24 @@ if (!e107::isInstalled('download'))
e107::lan('download',false, true); // Loads e_PLUGIN.'download/languages/'.e_LANGUAGE.'/English_front.php' e107::lan('download',false, true); // Loads e_PLUGIN.'download/languages/'.e_LANGUAGE.'/English_front.php'
$bcList = array(
'LAN_dl_19' => 'LAN_CATEGORY',
'LAN_dl_17' => 'LAN_FILES',
"LAN_dl_20" => "LAN_FILES",
"LAN_dl_21" => "LAN_SIZE",
"LAN_dl_22" => "LAN_DATE",
"LAN_dl_23" => "LAN_FILE",
"LAN_dl_24" => "LAN_AUTHOR",
"LAN_dl_25" => "LAN_ASCENDING",
"LAN_dl_26" => "LAN_DESCENDING",
"LAN_dl_27" => "LAN_GO",
"LAN_dl_28" => "LAN_NAME"
);
e107::getLanguage()->bcDefs($bcList);
require_once(e_PLUGIN.'download/handlers/download_class.php'); require_once(e_PLUGIN.'download/handlers/download_class.php');
require_once(e_PLUGIN.'download/handlers/category_class.php'); require_once(e_PLUGIN.'download/handlers/category_class.php');

View File

@@ -370,7 +370,7 @@ class faq
$query = "SELECT f.*,cat.* FROM #faqs AS f LEFT JOIN #faqs_info AS cat ON f.faq_parent = cat.faq_info_id WHERE cat.faq_info_class IN (".USERCLASS_LIST.") ".$insert." ORDER BY cat.faq_info_order, f.".$orderBy." ".$ascdesc." "; $query = "SELECT f.*,cat.* FROM #faqs AS f LEFT JOIN #faqs_info AS cat ON f.faq_parent = cat.faq_info_id WHERE cat.faq_info_class IN (".USERCLASS_LIST.") ".$insert." ORDER BY cat.faq_info_order, f.".$orderBy." ".$ascdesc." ";
if(!$sql->gen($query)) if(!$data = $sql->retrieve($query, true))
{ {
$message = (!empty($srch)) ? "<b>".$srch."</b> was not found in search results. <a class='e-tip' title='Reset' href='".$removeUrl."'>Reset</a>" : LAN_FAQS_NONE_AVAILABLE; $message = (!empty($srch)) ? "<b>".$srch."</b> was not found in search results. <a class='e-tip' title='Reset' href='".$removeUrl."'>Reset</a>" : LAN_FAQS_NONE_AVAILABLE;
return "<div class='alert alert-warning alert-block'>".$message."</div>" ; //TODO LAN return "<div class='alert alert-warning alert-block'>".$message."</div>" ; //TODO LAN
@@ -416,7 +416,7 @@ class faq
} }
while ($rw = $sql->fetch()) foreach ($data as $rw)
{ {
$rw['faq_sef'] = eHelper::title2sef($tp->toText($rw['faq_question']),'dashl'); $rw['faq_sef'] = eHelper::title2sef($tp->toText($rw['faq_question']),'dashl');

View File

@@ -710,8 +710,8 @@ class e107forum
$info['data']['post_id'] = $postId; // Append last inserted ID to data array for passing it to event callbacks. $info['data']['post_id'] = $postId; // Append last inserted ID to data array for passing it to event callbacks.
$triggerData = $info['data'];
e107::getEvent()->trigger('user_forum_post_created', $info); e107::getEvent()->trigger('user_forum_post_created', $triggerData);
ob_start(); // precaution so json doesn't break. ob_start(); // precaution so json doesn't break.
$this->trackEmail($info['data']); $this->trackEmail($info['data']);
@@ -757,8 +757,9 @@ class e107forum
e107::getMessage()->addDebug("Updating Thread with: ".print_a($info,true)); e107::getMessage()->addDebug("Updating Thread with: ".print_a($info,true));
$triggerData = $info['data'];
e107::getEvent()->trigger('user_forum_topic_updated', $info); $triggerData['thread_id'] = $postInfo['post_thread'];
e107::getEvent()->trigger('user_forum_topic_updated', $triggerData);
} }
if(($result || !$updateThread) && $updateForum) if(($result || !$updateThread) && $updateForum)
@@ -824,7 +825,7 @@ class e107forum
if($newThreadId = e107::getDb()->insert('forum_thread', $info)) if($newThreadId = e107::getDb()->insert('forum_thread', $info))
{ {
e107::getEvent()->trigger('user_forum_topic_created', $info);
$postInfo['post_thread'] = $newThreadId; $postInfo['post_thread'] = $newThreadId;
if(!$newPostId = $this->postAdd($postInfo, false)) if(!$newPostId = $this->postAdd($postInfo, false))
@@ -835,6 +836,13 @@ class e107forum
$this->threadMarkAsRead($newThreadId); $this->threadMarkAsRead($newThreadId);
$threadInfo['thread_sef'] = $this->getThreadsef($threadInfo); $threadInfo['thread_sef'] = $this->getThreadsef($threadInfo);
$triggerData = $info['data'];
$triggerData['thread_id'] = $newThreadId;
$triggerData['thread_sef'] = $threadInfo['thread_sef'];
$triggerData['post_id'] = $newPostId;
e107::getEvent()->trigger('user_forum_topic_created', $triggerData);
return array('postid' => $newPostId, 'threadid' => $newThreadId, 'threadsef'=>$threadInfo['thread_sef']); return array('postid' => $newPostId, 'threadid' => $newThreadId, 'threadsef'=>$threadInfo['thread_sef']);
} }
return false; return false;
@@ -902,7 +910,9 @@ class e107forum
e107::getMessage()->addDebug("Thread Update Failed: ".print_a($info,true)); e107::getMessage()->addDebug("Thread Update Failed: ".print_a($info,true));
} }
e107::getEvent()->trigger('user_forum_topic_updated', $info); $triggerData = $threadInfo;
$triggerData['thread_id'] = intval($threadId);
e107::getEvent()->trigger('user_forum_topic_updated', $triggerData);
} }
@@ -919,6 +929,8 @@ class e107forum
e107::getMessage()->addDebug("Post Update Failed: ".print_a($info,true)); e107::getMessage()->addDebug("Post Update Failed: ".print_a($info,true));
} }
$triggerData = $postInfo;
$triggerData['post_id'] = intval($postId);
e107::getEvent()->trigger('user_forum_post_updated', $info); e107::getEvent()->trigger('user_forum_post_updated', $info);
} }

View File

@@ -796,6 +796,13 @@ class forum_post_handler
$postInfo['post_attachments'] = e107::serialize($newValues); $postInfo['post_attachments'] = e107::serialize($newValues);
} }
//Allows directly overriding the method of adding files (or other data) as attachments
if($attachmentsPosted = $this->processAttachmentsPosted())
{
$postInfo['post_attachments'] = $attachmentsPosted;
}
// var_dump($uploadResult); // var_dump($uploadResult);
switch($this->action) switch($this->action)
@@ -1006,6 +1013,12 @@ class forum_post_handler
// $postVals['post_attachments'] = implode(',', $attachments); // $postVals['post_attachments'] = implode(',', $attachments);
} }
//Allows directly overriding the method of adding files (or other data) as attachments
if($attachmentsPosted = $this->processAttachmentsPosted($this->data['post_attachments']))
{
$postVals['post_attachments'] = $attachmentsPosted;
}
$postVals['post_edit_datestamp'] = time(); $postVals['post_edit_datestamp'] = time();
$postVals['post_edit_user'] = USERID; $postVals['post_edit_user'] = USERID;
$postVals['post_entry'] = $_POST['post']; $postVals['post_entry'] = $_POST['post'];
@@ -1072,6 +1085,11 @@ class forum_post_handler
$postVals['post_attachments'] = e107::serialize($newValues); $postVals['post_attachments'] = e107::serialize($newValues);
} }
//Allows directly overriding the method of adding files (or other data) as attachments
if($attachmentsPosted = $this->processAttachmentsPosted($this->data['post_attachments']))
{
$postVals['post_attachments'] = $attachmentsPosted;
}
$this->forumObj->postUpdate($this->data['post_id'], $postVals); $this->forumObj->postUpdate($this->data['post_id'], $postVals);
@@ -1224,6 +1242,31 @@ class forum_post_handler
*/ */
} }
//Allows directly overriding the method of adding files (or other data) as attachments
function processAttachmentsPosted($existingValues = '')
{
if(isset($_POST['post_attachments_json']) && trim($_POST['post_attachments_json']))
{
$postedAttachments = json_decode($_POST['post_attachments_json'], true);
$attachmentsJsonErrors = json_last_error();
if($attachmentsJsonErrors === JSON_ERROR_NONE)
{
if($existingValues)
{
$existingValues = e107::unserialize($existingValues);
return e107::serialize(array_merge_recursive($existingValues,$postedAttachments));
}
else
{
return e107::serialize($postedAttachments);
}
}
}
return false;
}
} }
require_once(HEADERF); require_once(HEADERF);

View File

@@ -474,6 +474,7 @@ foreach ($postList as $postInfo)
$alt = !$alt; $alt = !$alt;
$sc->setScVar('postInfo', $postInfo); $sc->setScVar('postInfo', $postInfo);
$sc->setVars($postInfo); // compatibility
if($postInfo['post_status']) if($postInfo['post_status'])
{ {
@@ -493,6 +494,7 @@ foreach ($postList as $postInfo)
{ {
$postInfo['thread_start'] = true; $postInfo['thread_start'] = true;
$sc->setScVar('postInfo', $postInfo); $sc->setScVar('postInfo', $postInfo);
$sc->setVars($postInfo); // compatibility
$sc->wrapper('forum_viewtopic/thread'); $sc->wrapper('forum_viewtopic/thread');
// $forum_shortcodes = e107::getScBatch('view', 'forum')->setScVar('postInfo', $postInfo)->wrapper('forum/viewtopic'); // $forum_shortcodes = e107::getScBatch('view', 'forum')->setScVar('postInfo', $postInfo)->wrapper('forum/viewtopic');
$forthr = $tp->parseTemplate($FORUMTHREADSTYLE, true, vartrue($sc)) . "\n"; $forthr = $tp->parseTemplate($FORUMTHREADSTYLE, true, vartrue($sc)) . "\n";

View File

@@ -261,6 +261,11 @@ $THREADTOPIC_REPLY = "
"; ";
$js = <<<TMPL
// javascript here.
TMPL;
e107::js('footer-inline', $js);
$FORUM_POST_TEMPLATE['reply'] = ""; $FORUM_POST_TEMPLATE['reply'] = "";

View File

@@ -23,10 +23,12 @@ if(isset($parms['caption'][e_LANGUAGE]))
$limit = vartrue($parms['count'],5); $limit = vartrue($parms['count'],5);
$tp = e107::getParser(); $tp = e107::getParser();
$template = e107::getTemplate('news', 'news_menu', 'carousel'); $template = e107::getTemplate('news', 'news_menu', 'carousel', true, true);
$nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'"; $nobody_regexp = "'(^|,)(".str_replace(",", "|", e_UC_NOBODY).")(,|$)'";
e107::getDebug()->log("News Carousel Menu ".print_a($parms,true));
$query = " $query = "
SELECT n.*, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon, SELECT n.*, nc.category_id, nc.category_name, nc.category_sef, nc.category_icon,
nc.category_meta_keywords, nc.category_meta_description nc.category_meta_keywords, nc.category_meta_description

View File

@@ -38,8 +38,12 @@ if(!empty($parm))
if(!$OTHERNEWS2_STYLE) if(!$OTHERNEWS2_STYLE)
{ {
if(deftrue('BOOTSTRAP')) // v2.x if(deftrue('BOOTSTRAP')) // v2.x
{
if(!defined("OTHERNEWS_COLS"))
{ {
define("OTHERNEWS_COLS",false); define("OTHERNEWS_COLS",false);
}
$template = e107::getTemplate('news', 'news_menu', 'other2'); $template = e107::getTemplate('news', 'news_menu', 'other2');
$OTHERNEWS2_STYLE = $template['item']; $OTHERNEWS2_STYLE = $template['item'];

View File

@@ -50,8 +50,11 @@ if(!empty($parm))
if(!$OTHERNEWS_STYLE) if(!$OTHERNEWS_STYLE)
{ {
if(deftrue('BOOTSTRAP')) // v2.x if(deftrue('BOOTSTRAP')) // v2.x
{
if(!defined("OTHERNEWS_COLS"))
{ {
define("OTHERNEWS_COLS",false); define("OTHERNEWS_COLS",false);
}
$template = e107::getTemplate('news', 'news_menu', 'other'); $template = e107::getTemplate('news', 'news_menu', 'other');
$item_selector = '<div class="btn-group pull-right"><a class="btn btn-mini btn-xs btn-default" href="#otherNews" data-slide="prev"></a> $item_selector = '<div class="btn-group pull-right"><a class="btn btn-mini btn-xs btn-default" href="#otherNews" data-slide="prev"></a>

View File

@@ -1,217 +1,316 @@
<?php <?php
/* /**
* e107 website system * e107 website system
* *
* Copyright (C) 2008-2013 e107 Inc (e107.org) * Copyright (C) 2008-2016 e107 Inc (e107.org)
* Released under the terms and conditions of the * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* *
* Plugin administration - newsfeeds
*
*
*/ */
require_once("../../class2.php");
if (!getperms("P") || !e107::isInstalled('newsfeed')) // Generated e107 Plugin Admin Area
require_once('../../class2.php');
if (!getperms('P') || !e107::isInstalled('newsfeed'))
{ {
e107::redirect('admin'); e107::redirect('admin');
exit; exit;
} }
require_once(e_ADMIN."auth.php"); e107::lan('newsfeed',true);
define('NEWSFEED_LIST_CACHE_TAG', 'nomd5_newsfeeds'); define('NEWSFEED_LIST_CACHE_TAG', 'nomd5_newsfeeds');
define('NEWSFEED_NEWS_CACHE_TAG', 'nomd5_newsfeeds_news_');
class newsfeed_adminArea extends e_admin_dispatcher
{
protected $modes = array(
'main' => array(
'controller' => 'newsfeed_ui',
'path' => null,
'ui' => 'newsfeed_form_ui',
'uipath' => null
),
);
protected $adminMenu = array(
'main/list' => array('caption'=> LAN_MANAGE, 'perm' => 'P'),
'main/create' => array('caption'=> LAN_CREATE, 'perm' => 'P'),
// 'main/custom' => array('caption'=> 'Custom Page', 'perm' => 'P')
);
protected $adminMenuAliases = array(
'main/edit' => 'main/list'
);
protected $menuTitle = LAN_PLUGIN_NEWSFEEDS_NAME;
}
class newsfeed_ui extends e_admin_ui
{
protected $pluginTitle = LAN_PLUGIN_NEWSFEEDS_NAME;
protected $pluginName = 'newsfeed';
// protected $eventName = 'newsfeed-newsfeed'; // remove comment to enable event triggers in admin.
protected $table = 'newsfeed';
protected $pid = 'newsfeed_id';
protected $perPage = 10;
protected $batchDelete = true;
protected $batchCopy = true;
// protected $sortField = 'somefield_order';
// protected $orderStep = 10;
// protected $tabs = array('Tabl 1','Tab 2'); // Use 'tab'=>0 OR 'tab'=>1 in the $fields below to enable.
// protected $listQry = "SELECT * FROM `#tableName` WHERE field != '' "; // Example Custom Query. LEFT JOINS allowed. Should be without any Order or Limit.
protected $listOrder = 'newsfeed_id DESC';
protected $fields = array ( 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ),
'newsfeed_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'newsfeed_name' => array ( 'title' => LAN_TITLE, 'type' => 'text', 'data' => 'str', 'required'=>true, 'width' => 'auto', 'inline' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'newsfeed_url' => array ( 'title' => LAN_URL, 'type' => 'url', 'data' => 'str', 'required'=>true, 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('size'=>'xxlarge'), 'class' => 'left', 'thclass' => 'left', ),
'newsfeed_data' => array ( 'title' => 'Data', 'type' => null, 'data' => false, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'newsfeed_timestamp' => array ( 'title' => 'Timestamp', 'type' => 'hidden', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'newsfeed_description' => array ( 'title' => LAN_DESCRIPTION, 'type' => 'textarea', 'data' => 'str', 'width' => '40%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'newsfeed_image' => array ( 'title' => NFLAN_11, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => LAN_OPTIONAL, 'readParms' => 'thumb=80x80', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
'newsfeed_updateint' => array ( 'title' => NFLAN_18, 'type' => 'text', 'data' => 'int', 'inline'=>true, 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('default'=>3600), 'class' => 'left', 'thclass' => 'left', ),
'newsfeed_active' => array ( 'title' => NFLAN_12, 'type' => 'radio', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => array('default'=>3, 'optArray'=>array(NFLAN_13,NFLAN_14,NFLAN_20,NFLAN_21)), 'class' => 'left', 'thclass' => 'left', ),
'newsfeed_showmenu' => array('title'=>NFLAN_45, 'type'=>'method', 'data'=>false, 'class'=>'center', 'thclass'=>'center' ),
'newsfeed_showmain' => array('title'=>NFLAN_46, 'type'=>'method', 'data'=>false, 'class'=>'center', 'thclass'=>'center'),
'options' => array ( 'title' => LAN_OPTIONS, 'type' => null, 'data' => null, 'width' => '8%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ),
);
protected $fieldpref = array('newsfeed_name', 'newsfeed_url', 'newsfeed_updateint', 'newsfeed_active', 'newsfeed_showmenu', 'newsfeed_showmain');
// protected $preftabs = array('General', 'Other' );
protected $prefs = array(
);
public function init()
{
if($this->getAction() == 'edit' || $this->getAction() == 'create')
{
$this->fields['newsfeed_updateint']['type'] = 'number';
}
// Set drop-down values (if any).
}
// ------- Customize Create --------
public function beforeCreate($new_data)
{
if(isset($new_data['newsfeed_showmenu']))
{
$new_data['newsfeed_image'] = e107::getParser()->toDB($new_data['newsfeed_image'])."::".intval($new_data['newsfeed_showmenu'])."::".intval($new_data['newsfeed_showmain']);
}
$new_data['newsfeed_timestamp'] = 0;
return $new_data;
}
public function afterCreate($new_data, $old_data, $id)
{
// do something
e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG);
e107::getCache()->clear(NEWSFEED_NEWS_CACHE_TAG);
}
public function onCreateError($new_data, $old_data)
{
// do something
}
// ------- Customize Update --------
public function beforeUpdate($new_data, $old_data, $id)
{
if(isset($new_data['newsfeed_showmenu']))
{
$new_data['newsfeed_image'] = e107::getParser()->toDB($new_data['newsfeed_image'])."::".intval($new_data['newsfeed_showmenu'])."::".intval($new_data['newsfeed_showmain']);
}
$new_data['newsfeed_timestamp'] = 0; // reset so the feed data refreshes.
return $new_data;
}
public function afterUpdate($new_data, $old_data, $id)
{
// do something
e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG);
e107::getCache()->clear(NEWSFEED_NEWS_CACHE_TAG);
}
public function onUpdateError($new_data, $old_data, $id)
{
// do something
}
/*
// optional - a custom page.
public function customPage()
{
$text = 'Hello World!';
return $text;
}
*/
}
class newsfeed_form_ui extends e_admin_form_ui
{
// Custom Method/Function
function newsfeed_active($curVal,$mode)
{
$frm = e107::getForm(); $frm = e107::getForm();
$mes = e107::getMessage();
if (e_QUERY) switch($mode)
{ {
list($action, $id) = explode(".", e_QUERY); case 'read': // List Page
$id = intval($id); return $curVal;
} break;
else
{
$action = FALSE;
$id = FALSE;
}
if (isset($_POST['createFeed']) || isset($_POST['updateFeed'])) case 'write': // Edit Page
{ return $frm->text('newsfeed_active',$curVal, 255, 'size=large');
if ($_POST['newsfeed_url'] && $_POST['newsfeed_name']) break;
{
$feed['newsfeed_name'] = $tp->toDB($_POST['newsfeed_name']);
$feed['newsfeed_description'] = $tp->toDB($_POST['newsfeed_description']);
$feed['newsfeed_image'] = $tp->toDB($_POST['newsfeed_image'])."::".intval($_POST['newsfeed_showmenu'])."::".intval($_POST['newsfeed_showmain']);
$feed['newsfeed_url'] = $tp->toDB($_POST['newsfeed_url']);
$feed['newsfeed_active'] = intval($_POST['newsfeed_active']);
$feed['newsfeed_updateint'] = intval($_POST['newsfeed_updateint']);
$feed['newsfeed_data'] = ''; // Start with blank data feed
$feed['newsfeed_timestamp'] = 0; // This should force an immediate update
if (isset($_POST['createFeed'])) case 'filter':
{ case 'batch':
if ($sql->insert('newsfeed',$feed)) return array();
{ break;
$admin_log->logArrayAll('NEWSFD_01', $feed);
$mes->addSuccess(LAN_CREATED);
}
else
{
$mes->addError(LAN_CREATED_FAILED.': '.$sql->mySQLerror);
}
}
elseif (isset($_POST['updateFeed']))
{
$feed['WHERE'] = "newsfeed_id=".intval($_POST['newsfeed_id']);
if($sql->update('newsfeed',$feed))
{
$admin_log->logArrayAll('NEWSFD_02', $feed);
$mes->addSuccess(LAN_UPDATED);
}
else
{
$mes->addInfo(LAN_NO_CHANGE.': '.$sql->mySQLerror);
}
}
e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG); // This should actually clear all the newsfeed data in one go
}
else
{
$mes->addError(LAN_REQUIRED_BLANK);
} }
} }
$ns->tablerender($caption, $mes->render() . $text);
if($action == "delete") function newsfeed_image($curVal,$mode)
{ {
$sql->db_Delete('newsfeed', 'newsfeed_id='.$id); $frm = e107::getForm();
e107::getLog()->add('NEWSFD_03','ID: '.$id,E_LOG_INFORMATIVE,'');
$mes->addSuccess(LAN_DELETED);
}
$ns->tablerender($caption, $mes->render() . $text); switch($mode)
if($headline_total = $sql->db_Select("newsfeed"))
{ {
$nfArray = $sql->rows(); case 'read': // List Page
return $curVal;
break;
$text = " case 'write': // Edit Page
<table class='table table-striped'>
<colgroup>
<col style='width: 5%; text-align: center;' />
<col style='width: 40%;' />
<col style='width: 10%; text-align: center;' />
<col style='width: 25%; text-align: center;' />
<col style='width: 10%; text-align: center;' />
</colgroup>
<thead>
<tr>
<th>".LAN_ID."</th>
<th>".LAN_NAME."</th>
<th>".NFLAN_26."</th>
<th>".NFLAN_12."</th>
<th class='center options'>".LAN_OPTIONS."</th>
</tr>
</thead>\n";
$active = array(NFLAN_13,NFLAN_14,NFLAN_20,NFLAN_21); $tmp = explode('::',$curVal);
foreach($nfArray as $newsfeed) return $frm->text('newsfeed_image',$tmp[0], 255, 'size=large');
{ break;
extract($newsfeed); // FIXME
$text .= " case 'filter':
<tr> case 'batch':
<td>$newsfeed_id</td> return array();
<td><a href='$newsfeed_url' rel='external'>$newsfeed_name</a></td> break;
<td>".($newsfeed_updateint ? $newsfeed_updateint : "3600")."</td>
<td>".$active[$newsfeed_active]."</td>
<td>
<a class='btn btn-default btn-large' href='".e_SELF."?edit.".$newsfeed_id."'>".ADMIN_EDIT_ICON."</a>
<a class='btn btn-default btn-large action delete' href='".e_SELF."?delete.".$newsfeed_id."' rel='no-confirm' title='".LAN_CONFDELETE."'>".ADMIN_DELETE_ICON."</a>
</td>
</tr>";
}
$text .= "</table>";
}
else
{
$mes->addInfo(NFLAN_41);
}
$ns->tablerender(NFLAN_07, $mes->render(). $text);
if($action == "edit")
{
if($sql->select("newsfeed", "*", "newsfeed_id=$id"))
{
$row = $sql->fetch();
extract($row); // FIX
list($newsfeed_image, $newsfeed_showmenu, $newsfeed_showmain) = explode("::", $newsfeed_image);
} }
} }
else
function newsfeed_showmain($curVal,$mode)
{ {
unset($newsfeed_showmenu, $newsfeed_showmain, $newsfeed_name, $newsfeed_url, $newsfeed_image, $newsfeed_description, $newsfeed_updateint, $newsfeed_active); $frm = e107::getForm();
switch($mode)
{
case 'read': // List Page
$data = $this->getController()->getListModel()->get('newsfeed_image');
list($image,$menu,$main) = explode('::',$data);
return intval($main);
break;
case 'write': // Edit Page
$data = $this->getController()->getModel()->get('newsfeed_image');
list($image,$menu,$main) = explode('::',$data);
if(empty($main))
{
$main = 10;
} }
$text = " return $frm->number('newsfeed_showmain',$main, 3);
<form method='post' action='".e_SELF."'>\n break;
<table class='table'>
<colgroup>
<col class='col-label' />
<col style='col-control' />
</colgroup>
<tr>
<td>".LAN_NAME."</td>
<td>".$frm->text('newsfeed_name', $newsfeed_name, '200')."</td>
</tr>
<tr> case 'filter':
<td>".LAN_URL."</td> case 'batch':
<td>".$frm->text('newsfeed_url', $newsfeed_url, '250', 'size=xxlarge')."<span class='field-help'>".NFLAN_10."</span></td> return array();
</tr> break;
<tr> }
<td>".NFLAN_11."</td> }
<td>".$frm->text('newsfeed_image', $newsfeed_image, '200') /* TODO imagepicker? */."<span class='field-help'>".NFLAN_17."</span></td>
</tr>
<tr>
<td>".LAN_DESCRIPTION."</td>
<td>".$frm->text('newsfeed_description', $newsfeed_description, '200')."<span class='field-help'>".NFLAN_37."</span></td>
</tr>
<tr>
<td>".NFLAN_18."</td>
<td>".$frm->number('newsfeed_updateint',($newsfeed_updateint ? $newsfeed_updateint : 3600),5)."<span class='field-help'>".NFLAN_19."</span></td>
</tr>
<tr>
<td>".NFLAN_12."</td>
<td>";
$array = array(NFLAN_13,NFLAN_14,NFLAN_20,NFLAN_21);
$text .=
$frm->radio('newsfeed_active', $array, ($newsfeed_active ? $newsfeed_active : 0), true, NFLAN_22)."
</td>
</tr>
<tr>
<td>".NFLAN_45."</td>
<td>".$frm->number('newsfeed_showmenu', $newsfeed_showmenu ,5)."<span class='field-help'>".NFLAN_47."</span></td>
</tr>
<tr>
<td>".NFLAN_46."</td>
<td>".$frm->number('newsfeed_showmain', $newsfeed_showmain ,5)."<span class='field-help'>".NFLAN_47."</span></td>
</tr>
</table>
<div class='buttons-bar center'>
".$frm->admin_button(($action == "edit" ? "updateFeed" : "createFeed"),($action == "edit" ? LAN_UPDATE : LAN_CREATE),'update')."
</div>
".($action == "edit" ? "<input type='hidden' name='newsfeed_id' value='$newsfeed_id' />" : "")."
</form>
";
$ns->tablerender(NFLAN_09, $mes->render() . $text);
function newsfeed_showmenu($curVal,$mode)
{
$frm = e107::getForm();
switch($mode)
{
case 'read': // List Page
$data = $this->getController()->getListModel()->get('newsfeed_image');
list($image,$menu,$main) = explode('::',$data);
return intval($menu);
break;
case 'write': // Edit Page
$data = $this->getController()->getModel()->get('newsfeed_image');
list($image,$menu,$main) = explode('::',$data);
if(empty($menu))
{
$menu = 10;
}
return $frm->number('newsfeed_showmenu',$menu, 3);
break;
case 'filter':
case 'batch':
return array();
break;
}
}
}
new newsfeed_adminArea();
require_once(e_ADMIN."auth.php");
e107::getAdminUI()->runPage();
require_once(e_ADMIN."footer.php"); require_once(e_ADMIN."footer.php");
?> exit;

View File

@@ -0,0 +1,50 @@
<?php
/*
* e107 Bootstrap CMS
*
* Copyright (C) 2008-2015 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* IMPORTANT: Make sure the redirect script uses the following code to load class2.php:
*
* if (!defined('e107_INIT'))
* {
* require_once("../../class2.php");
* }
*
*/
if (!defined('e107_INIT')) { exit; }
// v2.x Standard - Simple mod-rewrite module.
class newsfeed_url // plugin-folder + '_url'
{
function config()
{
$config = array();
$config['source'] = array(
'alias' => 'newsfeed',
'regex' => '^{alias}/(\d*)/(.*)', // matched against url, and if true, redirected to 'redirect' below.
'sef' => '{alias}/{newsfeed_id}/{newsfeed_sef}', // used by e107::url(); to create a url from the db table.
'redirect' => '{e_PLUGIN}newsfeed/newsfeed.php?id=$1', // file-path of what to load when the regex returns true.
);
$config['index'] = array(
'alias' => 'newsfeed',
'regex' => '^{alias}/?', // matched against url, and if true, redirected to 'redirect' below.
'sef' => '{alias}', // used by e107::url(); to create a url from the db table.
'redirect' => '{e_PLUGIN}newsfeed/newsfeed.php', // file-path of what to load when the regex returns true.
);
return $config;
}
}

View File

@@ -35,16 +35,30 @@ if (!is_object($newsFeed))
{ {
$newsFeed = new newsfeedClass; $newsFeed = new newsfeedClass;
} }
e107::css('inline', "
.newsfeed ul { max-width:100% }
.newsfeed img { max-width:100% }
");
require_once(HEADERF); require_once(HEADERF);
/* get template */ /* get template */
if (file_exists(THEME."newsfeed_template.php")) if(file_exists(THEME."templates/newsfeed/newsfeed_template.php"))
{ {
require_once(THEME."newsfeed_template.php"); include(THEME."templates/newsfeed/newsfeed_template.php");
}
elseif (file_exists(THEME."newsfeed_template.php"))
{
include(THEME."newsfeed_template.php");
} }
else if(!varset($NEWSFEED_LIST_START, FALSE)) else if(!varset($NEWSFEED_LIST_START, FALSE))
{ {
require_once(e_PLUGIN."newsfeed/templates/newsfeed_template.php"); include(e_PLUGIN."newsfeed/templates/newsfeed_template.php");
} }
$action = FALSE; $action = FALSE;
@@ -55,6 +69,12 @@ if(e_QUERY)
$id = intval(varset($qs[1], 0)); $id = intval(varset($qs[1], 0));
} }
if(!empty($_GET['id'])) //v2.x
{
$id = intval($_GET['id']);
$action = 'show';
}
if($action == "show") if($action == "show")
{ {
/* 'show' action - show feed */ /* 'show' action - show feed */
@@ -68,6 +88,7 @@ if($action == "show")
/* no action - display feed list ... */ /* no action - display feed list ... */
$newsFeed->readFeedList(); $newsFeed->readFeedList();
$vars = array();
if (count($newsFeed->feedList)) if (count($newsFeed->feedList))
{ {
$data = ""; $data = "";
@@ -75,10 +96,15 @@ if (count($newsFeed->feedList))
{ {
if (($feed['newsfeed_active'] == 2) || ($feed['newsfeed_active'] == 3)) if (($feed['newsfeed_active'] == 2) || ($feed['newsfeed_active'] == 3))
{ {
$FEEDNAME = "<a href='".e_SELF."?show.{$feed['newsfeed_id']}'>{$feed['newsfeed_name']}</a>";
$FEEDDESCRIPTION = ((!$feed['newsfeed_description'] || $feed['newsfeed_description'] == "default") ? "&nbsp;" : $feed['newsfeed_description']); $feed['newsfeed_sef'] = eHelper::title2sef($feed['newsfeed_name'], 'dashl');
$url = e107::url('newsfeed', 'source', $feed); // e_SELF."?show.{$feed['newsfeed_id']}
$vars['FEEDNAME'] = "<a href='".$url."'>{$feed['newsfeed_name']}</a>";
$vars['FEEDDESCRIPTION'] = ((!$feed['newsfeed_description'] || $feed['newsfeed_description'] == "default") ? "&nbsp;" : $feed['newsfeed_description']);
// $FEEDIMAGE = $feed['newsfeed_image']; // This needs splitting up. Not used ATM anyway, so disable for now // $FEEDIMAGE = $feed['newsfeed_image']; // This needs splitting up. Not used ATM anyway, so disable for now
$data .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_LIST); $data .= $tp->simpleParse($NEWSFEED_LIST, $vars);
} }
} }
} }
@@ -87,4 +113,3 @@ $text = $NEWSFEED_LIST_START . vartrue($data) . $NEWSFEED_LIST_END;
$ns->tablerender(NFLAN_29, $text); $ns->tablerender(NFLAN_29, $text);
require_once(FOOTERF); require_once(FOOTERF);
?>

View File

@@ -47,9 +47,8 @@ class newsfeedClass
var $useCache; // Set if cache is available var $useCache; // Set if cache is available
// Constructor // Constructor
function newsfeedClass() function __construct()
{ {
global $e107;
$this->validFeedList = FALSE; $this->validFeedList = FALSE;
$this->newsList = array(); $this->newsList = array();
$this->feedList = array(); $this->feedList = array();
@@ -57,7 +56,7 @@ class newsfeedClass
$this->lastProcessed = 0; $this->lastProcessed = 0;
$this->truncateCount = 150; // Set a pref for these two later $this->truncateCount = 150; // Set a pref for these two later
$this->truncateMore = '...'; $this->truncateMore = '...';
$this->useCache = $e107->ecache->UserCacheActive; // Have our own local copy - should be faster to access $this->useCache = e107::getCache()->UserCacheActive; // Have our own local copy - should be faster to access
} }
// Ensures the feed list is loaded - uses cache if available // Ensures the feed list is loaded - uses cache if available
@@ -72,12 +71,7 @@ class newsfeedClass
if($this->useCache) // Cache enabled - try to read from that first if($this->useCache) // Cache enabled - try to read from that first
{ {
$eArrayStorage = e107::getArrayStorage(); if (!$force && $temp = e107::getCache()->retrieve(NEWSFEED_LIST_CACHE_TAG))
global $e107;
if (!$force && $temp = $e107->ecache->retrieve(NEWSFEED_LIST_CACHE_TAG))
{ {
$this->feedList = e107::unserialize($temp); $this->feedList = e107::unserialize($temp);
return; return;
@@ -97,7 +91,7 @@ class newsfeedClass
{ {
$nfID = $row['newsfeed_id']; $nfID = $row['newsfeed_id'];
if (isset($row['newsfeed_data'])) if (!empty($row['newsfeed_data']))
{ {
$this->newsList[$nfID]['newsfeed_data'] = $row['newsfeed_data']; // Pull out the actual news - might as well since we're here $this->newsList[$nfID]['newsfeed_data'] = $row['newsfeed_data']; // Pull out the actual news - might as well since we're here
$this->newsList[$nfID]['newsfeed_timestamp'] = $row['newsfeed_timestamp']; $this->newsList[$nfID]['newsfeed_timestamp'] = $row['newsfeed_timestamp'];
@@ -110,8 +104,8 @@ class newsfeedClass
$this->validFeedList = TRUE; $this->validFeedList = TRUE;
} }
if ($this->useCache) if ($this->useCache) // Cache enabled - we need to save some updated info
{ // Cache enabled - we need to save some updated info {
$temp = e107::serialize($this->feedList, FALSE); $temp = e107::serialize($this->feedList, FALSE);
e107::getCache()->set(NEWSFEED_LIST_CACHE_TAG,$temp); e107::getCache()->set(NEWSFEED_LIST_CACHE_TAG,$temp);
} }
@@ -121,11 +115,8 @@ class newsfeedClass
// Returns the info for a single feed - from cache or memory as appropriate. If time expired, updates the feed. // Returns the info for a single feed - from cache or memory as appropriate. If time expired, updates the feed.
function getFeed($feedID, $force = FALSE) function getFeed($feedID, $force = FALSE)
{ {
global $e107, $admin_log;
$tp = e107::getParser(); $tp = e107::getParser();
$sql = e107::getDb(); $sql = e107::getDb();
$eArrayStorage = e107::getArrayStorage();
$this->readFeedList(); // Make sure we've got the feed data. $this->readFeedList(); // Make sure we've got the feed data.
@@ -135,19 +126,19 @@ class newsfeedClass
return FALSE; return FALSE;
} }
if(strpos($this->newsList[$feedID]['newsfeed_data'],'MagpieRSS')) //BC Fix to update newsfeed_data from v1 to v2 spec. if(empty($this->newsList[$feedID]['newsfeed_timestamp']) || empty($this->newsList[$feedID]['newsfeed_data']) || strpos($this->newsList[$feedID]['newsfeed_data'],'MagpieRSS')) //BC Fix to update newsfeed_data from v1 to v2 spec.
{ {
$force = true; $force = true;
} }
if ($force || !isset($this->newsList[$feedID]['newsfeed_data']) || !$this->newsList[$feedID]['newsfeed_data']) if($force) // No data already in memory
{ // No data already in memory {
if ($force || !($this->newsList[$feedID]['newsfeed_data'] = $e107->ecache->retrieve(NEWSFEED_NEWS_CACHE_TAG.$feedID, $this->feedList[$feedID]['newsfeed_updateint']/60))) if ($force || !($this->newsList[$feedID]['newsfeed_data'] = e107::getCache()->retrieve(NEWSFEED_NEWS_CACHE_TAG.$feedID, $this->feedList[$feedID]['newsfeed_updateint']/60)))
{ // Need to re-read from source - either no cached data yet, or cache expired { // Need to re-read from source - either no cached data yet, or cache expired
if (NEWSFEED_DEBUG) if (NEWSFEED_DEBUG)
{ {
$admin_log->e_log_event(10,debug_backtrace(),"DEBUG","Newsfeed update","Refresh item: ".$feedID,FALSE,LOG_TO_ROLLING); e107::getLog()->e_log_event(10,debug_backtrace(),"DEBUG","Newsfeed update","Refresh item: ".$feedID,FALSE,LOG_TO_ROLLING);
} }
require_once(e_HANDLER.'xml_class.php'); require_once(e_HANDLER.'xml_class.php');
@@ -195,7 +186,7 @@ class newsfeedClass
$dbData['newsfeed_description'] = $temp['newsfeed_description']; $dbData['newsfeed_description'] = $temp['newsfeed_description'];
if ($this->useCache) if ($this->useCache)
{ {
$e107->ecache->clear(NEWSFEED_LIST_CACHE_TAG); // Clear the newsfeed cache so its re-read next time e107::getCache()->clear(NEWSFEED_LIST_CACHE_TAG); // Clear the newsfeed cache so its re-read next time
} }
} }
} }
@@ -206,10 +197,10 @@ class newsfeedClass
} }
else else
{ {
$temp['newsfeed_image_link'] = "<img src='".$this->feedList[$feedID]['newsfeed_image']."' alt='' />"; $temp['newsfeed_image_link'] = !empty($newsfeed_image) ? "<img src='".$newsfeed_image."' alt='' />" : '';
} }
$serializedArray = $eArrayStorage->WriteArray($temp, FALSE); $serializedArray = e107::serialize($temp, false);
$now = time(); $now = time();
$this->newsList[$feedID]['newsfeed_data'] = $serializedArray; $this->newsList[$feedID]['newsfeed_data'] = $serializedArray;
@@ -217,17 +208,20 @@ class newsfeedClass
if ($this->useCache) if ($this->useCache)
{ {
$e107->ecache->set(NEWSFEED_NEWS_CACHE_TAG.$feedID,$serializedArray); e107::getCache()->set(NEWSFEED_NEWS_CACHE_TAG.$feedID, $serializedArray);
} }
else else
{ {
$dbData['newsfeed_data'] =addslashes($serializedArray); $dbData['newsfeed_data'] = $serializedArray;
$dbData['newsfeed_timestamp'] = $now; $dbData['newsfeed_timestamp'] = $now;
} }
if (count($dbData)) // Only write the feed data to DB if not using cache. Write description if changed if (count($dbData)) // Only write the feed data to DB if not using cache. Write description if changed
{ {
if(FALSE === $sql->db_UpdateArray('newsfeed', $dbData, " WHERE newsfeed_id=".$feedID))
$dbData['WHERE'] = "newsfeed_id=".$feedID;
if(FALSE === $sql->update('newsfeed', $dbData))
{ {
if (NEWSFEED_DEBUG) echo NFLAN_48."<br /><br />".var_dump($dbData); if (NEWSFEED_DEBUG) echo NFLAN_48."<br /><br />".var_dump($dbData);
} }
@@ -254,7 +248,6 @@ class newsfeedClass
{ {
$tp = e107::getParser(); $tp = e107::getParser();
$sql = e107::getDb();
global $NEWSFEED_MAIN_START, $NEWSFEED_MAIN, $NEWSFEED_MAIN_END; global $NEWSFEED_MAIN_START, $NEWSFEED_MAIN, $NEWSFEED_MAIN_END;
global $NEWSFEED_MENU_START, $NEWSFEED_MENU, $NEWSFEED_MENU_END; global $NEWSFEED_MENU_START, $NEWSFEED_MENU, $NEWSFEED_MENU_END;
@@ -272,7 +265,12 @@ class newsfeedClass
$this->readFeedList(); // Make sure we've got all the news feeds loaded $this->readFeedList(); // Make sure we've got all the news feeds loaded
/* get template */ /* get template */
if (file_exists(THEME."newsfeed_menu_template.php"))
if(file_exists(THEME."templates/newsfeed/newsfeed_menu_template.php")) //v2.x
{
include(THEME."templates/newsfeed/newsfeed_menu_template.php");
}
elseif(file_exists(THEME."newsfeed_menu_template.php")) //v1.x
{ {
include(THEME."newsfeed_menu_template.php"); include(THEME."newsfeed_menu_template.php");
} }
@@ -281,6 +279,8 @@ class newsfeedClass
include(e_PLUGIN."newsfeed/templates/newsfeed_menu_template.php"); include(e_PLUGIN."newsfeed/templates/newsfeed_menu_template.php");
} }
$vars = array();
foreach($this->feedList as $nfID => $feed) foreach($this->feedList as $nfID => $feed)
{ {
if (($filter == 0) || ($filter == $feed['newsfeed_id'])) if (($filter == 0) || ($filter == $feed['newsfeed_id']))
@@ -292,10 +292,10 @@ class newsfeedClass
$numtoshow = intval($where == 'main' ? $newsfeed_showmain : $newsfeed_showmenu); $numtoshow = intval($where == 'main' ? $newsfeed_showmain : $newsfeed_showmenu);
$numtoshow = ($numtoshow > 0 ? $numtoshow : 999); $numtoshow = ($numtoshow > 0 ? $numtoshow : 999);
$FEEDNAME = "<a href='".e_SELF."?show.{$feed['newsfeed_id']}'>".$tp->toHtml($feed['newsfeed_name'],false,'TITLE')."</a>"; $vars['FEEDNAME'] = "<a href='".e_SELF."?show.{$feed['newsfeed_id']}'>".$tp->toHtml($feed['newsfeed_name'],false,'TITLE')."</a>";
$FEEDDESCRIPTION = $feed['newsfeed_description']; $vars['FEEDDESCRIPTION'] = $feed['newsfeed_description'];
$FEEDIMAGE = $rss['newsfeed_image_link']; $vars['FEEDIMAGE'] = $rss['newsfeed_image_link'];
$FEEDLANGUAGE = $rss['channel']['language']; $vars['FEEDLANGUAGE'] = $rss['channel']['language'];
if($rss['channel']['lastbuilddate']) if($rss['channel']['lastbuilddate'])
{ {
@@ -310,18 +310,18 @@ class newsfeedClass
$pubbed = NFLAN_34; $pubbed = NFLAN_34;
} }
$FEEDLASTBUILDDATE = NFLAN_33.$pubbed; $vars['FEEDLASTBUILDDATE'] = NFLAN_33.$pubbed;
$FEEDCOPYRIGHT = $tp -> toHTML(vartrue($rss['channel']['copyright']), FALSE); $vars['FEEDCOPYRIGHT'] = $tp -> toHTML(vartrue($rss['channel']['copyright']), FALSE);
$FEEDTITLE = "<a href='".$rss['channel']['link']."' rel='external'>".vartrue($rss['channel']['title'])."</a>"; $vars['FEEDTITLE'] = "<a href='".$rss['channel']['link']."' rel='external'>".vartrue($rss['channel']['title'])."</a>";
$FEEDLINK = $rss['channel']['link']; $vars['FEEDLINK'] = $rss['channel']['link'];
if($feed['newsfeed_active'] == 2 or $feed['newsfeed_active'] == 3) if($feed['newsfeed_active'] == 2 or $feed['newsfeed_active'] == 3)
{ {
$LINKTOMAIN = "<a href='".e_PLUGIN."newsfeed/newsfeed.php?show.".$feed['newsfeed_id']."'>".NFLAN_39."</a>"; $vars['LINKTOMAIN'] = "<a href='".e_PLUGIN."newsfeed/newsfeed.php?show.".$feed['newsfeed_id']."'>".NFLAN_39."</a>";
} }
else else
{ {
$LINKTOMAIN = ""; $vars['LINKTOMAIN'] = "";
} }
$data = ""; $data = "";
@@ -332,42 +332,43 @@ class newsfeedClass
{ {
$item = $rss['items'][$i]; $item = $rss['items'][$i];
$FEEDITEMLINK = "<a href='".$item['link']."' rel='external'>".$tp -> toHTML($item['title'], FALSE)."</a>\n"; $vars['FEEDITEMLINK'] = "<a href='".$item['link']."' rel='external'>".$tp -> toHTML($item['title'], FALSE)."</a>\n";
$FEEDITEMLINK = str_replace('&', '&amp;', $FEEDITEMLINK); $vars['FEEDITEMLINK'] = str_replace('&', '&amp;', $vars['FEEDITEMLINK']);
$feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", strip_tags($item['description'])); $feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", strip_tags($item['description']));
$FEEDITEMCREATOR = $tp -> toHTML(vartrue($item['author']), FALSE); $vars['FEEDITEMCREATOR'] = $tp -> toHTML(vartrue($item['author']), FALSE);
if ($where == 'main') if ($where == 'main')
{ {
if($NEWSFEED_COLLAPSE) if(!empty($NEWSFEED_COLLAPSE))
{ {
$FEEDITEMLINK = "<a href='#' onclick='expandit(this)'>".$tp -> toHTML($item['title'], FALSE)."</a> $vars['FEEDITEMLINK'] = "<a href='#' onclick='expandit(this)'>".$tp -> toHTML($item['title'], FALSE)."</a>
<div style='display:none' > <div style='display:none' >
"; ";
$FEEDITEMTEXT = preg_replace("/&#091;.*]/", "", $tp -> toHTML($item['description'], FALSE))."
$vars['FEEDITEMTEXT'] = preg_replace("/&#091;.*]/", "", $tp -> toHTML($item['description'], FALSE))."
<br /><br /><a href='".$item['link']."' rel='external'>".NFLAN_44."</a><br /><br /> <br /><br /><a href='".$item['link']."' rel='external'>".NFLAN_44."</a><br /><br />
</div>"; </div>";
} }
else else
{ {
$FEEDITEMLINK = "<a href='".$item['link']."' rel='external'>".$tp -> toHTML($item['title'], FALSE)."</a>\n"; $vars['FEEDITEMLINK'] = "<a href='".$item['link']."' rel='external'>".$tp -> toHTML($item['title'], FALSE)."</a>\n";
$FEEDITEMLINK = str_replace('&', '&amp;', $FEEDITEMLINK); $vars['FEEDITEMLINK'] = str_replace('&', '&amp;', $vars['FEEDITEMLINK']);
$feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", $item['description']); $feeditemtext = preg_replace("#\[[a-z0-9=]+\]|\[\/[a-z]+\]|\{[A-Z_]+\}#si", "", $item['description']);
$FEEDITEMTEXT = $tp -> toHTML($feeditemtext, FALSE)."\n"; $vars['FEEDITEMTEXT'] = $tp -> toHTML($feeditemtext, FALSE)."\n";
} }
$data .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MAIN); $data .= $tp->simpleParse( $NEWSFEED_MAIN, $vars);
} }
else else
{ {
if ($this->truncateCount) if ($this->truncateCount)
{ {
$FEEDITEMTEXT = $tp->text_truncate($feeditemtext, $this->truncateCount, $this->truncateMore); $vars['FEEDITEMTEXT'] = $tp->text_truncate($feeditemtext, $this->truncateCount, $this->truncateMore);
} }
else else
{ {
$FEEDITEMTEXT = ''; // Might just want title $vars['FEEDITEMTEXT'] = ''; // Might just want title
} }
$data .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MENU); $data .= $tp->simpleParse($NEWSFEED_MENU, $vars);
} }
$i++; $i++;
} }
@@ -376,22 +377,24 @@ class newsfeedClass
if ($where == 'main') if ($where == 'main')
{ {
$BACKLINK = "<a href='".e_SELF."'>".NFLAN_31."</a>"; $vars['BACKLINK'] = "<a href='".e_SELF."'>".NFLAN_31."</a>";
$text = preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MAIN_START).$data.preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MAIN_END); $text = $tp->simpleParse($NEWSFEED_MAIN_START, $vars).$data.$tp->simpleParse( $NEWSFEED_MAIN_END, $vars);
} }
else else
{ {
$text .= preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MENU_START) . $data . preg_replace("/\{(.*?)\}/e", '$\1', $NEWSFEED_MENU_END); $text .= $tp->simpleParse($NEWSFEED_MENU_START, $vars) . $data . $tp->simpleParse($NEWSFEED_MENU_END, $vars);
} }
//TODO Move the $vars into their own shortcode class and change simpleParse to parseTemplate();
} }
if($which == 'all') if($which == 'all')
{ {
$ret['title'] = $NEWSFEED_MENU_CAPTION; $ret['title'] = (!empty($NEWSFEED_MENU_CAPTION)) ? $NEWSFEED_MENU_CAPTION : '';
} }
else else
{ {
$ret['title'] = $feed['newsfeed_name']." ".$NEWSFEED_MAIN_CAPTION; $ret['title'] = $feed['newsfeed_name']." ".varset($NEWSFEED_MAIN_CAPTION);
} }
$ret['text'] = $text; $ret['text'] = $text;

View File

@@ -8,8 +8,6 @@
<link url='admin_config.php' description='Configure Newsfeeds' icon='images/newsfeed_32.png' iconSmall='images/newsfeed_16.png' primary='true' >Configure Newsfeeds</link> <link url='admin_config.php' description='Configure Newsfeeds' icon='images/newsfeed_32.png' iconSmall='images/newsfeed_16.png' primary='true' >Configure Newsfeeds</link>
</adminLinks> </adminLinks>
<siteLinks> <siteLinks>
<link url="{e_PLUGIN}newsfeed/newsfeed.php" >Newsfeeds</link> <link url="{e_PLUGIN}newsfeed/newsfeed.php" sef="index" >LAN_PLUGIN_NEWSFEEDS_NAME</link>
</siteLinks> </siteLinks>
<pluginPrefs>
</pluginPrefs>
</e107Plugin> </e107Plugin>

View File

@@ -20,7 +20,7 @@ if (!defined('e107_INIT')) { exit; }
$NEWSFEED_MAIN_CAPTION = NFLAN_38; $NEWSFEED_MAIN_CAPTION = NFLAN_38;
$NEWSFEED_LIST_START = " $NEWSFEED_LIST_START = "
<table style='width: 100%;' class='table fborder'>\n"; <table style='width: 100%;' class='newsfeed-list table fborder'>\n";
$NEWSFEED_LIST = " $NEWSFEED_LIST = "
<tr> <tr>
@@ -32,16 +32,16 @@ $NEWSFEED_LIST_END = "
</table>\n"; </table>\n";
$NEWSFEED_MAIN_START = " $NEWSFEED_MAIN_START = "
<table style='width: 100%;' class='table fborder'> <table style='width: 100%;' class='newsfeed table fborder'>
<tr> <tr>
<td class='forumheader'>{FEEDIMAGE} {FEEDTITLE}</td> <td class='forumheader'><h3>{FEEDIMAGE} {FEEDTITLE}</h3></td>
</tr> </tr>
<tr> <tr>
<td class='forumheader3'> <td class='forumheader3'>
<ul>\n"; <ul>\n";
$NEWSFEED_MAIN = " $NEWSFEED_MAIN = "
<li><b>{FEEDITEMLINK}</b> <span class='smalltext'>{FEEDITEMCREATOR}</span><br />{FEEDITEMTEXT}<br /><br /></li>\n"; <li><h4>{FEEDITEMLINK}</h4><small class='smalltext'>{FEEDITEMCREATOR}</small><div>{FEEDITEMTEXT}</div></li>\n";
$NEWSFEED_MAIN_END = " $NEWSFEED_MAIN_END = "

View File

@@ -35,6 +35,7 @@ class pm_admin extends e_admin_dispatcher
'ui' => 'private_msg_form_ui', 'ui' => 'private_msg_form_ui',
'uipath' => null 'uipath' => null
), ),
/* /*
'block' => array( 'block' => array(
'controller' => 'private_msg_block_ui', 'controller' => 'private_msg_block_ui',
@@ -52,6 +53,7 @@ class pm_admin extends e_admin_dispatcher
'main/limits' => array('caption'=> ADLAN_PM_55, 'perm' => 'P'), 'main/limits' => array('caption'=> ADLAN_PM_55, 'perm' => 'P'),
'main/maint' => array('caption'=> ADLAN_PM_59, 'perm' => 'P'), 'main/maint' => array('caption'=> ADLAN_PM_59, 'perm' => 'P'),
'main/null' => array('divider'=> true), 'main/null' => array('divider'=> true),
'inbox/list' => array('caption'=> "Inbox", 'perm' => 'P'), 'inbox/list' => array('caption'=> "Inbox", 'perm' => 'P'),
'outbox/list' => array('caption'=> "Outbox", 'perm' => 'P'), 'outbox/list' => array('caption'=> "Outbox", 'perm' => 'P'),
@@ -71,6 +73,17 @@ class pm_admin extends e_admin_dispatcher
); );
protected $menuTitle = LAN_PLUGIN_PM_NAME; protected $menuTitle = LAN_PLUGIN_PM_NAME;
function init()
{
if(e_DEBUG == true)
{
$this->adminMenu['main/null2'] = array('divider'=> true);
$this->adminMenu['main/list'] = array('caption'=> "Log", 'perm' => 'P');
}
}
} }
@@ -129,7 +142,7 @@ class private_msg_ui extends e_admin_ui
'attach_size' => array('title'=> ADLAN_PM_28, 'tab'=>1, 'type' => 'number', 'data' => 'int', 'help'=>'', 'writeParms'=>'tdClassRight=form-inline&post=Kb'), 'attach_size' => array('title'=> ADLAN_PM_28, 'tab'=>1, 'type' => 'number', 'data' => 'int', 'help'=>'', 'writeParms'=>'tdClassRight=form-inline&post=Kb'),
'pm_max_send' => array('title'=> ADLAN_PM_81, 'tab'=>1, 'type' => 'number', 'data' => 'int', 'help'=>''), 'pm_max_send' => array('title'=> ADLAN_PM_81, 'tab'=>1, 'type' => 'number', 'data' => 'int', 'help'=>''),
'perpage' => array('title'=> ADLAN_PM_24, 'tab'=>0, 'type' => 'number', 'data' => 'int', 'help'=>''), 'perpage' => array('title'=> ADLAN_PM_24, 'tab'=>0, 'type' => 'number', 'data' => 'int', 'help'=>''),
'maxlength' => array('title'=> ADLAN_PM_84, 'tab'=>1, 'type' => 'number', 'data' => 'int', 'help'=>ADLAN_PM_85, 'writeParms'=>array('post'=>'chars.')),
); );
@@ -831,6 +844,15 @@ class private_msg_ui extends e_admin_ui
$this->fields['options']['readParms'] = 'editClass='.e_UC_NOBODY; $this->fields['options']['readParms'] = 'editClass='.e_UC_NOBODY;
} }
if($this->getMode() == 'main')
{
$this->listQry = 'SELECT p.*, u.user_name, f.user_name AS fromuser FROM #private_msg AS p LEFT JOIN #user AS u ON u.user_id = p.pm_to
LEFT JOIN #user as f on f.user_id = p.pm_from WHERE 1 ';
// $this->fields['pm_from']['nolist'] = true;
$this->fields['options']['readParms'] = 'editClass='.e_UC_NOBODY;
$this->perPage = 20;
}
if($this->getAction() == 'create') if($this->getAction() == 'create')
{ {
$this->fields['pm_to']['writeParms']['default'] = 99999999; $this->fields['pm_to']['writeParms']['default'] = 99999999;

View File

@@ -75,8 +75,10 @@ class pm_shortcodes extends e_shortcode
} }
/**
* @param int $parm - User ID.
* @return null|string
*/
function sc_sendpm($parm='') function sc_sendpm($parm='')
{ {
@@ -86,8 +88,12 @@ class pm_shortcodes extends e_shortcode
$url = e107::url('pm','index').'?send.'.$parm; $url = e107::url('pm','index').'?send.'.$parm;
require_once(e_PLUGIN."pm/pm_class.php");
if(check_class($pm_prefs['pm_class'])) $pm = new private_message;
if(check_class($pm_prefs['pm_class']) && $pm->canSendTo($parm)) // check $this->pmPrefs['send_to_class'].
{ {
if(deftrue('FONTAWESOME') && deftrue('BOOTSTRAP')) if(deftrue('FONTAWESOME') && deftrue('BOOTSTRAP'))
{ {

View File

@@ -86,4 +86,7 @@ define("LAN_PM_108", "Message sent on: ");
define("LAN_PM_109", "New Message(s)"); define("LAN_PM_109", "New Message(s)");
define("LAN_PM_111", "Read"); define("LAN_PM_111", "Read");
define("LAN_PM_112", "User(s)"); define("LAN_PM_112", "User(s)");
define("LAN_PM_113", "Read Message");
define("LAN_PM_114", "You do not have access to send to this user.");
?> ?>

View File

@@ -76,6 +76,8 @@ define("ADLAN_PM_80", "Preference formats updated");
define("ADLAN_PM_81", "Maximum number of PMs to send immediately"); define("ADLAN_PM_81", "Maximum number of PMs to send immediately");
define("ADLAN_PM_82", "If sending more than this, they are added to a queue and sent out using the cron task"); define("ADLAN_PM_82", "If sending more than this, they are added to a queue and sent out using the cron task");
define("ADLAN_PM_83", "Users may only send messages to users in this class"); define("ADLAN_PM_83", "Users may only send messages to users in this class");
define("ADLAN_PM_84", "Maximum message length");
define("ADLAN_PM_85", "0 = unlimited");
?> ?>

View File

@@ -148,8 +148,16 @@ class pm_extended extends private_message
$to_uid = $pm_info['pm_from']; $to_uid = $pm_info['pm_from'];
} }
if(!empty($to_uid)) if(!empty($to_uid))
{ {
if($this->canSendTo($to_uid) == false)
{
return "<div class='alert alert-danger'>".LAN_PM_114."</div>";// sending to this user is not permitted.
}
$sql2 = e107::getDb('sql2'); $sql2 = e107::getDb('sql2');
if($sql2->select('user', 'user_name', 'user_id = '.intval($to_uid))) //TODO add a check for userclass. if($sql2->select('user', 'user_name', 'user_id = '.intval($to_uid))) //TODO add a check for userclass.
{ {

View File

@@ -35,7 +35,8 @@ class private_message
public function __construct($prefs=null) public function __construct($prefs=null)
{ {
$this->e107 = e107::getInstance(); $this->e107 = e107::getInstance();
$this->pmPrefs = $prefs; } $this->pmPrefs = e107::pref('pm');
}
/** /**
@@ -262,6 +263,10 @@ class private_message
else else
{ // Sending to a single person { // Sending to a single person
$info['pm_to'] = intval($vars['to_info']['user_id']); // Sending to a single user now $info['pm_to'] = intval($vars['to_info']['user_id']); // Sending to a single user now
if($pmid = $sql->insert('private_msg', $info)) if($pmid = $sql->insert('private_msg', $info))
{ {
$info['pm_id'] = $pmid; $info['pm_id'] = $pmid;
@@ -272,6 +277,7 @@ class private_message
if(check_class($this->pmPrefs['notify_class'], null, $vars['to_info']['user_id'])) if(check_class($this->pmPrefs['notify_class'], null, $vars['to_info']['user_id']))
{ {
set_time_limit(20); set_time_limit(20);
$vars['pm_sent'] = $timestamp;
$this->pm_send_notify($vars['to_info']['user_id'], $vars, $pmid, count($a_list)); $this->pm_send_notify($vars['to_info']['user_id'], $vars, $pmid, count($a_list));
} }
$ret .= LAN_PM_40.": {$vars['to_info']['user_name']}<br />"; $ret .= LAN_PM_40.": {$vars['to_info']['user_name']}<br />";
@@ -407,7 +413,8 @@ class private_message
$data['PM_DATE'] = e107::getParser()->toDate($pmInfo['pm_sent'], 'long'); $data['PM_DATE'] = e107::getParser()->toDate($pmInfo['pm_sent'], 'long');
$data['SITENAME'] = SITENAME; $data['SITENAME'] = SITENAME;
$data['USERNAME'] = USERNAME; $data['USERNAME'] = USERNAME;
$data['PM_URL'] = "<a href='".$url."'>".$url."</a>";// e107::url('pm','index', null, array('mode'=>'full')).'?show.'.$pmid; $data['PM_URL'] = $url;// e107::url('pm','index', null, array('mode'=>'full')).'?show.'.$pmid;
$data['PM_BUTTON'] = "<a class='btn btn-primary' href='".$url."'>".LAN_PM_113."</a>";// e107::url('pm','index', null, array('mode'=>'full')).'?show.'.$pmid;
$text = e107::getParser()->simpleParse($template, $data); $text = e107::getParser()->simpleParse($template, $data);
@@ -434,8 +441,7 @@ class private_message
* Send PM read receipt * Send PM read receipt
* *
* @param array $pmInfo - PM details * @param array $pmInfo - PM details
* * @return boolean
* @return none
*/ */
function pm_send_receipt($pmInfo) //TODO Add Template and combine with method above.. function pm_send_receipt($pmInfo) //TODO Add Template and combine with method above..
{ {
@@ -449,15 +455,19 @@ class private_message
$txt .= LAN_PM_103.$pmInfo['pm_subject']."\n"; $txt .= LAN_PM_103.$pmInfo['pm_subject']."\n";
$txt .= LAN_PM_105."\n".$pmlink."\n"; $txt .= LAN_PM_105."\n".$pmlink."\n";
sendemail($pmInfo['from_email'], $subject, $txt, $pmInfo['from_name']); if(sendemail($pmInfo['from_email'], $subject, $txt, $pmInfo['from_name']))
{
return true;
}
return false;
} }
/** /**
* Get list of users blocked from sending to a specific user ID. * Get list of users blocked from sending to a specific user ID.
* *
* @param integer $to - user ID * @param int|mixed $to - user ID
*
* @return array of blocked users as user IDs * @return array of blocked users as user IDs
*/ */
function block_get($to = USERID) function block_get($to = USERID)
@@ -629,6 +639,7 @@ class private_message
function get_users_inclass($class) function get_users_inclass($class)
{ {
$sql = e107::getDb(); $sql = e107::getDb();
if($class == e_UC_MEMBER) if($class == e_UC_MEMBER)
{ {
$qry = "SELECT user_id, user_name, user_email, user_class FROM `#user` WHERE 1"; $qry = "SELECT user_id, user_name, user_email, user_class FROM `#user` WHERE 1";
@@ -642,7 +653,9 @@ class private_message
$regex = "(^|,)(".e107::getParser()->toDB($class).")(,|$)"; $regex = "(^|,)(".e107::getParser()->toDB($class).")(,|$)";
$qry = "SELECT user_id, user_name, user_email, user_class FROM `#user` WHERE user_class REGEXP '{$regex}'"; $qry = "SELECT user_id, user_name, user_email, user_class FROM `#user` WHERE user_class REGEXP '{$regex}'";
} }
if($sql->gen($qry))
if(!empty($qry) && $sql->gen($qry))
{ {
$ret = $sql->db_getList(); $ret = $sql->db_getList();
return $ret; return $ret;
@@ -651,6 +664,37 @@ class private_message
} }
/**
* Check permission to send a PM to someone.
* @param int $uid user_id of the person to send to
* @return bool
*/
function canSendTo($uid)
{
if(empty($uid))
{
return false;
}
$user = e107::user($uid);
$uclass = explode(",", $user['user_class']);
if($this->pmPrefs['send_to_class'] == 'matchclass')
{
$tmp = explode(",", USERCLASS);
$result = array_intersect($uclass, $tmp);
return !empty($result);
}
return in_array($this->pmPrefs['send_to_class'], $uclass);
}
/** /**
* Get inbox - up to $limit messages from $from * Get inbox - up to $limit messages from $from
* *

View File

@@ -170,8 +170,7 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
if(check_class($this->pmPrefs['multi_class'])) if(check_class($this->pmPrefs['multi_class']))
{ {
$selectize = array('maxItems'=>10); $ret = e107::getForm()->userpicker('pm_to', null, array('limit'=>10));
$ret = e107::getForm()->userpicker('pm_to', null, null, null, array('selectize'=>$selectize));
} }
else else
{ {
@@ -246,6 +245,9 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
public function sc_pm_form_message() public function sc_pm_form_message()
{ {
$value = ''; $value = '';
$maxlength = '';
$placeholder = '';
if(vartrue($this->var['pm_text'])) if(vartrue($this->var['pm_text']))
{ {
if(isset($_POST['quote'])) if(isset($_POST['quote']))
@@ -254,7 +256,16 @@ if(!class_exists('plugin_pm_pm_shortcodes'))
$value = "\n\n\n\n\n\n\n[quote{$t}={$this->var['from_name']}]\n".trim($this->var['pm_text'])."[/quote{$t}]"; $value = "\n\n\n\n\n\n\n[quote{$t}={$this->var['from_name']}]\n".trim($this->var['pm_text'])."[/quote{$t}]";
} }
} }
return "<textarea class='tbox form-control' name='pm_message' cols='60' rows='10' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'>{$value}</textarea>";
if(!empty($this->pmPrefs['maxlength']))
{
$length = intval($this->pmPrefs['maxlength']);
$maxlength = "maxlength=".$length;
$placeholder = "placeholder='Max. ".$length." chars.'"; // TODO LAN
}
return "<textarea class='tbox form-control' ".$placeholder." name='pm_message' cols='60' rows='10' ".$maxlength." onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'>{$value}</textarea>";
} }

View File

@@ -276,10 +276,9 @@ $PM_NOTIFY =
<tr><td>".LAN_PM_103."</td><td>{PM_SUBJECT}</td></tr> <tr><td>".LAN_PM_103."</td><td>{PM_SUBJECT}</td></tr>
<tr><td>".LAN_PM_108."</td><td>{PM_DATE}</td></tr> <tr><td>".LAN_PM_108."</td><td>{PM_DATE}</td></tr>
<tr><td>".LAN_PM_104."</td><td>{PM_ATTACHMENTS}</td></tr> <tr><td>".LAN_PM_104."</td><td>{PM_ATTACHMENTS}</td></tr>
</table>
</table><br /> <table class='table'><tr><td class='text-center'><br />
<div>".LAN_PM_105.": {PM_URL}</div> <a class='btn btn-primary btn-lg' href='{PM_URL}'>".LAN_PM_113."</a></td></tr>
</div> </table>
"; ";
?>

View File

@@ -41,14 +41,23 @@ class poll
function remove_poll_cookies() function remove_poll_cookies()
{ {
$arr_polls_cookies = array(); $arr_polls_cookies = array();
if(!empty($_COOKIE))
{
foreach($_COOKIE as $cookie_name => $cookie_val) foreach($_COOKIE as $cookie_name => $cookie_val)
{ // Collect poll cookies { // Collect poll cookies
if(substr($cookie_name,0,5) == 'poll_')
{
// e107::getDebug()->log("Poll: ".$cookie_name);
list($str, $int) = explode('_', $cookie_name, 2); list($str, $int) = explode('_', $cookie_name, 2);
if (($str == 'poll') && is_numeric($int)) if (($str == 'poll') && is_numeric($int))
{ // Yes, its poll's cookie { // Yes, its poll's cookie
$arr_polls_cookies[] = $int; $arr_polls_cookies[] = $int;
} }
} }
}
}
if (count($arr_polls_cookies) > 1) if (count($arr_polls_cookies) > 1)
{ // Remove all except first (assumption: there is always only one active poll) { // Remove all except first (assumption: there is always only one active poll)
rsort($arr_polls_cookies); rsort($arr_polls_cookies);
@@ -888,6 +897,7 @@ class poll_shortcodes extends e_shortcode
public $answerOption = array(); public $answerOption = array();
public $answerCount = 0; public $answerCount = 0;
public $pollRenderType = null; // type public $pollRenderType = null; // type
public $pollRenderMode = null;
public $pollPreview = false; public $pollPreview = false;
public $pollVoteTotal = 0; public $pollVoteTotal = 0;
public $pollCommentTotal = 0; public $pollCommentTotal = 0;

View File

@@ -217,7 +217,7 @@ class wysiwyg
function tinymce_lang() function tinymce_lang()
{ {
$lang = 'English'; //Quick Fix e_LANGUAGE $lang = e_LANGUAGE; // 'English'; //Quick Fix e_LANGUAGE
$tinylang = array( $tinylang = array(
"Arabic" => "ar", "Arabic" => "ar",
"Bulgarian" => "bg", "Bulgarian" => "bg",

View File

@@ -1011,6 +1011,10 @@ span.tag button.close {
.selectize-control.multi .selectize-input > div { cursor: pointer; margin: 1px 5px 0 0; padding: 1px 3px; background: #3a87ad; color: #ffffff; border: 0 solid rgba(0, 0, 0, 0); text-shadow: 1px 1px 0 black; box-shadow: 1px 1px 0 black; font-size: 12px; font-weight: bold; } .selectize-control.multi .selectize-input > div { cursor: pointer; margin: 1px 5px 0 0; padding: 1px 3px; background: #3a87ad; color: #ffffff; border: 0 solid rgba(0, 0, 0, 0); text-shadow: 1px 1px 0 black; box-shadow: 1px 1px 0 black; font-size: 12px; font-weight: bold; }
.selectize-control.single .selectize-input, .selectize-control.single .selectize-input.input-active, .selectize-control.single .selectize-input.input-active:hover, .selectize-control.single .selectize-input.focus, .selectize-control.multi .selectize-input, .selectize-control.multi .selectize-input.input-active, .selectize-control.multi .selectize-input.input-active:hover, .selectize-control.multi .selectize-input.focus { padding: 5px 5px 5px 5px !important; } .selectize-control.single .selectize-input, .selectize-control.single .selectize-input.input-active, .selectize-control.single .selectize-input.input-active:hover, .selectize-control.single .selectize-input.focus, .selectize-control.multi .selectize-input, .selectize-control.multi .selectize-input.input-active, .selectize-control.multi .selectize-input.input-active:hover, .selectize-control.multi .selectize-input.focus { padding: 5px 5px 5px 5px !important; }
div.selectize-control .form-control { background-color: #212121; border: none; box-shadow: 2px 2px 2px rgba(0, 0, 0,0.5); }
div.selectize-dropdown .option.active { color: #fff; background-color: #337ab7; }
/* Theme Manager - Find online */ /* Theme Manager - Find online */
.form-search > div > div > div > i.icon-search .form-search > div > div > div > i.icon-search
{ {
@@ -1258,9 +1262,6 @@ li.rssRow > div {
/* /*
body { background-color: rgb(68, 68, 68); } body { background-color: rgb(68, 68, 68); }

View File

@@ -402,7 +402,6 @@ $(document).ready(function()
/* Bootstrap Modal window within an iFrame for frontend */ /* Bootstrap Modal window within an iFrame for frontend */
$('.e-modal').on('click', function(e) $('.e-modal').on('click', function(e)
{ {
e.preventDefault(); e.preventDefault();
if($(this).attr('data-cache') == 'false') if($(this).attr('data-cache') == 'false')
@@ -414,8 +413,22 @@ $(document).ready(function()
var url = $(this).attr('href'); var url = $(this).attr('href');
var caption = $(this).attr('data-modal-caption'); var caption = $(this).attr('data-modal-caption');
var backdrop = $(this).attr('data-modal-backdrop');
var keyboard = $(this).attr('data-modal-keyboard');
var height = ($(window).height() * 0.7) - 120; var height = ($(window).height() * 0.7) - 120;
var modalOptions = {show: true};
if(backdrop !== undefined)
{
modalOptions['backdrop'] = backdrop;
}
if(keyboard !== undefined)
{
modalOptions['keyboard'] = keyboard;
}
if(caption === undefined) if(caption === undefined)
{ {
caption = ''; caption = '';
@@ -426,9 +439,9 @@ $(document).ready(function()
height = $(this).attr('data-modal-height'); height = $(this).attr('data-modal-height');
} }
$('.modal-body').html('<div><iframe id="e-modal-iframe" width="100%" height="'+height+'px" frameborder="0" scrolling="auto" style="display:block;" allowtransparency="true" src="' + url + '"></iframe></div>'); $('.modal-body').html('<div><iframe id="e-modal-iframe" width="100%" height="'+height+'px" frameborder="0" scrolling="auto" style="display:block;" allowtransparency="true" allowfullscreen src="' + url + '"></iframe></div>');
$('.modal-caption').html(caption + ' <i id="e-modal-loading" class="fa fa-spin fa-spinner"></i>'); $('.modal-caption').html(caption + ' <i id="e-modal-loading" class="fa fa-spin fa-spinner"></i>');
$('.modal').modal('show'); $('.modal').modal(modalOptions);
$("#e-modal-iframe").on("load", function () { $("#e-modal-iframe").on("load", function () {
$('#e-modal-loading').hide(); $('#e-modal-loading').hide();

View File

@@ -261,12 +261,14 @@ if (isset($id))
// $userList = $sql->db_getList(); // $userList = $sql->db_getList();
$text = $tp->parseTemplate($USER_SHORT_TEMPLATE_START, TRUE, $user_shortcodes); $text = $tp->parseTemplate($USER_SHORT_TEMPLATE_START, TRUE, $user_shortcodes);
$sc = e107::getScBatch('user');
foreach ($data as $row) foreach ($data as $row)
{ {
$loop_uid = $row['user_id']; $loop_uid = $row['user_id'];
// $text .= renderuser($row, "short"); // $text .= renderuser($row, "short");
e107::getScBatch('user')->setVars($row); $sc->setVars($row);
$sc->wrapper('user/list');
$text .= $tp->parseTemplate($USER_SHORT_TEMPLATE, TRUE, $user_shortcodes); $text .= $tp->parseTemplate($USER_SHORT_TEMPLATE, TRUE, $user_shortcodes);
} }