|
From: <dj...@us...> - 2013-05-22 13:04:59
|
Revision: 11574
http://sourceforge.net/p/xoops/svn/11574
Author: djculex
Date: 2013-05-22 13:04:57 +0000 (Wed, 22 May 2013)
Log Message:
-----------
NEW: Adding tagging
Bugfix: Fixing selector for like/dislike
Bugfix: Check permissions return array
Modified Paths:
--------------
XoopsModules/smallworld/trunk/smallworld/class/forms.php
XoopsModules/smallworld/trunk/smallworld/class/mail.php
XoopsModules/smallworld/trunk/smallworld/class/profile.php
XoopsModules/smallworld/trunk/smallworld/class/user.php
XoopsModules/smallworld/trunk/smallworld/include/functions.php
Modified: XoopsModules/smallworld/trunk/smallworld/class/forms.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/class/forms.php 2013-05-22 13:01:51 UTC (rev 11573)
+++ XoopsModules/smallworld/trunk/smallworld/class/forms.php 2013-05-22 13:04:57 UTC (rev 11574)
@@ -305,12 +305,15 @@
$v = unserialize(stripslashes($row['value']));
$pv = ($v['posts'] == '1') ? ' checked="checked"' : '';
$cv = ($v['comments'] == '1') ? ' checked="checked"' : '';
+ $nv = ($v['notify'] == '1') ? ' checked="checked"' : '';
$form .= '<input type="checkbox" name="usersettings[]" id="posts" value="'.$v['posts'].'" '.$pv.'> '._SMALLWORLD_SHOWMYPOSTS.'<br/>';
$form .= '<input type="checkbox" name="usersettings[]" id="comments" value="'.$v['comments'].'" '.$cv.'> '._SMALLWORLD_SHOWMYCOMMENTS.'<br/>';
+ $form .= '<input type="checkbox" name="usersettings[]" id="notify" value="'.$v['notify'].'" '.$nv.'> '._SMALLWORLD_NOTIFYME.'<br/>';
}
} else {
$form .= '<input type="checkbox" name="usersettings[]" id="posts" value="0"> '._SMALLWORLD_SHOWMYPOSTS.'<br/>';
$form .= '<input type="checkbox" name="usersettings[]" id="comments" value="0"> '._SMALLWORLD_SHOWMYCOMMENTS.'<br/>';
+ $form .= '<input type="checkbox" name="usersettings[]" id="notify" value="0"> '._SMALLWORLD_NOTIFYME.'<br/>';
}
}
$form .= "<br><input type='submit' id='smallworld_privsave' value='"._SMALLWORLD_SUBMIT."' class='smallworld_finish'/>";
Modified: XoopsModules/smallworld/trunk/smallworld/class/mail.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/class/mail.php 2013-05-22 13:01:51 UTC (rev 11573)
+++ XoopsModules/smallworld/trunk/smallworld/class/mail.php 2013-05-22 13:04:57 UTC (rev 11574)
@@ -157,6 +157,20 @@
$toMail = $ToUser->getVar('email');
}
+ elseif ($event == 'tag') {
+ $subject = _SMALLWORLD_MAIL_FRIENDTAGGEDYOU.$xoopsConfig['sitename'];
+ $tpl = new XoopsTpl();
+ $tpl->assign('toUser',$RecieveName);
+ $tpl->assign('fromUser',$SendName);
+ $tpl->assign('date',$date);
+ $tpl->assign('link',$link);
+ $tpl->assign('sitename',$xoopsConfig['sitename']);
+
+ $lnk = XOOPS_ROOT_PATH .'/modules/smallworld/language/'.$xoopsConfig['language'].'/mailTpl/mail_tag.html';
+ $message = $tpl->fetch($lnk);
+ $mail->Body = $message;
+ $toMail = $ToUser->getVar('email');
+ }
$mail->IsMail();
$mail->IsHTML(true);
Modified: XoopsModules/smallworld/trunk/smallworld/class/profile.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/class/profile.php 2013-05-22 13:01:51 UTC (rev 11573)
+++ XoopsModules/smallworld/trunk/smallworld/class/profile.php 2013-05-22 13:04:57 UTC (rev 11574)
@@ -68,11 +68,7 @@
$education = "<a href='javascript:void(0)' id='_smallworld_educationmore'>".$educationArray[0]." ("._SMALLWORLD_MORE.")</a>";
$lng = $r['birthplace_lng'];
$latt = $r['birthplace_lat'];
- if($moduleConfig['geolocate'] != 1) {
- $country = "<img src='".$r['birthplace_country']."'/>";
- } else {
- $country = $r['birthplace_country'];
- }
+ $country = $r['birthplace_country'];
$rank = $user->rank();
$rank_title = $rank['title'];
if (isset($rank['image'])) {
Modified: XoopsModules/smallworld/trunk/smallworld/class/user.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/class/user.php 2013-05-22 13:01:51 UTC (rev 11573)
+++ XoopsModules/smallworld/trunk/smallworld/class/user.php 2013-05-22 13:04:57 UTC (rev 11574)
@@ -35,6 +35,18 @@
$sql = "SELECT * FROM ".$xoopsDB->prefix('smallworld_user')." WHERE userid = ".$userID;
$result = $xoopsDB->queryF($sql);
$i = $xoopsDB->getRowsNum($result);
+ if ($xoopsUser) {
+ // If xoopsuser but no smallworld profile
+ if ($i == 0) {
+ $i = 1;
+ } else {
+ // if xoopsuser and has profile
+ $i = 2;
+ }
+ } else {
+ // if not xoopsUser ie anonymous user
+ $i = 0;
+ }
return $i;
}
Modified: XoopsModules/smallworld/trunk/smallworld/include/functions.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/include/functions.php 2013-05-22 13:01:51 UTC (rev 11573)
+++ XoopsModules/smallworld/trunk/smallworld/include/functions.php 2013-05-22 13:04:57 UTC (rev 11574)
@@ -267,7 +267,7 @@
$text = " " . $text;
$text = str_replace('UPLIMAGE', '', $text);
}
- return $text;
+ return linkify_twitter_status($text);
}
function Smallworld_stripWordsKeepUrl($text)
@@ -975,11 +975,16 @@
$db =& XoopsDatabaseFactory::getDatabaseConnection();
$myts =& MyTextSanitizer::getInstance();
$sql = "SELECT userid, username FROM ".$db->prefix('smallworld_user')." ORDER BY userid";
- $result = $db->query($sql);
- while ($r = $db->fetchArray($result)) {
- $data[$r['userid']] = $r['username'];
+ $result = $db->queryF($sql);
+ $num = $db->getRowsNum($result);
+ if ($num == 0) {
+ $ndata = array(0 => _MI_SMALLWORLD_ALL);
+ } else {
+ while ($r = $db->fetchArray($result)) {
+ $data[$r['userid']] = $r['username'];
+ }
+ $ndata = array_merge(array(0 => _MI_SMALLWORLD_ALL), $data);
}
- $ndata = array_merge(array(0 => _MI_SMALLWORLD_ALL), $data);
return $ndata;
}
@@ -996,12 +1001,7 @@
if ($module) {
$moduleConfig =& $config_handler->getConfigsByCat(0, $module->getVar('mid'));
}
-
- // check geolocation style
- if(isset($moduleConfig['geolocate'])) {
- $geolocate = $moduleConfig['geolocate'];
- }
-
+
// IF logged in define xoops / smallworld user id
$myid = ($xoopsUser) ? $xoopsUser->getVar('uid'):0;
@@ -1041,7 +1041,7 @@
if (!strstr($urltest, 'www.')) {
$xoops_url = str_replace( 'www.', '', $xoops_url );
}
-
+
// Set javascript vars but only if not already defined.
// Check prevents multible loads
$script = "if (myID === undefined) {"."\n";
@@ -1051,14 +1051,13 @@
$script .= "var myID = " . $myid . ";\n";
$script .= "var userHasProfile = " . $ChkProf . ";\n";
$script .= "var smallworldTakeOverLinks = " . $takeoverlinks . ";\n";
- $script .= "var geoL = " . $geolocate . ";\n";
$script .= "var geocomplete = '';\n";
$script .= "var smallworldVerString = '" . $smallworldUV . "';\n";
$script .= "var smallworlduseverification = new Array();\n";
$script .= "smallworlduseverification = smallworldVerString.split(',');\n";
$script .= "var hasmessages = " . $count_invit . ";\n";
$script .= "var smallworldvalidationstrenght = " . $validate . ";\n";
- $script .= "var smallworld_getFriendsMsgComCount = " . $getUserMsgNum . ";\n";
+ $script .= "var smallworld_getFriendsMsgComCount = " . $getUserMsgNum . ";\n";
$script .= "var $ = jQuery();\n";
$script .= "} else {"."\n";
$script .= "\n";
@@ -1066,20 +1065,13 @@
$xoTheme->addScript('','',$script);
// Include geolocate styling
- if ($geolocate != 1) {
- $xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/geoname.js');
- $xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/geoname_now.js');
- } else {
- $xoTheme->addScript("http://maps.google.com/maps/api/js?sensor=false&language="._LANGCODE);
- $xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/ui.geo_autocomplete.js');
- $xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/ui.geo_autocomplete_now.js');
-
- $xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/colorbox.css');
- }
+ $xoTheme->addScript("https://maps.googleapis.com/maps/api/js?sensor=false&language="._LANGCODE);
+ $xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/ui.geo_autocomplete.js');
+ $xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/ui.geo_autocomplete_now.js');
}
/**
- * Check if permission is et for userid to post publicly
+ * Check if permission is set for userid to post publicly
* @return array
*/
@@ -1095,3 +1087,58 @@
}
return $pub;
}
+ /**
+ * Change @username to urls
+ * @param string $status_text
+ * @return string $status_text
+ */
+ function linkify_twitter_status($status_text) {
+ // linkify twitter users
+ //$keywords = preg_split("/[\s,]+/", "hypertext language, programming");
+ $status_text = preg_replace(
+ '/(^|\s)@(\w+)/',
+ '\1<a href="'.XOOPS_URL . '/modules/smallworld/userprofile.php?username=\2">' . '@\2</a> ',
+ $status_text
+ );
+
+ return $status_text;
+ }
+
+ /**
+ * Extract users from @tags
+ * @param $txt
+ * @return array @users
+ **/
+ function smallworld_getUidFromName ($name)
+ {
+ global $xoopsDB;
+ $sql = "Select userid from ".$xoopsDB->prefix('smallworld_user')." where username = '".$name."'";
+ $result = $xoopsDB->queryF($sql);
+ while ($r = $xoopsDB->fetchArray($result)) {
+ $id = $r['userid'];
+ }
+ return $id;
+ }
+
+ /**
+ * Extract users from @tags
+ * @param $txt
+ * @return array @users
+ **/
+ function smallworld_getTagUsers ($txt, $sender, $permalink='')
+ {
+ $dBase = new SmallWorldDB;
+ $mail = new smallworld_mail;
+ preg_match_all("/@([a-zA-Z0-9]+|\\[[a-zA-Z0-9]+\\])/", $txt, $matches);
+ $users = array_unique($matches[1]);
+ foreach ($users as $users) {
+ $uid = smallworld_getUidFromName ($users);
+ $notify = json_decode($dBase->GetSettings($uid), true);
+ if (isset ($notify['notify'])) {
+ if ($notify['notify'] != 0) {
+ $mail->sendMails ($sender, $uid, 'tag', $link=$permalink, array($txt));
+ }
+ }
+
+ }
+ }
|