/** * recreate / update view definitions given a well-structured * directory on disk that contains map and reduce javascript files * @param string $viewsPath */ public static function loadViews($viewsPath) { $viewData = array(); $files = new DirectoryIterator($viewsPath); foreach ($files as $file) { if ($file->isFile()) { $parts = explode('.', $file->getFilename()); $view = $parts[1]; $designDoc = $parts[0]; $content = file_get_contents($file->getPathName()); $contentType = $parts[2]; $viewData[$designDoc][$view][$contentType] = $content; } } foreach ($viewData as $designDoc => $views) { $dd = new Modela_Doc_Design(); $dd->_id = $designDoc; foreach ($views as $viewName => $functions) { $v = new Modela_View(); $v->map = $functions['map']; $v->reduce = $functions['reduce']; $dd->addView($viewName, $v); } $docExists = Modela_Doc::get($dd->_id); if ($docExists) { $dd->_rev = $docExists->_rev; } $dd->save(); } }
public function authenticate() { $user = Modela_Doc::findOne($this->_designDoc, $this->_view, array("key" => $this->_identityValue), true); if ($user) { if ($this->_passwordIsValid($user)) { $result = new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $user, array()); } else { $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, null); } } else { $result = new Zend_Auth_Result(Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID, null); } return $result; }