/**
 * Build menu
 *
 * @param Menu $menu
 * @param User $user
 * @return array
 */
function documents_handle_on_build_menu(&$menu, &$user)
{
    if ($user->isAdministrator() || $user->getSystemPermission('can_use_documents')) {
        $menu->addToGroup(array(new MenuItem('documents', lang('Docs'), assemble_url('documents'), get_image_url('icon.gif', DOCUMENTS_MODULE))), 'main');
    }
    // if
}
/**
 * Show object visibility if it's private
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_object_visibility($params, &$smarty)
{
    static $ids = array();
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('object', $object, '$object is not valid instance of ProjectObject class', true);
    }
    // if
    if ($object->getVisibility() > VISIBILITY_PRIVATE) {
        return '';
    }
    // if
    $user = array_var($params, 'user');
    if (!instance_of($user, 'User')) {
        return new InvalidParamError('user', $user, '$user is expected to be an instance of User class', true);
    }
    // if
    if (!$user->canSeePrivate()) {
        return '';
    }
    // if
    $id = array_var($params, 'id');
    if (empty($id)) {
        do {
            $id = 'object_visibility_' . make_string(40);
        } while (in_array($id, $ids));
    }
    // if
    $ids[] = $id;
    return open_html_tag('a', array('href' => assemble_url('project_object_visibility', array('project_id' => $object->getProjectId(), 'object_id' => $object->getId())), 'title' => lang('Private :type', array('type' => Inflector::humanize($object->getType()))), 'class' => 'object_visibility', 'id' => $id)) . '<img src="' . get_image_url('private.gif') . '" alt="" /></a><script type="text/javascript">App.widgets.ObjectVisibility.init("' . $id . '");</script>';
}
/**
 * Add options to main menu
 *
 * @param Menu $menu
 * @param User $user
 * @return null
 */
function timetracking_handle_on_build_menu(&$menu, &$user)
{
    if ($user->isAdministrator() || $user->getSystemPermission('use_time_reports')) {
        $menu->addToGroup(array(new MenuItem('time', lang('Time'), 'https://www.healingcrystals.com/admin/timeSheets.php', get_image_url('navigation/time.gif'))), 'main');
    }
    // if
}
/**
 * Render star for a given user page
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_object_user_star($params, &$smarty)
{
    static $ids = array();
    $starred_user_id = array_var($params, 'starred_user_id');
    $starred_page_type = array_var($params, 'starred_page_type');
    $starred_by_user_id = array_var($params, 'starred_by_user_id');
    $project_id = array_var($params, 'project_id');
    $id = array_var($params, 'id');
    if (empty($id)) {
        do {
            $id = 'object_star_' . make_string(40);
        } while (in_array($id, $ids));
    }
    // if
    $ids[] = $id;
    $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
    mysql_select_db(DB_NAME, $link);
    $query = "select * from healingcrystals_starred_user_pages where starred_by_user_id='" . $starred_by_user_id . "' and starred_user_id='" . $starred_user_id . "' and starred_page_type='" . $starred_page_type . "'";
    $result = mysql_query($query);
    $is_starred = false;
    if (mysql_num_rows($result)) {
        $is_starred = true;
    }
    mysql_close($link);
    if ($is_starred) {
        $params = array('id' => $id, 'href' => assemble_url('unstar_user_' . $starred_page_type . '_page', array('project_id' => $project_id, 'user_id' => $starred_by_user_id)) . '&starred_user_id=' . $starred_user_id, 'title' => lang('Unstar this object'), 'class' => 'object_star');
        $result = open_html_tag('a', $params) . '<img src="' . get_image_url('icons/star-small.gif') . '" alt="" /></a>';
    } else {
        $params = array('id' => $id, 'href' => assemble_url('star_user_' . $starred_page_type . '_page', array('project_id' => $project_id, 'user_id' => $starred_by_user_id)) . '&starred_user_id=' . $starred_user_id, 'title' => lang('Star this object'), 'class' => 'object_star');
        $result = open_html_tag('a', $params) . '<img src="' . get_image_url('icons/unstar-small.gif') . '" alt="" /></a>';
    }
    // if
    return $result . "\n<script type=\"text/javascript\">App.layout.init_star_unstar_link('" . $id . "')</script>";
}
/**
 * Handle on_company_options event
 *
 * @param Company $company
 * @param NamedList $options
 * @param User $logged_user
 * @return null
 */
