コード例 #1
0
ファイル: complete.php プロジェクト: n2i/xvnkb
function setComplete($id)
{
    global $AppUI;
    $task = new CTask();
    if ($task->load($id)) {
        $q = new DBQuery();
        $q->addTable('user_tasks');
        $q->addQuery('user_id');
        $q->addWhere('task_id = ' . $id);
        $q->addWhere('user_id = ' . $AppUI->user_id);
        $r = $q->loadResult();
        if ($r != $AppUI->user_id) {
            $p = new CProject($task->task_project);
            if (!$p->project_id || $p->getManager() != $AppUI->user_id) {
                return 'Error';
            }
        }
        $q->addTable('tasks');
        $q->addUpdate('task_percent_complete', '100');
        $q->addWhere('task_id = ' . $id);
        $q->exec();
        return 'OK';
    }
    return 'Error';
}
コード例 #2
0
 function store()
 {
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . "::store-check failed";
     }
     $q = new DBQuery();
     if ($this->user_id) {
         // save the old password
         $perm_func = "updateLogin";
         $q->addTable('users');
         $q->addQuery('user_password');
         $q->addWhere("user_id = {$this->user_id}");
         $pwd = $q->loadResult();
         if ($pwd != $this->user_password) {
             $this->user_password = md5($this->user_password);
             addHistory($this->_tbl, $this->user_id, 'password changed', 'Password changed from IP ' . $_SERVER['REMOTE_ADDR']);
         } else {
             $this->user_password = null;
         }
         $ret = db_updateObject('users', $this, 'user_id', false);
     } else {
         $perm_func = "addLogin";
         $this->user_password = md5($this->user_password);
         $ret = db_insertObject('users', $this, 'user_id');
     }
     if (!$ret) {
         return get_class($this) . "::store failed <br />" . db_error();
     } else {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->{$perm_func}($this->user_id, $this->user_username);
         return NULL;
     }
 }
コード例 #3
0
ファイル: admin.class.php プロジェクト: n2i/xvnkb
 function store()
 {
     $msg = $this->check();
     if ($msg) {
         return get_class($this) . "::store-check failed";
     }
     $q = new DBQuery();
     if ($this->user_id) {
         // save the old password
         $perm_func = "updateLogin";
         $q->addTable('users');
         $q->addQuery('user_password');
         $q->addWhere("user_id = {$this->user_id}");
         $pwd = $q->loadResult();
         if ($pwd != $this->user_password) {
             $this->user_password = md5($this->user_password);
         } else {
             $this->user_password = null;
         }
         $ret = db_updateObject('users', $this, 'user_id', false);
     } else {
         $perm_func = "addLogin";
         $this->user_password = md5($this->user_password);
         $ret = db_insertObject('users', $this, 'user_id');
     }
     if (!$ret) {
         return get_class($this) . "::store failed <br />" . db_error();
     } else {
         $acl =& $GLOBALS['AppUI']->acl();
         $acl->{$perm_func}($this->user_id, $this->user_username);
         //Insert Default Preferences
         //Lets check if the user has allready default users preferences set, if not insert the default ones
         $q->addTable('user_preferences', 'upr');
         $q->addWhere("upr.pref_user = {$this->user_id}");
         $uprefs = $q->loadList();
         $q->clear();
         if (!count($uprefs) && $this->user_id > 0) {
             //Lets get the default users preferences
             $q->addTable('user_preferences', 'dup');
             $q->addWhere("dup.pref_user = 0");
             $dprefs = $q->loadList();
             $q->clear();
             foreach ($dprefs as $dprefskey => $dprefsvalue) {
                 $q->addTable('user_preferences', 'up');
                 $q->addInsert('pref_user', $this->user_id);
                 $q->addInsert('pref_name', $dprefsvalue['pref_name']);
                 $q->addInsert('pref_value', $dprefsvalue['pref_value']);
                 $q->exec();
                 $q->clear();
             }
         }
         return NULL;
     }
 }
コード例 #4
0
 function load($oid = null, $strip = true)
 {
     $result = parent::load($oid, $strip);
     if ($result && $oid) {
         $working_hours = dPgetConfig('daily_working_hours') ? dPgetConfig('daily_working_hours') : 8;
         $q = new DBQuery();
         $q->addTable('projects', 'p');
         $q->addQuery(' SUM(t1.task_duration * t1.task_percent_complete' . ' * IF(t1.task_duration_type = 24, ' . $working_hours . ', t1.task_duration_type)) / SUM(t1.task_duration' . ' * IF(t1.task_duration_type = 24, ' . $working_hours . ', t1.task_duration_type)) AS project_percent_complete');
         $q->addJoin('tasks', 't1', 'p.project_id = t1.task_project');
         $q->addWhere('project_id = ' . $oid . ' AND t1.task_id = t1.task_parent');
         $this->project_percent_complete = $q->loadResult();
     }
     return $result;
 }
