public function exportAction() { try { $fileContents = ""; $fileTitle = ""; $userId = $this->getParam("userId"); if ($userId > 0) { $user = User_Abstract::getById($userId); $userCollection[] = $user; $fileContents = PimPon_User_Export::doExport($userCollection); $fileTitle = $user->getName(); } else { if ($userId == 0) { $list = new User_List(); $list->setCondition("parentId = ?", intval($userId)); $list->load(); $userCollection = $list->getUsers(); $fileContents = PimPon_User_Export::doExport($userCollection); $fileTitle = 'all'; } } ob_end_clean(); header("Content-type: application/json"); header("Content-Disposition: attachment; filename=\"pimponexport.users." . $fileTitle . ".json\""); echo file_get_contents($fileContents); exit; } catch (Exception $ex) { Logger::err($ex->getMessage()); $this->_helper->json(array("success" => false, "data" => 'error'), false); } }
private static function getChilds(User $user) { $list = new User_List(); $list->setCondition("parentId = ?", $user->getId()); $list->load(); return $list->getUsers(); }
/** * legacy - not required anymore * * * @return void */ protected function cleanUp() { try { $class = Object_Class::getByName("unittest"); if ($class instanceof Object_Class) { $class->delete(); } } catch (Exception $e) { } try { $objectRoot = Object_Abstract::getById(1); if ($objectRoot and $objectRoot->hasChilds()) { $childs = $objectRoot->getChilds(); foreach ($childs as $child) { $child->delete(); } } } catch (Exception $e) { } try { $assetRoot = Asset::getById(1); if ($assetRoot and $assetRoot->hasChilds()) { $childs = $assetRoot->getChilds(); foreach ($childs as $child) { $child->delete(); } } } catch (Exception $e) { } try { $documentRoot = Asset::getById(1); if ($documentRoot and $documentRoot->hasChilds()) { $childs = $documentRoot->getChilds(); foreach ($childs as $child) { $child->delete(); } } } catch (Exception $e) { } try { $userList = new User_List(); $userList->setCondition("id > 1"); $users = $userList->load(); if (is_array($users) and count($users) > 0) { foreach ($users as $user) { $user->delete(); } } } catch (Exception $e) { } }
public function init() { if (!$this->_getParam("apikey")) { throw new Exception("API key missing"); } $userList = new User_List(); $userList->setCondition("password = ?", $this->_getParam("apikey")); $users = $userList->load(); if (!is_array($users) or count($users) !== 1) { throw new Exception("API key error"); } $user = $users[0]; Zend_Registry::set("pimcore_user", $user); parent::init(); }
public function getUserPermissionsAction() { $object = Object_Abstract::getById($this->_getParam("object")); $list = new User_List(); $list->load(); $users = $list->getUsers(); if (!empty($users)) { foreach ($users as $user) { $permission = $object->getUserPermissions($user); $permission->setUser($user); $permission->setUserId($user->getId()); $permission->setUsername($user->getUsername()); $permissions[] = $permission; } } $object->getUserPermissions($this->getUser()); if ($object->isAllowed("view")) { $this->_helper->json(array("permissions" => $permissions)); } $this->_helper->json(array("success" => false, "message" => "missing_permission")); }
public function configureOptions() { $list = new User_List(); $list->setOrder("asc"); $list->setOrderKey("username"); $users = $list->load(); $options = array(); if (is_array($users) and count($users) > 0) { foreach ($users as $user) { if ($user->getHasCredentials()) { $value = $user->getUsername(); $first = $user->getFirstname(); $last = $user->getLastname(); if (!empty($first) or !empty($last)) { $value .= " (" . $first . " " . $last . ")"; } $options[] = array("value" => $user->getId(), "key" => $value); } } } $this->setOptions($options); }
public function getUserPermissionsAction() { $document = Document::getById($this->_getParam("document")); $list = new User_List(); $list->load(); $users = $list->getUsers(); if (!empty($users)) { foreach ($users as $user) { $permission = $document->getUserPermissions($user); $permission->setUser($user); $permission->setUserId($user->getId()); $permission->setUsername($user->getUsername()); $permissions[] = $permission; Logger::debug($permission->getUser()->getUsername()); } } $document->getPermissionsForUser($this->getUser()); if ($document->isAllowed("view")) { $this->_helper->json(array("permissions" => $permissions)); } $this->_helper->json(array("success" => false, "message" => "missing_permission")); }
public function getSystemAction() { if ($this->getUser()->isAllowed("system_settings")) { $values = Pimcore_Config::getSystemConfig(); if (($handle = fopen(PIMCORE_PATH . "/config/timezones.csv", "r")) !== FALSE) { while (($rowData = fgetcsv($handle, 10000, ",", '"')) !== false) { $timezones[] = $rowData[0]; } fclose($handle); } $languages = Zend_Locale::getTranslationList('language'); asort($languages); $languageOptions = array(); $validLanguages = array(); foreach ($languages as $short => $translation) { if (strlen($short) == 2 or strlen($short) == 5 and strpos($short, "_") == 2) { $languageOptions[] = array("language" => $short, "display" => $translation . " ({$short})"); $validLanguages[] = $short; } } $valueArray = $values->toArray(); $valueArray['general']['validLanguage'] = explode(",", $valueArray['general']['validLanguages']); //for "wrong" legacy values if (is_array($valueArray['general']['validLanguage'])) { foreach ($valueArray['general']['validLanguage'] as $existingValue) { if (!in_array($existingValue, $validLanguages)) { $languageOptions[] = array("language" => $existingValue, "display" => $existingValue); } } } //cdn hosts - add as array if (!empty($valueArray['outputfilters']['cdnhostnames'])) { $hostNames = explode(",", $valueArray['outputfilters']['cdnhostnames']); if (is_array($hostNames)) { foreach ($hostNames as $host) { $valueArray['outputfilters']['cdnhostnamesArray'][] = array("value" => $host); } } } //cdn patterns - add as array if (!empty($valueArray['outputfilters']['cdnpatterns'])) { $patterns = explode(",", $valueArray['outputfilters']['cdnpatterns']); if (is_array($patterns)) { foreach ($patterns as $pattern) { $valueArray['outputfilters']['cdnpatternsArray'][] = array("value" => $pattern); } } } //debug email addresses - add as array ckogler if (!empty($valueArray['email']['debug']['emailaddresses'])) { $emailAddresses = explode(",", $valueArray['email']['debug']['emailaddresses']); if (is_array($emailAddresses)) { foreach ($emailAddresses as $emailAddress) { $valueArray['email']['debug']['emaildebugaddressesArray'][] = array("value" => $emailAddress); } } } else { $valueArray['email']['debug']['emaildebugaddressesArray'][] = array("value" => ''); } //cache exclude patterns - add as array if (!empty($valueArray['cache']['excludePatterns'])) { $patterns = explode(",", $valueArray['cache']['excludePatterns']); if (is_array($patterns)) { foreach ($patterns as $pattern) { $valueArray['cache']['excludePatternsArray'][] = array("value" => $pattern); } } } //remove password from values sent to frontend $valueArray['database']["params"]['password'] = "******"; //admin users as array $adminUsers = array(); $userList = new User_List(); $userList->setCondition("admin = 1 and email is not null and email != ''"); $users = $userList->load(); if (is_array($users)) { foreach ($users as $user) { $adminUsers[] = array("id" => $user->getId(), "username" => $user->getUsername()); } } $adminUsers[] = array("id" => "", "username" => "-"); $response = array("values" => $valueArray, "adminUsers" => $adminUsers, "config" => array("timezones" => $timezones, "languages" => $languageOptions, "client_ip" => Pimcore_Tool::getClientIp())); $this->_helper->json($response); } else { if ($this->getUser() != null) { Logger::err("user [" . $this->getUser()->getId() . "] attempted to view system settings, but has no permission to do so."); } else { Logger::err("attempt to view system settings, but no user in session."); } } $this->_helper->json(false); }
public function getAllUsersAction() { $list = new User_List(); $list->load(); $users = $list->getUsers(); if (!empty($users)) { foreach ($users as $user) { $userList[] = $user->getIterator(); } } $this->_helper->json(array("users" => $userList)); }
public function getAllUsersAction() { $list = new User_List(); $list->load(); $users = $list->getUsers(); if (!empty($users)) { foreach ($users as $user) { if ($user instanceof User) { $user->password = null; $userList[] = $user; } } } $this->_helper->json(array("users" => $userList)); }