/** * 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>'; }
/** * Construct company invoices controller * * @param Request $request * @return CompanyInvoicesController */ function __construct($request) { parent::__construct($request); if (!Invoice::canAccessCompanyInvoices($this->logged_user, $this->active_company)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $this->wireframe->current_menu_item = 'invoicing'; $this->wireframe->page_actions = array(); $this->wireframe->addBreadCrumb(lang('Invoices'), assemble_url('people_company_invoices', array('company_id' => $this->active_company->getId()))); $invoice_id = $this->request->getId('invoice_id'); if ($invoice_id) { $this->active_invoice = Invoices::findById($invoice_id); } // if if (instance_of($this->active_invoice, 'Invoice')) { if ($this->active_invoice->getCompanyId() != $this->active_company->getId()) { $this->httpError(HTTP_ERR_CONFLICT); } // if $this->wireframe->addBreadCrumb($this->active_invoice->getName(), $this->active_invoice->getCompanyViewUrl()); } else { $this->active_invoice = new Invoice(); } // if $this->smarty->assign(array('active_invoice' => $this->active_invoice, 'page_tab' => 'invoices')); js_assign('invoicing_precision', INVOICE_PRECISION); }
/** * 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 }
/** * 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 }
/** * 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 }
/** * 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> reminders', array('count' => $reminders_count)) : lang('<strong>:count</strong> reminder', array('count' => $reminders_count)), 'class' => 'reminders', 'icon' => get_image_url('important.gif'), 'url' => assemble_url('reminders'))); } // if }
/** * Render object assignees list * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_object_owner($params, &$smarty) { $object = array_var($params, 'object'); if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true); } // if $users_table = TABLE_PREFIX . 'users'; $assignments_table = TABLE_PREFIX . 'assignments'; $rows = db_execute_all("SELECT {$assignments_table}.is_owner AS is_assignment_owner, {$users_table}.id AS user_id, {$users_table}.company_id, {$users_table}.first_name, {$users_table}.last_name, {$users_table}.email FROM {$users_table}, {$assignments_table} WHERE {$users_table}.id = {$assignments_table}.user_id AND {$assignments_table}.object_id = ? and {$assignments_table}.is_owner='1' ORDER BY {$assignments_table}.is_owner DESC", $object->getId()); if (is_foreachable($rows)) { $owner = null; foreach ($rows as $row) { if (empty($row['first_name']) && empty($row['last_name'])) { $user_link = '<a href="' . assemble_url('people_company', array('company_id' => $row['company_id'])) . '#user' . $row['user_id'] . '">' . clean($row['email']) . '</a>'; } else { $user_link = '<a href="' . assemble_url('people_company', array('company_id' => $row['company_id'])) . '#user' . $row['user_id'] . '">' . clean($row['first_name']) . '</a>'; } // if $owner .= $user_link . ' '; } // foreach } // if if (empty($owner)) { $owner = '--'; } // if return $owner; }
/** * Handle on project options event * * @param NamedList $options * @param Project $project * @param User $user * @return null */ function project_exporter_handle_on_project_options(&$options, $project, $user) { if ($user->isAdministrator() || $user->isProjectLeader($project) || $user->isProjectManager()) { $options->add('export_project', array('url' => assemble_url('project_exporter', array('project_id' => $project->getId())), 'text' => lang('Export Project'))); } // }
/** * Contruct time report controller * * @param Request $request * @return ProjectTimeReportsController */ function __construct($request) { parent::__construct($request); if (!$this->logged_user->isAdministrator() && !$this->logged_user->getSystemPermission('use_time_reports')) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if $this->wireframe->addBreadCrumb(lang('Reports'), timetracking_module_reports_url($this->active_project)); $report_id = $this->request->getId('report_id'); if ($report_id) { $this->active_report = TimeReports::findById($report_id); } // if if (instance_of($this->active_report, 'TimeReport')) { $this->wireframe->addBreadCrumb($this->active_report->getName(), $this->active_report->getUrl()); } else { $this->active_report = new TimeReport(); } // if $this->wireframe->page_actions = array(); if (TimeReport::canAdd($this->logged_user)) { $this->wireframe->addPageAction(lang('New Report'), assemble_url('global_time_report_add', array('project_id' => $this->active_project->getId()))); } // if $this->smarty->assign('active_report', $this->active_report); }
/** * Render object assignees list * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_object_departments($params, &$smarty) { $resp = '--'; $object = array_var($params, 'object'); if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true); } // if $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME, $link); $query = "select a.category_name, a.id from \n\t\t\t healingcrystals_project_milestone_categories a \n\t\t\t inner join healingcrystals_project_object_categories b on b.category_id=a.id \n\t\t\t inner join healingcrystals_project_objects c on c.id=b.object_id where \n\t\t\t c.id='" . $object->getId() . "' order by a.category_name"; $result = mysql_query($query, $link); if (mysql_num_rows($result)) { $resp = ''; while ($info = mysql_fetch_assoc($result)) { if (instance_of($object, 'Milestone')) { $resp .= '<a href="' . assemble_url('project_milestones', array('project_id' => $object->getProjectId())) . '&category_id=' . $info['id'] . '">' . $info['category_name'] . '</a>, '; } elseif (instance_of($object, 'Ticket')) { $resp .= '<a href="' . assemble_url('project_tickets', array('project_id' => $object->getProjectId())) . '&department_id=' . $info['id'] . '">' . $info['category_name'] . '</a>, '; } elseif (instance_of($object, 'Page')) { $resp .= '<a href="' . assemble_url('project_pages', array('project_id' => $object->getProjectId())) . '&category_id=' . $info['id'] . '">' . $info['category_name'] . '</a>, '; } else { $resp .= $info['category_name'] . ', '; } } $resp = substr($resp, 0, -2); } mysql_close($link); return $resp; }
/** * Settings form * * @param void * @return null */ function index() { js_assign('test_svn_url', assemble_url('admin_source_test_svn')); $source_data = $this->request->post('source'); if (!is_foreachable($source_data)) { $source_data = array('svn_path' => ConfigOptions::getValue('source_svn_path'), 'svn_config_dir' => ConfigOptions::getValue('source_svn_config_dir'), 'source_svn_use_output_redirect' => ConfigOptions::getValue('source_svn_use_output_redirect'), 'source_svn_trust_server_cert' => ConfigOptions::getValue('source_svn_trust_server_cert')); } // if if ($this->request->isSubmitted()) { $svn_path = array_var($source_data, 'svn_path', null); $svn_path = $svn_path ? with_slash($svn_path) : null; ConfigOptions::setValue('source_svn_path', $svn_path); $svn_config_dir = array_var($source_data, 'svn_config_dir') == '' ? null : array_var($source_data, 'svn_config_dir'); ConfigOptions::setValue('source_svn_config_dir', $svn_config_dir); $svn_use_output_redirection = array_var($source_data, 'source_svn_use_output_redirect') == "1"; ConfigOptions::setValue('source_svn_use_output_redirect', $svn_use_output_redirection); $svn_trust_server_certificate = array_var($source_data, 'source_svn_trust_server_cert') == "1"; ConfigOptions::setValue('source_svn_trust_server_cert', $svn_trust_server_certificate); flash_success("Source settings successfully saved"); $this->redirectTo('admin_source'); } // if if (!RepositoryEngine::executableExists()) { $this->wireframe->addPageMessage(lang("SVN executable not found. You won't be able to use this module"), 'error'); } // if $this->smarty->assign(array('source_data' => $source_data)); }
/** * Render object subscribers * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_object_subscriptions($params, &$smarty) { $object = array_var($params, 'object'); if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true); } // if js_assign('max_subscribers_count', MAX_SUBSCRIBERS_COUNT); require_once SYSTEM_MODULE_PATH . '/helpers/function.user_link.php'; $subscribers = $object->getSubscribers(); if (count($subscribers) > MAX_SUBSCRIBERS_COUNT) { $smarty->assign(array('_object_subscriptions_list_subscribers' => false, '_object_subscriptions_object' => $object, '_object_subscriptions_subscribers_count' => count($subscribers), '_object_subscription_brief' => array_var($params, 'brief', false), '_object_subscriptions_popup_url' => assemble_url('object_subscribers_widget', array('object_id' => $object->getId())))); } else { $links = null; if (is_foreachable($subscribers)) { $links = array(); foreach ($subscribers as $subscriber) { $links[] = smarty_function_user_link(array('user' => $subscriber), $smarty); } // foreach } // if $smarty->assign(array('_object_subscriptions_list_subscribers' => true, '_object_subscriptions' => $subscribers, '_object_subscriptions_object' => $object, '_object_subscription_links' => $links, '_object_subscription_brief' => array_var($params, 'brief', false), '_object_subscriptions_popup_url' => assemble_url('object_subscribers_widget', array('object_id' => $object->getId())))); } // if return $smarty->fetch(get_template_path('_object_subscriptions', 'subscriptions', RESOURCES_MODULE)); }
/** * 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 }
/** * 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>"; }
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'); }
/** * Constructor * * @param Request $request * @return CompanyProfileController */ function __construct($request) { parent::__construct($request); $company_id = $this->request->getId('company_id'); if ($company_id) { $this->active_company = Companies::findById($company_id); } // if if (instance_of($this->active_company, 'Company')) { $this->wireframe->page_actions = array(); if (!$this->active_company->canView($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if if ($this->active_company->getIsArchived() && $this->logged_user->isPeopleManager()) { $this->wireframe->addBreadCrumb(lang('Archive'), assemble_url('people_archive')); } // if $this->wireframe->addBreadCrumb($this->active_company->getName(), $this->active_company->getViewUrl()); // Collect company tabs $tabs = new NamedList(); $tabs->add('overview', array('text' => str_excerpt($this->active_company->getName(), 25), 'url' => $this->active_company->getViewUrl())); $tabs->add('people', array('text' => lang('People'), 'url' => $this->active_company->getViewUrl())); $tabs->add('projects', array('text' => lang('Projects'), 'url' => $this->active_company->getViewUrl())); event_trigger('on_company_tabs', array(&$tabs, &$this->logged_user, &$this->active_company)); $this->smarty->assign(array('company_tabs' => $tabs, 'company_tab' => 'overview')); } else { $this->active_company = new Company(); } // if $this->smarty->assign(array('active_company' => $this->active_company)); }
/** * 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 }
/** * Handle on prepare project overview event * * @param NamedList $tabs * @param User $logged_user * @param Project $project * @return null */ function files_handle_on_project_tabs(&$tabs, &$logged_user, &$project) { $tabs->add('attachments', array('text' => lang('Attachments'), 'url' => assemble_url('attachments_list', array('project_id' => $project->getId())))); if ($logged_user->getProjectPermission('file', $project) >= PROJECT_PERMISSION_ACCESS) { $tabs->add('files', array('text' => lang('Files'), 'url' => files_module_url($project))); } // if }
/** * Returns url that toggles object completed state * * @param ProjectObject $object * @return string */ function mobile_access_module_get_task_toggle_url(&$object) { if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true); } // if return assemble_url('mobile_access_toggle_object_completed_status', array("project_id" => $object->getProjectId(), "object_id" => $object->getId())); }
/** * Return upload files URL * * @param Project $project * @param Category $category * @return string */ function files_module_upload_url($project, $additional_params = null) { $params = array('project_id' => $project->getId()); if (is_array($additional_params)) { $params = array_merge($params, $additional_params); } // if return assemble_url('project_files_upload', $params); }
/** * Return add discussion URL via public portal * * @param Portal $portal * @param Project $project * @param array $additional_params * @return string */ function portal_discussions_module_add_discussion_url($portal, $project, $additional_params = null) { $params = array('portal_name' => $portal->getSlug()); if ($additional_params !== null) { $params = array_merge($params, $additional_params); } // if return assemble_url('portal_discussions_add', $params); }
/** * 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>'; }
/** * Return add checklist ULRL * * @param Project $project * @param array $additional_params * @return string */ function checklists_module_add_checklist_url($project, $additional_params = null) { $params = array('project_id' => $project->getId()); if ($additional_params !== null) { $params = array_merge($params, $additional_params); } // if return assemble_url('project_checklists_add', $params); }
/** * 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>'; }
/** * Invoicing module on_project_object_quick_options event handler * * @package activeCollab.modules.invoicing * @subpackage handlers * @param NamedList $options * @param ProjectObject $object * @param User $user * @return null */ function invoicing_handle_on_project_object_quick_options(&$options, $object, $user) { /** * Add a quick option to create invoice from the ticket */ if (instance_of($object, 'Ticket') && $object->canView($user) && $user->getSystemPermission('can_manage_invoices')) { $options->add('make_invoice', array('text' => lang('Create Invoice'), 'url' => assemble_url('invoices_add', array('ticket_id' => $object->getId())))); } // if }
/** * System module on_project_object_quick_options event handler * * @package activeCollab.modules.system * @subpackage handlers * @param NamedList $options * @param ProjectObject $object * @param User $user * @return null */ function system_handle_on_project_object_quick_options(&$options, $object, $user) { /** * Add a quick option which links to the list of commits related to the object */ if (instance_of($object, 'ProjectObject') && $object->getState() == STATE_DELETED && ($user->isAdministrator() || $user->getSystemPermission('manage_trash'))) { $options->add('project_object_delete', array('text' => lang('Permanently delete'), 'url' => assemble_url('project_object_delete', array('project_id' => $object->getProjectId(), 'object_id' => $object->getId())), 'method' => 'post', 'confirm' => lang('Are you sure that you wish to permanently remove this :type?', array('type' => $object->getVerboseType(true))))); } // if }
/** * 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 }
/** * Construct PublicSubmitAdminController * * @param string $request * @return PublicSubmitAdminController * */ function __construct($request) { parent::__construct($request); $this->smarty->assign(array("public_submit_settings_url" => assemble_url('admin_settings_public_submit'))); if (!(extension_loaded('gd') || extension_loaded('gd2')) || !function_exists('imagefttext')) { $this->gd_loaded = false; } // if $this->smarty->assign(array('public_submit_url' => assemble_url('public_submit'), 'public_submit_enabled' => ConfigOptions::getValue('public_submit_enabled'), 'public_submit_captcha_enabled' => ConfigOptions::getValue('public_submit_enable_captcha'), 'public_submit_project' => Projects::findById(ConfigOptions::getValue('public_submit_default_project')), 'gd_loaded' => $this->gd_loaded)); return $this; }
/** * Render this item * * @param void * @return null */ function render() { $q = clean(array_var($_GET, 'q')); return '<form action="' . assemble_url('search') . '" method="get" id="searchForm"> <div class="inner"> <input type="text" name="q" class="text" value="' . $q . '" /> <div> <button type="submit"><span><span>' . clean($this->caption) . '</span></span></button> </div> </div> </form>'; }
/** * 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 }