コード例 #5
0
 function load($oid = null, $strip = true)
 {
     $result = parent::load($oid, $strip);
     if ($result && $oid) {
         $working_hours = dPgetConfig('daily_working_hours') ? dPgetConfig('daily_working_hours') : 8;
         $q = new DBQuery();
         $q->addTable('projects');
         $q->addQuery(" SUM(t1.task_duration * t1.task_percent_complete" . " * IF(t1.task_duration_type = 24, {$working_hours}, t1.task_duration_type))" . " / SUM(t1.task_duration * IF(t1.task_duration_type = 24, {$working_hours}" . ", t1.task_duration_type)) AS project_percent_complete");
         $q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project');
         $q->addWhere(" project_id = {$oid} AND t1.task_id = t1.task_parent");
         $this->project_percent_complete = $q->loadResult();
     }
     return $result;
 }
 function _fetchPreviousData()
 {
     $q = new DBQuery();
     $q->addTable($this->table_name);
     $q->addQuery($this->field_name);
     $q->addWhere("{$this->id_field_name} = {$this->row_id}");
     $previous_data = $q->loadResult();
     if ($previous_data != "") {
         $previous_data = unserialize($previous_data);
         $previous_data = !is_array($previous_data) ? array() : $previous_data;
     } else {
         $previous_data = array();
     }
     $this->previous_data = $previous_data;
 }
