public function loadModel($id)
 {
     $model = Command::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('mc', 'The requested page does not exist.'));
     }
     return $model;
 }
Esempio n. 2
0
?>

<?php 
if (!$edit) {
    $attribs = array('name', 'level', 'prereq', 'chat', 'response', 'run');
} else {
    $form = $this->beginWidget('CActiveForm', array('id' => 'command-form', 'enableAjaxValidation' => false));
    $userRoles = array_combine(User::$roleLevels, User::getRoleLabels());
    $userRoles[0] = Yii::t('mc', 'None');
    if (Yii::app()->user->isSuperuser()) {
        $attribs[] = array('label' => $form->labelEx($model, 'server_id'), 'type' => 'raw', 'value' => $form->textField($model, 'server_id') . ' ' . $form->error($model, 'server_id'), 'hint' => Yii::t('mc', 'The server ID, use 0 for "Global"'));
        $attribs[] = array('label' => $form->labelEx($model, 'hidden'), 'type' => 'raw', 'value' => $form->checkBox($model, 'hidden') . ' ' . $form->error($model, 'hidden'), 'hint' => Yii::t('mc', 'Only show this command to other superusers'));
    }
    $attribs[] = array('label' => $form->labelEx($model, 'name'), 'type' => 'raw', 'value' => $form->textField($model, 'name') . ' ' . $form->error($model, 'name'));
    $attribs[] = array('label' => $form->labelEx($model, 'level'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'level', $userRoles) . ' ' . $form->error($model, 'level'));
    $attribs[] = array('label' => $form->labelEx($model, 'prereq'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'prereq', array('0' => 'None') + CHtml::listData(Command::model()->findAllByAttributes(array('server_id' => $sv)), 'id', 'name')) . ' ' . $form->error($model, 'prereq'), 'hint' => Yii::t('mc', 'This command has to be run before'));
    $attribs[] = array('label' => $form->labelEx($model, 'chat'), 'type' => 'raw', 'value' => $form->textField($model, 'chat') . ' ' . $form->error($model, 'chat'), 'hint' => Yii::t('mc', 'The users message has to begin with this'));
    $attribs[] = array('label' => $form->labelEx($model, 'response'), 'type' => 'raw', 'value' => $form->textField($model, 'response') . ' ' . $form->error($model, 'response'), 'hint' => Yii::t('mc', 'Whispered to the player'));
    $attribs[] = array('label' => $form->labelEx($model, 'run'), 'type' => 'raw', 'value' => $form->textField($model, 'run') . ' ' . $form->error($model, 'run'), 'hint' => Yii::t('mc', 'Run this Minecraft command (<a href="http://www.multicraft.org/site/page?view=usage#commands" target="_blank">see usage</a> for arguments and multiple commands)'));
    $attribs[] = array('label' => '', 'type' => 'raw', 'value' => CHtml::submitButton($model->isNewRecord ? Yii::t('mc', 'Create') : Yii::t('mc', 'Save')));
}
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => $attribs));
if ($edit) {
    $this->endWidget();
}
if (Yii::app()->user->hasFlash('command')) {
    ?>
<div class="flash-success">
    <?php 
    echo Yii::app()->user->getFlash('command');
    ?>
Esempio n. 3
0
    <li id="command-tab" class="selected"><?php 
echo Yii::t('Job', 'Command Mode');
?>
</li><li id="test-case-tab"><?php 
echo Yii::t('Job', 'Test Case Mode');
?>
</li>
</ul>
<div id="run-fields">
    <!-- command fields start -->
    <div id="command-fields">
        <div class="row-fluid">
            <?php 
echo CHtml::activeLabel($command, 'name', array('class' => 'span2'));
$listData = array('' => '', -1 => '[' . Yii::t('Command', 'New Command') . ']');
$listData += Command::model()->getCommandOptions();
$this->widget('application.extensions.combobox.InputComboBox', array('model' => $job, 'attribute' => 'command_id', 'data' => $listData, 'options' => array('onSelect' => '
                        if(-1 == $("#Job_command_id").val()) {
                            item.value = ""
                        }
                        jobForm.setCommand(item.value, $("#Job_command_id").val())
                    ', 'allowText' => true, 'showStyle' => false, 'disableAutocomplete' => true), 'htmlOptions' => array('class' => 'focus span10', 'placeholder' => Yii::t('Job', 'Name Tip'))));
// set hidden data.
echo CHtml::activeHiddenField($job, 'id');
echo CHtml::activeHiddenField($job, 'stage_num');
echo CHtml::activeHiddenField($command, 'name');
echo CHtml::activeHiddenField($command, 'mode');
echo CHtml::hiddenField('Job[type]', $job->type, array("id" => "Job_type"));
?>
        </div>
        <div class="row-fluid" style="margin-bottom: 0">
 /**
  ** Command Functions
  **/
 public function actionListCommands($server_id)
 {
     $this->check($server_id);
     $cmds = Command::model()->findAllByAttributes(array('server_id' => (int) $server_id));
     $this->ls('Command', $cmds);
 }
Esempio n. 5
0
 public function createDefaultCommands()
 {
     $cmds = array(array(Yii::t('mc', 'Message of the Day'), 10, 'motd', ''), array(Yii::t('mc', 'Give Item'), 30, 'give', 'builtin:give'), array(Yii::t('mc', 'Teleport To'), 30, 'tp', 'builtin:tp'), array(Yii::t('mc', 'Summon Player'), 30, 'summon', 'builtin:summon'), array(Yii::t('mc', 'Admin Say'), 30, 'asay', 'builtin:asay'), array(Yii::t('mc', 'Save World'), 30, 'save', 'builtin:save'), array(Yii::t('mc', 'Time'), 10, 'time', 'builtin:time'), array(Yii::t('mc', 'Date'), 10, 'date', 'builtin:date'), array(Yii::t('mc', 'Player List'), 10, 'list', 'builtin:list'), array(Yii::t('mc', 'Say Player List'), 30, 'saylist', 'builtin:saylist'), array(Yii::t('mc', 'Create Backup'), 40, '', 'builtin:backup'), array(Yii::t('mc', 'Restart'), 40, '', 'builtin:restart'), array(Yii::t('mc', 'Restart if Empty'), 40, '', 'builtin:restart_empty'), array(Yii::t('mc', 'Stop'), 40, '', 'builtin:stop'), array(Yii::t('mc', 'Stop if Empty'), 40, '', 'builtin:stop_empty'), array(Yii::t('mc', 'Start'), 40, '', 'builtin:start'), array(Yii::t('mc', 'Teleport Other'), 40, '', 'builtin:tp_other'));
     foreach ($cmds as $c) {
         $cmd = Command::model()->findByAttributes(array('server_id' => $this->id, 'name' => $c[0]));
         if ($cmd) {
             continue;
         }
         $cmd = new Command();
         $cmd->server_id = $this->id;
         $cmd->name = $c[0];
         $cmd->level = $c[1];
         $cmd->chat = $c[2];
         $cmd->run = $c[3];
         $cmd->save();
     }
 }
Esempio n. 6
0
 case 'project_id':
     $oldProject = Project::model()->findByPk($diffAttr->old);
     if ($oldProject) {
         $diffAttr->old = $oldProject->path;
     }
     $newProject = Project::model()->findByPk($diffAttr->new);
     if ($newProject) {
         $diffAttr->new = $newProject->path;
     }
     break;
 case 'command_id':
     $oldCommand = Command::model()->findByPk($diffAttr->old);
     if ($oldCommand) {
         $diffAttr->old = $oldCommand->name;
     }
     $newCommand = Command::model()->findByPk($diffAttr->new);
     if ($newCommand) {
         $diffAttr->new = $newCommand->name;
     }
     break;
 case 'machine_id':
     $oldMachine = Machine::model()->findByPk($diffAttr->old);
     if ($oldMachine) {
         $diffAttr->old = $oldMachine->name;
     }
     $newMachine = Machine::model()->findByPk($diffAttr->new);
     if ($newMachine) {
         $diffAttr->new = $newMachine->name;
     }
     break;
 case 'crucial':
Esempio n. 7
0
    $attribs[] = array('label' => $form->labelEx($model, 'server_id'), 'type' => 'raw', 'value' => $form->textField($model, 'server_id') . ' ' . $form->error($model, 'server_id'), 'hint' => Yii::t('mc', 'The server ID, use 0 for "Global"'));
    $attribs[] = array('label' => $form->labelEx($model, 'hidden'), 'type' => 'raw', 'value' => $form->checkBox($model, 'hidden') . ' ' . $form->error($model, 'hidden'), 'hint' => Yii::t('mc', 'Only show this task to other superusers'));
}
$attribs[] = array('label' => $form->labelEx($model, 'name'), 'type' => 'raw', 'value' => $form->textField($model, 'name') . ' ' . $form->error($model, 'name'));
if (!$model->isNewRecord) {
    $attribs[] = array('label' => $form->labelEx($model, 'last_run_ts'), 'value' => ($model->last_run_ts ? @date(Yii::t('mc', 'd. M Y, H:i'), $model->last_run_ts) : Yii::t('mc', 'Never')) . $form->error($model, 'last_run_ts'));
    $attribs[] = array('label' => $form->labelEx($model, 'status'), 'value' => Schedule::getStatusValues($model->status));
}
$attribs[] = array('label' => $model->isNewRecord ? $form->labelEx($model, 'status') : Yii::t('mc', 'Change status to'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'status', array(0 => Schedule::getStatusValues(0), 3 => Schedule::getStatusValues(3))) . ' ' . $form->error($model, 'status'));
$attribs[] = array('label' => $form->labelEx($model, 'scheduled_ts'), 'type' => 'raw', 'value' => $this->widget('application.extensions.timepicker.EJuiDateTimePicker', array('value' => @date(Yii::t('mc', 'd. M Y H:i'), $model->scheduled_ts ? $model->scheduled_ts : time()), 'name' => 'scheduled_ts', 'options' => array('dateFormat' => Yii::t('mc', 'dd. M yy'))), true) . ' ' . $form->error($model, 'scheduled_ts'));
$attribs[] = array('name' => 'interval', 'type' => 'raw', 'value' => CHtml::checkBox('ival_do', $model->interval > 0) . ' ' . CHtml::dropDownList('ival_nr', $ival_nr, range(1, 59)) . ' ' . CHtml::dropDownList('ival_type', $ival_type, array(Yii::t('mc', 'Minutes'), Yii::t('mc', 'Hours'), Yii::t('mc', 'Days'))));
$fnd = array('server_id' => (int) $sv);
if (Command::model()->hasAttribute('hidden') && !Yii::app()->user->isSuperuser()) {
    $fnd['hidden'] = 0;
}
$attribs[] = array('name' => $form->labelEx($model, 'command'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'command', array('0' => Yii::t('mc', 'None')) + CHtml::listData(Command::model()->findAllByAttributes($fnd), 'id', 'name')) . ' ' . $form->error($model, 'command'));
$attribs[] = array('name' => $form->labelEx($model, 'args'), 'type' => 'raw', 'value' => $form->textField($model, 'args') . ' ' . $form->error($model, 'command'), 'hint' => Yii::t('mc', 'For example the text for the say command.'));
$players = array(0 => Yii::t('mc', 'Server'), -1 => Yii::t('mc', 'Everyone'));
$cmd = Player::model()->getDbConnection()->createCommand('select `id`, `name` from `player` where `server_id`=?');
$plrs = $cmd->query(array(1 => $model->server_id));
foreach ($plrs as $pl) {
    $players[$pl['id']] = $pl['name'];
}
$attribs[] = array('label' => $form->labelEx($model, 'run_for'), 'type' => 'raw', 'value' => $form->dropDownList($model, 'run_for', $players) . ' ' . $form->error($model, 'run_for'), 'hint' => Yii::t('mc', 'Runs only for players that are online, or always if "Server" is selected.'));
$attribs[] = array('label' => '', 'type' => 'raw', 'value' => CHtml::submitButton($model->isNewRecord ? Yii::t('mc', 'Create') : Yii::t('mc', 'Save')));
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => $attribs));
$this->endWidget();
echo CHtml::script('
function chIval(t)
{
    $("#ival_nr").toggle(t);