function getContent() { $this->adminGatekeeper(); // Admins only $users = User::get(array(), array(), 99999, 0); // TODO: make this more complete / efficient $remoteusers = RemoteUser::get(array(), array(), 99999, 0); $users = array_merge($users, $remoteusers); $t = \Idno\Core\site()->template(); $t->body = $t->__(array('users' => $users))->draw('admin/users'); $t->title = 'User Management'; $t->drawPage(); }
function postContent() { $this->createGatekeeper(); $user = \Idno\Core\site()->session()->currentUser(); if ($uuid = $this->getInput('uuid')) { if (!($new_user = \Idno\Entities\User::getByUUID($uuid)) && !($new_user = \Idno\Entities\User::getByProfileURL($uuid)) && !($new_user = \Idno\Entities\RemoteUser::getByUUID($uuid)) && !($new_user = \Idno\Entities\RemoteUser::getByProfileURL($uuid))) { // No user found, so create it if it's remote if (!\Idno\Entities\User::isLocalUUID($uuid)) { \Idno\Core\site()->logging->log("Creating new remote user", LOGLEVEL_DEBUG); $new_user = new \Idno\Entities\RemoteUser(); // Populate with data $new_user->setTitle($this->getInput('name')); $new_user->setHandle($this->getInput('nickname')); $new_user->email = $this->getInput('email'); $new_user->setUrl($uuid); if (!$new_user->save()) { throw new \Exception("There was a problem saving the new remote user."); } } } else { \Idno\Core\site()->logging->log("New user found as " . $new_user->uuid, LOGLEVEL_DEBUG); } if ($new_user) { \Idno\Core\site()->logging->log("Trying a follow", LOGLEVEL_DEBUG); if ($user->addFollowing($new_user)) { \Idno\Core\site()->logging->log("User added to following", LOGLEVEL_DEBUG); if ($user->save()) { \Idno\Core\site()->logging->log("Following saved", LOGLEVEL_DEBUG); \Idno\Core\site()->session()->addMessage("You are now following " . $new_user->getTitle()); } } else { \Idno\Core\site()->logging->log('Could not follow user for some reason (probably already following)', LOGLEVEL_DEBUG); } } else { throw new \Exception('Sorry, that user doesn\'t exist!'); } } else { throw new \Exception("No UUID, please try that again!"); } }
function postContent() { $this->createGatekeeper(); $user = \Idno\Core\site()->session()->currentUser(); if ($uuid = $this->getInput('uuid')) { if (!($new_user = \Idno\Entities\User::getByUUID($uuid)) && !($new_user = \Idno\Entities\User::getByProfileURL($uuid)) && !($new_user = \Idno\Entities\RemoteUser::getByUUID($uuid)) && !($new_user = \Idno\Entities\RemoteUser::getByProfileURL($uuid))) { // No user found, so create it if it's remote if (!\Idno\Entities\User::isLocalUUID($uuid)) { \Idno\Core\site()->logging->log("Creating new remote user", LOGLEVEL_DEBUG); $new_user = new \Idno\Entities\RemoteUser(); // Populate with data $new_user->setTitle($this->getInput('name')); $new_user->setHandle($this->getInput('nickname')); $new_user->email = $this->getInput('email'); $new_user->setUrl($uuid); // TODO: Get a profile URL - get it from passed photo variable, upload to local and treat as avatar. if (!$new_user->save()) { throw new \Exception("There was a problem saving the new remote user."); } } } else { \Idno\Core\site()->logging->log("New user found as " . $new_user->uuid, LOGLEVEL_DEBUG); } if ($new_user) { \Idno\Core\site()->logging->log("Trying a follow", LOGLEVEL_DEBUG); if ($user->addFollowing($new_user)) { \Idno\Core\site()->logging->log("User added to following", LOGLEVEL_DEBUG); if ($user->save()) { \Idno\Core\site()->logging->log("Following saved", LOGLEVEL_DEBUG); // Ok, we've saved the new user, now, lets subscribe to their feeds if ($feed = \Idno\Core\site()->reader()->getFeedObject($new_user->getURL())) { \Idno\Core\site()->session()->addMessage("You are now following " . $new_user->getTitle() . ', would you like to subscribe to their feed?'); $this->forward(\Idno\Core\site()->config()->getURL() . 'following/confirm/?feed=' . urlencode($new_user->getURL())); } \Idno\Core\site()->session()->addMessage("You are now following " . $new_user->getTitle()); } } else { \Idno\Core\site()->logging->log('Could not follow user for some reason (probably already following)', LOGLEVEL_DEBUG); \Idno\Core\site()->session()->addErrorMessage('You\'re already following ' . $this->getInput('name')); } } else { throw new \Exception('Sorry, that user doesn\'t exist!'); } } else { throw new \Exception("No UUID, please try that again!"); } }