コード例 #7
0
 function load($oid = null, $strip = true)
 {
     $result = parent::load($oid, $strip);
     if ($result && $oid) {
         $q = new DBQuery();
         $q->addTable('projects');
         $q->addQuery('SUM(t1.task_duration*t1.task_duration_type*t1.task_percent_complete) / 
                                     SUM(t1.task_duration*t1.task_duration_type) 
                                     AS project_percent_complete');
         $q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project');
         $q->addWhere(" project_id = {$oid}");
         $this->project_percent_complete = $q->loadResult();
     }
     return $result;
 }
コード例 #8
0
 function canDelete(&$msg, $oid = null, $joins = null)
 {
     global $AppUI;
     if ($oid) {
         // Check to see if there is a user
         $q = new DBQuery();
         $q->addTable('users');
         $q->addQuery('count(*) as user_count');
         $q->addWhere('user_contact = ' . (int) $oid);
         $user_count = $q->loadResult();
         if ($user_count > 0) {
             $msg = $AppUI->_('contactsDeleteUserError');
             return false;
         }
     }
     return parent::canDelete($msg, $oid, $joins);
 }
コード例 #9
0
 protected function _createProjectSelection($AppUI, $project_name)
 {
     $output .= '<tr><td align="right">' . $AppUI->_('Project Name') . ':</td>';
     $q = new DBQuery();
     $q->addQuery('project_id');
     $q->addTable('projects');
     $q->addWhere("project_name = '{$project_name}'");
     $project_id = $q->loadResult();
     $output .= '<td>';
     $output .= '<input type="text" name="new_project" value="' . $project_name . '" size="36" />';
     if ($project_id) {
         $output .= '<input type="hidden" name="project_id" value="' . $project_id . '" />';
         $output .= $AppUI->_('pexist');
     }
     $output .= '</td></tr>';
     return $output;
 }
コード例 #10
0
ファイル: sendpass.php プロジェクト: 222elm/dotprojectFrame
function sendNewPass()
{
    global $AppUI;
    $_live_site = dPgetConfig('base_url');
    $_sitename = dPgetConfig('company_name');
    // ensure no malicous sql gets past
    $checkusername = trim(dPgetParam($_POST, 'checkusername', ''));
    $checkusername = db_escape($checkusername);
    $confirmEmail = trim(dPgetParam($_POST, 'checkemail', ''));
    $confirmEmail = mb_strtolower(db_escape($confirmEmail));
    $q = new DBQuery();
    $q->addTable('users', 'u');
    $q->addQuery('u.user_id');
    $q->addWhere('user_username=\'' . $checkusername . '\' AND LOWER(contact_email)=\'' . $confirmEmail . '\'');
    $q->leftJoin('contacts', 'c', 'u.user_contact = c.contact_id');
    if (!($user_id = $q->loadResult()) || !$checkusername || !$confirmEmail) {
        $AppUI->setMsg('Invalid username or email.', UI_MSG_ERROR);
        $AppUI->redirect();
    }
    $newpass = makePass();
    $message = $AppUI->_('sendpass0', UI_OUTPUT_RAW) . ' ' . $checkusername . ' ' . $AppUI->_('sendpass1', UI_OUTPUT_RAW) . ' ' . $_live_site . ' ' . $AppUI->_('sendpass2', UI_OUTPUT_RAW) . ' ' . $newpass . ' ' . $AppUI->_('sendpass3', UI_OUTPUT_RAW);
    $subject = "{$_sitename} :: " . $AppUI->_('sendpass4', UI_OUTPUT_RAW) . " - {$checkusername}";
    $m = new Mail();
    // create the mail
    $m->From("dotProject@" . dPgetConfig('site_domain'));
    $m->To($confirmEmail);
    $m->Subject($subject);
    $m->Body($message, isset($GLOBALS['locale_char_set']) ? $GLOBALS['locale_char_set'] : "");
    // set the body
    $m->Send();
    // send the mail
    $newpass = md5($newpass);
    $q->clear();
    $q->addTable('users');
    $q->addUpdate('user_password', $newpass, true);
    $q->addWhere('user_id=\'' . $user_id . '\'');
    $cur = $q->exec();
    if (!$cur) {
        die('SQL error' . $database->stderr(true));
    } else {
        $AppUI->setMsg('New User Password created and emailed to you');
        $AppUI->redirect();
    }
}
コード例 #11
0
ファイル: vw_projecttask.php プロジェクト: joly/web2project
    $q->addQuery('ut.user_id,	u.user_username');
    $q->addQuery('contact_email, ut.perc_assignment, SUM(ut.perc_assignment) AS assign_extent');
    $q->addQuery('contact_first_name, contact_last_name');
    $q->addTable('user_tasks', 'ut');
    $q->leftJoin('users', 'u', 'u.user_id = ut.user_id');
    $q->leftJoin('contacts', 'c', 'u.user_contact = c.contact_id');
    $q->addWhere('ut.task_id = ' . (int) $row['task_id']);
    $q->addGroup('ut.user_id');
    $q->addOrder('perc_assignment desc, user_username');
    $assigned_users = array();
    $row['task_assigned_users'] = $q->loadList();
    $q->addQuery('count(task_id) as children');
    $q->addTable('tasks');
    $q->addWhere('task_parent = ' . (int) $row['task_id']);
    $q->addWhere('task_id <> task_parent');
    $row['children'] = $q->loadResult();
    $row['style'] = taskstyle_pd($row);
    $i = count($projects[$row['task_project']]['tasks']) + 1;
    $row['task_number'] = $i;
    $row['node_id'] = 'node_' . $i . '-' . $row['task_id'];
    if (strpos($row['task_duration'], '.') && $row['task_duration_type'] == 1) {
        $row['task_duration'] = floor($row['task_duration']) . ':' . round(60 * ($row['task_duration'] - floor($row['task_duration'])));
    }
    //pull the final task row into array
    $projects[$row['task_project']]['tasks'][] = $row;
}
$showEditCheckbox = isset($canEditTasks) && $canEditTasks || $perms->checkModule('admin', 'view');
$durnTypes = w2PgetSysVal('TaskDurationType');
$tempoTask = new CTask();
$userAlloc = $tempoTask->getAllocation('user_id');
?>
コード例 #12
0
        if ($where == ',') {
            $where = '0';
        }
    }
    $where = $where ? 'contact_company IN(' . $where . ')' : '';
} else {
    if (!$company_id) {
        //  Contacts from all allowed companies
        $where = "contact_company = ''" . " OR (contact_company IN ('" . implode('\',\'', array_values($aCpies_esc)) . "'))" . " OR (contact_company IN ('" . implode('\',\'', array_keys($aCpies_esc)) . "'))";
        $company_name = $AppUI->_('Allowed Companies');
    } else {
        // Contacts for this company only
        $q->addTable('companies', 'c');
        $q->addQuery('c.company_name');
        $q->addWhere('company_id = ' . $company_id);
        $company_name = $q->loadResult();
        $q->clear();
        /*
        	$sql = "select c.company_name from companies as c where company_id = $company_id";
        	$company_name = db_loadResult($sql);
        */
        $company_name_sql = db_escape($company_name);
        $where = " (contact_company = '{$company_name_sql}' or contact_company = '{$company_id}')";
    }
}
// This should now work on company ID, but we need to be able to handle both
$q->addTable('contacts', 'a');
$q->leftJoin('companies', 'b', 'b.company_id = a.contact_company');
$q->leftJoin('departments', 'c', 'c.dept_id = a.contact_department');
$q->leftJoin('users', 'u', 'u.user_contact=a.contact_id');
$q->addQuery('a.contact_id, a.contact_first_name, a.contact_last_name,' . ' a.contact_company, a.contact_department');
コード例 #13
0
ファイル: main_functions.php プロジェクト: n2i/xvnkb
function dPuserHasRole($name)
{
    global $AppUI;
    $uid = $AppUI->user_id;
    $sql = "SELECT r.role_id FROM roles AS r,user_roles AS ur WHERE ur.user_id={$uid} AND ur.role_id=r.role_id AND r.role_name='{$name}'";
    $q = new DBQuery();
    $q->addTable('roles', 'r');
    $q->addTable('user_roles', 'ur');
    $q->addQuery('r.role_id');
    $q->addWhere("ur.user_id={$uid} AND ur.role_id=r.role_id AND r.role_name='{$name}'");
    return $q->loadResult();
}
コード例 #14
0
ファイル: tasks.class.php プロジェクト: joly/web2project
 private function updateHoursWorked($task_log_task)
 {
     $q = new DBQuery();
     $q->addQuery('SUM(task_log_hours)');
     $q->addTable('task_log');
     $q->addWhere('task_log_task = ' . (int) $task_log_task);
     $totalHours = $q->loadResult();
     CTask::updateHoursWorked($task_log_task, $totalHours);
 }
コード例 #15
0
function dPuserHasRole($name)
{
    global $AppUI;
    $uid = (int) $AppUI->user_id;
    $q = new DBQuery();
    $q->addTable('roles', 'r');
    $q->innerJoin('user_roles', 'ur', 'ur.role_id=r.role_id');
    $q->addQuery('r.role_id');
    $q->addWhere("ur.user_id={$uid} AND r.role_name='{$name}'");
    return $q->loadResult();
}
コード例 #16
0
}
if (!$canEdit) {
    $AppUI->redirect('m=public&a=access_denied');
}
// Get the list of projects associated with this user.
// We need to get all projects that are owned by the user
// or where the user is a project contact.
// We then need to add all projects where a user is assigned a task, is a
// task contact, or is the owner of a task within that project.
// This should cover all situations that we need to correct.
$projects = array();
$q = new DBQuery();
$q->addQuery('user_contact');
$q->addTable('users');
$q->addWhere('user_id = ' . (int) $user_id);
$contact_id = $q->loadResult();
$q->addQuery('distinct project_id, project_name');
$q->addTable('projects');
$q->addWhere('project_owner = ' . (int) $user_id);
$projects += $q->loadHashList();
$q->addQuery('distinct prj.project_id, prj.project_name');
$q->addTable('projects', 'prj');
$q->innerJoin('project_contacts', 'prc', array('project_id'));
$q->addWhere('prc.contact_id = ' . (int) $contact_id);
$projects += $q->loadHashList();
$q->addQuery('distinct prj.project_id, prj.project_name');
$q->addTable('tasks', 't');
$q->innerJoin('projects', 'prj', 'prj.project_id = t.task_project');
$q->leftJoin('user_tasks', 'ut', 'ut.task_id = t.task_id');
$q->addWhere('t.task_owner = ' . (int) $user_id . ' OR ut.user_id = ' . (int) $user_id);
$projects += $q->loadHashList();
コード例 #17
0
ファイル: vw_logs.php プロジェクト: n2i/xvnkb
<?php

global $AppUI, $project_id, $df, $canEdit, $m, $tab;
// Lets check which cost codes have been used before
$q = new DBQuery();
$q->addQuery('project_company');
$q->addTable('projects');
$q->addWhere('project_id = ' . $project_id);
$company_id = $q->loadResult();
$q->addTable('billingcode');
$q->addQuery('billingcode_id, billingcode_name');
$q->addOrder('billingcode_name');
$q->addWhere('billingcode_status = 0');
$q->addWhere('(company_id = 0 OR company_id = ' . $company_id . ')');
$task_log_costcodes = $q->loadHashList();
// Show deleted codes separately (at the end)
$q->addTable('billingcode');
$q->addQuery('billingcode_id, billingcode_name');
$q->addOrder('billingcode_name');
$q->addWhere('billingcode_status = 1');
$q->addWhere('(company_id = 0 OR company_id = ' . $company_id . ')');
$task_log_costcodes = array_merge(array(0 => 'None'), $task_log_costcodes, $q->loadHashList());
$q = new DBQuery();
$q->addTable('users', 'u');
$q->addQuery('user_id, concat(contact_first_name," ",contact_last_name)');
$q->addJoin('contacts', 'c', 'u.user_contact = c.contact_id');
$q->addJoin('project_contacts', 'p', 'p.contact_id = u.user_id');
$q->addOrder('contact_first_name, contact_last_name');
$q->addWhere('p.project_id = ' . $project_id);
$users = arrayMerge(array('-1' => $AppUI->_('All members')), $q->loadHashList());
$cost_code = dPgetParam($_GET, 'cost_code', '0');
コード例 #18
0
ファイル: index.php プロジェクト: magsilva/dotproject
    if (count($allowedProjects)) {
        $q->addWhere('( ( ' . implode(' AND ', $allowedProjects) . ') OR file_project = 0 )');
    }
    if (count($allowedTasks)) {
        $q->addWhere('( ( ' . implode(' AND ', $allowedTasks) . ') OR file_task = 0 )');
    }
    if ($catsql) {
        $q->addWhere($catsql);
    }
    if ($company_id) {
        $q->addWhere("project_company = {$company_id}");
    }
    if ($project_id) {
        $q->addWhere("file_project = {$project_id}");
    }
    if ($task_id) {
        $q->addWhere("file_task = {$task_id}");
    }
    $key = array_search($file_type, $fts);
    if ($i > 0 || !$tabbed) {
        $q->addWhere('file_category = ' . $key);
    }
    if ($project_id > 0) {
        $q->addWhere('file_project = ' . $project_id);
    }
    $tabBox->add('index_table', $file_type . ' (' . $q->loadResult() . ')');
    ++$i;
}
$tabBox->add('folders_table', 'Folder Explorer');
$tabBox->show();
//}
コード例 #19
0
 function store()
 {
     $q = new DBQuery();
     $q->addQuery('billingcode_id');
     $q->addTable('billingcode');
     $q->addWhere("billingcode_name = '" . $this->billingcode_name . "'");
     $q->addWhere('company_id = ' . $this->company_id);
     $found_id = $q->loadResult();
     if ($found_id && $found_id != $this->_billingcode_id) {
         return 'Billing Code::code already exists';
     } else {
         if ($this->_billingcode_id) {
             $q->addTable('billingcode');
             $q->addUpdate('billingcode_desc', $this->billingcode_desc);
             $q->addUpdate('billingcode_name', $this->billingcode_name);
             $q->addUpdate('billingcode_value', $this->billingcode_value);
             $q->addUpdate('billingcode_status', $this->billingcode_status);
             $q->addUpdate('company_id', $this->company_id);
             $q->addWhere('billingcode_id = ' . $this->_billingcode_id);
             $q->exec();
             $q->clear();
         } else {
             if (!($ret = db_insertObject('billingcode', $this, 'billingcode_id'))) {
                 return 'Billing Code::store failed <br />' . db_error();
             } else {
                 return NULL;
             }
         }
     }
 }