function invoicing_handle_on_company_options(&$company, &$options, &$logged_user)
{
    if (Invoice::canAccessCompanyInvoices($logged_user, $company)) {
        $options->add('invoices', array('text' => lang('Invoices'), 'url' => assemble_url('people_company_invoices', array('company_id' => $company->getId())), 'icon' => get_image_url('company-invoices.gif', INVOICING_MODULE)));
    }
    // if
}
Example #6
0
 public function ckUpload()
 {
     $funcNum = $this->input->get_post('CKEditorFuncNum');
     $thumbimage_config = $this->config->item('thumbimage');
     $widths = $thumbimage_config['thumb_width'];
     // 需要处理的图片宽度尺寸
     $heights = $thumbimage_config['thumb_height'];
     // 需要处理的图片高度尺寸
     $path = '/uploads/ck/';
     $config['upload_path'] = '.' . $path;
     $config['allowed_types'] = 'gif|jpg|png';
     $config['max_size'] = '2048';
     $config['max_width'] = '0';
     $config['max_height'] = '0';
     $config['encrypt_name'] = TRUE;
     //检查并创建目录
     create_folders($config['upload_path']);
     $this->load->library('upload', $config);
     $field_name = "upload";
     if (!$this->upload->do_upload($field_name)) {
         $message = $this->upload->display_errors();
     } else {
         $upload_data = $this->upload->data();
         $url = get_image_url($path . $upload_data['file_name']);
     }
     echo "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction({$funcNum}, '{$url}', '{$message}');</script>";
 }
function system_handle_on_build_menu(&$menu, &$user, &$project = null)
{
    //EOF:task_1260
    // ---------------------------------------------------
    //  Tools
    // ---------------------------------------------------
    //BOF:task_1260
    /*if (is_null($project)){
      	$my_tickets_menu = new MenuItem('today', lang('My Tickets'), assemble_url('user_today_page'), get_image_url('navigation/today.png'));
      } else {
      	$my_tickets_menu = new MenuItem('today', lang('My Tickets'), assemble_url('project_user_today_page', array('project_id' => $project->getId(), 'user_id' => $user->getId())), get_image_url('navigation/today.png'));
      }*/
    //EOF:task_1260
    $menu->addToGroup(array(new MenuItem('tasks', lang('My Tasks'), assemble_url('goto_user_task_page', array('project_id' => TASK_LIST_PROJECT_ID)) . '&selected_user_id=' . $user->getId(), get_image_url('navigation/today.png')), new MenuItem('calendar', lang('Calendar'), Calendar::getDashboardCalendarUrl(), get_image_url('navigation/calendar.gif')), new MenuItem('projects', lang('Projects'), assemble_url('projects'), get_image_url('navigation/projects.gif')), new MenuItem('people', lang('People'), assemble_url('people'), get_image_url('navigation/people.gif'))), 'main');
    // ---------------------------------------------------
    //  Folders
    // ---------------------------------------------------
    $folders = array(new MenuItem('search', lang('Search'), assemble_url('quick_search'), get_image_url('navigation/search.gif')), new MenuItem('starred_folder', lang('Starred'), assemble_url('starred'), get_image_url('navigation/starred.gif')));
    if ($user->isAdministrator() || $user->getSystemPermission('manage_trash')) {
        $folders[] = new MenuItem('trash', lang('Trash'), assemble_url('trash'), get_image_url('navigation/trash.gif'));
    }
    // if
    $folders[] = new MenuItem('quick_add', lang('Quick Add'), assemble_url('homepage'), get_image_url('navigation/quick_add.gif'), null, '+');
    $menu->addToGroup($folders, 'folders');
}
/**
 * Build menu
 *
 * @param Menu $menu
 * @param User $user
 * @return array
 */
function incoming_mail_handle_on_build_menu(&$menu, &$user)
{
    if (($user->isAdministrator() || $user->getSystemPermission('can_use_incoming_mail_frontend')) && ($count_pending = IncomingMails::countPending()) > 0) {
        $menu->addToGroup(array(new MenuItem('incoming_mail', lang('Inbox'), assemble_url('incoming_mail'), get_image_url('icon_menu.gif', INCOMING_MAIL_MODULE), $count_pending)), 'main');
    }
    // if
}
/**
 * Handle on_dashboard_important_section event
 *
 * @param NamedList $items
 * @param User $user
 * @return null
 */
