/**
  * 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));
 }
/**
 * 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
}
/**
 * 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
}
/**
 * Populate object options array
 *
 * @param NamedList $options
 * @param ProjectObject $object
 * @param User $user
 * @return null
 */
function source_handle_on_project_object_options(&$options, $object, $user)
{
    // Trash exposes all commits for individual removal/restoration, which must not be allowed
    if (instance_of($object, 'Repository') || instance_of($object, 'Commit')) {
        $options->remove('move_to_trash');
    }
    // if
    if (instance_of($object, 'Repository') && $object->canEdit($user)) {
        $options->add('repository_users', array('text' => lang('Manage Repository Users'), 'url' => assemble_url('repository_users', array('repository_id' => $object->getId(), 'project_id' => $object->getProjectId()))));
        $options->add('repository_delete', array('text' => lang('Delete repository'), 'url' => assemble_url('repository_delete', array('repository_id' => $object->getId(), 'project_id' => $object->getProjectId()), array('id' => 'repository_delete'))));
    }
    // if
}
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @return null
 */
function milestones_handle_on_project_tabs(&$tabs, &$logged_user, &$project)
{
    if ($logged_user->getProjectPermission('milestone', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('milestones', array('text' => lang('Milestones'), 'url' => milestones_module_url($project)));
    }
    // if
    if ($logged_user->getProjectPermission('ticket', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('tickets', array('text' => lang('Tickets'), 'url' => tickets_module_url($project)));
    }
    // if
    if ($logged_user->getProjectPermission('page', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('pages', array('text' => lang('Pages'), 'url' => pages_module_url($project)));
    }
    // if
}
/**
 * Handle on_dashboard_sections event
 *
 * @param NamedList $sections
 * @param User $user
 * @return null
 */
function system_handle_on_dashboard_sections(&$sections, &$user)
{
    $sections->add('recent_activities', array('text' => lang('Recent Activities'), 'url' => assemble_url('recent_activities')));
    $sections->add('active_projects', array('text' => lang('Active Projects'), 'url' => assemble_url('active_projects')));
    $count_new = ProjectObjects::countNew($user);
    if ($count_new > 0) {
        $sections->add('new_updated', array('text' => lang('New / Updated <span class="slip">:count</span>', array('count' => $count_new)), 'url' => assemble_url('new_since_last_visit')));
    }
    // if
    $count_late_today = ProjectObjects::countLateAndToday($user, null, get_completable_project_object_types());
    if ($count_late_today > 0) {
        $sections->add('late_today', array('text' => lang('Late / Today <span class="slip">:count</span>', array('count' => $count_late_today)), 'url' => assemble_url('late_today')));
    }
    // if
}
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @return null
 */
function checklists_handle_on_project_tabs(&$tabs, &$logged_user, &$project)
{
    if ($logged_user->getProjectPermission('checklist', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('checklists', array('text' => lang('Checklists'), 'url' => checklists_module_url($project)));
    }
    // if
}
/**
 * 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
}
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @return null
 */
function timetracking_handle_on_project_tabs(&$tabs, &$logged_user, &$project)
{
    if ($logged_user->getProjectPermission('timerecord', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('time', array('text' => lang('Time'), 'url' => timetracking_module_url($project)));
    }
    // if
}
Пример #10
0
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @return null
 */
function source_handle_on_project_tabs(&$tabs, &$logged_user, &$project)
{
    if ($logged_user->getProjectPermission('repository', $project) >= PROJECT_PERMISSION_ACCESS) {
        $tabs->add('source', array('text' => lang('Source'), 'url' => source_module_url($project)));
    }
    // if
}
Пример #11
0
/**
 * 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
}
/**
 * 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')));
    }
    //
}
/**
 * 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
}
/**
 * Handle on inline tabs event
 *
 * @param NamedList $tabs
 * @param ApplicationObject $object
 * @param User $logged_user
 * @param string $interface
 * @return null
 */
function ac_gitolite_handle_on_inline_tabs(&$tabs, &$object, &$logged_user, $interface)
{
    if ($object instanceof User) {
        if ($object->getId() == $logged_user->getId() || $logged_user->isAdministrator() || $logged_user->isPeopleManager()) {
            $tabs->add('view_keys', array('title' => lang('Public Keys'), 'url' => Router::assemble('get_public_keys', array('company_id' => $object->getCompanyId(), 'user_id' => $object->getId()))));
        }
    }
    // if User
}
/**
 * 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
}
/**
 * Source module on_project_object_quick_options event handler
 *
 * @package activeCollab.modules.source
 * @subpackage handlers
 * @param NamedList $options
 * @param ProjectObject $object
 * @param User $user
 * @return null
 */
function source_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, 'Ticket') || instance_of($object, 'Discussion') || instance_of($object, 'Milestone')) && $object->canView($user)) {
        $object_commits_count = CommitProjectObjects::countByObject($object);
        if ($object_commits_count > 0) {
            $options->add('new_revision', array('text' => lang('Commits (:object_commits)', array('object_commits' => $object_commits_count)), 'url' => assemble_url('repository_project_object_commits', array('project_id' => $object->getProjectId(), 'object_id' => $object->getId()))));
        }
        // if
    }
    // if
}
 /**
  * Calendar
  *
  * @param void
  * @return null
  */
 function index()
 {
     require_once CALENDAR_MODULE_PATH . '/models/generators/DashboardCalendarGenerator.class.php';
     if ($this->request->get('month') && $this->request->get('year')) {
         $month = $this->request->get('month');
         $year = $this->request->get('year');
     } else {
         $today = new DateTimeValue(time() + get_user_gmt_offset());
         $month = $today->getMonth();
         $year = $today->getYear();
     }
     // if
     $first_weekday = UserConfigOptions::getValue('time_first_week_day', $this->logged_user);
     $generator = new DashboardCalendarGenerator($month, $year, $first_weekday);
     $generator->setData(Calendar::getActiveProjectsData($this->logged_user, $month, $year));
     $this->smarty->assign(array('month' => $month, 'year' => $year, 'calendar' => $generator, 'navigation_pattern' => Calendar::getDashboardMonthUrl('-YEAR-', '-MONTH-')));
     //BOF:mod 20110623
     $tabs = new NamedList();
     $tabs->add('dashboard', array('text' => 'Active Teams', 'url' => assemble_url('dashboard')));
     $tabs->add('home_page', array('text' => 'Home Page', 'url' => assemble_url('goto_home_tab')));
     $this->smarty->assign('page_tabs', $tabs);
     //EOF:mod 20110623
 }
 /**
  * Show tickets index page
  *
  * @param void
  * @return null
  */
 function index()
 {
     /*
         	$selected_milestone_id = $_GET['milestone_id'];
     		$milestones = Milestones::findByProject($this->active_project, $this->logged_user);
     		//$milestones = Milestones::findActiveByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility());
     		
     		if (empty($selected_milestone_id)){
     			//$tickets = Tickets::findOpenByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility());
               	$tickets = Milestones::groupByMilestone(Tickets::findOpenByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()), STATE_VISIBLE, $this->logged_user->getVisibility());
     		} else {
     			$milestone = new Milestone($selected_milestone_id);
     			$tickets_in_milestone = Tickets::findByMilestone($milestone, STATE_VISIBLE, $this->logged_user->getVisibility());
     			$tickets[$milestone->getId()] = array('milestone' => $milestone, 'objects' => $tickets_in_milestone);
     		}
     		
     		$this->smarty->assign(array('milestones' => $milestones, 
     								    'selected_milestone_id' => $selected_milestone_id, 
               							'can_add_ticket' => Ticket::canAdd($this->logged_user, $this->active_project),
               							'can_manage_categories' => $this->logged_user->isProjectLeader($this->active_project) || $this->logged_user->isProjectManager(),
               							'tickets' => $tickets,
     									'categories' => Categories::findByModuleSection($this->active_project, TICKETS_MODULE, 'tickets'),
     									'tickets_count' => (!empty($selected_milestone_id) ? count($tickets[$milestone->getId()]['objects']) : '-1')
     									));
     */
     if ($this->request->isApiCall()) {
         if ($this->active_category->isLoaded()) {
             $this->serveData(Tickets::findOpenByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility()), 'tickets');
         } else {
             $this->serveData(Tickets::findOpenByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()), 'tickets');
         }
         // if
     } else {
         $tickets_url = tickets_module_url($this->active_project);
         $options_sort = new NamedList();
         $options_sort->add('category', array('url' => $tickets_url . '&sort=category', 'text' => lang('by Category')));
         $options_sort->add('star', array('url' => $tickets_url . '&sort=star', 'text' => lang('by Star')));
         $options_sort->add('priority', array('url' => $tickets_url . '&sort=priority', 'text' => lang('by Priority')));
         $options_sort->add('name', array('url' => $tickets_url . '&sort=name', 'text' => lang('by Name')));
         $options_sort->add('owner', array('url' => $tickets_url . '&sort=owner', 'text' => lang('by Owner')));
         //BOF:mod #59_266
         $options_sort->add('project', array('url' => $tickets_url . '&sort=milestone', 'text' => 'by Milestone'));
         //EOF:mod #59_266
         $this->wireframe->addPageAction(lang('Sort'), '#', $options_sort->data);
         $task_id = $_GET['task_id'];
         if (!empty($task_id)) {
             $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
             mysql_select_db(DB_NAME);
             $query = "select type, body from healingcrystals_project_objects where id='" . (int) $task_id . "'";
             $result = mysql_query($query);
             $info = mysql_fetch_assoc($result);
             if (strtolower($info['type']) == 'task') {
                 $body_wo_tags = strip_tags($info['body']);
                 $query = "select max(integer_field_1) as max_count from healingcrystals_project_objects where project_id='" . $this->active_project->getId() . "'";
                 $result = mysql_query($query);
                 $info = mysql_fetch_assoc($result);
                 $integer_field_1 = $info['max_count'] + 1;
                 $query = "update healingcrystals_project_objects set \n                                     type='Ticket', \n                                     module='tickets', \n                                     parent_id='0', \n                                     parent_type=null, \n                                     name='" . str_replace("'", "''", $body_wo_tags) . "', \n                                     body=null, \n                                     updated_on=now(), \n                                     updated_by_id='" . $this->logged_user->getId() . "', \n                                     integer_field_1='" . $integer_field_1 . "' where id='" . (int) $task_id . "'";
                 mysql_query($query);
                 $edit_url = assemble_url('project_ticket_edit', array('project_id' => $this->active_project->getId(), 'ticket_id' => $integer_field_1));
                 header('Location: ' . $edit_url);
             }
             mysql_close($link);
         }
         $cur_department = $_GET['department_id'];
         $mID = $_GET['mID'];
         $page = (int) $_GET['page'];
         $page = $page <= 0 ? 1 : $page;
         $limit = (int) $_GET['limit'];
         //$limit = $limit<=0 ? 50 : $limit;
         $limit = $limit <= 0 ? 1000 : $limit;
         $offset = ($page - 1) * $limit;
         $sort_by = trim(strtolower($_GET['sort']));
         $sort_by = empty($sort_by) ? 'category' : $sort_by;
         $link = mysql_connect(DB_HOST, DB_USER, DB_PASS);
         mysql_select_db(DB_NAME);
         $tickets = array();
         /*if($this->active_category->isLoaded()) {
             $tickets = Milestones::groupByMilestone(
               Tickets::findOpenByCategory($this->active_category, STATE_VISIBLE, $this->logged_user->getVisibility()), 
               STATE_VISIBLE, $this->logged_user->getVisibility()
             );
           } else {
             $tickets = Milestones::groupByMilestone(
               Tickets::findOpenByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()), 
               STATE_VISIBLE, $this->logged_user->getVisibility()
             );*/
         if (empty($cur_department)) {
             //BOF:mod #59_266
             /*
             //EOF:mod #59_266
             $query = "select a.id as ticket_id, b.id as milestone_id, ifnull(a.priority, '0') from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id " ;
             //BOF:mod #59_266
             */
             $query = "select distinct a.id as ticket_id, b.id as milestone_id, cast(ifnull(a.priority, '0') as signed integer) as priority ::CONTENT_PLACE_HOLDER:: from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id ";
             //EOF:mod #59_266
             //BOF:mod 20120911
             /*
             //EOF:mod 20120911
                         $query_condition = " where a.project_id='" . $this->active_project->getId() . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility='" . VISIBILITY_NORMAL . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : "");
             //BOF:mod 20120911
             */
             $query_condition = " where a.project_id='" . $this->active_project->getId() . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility>='" . $this->logged_user->getVisibility() . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : "");
             //EOF:mod 20120911
         } else {
             if ($cur_department == '-1') {
                 //BOF:mod #59_266
                 /*
                 //EOF:mod #59_266
                 $query = "select a.id as ticket_id, b.id as milestone_id, ifnull(a.priority, '0') from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id " ;
                 //BOF:mod #59_266
                 */
                 $query = "select distinct a.id as ticket_id, b.id as milestone_id, cast(ifnull(a.priority, '0') as signed integer) as priority ::CONTENT_PLACE_HOLDER:: from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id ";
                 //EOF:mod #59_266
                 //BOF:mod 20120911
                 /*
                 //EOF:mod 20120911
                                 $query_condition = " where not exists(select * from healingcrystals_project_object_categories obj where obj.object_id=a.id) and a.project_id='" . $this->active_project->getId() . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility='" . VISIBILITY_NORMAL . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : "");
                 //BOF:mod 20120911
                 */
                 $query_condition = " where not exists(select * from healingcrystals_project_object_categories obj where obj.object_id=a.id) and a.project_id='" . $this->active_project->getId() . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility>='" . $this->logged_user->getVisibility() . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : "");
                 //EOF:mod 20120911
             } elseif ($cur_department == '-99') {
                 //BOF:mod #59_266
                 /*
                 //EOF:mod #59_266
                 $query = "select a.id as ticket_id, b.id as milestone_id, ifnull(a.priority, '0') from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id left join healingcrystals_project_milestone_categories dep on a.project_id=dep.project_id left join healingcrystals_project_object_categories obj on (dep.id=obj.category_id and a.id=obj.object_id) " ;
                 //BOF:mod #59_266
                 */
                 $query = "select distinct a.id as ticket_id, b.id as milestone_id, cast(ifnull(a.priority, '0') as signed integer) as priority ::CONTENT_PLACE_HOLDER:: from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id left join healingcrystals_project_milestone_categories dep on a.project_id=dep.project_id left join healingcrystals_project_object_categories obj on (dep.id=obj.category_id and a.id=obj.object_id) ";
                 //EOF:mod #59_266
                 $query_condition = " where a.project_id='" . $this->active_project->getId() . "' and a.type='Ticket' and a.completed_on is not null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : "");
             } else {
                 //BOF:mod #59_266
                 /*
                 //EOF:mod #59_266
                 $query = "select a.id as ticket_id, b.id as milestone_id, ifnull(a.priority, '0') from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id inner join healingcrystals_project_milestone_categories dep on a.project_id=dep.project_id inner join healingcrystals_project_object_categories obj on (dep.id=obj.category_id and a.id=obj.object_id) " ;
                 //BOF:mod #59_266
                 */
                 $query = "select distinct a.id as ticket_id, b.id as milestone_id, cast(ifnull(a.priority, '0') as signed integer) as priority ::CONTENT_PLACE_HOLDER:: from healingcrystals_project_objects a left join healingcrystals_project_objects b on a.milestone_id=b.id inner join healingcrystals_project_milestone_categories dep on a.project_id=dep.project_id inner join healingcrystals_project_object_categories obj on (dep.id=obj.category_id and a.id=obj.object_id) ";
                 //EOF:mod #59_266
                 //BOF:mod 20120911
                 /*
                 //EOF:mod 20120911
                                 $query_condition = " where a.project_id='" . $this->active_project->getId() . "' and dep.id='" . $cur_department . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility='" . VISIBILITY_NORMAL . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : "");
                 //BOF:mod 20120911
                 */
                 $query_condition = " where a.project_id='" . $this->active_project->getId() . "' and dep.id='" . $cur_department . "' and a.type='Ticket' and a.state='" . STATE_VISIBLE . "' and a.visibility>='" . $this->logged_user->getVisibility() . "' and a.completed_on is null " . ($this->active_category && $this->active_category->isLoaded() ? " and a.parent_id='" . $this->active_category->getId() . "' " : "") . (!empty($mID) ? " and b.id='" . $mID . "'" : "");
                 //EOF:mod 20120911
             }
         }
         //BOF:mod #59_266
         /*
         //EOF:mod #59_266
         $result = mysql_query($query . $query_condition);
         $total_tickets = mysql_num_rows($result);
         $total_pages = ceil($total_tickets / $limit);
         if ($sort_by=='category'){
         //BOF:mod #59_266
         */
         if ($sort_by == 'category' || $sort_by == 'milestone') {
             if ($sort_by == 'category') {
                 $query_1 = str_replace('::CONTENT_PLACE_HOLDER::', '', $query) . $query_condition;
             } else {
                 $query_1 = str_replace('::CONTENT_PLACE_HOLDER::', ", (select max(created_on) from healingcrystals_project_objects c where c.type='Comment' and c.parent_id=a.id) as comment_date", $query) . $query_condition;
             }
             $result_temp = mysql_query($query_1);
             $total_tickets = mysql_num_rows($result_temp);
             $total_pages = ceil($total_tickets / $limit);
             if ($sort_by == 'category') {
                 //$query_1 .= " order by isnull(b.id), b.name, a.position, priority desc limit " . $offset . ", " . $limit;
                 $query_1 .= " order by isnull(b.id), b.name, priority desc, a.position limit " . $offset . ", " . $limit;
             } else {
                 $query_1 .= " order by isnull(b.id), b.name, priority desc, comment_date desc limit " . $offset . ", " . $limit;
             }
             /*
             //EOF:mod #59_266
                 $query_1 = $query . $query_condition . " order by isnull(b.id), b.name, a.priority desc limit " . $offset . ", " . $limit;
             //BOF:mod #59_266
             */
             //EOF:mod #59_266
             $result = mysql_query($query_1, $link);
             $cur_milestone_id = -1;
             while ($ticket = mysql_fetch_assoc($result)) {
                 if ($cur_milestone_id == -1 || $cur_milestone_id != (int) $ticket['milestone_id']) {
                     $cur_milestone_id = (int) $ticket['milestone_id'];
                     if ($cur_milestone_id == 0) {
                         $cur_milestone_ref = null;
                     } else {
                         $cur_milestone_ref = new Milestone($ticket['milestone_id']);
                     }
                     $tickets[] = array('milestone' => $cur_milestone_ref, 'objects' => array());
                 }
                 $tickets[count($tickets) - 1]['objects'][] = new Ticket($ticket['ticket_id']);
             }
         } elseif ($sort_by == 'star' || $sort_by == 'priority' || $sort_by == 'name' || $sort_by == 'owner') {
             //BOF:mod #59_266
             $query = str_replace('::CONTENT_PLACE_HOLDER::', '', $query);
             $result_temp = mysql_query($query . $query_condition);
             $total_tickets = mysql_num_rows($result_temp);
             $total_pages = ceil($total_tickets / $limit);
             //EOF:mod #59_266
             switch ($sort_by) {
                 case 'star':
                     $query_1 = $query . " left join healingcrystals_starred_objects c on (a.id=c.object_id and c.user_id='" . $this->logged_user->getId() . "') left join healingcrystals_assignments d on (a.id=d.object_id and d.is_owner='1') left join healingcrystals_users e on d.user_id=e.id " . $query_condition . " order by isnull(c.object_id), 3 desc, isnull(e.first_name), e.first_name limit " . $offset . ", " . $limit;
                     break;
                 case 'priority':
                     $query_1 = $query . " left join healingcrystals_assignments d on (a.id=d.object_id and d.is_owner='1') left join healingcrystals_users e on d.user_id=e.id " . $query_condition . " order by 3 desc, isnull(e.first_name), e.first_name, a.name limit " . $offset . ", " . $limit;
                     break;
                 case 'name':
                     $query_1 = $query . $query_condition . " order by a.name limit " . $offset . ", " . $limit;
                     break;
                 case 'owner':
                     $query_1 = $query . " left join healingcrystals_assignments d on (a.id=d.object_id and d.is_owner='1') left join healingcrystals_users e on d.user_id=e.id " . $query_condition . " order by isnull(e.first_name), e.first_name, 3 desc, a.name limit " . $offset . ", " . $limit;
                     break;
             }
             $result = mysql_query($query_1, $link);
             while ($ticket = mysql_fetch_assoc($result)) {
                 $cur_milestone_id = (int) $ticket['milestone_id'];
                 if ($cur_milestone_id == 0) {
                     $cur_milestone_ref = null;
                 } else {
                     $cur_milestone_ref = new Milestone($ticket['milestone_id']);
                 }
                 $tickets[] = array('milestone' => $cur_milestone_ref, 'ticket' => new Ticket($ticket['ticket_id']));
             }
         }
         //} // if
         $all_milestones = array();
         //BOF:mod 20120911
         /*
         //EOF:mod 20120911
                 $query = "select id, name from healingcrystals_project_objects where project_id='" . $this->active_project->getId() . "' and type='Milestone' and state='" . STATE_VISIBLE . "' and visibility='" . VISIBILITY_NORMAL . "' and completed_on is null order by name";
         //BOF:mod 20120911
         */
         $query = "select id, name from healingcrystals_project_objects where project_id='" . $this->active_project->getId() . "' and type='Milestone' and state='" . STATE_VISIBLE . "' and visibility>='" . $this->logged_user->getVisibility() . "' and completed_on is null order by name";
         //EOF:mod 20120911
         $result = mysql_query($query, $link);
         while ($milestone = mysql_fetch_assoc($result)) {
             $all_milestones[] = array('id' => $milestone['id'], 'name' => $milestone['name']);
         }
         $departments = array();
         $query = "select id, category_name from healingcrystals_project_milestone_categories where project_id='" . $this->active_project->getId() . "' order by category_name";
         $result = mysql_query($query);
         while ($department = mysql_fetch_assoc($result)) {
             $departments[] = array('department_id' => $department['id'], 'department_name' => $department['category_name']);
         }
         $departments[] = array('department_id' => '-1', 'department_name' => 'Uncategorized');
         mysql_close($link);
         $this->smarty->assign(array('categories' => Categories::findByModuleSection($this->active_project, TICKETS_MODULE, 'tickets'), 'groupped_tickets' => $tickets, 'milestones' => Milestones::findActiveByProject($this->active_project, STATE_VISIBLE, $this->logged_user->getVisibility()), 'can_add_ticket' => Ticket::canAdd($this->logged_user, $this->active_project), 'can_manage_categories' => $this->logged_user->isProjectLeader($this->active_project) || $this->logged_user->isProjectManager(), 'departments_url' => assemble_url('project_manage_milestone_categories', array('project_id' => $this->active_project->getId())), 'total_tickets' => $total_tickets, 'total_pages' => $total_pages, 'current_page' => $page, 'all_milestones' => $all_milestones, 'current_milestone' => $mID, 'sort_by' => $sort_by, 'departments' => $departments, 'current_department_id' => $cur_department));
         js_assign('can_manage_tickets', Ticket::canManage($this->logged_user, $this->active_project));
     }
     // if
 }
