<?php if (!empty($vars["entity"])) { $group = $vars['entity']; $group_guid = $group->guid; // call the hook directly to avoid overrides and other logic $wav = identicon_url($group, 'large'); $img = '<img src="' . $wav . '" alt="identicon" />'; $check = elgg_view('input/checkboxes', array('name' => 'preferGroupIdenticon', 'options' => array(elgg_echo('identicon:group_preference_checkbox') => true), 'value' => $group->preferGroupIdenticon ? true : false)); $submit = elgg_view('input/submit', array('value' => elgg_echo('save'))); $form = elgg_view('input/form', array('action' => elgg_get_site_url() . "action/identicon/grouppreference?group_guid={$group_guid}", 'body' => $img . "\n" . $check . "\n<br>" . $submit)); $identicon_title = elgg_echo('identicon:title'); $identicon_explanation = elgg_echo('identicon:explanation'); $output = <<<HTML <div id="identicon-editgroupicon" class="elgg-divide-top mtl ptm"> \t<label>{$identicon_title}</label> \t<p> \t\t{$identicon_explanation} \t</p> \t{$form} </div> HTML; echo $output; }
function identicon_groupicon_hook($hook, $entity_type, $returnvalue, $params) { if ($hook == 'entity:icon:url' && $params['entity'] instanceof ElggGroup) { $ent = $params['entity']; // if we don't have an icon or the user just prefers the avatar if ($ent->preferGroupIdenticon || !$ent->icontime) { return identicon_url($ent, $params['size']); } } else { return $returnvalue; } }
<?php $user = $vars['entity']; if ($user) { // call the hook directly to avoid overrides and other logic $wav = identicon_url($user, 'large'); $img = '<img src="' . $wav . '" alt="identicon" />'; $check = elgg_view('input/checkboxes', array('name' => 'preferIdenticon', 'options' => array(elgg_echo('identicon:preference_checkbox') => true), 'value' => $user->preferIdenticon ? true : false)); $submit = elgg_view('input/submit', array('value' => elgg_echo('save'))); $form = elgg_view('input/form', array('action' => elgg_get_site_url() . "action/identicon/userpreference?user_guid={$user->guid}", 'body' => $img . "\n" . $check . "\n<br>" . $submit)); $identicon_title = elgg_echo('identicon:title'); $identicon_explanation = elgg_echo('identicon:explanation'); $output = <<<HTML <div id="identicon-editusericon" class="elgg-divide-top mtl ptm"> \t<label>{$identicon_title}</label> \t<p> \t\t{$identicon_explanation} \t</p> \t{$form} </div> HTML; echo $output; }