本文整理汇总了PHP中Projects::findAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Projects::findAll方法的具体用法?PHP Projects::findAll怎么用?PHP Projects::findAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Projects
的用法示例。
在下文中一共展示了Projects::findAll方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterAction
/**
* Filter action
*
* This action is called through ajax on filter change like tags & order
*
* @access public
* @return void
*
* @author Ole Aass <ole.aass@gmx.com>
*/
public function filterAction()
{
if ($this->request->isPost() && $this->request->isAjax()) {
$tags = $this->request->getPost('tags');
$currentPage = $this->request->getPost('page', 'int');
$counter = $this->request->getPost('counter', 'int');
$projects = new Projects();
if (empty($tags)) {
$list = $projects->findAll();
} else {
$tags = array_keys($tags);
$list = $projects->findByTags($tags);
}
$page = $projects->paginate($list, $currentPage, $counter);
$page->counter = $counter;
$this->view->setVar('page', $page);
$this->view->partial('index/projects');
}
}
示例2: getCompletedProjects
/**
* Return all completed projects
*
* @param void
* @return null
*/
function getCompletedProjects()
{
if (is_null($this->completed_projects)) {
if ($this->isOwner()) {
$this->completed_projects = Projects::findAll(array('conditions' => '`completed_on` > ' . DB::escape(EMPTY_DATETIME)));
// findAll
} else {
$this->completed_projects = ProjectCompanies::getProjectsByCompany($this, '`completed_on` > ' . DB::escape(EMPTY_DATETIME));
}
// if
}
// if
return $this->completed_projects;
}
示例3: getProjects
/**
* Return all projects this user can access
*
* @param void
* @return array
*/
function getProjects()
{
if ($this->projects === false) {
if ($this->isAdministrator() || $this->isProjectManager()) {
$this->projects = Projects::findAll();
} else {
$this->projects = Projects::findByUser($this);
}
// if
}
// if
return $this->projects;
}
示例4: getAll
/**
* Return all projects
*
* @param void
* @return array
*/
static function getAll($order_by = self::ORDER_BY_NAME)
{
return Projects::findAll(array('order' => $order_by));
// findAll
}
示例5: getSubWorkspacesSorted
/**
* returns first level child workspaces sorted by name
* @param $active
* @param $user
* @param $allLevels
* @return unknown_type
*/
function getSubWorkspacesSorted($active = false, $user = null)
{
$allLevels = false;
$key = ($active ? "active" : "closed") . "_" . ($user instanceof User ? $user->getId() : 0) . "_" . ($allLevels ? 'all' : 'single');
if (!array_var($this->subWScache, $key)) {
$depth = $this->getDepth();
$conditions = array("id != " . $this->getId() . " AND `p" . $depth . "` = ?", $this->getId());
if (!$allLevels && $depth < 9) {
$conditions[0] .= ' AND `p' . ($depth + 2) . '` = 0 ';
}
if ($active) {
$conditions[0] .= ' AND `completed_on` = ? ';
$conditions[] = EMPTY_DATETIME;
}
if ($user instanceof User && !can_manage_workspaces($user)) {
$pu_tbl = ProjectUsers::instance()->getTableName(true);
$conditions[0] .= " AND `id` IN (SELECT `project_id` FROM {$pu_tbl} WHERE `user_id` = ?)";
$conditions[] = $user->getId();
}
$this->subWScache[$key] = Projects::findAll(array('conditions' => $conditions, 'order' => 'name'));
}
return $this->subWScache[$key];
}
示例6: getSubprojects
/**
* Return subprojects
*
* @access public
* @param void
* @return array
*/
function getSubprojects()
{
if (logged_user()->isMemberOfOwnerCompany()) {
return $this->getAllSubprojects();
}
if (is_null($this->subprojects)) {
$this->subprojects = Projects::findAll(array('conditions' => array('`parent_id` = ?', $this->getId()), 'order' => 'name'));
// findAll
}
// if
return $this->subprojects;
}
示例7: getProjectFromPath
function getProjectFromPath($path, User $user = null)
{
$parents = explode("/", $path);
$length = count($parents);
// Clean up the array for empty places
while ($parents[0] == "" && $length > 0) {
array_shift($parents);
$length = count($parents);
}
while ($length > 0 && $parents[$length - 1] == "") {
array_pop($parents);
$length = count($parents);
}
if ($length == 0) {
// ERROR
return null;
} else {
if ($length == 1) {
// Level one workspace
$name = $parents[0];
// Loof for top level project
$proj = Projects::findOne(array('conditions' => array('p2 = ? and `name` = ?', 0, $name)));
if (!$proj) {
if (!$user instanceof User) {
// Not checking permissions and project is not top level, so the path is invalid
return null;
} else {
// User might not have permissions over workspace parent and other ancestors.
// This means current user might see workspace $proj in the root while it is really not top level.
$projs = Projects::findAll(array('conditions' => array('`name` = ?', $name)));
if (!$projs) {
//No project by that name
return null;
} else {
// Iterate through all projects with that name
foreach ($projs as $ws) {
// If $user has no permissions over $ws, it is not what we are looking for
if ($user->isProjectUser($ws)) {
$is_candidate_project = true;
// Iterate through all ancestors to check permissions
foreach ($ws->getParentIds(false) as $ancestor_id) {
$ancestor = Projects::findById($ancestor_id);
if ($user->isProjectUser($ancestor)) {
// If user has permission over an ancestor, path is wrong
$is_candidate_project = false;
break;
}
//if
}
//foreach $ancestor
if ($is_candidate_project) {
// No permissions over ancestors
return $ws;
}
// if
}
// if
}
// foreach $project
// No project by that name should appear in the root
return null;
}
}
}
if ($user && (!$user instanceof User || !$user->isProjectUser($proj))) {
return null;
} else {
return $proj;
}
} else {
$currentName = array_pop($parents);
$length = count($parents);
$new_path = implode("/", $parents);
$parent = Projects::getProjectFromPath($new_path, $user);
if ($parent instanceof Project) {
$conditions = 'p' . $length . ' = ? and p' . ($length + 2) . ' = ? and `name` = ?';
$proj = Projects::findOne(array('conditions' => array($conditions, $parent->getId(), 0, $currentName)));
if ($user) {
//we are checking permissions
if ($proj && $user->isProjectUser($proj)) {
// User has permissions over workspace, found!
return $proj;
} else {
// child does not exist, or it exists and user has no permissions
// still have to check if there exists a descendant (child of child^n) with that name
// If we have permissions over that descendant and have no permissions for WS between, we found a valid WS
$conditions = 'p' . $length . ' = ? and `name` = ?';
$projs = Projects::findAll(array('conditions' => array($conditions, $parent->getId(), $currentName)));
if ($projs) {
//Iterate through all projects with that name
foreach ($projs as $ws) {
if ($user->isProjectUser($ws)) {
$is_candidate_project = true;
// Iterate through all ancestors to check permissions
$parent_depth = $parent->getDepth();
$ws_depth = $ws->getDepth(false);
$parent_ids = $ws->getParentIds(false);
// Iterate through all descendants of $parent and ancestors of $ws
for ($i = $parent_depth; $i < $ws_depth; $i++) {
$ancestor_id = $parent_ids[$i];
//.........这里部分代码省略.........