Пример #20
0
 /**
  * Return quick user options
  *
  * @param User $user
  * @return array
  */
 function getQuickOptions($user)
 {
     if (!isset($this->quick_options[$user->getId()])) {
         $options = new NamedList();
         if ($this->canEdit($user)) {
             $options->add('edit_profile', array('text' => lang('Update Profile'), 'url' => $this->getEditProfileUrl()));
             $options->add('edit_settings', array('text' => lang('Change Settings'), 'url' => $this->getEditSettingsUrl()));
             $options->add('edit_password', array('text' => lang('Change Password'), 'url' => $this->getEditPasswordUrl()));
             $options->add('api', array('text' => lang('API Settings'), 'url' => $this->getApiSettingsUrl()));
         }
         // if
         event_trigger('on_user_quick_options', array(&$this, &$options, &$user));
         $this->quick_options[$user->getId()] = $options;
     }
     // if
     return $this->quick_options[$user->getId()];
 }
Пример #21
0
 /**
  * Return options for this object
  *
  * @param User $user
  * @return array
  */
 function getOptions($user)
 {
     $options = new NamedList();
     if ($this->canView($user) && !$this->isCanceled()) {
         $options->add('view_pdf', array('url' => $this->getPdfUrl(), 'text' => $this->getStatus() == INVOICE_STATUS_DRAFT ? lang('Preview PDF') : lang('View PDF')));
     }
     // if
     if ($this->canIssue($user) && instance_of($this->getCompany(), 'Company')) {
         $options->add('issue', array('url' => $this->getIssueUrl(), 'text' => lang('Issue')));
     }
     // if
     if ($this->canCancel($user)) {
         $options->add('cancel', array('url' => $this->getCancelUrl(), 'text' => lang('Cancel'), 'confirm' => lang('Are you sure that you want to cancel this invoice? All existing payments associated with this invoice will be deleted!'), 'method' => 'post'));
     }
     if ($user->getSystemPermission('can_manage_invoices')) {
         $options->add('duplicate', array('url' => $this->getDuplicateUrl(), 'text' => lang('Duplicate')));
     }
     // if
     if ($this->countTimeRecords()) {
         $options->add('time', array('url' => $this->getDuplicateUrl(), 'text' => lang('Time Records (:count)', array('count' => $this->countTimeRecords()))));
     }
     // if
     if ($this->canEdit($user)) {
         $options->add('edit', array('url' => $this->getEditUrl(), 'text' => lang('Edit')));
     }
     // if
     if ($this->canDelete($user)) {
         $options->add('delete', array('url' => $this->getDeleteUrl(), 'text' => lang('Delete'), 'confirm' => lang('Are you sure that you want to delete this invoice?'), 'method' => 'post'));
     }
     // if
     return $options->count() ? $options : null;
 }
 function my_subscribed_tickets()
 {
     $selected_project = $_GET['selected_project'];
     $order_by = $_GET['order_by'];
     $sort_order = $_GET['sort_order'];
     $user = $this->logged_user;
     $entries = $this->logged_user->getSubscribedTickets($user->getId(), $selected_project, $order_by, $sort_order);
     $this->smarty->assign(array('active_user' => $user, 'entries' => $entries, 'user_projects' => $user->getActiveProjects(), 'selected_project' => $selected_project));
     $tabs = new NamedList();
     $tabs->add('dashboard', array('text' => 'Active Teams', 'url' => assemble_url('dashboard')));
     $tabs->add('home_page', array('text' => 'Home Page', 'url' => assemble_url('goto_home_tab')));
     $tabs->add('assigned_action_request', array('text' => 'Assigned Action Requests', 'url' => assemble_url('assigned_action_request')));
     $tabs->add('owned_tickets', array('text' => 'Owned Tickets', 'url' => assemble_url('my_tickets')));
     $tabs->add('subscribed_tickets', array('text' => 'Subscribed Tickets', 'url' => assemble_url('my_subscribed_tickets')));
     //BOF:mod 20110715 ticketid246
     $customtabs = $this->logged_user->getCustomTabsInfo();
     $tabs->add('tab1', array('text' => $customtabs[0]['name'], 'url' => $customtabs[0]['url'], 'ondblclick' => "customtab_ondblclick(this, '1')"));
     $tabs->add('tab2', array('text' => $customtabs[1]['name'], 'url' => $customtabs[1]['url'], 'ondblclick' => "customtab_ondblclick(this, '2')"));
     $tabs->add('tab3', array('text' => $customtabs[2]['name'], 'url' => $customtabs[2]['url'], 'ondblclick' => "customtab_ondblclick(this, '3')"));
     //EOF:mod 20110715 ticketid246
     $this->smarty->assign('page_tabs', $tabs);
     $this->smarty->assign('page_tab', 'subscribed_tickets');
 }