function resources_handle_on_dashboard_important_section(&$items, &$user)
{
    if ($reminders_count = Reminders::countActiveByUser($user)) {
        $items->add('reminders', array('label' => $reminders_count > 1 ? lang('<strong>:count</strong>&nbsp;reminders', array('count' => $reminders_count)) : lang('<strong>:count</strong>&nbsp;reminder', array('count' => $reminders_count)), 'class' => 'reminders', 'icon' => get_image_url('important.gif'), 'url' => assemble_url('reminders')));
    }
    // if
}
/**
 * Return array of options $logged_user can do to $user account
 *
 * @param User $user
 * @param NamedList $options
 * @param User $logged_user
 * @return null
 */
function calendar_handle_on_user_options(&$user, &$options, &$logged_user)
{
    if (can_access_profile_calendar($logged_user, $user)) {
        $options->add('calendar', array('text' => lang('Schedule'), 'icon' => get_image_url('gray-calendar.gif'), 'url' => Calendar::getProfileCalendarUrl($user)));
    }
    // if
}
/**
 * on_time_report_footer_options event handler implementation
 *
 * @param TimeReport $report
 * @param array $options
 * @param Project $project
 * @param User $user
 * @return null
 */
function invoicing_handle_on_time_report_footer_options(&$report, &$options, &$project, &$user)
{
    if (Invoice::canAdd($user)) {
        $options[] = array('url' => instance_of($project, 'Project') ? assemble_url('invoices_add', array('time_report_id' => $report->getId(), 'project_id' => $project->getId())) : assemble_url('invoices_add', array('time_report_id' => $report->getId())), 'text' => lang('New Invoice'), 'icon' => get_image_url('create-invoice.gif', INVOICING_MODULE));
    }
    // if
}
Example #12
0
 public function getGoodsList($Page, $where)
 {
     $goods = $this->where($where)->order('`sort` DESC,goods_id DESC')->limit($Page->firstRow . ',' . $Page->listRows)->select();
     foreach ($goods as $k => $v) {
         $goods[$k]['pic_url'] = get_image_url($v['pic_url']);
     }
     return $goods;
 }
/**
 * Build menu
 *
 * @param Menu $menu
 * @param User $user
 * @return array
 */
function status_handle_on_build_menu(&$menu, &$user)
{
    if ($user->isAdministrator() || $user->getSystemPermission('can_use_status_updates')) {
        $last_visit = UserConfigOptions::getValue('status_update_last_visited', $user);
        $menu->addToGroup(array(new MenuItem('status', lang('Status'), assemble_url('status_updates'), get_image_url('icon_menu.gif', STATUS_MODULE), StatusUpdates::countNewMessagesForUser($user, $last_visit))), 'main');
    }
    // if
}
Example #14
0
function shortcode_gallery($atts)
{
    $ids = explode(',', $atts['ids']);
    $pairs = [];
    foreach ($ids as $id) {
        $pairs[get_image_url($id)] = get_image_url($id, 'large');
    }
    return renderLatteToString(__DIR__ . '/gallery.latte', ['pairs' => $pairs]);
}
/**
 * Render snooze task reminder widget
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_snooze_task_reminder($params, &$smarty)
{
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('$object', $object, '$object is expected to be a valid instance of ProjectObject class');
    }
    // if
    return '<span class="option"><a href="' . assemble_url('project_task_snoozereminder', array('project_id' => $object->getProjectId(), 'task_id' => $object->getId())) . '" onclick="javascript:return false;"><img id="snooze_' . $object->getId() . '" src="' . get_image_url('gray-clock-small.gif') . '" alt="Snooze Reminder" title="Snooze Reminder" /></a></span>';
}
Example #16
0
 public function hotGoods($cateId, $limit = 8)
 {
     $where = array('cate_id' => $cateId);
     $res = $this->where($where)->order('hits DESC,goods_id DESC')->limit($limit)->select();
     foreach ($res as $k => $v) {
         $res[$k]['pic_url'] = get_image_url($res[$k]['pic_url']);
     }
     return $res;
 }
Example #17
0
/**
 * Returns company invoicing logo url
 * 
 * @param void
 * @return null
 */
