当前位置: 首页>>代码示例>>PHP>>正文


PHP Projects::getAll方法代码示例

本文整理汇总了PHP中Projects::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Projects::getAll方法的具体用法?PHP Projects::getAll怎么用?PHP Projects::getAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Projects的用法示例。


在下文中一共展示了Projects::getAll方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getProjectsByCompany

 /**
  * Return all projects that this company is member of
  *
  * @access public
  * @param Company $company
  * @param string $additional_conditions Additional SQL conditions
  * @return array
  */
 static function getProjectsByCompany(Company $company, $additional_conditions = null)
 {
     if ($company->isOwner()) {
         return Projects::getAll();
     }
     $projects_table = Projects::instance()->getTableName(true);
     $project_companies_table = ProjectCompanies::instance()->getTableName(true);
     $projects = array();
     $sql = "SELECT {$projects_table}.* FROM {$projects_table}, {$project_companies_table} WHERE ({$projects_table}.`id` = {$project_companies_table}.`project_id` AND {$project_companies_table}.`company_id` = " . DB::escape($company->getId()) . ')';
     if (trim($additional_conditions) != '') {
         $sql .= " AND ({$additional_conditions})";
     }
     $rows = DB::executeAll($sql);
     if (is_array($rows)) {
         foreach ($rows as $row) {
             $projects[] = Projects::instance()->loadFromRow($row);
         }
         // foreach
     }
     // if
     return count($projects) ? $projects : null;
 }
开发者ID:469306621,项目名称:Languages,代码行数:30,代码来源:ProjectCompanies.class.php

示例2: select_project

/**
 * Renders select project box
 *
 * @param string $name
 * @param Project $project
 * @param integer $selected ID of selected milestone
 * @param array $attributes Array of additional attributes
 * @return string
 * @throws InvalidInstanceError
 */
function select_project($name, $projectname = null, $selected = null, $attributes = null)
{
    if (is_array($attributes)) {
        if (!isset($attributes['class'])) {
            $attributes['class'] = 'select_project';
        }
    } else {
        $attributes = array('class' => 'select_project');
    }
    // if
    $options = array(option_tag(lang('none'), 0));
    if (is_null($projectname)) {
        $projects = Projects::getAll();
    } else {
        $projects = Projects::getAll();
    }
    if (is_array($projects)) {
        foreach ($projects as $project) {
            $option_attributes = $project->getId() == $selected ? array('selected' => 'selected') : null;
            $options[] = option_tag($project->getName(), $project->getId(), $option_attributes);
        }
        // foreach
    }
    // if
    return select_box($name, $options, $attributes);
}
开发者ID:bahmany,项目名称:PythonPurePaperless,代码行数:36,代码来源:application.php

