public function getPing($r) { $pinged = Dase_DBO_DaseUser::get($this->db, $r->get('eid')); if ($pinged) { $r->renderResponse($pinged->eid); } else { $r->renderError(404, 'no such user'); } }
public function insert($db, $r) { $db_user = Dase_DBO_DaseUser::get($db, $this->getEid()); if (!$db_user) { $db_user = new Dase_DBO_DaseUser($db); $db_user->name = $this->getTitle(); $db_user->eid = strtolower($this->getEid()); $db_user->insert(); } return $db_user; }
public function postToUsers($r) { $content_type = $r->getContentType(); if ('application/atom+xml;type=entry' == $content_type || 'application/atom+xml' == $content_type) { $raw_input = $r->getBody(); $client_md5 = $r->getHeader('Content-MD5'); //if Content-MD5 header isn't set, we just won't check if ($client_md5 && md5($raw_input) != $client_md5) { $r->renderError(412, 'md5 does not match'); } try { $entry = Dase_Atom_Entry::load($raw_input); } catch (Exception $e) { Dase_Log::debug(LOG_FILE, 'users handler error: ' . $e->getMessage()); $r->renderError(400, 'bad xml'); } if ('user' != $entry->entrytype) { $r->renderError(400, 'must be a user entry'); } try { $user = $entry->insert($this->db, $r); header("HTTP/1.1 201 Created"); header("Content-Type: application/atom+xml;type=entry;charset='utf-8'"); header("Location: " . $user->getUrl($r->app_root) . '.atom?type=entry'); echo $user->asAtomEntry($r->app_root); exit; } catch (Dase_Exception $e) { $r->renderError(409, $e->getMessage()); } } elseif ('application/x-www-form-urlencoded' == $content_type) { //in honor of http://www.tbray.org/ongoing/When/200x/2009/01/29/Name-Value-Pairs $eid = $r->get('eid'); $name = $r->get('name'); $user = Dase_DBO_DaseUser::get($this->db, $eid); if (!$user) { $user = new Dase_DBO_DaseUser($this->db); $user->name = $name; $user->eid = strtolower($eid); $user->updated = date(DATE_ATOM); $user->created = date(DATE_ATOM); $user->insert(); } header("HTTP/1.1 201 Created"); header("Content-Type: application/atom+xml;type=entry;charset='utf-8'"); header("Location: " . $user->getUrl($r->app_root) . '.atom?type=entry'); echo $user->asAtomEntry($r->app_root); exit; } else { $r->renderError(415, 'cannot accept ' . $content_type); } }
public function getEidauth($r) { $user = Dase_DBO_DaseUser::get($this->db, $r->get('eid')); if ($user) { $r->renderResponse($user->getHttpPassword($r->getAuthToken())); } else { //allow BB to create user if ('blackboard' == $r->get('serviceuser')) { $u = new Dase_DBO_DaseUser($db); $u->eid = strtolower($r->get('eid')); //name will simply be eid $u->name = $r->get('eid'); $u->insert(); $r->renderResponse($u->getHttpPassword($r->getAuthToken())); } $r->renderError(404); } }
public function postToManagers($r) { if (!$r->has('auth_level')) { $params['msg'] = 'You must select an Authorization Level'; $r->renderRedirect('manage/' . $this->collection->ascii_id . '/managers', $params); } if (!$r->has('dase_user_eid')) { $params['msg'] = 'You must enter an EID'; $r->renderRedirect('manage/' . $this->collection->ascii_id . '/managers', $params); } $eid = strtolower($r->get('dase_user_eid')); if (!Dase_DBO_DaseUser::get($this->db, $eid)) { $params['msg'] = 'User ' . $eid . ' does not yet exist'; $r->renderRedirect('manage/' . $this->collection->ascii_id . '/managers', $params); } $mgr = new Dase_DBO_CollectionManager($this->db); $mgr->dase_user_eid = $eid; $mgr->auth_level = $r->get('auth_level'); $mgr->collection_ascii_id = $this->collection->ascii_id; $mgr->created = date(DATE_ATOM); $mgr->created_by_eid = $this->user->eid; try { $mgr->insert(); $params['msg'] = 'success!'; } catch (Exception $e) { $params['msg'] = 'there was a problem:' . $e->getMessage(); } $r->renderRedirect('manage/' . $this->collection->ascii_id . '/managers', $params); }
public function getUser($r) { $user = Dase_DBO_DaseUser::get($this->db, $r->get('eid')); $tpl = new Dase_Template($r); $tpl->assign('user', $user); $tpl->assign('htpass', $user->getHttpPassword($r->getAuthToken())); $tpl->assign('tags', $user->getTags()); $tpl->assign('collections', $user->getCollections($r->app_root)); $r->renderResponse($tpl->fetch('admin/user.tpl')); }