/**
 * Handle on prepare project overview event
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Project $project
 * @return null
 */
function github_handle_on_project_tabs(&$tabs, &$logged_user, &$project)
{
    $tabs->add('github', array('text' => lang('Github'), 'url' => github_module_url($project)));
}
 /**
  * Return array of portal object quick options
  *
  * @param Portal $portal
  * @param Commit $commit
  * @param string $file
  * @return array
  */
 function getPortalQuickOptions($portal, $commit = null, $file = null)
 {
     if (!isset($this->portal_quick_options[$portal->getId()])) {
         $options = new NamedList();
         if ($this->canPortalSubtask($portal)) {
             $options->add('new_task', array('text' => lang('New Task'), 'url' => $this->getPortalPostTaskUrl($portal)));
         }
         // if
         event_trigger('on_portal_object_quick_options', array(&$options, $this, $portal, $commit, $file));
         $this->portal_quick_options[$portal->getId()] = $options;
     }
     // if
     return $this->portal_quick_options[$portal->getId()];
 }
Пример #25
0
/**
 * Invoicing module on_company_tabs even handler implementation
 *
 * @param NamedList $tabs
 * @param User $logged_user
 * @param Company $company
 * @return null
 */
function invoicing_handle_on_company_tabs(&$tabs, &$logged_user, &$company)
{
    $tabs->add('invoices', array('text' => lang('Invoices'), 'url' => assemble_url('people_company_invoices', array('company_id' => $company->getId()))));
}
 function ac_gitolite_get_tags()
 {
     // prepare options for dropdown
     $repo_path = $this->active_repository->getRepositoryPathUrl();
     $branches = ProjectGitolite::get_tags($repo_path);
     $file_options = new NamedList();
     if (is_array($branches)) {
         foreach ($branches as $key => $value) {
             $file_options->add("tags_{$key}", array('text' => $value, 'url' => "#"));
         }
     } else {
         $file_options->add("no_branches", array('text' => "No Tags Added", 'url' => "#"));
     }
     /* $file_options->add('download', array(
        'text' => lang('Download'),
        'url' => $repository->getFileDownloadUrl($commit, $file)
        )); */
     return $file_options->toArray();
 }