function get_company_invoicing_logo_url()
{
    $logo = get_company_invoicing_logo_path();
    if (is_file($logo)) {
        return URL_BASE == ROOT_URL . '/' ? ROOT_URL . '/public/brand/invoicing_logo.jpg' : ROOT_URL . '/brand/invoicing_logo.jpg';
    } else {
        return get_image_url('default-invoice-logo.gif', INVOICING_MODULE);
    }
    // if
}
Example #18
0
function image($size = 'regular', $class_list = '')
{
    $url = get_image_url('size-' . $size);
    $url_hq = get_image_url('size-' . $size . '-hq');
    if (!$url) {
        return;
    }
    $class_list = $class_list ? 'class="' . $class_list . '"' : '';
    echo '<img ' . $class_list . ' src="' . $url . '" srcset="' . $url_hq . ' 2x" alt="">';
}
/**
 * Handle on_dashboard_important_section event
 *
 * @param NamedList $items
 * @param User $user
 * @return null
 */
function invoicing_handle_on_dashboard_important_section(&$items, &$user)
{
    $company = $user->getCompany();
    // if user can manage invoices, list overdue invoices for all companies
    if ($user->getSystemPermission('can_manage_invoices')) {
        // if it's administrator list only overdue invoices
        if (($admin_overdue_invoices = Invoices::countOverdue()) > 0) {
            $items->add('admin_overdue_invoices', array('label' => $admin_overdue_invoices > 1 ? lang('<strong>:count</strong> overdue invoices for all companies', array('count' => $admin_overdue_invoices)) : lang('<strong>:count</strong> overdue invoice for all companies', array('count' => $admin_overdue_invoices)), 'class' => 'adminoverdue_invoices', 'icon' => get_image_url('important.gif'), 'url' => assemble_url('invoices')));
        }
        // if
    }
    // if
    // if user is company manager or can manage invoices show outstanding and overdue invoices for his company
    if ($user->isCompanyManager($company) || $user->getSystemPermission('can_manage_invoices')) {
        //
        // Outstanding Invoices
        //
        $issued_invoices_count = Invoices::countOutstanding($company);
        if ($issued_invoices_count > 0) {
            if ($issued_invoices_count == 1) {
                // if there is only one outstanding invoice, then link should open that very same invoice
                $issued_invoices = Invoices::findOutstanding($company, array(INVOICE_STATUS_ISSUED));
                $link_url = $issued_invoices[0]->getCompanyViewUrl();
                $label = lang('<strong>1</strong> outstanding invoice for your company');
            } else {
                // if there is multuple outstanding invoices, then link should open company invoices pages
                $link_url = assemble_url('people_company_invoices', array('company_id' => $company->getId()));
                $label = lang('<strong>:count</strong> outstanding invoices for your company', array('count' => $issued_invoices_count));
            }
            // if
            $items->add('issued_invoices', array('label' => $label, 'class' => 'issued_invoices', 'icon' => get_image_url('icon_small.gif', INVOICING_MODULE), 'url' => $link_url));
        }
        // if
        //
        // Overdue Invoices
        //
        $overdue_invoices_count = Invoices::countOverdue($company);
        if ($overdue_invoices_count > 0) {
            if ($overdue_invoices_count == 1) {
                // if there is only one overdue invoice, then link should open that very same invoice
                $overdue_invoices = Invoices::findOverdue($company, array(INVOICE_STATUS_ISSUED));
                $link_url = $overdue_invoices[0]->getCompanyViewUrl();
                $label = lang('<strong>1</strong> overdue invoice for your company');
            } else {
                // if there is multuple overdue invoices, then link should open company invoices pages
                $link_url = assemble_url('people_company_invoices', array('company_id' => $company->getId()));
                $label = lang('<strong>:count</strong> overdue invoices for your company', array('count' => $overdue_invoices));
            }
            // if
            $items->add('overdue_invoices', array('label' => $label, 'class' => 'overdue_invoices', 'icon' => get_image_url('important.gif'), 'url' => $link_url));
        }
        // if
    }
    // if
}
Example #20
0
 /**
  * カウンタ画像データ配列を取得する
  *
  * @param	array	$counter	カウンタデータ配列
  * @return	array	カウンタ画像データ配列
  * @access	public
  */
 function getImgSrcs($counter)
 {
     $imgPath = get_image_url() . "/images/counter/common/" . $counter["show_type"] . "/";
     $strNum = sprintf("%0" . $counter["counter_digit"] . "d", $counter["counter_num"]);
     $imgSrcs = array();
     for ($i = 0; $i < strlen($strNum); $i++) {
         $n = substr($strNum, $i, 1);
         $imgSrcs[] = $imgPath . $n . ".gif";
     }
     return $imgSrcs;
 }
 /**
  * Index page action
  * 
  * @param void
  * @return void
  */
 function index()
 {
     $page = (int) $this->request->get('page');
     if ($page < 1) {
         $page = 1;
     }
     // if
     $per_page = 10;
     list($documents, $pagination) = Documents::paginateDocuments($this->logged_user->getVisibility(), $page, $per_page);
     $this->smarty->assign(array('documents' => $documents, 'pagination' => $pagination));
     js_assign(array('pin_icon_url' => get_image_url('icons/pinned.16x16.gif'), 'unpin_icon_url' => get_image_url('icons/not-pinned.16x16.gif')));
 }
