Пример #1
0
 /**
  * Before allowing someone to do stuff, check to see
  * whether they have access to the file they've requested
  * 
  */
 public function preDispatch()
 {
     if (za()->getUser()->getRole() == User::ROLE_EXTERNAL) {
         // make sure the id is valid
         $id = $this->_getParam('id');
         $client = $this->clientService->getUserClient(za()->getUser());
         $project = $this->byId($this->_getParam('projectid'), 'Project');
         if ($client == null || $project == null) {
             $this->log->warn("User " . za()->getUser()->getUsername() . " tried viewing without valid client or project");
             $this->requireLogin();
             return;
         }
         if ($id) {
             // see whether the list of files for the current user's
             // company is valid
             /*$path = 'Clients/'.$client->title.'/Projects/'.$project->title;
             	            
             	            $okay = $this->fileService->isInDirectory($this->fileService->getFile($id), $path, true);
             
             	            if (!$okay) {
             	                $this->requireLogin();
             	            }*/
         }
     }
 }
Пример #2
0
 public function preDispatch()
 {
     $userClient = $this->clientService->getUserClient(za()->getUser());
     if ($userClient != null) {
         $id = $this->_getParam('id');
         // get the user's client
         if ($id != $userClient->id) {
             $this->_setParam('id', $userClient->id);
         }
     } else {
         $this->requireLogin();
     }
 }
Пример #3
0
 public function listAction()
 {
     $client = $this->clientService->getClient((int) $this->_getParam('clientid'));
     if (!$client) {
         echo "Failed loading projects";
         return;
     }
     $this->view->hideHeader = true;
     $this->view->client = $client;
     $totalCount = $this->projectService->getProjectCount(array('clientid=' => $client->id, 'parentid=' => 0, 'isprivate=' => 0));
     $this->view->pagerName = 'ptasks';
     $currentPage = ifset($this->_getAllParams(), $this->view->pagerName, 1);
     $this->view->totalProjects = $totalCount;
     $this->view->projectListSize = za()->getConfig('project_task_list_size');
     $this->view->projects = $this->projectService->getProjects(array('clientid=' => $client->id, 'parentid=' => 0, 'isprivate=' => 0));
     $this->renderRawView('project/index.php');
     /*
             $client = $this->clientService->getClient((int) $this->_getParam('clientid'));
             if (!$client) {
                 echo "Failed loading projects";
                 return;
             }
             $this->view->hideHeader = true;
             $this->view->client = $client;
             $this->view->projects = $this->projectService->getProjects(array('clientid=' => $client->id, 'parentid='=>0, 'isprivate='=>0));
     
             $this->renderRawView('project/index.php');*/
 }
Пример #4
0
 /**
  * Edit a user object.
  *
  */
 public function editAction()
 {
     $id = (int) $this->_getParam('id');
     $userToEdit = za()->getUser();
     // If an ID is passed, we need to have a higher role than that user
     // to be able to edit them an admin to be
     // able to edit this user
     if ($id > 0) {
         $selectedUser = $this->userService->getUser($id);
         // now, if the selectedUser has a role less than mine, we can
         // edit them
         if ($selectedUser->getRoleValue() < za()->getUser()->getRoleValue() || za()->getUser()->isPower()) {
             $userToEdit = $selectedUser;
         }
     }
     // if the user's an admin, give them the list of contacts
     // to bind for this user
     if (za()->getUser()->hasRole(User::ROLE_USER)) {
         // get all the contacts
         $this->view->contacts = $this->clientService->getContacts();
     }
     $this->view->leave = $this->userService->getLeaveForUser($userToEdit);
     $this->view->accruedLeave = $this->userService->calculateLeave($userToEdit);
     $this->view->leaveApplications = $this->userService->getLeaveApplicationsForUser($userToEdit);
     $this->view->model = $userToEdit;
     $this->view->themes = $this->getThemes();
     $this->renderView('user/edit.php');
 }