/**
 * Add options to Home Screen
 *
 * @param NamedList $menu
 * @param User $user
 */
function timer_handle_on_phone_homescreen(NamedList &$items, IUser &$user)
{
    $items->add('timer', array('text' => lang('Timer'), 'url' => TimerModule::getTimerRoute(), 'icon' => AngieApplication::getImageUrl('module.png', TIMER_MODULE, AngieApplication::INTERFACE_PHONE)));
}
 /**
  * Construct project controller
  *
  * @param Request $request
  * @return ProjectController
  */
 function __construct($request)
 {
     parent::__construct($request);
     $this->wireframe->page_actions = array();
     // Reset page actions
     $project_id = $this->request->get('project_id');
     if ($project_id) {
         $this->active_project = Projects::findById($project_id);
     }
     // if
     if (instance_of($this->active_project, 'Project')) {
         if (!$this->logged_user->isProjectMember($this->active_project)) {
             $this->httpError(HTTP_ERR_FORBIDDEN);
         }
         // if
         if ($this->active_project->getType() == PROJECT_TYPE_SYSTEM) {
             $this->httpError(HTTP_ERR_NOT_FOUND);
         }
         // if
         if ($this->active_project->isCompleted()) {
             $this->wireframe->addBreadCrumb(lang('Archive'), assemble_url('projects_archive'));
         }
         // if
         $this->wireframe->addBreadCrumb($this->active_project->getName(), $this->active_project->getOverviewUrl());
         $tabs = new NamedList();
         $tabs->add('overview', array('text' => str_excerpt($this->active_project->getName(), 25), 'url' => $this->active_project->getOverviewUrl()));
         event_trigger('on_project_tabs', array(&$tabs, &$this->logged_user, &$this->active_project));
         $tabs->add('people', array('text' => lang('People'), 'url' => $this->active_project->getPeopleUrl()));
         $tabs->add('recent_pages', array('text' => lang('Recent Pages'), 'url' => assemble_url('recent_pages') . '&project_id=' . $this->active_project->getId()));
         /*$tabs->add('recent_pages_1', array(
             'text' => lang('Recent Pages'),
             'url' => assemble_url('project_recent_pages_1'),
           ));*/
         //BOF:mod
         /*$tabs->add('attachments', array(
             'text' => lang('Attachments'),
             'url' => assemble_url('attachments_list', array('project_id' => $this->active_project->getId())) ,
           ));*/
         //EOF:mod
         $tabs->add('reminders', array('text' => lang('Notifications'), 'url' => assemble_url('reminders_list', array('project_id' => $this->active_project->getId()))));
         $tabs->add('calendar', array('text' => lang('Calendar'), 'url' => Calendar::getProjectCalendarUrl($this->active_project)));
         js_assign('image_picker_url', assemble_url('image_picker', array('project_id' => $this->active_project->getId())));
         js_assign('active_project_id', $this->active_project->getId());
         $this->smarty->assign('page_tabs', $tabs);
         // ---------------------------------------------------
         //  Set page company and page project
         // ---------------------------------------------------
         $page_company = $this->active_project->getCompany();
         if (instance_of($page_company, 'Company')) {
             $this->wireframe->page_company = $page_company;
         }
         // if
         $this->wireframe->page_project = $this->active_project;
         // New project
     } else {
         if ($this->controller_name == 'project') {
             $this->active_project = new Project();
         } else {
             $this->httpError(HTTP_ERR_NOT_FOUND);
         }
         // if
     }
     // if
     $this->smarty->assign(array('active_project' => $this->active_project, 'page_tab' => 'overview'));
     // -----------------------------------------------------------------------
     //  Do category related voodoo if categories are enabled. Categories are
     //  not initialized if we don't have a loaded project (no project ID)
     // -----------------------------------------------------------------------
     if ($this->active_project->isLoaded() && $this->enable_categories) {
         $category_id = $this->request->get('category_id');
         if ($category_id) {
             $this->active_category = Categories::findById($category_id);
         }
         // if
         if (instance_of($this->active_category, 'Category')) {
             if ($this->active_category->getProjectId() != $this->active_project->getId()) {
                 $this->active_category = new Category();
                 // this category is not part of selected project
             }
             // if
         } else {
             $this->active_category = new Category();
         }
         // if
         $this->smarty->assign(array('active_category' => $this->active_category, 'categories_url' => Category::getSectionUrl($this->active_project, $this->getControllerName(), $this->active_module), 'add_category_url' => Category::getAddUrl($this->active_project, $this->getControllerName(), $this->active_module)));
     }
     // if
 }
