Commit 46d07268 authored by bgm's avatar bgm Committed by Aegir user

Update civirules, sumfields, flexmailer, volunteer, angularprofiles, etc

parent 2cda87f4
<?php <?php
return array ( return array(
0=>array ( array(
'name'=>'dataviz_contact',
'entity'=> 'Dashboard',
'params'=> array (
'version'=>'3',
'name'=>'dataviz_contact', 'name'=>'dataviz_contact',
'label'=> 'Dataviz of contacts', 'entity'=> 'Dashboard',
'url' => CRM_Utils_System::url('civicrm/dataviz/contacts', 'snippet=4'), 'params'=> array(
) 'version'=>'3',
), 'name'=>'dataviz_contact',
'label'=> 'Dataviz of contacts',
'url' => 'civicrm/dataviz/contacts?snippet=4',
),
),
1=>array ( array(
'name'=>'dataviz_events', 'name'=>'dataviz_events',
'entity'=> 'Dashboard', 'entity'=> 'Dashboard',
'params'=> array ( 'params'=> array(
'version'=>'3', 'version'=>'3',
'name'=>'dataviz_event', 'name'=>'dataviz_event',
'label'=> 'Dataviz of events', 'label'=> 'Dataviz of events',
'url' => CRM_Utils_System::url('civicrm/dataviz/events', 'snippet=4'), 'url' => 'civicrm/dataviz/events?snippet=4',
) ),
), ),
2=>array ( array(
'name'=>'dataviz_contribute',
'entity'=> 'Dashboard',
'params'=> array (
'version'=>'3',
'name'=>'dataviz_contribute', 'name'=>'dataviz_contribute',
'label'=> 'Dataviz of contributions', 'entity'=> 'Dashboard',
'url' => CRM_Utils_System::url('civicrm/dataviz/contribute', 'snippet=4'), 'params'=> array(
) 'version'=>'3',
) 'name'=>'dataviz_contribute',
'label'=> 'Dataviz of contributions',
'url' => 'civicrm/dataviz/contribute?snippet=4',
),
),
); );
<?php
class CRM_Civisualize_Page_Doc extends CRM_Core_Page {
public function run() {
CRM_Core_Resources::singleton()
->addScriptFile('eu.tttp.civisualize', 'js/marked.min.js', 110, 'html-header', FALSE);
$request = CRM_Utils_System::currentPath();
if (false !== strpos($request, '..')) {
die ("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org");
}
$request = explode('/',$request);
//print_r($request);
$tplfile = NULL;
$smarty= CRM_Core_Smarty::singleton( );
$smarty->assign("options",array());
$path = "doc/";
if (CRM_Utils_Array::value(2, $request)) {
$tplfile = _civicrm_api_get_camel_name($request[2]);
$tplfile = explode('?', $tplfile);
$file = $tplfile[0].'.md';
}
if (CRM_Utils_Array::value(3, $request)) {
$r3 = _civicrm_api_get_camel_name($request[3]);
if (!is_numeric($r3)) {
$file = $r3 .'.md';
$path = $path.$tplfile[0].'/';
}
$smarty->assign("id",$r3);
}
if (CIVISUALIZE_GITHUB_DOC) {
$smarty->assign("github",CIVISUALIZE_GITHUB_DOC);
} else {
$smarty->assign("github","TechToThePeople/civisualize");
}
// $github = civicrm_api3('setting', 'getvalue', array('group' => 'Civisualize Preferences', 'name' => 'civisualize_github_doc'));
$md = file_get_contents($path.$file, FILE_USE_INCLUDE_PATH);
if (!$md) {
$md= "$path$file not found";
$smarty->assign("error","missing_file");
}
$smarty->assign("mdfile",$file);
$smarty->assign("path",$path);
$smarty->assign("md",$md);
if (CRM_Utils_Array::value(4, $request)) {
$r3 = CRM_Utils_String::munge($request[4]);
$smarty->assign("id2",$r3);
}
if (!$tplfile) {
$tpl = "CRM/Civisualize/Page/Doc.tpl";
}
parent::run();
}
}
...@@ -10,7 +10,7 @@ class CRM_Civisualize_Page_Main extends CRM_Core_Page { ...@@ -10,7 +10,7 @@ class CRM_Civisualize_Page_Main extends CRM_Core_Page {
die ("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org"); die ("SECURITY FATAL: the url can't contain '..'. Please report the issue on the forum at civicrm.org");
} }
$request = split ('/',$request); $request = explode('/',$request);
$tplfile = NULL; $tplfile = NULL;
$smarty= CRM_Core_Smarty::singleton( ); $smarty= CRM_Core_Smarty::singleton( );
$smarty->assign("options",array()); $smarty->assign("options",array());
...@@ -23,8 +23,12 @@ class CRM_Civisualize_Page_Main extends CRM_Core_Page { ...@@ -23,8 +23,12 @@ class CRM_Civisualize_Page_Main extends CRM_Core_Page {
$r3 = _civicrm_api_get_camel_name($request[3]); $r3 = _civicrm_api_get_camel_name($request[3]);
$smarty->assign("id",$r3); $smarty->assign("id",$r3);
} }
if (CRM_Utils_Array::value(4, $request)) {
$r3 = CRM_Utils_String::munge($request[4]);
$smarty->assign("id2",$r3);
}
if (!$tplfile) { if (!$tplfile) {
$tpl = "CRM/Civizualise/Page/Main.tpl"; $tpl = "CRM/Civisualize/Page/Main.tpl";
} }
if( !$smarty->template_exists($tpl) ){ if( !$smarty->template_exists($tpl) ){
header("Status: 404 Not Found"); header("Status: 404 Not Found");
...@@ -54,8 +58,13 @@ class CRM_Civisualize_Page_Main extends CRM_Core_Page { ...@@ -54,8 +58,13 @@ class CRM_Civisualize_Page_Main extends CRM_Core_Page {
->addScriptFile('eu.tttp.civisualize', 'js/d3.v3.js', 110, 'html-header', FALSE) ->addScriptFile('eu.tttp.civisualize', 'js/d3.v3.js', 110, 'html-header', FALSE)
->addScriptFile('eu.tttp.civisualize', 'js/dc/dc.js', 110, 'html-header', FALSE) ->addScriptFile('eu.tttp.civisualize', 'js/dc/dc.js', 110, 'html-header', FALSE)
->addScriptFile('eu.tttp.civisualize', 'js/dc/crossfilter.js', 110, 'html-header', FALSE) ->addScriptFile('eu.tttp.civisualize', 'js/dc/crossfilter.js', 110, 'html-header', FALSE)
->addScriptFile('eu.tttp.civisualize', 'js/filesaver.js', 110, 'html-header', FALSE)
->addScriptFile('eu.tttp.civisualize', 'js/common.js', 110, 'html-header', FALSE)
->addStyleFile('eu.tttp.civisualize', 'js/dc/dc.css') ->addStyleFile('eu.tttp.civisualize', 'js/dc/dc.css')
->addStyleFile('eu.tttp.civisualize', 'css/style.css'); ->addStyleFile('eu.tttp.civisualize', 'css/style.css')
->addVars('civisualize', array(
'baseUrl' => CRM_Core_Resources::singleton()->getUrl('eu.tttp.civisualize'),
));
require_once 'CRM/Core/Smarty/plugins/function.crmSQL.php'; require_once 'CRM/Core/Smarty/plugins/function.crmSQL.php';
$smarty->register_function("crmSQL", "smarty_function_crmSQL"); $smarty->register_function("crmSQL", "smarty_function_crmSQL");
......
...@@ -14,50 +14,68 @@ function smarty_function_crmSQL($params, &$smarty) { ...@@ -14,50 +14,68 @@ function smarty_function_crmSQL($params, &$smarty) {
$parameters = array(); $parameters = array();
if(array_key_exists('json', $params)){ try{
$json=json_decode(file_get_contents('queries/'.$params["json"].".json", true));//file_get_contents('queries/'.$params["json"].".json", true) if(array_key_exists('json', $params)){
$sql=$json->{"query"};
foreach ($json->{"params"} as $key => $value) {
$var=intval($key);
$name=$value->{"name"};
$type=$value->{"type"};
if(array_key_exists($name, $params)){
$parameters[$var] = array($params[$name],$type);
}
}
}
else if(array_key_exists('sql', $params)){ $json=json_decode(str_replace(array("\r\n","\r","\n")," ",file_get_contents('queries/'.$params["json"].".json", true)));
$sql = $params["sql"]; $sql=$json->query;
} if (!$sql){
$smarty->trigger_error("assign: missing 'query' in the json file");
$error = "crmAPI: missing 'query' in the json";
}
foreach ($json->params as $key => $value) {
$var=intval($key);
$name=$value->name;
$type=$value->type;
if(array_key_exists($name, $params)){
$parameters[$var] = array($params[$name],$type);
}
}
}
else if(array_key_exists('file', $params)){ elseif(array_key_exists('sql', $params)){
$sql = file_get_contents('queries/'.$params["file"].".sql", true); $sql = $params["sql"];
} }
$forbidden=array("delete ", "drop ","update ","grant "); elseif(array_key_exists('file', $params)){
foreach ($forbidden as $check) { $filename = 'queries/'.$params["file"].".sql";
if(strpos(strtolower($sql), $check)!==false){ $sql = file_get_contents($filename, true);
$smarty->trigger_error($check."command not allowed"); if (!$sql) throw new Exception ("missing filename or empty ".$filename);
$error = "crmAPI: you can not ".$check."using crmSQL";
$is_error = 1;
break;
}
}
if (array_key_exists('debug', $params)) { }
$smarty->trigger_error("sql:". $params["sql"]);
} $forbidden=array("delete ", "drop ","update ","grant ");
foreach ($forbidden as $check) {
if(strpos(strtolower($sql), $check)!==false){
$smarty->trigger_error($check."command not allowed");
$error = "crmAPI: you can not ".$check."using crmSQL";
$is_error = 1;
break;
}
}
if (array_key_exists('debug', $params)) {
$smarty->trigger_error("sql:". $params["sql"]);
}
try{
if($is_error==0){ if($is_error==0){
$errorScope = CRM_Core_TemporaryErrorScope::useException(); $errorScope = CRM_Core_TemporaryErrorScope::useException();
CRM_Core_DAO::executeQuery("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED ;");
$dao = CRM_Core_DAO::executeQuery($sql,$parameters); $dao = CRM_Core_DAO::executeQuery($sql,$parameters);
$values = array(); $values = array();
while ($dao->fetch()) { $keys= null;
if (array_key_exists('sequential', $params)) {
while ($dao->fetch()) {
if (!$keys) $keys= array_keys($dao->toArray());
$values[] = array_values($dao->toArray());
}
} else {
while ($dao->fetch()) {
$values[] = $dao->toArray(); $values[] = $dao->toArray();
}
$keys= array_keys($values[0]);
} }
} }
} }
catch(Exception $e){ catch(Exception $e){
$is_error=1; $is_error=1;
...@@ -72,5 +90,11 @@ function smarty_function_crmSQL($params, &$smarty) { ...@@ -72,5 +90,11 @@ function smarty_function_crmSQL($params, &$smarty) {
} }
} }
return json_encode(array("is_error"=>$is_error, "error"=>$error, "values" => $values), JSON_NUMERIC_CHECK); if (array_key_exists('debug', $params)) {
return json_encode(array("is_error"=>$is_error, "keys"=> $keys, "error"=>$error, "values" => $values,"sql" => trim(preg_replace('/\s+/', ' ', $sql))), JSON_NUMERIC_CHECK);
}
if (!$smarty)
return array("is_error"=>$is_error, "keys"=> $keys, "error"=>$error, "values" => $values);
return json_encode(array("is_error"=>$is_error, "keys"=> $keys, "error"=>$error, "values" => $values), JSON_NUMERIC_CHECK);
} }
...@@ -13,15 +13,15 @@ Civisualize will help you out with ready to use visualizations that we have crea ...@@ -13,15 +13,15 @@ Civisualize will help you out with ready to use visualizations that we have crea
*** ***
Installation Installation
------------ ------------
You can install this extension directly from your civicrm site, like any other etension from Administer->System settings->Manage extensions You can directly clone to your civiCRM extension directory using
If you don't have a bootstrap based theme, you should install https://github.com/TechToThePeople/bootstrapvisualize
You can also live at the cutting edge and directly clone the master branch to your civiCRM extension directory using
`git clone https://github.com/TechToThePeople/civisualize.git` `git clone https://github.com/TechToThePeople/civisualize.git`
You can also download a zip file from
`https://codeload.github.com/TechToThePeople/civisualize/zip/master`
and extract in your extension directory. The next step is enabling the extension which can be done from `"Administer -> Customize -> Manage CiviCRM Extensions".`
Ready to Use Visualizations Ready to Use Visualizations
--------------------------- ---------------------------
...@@ -129,6 +129,9 @@ We have also used {crmTitle} function which let you set the title of the page, a ...@@ -129,6 +129,9 @@ We have also used {crmTitle} function which let you set the title of the page, a
Checkour resources at [dc.js](http://dc-js.github.io/dc.js/) and create your first visualization. Checkour resources at [dc.js](http://dc-js.github.io/dc.js/) and create your first visualization.
## Documentation and help
If you want to add a document, add a markdown file that has the same name as the template into the doc folder
We love you We love you
------- -------
xavier made this, sid helped him. You can find us on civicrm forum, [@eucampaign](http://twitter.com/eucampaign) and [@sid0_o](http://twitter.com/sid0_o) on twitter, or in the dc mailing group. Be warned, d3 is awesome, but the learning curve is steep. Worthwhile, the view at the top is beautiful. xavier made this, sid helped him. You can find us on civicrm forum, [@eucampaign](http://twitter.com/eucampaign) and [@sid0_o](http://twitter.com/sid0_o) on twitter, or in the dc mailing group. Be warned, d3 is awesome, but the learning curve is steep. Worthwhile, the view at the top is beautiful.
...@@ -16,7 +16,7 @@ function _civicrm_api3_basic_getsql ($params,$sql) { ...@@ -16,7 +16,7 @@ function _civicrm_api3_basic_getsql ($params,$sql) {
require_once 'civisualize.civix.php'; require_once 'civisualize.civix.php';
function civicrm_civicrm_dashboard( $contactID, &$contentPlacement ) { function civisualize_civicrm_dashboard( $contactID, &$contentPlacement ) {
CRM_Core_Resources::singleton() CRM_Core_Resources::singleton()
->addScriptFile('eu.tttp.civisualize', 'js/d3.v3.js', 110, 'html-header', FALSE) ->addScriptFile('eu.tttp.civisualize', 'js/d3.v3.js', 110, 'html-header', FALSE)
->addScriptFile('eu.tttp.civisualize', 'js/dc/dc.js', 110, 'html-header', FALSE) ->addScriptFile('eu.tttp.civisualize', 'js/dc/dc.js', 110, 'html-header', FALSE)
...@@ -93,32 +93,22 @@ function civisualize_civicrm_managed(&$entities) { ...@@ -93,32 +93,22 @@ function civisualize_civicrm_managed(&$entities) {
return _civisualize_civix_civicrm_managed($entities); return _civisualize_civix_civicrm_managed($entities);
} }
/** /**
* * Adds a navigation menu item under report.
*Adds a navigation menu item under report. *
* * @param array $params
*/ */
function civisualize_civicrm_navigationMenu( &$params ) { function civisualize_civicrm_navigationMenu( &$params ) {
// get the id of Administer Menu $path = "Reports";
$reportMenuId = CRM_Core_DAO::getFieldValue('CRM_Core_BAO_Navigation', 'Reports', 'id', 'name'); $item = array(
'label' => 'Civisualize',
'name' => 'Civisualize',
'url' => 'civicrm/dataviz',
'permission' => 'access CiviReport',
'operator' => '',
'separator' => TRUE,
'active' => 1,
);
// skip adding menu if there is no administer menu _civisualize_civix_insert_navigation_menu($params, $path, $item);
if ($reportMenuId) {
// get the maximum key under adminster menu
$maxKey = max( array_keys($params[$reportMenuId]['child']));
$params[$reportMenuId]['child'][$maxKey+1] = array (
'attributes' => array (
'label' => 'Civisualize',
'name' => 'Civisualize',
'url' => 'civicrm/dataviz',
'permission' => 'access CiviReport',
'operator' => NULL,
'separator' => TRUE,
'parentID' => $reportMenuId,
'navID' => $maxKey+1,