<script type="text/javascript">
//<![CDATA[
- function setFileType(newType) {
- switch (newType) {
- case 'csv':
- showOptions('separatorDiv', 'textSeparatorDiv');
- break;
- case 'xml':
- hideOptions('separatorDiv', 'textSeparatorDiv');
- break;
- }
- }
- onloadEvents.push(function() { setFileType('{@$fileType}'); });
+ $(function() {
+ new WCF.ACP.Options();
+ });
//]]>
</script>
</header>
<form method="post" action="index.php?form=UserEmailAddressExport">
-
<div class="border content">
<fieldset>
<legend>{lang}wcf.acp.user.exportEmailAddress.markedUsers{/lang}</legend>
<dl>
<dd><!-- ToDo: Definition List -->
- <li><label><input type="radio" onclick="if (IS_SAFARI) setFileType('csv')" onfocus="setFileType('csv')" name="fileType" value="csv" {if $fileType == 'csv'}checked="checked" {/if}/> {lang}wcf.acp.user.exportEmailAddress.fileType.csv{/lang}</label></li>
- <li><label><input type="radio" onclick="if (IS_SAFARI) setFileType('xml')" onfocus="setFileType('xml')" name="fileType" value="xml" {if $fileType == 'xml'}checked="checked" {/if}/> {lang}wcf.acp.user.exportEmailAddress.fileType.xml{/lang}</label></li>
+ <li><label><input type="radio" class="enablesOptions" data-disableOptions="[ ]" data-enableOptions="[ 'separatorDiv', 'textSeparatorDiv' ]" name="fileType" value="csv" {if $fileType == 'csv'}checked="checked" {/if}/> {lang}wcf.acp.user.exportEmailAddress.fileType.csv{/lang}</label></li>
+ <li><label><input type="radio" class="enablesOptions" data-disableOptions="[ 'separatorDiv', 'textSeparatorDiv' ]" data-enableOptions="[ ]" name="fileType" value="xml" {if $fileType == 'xml'}checked="checked" {/if}/> {lang}wcf.acp.user.exportEmailAddress.fileType.xml{/lang}</label></li>
</dd>
</dl>
</fieldset>
<input type="reset" value="{lang}wcf.global.button.reset{/lang}" accesskey="r" />
<input type="submit" value="{lang}wcf.global.button.submit{/lang}" accesskey="s" />
{@SID_INPUT_TAG}
- <input type="hidden" name="userIDs" value="{@$userIDs}" />
</div>
</form>
<?php
namespace wcf\acp\form;
use wcf\data\user\User;
+use wcf\system\clipboard\ClipboardHandler;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\IllegalLinkException;
use wcf\system\WCF;
public $textSeparator = '"';
public $users = array();
+ /**
+ * clipboard item type id
+ * @var integer
+ */
+ protected $typeID = null;
+
+ /**
+ * @see wcf\page\IPage::readParameters()
+ */
+ public function readParameters() {
+ parent::readParameters();
+
+ // get type id
+ $this->typeID = ClipboardHandler::getInstance()->getTypeID('com.woltlab.wcf.user');
+ if ($this->typeID === null) {
+ throw new SystemException("clipboard item type 'com.woltlab.wcf.user' is unknown.");
+ }
+
+ // get user ids
+ $users = ClipboardHandler::getInstance()->getMarkedItems($this->typeID);
+ if (!isset($users['com.woltlab.wcf.user']) || empty($users['com.woltlab.wcf.user'])) throw new IllegalLinkException();
+
+ // load users
+ $this->userIDs = array_keys($users['com.woltlab.wcf.user']);
+ $this->users = $users['com.woltlab.wcf.user'];
+ }
+
/**
* @see wcf\form\IForm::readFormParameters()
*/
parent::readFormParameters();
if (isset($_POST['fileType']) && $_POST['fileType'] == 'xml') $this->fileType = $_POST['fileType'];
- if (isset($_POST['userIDs'])) $this->userIDs = ArrayUtil::toIntegerArray(explode(',', $_POST['userIDs']));
if (isset($_POST['separator'])) $this->separator = $_POST['separator'];
if (isset($_POST['textSeparator'])) $this->textSeparator = $_POST['textSeparator'];
}
- /**
- * @see wcf\form\IForm::validate()
- */
- public function validate() {
- parent::validate();
-
- if (empty($this->userIDs)) throw new IllegalLinkException();
- }
-
/**
* @see wcf\form\IForm::save()
*/
$statement->execute($conditions->getParameters());
$i = 0;
- while ($row = WCF::getDB()->fetchArray($result)) {
+ while ($row = $statement->fetchArray()) {
if ($this->fileType == 'xml') echo "<address><![CDATA[".StringUtil::escapeCDATA($row['email'])."]]></address>\n";
else echo $this->textSeparator . $row['email'] . $this->textSeparator . ($i < $count['count'] ? $this->separator : '');
$i++;
echo "</addresses>";
}
- // TODO: Implement unmarkAll()
- //UserEditor::unmarkAll();
$this->saved();
- exit;
- }
-
- /**
- * @see wcf\page\IPage::readData()
- */
- public function readData() {
- parent::readData();
- if (!count($_POST)) {
- // get marked user ids
- $markedUsers = WCF::getSession()->getVar('markedUsers');
- if (is_array($markedUsers)) $this->userIDs = implode(',', $markedUsers);
- if (empty($this->userIDs)) throw new IllegalLinkException();
- }
+ // remove items
+ ClipboardHandler::getInstance()->removeItems($this->typeID);
- $this->users = User::getUsers($this->userIDs);
+ exit;
}
/**
WCF::getTPL()->assign(array(
'users' => $this->users,
- 'userIDs' => $this->userIDs,
'separator' => $this->separator,
'textSeparator' => $this->textSeparator,
'fileType' => $this->fileType