コード例 #1
0
ファイル: filters.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Override default filter values
  *
  * ex: change hub_id to Hub
  *
  * @param  $vals   - incoming values
  * @param  $column - incoming column for which values pertain
  * @return $return - outgoing values
  */
 public static function filtersOverrides($vals, $column)
 {
     $return = [];
     if ($column == 'task_id') {
         $ids = array_map(function ($task) {
             return $task->val;
         }, $vals);
         $tasks = Task::whereIn('id', $ids)->rows();
     }
     foreach ($vals as $val) {
         // Just so I don't have to keep writing $val->val
         $value = $val->val;
         $x = array();
         $x['value'] = $value;
         $x['display'] = $value;
         // Now override at will...
         if ($column == 'assignee_id' || $column == 'liaison_id' || $column == 'user_id') {
             $x['value'] = $value;
             $x['display'] = User::getInstance($value)->get('name');
             if ($value == 0) {
                 $x['display'] = 'No User';
             }
         } elseif ($column == 'hub_id') {
             $x['value'] = $value;
             $x['display'] = Hub::oneOrFail($value)->name;
         } elseif ($column == 'task_id') {
             $x['value'] = $value;
             $x['display'] = $tasks->seek($value)->name;
         } elseif ($column == 'active') {
             $x['value'] = $value;
             $x['display'] = $value ? 'Yes' : 'No';
         }
         $return[] = $x;
     }
     // Get an array of kays for sorting purposes
     // We do this here, as opposed to in the query, because the data could have been modified at this point by the overrides above
     foreach ($return as $key => $row) {
         $display[$key] = $row['display'];
     }
     // Do the sort
     array_multisort($display, SORT_ASC, $return);
     return $return;
 }
コード例 #2
0
ファイル: display.php プロジェクト: mined-gatech/hubzero-cms
								<?php 
echo Lang::txt('COM_TIME_OVERVIEW_HUB');
?>
:
								<span class="hub-error error-message"><?php 
echo Lang::txt('COM_TIME_OVERVIEW_PLEASE_SELECT_HUB');
?>
</span>
							</label>
							<select name="hub_id" id="hub_id" tabindex="1">
								<option value=""><?php 
echo Lang::txt('COM_TIME_NO_HUB');
?>
</option>
								<?php 
foreach (Hub::all()->ordered() as $hub) {
    ?>
									<option value="<?php 
    echo $hub->id;
    ?>
">
										<?php 
    echo $hub->name;
    ?>
									</option>
								<?php 
}
?>
							</select>
						</div>
						<div class="grouping" id="task-group">
コード例 #3
0
ファイル: default.php プロジェクト: mined-gatech/hubzero-cms
			</div>
		</div>
		<div class="clear"></div>

		<div class="grouping">
			<label for="hub_id"><?php 
echo Lang::txt('PLG_SUPPORT_TIME_HUB');
?>
:
				<select name="hub_id" id="hub_id">
					<option value=""><?php 
echo Lang::txt('PLG_SUPPORT_TIME_NO_HUB_SELECTED');
?>
</option>
					<?php 
foreach (Hub::all()->order('name', 'asc') as $hub) {
    ?>
						<option value="<?php 
    echo $hub->id;
    ?>
">
							<?php 
    echo $hub->name;
    ?>
						</option>
					<?php 
}
?>
				</select>
			</label>
コード例 #4
0
ファイル: edit.php プロジェクト: kevinwojo/hubzero-cms
?>
 />No
				</div>

				<div class="grouping" id="hub-group">
					<label for="hub_id"><?php 
echo Lang::txt('COM_TIME_TASKS_HUB_NAME');
?>
:</label>
					<select name="hub_id" id="hub_id">
						<option value=""><?php 
echo Lang::txt('COM_TIME_NO_HUB');
?>
</option>
						<?php 