Пример #29
0
 /**
  * Return quick options
  *
  * @param User $user
  * @return NamedList
  */
 function getQuickOptions($user)
 {
     if (!isset($this->quick_options[$user->getId()])) {
         $options = new NamedList();
         if ($this->canEdit($user)) {
             $options->add('edit', array('text' => lang('Change Details'), 'url' => $this->getEditUrl()));
             $options->add('edit_logo', array('text' => lang('Change Logo'), 'url' => $this->getEditLogoUrl()));
         }
         // if
         // Additional
         event_trigger('on_company_quick_options', array(&$this, &$options, &$user));
         $this->quick_options[$user->getId()] = $options;
     }
     // if
     return $this->quick_options[$user->getId()];
 }
Пример #30
0
 /**
  * Return project options
  *
  * @param User $user
  * @return array
  */
 function getOptions($user)
 {
     if (!isset($this->options[$user->getId()])) {
         $options = new NamedList();
         if ($this->canEdit($user)) {
             $options->add('edit', array('url' => $this->getEditUrl(), 'text' => lang('Edit')));
             $options->add('edit_status', array('url' => $this->getEditStatusUrl(), 'text' => lang('Change Status')));
             $options->add('edit_icon', array('url' => $this->getEditIconUrl(), 'text' => lang('Change Icon')));
         }
         // if
         if ($this->canDelete($user)) {
             $options->add('delete', array('text' => lang('Delete'), 'url' => $this->getDeleteUrl(), 'method' => 'post', 'confirm' => lang('Are you sure that you want to delete this project and all related objects? This cannot be undone!')));
         }
         // if
         if (PinnedProjects::isPinned($this, $user)) {
             $options->add('pin_unpin', array('text' => lang('Remove from Favorites'), 'url' => $this->getUnpinUrl(), 'method' => 'post'));
         } else {
             $options->add('pin_unpin', array('text' => lang('Add to Favorites'), 'url' => $this->getPinUrl(), 'method' => 'post'));
         }
         // if
         //BOF: task 04 | AD
         $options->add('manage_milestone_categories', array('url' => $this->getManageMilestoneCategoriesUrl(), 'text' => lang('Manage Milestone Categories')));
         //EOF: task 04 | AD
         event_trigger('on_project_options', array(&$options, &$this, &$user));
         $this->options[$user->getId()] = $options;
     }
     // if
     return $this->options[$user->getId()];
 }