/**
 * Add options to main menu
 *
 * @param Menu $menu
 * @param User $user
 * @return null
 */
function invoicing_handle_on_build_menu(&$menu, &$user)
{
    $company = $user->getCompany();
    if ($user->getSystemPermission('can_manage_invoices')) {
        $menu->addToGroup(array(new MenuItem('invoicing', lang('Invoices'), assemble_url('invoices'), get_image_url('menu-icon.gif', INVOICING_MODULE), Invoices::countOverdue())), 'main');
    } else {
        if ($user->isCompanyManager($company)) {
            $menu->addToGroup(array(new MenuItem('invoicing', lang('Invoices'), assemble_url('people_company_invoices', array('company_id' => $user->getCompanyId())), get_image_url('menu-icon.gif', INVOICING_MODULE), Invoices::countByCompany($user->getCompany(), array(INVOICE_STATUS_ISSUED)))), 'main');
        }
    }
    // if
}
/**
 * Add system admin tools sections
 *
 * @param array $sections
 * @return null
 */
function system_handle_on_admin_sections(&$sections)
{
    $sections[ADMIN_SECTION_SYSTEM][SYSTEM_MODULE] = array(array('name' => lang('General'), 'description' => lang('General activeCollab settings'), 'url' => assemble_url('admin_settings_general'), 'icon' => get_image_url('settings/general.gif', SYSTEM_MODULE)), array('name' => lang('Modules'), 'description' => lang('Module administration tool. You can use it to install/uninstall modules, configure them and so on'), 'url' => assemble_url('admin_modules'), 'icon' => get_image_url('admin/modules.gif')), array('name' => lang('Roles'), 'description' => lang('Roles administration tool. Use it to configure system level permissions for users of the system'), 'url' => assemble_url('admin_roles'), 'icon' => get_image_url('admin/roles.gif')), array('name' => lang('Date and Time'), 'description' => lang('Set system timezone, daylight saving time, first day of the week etc'), 'url' => assemble_url('admin_settings_date_time'), 'icon' => get_image_url('settings/date_time.gif', SYSTEM_MODULE)), array('name' => lang('Master Categories'), 'description' => lang('Manage default categories that are added when new project is created'), 'url' => assemble_url('admin_settings_categories'), 'icon' => get_image_url('settings/categories.gif', SYSTEM_MODULE)), array('name' => lang('Maintenance Mode'), 'description' => lang('Put system in maintenance mode'), 'url' => assemble_url('admin_settings_maintenance'), 'icon' => get_image_url('admin/maintenance.gif')));
    if (LOCALIZATION_ENABLED) {
        $sections[ADMIN_SECTION_SYSTEM][SYSTEM_MODULE][] = array('name' => lang('Languages'), 'description' => lang('Tools for managing available languages and translations'), 'url' => assemble_url('admin_languages'), 'icon' => get_image_url('admin/languages.gif'));
    }
    // if
    $sections[ADMIN_SECTION_MAIL][SYSTEM_MODULE] = array(array('name' => lang('Mailing'), 'description' => lang('Set up how activeCollab will send emails - you can use your default PHP settings or SMTP server'), 'url' => assemble_url('admin_settings_mailing'), 'icon' => get_image_url('settings/mailing.gif', SYSTEM_MODULE)), array('name' => lang('Email Templates'), 'description' => lang('Browse and change email templates that are used to generate emails that users receive as notifications'), 'url' => assemble_url('admin_settings_email_templates'), 'icon' => get_image_url('settings/email_templates.gif', SYSTEM_MODULE)), array('name' => lang('Test Mail Settings'), 'description' => lang('Use this simple tool to send test emails to check if activeCollab mailer is well configured'), 'url' => assemble_url('admin_tools_test_email'), 'icon' => get_image_url('tools/test_mail_settings.gif', SYSTEM_MODULE)));
    if (MASS_MAILER_ENABLED) {
        $sections[ADMIN_SECTION_MAIL][SYSTEM_MODULE][] = array('name' => lang('Mass Mailer'), 'description' => lang('Simple tool that let you send plain text messages to any group of users registered to the system'), 'url' => assemble_url('admin_tools_mass_mailer'), 'icon' => get_image_url('tools/mass_mailer.gif', SYSTEM_MODULE));
    }
    // if
    $sections[ADMIN_SECTION_TOOLS][SYSTEM_MODULE] = array(array('name' => lang('Scheduled Tasks'), 'description' => lang('Log of scheduled tasks last activity time'), 'url' => assemble_url('admin_other_scheduled_tasks'), 'icon' => get_image_url('admin/scheduled-tasks.gif')));
}
Example #24
0
function add_shortcode_clients($atts)
{
    extract(shortcode_atts(array('id' => ''), $atts));
    $output = '';
    $images = tf_get_gallery_images($id);
    $output .= '<ul class="partners">';
    foreach ($images as $image) {
        $output .= "<li>";
        $output .= "<a title='" . $image['title'] . "'>";
        $output .= "<img class='' src='" . theme_resize(get_image_url($image['id']), 145, 60, false) . "'/>";
        $output .= "</a>";
        $output .= "</li>";
    }
    $output .= '</ul>';
    return $output;
}
Example #25
0
function action_link($url, $img_path, $label, $class = null, $link_attributes = array())
{
    $localized_label = lang($label);
    ?>
  <a
    href="<?php 
    echo $url;
    ?>
"
    <?php 
    if (!is_null($class)) {
        ?>
    class="<?php 
        echo $class;
        ?>
"
    <?php 
    }
    ?>
    <?php 
    foreach ($link_attributes as $name => $value) {
        echo $name . '="' . $value . '"';
    }
    ?>
  >
    <img
      title="<?php 
    echo $localized_label;
    ?>
"
      src="<?php 
    echo get_image_url($img_path);
    ?>
"
      height="12"
      alt="<?php 
    echo $localized_label;
    ?>
"
      />
  </a>
<?php 
}
Example #26
0
 function handle_upload()
 {
     //get image
     $upload_key = $this->viewstate['upload_key'];
     $image_que = factory::create('image_que');
     if (isset($_FILES['Filedata']) && $_FILES['Filedata']['name'] != '' && isset($upload_key) && $upload_key != '') {
         $temp_file = $this->upload_image('Filedata');
         if ($temp_file !== false) {
             $image_que->upload_key = $upload_key;
             $image_que->save_image($temp_file);
             $image_que->insert();
         }
     }
     header("Content-type: application/json; charset=utf-8");
     if ($this->validate()) {
         print json_encode(array("success" => true, "image_key" => $image_que->image_key, "image_url" => get_image_url('s', $image_que->image_key)));
     } else {
         print json_encode(array("success" => false, "warnings" => $this->warnings));
     }
 }