コード例 #20
0
    } else {
        $AppUI->setMsg('deleted', UI_MSG_ALERT, true);
    }
    $AppUI->redirect();
    return;
} else {
    if ($isNewUser) {
        if (!(getPermission('admin', 'add') && getPermission('users', 'add'))) {
            $AppUI->redirect('m=admin&a=access_denied');
        }
        //pull a list of existing usernames
        $q = new DBQuery();
        $q->addTable('users', 'u');
        $q->addQuery('user_username');
        $q->addWhere("user_username like '{$obj->user_username}'");
        $userEx = $q->loadResult();
        // If userName already exists quit with error and do nothing
        if ($userEx) {
            $AppUI->setMsg('already exists. Try another username.', UI_MSG_ERROR, true);
            $AppUI->redirect();
        }
        $contact->contact_owner = $AppUI->user_id;
    } else {
        if (!getPermission('admin', 'edit') || !getPermission('users', 'edit', $user_id_aed)) {
            $AppUI->redirect('m=public&a=access_denied');
        }
    }
}
if ($msg = $contact->store()) {
    $AppUI->setMsg($msg, UI_MSG_ERROR);
} else {
コード例 #21
0
ファイル: files.class.php プロジェクト: joly/web2project
 public function countFolders()
 {
     $q = new DBQuery();
     $q->addTable($this->_tbl);
     $q->addQuery('COUNT(' . $this->_tbl_key . ' )');
     $result = $q->loadResult();
     return $result;
 }
コード例 #22
0
ファイル: upcoming.php プロジェクト: joly/web2project
<?php

/* $Id$ $URL$ */
if (!defined('W2P_BASE_DIR')) {
    die('You should not access this file directly.');
}
// Output the PDF
// make the PDF file
if ($project_id != 0) {
    $q = new DBQuery();
    $q->addTable('projects');
    $q->addQuery('project_name');
    $q->addWhere('project_id=' . (int) $project_id);
    $pname = 'Project: ' . $q->loadResult();
} else {
    $pname = $AppUI->_('All Projects');
}
if ($err = db_error()) {
    $AppUI->setMsg($err, UI_MSG_ERROR);
    $AppUI->redirect();
}
$font_dir = W2P_BASE_DIR . '/lib/ezpdf/fonts';
require $AppUI->getLibraryClass('ezpdf/class.ezpdf');
$pdf = new Cezpdf($paper = 'A4', $orientation = 'landscape');
$pdf->ezSetCmMargins(1, 2, 1.5, 1.5);
$pdf->selectFont($font_dir . '/Helvetica.afm');
if ($locale_char_set == 'utf-8' && function_exists('utf8_decode')) {
    $pdf->ezText(utf8_decode(w2PgetConfig('company_name')), 12);
} else {
    $pdf->ezText(w2PgetConfig('company_name'), 12);
}
コード例 #23
0
ファイル: chpwd.php プロジェクト: 222elm/dotprojectFrame
    $user_id = @$AppUI->user_id;
}
// check for a non-zero user id
if ($user_id) {
    $old_pwd = db_escape(trim(dPgetCleanParam($_POST, 'old_pwd', null)));
    $new_pwd1 = db_escape(trim(dPgetCleanParam($_POST, 'new_pwd1', null)));
    $new_pwd2 = db_escape(trim(dPgetCleanParam($_POST, 'new_pwd2', null)));
    // has the change form been posted
    if ($new_pwd1 && $new_pwd2 && $new_pwd1 == $new_pwd2) {
        // check that the old password matches
        $old_md5 = md5($old_pwd);
        $q = new DBQuery();
        $q->addQuery('user_id');
        $q->addTable('users');
        $q->addWhere("user_password='******' AND user_id={$user_id}");
        if ($AppUI->user_type == 1 || $q->loadResult() == $user_id) {
            require_once $AppUI->getModuleClass('admin');
            $user = new CUser();
            $user->user_id = $user_id;
            $user->user_password = $new_pwd1;
            if ($msg = $user->store()) {
                $AppUI->setMsg($msg, UI_MSG_ERROR);
            } else {
                echo $AppUI->_('chgpwUpdated');
            }
        } else {
            echo $AppUI->_('chgpwWrongPW');
        }
    } else {
        ?>
<script language="javascript">
コード例 #24
0
function getNextVersionID()
{
    $q = new DBQuery();
    $q->addTable('files', 'f');
    $q->addQuery('MAX(f.file_version_id) AS max_version_id');
    $latest_file_version = intval($q->loadResult());
    $q->clear();
    return $latest_file_version + 1;
}
コード例 #25
0
 /**
  * Called by the Event Queue processor to process a reminder
  * on a task.
  * @access		  public
  * @param		 string		   $module		  Module name (not used)
  * @param		 string		   $type Type of event (not used)
  * @param		 integer		$id ID of task being reminded
  * @param		 integer		$owner		  Originator of event
  * @param		 mixed		  $args event-specific arguments.
  * @return		  mixed		   true, dequeue event, false, event stays in queue.
  -1, event is destroyed.
 */
 function remind($module, $type, $id, $owner, &$args)
 {
     global $locale_char_set, $AppUI;
     $q = new DBQuery();
     $df = $AppUI->getPref('SHDATEFORMAT');
     $tf = $AppUI->getPref('TIMEFORMAT');
     // If we don't have preferences set for these, use ISO defaults.
     if (!$df) {
         $df = '%Y-%m-%d';
     }
     if (!$tf) {
         $tf = '%H:%m';
     }
     $df .= ' ' . $tf;
     // 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 CDate();
     if (!$today->isWorkingDay()) {
         return true;
     }
     // Check if the task is completed
     if ($this->task_percent_complete == 100) {
         return -1;
     }
     // Grab the assignee list
     $q->addTable('user_tasks', 'ut');
     $q->leftJoin('users', 'u', 'u.user_id = ut.user_id');
     $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
     $q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
     $q->addWhere('ut.task_id = ' . $id);
     $contacts = $q->loadHashList('contact_id');
     $q->clear();
     // Now we also check the owner of the task, as we will need
     // to notify them as well.
     $owner_is_not_assignee = false;
     $q->addTable('users', 'u');
     $q->leftJoin('contacts', 'c', 'c.contact_id = u.user_contact');
     $q->addQuery('c.contact_id, contact_first_name, contact_last_name, contact_email');
     $q->addWhere('u.user_id = ' . $this->task_owner);
     if ($q->exec(ADODB_FETCH_NUM)) {
         list($owner_contact, $owner_first_name, $owner_last_name, $owner_email) = $q->fetchRow();
         if (!isset($contacts[$owner_contact])) {
             $owner_is_not_assignee = true;
             $contacts[$owner_contact] = array('contact_id' => $owner_contact, 'contact_first_name' => $owner_first_name, 'contact_last_name' => $owner_last_name, 'contact_email' => $owner_email);
         }
     }
     $q->clear();
     // build the subject line, based on how soon the
     // task will be overdue.
     $starts = new CDate($this->task_start_date);
     $expires = new CDate($this->task_end_date);
     $now = new CDate();
     $diff = $expires->dateDiff($now);
     $prefix = $AppUI->_('Task Due', UI_OUTPUT_RAW);
     if ($diff == 0) {
         $msg = $AppUI->_('TODAY', UI_OUTPUT_RAW);
     } else {
         if ($diff == 1) {
             $msg = $AppUI->_('TOMORROW', UI_OUTPUT_RAW);
         } else {
             if ($diff < 0) {
                 $msg = $AppUI->_(array('OVERDUE', abs($diff), 'DAYS'));
                 $prefix = $AppUI->_('Task', UI_OUTPUT_RAW);
             } else {
                 $msg = $AppUI->_(array($diff, 'DAYS'));
             }
         }
     }
     $q->addTable('projects');
     $q->addQuery('project_name');
     $q->addWhere('project_id = ' . $this->task_project);
     $project_name = htmlspecialchars_decode($q->loadResult());
     $q->clear();
     $subject = $prefix . ' ' . $msg . ' ' . $this->task_name . '::' . $project_name;
     $body = $AppUI->_('Task Due', UI_OUTPUT_RAW) . ': ' . $msg . "\n" . $AppUI->_('Project', UI_OUTPUT_RAW) . ': ' . $project_name . "\n" . $AppUI->_('Task', UI_OUTPUT_RAW) . ': ' . $this->task_name . "\n" . $AppUI->_('Start Date', UI_OUTPUT_RAW) . ': ' . $starts->format($df) . "\n" . $AppUI->_('Finish Date', UI_OUTPUT_RAW) . ': ' . $expires->format($df) . "\n" . $AppUI->_('URL', UI_OUTPUT_RAW) . ': ' . DP_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . $this->task_id . '&reminded=1' . "\n\n" . $AppUI->_('Resources', UI_OUTPUT_RAW) . ":\n";
     foreach ($contacts as $contact) {
         if ($owner_is_not_assignee || $contact['contact_id'] != $owner_contact) {
             $body .= $contact['contact_first_name'] . ' ' . $contact['contact_last_name'] . ' <' . $contact['contact_email'] . ">\n";
         }
     }
     $body .= "\n" . $AppUI->_('Description', UI_OUTPUT_RAW) . ":\n" . $this->task_description . "\n";
     $mail = new Mail();
     foreach ($contacts as $contact) {
         if ($mail->ValidEmail($contact['contact_email'])) {
             $mail->To($contact['contact_email']);
         }
     }
     $mail->From('"' . $owner_first_name . ' ' . $owner_last_name . '" <' . $owner_email . '>');
     $mail->Subject($subject, $locale_char_set);
     $mail->Body($body, $locale_char_set);
     return $mail->Send();
 }
コード例 #26
0
 /**
  * w2Pacl::w2Pacl_check()
  * //w2Pacl_check is used for modules only
  *
  * @param mixed $application it passes 'application' string by default and is not used
  * @param mixed $op one of the acos 'access','view','add','delete','edit'
  * @param mixed $user it passes 'user' string by default and is not used
  * @param mixed $userid it passes the user_id
  * @param mixed $app it passes 'app' string by default and is not used
  * @param mixed $module it passes the modules name
  * @return
  */
 public function w2Pacl_check($application = 'application', $op, $user = '******', $userid, $app = 'app', $module)
 {
     global $w2p_performance_acltime, $w2p_performance_aclchecks;
     $q = new DBQuery();
     $q->addTable($this->_db_acl_prefix . 'permissions');
     $q->addQuery('access');
     $q->addWhere('module = \'' . $module . '\'');
     $q->addWhere('action = \'' . $op . '\'');
     $q->addWhere('item_id = 0');
     $q->addWhere('user_id = ' . (int) $userid);
     $q->addOrder('acl_id DESC');
     if (W2P_PERFORMANCE_DEBUG) {
         $startTime = array_sum(explode(' ', microtime()));
     }
     $res = $q->loadResult();
     if (W2P_PERFORMANCE_DEBUG) {
         ++$w2p_performance_aclchecks;
         $w2p_performance_acltime += array_sum(explode(' ', microtime())) - $startTime;
     }
     return $res;
 }
コード例 #27
0
ファイル: view.php プロジェクト: magsilva/dotproject
if (in_array($project_id, $denied)) {
    $AppUI->redirect("m=public&a=access_denied");
}
$canDelete = $obj->canDelete($msg, $project_id);
// get critical tasks (criteria: task_end_date)
$criticalTasks = $project_id > 0 ? $obj->getCriticalTasks($project_id) : NULL;
// get ProjectPriority from sysvals
$projectPriority = dPgetSysVal('ProjectPriority');
$projectPriorityColor = dPgetSysVal('ProjectPriorityColor');
$working_hours = $dPconfig['daily_working_hours'] ? $dPconfig['daily_working_hours'] : 8;
$q = new DBQuery();
//check that project has tasks; otherwise run seperate query
$q->addTable('tasks');
$q->addQuery("COUNT(distinct tasks.task_id) AS total_tasks");
$q->addWhere('task_project = ' . $project_id);
$hasTasks = $q->loadResult();
$q->clear();
// load the record data
// GJB: Note that we have to special case duration type 24 and this refers to the hours in a day, NOT 24 hours
if ($hasTasks) {
    $q->addTable('projects');
    $q->addQuery("company_name, CONCAT_WS(', ',contact_last_name,contact_first_name) user_name, projects.*," . " SUM(t1.task_duration * t1.task_percent_complete" . " * IF(t1.task_duration_type = 24, {$working_hours}, t1.task_duration_type))" . " / SUM(t1.task_duration * IF(t1.task_duration_type = 24, {$working_hours}, t1.task_duration_type))" . " AS project_percent_complete");
    $q->addJoin('companies', 'com', 'company_id = project_company');
    $q->addJoin('users', 'u', 'user_id = project_owner');
    $q->addJoin('contacts', 'con', 'contact_id = user_contact');
    $q->addJoin('tasks', 't1', 'projects.project_id = t1.task_project');
    $q->addWhere('project_id = ' . $project_id . ' AND t1.task_id = t1.task_parent');
    $q->addGroup('project_id');
    $sql = $q->prepare();
} else {
    $q->addTable('projects');
コード例 #28
0
ファイル: co.php プロジェクト: joly/web2project
// setup the title block
$titleBlock = new CTitleBlock('Checkout', 'folder5.png', $m, "{$m}.{$a}");
$titleBlock->addCrumb('?m=files', 'files list');
$titleBlock->show();
if ($obj->file_project) {
    $file_project = $obj->file_project;
}
if ($obj->file_task) {
    $file_task = $obj->file_task;
    $task_name = $obj->getTaskName();
} elseif ($file_task) {
    $q = new DBQuery();
    $q->addTable('tasks');
    $q->addQuery('task_name');
    $q->addWhere('task_id=' . (int) $file_task);
    $task_name = $q->loadResult();
    $q->clear();
} else {
    $task_name = '';
}
$extra = array('where' => 'project_active<>0');
$project = new CProject();
$projects = $project->getAllowedRecords($AppUI->user_id, 'projects.project_id,project_name', 'project_name', null, $extra, 'projects');
$projects = arrayMerge(array('0' => $AppUI->_('All')), $projects);
?>

<script language='javascript'>
function popFile( params ) {
    fileloader = window.open("fileviewer.php?"+params,"mywindow","location=1,status=1,scrollbars=0,width=80,height=80");
    fileloader.moveTo(0,0);
}
コード例 #29
0
ファイル: gantt.php プロジェクト: joly/web2project
     $q = new DBQuery();
     $q->addTable('tasks', 't');
     $q->addJoin('user_tasks', 'u', 't.task_id = u.task_id', 'inner');
     $q->addQuery('ROUND(SUM(t.task_duration*u.perc_assignment/100),2) AS wh');
     $q->addWhere('t.task_duration_type = 24');
     $q->addWhere('t.task_id = ' . (int) $a['task_id']);
     $wh = $q->loadResult();
     $work_hours = $wh * $w2Pconfig['daily_working_hours'];
     $q->clear();
     $q = new DBQuery();
     $q->addTable('tasks', 't');
     $q->addJoin('user_tasks', 'u', 't.task_id = u.task_id', 'inner');
     $q->addQuery('ROUND(SUM(t.task_duration*u.perc_assignment/100),2) AS wh');
     $q->addWhere('t.task_duration_type = 1');
     $q->addWhere('t.task_id = ' . (int) $a['task_id']);
     $wh2 = $q->loadResult();
     $work_hours += $wh2;
     $q->clear();
     //due to the round above, we don't want to print decimals unless they really exist
     $dur = $work_hours;
 }
 $dur .= ' h';
 $enddate = new CDate($end);
 $startdate = new CDate($start);
 //$gantt->addBar($name, $start, $end, $actual_end, $caption, 0.6, $p['project_color_identifier'], $p['project_active'], $progress);
 if ($caller == 'todo') {
     $bar = new GanttBar($row++, array($name, $pname, $dur, $startdate->format($df), $enddate->format($df)), substr($start, 2, 8), substr($end, 2, 8), $cap, $a['task_dynamic'] == 1 ? 0.1 : 0.6);
 } else {
     $bar = new GanttBar($row++, array($name, $dur, $startdate->format($df), $enddate->format($df)), substr($start, 2, 8), substr($end, 2, 8), $cap, $a['task_dynamic'] == 1 ? 0.1 : 0.6);
 }
 $bar->progress->Set(min($progress / 100, 1));
コード例 #30
0
ファイル: forums.class.php プロジェクト: joly/web2project
 public function delete()
 {
     $q = new DBQuery();
     $q->setDelete('forum_visits');
     $q->addWhere('visit_message = ' . (int) $this->message_id);
     $q->exec();
     // No error if this fails, it is not important.
     $q->clear();
     $q->addTable('forum_messages');
     $q->addQuery('message_forum');
     $q->addWhere('message_id = ' . (int) $this->message_id);
     $forumId = $q->loadResult();
     $q->clear();
     $q->setDelete('forum_messages');
     $q->addWhere('message_id = ' . (int) $this->message_id);
     if (!$q->exec()) {
         $result = db_error();
     } else {
         $result = null;
     }
     $q->clear();
     $q->addTable('forum_messages');
     $q->addQuery('COUNT(message_id)');
     $q->addWhere('message_forum = ' . (int) $forumId);
     $messageCount = $q->loadResult();
     $q->clear();
     $q->addTable('forums');
     $q->addUpdate('forum_message_count', $messageCount);
     $q->addWhere('forum_id = ' . (int) $forumId);
     $q->exec();
     $q->clear();
     return $result;
 }