Пример #5
0
 /**
  * Get the detailed timesheet for this project.
  *
  */
 public function detailedtimesheetAction()
 {
     $project = $this->projectService->getProject($this->_getParam('projectid'));
     $client = $this->clientService->getClient($this->_getParam('clientid'));
     $task = $this->projectService->getTask($this->_getParam('taskid'));
     $user = $this->userService->getUserByField('username', $this->_getParam('username'));
     if (!$project && !$client && !$task && !$user) {
         return;
     }
     if ($task) {
         $this->view->records = $this->projectService->getDetailedTimesheet(null, $task->id);
     } else {
         if ($project) {
             $start = null;
             $this->view->records = $this->projectService->getDetailedTimesheet(null, null, $project->id);
         } else {
             if ($client) {
                 $start = null;
                 $this->view->records = $this->projectService->getDetailedTimesheet(null, null, null, $client->id);
             } else {
                 if ($user) {
                     $this->view->records = $this->projectService->getDetailedTimesheet($user);
                 }
             }
         }
     }
     $this->view->task = $task;
     $this->renderRawView('timesheet/ajax-timesheet-details.php');
 }
Пример #6
0
 /**
  * Get a bunch of data prepared for the view
  */
 protected function prepareForEdit()
 {
     if ($this->view->model == null) {
         throw new Exception("Task not found!");
     }
     // check the existence of the client to add this contact to
     $pid = (int) $this->_getParam('projectid') ? (int) $this->_getParam('projectid') : $this->view->model->projectid;
     $project = new Project();
     if ($pid) {
         $project = $this->projectService->getProject($pid);
     }
     $this->view->project = $project;
     $this->view->projectUsers = $this->projectService->getProjectUsers($project);
     $this->view->activeTasks = array();
     if ($project->id) {
         $this->view->projects = $this->projectService->getProjectsForClient($project->clientid);
         $this->view->activeTasks = $this->projectService->getActiveProjectTasks($project);
     } else {
         $this->view->projects = new ArrayObject();
     }
     $this->view->categories = $this->view->model->constraints['category']->getValues();
     $this->view->clients = $this->clientService->getClients();
     $this->view->model->tags = "";
     if ($this->view->model->id) {
         $this->view->notes = $this->notificationService->getNotesFor($this->view->model);
         $this->view->existingWatch = $this->notificationService->getWatch(za()->getUser(), $this->view->model->id, 'Task');
         $this->view->allUsers = $this->userService->getUserList();
         $this->view->subscribers = $this->notificationService->getSubscribers($this->view->model->id, 'Task');
         $tags = $this->tagService->getItemTags($this->view->model);
         $tagStr = "";
         $sep = "";
         foreach ($tags as $tag) {
             $tagStr .= $sep . $tag->tag;
             $sep = ',';
         }
         $this->view->model->tags = $tagStr;
         // get all the issues that triggered this task
         $this->view->issues = $this->itemLinkService->getLinkedItemsOfType($this->view->model, 'to', 'Issue');
         $this->view->features = $this->itemLinkService->getLinkedItemsOfType($this->view->model, 'to', 'Feature');
         // get selectable features based on the milestont this project is in.
         $this->view->selectableFeatures = $project->getFeatures();
         $client = $this->clientService->getClient($project->clientid);
         // get all the requests for the given client
         $this->view->selectableRequests = $client->getIssues();
     }
 }
Пример #7
0
 public function viewinvoiceAction()
 {
     $this->getResponse()->setHeader('Content-type', 'text/plain');
     $invoice = $this->byId();
     $timesheet = $this->projectService->getTimesheet($invoice->timesheetid);
     if (!$timesheet) {
         throw new Exception("Must have a timesheet to view invoice");
     }
     $project = $this->projectService->getProject((int) $invoice->projectid);
     $this->view->client = $this->clientService->getClient($project->clientid);
     $this->view->invoice = $invoice;
     $timesheet->to = date('Y-m-d 23:59:59', strtotime($timesheet->to));
     // $this->view->tasks = $this->projectService->getTasks(array("projectid=" => $project->id));
     $this->view->records = $this->projectService->getSummaryTimesheet(null, null, $project->id, null, $timesheet->id, $timesheet->from, $timesheet->to);
     $this->view->project = $project;
     $this->renderRawView('invoice/view.php');
 }