示例3: update_permissions

 /**
  * Update company permissions
  *
  * @param void
  * @return null
  */
 function update_permissions()
 {
     if (!logged_user()->isAdministrator(owner_company())) {
         flash_error(lang('no access permissions'));
         $this->redirectTo('dashboard');
     }
     // if
     $company = Companies::findById(get_id());
     if (!$company instanceof Company) {
         flash_error(lang('company dnx'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     if ($company->isOwner()) {
         flash_error(lang('error owner company has all permissions'));
         $this->redirectToReferer(get_url('administration'));
     }
     // if
     $projects = Projects::getAll(Projects::ORDER_BY_NAME);
     if (!is_array($projects) || !count($projects)) {
         flash_error(lang('no projects in db'));
         $this->redirectToUrl($company->getViewUrl());
     }
     // if
     tpl_assign('projects', $projects);
     tpl_assign('company', $company);
     if (array_var($_POST, 'submitted') == 'submitted') {
         $counter = 0;
         $logged_user = logged_user();
         // reuse...
         foreach ($projects as $project) {
             if (!$logged_user->isProjectUser($project)) {
                 continue;
             }
             // if
             $new_value = array_var($_POST, 'project_' . $project->getId()) == 'checked';
             $relation = ProjectCompanies::findById(array('project_id' => $project->getId(), 'company_id' => $company->getId()));
             // findById
             $current_value = $relation instanceof ProjectCompany;
             try {
                 if ($current_value != $new_value) {
                     if ($new_value) {
                         $relation = new ProjectCompany();
                         $relation->setProjectId($project->getId());
                         $relation->setCompanyId($company->getId());
                         $relation->save();
                     } else {
                         $relation->delete();
                     }
                     // if
                     $counter++;
                 }
                 // if
             } catch (Exception $e) {
                 die($e->__toString());
             }
             // if
         }
         // foreach
         flash_success(lang('success update company permissions', $counter));
         $this->redirectToUrl($company->getViewUrl());
     }
     // if
 }
开发者ID:ukd1,项目名称:Project-Pier,代码行数:70,代码来源:CompanyController.class.php

示例4: getProjects

 /**
  * Return all projects that this company is member of
  *
  * @access public
  * @param void
  * @return array
  */
 function getProjects()
 {
     return $this->isOwner() ? Projects::getAll() : ProjectCompanies::getProjectsByCompany($this);
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:11,代码来源:Company.class.php

示例5: edit_group

 /**
  * Edit group
  *
  * @param void
  * @return null
  */
 function edit_group()
 {
     $this->setTemplate('add_group');
     if (!can_manage_security(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $group = Groups::findById(get_id());
     if (!$group instanceof Group) {
         flash_error(lang('group dnx'));
         $this->redirectTo('administration', 'groups');
     }
     // if
     if (logged_user()->isAdministrator()) {
         $projects = Projects::getAll();
     } else {
         $projects = null;
     }
     $permissions = ProjectUsers::getNameTextArray();
     $group_data = array_var($_POST, 'group');
     if (!is_array($group_data)) {
         $group_data = array('name' => $group->getName(), 'can_edit_company_data' => $group->getCanEditCompanyData(), 'can_manage_security' => $group->getCanManageSecurity(), 'can_manage_workspaces' => $group->getCanManageWorkspaces(), 'can_manage_configuration' => $group->getCanManageConfiguration(), 'can_manage_contacts' => $group->getCanManageContacts(), 'can_manage_templates' => $group->getCanManageTemplates(), 'can_manage_reports' => $group->getCanManageReports(), 'can_manage_time' => $group->getCanManageTime(), 'can_add_mail_accounts' => $group->getCanAddMailAccounts());
         // array
     }
     // if
     $users = GroupUsers::getUsersByGroup($group->getId());
     if ($users) {
         foreach ($users as $usr) {
             $group_data['user[' . $usr->getId() . ']'] = true;
         }
     }
     tpl_assign('group', $group);
     tpl_assign('group_data', $group_data);
     tpl_assign('permissions', $permissions);
     tpl_assign('projects', $projects);
     if (is_array(array_var($_POST, 'group'))) {
         $group->setFromAttributes($group_data);
         if (array_var($group_data, "can_edit_company_data") != 'checked') {
             $group->setCanEditCompanyData(false);
         }
         if (array_var($group_data, "can_manage_security") != 'checked') {
             $group->setCanManageSecurity(false);
         }
         if (array_var($group_data, "can_manage_configuration") != 'checked') {
             $group->setCanManageConfiguration(false);
         }
         if (array_var($group_data, "can_manage_workspaces") != 'checked') {
             $group->setCanManageWorkspaces(false);
         }
         if (array_var($group_data, "can_manage_contacts") != 'checked') {
             $group->setCanManageContacts(false);
         }
         if (array_var($group_data, "can_manage_templates") != 'checked') {
             $group->setCanManageTemplates(false);
         }
         if (array_var($group_data, "can_manage_reports") != 'checked') {
             $group->setCanManageReports(false);
         }
         if (array_var($group_data, "can_manage_time") != 'checked') {
             $group->setCanManageTime(false);
         }
         if (array_var($group_data, "can_add_mail_accounts") != 'checked') {
             $group->setCanAddMailAccounts(false);
         }
         try {
             DB::beginWork();
             //set permissions
             $permissionsString = array_var($_POST, 'permissions');
             if ($permissionsString && $permissionsString != '') {
                 $permissions = json_decode($permissionsString);
             }
             if (is_array($permissions) && count($permissions) > 0) {
                 //Clear old modified permissions
                 $ids = array();
                 foreach ($permissions as $perm) {
                     $ids[] = $perm->wsid;
                 }
                 ProjectUsers::clearByUser($group, implode(',', $ids));
                 //Add new permissions
                 //TODO - Make batch update of these permissions
                 foreach ($permissions as $perm) {
                     if (ProjectUser::hasAnyPermissions($perm->pr, $perm->pc)) {
                         $relation = new ProjectUser();
                         $relation->setProjectId($perm->wsid);
                         $relation->setUserId($group->getId());
                         $relation->setCheckboxPermissions($perm->pc);
                         $relation->setRadioPermissions($perm->pr);
                         $relation->save();
                     }
                     //endif
                     //else if the user has no permissions at all, he is not a project_user. ProjectUser is not created
                 }
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:GroupController.class.php

示例6: update_permissions

 /**
  * Update company permissions
  *
  * @param void
  * @return null
  */
 function update_permissions()
 {
     if (!logged_user()->isAdministrator(owner_company())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $company = Companies::findById(get_id());
     if (!$company instanceof Company) {
         flash_error(lang('company dnx'));
         ajx_current("empty");
         return;
     }
     // if
     if ($company->isOwner()) {
         flash_error(lang('error owner company has all permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $projects = Projects::getAll(Projects::ORDER_BY_NAME);
     if (!is_array($projects) || !count($projects)) {
         flash_error(lang('no projects in db'));
         ajx_current("empty");
         return;
     }
     // if
     tpl_assign('projects', $projects);
     tpl_assign('company', $company);
     if (array_var($_POST, 'submitted') == 'submitted') {
         $counter = 0;
         $logged_user = logged_user();
         // reuse...
         ProjectCompanies::delete('company_id = ' . $company->getId());
         $wsids = array_var($_POST, 'ws_ids', '');
         $selected = Projects::findByCSVIds($wsids);
         $counter = 0;
         foreach ($selected as $ws) {
             $pc = new ProjectCompany();
             $pc->setCompanyId($company->getId());
             $pc->setProjectId($ws->getId());
             $pc->save();
             $counter++;
         }
         flash_success(lang('success update company permissions', $counter));
         ajx_current("back");
     }
     // if
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:56,代码来源:CompanyController.class.php

示例7: update_permissions

 /**
  * Show update permissions page
  *
  * @param void
  * @return null
  */
 function update_permissions()
 {
     $user = Users::findById(get_id());
     if (!$user instanceof User) {
         flash_error(lang('user dnx'));
         ajx_current("empty");
         return;
     }
     // if
     if (!$user->canUpdatePermissions(logged_user())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $company = $user->getCompany();
     if (!$company instanceof Company) {
         flash_error(lang('company dnx'));
         ajx_current("empty");
         return;
     }
     // if
     if (logged_user()->isAdministrator()) {
         $projects = Projects::getAll();
     } else {
         $projects = null;
     }
     $permissions = ProjectUsers::getNameTextArray();
     $redirect_to = array_var($_GET, 'redirect_to');
     if (trim($redirect_to) == '' || !is_valid_url($redirect_to)) {
         $redirect_to = $user->getCardUrl();
     }
     // if
     $user_data = array_var($_POST, 'user');
     if (!is_array($user_data)) {
         $user_data = array('can_edit_company_data' => $user->getCanEditCompanyData(), 'can_manage_security' => $user->getCanManageSecurity(), 'can_manage_workspaces' => $user->getCanManageWorkspaces(), 'can_manage_configuration' => $user->getCanManageConfiguration(), 'can_manage_contacts' => $user->getCanManageContacts(), 'can_manage_templates' => $user->getCanManageTemplates(), 'can_manage_reports' => $user->getCanManageReports(), 'can_manage_time' => $user->getCanManageTime(), 'can_add_mail_accounts' => $user->getCanAddMailAccounts());
         // array
         Hook::fire('add_user_permissions', $user, $user_data);
     }
     // if
     tpl_assign('user_data', $user_data);
     tpl_assign('user', $user);
     tpl_assign('company', $company);
     tpl_assign('projects', $projects);
     tpl_assign('permissions', $permissions);
     tpl_assign('redirect_to', $redirect_to);
     if (array_var($_POST, 'submitted') == 'submitted') {
         $user_data = array_var($_POST, 'user');
         if (!is_array($user_data)) {
             $user_data = array();
         }
         try {
             DB::beginWork();
             $permissionsString = array_var($_POST, 'permissions');
             if ($permissionsString && $permissionsString != '') {
                 $permissions = json_decode($permissionsString);
             }
             if (is_array($permissions) && count($permissions) > 0) {
                 //Clear old modified permissions
                 $ids = array();
                 foreach ($permissions as $perm) {
                     $ids[] = $perm->wsid;
                 }
                 ProjectUsers::clearByUser($user, implode(',', $ids));
                 //Add new permissions
                 //TODO - Make batch update of these permissions
                 foreach ($permissions as $perm) {
                     if (ProjectUser::hasAnyPermissions($perm->pr, $perm->pc)) {
                         $relation = new ProjectUser();
                         $relation->setProjectId($perm->wsid);
                         $relation->setUserId($user->getId());
                         $relation->setCheckboxPermissions($perm->pc, $user->isGuest() ? false : true);
                         $relation->setRadioPermissions($perm->pr, $user->isGuest() ? false : true);
                         $relation->save();
                     }
                     //endif
                     //else if the user has no permissions at all, he is not a project_user. ProjectUser is not created
                 }
                 //end foreach
             }
             // if
             $user->setCanEditCompanyData(false);
             $user->setCanManageSecurity(false);
             $user->setCanManageConfiguration(false);
             $user->setCanManageWorkspaces(false);
             $user->setCanManageContacts(false);
             $user->setCanManageTemplates(false);
             $user->setCanManageReports(false);
             $user->setCanManageTime(false);
             $user->setCanAddMailAccounts(false);
             $other_permissions = array();
             Hook::fire('add_user_permissions', $user, $other_permissions);
             foreach ($other_permissions as $k => $v) {
                 $user->setColumnValue($k, false);
//.........这里部分代码省略.........
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:101,代码来源:AccountController.class.php

示例8: projects

 /**
  * List all company projects
  *
  * @access public
  * @param void
  * @return null
  */
 function projects()
 {
     if (!logged_user()->isCompanyAdmin(owner_company())) {
         flash_error(lang('no access permissions'));
         ajx_current("empty");
         return;
     }
     // if
     $projects = null;
     if (can_manage_workspaces(logged_user())) {
         $padres = Projects::getAll('name', 'p2 = 0');
         //traigo todos los nivel 1
     } else {
         $padres = logged_user()->getProjects('name', 'p2 = 0');
     }
     foreach ($padres as $hijo) {
         $projects[] = $hijo;
         $aux = $hijo->getSortedChildren(logged_user());
         if (is_array($aux)) {
             foreach ($aux as $a) {
                 $projects[] = $a;
             }
         }
     }
     tpl_assign('projects', $projects);
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:33,代码来源:AdministrationController.class.php


注:本文中的Projects::getAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。