Exemple #1
0
/**
 * Renders select page box
 *
 * @param string $name Name to use in HTML for the select
 * @param Project $project
 * @param integer $selected Id of selected element
 * @param array $attributes Array of additional attributes
 * @return string
 */
function wiki_select_page($name, $project, $selected = null, $attributes = null)
{
    if (is_array($attributes)) {
        if (!isset($attributes['class'])) {
            $attributes['class'] = 'wiki_select_page';
        }
    } else {
        $attributes = array('class' => 'wiki_select_page');
    }
    // if
    $options = array(option_tag(lang('none'), 0));
    if (logged_user()->isAdministrator()) {
        $pages = Wiki::getAllProjectPages($project);
    } else {
        $pages = Wiki::getAllProjectPages($project);
    }
    if (is_array($pages)) {
        foreach ($pages as $page) {
            $option_attributes = $page->getId() == $selected ? array('selected' => 'selected') : null;
            $options[] = option_tag($page->getObjectName(), $page->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    return select_box($name, $options, $attributes);
}
Exemple #2
0
/**
 * Render select folder box
 *
 * @param string $name Control name
 * @param Project $project
 * @param integer $selected ID of selected folder
 * @param array $attributes Select box attributes
 * @return string
 */
function select_project_folder($name, $project = null, $selected = null, $attributes = null)
{
    if (is_null($project)) {
        $project = active_project();
    }
    // if
    if (!$project instanceof Project) {
        throw new InvalidInstanceError('$project', $project, 'Project');
    }
    // if
    if (is_array($attributes)) {
        if (!isset($attributes['class'])) {
            $attributes['class'] = 'select_folder';
        }
    } else {
        $attributes = array('class' => 'select_folder');
    }
    // if
    $options = array(option_tag(lang('none'), 0));
    $folders = $project->getFolders();
    if (is_array($folders)) {
        foreach ($folders as $folder) {
            $option_attributes = $folder->getId() == $selected ? array('selected' => true) : null;
            $options[] = option_tag($folder->getName(), $folder->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    return select_box($name, $options, $attributes);
}
Exemple #3
0
/**
 * Renders locale select box
 *
 * @param string  $name
 * @param array   $locales
 * @param integer $selected   id of selected element
 * @param array   $attributes additional attributes
 * @return string
 */
function select_locale($name, $locales = null, $selected = null, $attributes = null)
{
    if (is_array($attributes)) {
        if (!isset($attributes['class'])) {
            $attributes['class'] = 'select_locale';
        }
    } else {
        $attributes = array('class' => 'select_locale');
    }
    // if
    $options = array(option_tag(lang('none'), 0));
    if (is_null($locales)) {
        $locales = array();
    }
    if (is_array($locales)) {
        foreach ($locales as $k => $locale) {
            if (is_string($locale)) {
                $option_attributes = $locale == $selected ? array('selected' => 'selected') : null;
                $options[] = option_tag($locale, $k, $option_attributes);
            } else {
                $option_attributes = $locale->getId() == $selected ? array('selected' => 'selected') : null;
                $options[] = option_tag($locale->getName(), $locale->getId(), $option_attributes);
            }
        }
        // foreach
    }
    // if
    return select_box($name, $options, $attributes);
}
/**
 * Render select parent object for provided project
 * 
 * Supported paramteres:
 * 
 * - types - type of of parent objects to be listed
 * - project - Instance of selected project (required)
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_project_object($params, &$smarty)
{
    $project = array_var($params, 'project');
    if (!instance_of($project, 'Project')) {
        return new InvalidParamError('project', $project, '$project is expected to be an instance of Project class', true);
    }
    // if
    $value = array_var($params, 'value');
    unset($params['project']);
    $types = array_var($params, 'types', null);
    if (!$types || !is_foreachable($types = explode(',', $types))) {
        $types = array('ticket', 'file', 'discussion', 'page');
    }
    // if
    $id_name_map = ProjectObjects::getIdNameMapForProject($project, $types);
    if (!is_foreachable($id_name_map)) {
        return false;
    }
    // if
    $sorted = array();
    foreach ($id_name_map as $object) {
        $option_attributes = $value == $object['id'] ? array('selected' => true) : null;
        $sorted[strtolower($object['type'])][] = option_tag($object['name'], $object['id'], $option_attributes);
    }
    // foreach
    if (is_foreachable($sorted)) {
        foreach ($sorted as $sorted_key => $sorted_values) {
            $options[] = option_group_tag($sorted_key, $sorted_values);
        }
        // foreach
    }
    // if
    return select_box($options, $params);
}
 /**
 * Render form control
 *
 * @param string $control_name
 * @return string
 */
 function render($control_name) {
   $options = array();
   
   $option_attributes = $this->getValue() == 'd/m/Y' ? array('selected' => 'selected') : null;
   $options[] = option_tag('dd/mm/yyyy', 'd/m/Y', $option_attributes);
   
   $option_attributes = $this->getValue() == 'm/d/Y' ? array('selected' => 'selected') : null;
   $options[] = option_tag('mm/dd/yyyy', 'm/d/Y', $option_attributes);
   
   $option_attributes = $this->getValue() == 'Y/m/d' ? array('selected' => 'selected') : null;
   $options[] = option_tag('yyyy/mm/dd', 'Y/m/d', $option_attributes);
   
   $option_attributes = $this->getValue() == 'd-m-Y' ? array('selected' => 'selected') : null;
   $options[] = option_tag('dd-mm-yyyy', 'd-m-Y', $option_attributes);
   
   $option_attributes = $this->getValue() == 'm/d/Y' ? array('selected' => 'selected') : null;
   $options[] = option_tag('mm-dd-yyyy', 'm-d-Y', $option_attributes);
   
   $option_attributes = $this->getValue() == 'Y-m-d' ? array('selected' => 'selected') : null;
   $options[] = option_tag('yyyy-mm-dd', 'Y-m-d', $option_attributes);
   
   $option_attributes = $this->getValue() == 'd.m.Y' ? array('selected' => 'selected') : null;
   $options[] = option_tag('dd.mm.yyyy', 'd.m.Y', $option_attributes);
   
   $option_attributes = $this->getValue() == 'm/d/Y' ? array('selected' => 'selected') : null;
   $options[] = option_tag('mm.dd.yyyy', 'm.d.Y', $option_attributes);
   
   $option_attributes = $this->getValue() == 'Y.m.d' ? array('selected' => 'selected') : null;
   $options[] = option_tag('yyyy.mm.dd', 'Y.m.d', $option_attributes);
   
   return select_box($control_name, $options);
 } // render
/**
 * Select milestone category control
 * 
 * Params:
 * 
 * - Commong SELECT attributes
 * - Value - Selected milestone category id
 *
 * @param array $params
 * @return string
 */
function smarty_function_select_milestone_category($params, &$smarty)
{
    $project = array_var($params, 'project');
    $project_id = 0;
    if (instance_of($project, 'Project')) {
        $project_id = $project->getId();
    }
    // if
    $categories = array();
    $categories[] = array('id' => '0', 'text' => '-- select  --');
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $sql = "select id as id, category_name as text from healingcrystals_project_milestone_categories where project_id='" . do_json_encode($project_id) . "' order by category_name";
    $result = mysql_query($sql, $link);
    while ($entry = mysql_fetch_array($result, MYSQL_ASSOC)) {
        $categories[] = $entry;
    }
    mysql_close($link);
    $value = 0;
    if (isset($params['value'])) {
        $value = $params['value'];
        unset($params['value']);
    }
    // if
    $options = array();
    for ($i = 0; $i < count($categories); $i++) {
        $option_attribites = $categories[$i]['id'] == $value ? array('selected' => true) : null;
        $options[] = option_tag($categories[$i]['text'], $categories[$i]['id'], $option_attribites);
    }
    return select_box($options, $params);
}
/**
 * Render select Mailbox type control
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_incoming_mail_object_type($params, &$smarty)
{
    $mailbox_object_types = array();
    if (module_loaded('discussions')) {
        $mailbox_object_types[] = INCOMING_MAIL_OBJECT_TYPE_DISCUSSION;
    }
    // if
    if (module_loaded('tickets')) {
        $mailbox_object_types[] = INCOMING_MAIL_OBJECT_TYPE_TICKET;
    }
    // if
    if (!array_var($params, 'skip_comment', true)) {
        $mailbox_object_types[] = INCOMING_MAIL_OBJECT_TYPE_COMMENT;
    }
    // if
    $value = null;
    if (isset($params['value'])) {
        $value = $params['value'];
        unset($params['value']);
    }
    // if
    $options = array();
    foreach ($mailbox_object_types as $mailbox_object_type) {
        $option_attributes = $mailbox_object_type == $value ? array('selected' => true) : null;
        $options[] = option_tag(Inflector::humanize($mailbox_object_type), $mailbox_object_type, $option_attributes);
    }
    // foreach
    return select_box($options, $params);
}
/**
 * Render select user control
 * 
 * Supported paramteres:
 * 
 * - all HTML attributes
 * - value - ID of selected user
 * - project - Instance of selected project, if NULL all users will be listed
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_incoming_mail_select_user($params, &$smarty)
{
    $project = array_var($params, 'project');
    if (!instance_of($project, 'Project')) {
        return new InvalidParamError('object', $project, '$project is expected to be an instance of Project class', true);
    }
    // if
    $users = Users::findForSelect(null, array_var($params, 'project'));
    $value = array_var($params, 'value', null, true);
    $options = array(option_tag(lang('Original Author'), 'original_author', $value == 'original_author' ? array('selected' => true) : null));
    if (is_foreachable($users)) {
        foreach ($users as $company_name => $company_users) {
            $company_options = array();
            foreach ($company_users as $user) {
                $option_attributes = $user['id'] == $value ? array('selected' => true) : null;
                $company_options[] = option_tag($user['display_name'], $user['id'], $option_attributes);
            }
            // foreach
            $options[] = option_group_tag($company_name, $company_options);
        }
        // if
    }
    // if
    return select_box($options, $params);
}
/**
 * Render select_default_assignment_filter control
 * 
 * Parameters:
 * 
 * - user - User - User using the page
 * - value - integer - ID of selected filter
 * - optional - boolean - Value is optional?
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_default_assignment_filter($params, &$smarty)
{
    $user = array_var($params, 'user', null, true);
    $value = array_var($params, 'value', null, true);
    $optional = array_var($params, 'optional', true, true);
    $default_filter_id = (int) ConfigOptions::getValue('default_assignments_filter');
    $default_filter = $default_filter_id ? AssignmentFilters::findById($default_filter_id) : null;
    $options = array();
    if (instance_of($default_filter, 'AssignmentFilter') && $optional) {
        $options[] = option_tag(lang('-- System Default (:filter) --', array('filter' => $default_filter->getName())), '');
    }
    // if
    $grouped_filters = AssignmentFilters::findGrouped($user, true);
    if (is_foreachable($grouped_filters)) {
        foreach ($grouped_filters as $group_name => $filters) {
            $group_options = array();
            foreach ($filters as $filter) {
                $group_options[] = option_tag($filter->getName(), $filter->getId(), array('selected' => $value == $filter->getId()));
            }
            // foreach
            if (count($options) > 0) {
                $options[] = option_tag('', '');
            }
            // if
            $options[] = option_group_tag($group_name, $group_options);
        }
        // foreach
    }
    // if
    return select_box($options, $params);
}
/**
 * Render select team control
 * 
 * Params:
 * 
 * - project - Project instance that need to be used
 * - active_only - Return only active milestones, true by default
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_team($params, &$smarty)
{
    $project = array_var($params, 'project');
    if (!instance_of($project, 'Project')) {
        return new InvalidParamError('project', $project, '$project value is expected to be an instance of Project class', true);
    }
    // if
    unset($params['project']);
    $value = null;
    if (isset($params['value'])) {
        $value = $params['value'];
        unset($params['value']);
    }
    // if
    $options = array();
    $logged_user = $smarty->get_template_vars('logged_user');
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME);
    $query = "select a.id, a.name from healingcrystals_projects a inner join healingcrystals_project_users b on (a.id=b.project_id and b.user_id='" . $logged_user->getId() . "') where a.status='active' and a.completed_on is null and b.role_id<>'9' order by a.name";
    $result = mysql_query($query, $link);
    while ($info = mysql_fetch_assoc($result)) {
        if ($info['id'] == $project->getId()) {
            $option_attributes = array('selected' => true);
            $options[] = option_tag(lang($info['name']), $info['id'], $option_attributes);
        } else {
            $options[] = option_tag(lang($info['name']), $info['id']);
        }
    }
    mysql_close($link);
    return select_box($options, $params);
}
/**
 * Render select category control
 * 
 * Supported paramteres:
 * 
 * - all HTML attributes
 * - project - Parent project, required
 * - module - Module
 * - controller - Controller name
 * - value - ID of selected category
 * - optional - If false there will be no -- none -- option
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_category($params, &$smarty)
{
    static $ids = array();
    $project = array_var($params, 'project', null, true);
    if (!instance_of($project, 'Project')) {
        return new InvalidParamError('project', $project, 'Project parameter is required for select category helper and it needs to be an instance of Project class', true);
    }
    // if
    $user = array_var($params, 'user', null, true);
    $module = trim(array_var($params, 'module', null, true));
    if ($module == '') {
        return new InvalidParamError('module', $module, 'Module parameter is required for select category helper', true);
    }
    // if
    $controller = trim(array_var($params, 'controller', null, true));
    if ($controller == '') {
        return new InvalidParamError('controller', $controller, 'Controller parameter is required for select category helper', true);
    }
    // if
    $id = array_var($params, 'id', null, true);
    if (empty($id)) {
        $counter = 1;
        do {
            $id = "select_category_{$counter}";
            $counter++;
        } while (in_array($id, $ids));
    }
    // if
    $params['id'] = $id;
    $value = array_var($params, 'value', null, true);
    $optional = array_var($params, 'optional', true, true);
    $options = array();
    if ($optional) {
        $options[] = option_tag(lang('-- None --'), '');
    }
    // if
    $categories = Categories::findByModuleSection($project, $module, $controller);
    if (is_foreachable($categories)) {
        foreach ($categories as $category) {
            $option_attributes = array('class' => 'object_option');
            if ($category->getId() == $value) {
                $option_attributes['selected'] = true;
            }
            // if
            $options[] = option_tag($category->getName(), $category->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    if (instance_of($user, 'User') && Category::canAdd($user, $project)) {
        $params['add_object_url'] = Category::getQuickAddUrl($project, $controller, $module);
        $params['object_name'] = 'category';
        $params['add_object_message'] = lang('Please insert new category name');
        $options[] = option_tag('', '');
        $options[] = option_tag(lang('New Category...'), '', array('class' => 'new_object_option'));
    }
    // if
    return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>';
}
/**
 * Select priority control
 * 
 * Params:
 * 
 * - Commong SELECT attributes
 * - Value - Selected priority
 *
 * @param array $params
 * @return string
 */
function smarty_function_select_priority($params, &$smarty)
{
    $priorities = array(PRIORITY_URGENT => lang('Urgent'), PRIORITY_HIGHEST => lang('Highest'), PRIORITY_HIGH => lang('High'), PRIORITY_NORMAL => lang('Normal'), PRIORITY_LOW => lang('Low'), PRIORITY_LOWEST => lang('Lowest'), PRIORITY_HOLD => lang('Hold'), '-99' => lang('Unknown'));
    if (isset($params['task_id'])) {
        $priorities_images = array(PRIORITY_URGENT => 'assets/images/icons/priority/urgent.png', PRIORITY_HIGHEST => 'assets/images/icons/priority/highest.gif', PRIORITY_HIGH => 'assets/images/icons/priority/high.gif', PRIORITY_NORMAL => 'assets/images/icons/priority/normal.gif', PRIORITY_LOW => 'assets/images/icons/priority/low.gif', PRIORITY_LOWEST => 'assets/images/icons/priority/lowest.gif', PRIORITY_HOLD => 'assets/images/icons/priority/hold.png', '-99' => 'assets/images/icons/priority/unknown.png');
        /*$priority_not_set = false;
        		if ($params['value']=='0'){
        			$link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
        			mysql_select_db(DB_NAME, $link);
        			$query = "select isnull(priority) as priority_not_set from healingcrystals_project_objects where id='" . (int)$params['task_id'] . "'";
        			$result = mysql_query($query, $link);
        			$info = mysql_fetch_assoc($result);
        			if ($info['priority_not_set']=='1') $priority_not_set = true;
        			mysql_close($link);
        		}
        		if (!$priority_not_set){
        			$params['sel-image'] = $priorities_images[$params['value']];
            $value = 0;
            if(isset($params['value'])) {
              $value = (integer) $params['value'];
        			  if($value > PRIORITY_URGENT || $value < PRIORITY_HOLD) {
        				$value = 0;
        			  } // if
        			} // if
        		} else {
        			$value = '-99';
        		}
        		unset($params['value']);
        		return '<span id="' . $params['task_id'] . '" url="' . $params['url'] . '" class="cur_priority" style="cursor:pointer;"><img class="cur_priority" src="' . $priorities_images[$value] . '" /></span>';*/
        return '<span id="' . $params['task_id'] . '" url="' . $params['url'] . '" class="cur_priority" style="cursor:pointer;"><img class="cur_priority" src="' . $priorities_images[$params['value']] . '" /></span>';
    } else {
        $value = 0;
        if (isset($params['value'])) {
            $value = (int) $params['value'];
            //if($value > PRIORITY_HIGHEST || $value < PRIORITY_LOWEST) {
            //BOF:mod 20121122
            /*
            //EOF:mod 20121122
                  if($value > PRIORITY_HIGHEST || $value < PRIORITY_HOLD) {
            //BOF:mod 20121122
            */
            if ($value > PRIORITY_URGENT || $value < PRIORITY_HOLD) {
                //EOF:mod 20121122
                $value = 0;
            }
            // if
            unset($params['value']);
        }
        // if
        $options = array();
        foreach ($priorities as $priority => $priority_text) {
            $option_attribites = $priority == $value ? array('selected' => true) : null;
            $options[] = option_tag($priority_text, $priority, $option_attribites);
        }
        // if
        return select_box($options, $params);
    }
}
/**
 * Render select project helper
 * 
 * Parametars:
 * 
 *  - value - Id of selected project
 *  - user - Limit only to projects that can be viewed by User
 *  - optional
 * 
 * @param void
 * @return null
 */
function smarty_function_select_project($params, &$smarty)
{
    $user = array_var($params, 'user', null, true);
    if (!instance_of($user, 'User')) {
        return new InvalidParamError('user', $user, '$user is expected to be an instance of User class', true);
    }
    // if
    $show_all = array_var($params, 'show_all', false) && $user->isProjectManager();
    $value = array_var($params, 'value', null, true);
    $projects_table = TABLE_PREFIX . 'projects';
    $project_users_table = TABLE_PREFIX . 'project_users';
    if ($show_all) {
        $projects = db_execute_all("SELECT {$projects_table}.id, {$projects_table}.name, {$projects_table}.status FROM {$projects_table} WHERE {$projects_table}.type = ? ORDER BY {$projects_table}.name", PROJECT_TYPE_NORMAL);
    } else {
        $projects = db_execute_all("SELECT {$projects_table}.id, {$projects_table}.name, {$projects_table}.status FROM {$projects_table}, {$project_users_table} WHERE {$project_users_table}.user_id = ? AND {$project_users_table}.project_id = {$projects_table}.id AND {$projects_table}.type = ? ORDER BY {$projects_table}.name", $user->getId(), PROJECT_TYPE_NORMAL);
    }
    // if
    $exclude = (array) array_var($params, 'exclude', array(), true);
    $active_options = array();
    $archived_options = array();
    if (is_foreachable($projects)) {
        foreach ($projects as $k => $project) {
            if (in_array($project['id'], $exclude)) {
                continue;
            }
            // if
            $option_attributes = $project['id'] == $value ? array('selected' => true) : null;
            if ($project['status'] == PROJECT_STATUS_ACTIVE) {
                $active_options[] = option_tag($project['name'], $project['id'], $option_attributes);
            } else {
                $archived_options[] = option_tag($project['name'], $project['id'], $option_attributes);
            }
            // if
        }
        // if
    }
    // if
    $optional = array_var($params, 'optional', false, true);
    $options = array();
    if ($optional) {
        $options[] = option_tag(lang(array_var($params, 'optional_caption', '-- Select Project --')), '');
        $options[] = option_tag('', '');
    }
    // if
    if (is_foreachable($active_options)) {
        $options[] = option_group_tag(lang('Active'), $active_options);
    }
    // if
    if (is_foreachable($active_options) && is_foreachable($archived_options)) {
        $options[] = option_tag('', '');
    }
    // if
    if (is_foreachable($archived_options)) {
        $options[] = option_group_tag(lang('Archive'), $archived_options);
    }
    // if
    return select_box($options, $params);
}
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     $option_attributes = $this->getValue() == FILE_STORAGE_FILE_SYSTEM ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('file storage file system'), FILE_STORAGE_FILE_SYSTEM, $option_attributes);
     $option_attributes = $this->getValue() == FILE_STORAGE_MYSQL ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('file storage mysql'), FILE_STORAGE_MYSQL, $option_attributes);
     return select_box($control_name, $options);
 }
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     $option_attributes = $this->getValue() == 'mail()' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('mail transport mail()'), 'mail()', $option_attributes);
     $option_attributes = $this->getValue() == 'smtp' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('mail transport smtp'), 'smtp', $option_attributes);
     return select_box($control_name, $options);
 }
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     $option_attributes = $this->getValue() == 'no' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('secure ldap connection no'), 'no', $option_attributes);
     $option_attributes = $this->getValue() == 'tls' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('secure ldap connection tls'), 'tls', $option_attributes);
     return select_box($control_name, $options);
 }
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     $option_attributes = $this->getValue() == 'like' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('search engine mysql like'), 'like', $option_attributes);
     $option_attributes = $this->getValue() == 'match' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('search engine mysql match'), 'match', $option_attributes);
     return select_box($control_name, $options);
 }
