/** * Sub-function to collect events within a period * @param Date the starting date of the period * @param Date the ending date of the period * @param array by-ref an array of links to append new items to * @param int the length to truncate entries by * @author Andrew Eddie <*****@*****.**> */ function getEventLinks($startPeriod, $endPeriod, &$links, $strMaxLen, $minical = false) { global $event_filter; $events = CEvent::getEventsForPeriod($startPeriod, $endPeriod, $event_filter); $cwd = explode(',', w2PgetConfig('cal_working_days')); // assemble the links for the events foreach ($events as $row) { $start = new CDate($row['event_start_date']); $end = new CDate($row['event_end_date']); $date = $start; for ($i = 0, $i_cmp = $start->dateDiff($end); $i <= $i_cmp; $i++) { // the link // optionally do not show events on non-working days if ($row['event_cwd'] && in_array($date->getDayOfWeek(), $cwd) || !$row['event_cwd']) { if ($minical) { $link = array(); } else { $url = '?m=calendar&a=view&event_id=' . $row['event_id']; $link['href'] = ''; $link['alt'] = ''; $link['text'] = w2PtoolTip($row['event_title'], getEventTooltip($row['event_id']), true) . w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar') . '</a> ' . '<a href="' . $url . '"><span class="event">' . $row['event_title'] . '</span></a>' . w2PendTip(); } $links[$date->format(FMT_TIMESTAMP_DATE)][] = $link; } $date = $date->getNextDay(); } } }
/** * Object constructor to set table and key field * * Can be overloaded/supplemented by the child class * @param string $table name of the table in the db schema relating to child class * @param string $key name of the primary key field in the table * @param (OPTIONAL) string $module name as stored in the 'mod_directory' of the 'modules' table, and the 'value' field of the 'gacl_axo' table. * It is used for permission checking in situations where the table name is different from the module folder name. * For compatibility sake this variable is set equal to the $table if not set as failsafe. */ public function __construct($table, $key, $module = '') { $this->_error = array(); $this->_tbl = $table; $this->_tbl_key = $key; $this->_tbl_module = '' == $module ? $table : $module; $this->_tbl_prefix = w2PgetConfig('dbprefix', ''); $this->_query = new w2p_Database_Query(); /* * I hate this global but this will allow us to get rid of all the * others, so I think it's the best approach for now. * ~ caseydk 27 Dec 2011 */ global $AppUI; $this->_AppUI = $AppUI; $this->_perms = $this->_AppUI->acl(); /* * This block does a lot and may need to be simplified.. but the point * is that it sets up all of our base Events for later notifications, * logging, etc. We also need a way to enable Core Modules (CProject, * CTask, etc) and Add On Modules to add their own hooks. */ $this->_dispatcher = new w2p_Core_Dispatcher(); $this->_dispatcher->subscribe($this, get_class($this), 'preStoreEvent'); $this->_dispatcher->subscribe($this, get_class($this), 'postStoreEvent'); $this->_dispatcher->subscribe($this, get_class($this), 'preCreateEvent'); $this->_dispatcher->subscribe($this, get_class($this), 'postCreateEvent'); $this->_dispatcher->subscribe($this, get_class($this), 'preUpdateEvent'); $this->_dispatcher->subscribe($this, get_class($this), 'postUpdateEvent'); $this->_dispatcher->subscribe($this, get_class($this), 'preDeleteEvent'); $this->_dispatcher->subscribe($this, get_class($this), 'postDeleteEvent'); $this->_dispatcher->subscribe($this, get_class($this), 'preLoadEvent'); $this->_dispatcher->subscribe($this, get_class($this), 'postLoadEvent'); parent::__construct($this->_tbl_module, get_class($this), array()); }
public function testW2PgetConfig() { global $w2Pconfig; $this->assertEquals('web2project.net', w2PgetConfig('site_domain')); $this->assertEquals(null, w2PgetConfig('NotGonnaBeThere')); $this->assertEquals('Some Default', w2PgetConfig('NotGonnaBeThere', 'Some Default')); }
function db_connect($host = 'localhost', $dbname, $user = '******', $passwd = '', $persist = false) { global $db, $ADODB_FETCH_MODE; switch (strtolower(trim(w2PgetConfig('dbtype')))) { case 'oci8': case 'oracle': if ($persist) { $db->PConnect($host, $user, $passwd, $dbname) or die('FATAL ERROR: Connection to database server failed'); } else { $db->Connect($host, $user, $passwd, $dbname) or die('FATAL ERROR: Connection to database server failed'); } if (!defined('ADODB_ASSOC_CASE')) { define('ADODB_ASSOC_CASE', 0); } break; default: //mySQL if ($persist) { $db->PConnect($host, $user, $passwd, $dbname) or die('FATAL ERROR: Connection to database server failed'); } else { $db->Connect($host, $user, $passwd, $dbname) or die('FATAL ERROR: Connection to database server failed'); } } $ADODB_FETCH_MODE = ADODB_FETCH_BOTH; }
/** * Object constructor to set table and key field * * Can be overloaded/supplemented by the child class * @param string $table name of the table in the db schema relating to child class * @param string $key name of the primary key field in the table */ public function __construct($table, $key) { $this->_tbl = $table; $this->_tbl_key = $key; $this->_tbl_prefix = w2PgetConfig('dbprefix', ''); $this->_query = new DBQuery(); }
/** * parse file for indexing * @todo convert to using the FileSystem methods */ public function index(CFile $file) { /* Workaround for indexing large files: ** Based on the value defined in config data, ** files with file_size greater than specified limit ** are not indexed for searching. ** Negative value :<=> no filesize limit */ $index_max_file_size = w2PgetConfig('index_max_file_size', 0); if ($file->file_size > 0 && ($index_max_file_size < 0 || (int) $file->file_size <= $index_max_file_size * 1024)) { // get the parser application $parser = w2PgetConfig('parser_' . $file->file_type); if (!$parser) { $parser = w2PgetConfig('parser_default'); } if (!$parser) { return false; } // buffer the file $file->_filepath = W2P_BASE_DIR . '/files/' . $file->file_project . '/' . $file->file_real_filename; if (file_exists($file->_filepath)) { $fp = fopen($file->_filepath, 'rb'); $x = fread($fp, $file->file_size); fclose($fp); $ignore = w2PgetSysVal('FileIndexIgnoreWords'); $ignore = $ignore['FileIndexIgnoreWords']; $ignore = explode(',', $ignore); $x = strtolower($x); $x = preg_replace("/[^A-Za-z0-9 ]/", "", $x); foreach ($ignore as $ignoreWord) { $x = str_replace(" {$ignoreWord} ", ' ', $x); } $x = str_replace(' ', ' ', $x); $words = explode(' ', $x); foreach ($words as $index => $word) { if ('' == trim($word)) { continue; } $q = $this->query; $q->addTable('files_index'); $q->addInsert('file_id', $file->file_id); $q->addInsert('word', $word); $q->addInsert('word_placement', $index); $q->exec(); $q->clear(); } } else { //TODO: if the file doesn't exist.. should we delete the db record? } } $file->file_indexed = 1; $file->store(); return count($words); }
/** * Object constructor to set table and key field * * Can be overloaded/supplemented by the child class * @param string $table name of the table in the db schema relating to child class * @param string $key name of the primary key field in the table * @param (OPTIONAL) string $module name as stored in the 'mod_directory' of the 'modules' table, and the 'value' field of the 'gacl_axo' table. * It is used for permission checking in situations where the table name is different from the module folder name. * For compatibility sake this variable is set equal to the $table if not set as failsafe. */ public function __construct($table, $key, $module = '') { $this->_tbl = $table; $this->_tbl_key = $key; if ($module) { $this->_tbl_module = $module; } else { $this->_tbl_module = $table; } $this->_tbl_prefix = w2PgetConfig('dbprefix', ''); $this->_query = new w2p_Database_Query(); }
public function connect($host = 'localhost', $dbname, $user = '******', $passwd = '', $persist = false) { global $ADODB_FETCH_MODE; switch (strtolower(trim(w2PgetConfig('dbtype')))) { default: //mySQL if ($persist) { $this->db->PConnect($host, $user, $passwd, $dbname) or die('FATAL ERROR: Connection to database server failed'); } else { $this->db->Connect($host, $user, $passwd, $dbname) or die('FATAL ERROR: Connection to database server failed'); } } $ADODB_FETCH_MODE = ADODB_FETCH_BOTH; }
/** * Constructor * @param string The base URL query string to prefix tab links * @param string The base path to prefix the include file * @param int The active tab * @param string Optional javascript method to be used to execute tabs. * Must support 2 arguments, currently active tab, new tab to activate. */ public function __construct($baseHRef = '', $baseInc = '', $active = 0, $javascript = null) { global $AppUI, $currentTabId, $currentTabName, $m, $a; $this->_AppUI = $AppUI; $this->currentTabId = $currentTabId; $this->currentTabName = $currentTabName; $this->m = $m; $this->a = $a; $this->tabs = array(); $this->active = $active; $this->baseHRef = $baseHRef ? $baseHRef . '&' : '?'; $this->javascript = $javascript; $this->baseInc = $baseInc; $this->_uistyle = $this->_AppUI->getPref('UISTYLE') ? $this->_AppUI->getPref('UISTYLE') : w2PgetConfig('host_style'); if (!$this->_uistyle) { $this->_uistyle = 'web2project'; } }
function sendNewPass() { global $AppUI; $_live_site = w2PgetConfig('base_url'); $_sitename = w2PgetConfig('company_name'); // ensure no malicous sql gets past $checkusername = trim(w2PgetParam($_POST, 'checkusername', '')); $checkusername = db_escape($checkusername); $confirmEmail = trim(w2PgetParam($_POST, 'checkemail', '')); $confirmEmail = strtolower(db_escape($confirmEmail)); $q = new DBQuery(); $q->addTable('users'); $q->addJoin('contacts', '', 'user_contact = contact_id', 'inner'); $q->addQuery('user_id'); $q->addWhere('user_username = \'' . $checkusername . '\''); $q->addWhere('LOWER(contact_email) = \'' . $confirmEmail . '\''); 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->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->addTable('users'); $q->addUpdate('user_password', $newpass); $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(); } }
function calcDuration($start_date, $start_hour, $start_minute, $end_date, $end_hour, $end_minute, $duration_type) { $year = substr($start_date, 0, 4); $month = substr($start_date, 4, 2); $day = substr($start_date, 6, 2); $startDate = new w2p_Utilities_Date($year . '-' . $month . '-' . $day); $startDate->setTime($start_hour, $start_minute); $year = substr($end_date, 0, 4); $month = substr($end_date, 4, 2); $day = substr($end_date, 6, 2); $endDate = new w2p_Utilities_Date($year . '-' . $month . '-' . $day); $endDate->setTime($end_hour, $end_minute); $duration = $startDate->calcDuration($endDate); if (intval($duration_type) == 24) { $workHours = intval(w2PgetConfig('daily_working_hours')); $duration = $duration / $workHours; } $response = new xajaxResponse(); $response->assign('task_duration', 'value', $duration); return $response; }
<?php echo '</a>'; ?> </table> </td> </tr> <tr id="files" <?php echo isset($view_options[0]['pd_option_view_files']) ? $view_options[0]['pd_option_view_files'] ? 'style="visibility:visible;display:"' : 'style="visibility:collapse;display:none"' : 'style="visibility:visible;display:"'; ?> > <td colspan="2" class="hilite"> <?php //Permission check here $canViewFiles = $perms->checkModule('files', 'view'); if ($canViewFiles) { require w2PgetConfig('root_dir') . '/modules/projectdesigner/vw_files.php'; } else { echo $AppUI->_('You do not have permission to view files'); } ?> </td> </tr> </table> <div style="display:none;"> <table class="tbl"> <tr><td id="td_sample"> </td></tr> </table> </div> <script language="javascript"> var original_bgc = getStyle('td_sample', 'background-color', 'backgroundColor'); </script>
$titleBlock->addCrumb('?m=system&a=addeditpref', 'default user preferences'); $titleBlock->show(); // prepare the automated form fields based on db system configuration data $output = null; $last_group = ''; foreach ($rs as $c) { $tooltip = $AppUI->_($c['config_name'] . '_tooltip'); // extraparse the checkboxes and the select lists $extra = ''; $value = ''; switch ($c['config_type']) { case 'select': // Build the select list. if ($c['config_name'] == 'system_timezone') { $timezones = w2PgetSysVal('Timezones'); $entry = arraySelect($timezones, 'w2Pcfg[system_timezone]', 'class=text size=1', w2PgetConfig('system_timezone'), true); } else { $entry = '<select class="text" name="w2Pcfg[' . $c['config_name'] . ']">'; // Find the detail relating to this entry. $children = $w2Pcfg->getChildren($c['config_id']); foreach ($children as $child) { $entry .= '<option value="' . $child['config_list_name'] . '"'; if ($child['config_list_name'] == $c['config_value']) { $entry .= ' selected="selected"'; } $entry .= '>' . $AppUI->_($child['config_list_name'] . '_item_title') . '</option>'; } $entry .= '</select>'; } break; case 'checkbox':
/** Prepare the DELETE component of the SQL query */ public function prepareDelete() { switch (strtolower(trim(w2PgetConfig('dbtype')))) { case 'oci8': case 'oracle': $q = 'DELETE FROM '; if (isset($this->table_list)) { if (is_array($this->table_list)) { // Grab the first record list($key, $table) = each($this->table_list); } else { $table = $this->table_list; } } else { return false; } $q .= $this->_table_prefix . $table; $q .= $this->make_where_clause($this->where); return $q; break; default: //mySQL $q = 'DELETE FROM '; if (isset($this->table_list)) { if (is_array($this->table_list)) { // Grab the first record list($key, $table) = each($this->table_list); } else { $table = $this->table_list; } } else { return false; } $q .= $this->quote_db($this->_table_prefix . $table); $q .= $this->make_where_clause($this->where); return $q; } }
</table> <table align="center" border="0" width="700" cellpadding="0" cellspacing="0" class=""> <tr> <td style="padding-top:10px;padding-bottom:10px;" align="left" valign="top" class="txt"><h1>New Signup to web2Project!</h1> Please enter the info below to create a new signup.</td> </tr> </table> <form name="editFrm" action="./do_user_aed.php" method="post" accept-charset="utf-8"> <input type="hidden" name="user_id" value="0" /> <input type="hidden" name="contact_id" value="0" /> <input type="hidden" name="username_min_len" value="<?php echo w2PgetConfig('username_min_len'); ?> )" /> <input type="hidden" name="password_min_len" value="<?php echo w2PgetConfig('password_min_len'); ?> )" /> <input type="hidden" name="cid" value="<?php echo $cid; ?> " /> <table style="border-style:none;" align="center" border="0" width="700" cellpadding="0" cellspacing="0" class="std"> <tr><td colspan="5"><?php echo styleRenderBoxTop(); ?> </td></tr> <tr> <td align="right" width="230">* <?php echo $AppUI->_('Login Name');
$user_list = w2PgetUsersHashList(); if ($log_userfilter != 0) { $user_list = array($log_userfilter => $user_list[$log_userfilter]); } $ss = "'" . $start_date->format(FMT_DATETIME_MYSQL) . "'"; $se = "'" . $end_date->format(FMT_DATETIME_MYSQL) . "'"; $and = false; $where = false; $q = new w2p_Database_Query(); $q->addTable('tasks', 't'); $q->addQuery('t.*'); $q->addJoin('projects', '', 'projects.project_id = task_project', 'inner'); $q->addJoin('project_departments', '', 'project_departments.project_id = projects.project_id'); $q->addJoin('departments', '', 'department_id = dept_id'); $q->addWhere('project_active = 1'); if (($template_status = w2PgetConfig('template_projects_status_id')) != '') { $q->addWhere('project_status <> ' . (int) $template_status); } if ($use_period) { $q->addWhere('( (task_start_date >= ' . $ss . ' AND task_start_date <= ' . $se . ') OR ' . '(task_end_date <= ' . $se . ' AND task_end_date >= ' . $ss . ') )'); } if ($project_id != 0) { $q->addWhere('task_project=' . $project_id); } $proj = new CProject(); $obj = new CTask(); $allowedProjects = $proj->getAllowedSQL($AppUI->user_id, 'task_project'); $allowedTasks = $obj->getAllowedSQL($AppUI->user_id); if (count($allowedProjects)) { $q->addWhere(implode(' AND ', $allowedProjects)); }
$q->clear(); $q->addQuery('ut.user_id, u.user_username'); $q->addQuery('ut.perc_assignment'); $q->addQuery('CONCAT(contact_first_name, \' \',contact_last_name) AS assignee, contact_email'); $q->addTable('user_tasks', 'ut'); $q->addJoin('users', 'u', 'u.user_id = ut.user_id', 'inner'); $q->addJoin('contacts', 'c', 'u.user_contact = c.contact_id', 'inner'); $q->addWhere('ut.task_id = ' . (int) $row['task_id']); $q->addOrder('perc_assignment desc, contact_first_name, contact_last_name'); $assigned_users = array(); $row['task_assigned_users'] = $q->loadList(); //pull the final task row into array $projects[$row['task_project']]['tasks'][] = $row; } } $showEditCheckbox = isset($canEdit) && $canEdit && w2PgetConfig('direct_edit_assignment') ? true : false; global $history_active; $history_active = !empty($mods['history']) && canView('history'); ?> <script language="javascript" type="text/javascript"> function toggle_users(id){ var element = document.getElementById(id); element.style.display = (element.style.display == '' || element.style.display == "none") ? "inline" : "none"; } <?php // security improvement: // some javascript functions may not appear on client side in case of user not having write permissions // else users would be able to arbitrarily run 'bad' functions if (isset($canEdit) && $canEdit && $w2Pconfig['direct_edit_assignment']) {
/** * Return database connection for tests */ protected function getConnection() { $pdo = new PDO(w2PgetConfig('dbtype') . ':host=' . w2PgetConfig('dbhost') . ';dbname=' . w2PgetConfig('dbname'), w2PgetConfig('dbuser'), w2PgetConfig('dbpass')); return $this->createDefaultDBConnection($pdo, w2PgetConfig('dbname')); }
$user_id = w2PgetParam($_POST, 'user_id', 0); $AppUI->setState('user_id', $_POST['user_id']); } elseif ($AppUI->getState('user_id')) { $user_id = $AppUI->getState('user_id'); } else { $AppUI->setState('user_id', $user_id); } } if (isset($_POST['f'])) { $AppUI->setState('TaskIdxFilter', $_POST['f']); } $f = $AppUI->getState('TaskIdxFilter') ? $AppUI->getState('TaskIdxFilter') : w2PgetConfig('task_filter_default', 'myunfinished'); if (isset($_POST['f2'])) { $AppUI->setState('CompanyIdxFilter', $_POST['f2']); } $f2 = $AppUI->getState('CompanyIdxFilter') ? $AppUI->getState('CompanyIdxFilter') : (w2PgetConfig('company_filter_default', 'user') == 'user' ? $AppUI->user_company : 'allcompanies'); if (isset($_GET['project_id'])) { $AppUI->setState('TaskIdxProject', w2PgetParam($_GET, 'project_id', null)); } $project_id = $AppUI->getState('TaskIdxProject') ? $AppUI->getState('TaskIdxProject') : 0; if (isset($_POST['show_task_options'])) { $AppUI->setState('TaskListShowIncomplete', w2PgetParam($_POST, 'show_incomplete', 0)); } $showIncomplete = $AppUI->getState('TaskListShowIncomplete', 0); // get CCompany() to filter tasks by company $obj = new CCompany(); $companies = $obj->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name'); $filters2 = arrayMerge(array('allcompanies' => $AppUI->_('All Companies', UI_OUTPUT_RAW)), $companies); // setup the title block $titleBlock = new w2p_Theme_TitleBlock('Tasks', 'applet-48.png', $m, $m . '.' . $a); // patch 2.12.04 text to search entry box
/** * Rebuilt this as a class method to override the basic layout, etc information. * While this is overkill for the core system, it's absolutely necessary for * good custom theming. * * @param type $AppUI * @param type $rootTag * @param type $innerTag * @param type $dividingToken * @param type $m * @return type */ function buildHeaderNavigation($AppUI, $rootTag = '', $innerTag = '', $dividingToken = '', $m = '') { trigger_error("The buildHeaderNavigation function has been deprecated in v3.1 and will be removed by v5.0. Please use w2p_Theme_Base->buildHeaderNavigation() instead.", E_USER_NOTICE); $uistyle = $AppUI->getPref('UISTYLE') ? $AppUI->getPref('UISTYLE') : w2PgetConfig('host_style'); $style = 'style_' . str_replace('-', '', $uistyle); $theme = new $style($AppUI, $m); return $theme->buildHeaderNavigation($rootTag, $innerTag, $dividingToken); }
<?php /* $Id$ $URL$ */ if (!defined('W2P_BASE_DIR')) { die('You should not access this file directly'); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <title><?php echo @w2PgetConfig('page_title'); ?> </title> <meta http-equiv="Content-Type" content="text/html;charset=<?php echo isset($locale_char_set) ? $locale_char_set : 'UTF-8'; ?> " /> <title><?php echo $w2Pconfig['company_name']; ?> :: web2Project Lost Password Recovery</title> <meta http-equiv="Pragma" content="no-cache" /> <meta name="Version" content="<?php echo $AppUI->getVersion(); ?> " /> <link rel="stylesheet" type="text/css" href="./style/<?php echo $uistyle; ?>
public function indexStrings() { global $AppUI, $w2Pconfig; $nwords_indexed = 0; /* Workaround for indexing large files: ** Based on the value defined in config data, ** files with file_size greater than specified limit ** are not indexed for searching. ** Negative value :<=> no filesize limit */ $index_max_file_size = w2PgetConfig('index_max_file_size', 0); if ($index_max_file_size < 0 || $obj->file_size <= $index_max_file_size * 1024) { // get the parser application $parser = $w2Pconfig['parser_' . $this->file_type]; if (!$parser) { $parser = $w2Pconfig['parser_default']; } if (!$parser) { return false; } // buffer the file $this->_filepath = W2P_BASE_DIR . '/files/' . $this->file_project . '/' . $this->file_real_filename; $fp = fopen($this->_filepath, 'rb'); $x = fread($fp, $this->file_size); fclose($fp); // parse it $parser = $parser . ' ' . $this->_filepath; $pos = strpos($parser, '/pdf'); if (false !== $pos) { $x = `{$parser} -`; } else { $x = `{$parser}`; } // if nothing, return if (strlen($x) < 1) { return 0; } // remove punctuation and parse the strings $x = str_replace(array('.', ',', '!', '@', '(', ')'), ' ', $x); $warr = explode(' ', $x); $wordarr = array(); $nwords = count($warr); for ($x = 0; $x < $nwords; $x++) { $newword = $warr[$x]; if (!preg_match('[[:punct:]]', $newword) && mb_strlen(mb_trim($newword)) > 2 && !preg_match('[[:digit:]]', $newword)) { $wordarr[$newword] = $x; } } // filter out common strings $ignore = w2PgetSysVal('FileIndexIgnoreWords'); $ignore = str_replace(' ,', ',', $ignore); $ignore = str_replace(', ', ',', $ignore); $ignore = explode(',', $ignore); foreach ($ignore as $w) { unset($wordarr[$w]); } $nwords_indexed = count($wordarr); // insert the strings into the table while (list($key, $val) = each($wordarr)) { $q = new DBQuery(); $q->addTable('files_index'); $q->addReplace('file_id', $this->file_id); $q->addReplace('word', $key); $q->addReplace('word_placement', $val); $q->exec(); $q->clear(); } } return $nwords_indexed; }
public function getTaskList($userId, $days = 30) { /* * This list of fields - id, name, description, startDate, endDate, * updatedDate - are named specifically for the iCal creation. * If you change them, it's probably going to break. So don't do that. */ $q = new w2p_Database_Query(); $q->addQuery('t.task_id as id'); $q->addQuery('task_name as name'); $q->addQuery('task_description as description'); $q->addQuery('task_start_date as startDate'); $q->addQuery('task_end_date as endDate'); $q->addQuery('task_updated as updatedDate'); $q->addQuery('CONCAT(\'' . W2P_BASE_URL . '/index.php?m=tasks&a=view&task_id=' . '\', t.task_id) as url'); $q->addQuery('p.project_id, p.project_name'); $q->addTable('tasks', 't'); $q->addWhere('(task_start_date < ' . $q->dbfnDateAdd($q->dbfnNow(), $days, 'DAY') . ' OR task_end_date < ' . $q->dbfnDateAdd($q->dbfnNow(), $days, 'DAY') . ')'); $q->addWhere('task_percent_complete < 100'); $q->addWhere('task_dynamic <> 1'); $q->innerJoin('user_tasks', 'ut', 'ut.task_id = t.task_id'); $q->addWhere('ut.user_id = ' . $userId); $q->innerJoin('projects', 'p', 'p.project_id = t.task_project'); $q->addWhere('project_active > 0'); if (($template_status = w2PgetConfig('template_projects_status_id')) != '') { $q->addWhere('project_status <> ' . $template_status); } $q->addOrder('task_start_date, task_end_date'); return $q->loadList(); }
function showcompany($company, $restricted = false) { global $AppUI, $allpdfdata, $log_start_date, $log_end_date, $log_all; $q = new w2p_Database_Query(); $q->addTable('projects'); $q->addQuery('project_id, project_name'); $q->addWhere('project_company = ' . (int) $company); $projects = $q->loadHashList(); $q->clear(); $q->addTable('companies'); $q->addQuery('company_name'); $q->addWhere('company_id = ' . (int) $company); $company_name = $q->loadResult(); $q->clear(); $table = '<h2>Company: ' . $company_name . '</h2> <table cellspacing="1" cellpadding="4" border="0" class="tbl">'; $project_row = ' <tr> <th>' . $AppUI->_('Project') . '</th>'; $pdfth[] = $AppUI->_('Project'); $project_row .= '<th>' . $AppUI->_('Total') . '</th></tr>'; $pdfth[] = $AppUI->_('Total'); $pdfdata[] = $pdfth; $hours = 0.0; $table .= $project_row; foreach ($projects as $project => $name) { $pdfproject = array(); $pdfproject[] = $name; $project_hours = 0; $project_row = '<tr><td>' . $name . '</td>'; $q->addTable('projects'); $q->addTable('tasks'); $q->addTable('task_log'); $q->addQuery('task_log_costcode, SUM(task_log_hours) as hours'); $q->addWhere('project_id = ' . (int) $project); $q->addWhere('project_active = 1'); if (($template_status = w2PgetConfig('template_projects_status_id')) != '') { $q->addWhere('project_status <> ' . (int) $template_status); } if ($log_start_date != 0 && !$log_all) { $q->addWhere('task_log_date >=' . $log_start_date); } if ($log_end_date != 0 && !$log_all) { $q->addWhere('task_log_date <=' . $log_end_date); } if ($restricted) { $q->addWhere('task_log_creator = ' . (int) $AppUI->user_id); } $q->addWhere('project_id = task_project'); $q->addWhere('task_id = task_log_task'); $q->addGroup('project_id'); $task_logs = $q->loadHashList(); $q->clear(); foreach ($task_logs as $task_log) { $project_hours += $task_log; } $project_row .= '<td style="text-align:right;">' . sprintf('%.2f', round($project_hours, 2)) . '</td></tr>'; $pdfproject[] = round($project_hours, 2); $hours += $project_hours; if ($project_hours > 0) { $table .= $project_row; $pdfdata[] = $pdfproject; } } if ($hours > 0) { $pdfdata[] = array($AppUI->_('Total'), round($hours, 2)); $allpdfdata[$company_name] = $pdfdata; echo $table; echo '<tr><td>' . $AppUI->_('Total') . '</td><td style="text-align:right;">' . sprintf('%.2f', round($hours, 2)) . '</td></tr></table>'; } return $hours; }
$offset = $offset >= 0 ? '+' . $offset / 3600 : $offset / 3600; echo $AppUI->_('Your system has a default timezone of GMT' . $offset . '.'); } else { ?> <a href="?m=system&a=systemconfig#system_timezone"><?php echo $AppUI->_('Select a Timezone'); ?> </a> - <span class="error"><?php echo $AppUI->_('You do not have a default server timezone selected. Please select one immediately.'); ?> </span> <?php } echo '<br />'; $availableVersion = w2PgetConfig('available_version', ''); if (version_compare($AppUI->getVersion(), $availableVersion, '<')) { ?> <a href="http://sourceforge.net/projects/web2project/" target="_new"><?php echo $AppUI->_('Upgrade Available!'); ?> </a> - <span class="error"><?php echo $AppUI->_('Your system should be upgraded to v' . $availableVersion . '. Please upgrade at your earliest convenience.'); ?> </span> <?php } else { echo $AppUI->_('Your system is the latest version available.'); } ?>
public static function updatePercentComplete($project_id) { $working_hours = w2PgetConfig('daily_working_hours') ? w2PgetConfig('daily_working_hours') : 8; $q = new w2p_Database_Query(); $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', 'inner'); $q->addWhere('project_id = ' . $project_id . ' AND t1.task_id = t1.task_parent'); $project_percent_complete = $q->loadResult(); $q->clear(); $q->addTable('projects'); $q->addUpdate('project_percent_complete', $project_percent_complete); $q->addWhere('project_id = ' . (int) $project_id); $q->exec(); global $AppUI; CTask::storeTokenTask($AppUI, $project_id); }
global $company_id, $project_id, $task_id; global $currentTabId; global $currentTabName; global $tabbed, $m; // add to allow for returning to other modules besides Files $current_uriArray = parse_url($_SERVER['REQUEST_URI']); $current_uri = $current_uriArray['query']; $tab = !$company_id && !$project_id && !$task_id || $m == 'files' ? $currentTabId : 0; $page = w2PgetParam($_GET, 'page', 1); if (!isset($project_id)) { $project_id = w2PgetParam($_REQUEST, 'project_id', 0); } if (!isset($showProject)) { $showProject = true; } $xpg_pagesize = w2PgetConfig('page_size', 50); $xpg_min = $xpg_pagesize * ($page - 1); // This is where we start our record set from // load the following classes to retrieved denied records $project = new CProject(); $task = new CTask(); $df = $AppUI->getPref('SHDATEFORMAT'); $tf = $AppUI->getPref('TIMEFORMAT'); if (($company_id || $project_id || $task_id) && !($m == 'files')) { $catsql = false; } elseif ($tabbed) { if ($tab <= 0) { $catsql = false; } else { $catsql = 'file_category = ' . ($tab - 1); }
/* $Id$ $URL$ */ if (!defined('W2P_BASE_DIR')) { die('You should not access this file directly.'); } global $AppUI, $company_id, $deny, $canRead, $canEdit, $w2Pconfig, $start_date, $end_date, $this_day, $event_filter, $event_filter_list; $perms =& $AppUI->acl(); $user_id = $AppUI->user_id; $other_users = false; $no_modify = false; $start_date = new CDate('0000-00-00 00:00:00'); $end_date = new CDate('9999-12-31 23:59:59'); // assemble the links for the events $events = CEvent::getEventsForPeriod($start_date, $end_date, 'all', 0, 0, $company_id); $start_hour = w2PgetConfig('cal_day_start'); $end_hour = w2PgetConfig('cal_day_end'); $tf = $AppUI->getPref('TIMEFORMAT'); $df = $AppUI->getPref('SHDATEFORMAT'); $types = w2PgetSysVal('EventType'); $html = '<table cellspacing="1" cellpadding="2" border="0" width="100%" class="tbl">'; $html .= '<tr><th>' . $AppUI->_('Date') . '</th><th>' . $AppUI->_('Type') . '</th><th>' . $AppUI->_('Event') . '</th></tr>'; foreach ($events as $row) { $html .= '<tr>'; $start = new CDate($row['event_start_date']); $end = new CDate($row['event_end_date']); $html .= '<td width="25%" nowrap="nowrap">' . $start->format($df . ' ' . $tf) . ' - '; $html .= $end->format($df . ' ' . $tf) . '</td>'; $href = '?m=calendar&a=view&event_id=' . $row['event_id']; $alt = $row['event_description']; $html .= '<td width="10%" nowrap="nowrap">'; $html .= w2PshowImage('event' . $row['event_type'] . '.png', 16, 16, '', '', 'calendar');
public function getAllTasksForPeriod($start_date, $end_date, $company_id = 0, $user_id = null) { global $AppUI; $q = new w2p_Database_Query(); // convert to default db time stamp $db_start = $start_date->format(FMT_DATETIME_MYSQL); $db_end = $end_date->format(FMT_DATETIME_MYSQL); // Allow for possible passing of user_id 0 to stop user filtering if (!isset($user_id)) { $user_id = $AppUI->user_id; } // check permissions on projects $proj = new CProject(); $task_filter_where = $proj->getAllowedSQL($AppUI->user_id, 't.task_project'); // exclude read denied projects $deny = $proj->getDeniedRecords($AppUI->user_id); // check permissions on tasks $obj = new CTask(); $allow = $obj->getAllowedSQL($AppUI->user_id, 't.task_id'); $q->addTable('tasks', 't'); if ($user_id) { $q->innerJoin('user_tasks', 'ut', 't.task_id=ut.task_id'); } $q->innerJoin('projects', 'projects', 't.task_project = projects.project_id'); $q->innerJoin('companies', 'companies', 'projects.project_company = companies.company_id'); $q->leftJoin('project_departments', '', 'projects.project_id = project_departments.project_id'); $q->leftJoin('departments', '', 'departments.dept_id = project_departments.department_id'); $q->addQuery('DISTINCT t.task_id, t.task_name, t.task_start_date, t.task_end_date, t.task_percent_complete, t.task_duration' . ', t.task_duration_type, projects.project_color_identifier AS color, projects.project_name, t.task_milestone, task_description, task_type, company_name, task_access, task_owner'); $q->addWhere('task_status > -1' . ' AND (task_start_date <= \'' . $db_end . '\' AND t.task_percent_complete<100 OR task_end_date = \'0000-00-00 00:00:00\' OR task_end_date = NULL )'); $q->addWhere('project_active = 1'); if (($template_status = w2PgetConfig('template_projects_status_id')) != '') { $q->addWhere('project_status <> ' . $template_status); } if ($user_id) { $q->addWhere('ut.user_id = ' . (int) $user_id); } if ($company_id) { $q->addWhere('projects.project_company = ' . (int) $company_id); } if (count($task_filter_where) > 0) { $q->addWhere('(' . implode(' AND ', $task_filter_where) . ')'); } if (count($deny) > 0) { $q->addWhere('(t.task_project NOT IN (' . implode(', ', $deny) . '))'); } if (count($allow) > 0) { $q->addWhere('(' . implode(' AND ', $allow) . ')'); } $q->addOrder('t.task_start_date'); // assemble query $tasks = $q->loadList(-1, 'task_id'); // check tasks access $result = array(); foreach ($tasks as $key => $row) { $obj->load($row['task_id']); $canAccess = $obj->canAccess(); if (!$canAccess) { continue; } $result[$key] = $row; } // execute and return return $result; }
public function indexStrings() { global $w2Pconfig; $nwords_indexed = 0; /* Workaround for indexing large files: ** Based on the value defined in config data, ** files with file_size greater than specified limit ** are not indexed for searching. ** Negative value :<=> no filesize limit */ $index_max_file_size = w2PgetConfig('index_max_file_size', 0); if ($this->file_size > 0 && ($index_max_file_size < 0 || (int) $this->file_size <= $index_max_file_size * 1024)) { // get the parser application $parser = $w2Pconfig['parser_' . $this->file_type]; if (!$parser) { $parser = $w2Pconfig['parser_default']; } if (!$parser) { return false; } // buffer the file $this->_filepath = W2P_BASE_DIR . '/files/' . $this->file_project . '/' . $this->file_real_filename; if (file_exists($this->_filepath)) { $fp = fopen($this->_filepath, 'rb'); $x = fread($fp, $this->file_size); fclose($fp); // parse it $parser = $parser . ' ' . $this->_filepath; $pos = strpos($parser, '/pdf'); /* * TODO: I *really* hate using error surpression here and I would * normally just detect if safe_mode is on and if it was, skip * this call. Unfortunately, safe_mode has been deprecated in * 5.3 and will be removed in 5.4 */ if (false !== $pos) { $x = @shell_exec(`{$parser} -`); } else { $x = @shell_exec(`{$parser}`); } // if nothing, return if (strlen($x) < 1) { return 0; } // remove punctuation and parse the strings $x = str_replace(array('.', ',', '!', '@', '(', ')'), ' ', $x); $warr = explode(' ', $x); $wordarr = array(); $nwords = count($warr); for ($x = 0; $x < $nwords; $x++) { $newword = $warr[$x]; if (!preg_match('[!"#$%&\'()*+,\\-./:;<=>?@[\\\\]^_`{|}~]', $newword) && mb_strlen(mb_trim($newword)) > 2 && !preg_match('[0-9]', $newword)) { $wordarr[$newword] = $x; } } // filter out common strings $ignore = w2PgetSysVal('FileIndexIgnoreWords'); $ignore = str_replace(' ,', ',', $ignore); $ignore = str_replace(', ', ',', $ignore); $ignore = explode(',', $ignore); foreach ($ignore as $w) { unset($wordarr[$w]); } $nwords_indexed = count($wordarr); // insert the strings into the table while (list($key, $val) = each($wordarr)) { $q = new w2p_Database_Query(); $q->addTable('files_index'); $q->addReplace('file_id', $this->file_id); $q->addReplace('word', $key); $q->addReplace('word_placement', $val); $q->exec(); $q->clear(); } } else { //TODO: if the file doesn't exist.. should we delete the db record? } } $q = new w2p_Database_Query(); $q->addTable('files'); $q->addUpdate('file_indexed', 1); $q->addWhere('file_id = ' . $this->file_id); $q->exec(); return $nwords_indexed; }