Example #27
0
function get_item_image_data($name, $size)
{
    global $mtdata;
    $data = array();
    if ($groupname = is_group($name)) {
        $group = $mtdata['groups'][$groupname];
        prepare_images($group['image_item']);
        $data['group'] = true;
        $data['src'] = get_image_url($group['image_item'], $size);
        $data['alt'] = 'Group ' . $groupname;
        $data['itemlink'] = url_group($groupname);
    } else {
        $item = $mtdata['items'][$name];
        prepare_images($item);
        $data['group'] = false;
        $data['src'] = get_image_url($item, $size);
        $data['alt'] = $item['description'];
        $data['itemlink'] = url_item($name);
    }
    return $data;
}
/**
 * Render pin/unpin icon
 * 
 * Parameters:
 * 
 * - project - Selected project
 * - user - Check pinned state agains this user
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_project_pinned($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
    $user = array_var($params, 'user');
    if (!instance_of($user, 'User')) {
        return new InvalidParamError('user', $user, '$user is expected to be an instance of User class', true);
    }
    // if
    require_once SMARTY_PATH . '/plugins/block.link.php';
    $repeat = false;
    if (PinnedProjects::isPinned($project, $user)) {
        return smarty_block_link(array('href' => $project->getUnpinUrl(), 'title' => lang('Unpin'), 'class' => lang('unpin'), 'method' => 'post'), '<img src="' . get_image_url('icons/pinned.16x16.gif') . '" alt="" />', $smarty, $repeat);
    } else {
        return smarty_block_link(array('href' => $project->getPinUrl(), 'title' => lang('Pin to Top'), 'class' => lang('pin_to_top'), 'method' => 'post'), '<img src="' . get_image_url('icons/not-pinned.16x16.gif') . '" alt="" />', $smarty, $repeat);
    }
    // if
}
/**
 * Render object time widget
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_object_time($params, &$smarty)
{
    if (!module_loaded('timetracking')) {
        return '';
    }
    // if
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('$object', $object, '$object is expected to be a valid instance of ProjectObject class');
    }
    // if
    $show_time = '';
    $additional_class = '';
    if (array_var($params, 'show_time', true)) {
        $object_time = TimeRecords::sumObjectTime($object);
        if ($object->can_have_tasks) {
            $tasks_time = TimeRecords::sumTasksTime($object);
        } else {
            $tasks_time = 0;
        }
        // if
        $additional_class = 'with_text';
        $total_time = $object_time + $tasks_time;
        if ($object_time == 0 && $tasks_time == 0) {
            $show_time = '<span class="time_widget_text">' . lang('No time tracked') . '</span> ';
        } elseif ($tasks_time == 0) {
            $show_time = '<span class="time_widget_text">' . lang(':total hours logged', array('total' => float_format($total_time, 2))) . '</span> ';
        } else {
            $show_time = '<span class="time_widget_text">' . lang(':total hours logged - :object_time for the ticket and :tasks_time for tasks', array('type' => $object->getVerboseType(true), 'total' => float_format($total_time, 2), 'object_time' => float_format($object_time, 2), 'tasks_time' => float_format($tasks_time, 2))) . '</span> ';
        }
        // if
    }
    // if
    $wrapper_id = 'object_time_widget_' . $object->getId();
    $image_url = $object->getHasTime() ? get_image_url('clock-small.gif') : get_image_url('gray-clock-small.gif');
    return '<span id="' . $wrapper_id . '" class="time_popup_widget ' . $additional_class . '">' . $show_time . '<a href="' . $object->getTimeUrl() . '" title="' . lang('Time') . '"><img src="' . $image_url . '" alt="" /></a></span><script type="text/javascript">App.TimePopup.init("' . $wrapper_id . '")</script>';
}
/**
 * Render object subscriptions icon and link
 * 
 * Params:
 * 
 * - object - Object user needs to be subscribed to
 * - user - User who is subscribed, if not set logged user is used
 *
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_object_subscription($params, &$smarty)
{
    $object = array_var($params, 'object');
    if (!instance_of($object, 'ProjectObject')) {
        return new InvalidParamError('$object', $object, '$object is expected to be a valid instance of ProjectObject class', true);
    }
    // if
    $user = array_var($params, 'user');
    if (!instance_of($user, 'User')) {
        return new InvalidParamError('$user', $user, '$user is expected to be a valid instance of User class', true);
    }
    // if
    $render_wrapper = (bool) array_var($params, 'render_wrapper', true);
    $wrapper_id = 'object_subscription_widget_' . $object->getId() . '_user_' . $user->getId();
    require_once SMARTY_PATH . '/plugins/block.link.php';
    if (Subscriptions::isSubscribed($user, $object)) {
        $content = '<a href="' . $object->getUnsubscribeUrl($user) . '" title="' . lang('Click to unsubscribe') . '"><img src="' . get_image_url('subscribe-small.gif') . '" alt="" /></a>';
    } else {
        $content = '<a href="' . $object->getSubscribeUrl($user) . '" title="' . lang('Click to subscribe') . '"><img src="' . get_image_url('gray-subscribe-small.gif') . '" alt="" /></a>';
    }
    // if
    $content .= '<script type="text/javascript">App.layout.init_subscribe_unsubscribe_link("' . $wrapper_id . '")</script>';
    return $render_wrapper ? '<span id="' . $wrapper_id . '">' . $content . '</span>' : $content;
}