Skip to content

Instantly share code, notes, and snippets.

@chicks
Created March 8, 2016 17:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chicks/06d8e0138f7d394def7c to your computer and use it in GitHub Desktop.
Save chicks/06d8e0138f7d394def7c to your computer and use it in GitHub Desktop.
<?php
//-----------------------------------------------------------------------------
if(!defined('sugarEntry'))define('sugarEntry', true);
require_once('include/entryPoint.php');
//-----------------------------------------------------------------------------
$db = DBManagerFactory::getInstance();
//-- TEMPLATE = birgit
$query = "SELECT id from users where user_name='birgit'";
$result = $db->query($query, true,"Error fetching birgit: ");
if ($row = $db->fetchByAssoc($result))
$birgit = $row['id'];
else
die("user_name birgit not found!");
$query = "SELECT id from users where status='Active' and employee_status='Active' and portal_only=0 and is_group=0 and deleted=0 ".
//-- for test uncomment the following line
// "and user_name='tom' ".
"and user_name<>'birgit' ";
$result = $db->query($query, true,"Error fetching users: ");
while ($row = $db->fetchByAssoc($result))
{
$klaus = $row['id'];
print("Copy birgits dashlets to ".$klaus."\n");
$sql = "DELETE from dashboards where assigned_user_id = '".$klaus."'";
$res = $db->query($sql, true,"Error cleaning dashboards: ");
$sql = "INSERT INTO dashboards (id, name,date_entered,date_modified,modified_user_id,created_by,description,".
" deleted,assigned_user_id,dashboard_module,view,metadata) ".
"SELECT uuid(),name,date_entered,date_modified,'".$klaus."', '".$klaus."',description,".
" deleted,'".$klaus."', dashboard_module,view,metadata ".
"FROM dashboards ".
"WHERE assigned_user_id = '".$birgit."'";
$res = $db->query($sql, true,"Error copying birgit dashboards: ");
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment