/** * Check whether the user has the specified access level for any project project * @param int $p_access_level integer representing access level * @param int|null $p_user_id integer representing user id, defaults to null to use current user * @return bool whether user has access level specified * @access public */ function access_has_any_project($p_access_level, $p_user_id = null) { # Short circuit the check in this case if (NOBODY == $p_access_level) { return false; } if (null === $p_user_id) { $p_user_id = auth_get_current_user_id(); } $t_projects = project_get_all_rows(); foreach ($t_projects as $t_project) { if (access_has_project_level($p_access_level, $t_project['id'], $p_user_id)) { return true; } } return false; }
<tr> <td colspan="7"> <form method="post" action="manage_proj_subproj_add.php"> <?php echo form_security_field('manage_proj_subproj_add'); ?> <input type="hidden" name="project_id" value="<?php echo $f_project_id; ?> " /> <select name="subproject_id"> <?php $t_all_subprojects = project_hierarchy_get_subprojects($f_project_id, true); $t_all_subprojects[] = $f_project_id; $t_manage_access = config_get('manage_project_threshold'); $t_projects = project_get_all_rows(); $t_projects = multi_sort($t_projects, 'name', ASCENDING); foreach ($t_projects as $t_project) { if (in_array($t_project['id'], $t_all_subprojects) || in_array($f_project_id, project_hierarchy_get_all_subprojects($t_project['id'])) || !access_has_project_level($t_manage_access, $t_project['id'])) { continue; } ?> <option value="<?php echo $t_project['id']; ?> "><?php echo string_attribute($t_project['name']); ?> </option> <?php }
function ERP_custom_function_print_projects_option_list($p_sel_value) { $t_all_projects = project_get_all_rows(); $t_projects_sorted = array(); foreach ($t_all_projects as $t_project_key => $t_project) { $t_projects_sorted[$t_project_key] = $t_project['name']; } natcasesort($t_projects_sorted); foreach ($t_projects_sorted as $t_project_id => $t_project_name) { echo '<option value="' . $t_all_projects[$t_project_id]['id'] . '"'; check_selected((array) $p_sel_value, (int) $t_all_projects[$t_project_id]['id']); echo '>' . ($t_all_projects[$t_project_id]['enabled'] == FALSE ? '* ' : NULL) . string_attribute($t_all_projects[$t_project_id]['name']) . '</option>' . "\n"; } }
private function process_imap_mailbox() { $this->_mailserver = new Net_IMAP($this->_mailbox['hostname'], $this->_mailbox['port']); if ($this->_mailserver->_connected === TRUE) { $t_loginresult = $this->mailbox_login(); if (!$this->pear_error('Attempt login', $t_loginresult)) { // If basefolder is empty we try to select the inbox folder if (is_blank($this->_mailbox['imap_basefolder'])) { $this->_mailbox['imap_basefolder'] = $this->_mailserver->getCurrentMailbox(); } if ($this->_mailserver->mailboxExist($this->_mailbox['imap_basefolder'])) { if ($this->_test_only === FALSE) { // There does not seem to be a viable api function which removes this plugins dependability on table column names // So if a column name is changed it might cause problems if the code below depends on it. // Luckily we only depend on id, name and enabled if ($this->_mailbox['imap_createfolderstructure'] == ON) { $t_projects = project_get_all_rows(); $t_hierarchydelimiter = $this->_mailserver->getHierarchyDelimiter(); } else { $t_projects = array(0 => project_get_row($this->_mailbox['project_id'])); } foreach ($t_projects as $t_project) { if ($t_project['enabled'] == ON) { $t_project_name = $this->cleanup_project_name($t_project['name']); $t_foldername = $this->_mailbox['imap_basefolder'] . ($this->_mailbox['imap_createfolderstructure'] ? $t_hierarchydelimiter . $t_project_name : NULL); // We don't need to check twice whether the mailbox exist incase createfolderstructure is false if (!$this->_mailbox['imap_createfolderstructure'] || $this->_mailserver->mailboxExist($t_foldername) === TRUE) { $this->_mailserver->selectMailbox($t_foldername); $t_ListMsgs = $this->_mailserver->getListing(); if (!$this->pear_error('Retrieve list of messages', $t_ListMsgs)) { while ($t_Msg = array_shift($t_ListMsgs)) { $t_isDeleted = $this->isDeleted($t_Msg['msg_id']); if ($this->pear_error('Check email deleted flag', $t_isDeleted)) { $t_isDeleted = FALSE; } if ($t_isDeleted === TRUE) { // Email marked as deleted. Do nothing } else { $t_emailresult = $this->process_single_email($t_Msg['msg_id'], (int) $t_project['id']); if ($t_emailresult === TRUE) { $t_deleteresult = $this->_mailserver->deleteMsg($t_Msg['msg_id']); $this->pear_error('Attempt delete email', $t_deleteresult); } } } } } elseif ($this->_mailbox['imap_createfolderstructure'] === TRUE) { // create this mailbox $this->_mailserver->createMailbox($t_foldername); } } else { $this->custom_error('Project is disabled: ' . $t_project['name']); } } } } else { $this->custom_error('IMAP basefolder not found'); } } //$t_mailbox->expunge(); //disabled as this is handled by the disconnect // mail_delete decides whether to perform the expunge command before closing the connection $this->_mailserver->disconnect((bool) $this->_mail_delete); } else { $this->custom_error('Failed to connect to the mail server'); } }
function removeCustomField($p_field_name) { $t_field_id = custom_field_get_id_from_name($p_field_name); $t_projects = project_get_all_rows(); foreach ($t_projects as $t_row) { custom_field_unlink($t_field_id, $t_row['id']); } }