Skip to content

Commit

Permalink
Set Owner for notes in documents. Added utility function for user inf…
Browse files Browse the repository at this point in the history
…o+smarty wrapper. Display owner name.
  • Loading branch information
yehster committed Feb 22, 2013
1 parent 08a8c59 commit 857a1d3
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
1 change: 1 addition & 0 deletions controllers/C_Document.class.php
Expand Up @@ -247,6 +247,7 @@ function note_action_process($patient_id) {
return; return;


$n = new Note(); $n = new Note();
$n->set_owner($_SESSION['authUserID']);
parent::populate_object($n); parent::populate_object($n);
$n->persist(); $n->persist();


Expand Down
45 changes: 45 additions & 0 deletions library/plugins/function.user_info.php
@@ -0,0 +1,45 @@
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
* user_info() version for smarty templates
* Kevin Yeh 2013
*/


/**
* Smarty {user_info} function plugin
*
* Type: function<br>
* Name: user_info<br>
* Purpose: Return the user info for a given ID<br>
*
* Examples:
*
* {user_info id=1}
*
* @param array
* @param Smarty
*/

require_once(dirname(__FILE__) . '../../user.inc');

function smarty_function_user_info($params, &$smarty)
{
if (empty($params['id'])) {
$smarty->trigger_error("user_info: missing 'id' parameter");
return;
} else {
$user_id = $params['id'];
}

$user_info=getUserIDInfo($user_id);
if($user_info)
{
echo $user_info['fname']." ".$user_info['lname'];
}
}


?>
6 changes: 6 additions & 0 deletions library/user.inc
Expand Up @@ -138,4 +138,10 @@ function removeUserSetting($label,$user=NULL) {
} }
} }



function getUserIDInfo($id)
{
$res= sqlStatement("SELECT fname,lname,username FROM users where id=?",array($id));
return sqlFetchArray($res);
}
?> ?>
5 changes: 4 additions & 1 deletion templates/documents/general_view.html
Expand Up @@ -161,9 +161,12 @@
{xl t='Note'} #{$note->get_id()} {xl t='Note'} #{$note->get_id()}
{xl t='Date:'} {$note->get_date()} {xl t='Date:'} {$note->get_date()}
{$note->get_note()} {$note->get_note()}
{if $note->get_owner()}
&nbsp;-{user_info id=$note->get_owner()}
{/if}
</div> </div>
{/foreach} {/foreach}
{/if} {/if}
</div> </div>
</div> </div>
</div> </div>
Expand Down

0 comments on commit 857a1d3

Please sign in to comment.