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(); }
public function treeGetChildsByIdAction() { $list = new User_List(); $list->setCondition("parentId = ?", intval($this->_getParam("node"))); $list->load(); $users = array(); if (is_array($list->getUsers())) { foreach ($list->getUsers() as $user) { $users[] = $this->getTreeNodeConfig($user); } } $this->_helper->json($users); }
/** * 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 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); }