本文整理汇总了PHP中CProject::load方法的典型用法代码示例。如果您正苦于以下问题:PHP CProject::load方法的具体用法?PHP CProject::load怎么用?PHP CProject::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CProject
的用法示例。
在下文中一共展示了CProject::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: store
public function store(CAppUI $AppUI = null)
{
global $AppUI;
$perms = $AppUI->acl();
$stored = false;
$this->w2PTrimAll();
$this->project_target_budget = str_replace(',', '', $this->project_target_budget);
// ensure changes of state in checkboxes is captured
$this->project_active = (int) $this->project_active;
$this->project_private = (int) $this->project_private;
$this->project_target_budget = $this->project_target_budget ? $this->project_target_budget : 0.0;
$this->project_actual_budget = $this->project_actual_budget ? $this->project_actual_budget : 0.0;
// Make sure project_short_name is the right size (issue for languages with encoded characters)
if (mb_strlen($this->project_short_name) > 10) {
$this->project_short_name = mb_substr($this->project_short_name, 0, 10);
}
if (empty($this->project_end_date)) {
$this->project_end_date = null;
}
$errorMsgArray = $this->check();
if (count($errorMsgArray) > 0) {
return $errorMsgArray;
}
$this->project_id = (int) $this->project_id;
// convert dates to SQL format first
if ($this->project_start_date) {
$date = new CDate($this->project_start_date);
$this->project_start_date = $date->format(FMT_DATETIME_MYSQL);
}
if ($this->project_end_date) {
$date = new CDate($this->project_end_date);
$date->setTime(23, 59, 59);
$this->project_end_date = $date->format(FMT_DATETIME_MYSQL);
}
if ($this->project_actual_end_date) {
$date = new CDate($this->project_actual_end_date);
$this->project_actual_end_date = $date->format(FMT_DATETIME_MYSQL);
}
// let's check if there are some assigned departments to project
if ('' != $this->project_actual_end_date) {
$obj->project_departments = implode(',', w2PgetParam($_POST, 'dept_ids', array()));
}
// check project parents and reset them to self if they do not exist
if (!$this->project_parent) {
$this->project_parent = $this->project_id;
$this->project_original_parent = $this->project_id;
} else {
$parent_project = new CProject();
$parent_project->load($this->project_parent);
$this->project_original_parent = $parent_project->project_original_parent;
}
if (!$this->project_original_parent) {
$this->project_original_parent = $this->project_id;
}
/*
* TODO: I don't like the duplication on each of these two branches, but I
* don't have a good idea on how to fix it at the moment...
*/
if ($this->project_id && $perms->checkModuleItem('projects', 'edit', $this->company_id)) {
$q = new DBQuery();
$this->project_updated = $q->dbfnNow();
if ($msg = parent::store()) {
return $msg;
}
addHistory('projects', $this->project_id, 'update', $this->project_name, $this->project_id);
$stored = true;
}
if (0 == $this->project_id && $perms->checkModuleItem('projects', 'add')) {
$q = new DBQuery();
$this->project_updated = $q->dbfnNow();
$this->project_created = $q->dbfnNow();
if ($msg = parent::store()) {
return $msg;
}
if (0 == $this->project_parent || 0 == $this->project_original_parent) {
$this->project_parent = $this->project_id;
$this->project_original_parent = $this->project_id;
if ($msg = parent::store()) {
return $msg;
}
}
addHistory('projects', $this->project_id, 'add', $this->project_name, $this->project_id);
$stored = true;
}
//split out related departments and store them seperatly.
$q = new DBQuery();
$q->setDelete('project_departments');
$q->addWhere('project_id=' . (int) $this->project_id);
$q->exec();
$q->clear();
if ($this->project_departments) {
$departments = explode(',', $this->project_departments);
foreach ($departments as $department) {
$q->addTable('project_departments');
$q->addInsert('project_id', $this->project_id);
$q->addInsert('department_id', $department);
$q->exec();
$q->clear();
}
}
//.........这里部分代码省略.........
示例2: testDeleteWithChildren
/**
* Tests deleting a task with children
*/
public function testDeleteWithChildren()
{
$this->obj->load(15);
$children = $this->obj->getDeepChildren();
$this->obj->delete();
foreach ($children as $child) {
$this->assertFalse($this->obj->load($child));
$this->assertEquals(0, count($this->obj->getAssignedUsers($child)));
$this->assertEquals(0, count($this->obj->getTaskLogs($child)));
$this->assertEquals(0, count($this->obj->getAssignedUsers($child)));
$this->assertEquals(0, count($this->obj->getDependencyList($child)));
$this->assertEquals(0, count($this->obj->getDependentTaskList($child)));
}
/**
* Test to make sure project task count was updated
*/
$project = new CProject();
$project->load(1);
$this->assertEquals(27, $project->project_task_count);
}
示例3: die
<?php
if (!defined('W2P_BASE_DIR')) {
die('You should not call this file directly.');
}
$sort = w2PgetParam($_REQUEST, 'sort', 'asc');
$forum_id = w2PgetParam($_REQUEST, 'forum_id', 0);
$message_id = w2PgetParam($_REQUEST, 'message_id', 0);
$perms =& $AppUI->acl();
if (!$perms->checkModuleItem('forums', 'view', $forum_id)) {
$AppUI->redirect(ACCESS_DENIED);
}
$forum = new CForum();
$forum->load($forum_id);
$project = new CProject();
$project->load($forum->forum_project);
$messages = $forum->getMessages(null, $forum_id, $message_id, $sort);
// get the prefered date format
$df = $AppUI->getPref('SHDATEFORMAT');
$df .= ' ' . $AppUI->getPref('TIMEFORMAT');
$pdfdata = array();
$pdfhead = array('Date', 'User', 'Message');
foreach ($messages as $row) {
// Find the parent message - the topic.
if ($row['message_id'] == $message_id) {
$topic = $row['message_title'];
}
$date = new w2p_Utilities_Date($AppUI->formatTZAwareTime($row['message_date'], '%Y-%m-%d %T'));
$pdfdata[] = array($date->format($df), $row['contact_display_name'], '<b>' . $row['message_title'] . '</b>' . "\n" . $row['message_body']);
}
$font_dir = W2P_BASE_DIR . '/lib/ezpdf/fonts';
示例4: arrayMerge
// get internal companies
// 6 is standard value for internal companies
$companies_internal = $row->listCompaniesByType(array('6'));
$companies_internal = arrayMerge(array('0' => ''), $companies_internal);
// pull users
$q = new DBQuery();
$q->addTable('users', 'u');
$q->addTable('contacts', 'con');
$q->addQuery('user_id');
$q->addQuery('CONCAT_WS(", ",contact_last_name,contact_first_name)');
$q->addOrder('contact_last_name');
$q->addWhere('u.user_contact = con.contact_id');
$users = $q->loadHashList();
// load the record data
$row = new CProject();
if (!$row->load($project_id, false) && $project_id > 0) {
$AppUI->setMsg('Project');
$AppUI->setMsg("invalidID", UI_MSG_ERROR, true);
$AppUI->redirect();
} else {
if (count($companies) < 2 && $project_id == 0) {
$AppUI->setMsg("noCompanies", UI_MSG_ERROR, true);
$AppUI->redirect();
}
}
if ($project_id == 0 && $company_id > 0) {
$row->project_company = $company_id;
}
// add in the existing company if for some reason it is dis-allowed
if ($project_id && !array_key_exists($row->project_company, $companies)) {
$q = new DBQuery();
示例5: canUserEditTimeInformation
function canUserEditTimeInformation()
{
global $AppUI;
$project = new CProject();
$project->load($this->task_project);
// Code to see if the current user is
// enabled to change time information related to task
$can_edit_time_information = false;
// Let's see if all users are able to edit task time information
if (dPgetConfig('restrict_task_time_editing') == true && $this->task_id > 0) {
// Am I the task owner?
if ($this->task_owner == $AppUI->user_id) {
$can_edit_time_information = true;
}
// Am I the project owner?
if ($project->project_owner == $AppUI->user_id) {
$can_edit_time_information = true;
}
// Am I sys admin?
if (getPermission('admin', 'edit')) {
$can_edit_time_information = true;
}
} else {
if (dPgetConfig('restrict_task_time_editing') == false || $this->task_id == 0) {
// If all users are able, then don't check anything
$can_edit_time_information = true;
}
}
return $can_edit_time_information;
}
示例6: testDelete
/**
* Tests deletion of a project.
*/
public function testDelete()
{
$this->obj->bind($this->post_data);
$result = $this->obj->store();
$this->assertTrue($result);
$original_id = $this->obj->project_id;
$result = $this->obj->delete();
$item = new CProject();
$item->overrideDatabase($this->mockDB);
$this->mockDB->stageHash(array('project_name' => '', 'project_url' => ''));
$item->load($original_id);
$this->assertTrue(is_a($item, 'CProject'));
$this->assertEquals('', $item->project_name);
$this->assertEquals('', $item->project_url);
/*
* TODO: Not sure on how to test the cascading deletes. They're handled
* in PHP, not in the database, so we need some assurance that they
* actually happen..
*/
}
示例7: dPgetParam
$printpdf = dPgetParam($_REQUEST, 'printpdf', 0);
$monospacefont = dPgetParam($_REQUEST, 'monospacefont');
// Get the state of formatting variables here /////////////////////////////////////////////////////
ini_set('memory_limit', $dPconfig['reset_memory_limit']);
include $AppUI->getLibraryClass('jpgraph/src/jpgraph');
include $AppUI->getLibraryClass('jpgraph/src/jpgraph_gantt');
require_once 'tasks.class.php';
$project_id = dPgetParam($_REQUEST, 'project_id', 0);
$f = dPgetParam($_REQUEST, 'f', 0);
// get the prefered date format
$df = $AppUI->getPref('SHDATEFORMAT');
require_once $AppUI->getModuleClass('projects');
$project = new CProject();
if ($project_id > 0) {
$criticalTasks = $project->getCriticalTasks($project_id);
$project->load($project_id);
}
// pull valid projects and their percent complete information
$q = new DBQuery();
$q->addTable('projects');
$q->addQuery('project_id, project_color_identifier, project_name' . ', project_start_date, project_end_date');
$q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project');
$q->addWhere('project_status != 7');
$q->addGroup('project_id');
$q->addOrder('project_name');
$project->setAllowedSQL($AppUI->user_id, $q);
$projects = $q->loadHashList('project_id');
$q->clear();
$caller = defVal(@$_REQUEST['caller'], null);
/**
* if task filtering has been requested create the list of task_ids
示例8: canAdmin
public function canAdmin()
{
if (!$this->file_project) {
return false;
}
if (!$this->file_id) {
return false;
}
$project = new CProject();
$project->project_id = $this->file_project;
$project->load();
return $project->project_owner == $this->_AppUI->user_id;
}
示例9: updateTaskCount
/**
* @deprecated
*/
public static function updateTaskCount($projectId, $taskCount)
{
trigger_error("CProject::updateTaskCount has been deprecated in v2.3 and will be removed by v4.0. Please use CProject::updateTaskCache instead.", E_USER_NOTICE);
if ((int) $projectId) {
$project = new CProject();
$project->load($projectId);
$project->project_task_count = $taskCount;
$project->store();
self::updatePercentComplete($projectId);
}
}
示例10: getTaskTooltip
function getTaskTooltip($task_id)
{
global $AppUI;
if (!$task_id) {
return '';
}
$df = $AppUI->getPref('SHDATEFORMAT');
$tf = $AppUI->getPref('TIMEFORMAT');
$task = new CTask();
// load the record data
$task->load($task_id);
// load the event types
$types = w2PgetSysVal('TaskType');
$assignees = $task->assignees($task_id);
$assigned = array();
foreach ($assignees as $user) {
$assigned[] = $user['contact_name'] . ' ' . $user['perc_assignment'] . '%';
}
$start_date = (int) $task->task_start_date ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($task->task_start_date, '%Y-%m-%d %T')) : null;
$end_date = (int) $task->task_end_date ? new w2p_Utilities_Date($AppUI->formatTZAwareTime($task->task_end_date, '%Y-%m-%d %T')) : null;
// load the record data
$project = new CProject();
$project->load($task->task_project);
$task_project = $project->project_name;
$company = new CCompany();
$company->load($project->project_company);
$task_company = $company->company_name;
$tt = '<table class="tool-tip">';
$tt .= '<tr>';
$tt .= ' <td valign="top" width="40%">';
$tt .= ' <strong>' . $AppUI->_('Details') . '</strong>';
$tt .= ' <table cellspacing="3" cellpadding="2" width="100%">';
$tt .= ' <tr>';
$tt .= ' <td class="tip-label">' . $AppUI->_('Company') . '</td>';
$tt .= ' <td>' . $task_company . '</td>';
$tt .= ' </tr>';
$tt .= ' <tr>';
$tt .= ' <td class="tip-label">' . $AppUI->_('Project') . '</td>';
$tt .= ' <td>' . $task_project . '</td>';
$tt .= ' </tr>';
$tt .= ' <tr>';
$tt .= ' <td class="tip-label">' . $AppUI->_('Type') . '</td>';
$tt .= ' <td>' . $AppUI->_($types[$task->task_type]) . '</td>';
$tt .= ' </tr> ';
$tt .= ' <tr>';
$tt .= ' <td class="tip-label">' . $AppUI->_('Progress') . '</td>';
$tt .= ' <td>' . sprintf("%.1f%%", $task->task_percent_complete) . '</td>';
$tt .= ' </tr> ';
$tt .= ' <tr>';
$tt .= ' <td class="tip-label">' . $AppUI->_('Starts') . '</td>';
$tt .= ' <td>' . ($start_date ? $start_date->format($df . ' ' . $tf) : '-') . '</td>';
$tt .= ' </tr>';
$tt .= ' <tr>';
$tt .= ' <td class="tip-label">' . $AppUI->_('Ends') . '</td>';
$tt .= ' <td>' . ($end_date ? $end_date->format($df . ' ' . $tf) : '-') . '</td>';
$tt .= ' </tr>';
$tt .= ' <tr>';
$tt .= ' <td class="tip-label">' . $AppUI->_('Assignees') . '</td>';
$tt .= ' <td>';
$tt .= implode('<br />', $assigned);
$tt .= ' </tr>';
$tt .= ' </table>';
$tt .= ' </td>';
$tt .= ' <td width="60%" valign="top">';
$tt .= ' <strong>' . $AppUI->_('Description') . '</strong>';
$tt .= ' <table cellspacing="0" cellpadding="2" border="0" width="100%">';
$tt .= ' <tr>';
$tt .= ' <td class="tip-label description">';
$tt .= ' ' . $task->task_description;
$tt .= ' </td>';
$tt .= ' </tr>';
$tt .= ' </table>';
$tt .= ' </td>';
$tt .= '</tr>';
$tt .= '</table>';
return $tt;
}
示例11: CCompany
$row = new CCompany();
$companies = $row->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name');
$companies = arrayMerge(array('0' => ''), $companies);
// pull users
$q = new DBQuery();
$q->addTable('users', 'u');
$q->addTable('contacts', 'c');
$q->addQuery('user_id');
$q->addQuery('CONCAT_WS(" ",contact_first_name,contact_last_name)');
$q->addOrder('contact_last_name');
$q->addWhere('u.user_contact = c.contact_id');
$q->addWhere('user_id <> 1');
$users = $q->loadHashList();
// load the record data
$row = new CProject();
if ($project_id > 0 && !$row->load($project_id, false)) {
$AppUI->setMsg('Project');
$AppUI->setMsg("invalidID", UI_MSG_ERROR, true);
$AppUI->redirect();
} else {
if (count($companies) < 2 && $project_id == 0) {
$AppUI->setMsg("noCompanies", UI_MSG_ERROR, true);
$AppUI->redirect();
}
}
if ($project_id == 0 && $company_id > 0) {
$row->project_company = $company_id;
}
// add in the existing company if for some reason it is dis-allowed
if ($project_id && !array_key_exists($row->project_company, $companies)) {
$q = new DBQuery();
示例12: remind
/**
* Called by the Event Queue processor to process a reminder
* on a task.
* @access public
* @param string $notUsed Module name (not used)
* @param string $notUsed2 Type of event (not used)
* @param integer $id ID of task being reminded
* @param integer $owner Originator of event
* @param mixed $notUsed event-specific arguments.
*
* @return mixed true, dequeue event, false, event stays in queue.
* -1, event is destroyed.
*/
public function remind($notUsed = null, $notUsed2 = null, $id, $owner, $notUsed3 = null)
{
// At this stage we won't have an object yet
if (!$this->load($id)) {
return -1;
// No point it trying again later.
}
$this->htmlDecode();
// Only remind on working days.
$today = new w2p_Utilities_Date();
if (!$today->isWorkingDay()) {
return true;
}
// Check if the task is completed
if ($this->task_percent_complete == 100) {
return -1;
}
$contacts = $this->assignees($this->task_id);
$contact = new CContact();
$owner = $contact->findContactByUserId($this->task_owner);
$contacts[$owner->contact_id] = array('user_id' => $this->task_owner, 'contact_id' => $owner->contact_id, 'contact_name' => $owner->contact_display_name, 'contact_email' => $owner->contact_email);
// build the subject line, based on how soon the
// task will be overdue.
$starts = new w2p_Utilities_Date($this->task_start_date);
$expires = new w2p_Utilities_Date($this->task_end_date);
$now = new w2p_Utilities_Date();
$diff = $expires->dateDiff($now);
$diff *= $expires->compare($expires, $now);
$prefix = $this->_AppUI->_('Task Due', UI_OUTPUT_RAW);
if ($diff == 0) {
$msg = $this->_AppUI->_('TODAY', UI_OUTPUT_RAW);
} elseif ($diff == 1) {
$msg = $this->_AppUI->_('TOMORROW', UI_OUTPUT_RAW);
} elseif ($diff < 0) {
$msg = $this->_AppUI->_(array('OVERDUE', abs($diff), 'DAYS'));
$prefix = $this->_AppUI->_('Task', UI_OUTPUT_RAW);
} else {
$msg = $this->_AppUI->_(array($diff, 'DAYS'));
}
$project = new CProject();
$project->overrideDatabase($this->_query);
$project_name = $project->load($this->task_project)->project_name;
// Check to see that the project is both active and not a template
if (!$project->project_active || $project->project_status == w2PgetConfig('template_projects_status_id', 0)) {
return -1;
}
$subject = $prefix . ' ' . $msg . ' ' . $this->task_name . '::' . $project_name;
$emailManager = new w2p_Output_EmailManager($this->_AppUI);
$body = $emailManager->getTaskRemind($this, $msg, $project_name, $contacts);
$mail = new w2p_Utilities_Mail();
$mail->Subject($subject);
foreach ($contacts as $contact) {
$user_id = $contact['user_id'];
$this->_AppUI->loadPrefs($user_id);
$df = $this->_AppUI->getPref('SHDATEFORMAT');
$tz = $this->_AppUI->getPref('TIMEZONE');
$body = str_replace('START-TIME', $starts->convertTZ($tz)->format($df), $body);
$body = str_replace('END-TIME', $expires->convertTZ($tz)->format($df), $body);
$mail->Body($body, $this->_locale_char_set);
$mail->To($contact['contact_email'], true);
$mail->Send();
}
return true;
}
示例13: executeDelete
/**
* Delete Request Handler
*
* This method is called when a request is a DELETE
*
* @return array
*/
public function executeDelete()
{
$valid = $this->hasRequiredParameters($this->requiredParams);
if ($valid instanceof Frapi_Error) {
return $valid;
}
$username = $this->getParam('username');
$password = $this->getParam('password');
$project_id = $this->getParam('project_id', self::TYPE_INT);
// Attempt to login as user, a little bit of a hack as we currently
// require the $_POST['login'] var to be set as well as a global AppUI
$AppUI = new CAppUI();
$GLOBALS['AppUI'] = $AppUI;
$_POST['login'] = 'login';
if (!$AppUI->login($username, $password)) {
throw new Frapi_Error('INVALID_LOGIN');
}
$project = new CProject();
$project->load($project_id);
if (!$project->delete($AppUI)) {
throw new Frapi_Error('PERMISSION_ERROR');
}
$this->data['success'] = true;
return $this->toArray();
}
示例14: getTaskEmailLog
public function getTaskEmailLog(CTask $task, CTask_Log $log)
{
$project = new CProject();
$projname = $project->load($task->task_project)->project_name;
$contact = new CContact();
$creatorname = $contact->findContactByUserid($log->task_log_creator)->contact_display_name;
$body = $this->_AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $projname . "\n";
if ($task->task_parent != $task->task_id) {
$tmpTask = new CTask();
$taskname = $tmpTask->load($task->task_parent)->task_name;
$body .= $this->_AppUI->_('Parent Task', UI_OUTPUT_RAW) . ': ' . $taskname . "\n";
}
$body .= $this->_AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $task->task_name . "\n";
$task_types = w2PgetSysVal('TaskType');
$body .= $this->_AppUI->_('Task Type', UI_OUTPUT_RAW) . ':' . $task_types[$task->task_type] . "\n";
$body .= $this->_AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $task->task_id . "\n\n";
$body .= "------------------------\n\n";
$body .= $this->_AppUI->_('User', UI_OUTPUT_RAW) . ': ' . $creatorname . "\n";
$body .= $this->_AppUI->_('Hours', UI_OUTPUT_RAW) . ': ' . $log->task_log_hours . "\n";
$body .= $this->_AppUI->_('Summary', UI_OUTPUT_RAW) . ': ' . $log->task_log_name . "\n\n";
$body .= $log->task_log_description;
$user = new CUser();
$body .= "\n--\n" . $user->load($this->_AppUI->user_id)->user_signature;
return $body;
}
示例15: CProject
?>
</th>
<th><?php
echo $AppUI->_('Status');
?>
</th>
</tr>
<?php
//while ($line = mysql_fetch_array($res, MYSQL_ASSOC)) {
$s = '';
foreach ($st_projects_arr as $project) {
$line = $project[0];
$level = $project[1];
if ($line['project_id']) {
$s_project = new CProject();
$s_project->load($line['project_id']);
$s_company = new CCompany();
$s_company->load($s_project->project_company);
$start_date = intval($s_project->project_start_date) ? new CDate($s_project->project_start_date) : null;
$end_date = intval($s_project->project_end_date) ? new CDate($s_project->project_end_date) : null;
$actual_end_date = intval($s_project->project_actual_end_date) ? new CDate($s_project->project_actual_end_date) : null;
$style = $actual_end_date > $end_date && !empty($end_date) ? 'style="color:red; font-weight:bold"' : '';
$x++;
$row_class = $x % 2 ? 'style="background:#fff;"' : 'style="background:#f0f0f0;"';
$row_classr = $x % 2 ? 'style="background:#fff;text-align:right;"' : 'style="background:#f0f0f0;text-align:right;"';
$s .= '<tr><td ' . $row_class . ' align="center"><a href="./index.php?m=projects&a=addedit&project_id=' . $line['project_id'] . '"><img src="' . w2PfindImage('icons/' . ($project_id == $line['project_id'] ? 'pin' : 'pencil') . '.gif') . '" border=0 /></b></a></td>';
$s .= '<td ' . $row_classr . ' nowrap="nowrap">' . $line['project_id'] . '</td>';
if ($level) {
$sd = str_repeat(' ', $level - 1) . w2PshowImage('corner-dots.gif', 16, 12) . ' ' . '<a href="./index.php?m=projects&a=view&project_id=' . $line['project_id'] . '">' . $line['project_name'] . '</a>';
} else {
$sd = '<a href="./index.php?m=projects&a=view&project_id=' . $line['project_id'] . '">' . $line['project_name'] . '</a>';