/**
 * Render select company box
 * 
 * Parameters:
 * 
 * - value - Value of selected company
 * - optional - Is value of this field optional or not
 * - exclude - Array of company ID-s that will be excluded
 * - can_create_new - Should this select box offer option to create a new 
 *   company from within the list
 * 
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_company($params, &$smarty)
{
    static $ids = array();
    $companies = Companies::getIdNameMap(array_var($params, 'companies'));
    $value = array_var($params, 'value', null, true);
    $id = array_var($params, 'id', null, true);
    if (empty($id)) {
        $counter = 1;
        do {
            $id = "select_company_dropdown_{$counter}";
            $counter++;
        } while (in_array($id, $ids));
    }
    // if
    $ids[] = $id;
    $params['id'] = $id;
    $optional = array_var($params, 'optional', false, true);
    $exclude = array_var($params, 'exclude', array(), true);
    if (!is_array($exclude)) {
        $exclude = array();
    }
    // if
    $can_create_new = array_var($params, 'can_create_new', true, true);
    if ($optional) {
        $options = array(option_tag(lang('-- None --'), ''), option_tag('', ''));
    } else {
        $options = array();
    }
    // if
    foreach ($companies as $company_id => $company_name) {
        if (in_array($company_id, $exclude)) {
            continue;
        }
        // if
        $option_attributes = array('class' => 'object_option');
        if ($value == $company_id) {
            $option_attributes['selected'] = true;
        }
        // if
        $options[] = option_tag($company_name, $company_id, $option_attributes);
    }
    // if
    if ($can_create_new) {
        $logged_user = get_logged_user();
        if (instance_of($logged_user, 'User') && Company::canAdd($logged_user)) {
            $params['add_object_url'] = assemble_url('people_companies_quick_add');
            $params['object_name'] = 'company';
            $params['add_object_message'] = lang('Please insert new company name');
            $options[] = option_tag('', '');
            $options[] = option_tag(lang('New Company...'), '', array('class' => 'new_object_option'));
        }
        // if
    }
    // if
    return select_box($options, $params) . '<script type="text/javascript">$("#' . $id . '").new_object_from_select();</script>';
}
 /**
 * Render form control
 *
 * @param string $control_name
 * @return string
 */
 function render($control_name) {
   $options = array();
   $actions_of_dashboard_controller = array_diff(get_class_methods('DashboardController'), get_class_methods('ApplicationController'));
  foreach ($actions_of_dashboard_controller as $action_name)
  {
    $option_attributes = $this->getValue() == $action_name ? array('select' => 'select') : null;
    $options[] = option_tag(lang("config option name dashboard action $action_name"), $action_name, $option_attributes);
  }
  return select_box($control_name, $options);
 } // render
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     foreach ($this->available_themes as $theme) {
         $option_attributes = $this->getValue() == $theme ? array('selected' => true) : null;
         $options[] = option_tag($theme, $theme, $option_attributes);
     }
     // foreach
     return select_box($control_name, $options);
 }
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     for ($dow = 1; $dow <= 7; $dow++) {
         $option_attributes = $this->getValue() == "{$dow}" ? array('selected' => 'selected') : null;
         $options[] = option_tag(lang('weekday full ' . $dow), "{$dow}", $option_attributes);
     }
     // for
     return select_box($control_name, $options);
 }
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     $option_attributes = $this->getValue() == 'move' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('drag drop move option'), 'move', $option_attributes);
     $option_attributes = $this->getValue() == 'keep' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('drag drop keep option'), 'keep', $option_attributes);
     $option_attributes = $this->getValue() == 'prompt' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('drag drop prompt option'), 'prompt', $option_attributes);
     return select_box($control_name, $options);
 }
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     $option_attributes = $this->getValue() == 'classify' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('mail drag drop classify option'), 'classify', $option_attributes);
     $option_attributes = $this->getValue() == 'dont' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('mail drag drop dont option'), 'dont', $option_attributes);
     $option_attributes = $this->getValue() == 'prompt' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('mail drag drop prompt option'), 'prompt', $option_attributes);
     return select_box($control_name, $options);
 }
 /**
  * Render form control
  *
  * @param string $control_name        	
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     $option_attributes = $this->getValue() == 'to' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('mail to'), 'to', $option_attributes);
     $option_attributes = $this->getValue() == 'cc' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('mail CC'), 'cc', $option_attributes);
     $option_attributes = $this->getValue() == 'bcc' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('mail BCC'), 'bcc', $option_attributes);
     return select_box($control_name, $options);
 }
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     $option_attributes = $this->getValue() == 'current' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('only in current member'), 'current', $option_attributes);
     $option_attributes = $this->getValue() == 'current_and_parents' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('only in current member and parents'), 'current_and_parents', $option_attributes);
     $option_attributes = $this->getValue() == 'all' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('all milestones'), 'all', $option_attributes);
     return select_box($control_name, $options);
 }
/**
 * Render select billable status field
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_billable_status($params, &$smarty)
{
    $statuses = array(BILLABLE_STATUS_NOT_BILLABLE => lang('Not Billable'), BILLABLE_STATUS_BILLABLE => lang('Billable'), BILLABLE_STATUS_PENDING_PAYMENT => lang('Pending Payment'), BILLABLE_STATUS_BILLED => lang('Billed'));
    $value = array_var($params, 'value', null, true);
    $options = array();
    foreach ($statuses as $status => $text) {
        $options[] = option_tag($text, $status, array('selected' => $value == $status));
    }
    // foreach
    return select_box($options, $params);
}
/**
 * Render select currency box
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_invoice_status($params, &$smarty)
{
    $possibilities = array(INVOICE_STATUS_DRAFT => lang('Draft'), INVOICE_STATUS_ISSUED => lang('Issued'), INVOICE_STATUS_BILLED => lang('Billled'), INVOICE_STATUS_CANCELED => lang('Canceled'));
    $value = array_var($params, 'value', NULL, True);
    $options = array();
    foreach ($possibilities as $k => $v) {
        $option_attributes = $k == $value ? array('selected' => True) : Null;
        $options[] = option_tag($v, $k, $option_attributes);
    }
    return select_box($options, $params);
}
 /**
  * Render form control
  *
  * @param string $control_name
  * @return string
  */
 function render($control_name)
 {
     $options = array();
     $option_attributes = $this->getValue() == 'always' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('show context help always'), 'always', $option_attributes);
     $option_attributes = $this->getValue() == 'never' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('show context help never'), 'never', $option_attributes);
     $option_attributes = $this->getValue() == 'until_close' ? array('selected' => 'selected') : null;
     $options[] = option_tag(lang('show context help until close'), 'until_close', $option_attributes);
     return select_box($control_name, $options);
 }
	/**
	 * Render form control
	 *
	 * @param string $control_name
	 * @return string
	 */
	function render($control_name, $default = null) {
		$options = array();
		if ($default){
			$options[] = option_tag($default['text'], $default['value'], array('selected' => true));
		}
		foreach($this->available_locales as $locale) {
			$option_attributes = $this->getValue() == $locale && !$default ? array('selected' => true) : null;
			$options[] = option_tag(get_language_name($locale), $locale, $option_attributes);
		} // foreach

		return select_box($control_name, $options);
	} // render
/**
 * Render select box for for Yes, No, Use Global
 * 
 * Parameters:
 * 
 * - all HTML attributes
 * - value - value of selected option
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_select_yes_no_none($params, &$smarty)
{
    $value = null;
    if (isset($params['value'])) {
        $value = (bool) array_var($params, 'value');
        unset($params['value']);
    }
    // if
    $options[] = option_tag(lang('Use Global Settings'), '', empty($value) ? array('selected' => true) : null);
    $options[] = option_tag(lang('No'), 0, $value == false ? array('selected' => true) : null);
    $options[] = option_tag(lang('Yes'), 1, $value == true ? array('selected' => true) : null);
    return select_box($options, $params);
}