/**
  * Action permettant d'enregistrer ou de mettre à jour automatiquement un device
  *
  * @param sfWebRequest $request
  */
 public function execute($request)
 {
     $this->getResponse()->setContentType('application/json');
     $this->setLayout(false);
     if ($request->getPostParameter('drivers') == null) {
         $response = array("error" => "Error with the post parameters drivers.", "success" => false);
     } else {
         $JSONArray = json_decode($request->getPostParameter('drivers'));
         //die("json: ".$JSONArray. " / error:".json_last_error());
         $device_identifier = $request->getParameter('device_identifier');
         $device_type_name = $request->getParameter('device_type');
         $response = array("error" => "An error occured when we try to create / update the device.", "success" => false);
         try {
             $device = Doctrine_Core::getTable("EiDevice")->findOneBy("device_identifier", $device_identifier);
             if ($device != null) {
                 /* Si le device existe, on efface ses drivers (les browsers sont effacés en cascade) */
                 $device_drivers = $device->getEiDeviceDriver();
                 foreach ($device_drivers as $device_driver) {
                     $device_driver->delete();
                 }
             } else {
                 /* Sinon on créé ce device */
                 $device = new EiDevice();
                 $device->setDeviceIdentifier($device_identifier);
                 $device_type = Doctrine_Core::getTable('EiDeviceType')->findOneBy('hidden_name', $device_type_name);
                 $device->setDeviceTypeId($device_type);
                 $device->save();
             }
             /* On créé les drivers et browsers de ces drivers pour le device */
             foreach ($JSONArray as $driver) {
                 $driver_type_name = $driver->{'driver_type'};
                 $driver_type = Doctrine_Core::getTable("EiDriverType")->findOneBy("hidden_name", $driver_type_name);
                 $device_driver = new EiDeviceDriver();
                 $device_driver->setDeviceId($device->getId());
                 $device_driver->setDriverTypeId($driver_type->getId());
                 $device_driver->save();
                 foreach ($driver->{'browsers'} as $browser_name) {
                     $browser_type = Doctrine_Core::getTable("EiBrowserType")->findOneBy("hidden_name", $browser_name);
                     $driver_browser = new EiDriverBrowser();
                     $driver_browser->setDeviceDriverId($device_driver->getId());
                     $driver_browser->setBrowserTypeId($browser_type->getId());
                     $driver_browser->save();
                 }
             }
             unset($response["error"]);
             $response["success"] = true;
         } catch (Exception $e) {
             $response = array("error" => "Exception : An error occured when we try to create / update the device: " . $e->getMessage());
         }
     }
     return $this->renderText(json_encode($response));
 }
Example #2
0
                            <?php 
        echo $my_device['device_identifier'];
        ?>
                        </td>
                        <td>
                            <img src="<?php 
        echo sfConfig::get($my_device['logo_path']);
        ?>
" width="20" height="20" />&nbsp;
                            <?php 
        echo $my_device['name'];
        ?>
                        </td>
                        <td>
                            <?php 
        EiDevice::displayDrivers($my_device['device_id']);
        ?>
                        </td>
                        <td>
                            <!--<a class="btn btn-sm btn-success" role="button" data-toggle="modal" title="Edit device" href="#editDevice">
                                <?php 
        echo ei_icon('ei_edit');
        ?>
 Edit
                            </a>-->
                            <a href="<?php 
        echo url_for2('resourcesDeviceDisown', array('device_id' => $my_device['id']));
        ?>
" role="button" class="btn btn-sm btn-danger" data-toggle="modal" title="Remove device from my devices">
                                <?php 
        echo ei_icon('ei_unlink');
Example #3
0
" data-player-nom="<?php 
    echo $ei_scenario->getNomScenario();
    ?>
" data-toggle="dropdown">
<!--                    <img src="/images/icones/playWebDriver.gif" alt="" width="22" height="22" />-->
                    <span id="deviceImgWebDrivers">
                    </span>
                    <span class="caret"></span>
                </a>

                <ul class="dropdown-menu open" id="webDriverDropdown">
                    <?php 
    /*foreach( EiDeviceUserTable::getMyDevices($sf_user->getEiUser()->getUserId()) as $device ){
          include_partial("eiscenario/deviceChoice", array("device" => $device));
      }*/
    EiDevice::displayDevicesList($sf_user->getEiUser()->getUserId());
    ?>
                </ul>
            </div>

            <div class="text" id="btnSwitchExecutionMenuContainer">
                <a href="#" title="Open/Close execution menu" id="btnSwitchExecutionMenu">
                    <?php 
    echo ei_icon('ei_user_settings', '', 'fa-2x');
    ?>
                </a>
            </div>
            
            <div class="text">
                <span class="hidden-sm hidden-xs hidden-md hidden-lg">Play</span>
                <a href="#" title="Play scenario" class="disabledOracle" id="btnPlayScenarioInIde" data-player-jdd="<?php 
Example #4
0
                                                <?php 
        echo $available_device['device_identifier'];
        ?>
                                            </td>
                                            <td>
                                                <img src="<?php 
        echo sfConfig::get($available_device['logo_path']);
        ?>
" width="20" height="20" />&nbsp;
                                                <?php 
        echo $available_device['name'];
        ?>
                                            </td>
                                            <td>
                                                <?php 
        EiDevice::displayDrivers($available_device['id']);
        ?>
                                            </td>
                                            <td>
                                                <?php 
        echo $form['device_id']->renderError();
        ?>
                                                <input name="ei_device_user[device_id]" type="radio" value="<?php 
        echo $available_device['id'];
        ?>
" id="ei_device_user_device_id_<?php 
        echo $available_device['id'];
        ?>
">
                                            </td>
                                        </tr>