Пример #8
0
 /**
  * Get all the files for a given expense
  * @return ArrayObject
  */
 public function getExpenseFiles(Expense $expense)
 {
     $client = $this->clientService->getClient($expense->clientid);
     if (!$client) {
         // throw new Exception("Invalid expense for attaching files to");
         return array();
     }
     $path = 'Expenses/' . $expense->id;
     $files = $this->fileService->listDirectory($path);
     return $files;
 }
Пример #9
0
 public function listAction()
 {
     $cid = (int) $this->_getParam('clientid');
     if ($cid) {
         $this->view->client = $this->clientService->getClient($cid);
     }
     if ($this->_getParam('_ajax')) {
         $this->renderRawView('project/list.php');
     } else {
         $this->renderView('project/list.php');
     }
 }
Пример #10
0
 public function indexAction()
 {
     $lm = $this->clientService->getClient(za()->getConfig('owning_company'));
     $path = "Clients/" . $lm->title . "/Accounts";
     if ($this->_getParam('folder')) {
         $basePath = base64_decode($this->_getParam('folder'));
         if ($basePath != $path && $basePath != $path . "/" && strpos($basePath, $path) === 0) {
             // we've got a 'starts with' situation, so lets give the view a parent path to deal with
             $this->view->parentPath = dirname($basePath);
         }
         $path = $basePath;
     }
     // The target of a picker action. If set, we need to show the picker
     $this->view->picker = $this->_getParam('picker');
     // Get all top level files
     $files = $this->fileService->listDirectory($path);
     $this->view->files = $files;
     if ($path == '/') {
         $this->view->base = '';
     } else {
         $this->view->base = trim($path, '/') . '/';
     }
     $this->renderView('filemanager/list.php');
 }
Пример #11
0
 /**
  * Generates the appropriate query for returning a list of issues
  * 
  * @param array $where
  * @return arrayobject
  */
 protected function getList($type, $where = array())
 {
     $query = $this->_getParam('query');
     if (mb_strlen($query) >= 2) {
         $where[] = new Zend_Db_Expr("title like " . $this->dbService->quote('%' . $query . '%') . " OR description like " . $this->dbService->quote('%' . $query . '%'));
     }
     // Handle this up here otherwise a model object might take
     $sortDir = $this->_getParam('sortorder', $this->_getParam('dir', 'desc'));
     if ($sortDir == 'up' || $sortDir == 'asc') {
         $sortDir = 'asc';
     } else {
         $sortDir = 'desc';
     }
     // now just iterate parameters
     $params = $this->_getAllParams();
     unset($params['title']);
     unset($params['sortorder']);
     $dummyObj = new $type();
     // get all the type's parameters
     $fields = $dummyObj->unBind();
     foreach ($fields as $name => $val) {
         // if we have a param with $name, add it to the filter
         $val = ifset($params, $name, null);
         if (!is_null($val)) {
             $where[$name . ' ='] = $val;
         }
     }
     // If not a User, can only see non-private issues
     if (za()->getUser()->getRole() == User::ROLE_EXTERNAL) {
         if (isset($fields['isprivate'])) {
             $where['isprivate='] = 0;
         }
         if (isset($fields['clientid'])) {
             $client = $this->clientService->getUserClient(za()->getUser());
             $where['clientid='] = $client->id;
         }
     }
     $sort = $this->_getParam('sortname', $this->_getParam('sort', 'updated'));
     $sort .= ' ' . $sortDir;
     $this->view->totalCount = $this->dbService->getObjectCount($where, $type);
     $currentPage = ifset($params, 'page', 1);
     $this->view->listSize = $this->_getParam('rp', za()->getConfig('project_list_size', 10));
     if ($this->_getParam("unlimited")) {
         $currentPage = null;
     }
     return $this->dbService->getObjects($type, $where, $sort, $currentPage, $this->view->listSize);
 }
Пример #12
0
 /**
  * Gets the list of attachments for a given issue
  *
  * @param unknown_type $issueId
  */
 public function getIssueFiles(Issue $issue)
 {
     $client = $this->clientService->getClient($issue->clientid);
     if (!$client) {
         throw new Exception("Invalid request for attaching files to");
     }
     $path = 'Clients/' . $client->title . '/Issues/' . $issue->id;
     $fileService = za()->getService('FileService');
     $files = array();
     try {
         $files = $fileService->listDirectory($path);
     } catch (Exception $e) {
         $this->log->err("Failed retrieving files from {$path}; " . $e->getMessage());
         $files = array();
     }
     return $files;
 }
Пример #13
0
 public function uploadcontactsAction()
 {
     if (!isset($_FILES['import']) && !isset($_FILES['import']['tmp_name'])) {
         throw new Exception("Import file not found");
     }
     $fname = $_FILES['import']['tmp_name'];
     $contacts = null;
     try {
         $contacts = $this->clientService->importContacts($fname);
     } catch (ContactImportException $cie) {
         $msg = array("Imported " . count($contacts) . " contacts, " . count($cie->errors) . " not imported.", $cie->errors);
         $this->flash($msg);
         $this->redirect('contact', 'contactimport');
         return;
     }
     $this->flash("Imported " . count($contacts) . " contacts");
     $this->redirect('contact');
 }
Пример #14
0
 /**
  * Generates the appropriate query for returning a list of issues
  *
  * @param array $where
  * @return arrayobject
  */
 protected function getIssueList($where = array())
 {
     $sortDir = $this->_getParam('sortorder', $this->_getParam('dir', 'desc'));
     if ($sortDir == 'up' || $sortDir == 'asc') {
         $sortDir = 'asc';
         $issueParams = array('dir' => 'up');
     } else {
         $sortDir = 'desc';
         $issueParams = array('dir' => 'down');
     }
     $mineOnly = $this->_getParam('mineOnly');
     if ($mineOnly) {
         $where['issue.userid='] = za()->getUser()->getUsername();
         $issueParams['mineOnly'] = $mineOnly;
     }
     $query = $this->_getParam('query');
     if (mb_strlen($query) >= 2) {
         $where[] = new Zend_Db_Expr("issue.title like " . $this->issueService->dbService->quote('%' . $query . '%') . " OR issue.description like " . $this->issueService->dbService->quote('%' . $query . '%'));
     }
     $filter = $this->_getParam('titletext');
     if (mb_strlen($filter) >= 2) {
         // add some filtering to the query
         $where['issue.title like '] = '%' . $filter . '%';
         $issueParams['titletext'] = $filter;
     }
     $filter = $this->_getParam('severity');
     if (mb_strlen($filter)) {
         // add some filtering to the query
         $where['issue.severity = '] = $filter;
         $issueParams['severity'] = $filter;
     }
     $filter = $this->_getParam('status');
     if ($filter !== null && !is_array($filter) && strlen($filter)) {
         $filter = array($filter);
         $issueParams['status'] = $filter;
     }
     if (is_array($filter)) {
         $where['status'] = $filter;
         $issueParams['status'] = $filter;
     }
     $filter = $this->_getParam('type');
     if (mb_strlen($filter)) {
         // add some filtering to the query
         $where['issue.issuetype = '] = $filter;
         $issueParams['type'] = $filter;
     }
     $filter = $this->_getParam('clientid');
     if (mb_strlen($filter)) {
         // add some filtering to the query
         $where['issue.clientid = '] = $filter;
         $issueParams['clientid'] = $filter;
     }
     $filter = $this->_getParam('projectid');
     if (mb_strlen($filter)) {
         // add some filtering to the query
         $where['issue.projectid = '] = $filter;
         $issueParams['projectid'] = $filter;
     }
     $filter = $this->_getParam('startdate');
     if (mb_strlen($filter)) {
         $where['issue.updated >= '] = date('Y-m-d 00:00:00', strtotime($filter));
         $issueParams['startdate'] = $filter;
     }
     $filter = $this->_getParam('enddate');
     if (mb_strlen($filter)) {
         $where['issue.updated <= '] = date('Y-m-d 23:59:59', strtotime($filter));
         $issueParams['enddate'] = $filter;
     }
     // If not a User, can only see non-private issues
     if (!za()->getUser()->hasRole(User::ROLE_USER)) {
         $where['issue.isprivate='] = 0;
     }
     $sort = $this->_getParam('sortname', $this->_getParam('sort', 'updated'));
     $this->view->sort = $sort;
     $issueParams['sort'] = $sort;
     $this->view->sortDir = $sortDir;
     $tmp = new Issue();
     $this->view->severities = $tmp->constraints['severity']->getValues();
     $this->view->types = $tmp->constraints['issuetype']->getValues();
     $this->view->statuses = $tmp->constraints['status']->getValues();
     $sort .= ' ' . $sortDir;
     $totalCount = $this->issueService->getIssueCount($where);
     $this->view->pagerName = 'page';
     $currentPage = ifset($this->_getAllParams(), $this->view->pagerName, 1);
     $this->view->clients = $this->clientService->getClients();
     $this->view->totalCount = $totalCount;
     $this->view->listSize = $this->_getParam('rp', za()->getConfig('project_list_size', 10));
     if ($this->_getParam("unlimited")) {
         $currentPage = null;
     }
     $this->view->searchParams = $issueParams;
     return $this->issueService->getIssues($where, $sort, $currentPage, $this->view->listSize);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     return $this->service->destroy($id);
 }
Пример #16
0
 /**
  * When saving, use the clientController saveContact so we can update
  * the user's information too.
  */
 protected function saveObject($params, $modelType)
 {
     return $this->clientService->saveContact($params);
 }
Пример #17
0
 /**
  * View the expenses for a given user / client
  */
 public function viewAction()
 {
     $view = new CompositeView();
     $view->addScriptPath('extensions/expenses/views');
     $report = $this->byId(null, 'ExpenseReport');
     $client = null;
     $user = null;
     $expenses = array();
     // we either have a fixed report, or we have a dynamic one
     if ($report) {
         if (mb_strlen($report->username)) {
             $expenses = $this->expenseService->getExpenses(array('userreportid=' => $report->id));
             $user = $this->userService->getUserByField('username', $report->username);
         } else {
             $expenses = $this->expenseService->getExpenses(array('expensereportid=' => $report->id));
             $client = $this->clientService->getClient($report->clientid);
         }
         $view->start = $report->from;
         $view->end = $report->to;
     } else {
         $client = $this->clientService->getClient($this->_getParam('clientid'));
         $user = $this->userService->getUserByField('username', $this->_getParam('username'));
         $view->user = $user;
         $start = $this->_getParam('start', $this->_getParam('start', $this->calculateDefaultStartDate()));
         $end = $this->_getParam('end', $this->_getParam('end', $this->calculateDefaultEndDate()));
         $expenses = $this->expenseService->getDynamicExpenseReport($start, $end, $user, $client);
         $view->start = $start;
         $view->end = $end;
     }
     $view->expenses = $expenses;
     $view->client = $client;
     $view->user = $user;
     $view->report = $report;
     $view->mode = $this->_getParam('pdf') ? 'pdf' : 'html';
     $content = $view->render('expense/view.php');
     if ($this->_getParam('pdf')) {
         ini_set('memory_limit', '32M');
         include_once "dompdf/dompdf_config.inc.php";
         include_once "dompdf/include/dompdf.cls.php";
         include_once "dompdf/include/frame_tree.cls.php";
         include_once "dompdf/include/stylesheet.cls.php";
         include_once "dompdf/include/frame.cls.php";
         include_once "dompdf/include/style.cls.php";
         include_once "dompdf/include/attribute_translator.cls.php";
         include_once "dompdf/include/frame_factory.cls.php";
         include_once "dompdf/include/frame_decorator.cls.php";
         include_once "dompdf/include/positioner.cls.php";
         include_once "dompdf/include/block_positioner.cls.php";
         include_once "dompdf/include/block_frame_decorator.cls.php";
         include_once "dompdf/include/frame_reflower.cls.php";
         include_once "dompdf/include/block_frame_reflower.cls.php";
         include_once "dompdf/include/frame_reflower.cls.php";
         include_once "dompdf/include/text_frame_reflower.cls.php";
         include_once "dompdf/include/canvas_factory.cls.php";
         include_once "dompdf/include/canvas.cls.php";
         include_once "dompdf/include/abstract_renderer.cls.php";
         include_once "dompdf/include/renderer.cls.php";
         include_once "dompdf/include/cpdf_adapter.cls.php";
         include_once "dompdf/include/font_metrics.cls.php";
         include_once "dompdf/include/block_renderer.cls.php";
         include_once "dompdf/include/text_renderer.cls.php";
         include_once "dompdf/include/image_cache.cls.php";
         include_once "dompdf/include/text_frame_decorator.cls.php";
         include_once "dompdf/include/inline_positioner.cls.php";
         include_once "dompdf/include/page_frame_reflower.cls.php";
         include_once "dompdf/include/page_frame_decorator.cls.php";
         include_once "dompdf/include/table_frame_decorator.cls.php";
         include_once "dompdf/include/cellmap.cls.php";
         include_once "dompdf/include/table_frame_reflower.cls.php";
         include_once "dompdf/include/table_row_frame_decorator.cls.php";
         include_once "dompdf/include/null_positioner.cls.php";
         include_once "dompdf/include/table_row_frame_reflower.cls.php";
         include_once "dompdf/include/table_cell_frame_decorator.cls.php";
         include_once "dompdf/include/table_cell_positioner.cls.php";
         include_once "dompdf/include/table_cell_frame_reflower.cls.php";
         include_once "dompdf/include/table_row_group_frame_decorator.cls.php";
         include_once "dompdf/include/table_row_group_frame_reflower.cls.php";
         include_once "dompdf/include/table_cell_renderer.cls.php";
         include_once "dompdf/include/inline_frame_decorator.cls.php";
         include_once "dompdf/include/inline_frame_reflower.cls.php";
         include_once "dompdf/include/image_frame_decorator.cls.php";
         include_once "dompdf/include/image_frame_reflower.cls.php";
         include_once "dompdf/include/inline_renderer.cls.php";
         include_once "dompdf/include/image_renderer.cls.php";
         include_once "dompdf/include/dompdf_exception.cls.php";
         $dompdf = new DOMPDF();
         // $dompdf->set_paper('letter', 'landscape');
         $dompdf->load_html($content);
         $dompdf->render();
         $name = "expenses-" . date('Y-m-d', strtotime($view->start)) . '-to-' . date('Y-m-d', strtotime($view->end)) . '.pdf';
         $dompdf->stream($name);
     } else {
         echo $content;
     }
 }
Пример #18
0
<?php

$cwd = dirname(__FILE__);
$ipath = "/include";
while ($cwd != "/") {
    if (file_exists($cwd . $ipath . "/findVLE.php")) {
        set_include_path($cwd . $ipath . PATH_SEPARATOR . $cwd . $ipath . "/PowerTLA" . PATH_SEPARATOR . get_include_path());
        break;
    }
    $cwd = dirname($cwd);
}
require_once "findVLE.php";
$service = new ClientService();
$service->run();
Пример #19
0
<?php

ProfileService::apiDefinition($apis, $enginepath, "profile.php");
ClientService::apiDefinition($apis, $enginepath, "client.php");
Пример #20
0
 /**
  * Delete a client
  *
  */
 public function deleteAction()
 {
     $client = $this->byId();
     $this->clientService->deleteClient($client);
     $this->redirect('client');
 }
Пример #21
0
 /**
  * Constructs a new SchoolAge class, setting the object_type column to ClientServicePeer::CLASSKEY_SCHOOL_AGE.
  */
 public function __construct()
 {
     parent::__construct();
     $this->setObjectType(ClientServicePeer::CLASSKEY_SCHOOL_AGE);
 }
Пример #22
0
 public function removeMember($mid, $id)
 {
     return $this->service->removeMember($mid, $id);
 }