/** * Get policy. * * @param UserDao $user * @param FolderDao $folder * @return false|FolderpolicyuserDao * @throws Zend_Exception */ public function getPolicy($user, $folder) { if (!$user instanceof UserDao) { throw new Zend_Exception('Should be a user.'); } if (!$folder instanceof FolderDao) { throw new Zend_Exception('Should be a folder.'); } return $this->initDao('Folderpolicyuser', $this->database->fetchRow($this->database->select()->where('folder_id = ?', $folder->getKey())->where('user_id = ?', $user->getKey()))); }
/** * Get policy. * * @param GroupDao $group * @param FolderDao $folder * @return false|FolderpolicygroupDao * @throws Zend_Exception */ public function getPolicy($group, $folder) { if (!$group instanceof GroupDao) { throw new Zend_Exception('Should be a group.'); } if (!$folder instanceof FolderDao) { throw new Zend_Exception('Should be a folder.'); } return $this->initDao('Folderpolicygroup', $this->database->fetchRow($this->database->select()->where('folder_id = ?', $folder->getKey())->where('group_id = ?', $group->getKey()))); }
/** * Set the folder of the scalar result. * * @param Validation_ScalarResultDao $scalarResult target scalar result * @param FolderDao $folder target folder * @throws Zend_Exception */ public function setFolder($scalarResult, $folder) { if (!$scalarResult instanceof Validation_ScalarResultDao) { throw new Zend_Exception('Should be a scalar result.'); } if (!$folder instanceof FolderDao) { throw new Zend_Exception('Should be a folder.'); } $scalarResult->setFolderId($folder->getKey()); parent::save($scalarResult); }
/** * Get a single set of scores for a dashboard. * * @param Validation_DashboardDao $dashboard target dashboard * @param FolderDao $folder folder that corresponds to the results * @return array array where the keys are item ids and the values are scores * @throws Zend_Exception */ public function getScores($dashboard, $folder) { if (!$dashboard instanceof Validation_DashboardDao) { throw new Zend_Exception('Should be a dashboard.'); } if (!$folder instanceof FolderDao) { throw new Zend_Exception('Should be a folder.'); } $sql = $this->database->select()->setIntegrityCheck(false)->from(array('d' => 'validation_dashboard'))->join(array('j' => 'validation_dashboard2scalarresult'), 'd.dashboard_id = j.dashboard_id')->join(array('r' => 'validation_scalarresult'), 'j.scalarresult_id = r.scalarresult_id')->where('r.folder_id = ' . $folder->getKey())->where('d.dashboard_id = ' . $dashboard->getKey()); $rowset = $this->database->fetchAll($sql); $results = array(); foreach ($rowset as $row) { $results[$row['item_id']] = $row['value']; } return $results; }
/** * Check whether an item exists with the given name in the given folder. * If it does, returns the existing item dao. Otherwise returns false. * * @param string $name * @param FolderDao $folder * @return false|ItemDao * @throws Zend_Exception */ public function existsInFolder($name, $folder) { $sql = $this->database->select()->setIntegrityCheck(false)->from(array('i' => 'item'))->join(array('i2f' => 'item2folder'), 'i.item_id = i2f.item_id AND ' . $this->database->getDB()->quoteInto('i2f.folder_id = ?', $folder->getKey()), array())->where('i.name = ?', $name)->limit(1); return $this->initDao('Item', $this->database->fetchRow($sql)); }