private static function loadHolidaysSettings() { global $AppUI; if (is_null(self::$holiday_manual)) { // Query database for settings $q = new w2p_Database_Query(); $q->addTable("holiday_settings"); $q->addQuery("holiday_manual, holiday_auto, holiday_driver, holiday_filter"); $settings = $q->loadHash(); self::$holiday_manual = $settings['holiday_manual']; self::$holiday_auto = $settings['holiday_auto']; self::$holiday_driver = $settings['holiday_driver']; self::$holiday_filter = $settings['holiday_filter']; } if (self::$holiday_auto && self::$holiday_filter >= 0 && is_null(self::$holiday_filter_instance)) { $filters_alloc = Date_Holidays::getInstalledFilters(); require_once dirname(__FILE__) . "/PEAR/Holidays/Filter/" . str_replace("_", "/", $filters_alloc[self::$holiday_filter]['title']) . ".php"; $filterclass = "Date_Holidays_Filter_" . $filters_alloc[self::$holiday_filter]['title']; self::$holiday_filter_instance = new $filterclass(); } if (self::$holiday_auto && self::$holiday_driver >= 0 && is_null(self::$holiday_driver_instance)) { $drivers_alloc = Date_Holidays::getInstalledDrivers(); self::$holiday_driver_instance = Date_Holidays::factory($drivers_alloc[self::$holiday_driver]['title'], null, $AppUI->user_locale); } }
public function install() { $q = new w2p_Database_Query(); $q->addTable('modules'); $q->addQuery('mod_directory'); $q->addWhere('mod_directory = \'' . $this->mod_directory . '\''); if ($temp = $q->loadHash()) { // the module is already installed // TODO: check for older version - upgrade return false; } // This arbitrarily places it at the end of the list. $this->mod_ui_order = 100; $this->store(); $this->_compactModuleUIOrder(); $perms =& $GLOBALS['AppUI']->acl(); $perms->addModule($this->mod_directory, $this->mod_name); // Determine if it is an admin module or not, then add it to the correct set if (!isset($this->mod_admin)) { $this->mod_admin = 0; } if ($this->mod_admin) { $perms->addGroupItem($this->mod_directory, "admin"); } else { $perms->addGroupItem($this->mod_directory, "non_admin"); } if (isset($this->permissions_item_table) && $this->permissions_item_table) { $perms->addModuleSection($this->permissions_item_table); } return true; }
public function getProject() { $q = new w2p_Database_Query(); $q->addTable('projects'); $q->addQuery('project_name, project_short_name, project_color_identifier'); $q->addWhere('project_id = ' . (int) $this->task_project); $projects = $q->loadHash(); $q->clear(); return $projects; }
$selection_string = 'Department'; $dataId = $dept_id; $deptList = CDepartment::getDepartmentList(null, $company_id, null); foreach ($deptList as $dept) { $select_list[$dept['dept_id']] = $dept['dept_name']; } break; } $select_list = array('0' => '') + $select_list; $myId = (int) w2PgetParam($_POST, $id_field, 0); if ($myId) { $q = new w2p_Database_Query(); $q->addTable($table_name); $q->addQuery('*'); $q->addWhere($id_field . '=' . $myId); $r_data = $q->loadHash(); $q->clear(); $data_update_script = ''; $update_address = isset($_POST['overwrite_address']); if ($table_name == 'companies') { $update_fields = array(); if ($update_address) { $update_fields = array('company_address1' => 'contact_address1', 'company_address2' => 'contact_address2', 'company_city' => 'contact_city', 'company_state' => 'contact_state', 'company_zip' => 'contact_zip', 'company_phone1' => 'contact_phone', 'company_phone2' => 'contact_phone2', 'company_fax' => 'contact_fax'); } if ($myId > 0) { $data_update_script = "opener.setCompany({$myId} , '" . $AppUI->__($r_data[$name_field], UI_OUTPUT_JS) . "');"; } else { $data_update_script = "opener.setCompany({$myId}, '');"; } } else { if ($table_name == 'departments') {
public function w2Pacl_nuclear($userid, $module, $item, $mod_class = array()) { global $AppUI; //This is a sensitive function so if the minimum permission request arguments are not provided don't permit anything to this item if (!$userid || !$module || !$item) { return array(); } if (!count($mod_class)) { $q = new w2p_Database_Query(); $q->addTable('modules'); $q->addQuery('mod_main_class, permissions_item_table, permissions_item_field, permissions_item_label, mod_directory'); $q->addWhere('mod_directory = \'' . $module . '\''); $q->addWhere('mod_active = 1'); $mod_class = $q->loadHash(); } //If we don't know what is the module we are dealing with lets deny if (!$mod_class['mod_directory']) { dprint(__FILE__, __LINE__, 2, 'user:'******'module:' . $module . 'Item:' . $item . $AppUI->getModuleClass($mod_class['mod_directory'])); return array(); } $obj = new $mod_class['mod_main_class'](); $allowedRecords = array(); if ($module == 'projects') { $allowedRecords = $obj->getAllowedRecords($userid, $mod_class['permissions_item_table'] . '.' . $mod_class['permissions_item_field'] . ',' . $mod_class['permissions_item_label'], '', null, null, 'projects'); } else { $allowedRecords = $obj->getAllowedRecords($userid, $mod_class['permissions_item_table'] . '.' . $mod_class['permissions_item_field'] . ',' . $mod_class['permissions_item_label']); } if (count($allowedRecords)) { if (isset($allowedRecords[(int) $item])) { return array('access' => 1, 'acl_id' => 'checked'); } else { return array(); } } else { return array(); } }
if ($action == 'add') { $q->clear(); } $q->addTable('history'); $q->addUpdate('history_item = history_id'); $q->addWhere('history_table = \'history\''); $okMsg = 'History deleted'; } $q->clear(); $AppUI->redirect(); } // pull the history $q->addTable('history'); $q->addQuery('*'); $q->addWhere('history_id =' . $history_id); $history = $q->loadHash(); $q->clear(); $titleBlock = new CTitleBlock($history_id ? 'Edit history' : 'New history', 'stock_book_blue_48.png', 'history', 'history.' . $a); if ($canDelete) { $titleBlock->addCrumbDelete('delete history', $canDelete, $msg); } $titleBlock->show(); ?> <script language="javascript" type="text/javascript"> function delIt() { document.AddEdit.action.value = 'del'; document.AddEdit.submit(); } function cancel() {
foreach ($avail_modules as $avail_module) { $modules[$avail_module['value']] = $avail_module['value']; } $modules = array(0 => 'All Modules') + $modules; $actions = array(0 => 'All Actions', 'access' => 'access', 'add' => 'add', 'delete' => 'delete', 'edit' => 'edit', 'view' => 'view'); $table = '<table class="tbl" width="100%" cellspacing="1" cellpadding="2" border="0">'; $table .= '<tr><th colspan="9"><b>Permission Result Table</b></th></tr>'; $table .= '<tr><th>UserID</th><th>User</th><th>User Name</th><th>Module</th><th>Item</th><th>Item Name</th><th>Action</th><th>Allow</th><th>ACL_ID</th></tr>'; foreach ($permissions as $permission) { $item = ''; if ($permission['item_id']) { $q = new w2p_Database_Query(); $q->addTable('modules'); $q->addQuery('permissions_item_field,permissions_item_label'); $q->addWhere('mod_directory = \'' . $permission['module'] . '\''); $field = $q->loadHash(); $q = new w2p_Database_Query(); $q->addTable($permission['module']); $q->addQuery($field['permissions_item_label']); $q->addWhere($field['permissions_item_field'] . ' = \'' . $permission['item_id'] . '\''); $item = $q->loadResult(); } if (!($permission['item_id'] && !$permission['acl_id'])) { $table .= '<tr>' . '<td style="text-align:right;">' . $permission['user_id'] . '</td>' . '<td>' . $permission['user_name'] . '</td>' . '<td>' . $users[$permission['user_id']] . '</td>' . '<td>' . $permission['module'] . '</td>' . '<td style="text-align:right;">' . ($permission['item_id'] ? $permission['item_id'] : '') . '</td>' . '<td>' . ($item ? $item : 'ALL') . '</td>' . '<td>' . $permission['action'] . '</td>' . '<td ' . (!$permission['access'] ? 'style="text-align:right;background-color:red"' : 'style="text-align:right;background-color:green"') . '>' . $permission['access'] . '</td>' . '<td ' . ($permission['acl_id'] ? '' : 'style="background-color:gray"') . '>' . ($permission['acl_id'] ? $permission['acl_id'] : 'soft-denial') . '</td>' . '</tr>'; } } $table .= '</table>'; $users = array('' => '(' . $AppUI->_('Select User') . ')') + $users; $user = isset($_POST['user']) && $_POST['user'] != '' ? $_POST['user'] : $AppUI->user_id; $user_selector = arraySelect($users, 'user', 'class="text" onchange="javascript:document.pickUser.submit()"', $user); $module = isset($_POST['module']) && $_POST['module'] != '' ? $_POST['module'] : '';
echo '<br />'; if (function_exists('styleRenderBoxTop')) { echo styleRenderBoxTop(); } echo '<table cellspacing="0" cellpadding="4" border="0" width="100%" class="std"> <tr> <td>'; echo '<table class="std" width="100%">'; echo '<tr><th>' . $AppUI->_('Task name') . '</th><th>' . $AppUI->_('T.Owner') . '</th><th>' . $AppUI->_('H.Alloc.') . '</th><th>' . $AppUI->_('Task end date') . '</th><th>' . $AppUI->_('Last activity date') . '</th><th>' . $AppUI->_('Done') . '?</th></tr>'; $hrs = $AppUI->_('hrs'); // To avoid calling $AppUI each row foreach ($tasks as $task) { if ($actual_project_id != $task['task_project']) { echo '<tr><td colspan="6"><b>' . $task['project_name'] . '</b></td>'; $actual_project_id = $task['task_project']; } $q->addTable('task_log'); $q->addQuery('*'); $q->addWhere('task_log_task = ' . (int) $task['task_id']); $q->addOrder('task_log_date DESC'); $q->setLimit(1); $task_log = $q->loadHash(); $q->clear(); $done_img = $task['task_percent_complete'] == 100 ? 'Yes' : 'No'; echo '<tr><td> ' . $task['task_name'] . '</td><td>' . $task['user_username'] . '</td><td align="right">' . $task['task_duration'] * $task['task_duration_type'] . ' ' . $hrs . '</td><td align="center">' . $task['task_end_date'] . '</td><td align="center">' . $task_log['task_log_date'] . '</td><td align="center">' . $done_img . '</td></tr>'; } echo '</table>'; echo '</td> </tr> </table>'; }
$q->addTable('contacts', 'con'); $q->addQuery('con.*, company_id, company_name, dept_name'); $q->addJoin('companies', 'com', 'contact_company = company_id'); $q->addJoin('departments', 'dep', 'dept_id = contact_department'); $q->addWhere('con.contact_id = ' . (int) $contact_id); } else { $q = new w2p_Database_Query(); $q->addTable('users', 'u'); $q->addQuery('u.*'); $q->addQuery('con.*, company_id, company_name, dept_name'); $q->addJoin('contacts', 'con', 'user_contact = contact_id', 'inner'); $q->addJoin('companies', 'com', 'contact_company = company_id'); $q->addJoin('departments', 'dep', 'dept_id = contact_department'); $q->addWhere('u.user_id = ' . (int) $user_id); } $user = $q->loadHash(); if (!$user && $user_id > 0) { $titleBlock = new CTitleBlock('Invalid User ID', 'helix-setup-user.png', $m, $m . '.' . $a); $titleBlock->addCrumb('?m=admin', 'users list'); $titleBlock->show(); } else { if (!$user_id && !$contact_id) { $user['contact_id'] = 0; } // pull companies $company = new CCompany(); $companies = $company->getAllowedRecords($AppUI->user_id, 'company_id,company_name', 'company_name'); $companies = arrayMerge(array('0' => ''), $companies); // setup the title block $ttl = $user_id ? 'Edit User' : 'Add User'; $titleBlock = new CTitleBlock($ttl, 'helix-setup-user.png', $m, $m . '.' . $a);
/** * @param $row * * @return array */ function getPermissionField($row) { $q = new w2p_Database_Query(); $q->addTable('modules'); $q->addQuery('permissions_item_field,permissions_item_label'); $q->addWhere('mod_directory = \'' . $row['module'] . '\''); $field = $q->loadHash(); return $field; }
public function show_history($history) { global $AppUI; $id = $history['history_item']; $module = $history['history_table']; $secondary_key = ''; if ($module == 'companies') { $table_id = 'company_id'; } elseif ($module == 'modules') { $table_id = 'mod_id'; } elseif ($module == 'departments') { $table_id = 'dept_id'; } elseif ($module == 'forums') { $table_id = 'forum_id'; } elseif ($module == 'forum_messages') { $table_id = 'message_id'; } elseif ($module == 'task_log') { $table_id = (substr($module, -1) == 's' ? substr($module, 0, -1) : $module) . '_id'; $secondary_key = ', task_log_task'; } else { $table_id = (substr($module, -1) == 's' ? substr($module, 0, -1) : $module) . '_id'; } if ($module == 'login') { return $AppUI->_('User') . ' "' . $history['history_description'] . '" ' . $AppUI->_($history['history_action']); } if ($history['history_action'] == 'add') { $msg = $AppUI->_('Added new') . ' '; } elseif ($history['history_action'] == 'update') { $msg = $AppUI->_('Modified') . ' '; } elseif ($history['history_action'] == 'delete') { return $AppUI->_('Deleted') . ' "' . $history['history_description'] . '" ' . $AppUI->_('from') . ' ' . $AppUI->_($module) . ' ' . $AppUI->_('module'); } $q = new w2p_Database_Query(); $q->addTable($module); $q->addQuery($table_id . $secondary_key); $q->addWhere($table_id . ' =' . $id); $result = $q->loadHash(); if ($result) { switch ($module) { case 'history': $link = '&a=addedit&history_id='; break; case 'files': $link = '&a=addedit&file_id='; break; case 'tasks': $link = '&a=view&task_id='; break; case 'forums': $link = '&a=viewer&forum_id='; break; case 'projects': $link = '&a=view&project_id='; break; case 'companies': $link = '&a=view&company_id='; break; case 'contacts': $link = '&a=view&contact_id='; break; case 'task_log': $module = 'tasks'; $link = '&a=view&task_id=' . $result['task_log_task'] . '&tab=0#tasklog'; break; } } $q->clear(); if (!empty($link)) { $link = '<a href="?m=' . $module . $link . $id . '">' . $history['history_description'] . '</a>'; } else { $link = $history['history_description']; } $msg .= $AppUI->_('item') . " '{$link}' " . $AppUI->_('in') . ' ' . $AppUI->_(ucfirst($module)) . ' ' . $AppUI->_('module'); // . $history; return $msg; }
for ($i = 0; $drivers_alloc[$i]; $i++) { $drivers_available[$i] = $drivers_alloc[$i]['title']; } $filters_alloc = Date_Holidays::getInstalledFilters(); $filters_available = array(-1 => $AppUI->_("None")); for ($i = 0; $filters_alloc[$i]; $i++) { list($country, $whitelist) = explode("_", $filters_alloc[$i]['title']); if ($whitelist) { $filters_available[$i] = $AppUI->_($country) . " >> " . $AppUI->_($whitelist); } } // Query database settings $q = new w2p_Database_Query(); $q->addTable("holiday_settings"); $q->addQuery("holiday_manual, holiday_auto, holiday_driver, holiday_filter"); extract($q->loadHash()); // establish the focus 'date' $date = w2PgetParam($_GET, 'date', null); if (!$date) { $date = new w2p_Utilities_Date(); } else { $date = new w2p_Utilities_Date($date); } $date->setDay(1); $date->setMonth(1); $date->setTime(0, 0, 0); $year = $date->getYear(); $prev_year = $date->format(FMT_TIMESTAMP_DATE); $prev_year = (int) ($prev_year - 10000); $next_year = $date->format(FMT_TIMESTAMP_DATE); $next_year = (int) ($next_year + 10000);