[Pieforms-commit] SF.net SVN: pieforms: [20] pieforms/src/pieform/elements/userlist.php
Status: Alpha
Brought to you by:
oracleshinoda
From: <ora...@us...> - 2006-11-18 11:24:42
|
Revision: 20 http://svn.sourceforge.net/pieforms/?rev=20&view=rev Author: oracleshinoda Date: 2006-11-18 03:24:34 -0800 (Sat, 18 Nov 2006) Log Message: ----------- Removed the custom userlist element. It's too much dependent on the Mahara project. Removed Paths: ------------- pieforms/src/pieform/elements/userlist.php Deleted: pieforms/src/pieform/elements/userlist.php =================================================================== --- pieforms/src/pieform/elements/userlist.php 2006-11-18 11:20:10 UTC (rev 19) +++ pieforms/src/pieform/elements/userlist.php 2006-11-18 11:24:34 UTC (rev 20) @@ -1,106 +0,0 @@ -<?php -/** - * This program is part of Pieforms - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - * @package pieform - * @subpackage element - * @author Martyn Smith <ma...@ca...> - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL - * @copyright (C) 2006 Catalyst IT Ltd http://catalyst.net.nz - * - */ - - - -/** - * Provides a basic text field input. - * - * @todo this is just lies ... - * @param array $element The element to render - * @param Pieform $form The form to render the element for - * @return string The HTML for the element - */ -function pieform_render_userlist($element, Pieform $form) { - $smarty = smarty(); - - $smarty->left_delimiter = '{{'; - $smarty->right_delimiter = '}}'; - - $value = $form->get_value($element); - - if (!is_array($value) && isset($element['defaultvalue']) && is_array($element['defaultvalue'])) { - $value = $element['defaultvalue']; - } - - if (is_array($value) && count($value)) { - $members = get_records_select('usr','id IN (' . join(',',$value) . ')', null, '', 'id,firstname,lastname,preferredname'); - - foreach($members as &$member) { - $member = display_name($member); - } - - $smarty->assign('options',$members); - $smarty->assign('value', join(',',$value)); - } - - $smarty->assign('name', $element['name']); - if (!empty($element['filter'])) { - $smarty->assign('filter', true); - } - - return $smarty->fetch('form/userlist.tpl'); -} - -function pieform_get_value_userlist($element, Pieform $form) { - $name = $element['name']; - - $global = ($form->get_method() == 'get') ? $_GET : $_POST; - - if (isset($global[$name])) { - $value = $global[$name]; - - if ($value == '') { - return array(); - } - - if (preg_match('/^(\d+(,\d+)*)$/',$value)) { - return array_map('intval', explode(',', $value)); - } - - throw new PieformException("Invalid value for userlist form element '$name' = '$value'"); - } - - return null; -} - -function pieform_is_empty_userlist($value, $element) { - if (is_array($value) && count($value)) { - return false; - } - - return true; -} - -function pieform_render_userlist_set_attributes($element) { - // By default, use the filter select box - if (!isset($element['filter'])) { - $element['filter'] = true; - } - return $element; -} - -?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |