/**
  * Renders the chart
  * @param IUser $logged_user
  * @return string
  */
 function render(IUser $logged_user)
 {
     $db_result = DB::execute("SELECT milestone_id, COUNT(*) as count FROM " . TABLE_PREFIX . "project_objects WHERE project_id = ? AND type='Task' AND state >= ? AND visibility >= ? GROUP BY milestone_id", $this->project->getId(), STATE_VISIBLE, $logged_user->getMinVisibility());
     $array_result = $db_result instanceof DBResult ? $db_result->toArrayIndexedBy('milestone_id') : false;
     if (is_foreachable($array_result)) {
         $pie_chart = new PieChart('400px', '400px', 'milestone_eta_report_pie_chart_placeholder');
         $this->serie_array = array();
         $this->milestones = array();
         // Set data for the rest
         foreach ($array_result as $serie_data) {
             $point = new ChartPoint('1', $serie_data['count']);
             $serie = new ChartSerie($point);
             if (intval($serie_data['milestone_id'])) {
                 $milestone = new RemediaMilestone(intval($serie_data['milestone_id']));
                 $label = PieChart::makeShortForPieChart($milestone->getName());
                 $this->milestones[] = $milestone;
             } else {
                 $label = lang('No Milestone');
             }
             //if
             $serie->setOption('label', $label);
             $this->serie_array[] = $serie;
         }
         //foreach
         $pie_chart->addSeries($this->serie_array);
         return $pie_chart->render();
     } else {
         return '<p class="empty_slate">' . lang('There are no milestones in this project.') . '</p>';
     }
     //if
 }
Ejemplo n.º 2
0
 /**
  * 新增用户
  * @param IUser $user
  * @return int 
  */
 public function newUser(IUser $user)
 {
     $data = $user->toArray();
     if (empty($data)) {
         return 0;
     }
     return $this->insert($data);
 }
Ejemplo n.º 3
0
 /**
  * 通知消息
  * @param IUSer $user 发送消息的人
  * @return mixed
  */
 public function notify(IUser $user)
 {
     foreach ($this->userList as $receiver) {
         if ($receiver != $user) {
             $receiver->receiveMessage($user->getMessage());
         }
     }
 }
Ejemplo n.º 4
0
/**
 * Handle on_reports_panel event
 *
 * @param ReportsPanel $panel
 * @param IUser $user
 */
function frosso_estimated_cost_handle_on_reports_panel(ReportsPanel &$panel, IUser &$user)
{
    if ($user->isProjectManager()) {
        $panel->defineRow('remedia_reports', new ReportsPanelRow(lang('Milestone Reports')));
        $panel->addTo('remedia_reports', 'my_projects_report', lang('Milestone ETA Report'), Router::assemble('frosso_estimated_cost_report'), AngieApplication::getImageUrl('module.png', FROSSO_EC_MODULE, AngieApplication::INTERFACE_DEFAULT));
    }
    // if
}
Ejemplo n.º 5
0
 /**
  *
  * @param IUser $user 
  */
 public function setUser(IUser $user)
 {
     if (!$user->isValid()) {
         throw new ErrorException(t('Unknown username and/or password'), E_ERROR);
     }
     $this->getSession()->set(self::SES_USER_KEY, $user);
 }