foreach (Hub::whereEquals('active', 1)->order('name', 'asc') as $hub) {
    ?>
							<option <?php 
    echo $hub->id == $this->row->hub->id ? 'selected="selected" ' : '';
    ?>
value="<?php 
    echo $hub->id;
    ?>
">
								<?php 
    echo $hub->name;
    ?>
							</option>
						<?php 
}
?>
コード例 #5
0
ファイル: csv.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Download CSV
  *
  * @return void
  */
 public static function download()
 {
     // Load language
     Lang::load('plg_time_csv', __DIR__);
     $hub_id = Request::getInt('hub_id', null);
     $start = Request::getCmd('start_date', Date::of(strtotime('today - 1 month'))->format('Y-m-d'));
     $end = Request::getCmd('end_date', Date::format('Y-m-d'));
     $records = Record::all()->where('date', '>=', $start)->where('date', '<=', Date::of(strtotime($end . ' + 1 day'))->format('Y-m-d'))->order('date', 'asc');
     if (isset($hub_id) && $hub_id > 0) {
         // @FIXME: is there a better way to do this?
         $records->whereIn('task_id', Task::select('id')->whereEquals('hub_id', $hub_id)->rows()->fieldsByKey('id'));
         $hubname = Hub::oneOrFail($hub_id)->name_normalized;
     }
     $all = true;
     foreach (Request::query() as $key => $value) {
         if (strpos($key, 'fields-') !== false) {
             $all = false;
         }
     }
     $filename = 'time_report';
     $filename .= isset($hubname) ? '_' . $hubname : '';
     $filename .= '_' . Date::of($start)->format('Ymd');
     $filename .= '-' . Date::of($end)->format('Ymd');
     $filename .= '.csv';
     // Set content type headers
     header("Content-type: application/csv");
     header("Content-Disposition: attachment; filename={$filename}");
     header("Pragma: no-cache");
     header("Expires: 0");
     $row = array();
     if ($hub = Request::getInt('fields-hub', $all)) {
         $row[] = Lang::txt('PLG_TIME_CSV_HUB');
     }
     if ($task = Request::getInt('fields-task', $all)) {
         $row[] = Lang::txt('PLG_TIME_CSV_TASK');
     }
     if ($user = Request::getInt('fields-user', $all)) {
         $row[] = Lang::txt('PLG_TIME_CSV_USER');
     }
     if ($date = Request::getInt('fields-date', $all)) {
         $row[] = Lang::txt('PLG_TIME_CSV_DATE');
     }
     if ($time = Request::getInt('fields-time', $all)) {
         $row[] = Lang::txt('PLG_TIME_CSV_TIME');
     }
     if ($description = Request::getInt('fields-description', $all)) {
         $row[] = Lang::txt('PLG_TIME_CSV_DESCRIPTION');
     }
     echo implode(',', $row) . "\n";
     $permissions = new Permissions('com_time');
     foreach ($records->including('task.hub', 'user') as $record) {
         if ($permissions->can('view.report', 'hub', $record->task->hub_id)) {
             $output = fopen('php://output', 'w');
             $row = array();
             if ($hub) {
                 $row[] = $record->task->hub->name;
             }
             if ($task) {
                 $row[] = $record->task->name;
             }
             if ($user) {
                 $row[] = $record->user->name;
             }
             if ($date) {
                 $row[] = Date::of($record->date)->toLocal();
             }
             if ($time) {
                 $row[] = $record->time;
             }
             if ($description) {
                 $row[] = $record->description;
             }
             fputcsv($output, $row);
             fclose($output);
         }
     }
     exit;
 }
コード例 #6
0
ファイル: timev1_0.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Shows a single hub
  *
  * @apiMethod GET
  * @apiUri    /time/showHub
  * @apiParameter {
  * 		"name":        "id",
  * 		"description": "Hub ID",
  * 		"type":        "integer",
  * 		"required":    true,
  * 		"default":     null
  * }
  * @return  void
  */
 public function showHubTask()
 {
     // Require authentication and authorization
     $this->requiresAuthentication();
     $this->authorizeOrFail();
     // Incoming posted data
     $id = Request::getInt('id');
     // Error checking
     if (empty($id)) {
         App::abort(404, 'Missing id parameter');
     }
     try {
         $hub = Hub::oneOrFail($id);
     } catch (Hubzero\Error\Exception\RuntimeException $e) {
         App::abort(404, 'Hub not found');
     }
     $result = new stdClass();
     $result->hname = $hub->name;
     $result->hliaison = $hub->liaison;
     $result->hsupportlevel = $hub->support_level;
     $result->hanniversarydate = $hub->anniversary_date;
     // Create object with specific hub properties
     $response = new stdClass();
     $response->hub = $result;
     // Return object
     $this->send($response);
 }
コード例 #7
0
ファイル: edit.php プロジェクト: mined-gatech/hubzero-cms
?>
 />No
				</div>

				<div class="grouping" id="hub-group">
					<label for="hub_id"><?php 
echo Lang::txt('COM_TIME_TASKS_HUB_NAME');
?>
:</label>
					<select name="hub_id" id="hub_id">
						<option value=""><?php 
echo Lang::txt('COM_TIME_NO_HUB');
?>
</option>
						<?php 
foreach (Hub::whereEquals('active', 1) as $hub) {
    ?>
							<option <?php 
    echo $hub->id == $this->row->hub->id ? 'selected="selected" ' : '';
    ?>
value="<?php 
    echo $hub->id;
    ?>
">
								<?php 
    echo $hub->name;
    ?>
							</option>
						<?php 
}
?>
コード例 #8
0
ファイル: hubs.php プロジェクト: mined-gatech/hubzero-cms
 /**
  * Delete hubs
  *
  * @return void
  */
 public function deleteTask()
 {
     // Get model
     $hub = Hub::oneOrFail(Request::getInt('id'));
     // If there are active tasks, don't allow deletion
     if ($hub->tasks->count() > 0) {
         App::redirect(Route::url($this->base . '&task=readonly&id=' . $hub->get('id')), Lang::txt('COM_TIME_HUBS_DELETE_HAS_ASSOCIATED_TASKS'), 'warning');
         return;
     }
     // Delete the contacts first
     if (!$hub->contacts->destroyAll()) {
         App::redirect(Route::url($this->base . '&task=readonly&id=' . $hub->get('id')), Lang::txt('COM_TIME_HUBS_DELETE_CONTACTS_FAILED'), 'warning');
         return;
     }
     // Now delete the actual hub
     if (!$hub->destroy()) {
         App::redirect(Route::url($this->base . '&task=readonly&id=' . $hub->get('id')), Lang::txt('COM_TIME_HUBS_DELETE_FAILED'), 'warning');
         return;
     }
     // Set the redirect
     App::redirect(Route::url($this->base . $this->start($hub)), Lang::txt('COM_TIME_HUBS_DELETE_SUCCESSFUL'), 'passed');
 }