Ejemplo n.º 6
0
 public function testIndexWithRegularBrowser()
 {
     $this->request->expects($this->once())->method('isUserAgent')->with(['/MSIE 8.0/'])->will($this->returnValue(false));
     $this->viewController->expects($this->once())->method('getStorageInfo')->will($this->returnValue(['relative' => 123, 'owner' => 'MyName', 'ownerDisplayName' => 'MyDisplayName']));
     $this->config->expects($this->exactly(3))->method('getUserValue')->will($this->returnValueMap([[$this->user->getUID(), 'files', 'file_sorting', 'name', 'name'], [$this->user->getUID(), 'files', 'file_sorting_direction', 'asc', 'asc'], [$this->user->getUID(), 'files', 'show_hidden', false, false]]));
     $this->config->expects($this->any())->method('getAppValue')->will($this->returnArgument(2));
     $nav = new Template('files', 'appnavigation');
     $nav->assign('navigationItems', [['id' => 'files', 'appname' => 'files', 'script' => 'list.php', 'order' => 0, 'name' => new \OC_L10N_String(new \OC_L10N('files'), 'All files', []), 'active' => false, 'icon' => ''], ['id' => 'favorites', 'appname' => 'files', 'script' => 'simplelist.php', 'order' => 5, 'name' => null, 'active' => false, 'icon' => ''], ['id' => 'sharingin', 'appname' => 'files_sharing', 'script' => 'list.php', 'order' => 10, 'name' => new \OC_L10N_String(new \OC_L10N('files_sharing'), 'Shared with you', []), 'active' => false, 'icon' => ''], ['id' => 'sharingout', 'appname' => 'files_sharing', 'script' => 'list.php', 'order' => 15, 'name' => new \OC_L10N_String(new \OC_L10N('files_sharing'), 'Shared with others', []), 'active' => false, 'icon' => ''], ['id' => 'sharinglinks', 'appname' => 'files_sharing', 'script' => 'list.php', 'order' => 20, 'name' => new \OC_L10N_String(new \OC_L10N('files_sharing'), 'Shared by link', []), 'active' => false, 'icon' => ''], ['id' => 'systemtagsfilter', 'appname' => 'systemtags', 'script' => 'list.php', 'order' => 25, 'name' => new \OC_L10N_String(new \OC_L10N('systemtags'), 'Tags', []), 'active' => false, 'icon' => ''], ['id' => 'trashbin', 'appname' => 'files_trashbin', 'script' => 'list.php', 'order' => 50, 'name' => new \OC_L10N_String(new \OC_L10N('files_trashbin'), 'Deleted files', []), 'active' => false, 'icon' => '']]);
     $expected = new Http\TemplateResponse('files', 'index', ['usedSpacePercent' => 123, 'owner' => 'MyName', 'ownerDisplayName' => 'MyDisplayName', 'isPublic' => false, 'defaultFileSorting' => 'name', 'defaultFileSortingDirection' => 'asc', 'showHiddenFiles' => false, 'mailNotificationEnabled' => 'no', 'mailPublicNotificationEnabled' => 'no', 'allowShareWithLink' => 'yes', 'appNavigation' => $nav, 'appContents' => [['id' => 'files', 'content' => null], ['id' => 'favorites', 'content' => null], ['id' => 'sharingin', 'content' => null], ['id' => 'sharingout', 'content' => null], ['id' => 'sharinglinks', 'content' => null], ['id' => 'systemtagsfilter', 'content' => null], ['id' => 'trashbin', 'content' => null]]]);
     $policy = new Http\ContentSecurityPolicy();
     $policy->addAllowedFrameDomain('\'self\'');
     $expected->setContentSecurityPolicy($policy);
     $this->assertEquals($expected, $this->viewController->index('MyDir', 'MyView'));
 }
Ejemplo n.º 7
0
 /**
  * Loads a page instance.
  * This method will create a page instance or load it from memory.
  * If the page name contains module ID, the module will be also loaded.
  * Errors happened during the loading will be handled using the error handler.
  * @param string the page name (either PageType or ModuleName:PageType).
  * @return TPage the loaded page instance
  * @see createComponent()
  */
 public function loadPage($type)
 {
     if (isset($this->pages[$type])) {
         return $this->pages[$type];
     }
     $type = trim($type, ':');
     $pos = strpos($type, ':');
     if ($pos === false) {
         $moduleName = '';
         $pageName = $type;
     } else {
         $moduleName = substr($type, 0, $pos);
         $pageName = substr($type, $pos + 1);
     }
     try {
         if (empty($pageName)) {
             throw new TPageNotDefinedException("[empty]");
         }
         // user authentication
         $role = $this->getRequiredRole($moduleName, $pageName);
         if (!is_null($role)) {
             if (!$this->user->isAuthenticated()) {
                 $this->user->onAuthenticationRequired($type);
                 $this->errorHandler->handleError(TErrorHandler::CASE_UNAUTHORIZED, new TPageUnauthorizedException($type));
             }
         }
         // creating the module and page objects
         $module = empty($moduleName) ? null : $this->loadModule($moduleName);
         if (!pradoImportClass($pageName)) {
             throw new TPageNotDefinedException($pageName);
         }
         $page = $this->createComponent($pageName, $pageName);
         if (!$page instanceof TPage) {
             // will use is_subclass_of since PHP 5.0.3
             throw new TPageNotDefinedException($pageName);
         }
         $page->setModule($module);
         // page authorization
         $authorized = is_null($role) ? true : $this->user->isInRole($role);
         if ($authorized) {
             $authorized = $page->onAuthorize($this->user);
         }
         if ($authorized) {
             return $page;
         } else {
             $this->user->onAuthorizationRequired($page);
             $this->errorHandler->handleError(TErrorHandler::CASE_UNAUTHORIZED, new TPageUnauthorizedException($type));
         }
     } catch (TPageNotDefinedException $e) {
         $this->errorHandler->handleError(TErrorHandler::CASE_PAGENOTFOUND, $e);
     } catch (TModuleNotDefinedException $e) {
         $this->errorHandler->handleError(TErrorHandler::CASE_PAGENOTFOUND, $e);
     } catch (Exception $e) {
         $this->errorHandler->handleError(TErrorHandler::CASE_INTERNALERROR, $e);
     }
 }
Ejemplo n.º 8
0
 public function update(IUser $user)
 {
     $this->db->updateRecord($this->table, ["clmnID" => $user->getID()], ["clmnUserName" => $user->getName(), "clmnPassword" => $user->getPassword(), "clmnEmail" => $user->getEmail()]);
 }
 /**
  * Gets a list of workgroups where the user is included.
  *
  * @param IUser $user
  * @return array(IWorkgroup)
  * @throws EyeUMException User not found.
  */
 public function getAllWorkgroupsByUser(IUser $user)
 {
     // check existence
     $this->getUserById($user->getId());
     try {
         $refAssignation = $this->getNewUserWorkgroupAssignationInstance();
         $refAssignation->setUserId($user->getId());
         $assignations = $this->getAllUserWorkgroupAssignations($refAssignation);
         $return = array();
         foreach ($assignations as $assignation) {
             $return[$assignation->getWorkgroupId()] = $this->getWorkgroupById($assignation->getWorkgroupId());
         }
         return $return;
     } catch (Exception $e) {
         throw new EyeUMException('Unable to retrieve all the workgroups from user ' . $user->getName() . '.', 0, $e);
     }
 }
Ejemplo n.º 10
0
 public function retrieveLastRelationsByUserId(IUser $user, $limit)
 {
     try {
         $transferObject = new Relation();
         $query = 'SELECT sourceId, targetId FROM relation WHERE (sourceId = :sourceid OR targetId = :targetid) AND (state != "pending") ORDER BY date DESC LIMIT :limit';
         $stmt = $this->dao->prepare($query);
         $result = $this->dao->execute($stmt, array('sourceid' => $user->getId(), 'targetId' => $user->getId(), 'limit' => $limit));
         $result = $stmt->fetchAll(PDO::FETCH_ASSOC);
         $toReturn = array();
         foreach ($result as $entry) {
             $toReturn[] = $user->getId() == $entry['sourceId'] ? $entry['targetId'] : $entry['sourceId'];
         }
         return $toReturn;
     } catch (Exception $e) {
         throw new EyePeopleException($e->getMessage());
     }
 }
Ejemplo n.º 11
0
 public function setUser(IUser $user)
 {
     $this->set('user', $user->getUserId());
 }
 public function setUser(IUser $user)
 {
     $this->pdo->exec("update oauth_token set user_id = '" . $user->getId() . "' where id = " . $this->id);
     $this->user = $user;
 }