예제 #1
0
 /**
  * Updates configuration.
  *
  * @param  	request all values this values for the config update
  * @return 	json    boolean response of true or false in json format (true is success)
  */
 function updateJsonAction()
 {
     $model = new RM_Config();
     $fields = $model->fetchAll();
     foreach ($fields as $field) {
         switch ($field->xtype) {
             case "checkbox":
                 $value = $this->_getParam($field->id);
                 break;
             default:
                 $value = $this->_getParam($field->id, $this->_getParam($field->id . "_hidden"));
         }
         if ($value !== null) {
             $field->value = $value;
             $field->save();
         }
     }
     // process image resizing
     if ($this->_getParam('image_resize', 0) == 1) {
         //1. resize images for media, if we will later add extra options for admin thumnails
         //$mediaManager = new RM_Media_Manager();
         //$mediaManager->resize();
         //2. resize images for units
         $unitModel = new RM_Units();
         $units = $unitModel->fetchAll();
         foreach ($units as $unit) {
             $unitMediaManager = new RM_Media_Unit_Manager($unit);
             $unitMediaManager->resize();
         }
     }
     return array('data' => array('success' => true));
 }
예제 #2
0
 /**
  * Create a copy of all input units. Copy will be exactly the same object with just
  * a different primary key value from main rm database table.
  *
  * @param ids - array from REQUEST
  * @return array
  */
 public function copyJsonAction()
 {
     $unitIDs = $this->_getParam('ids', array());
     $model = new RM_Units();
     $total = $model->fetchAll()->count();
     $trueCopy = array();
     $falseCopy = array();
     foreach ($unitIDs as $unitID) {
         $unit = $model->find($unitID)->current();
         if ($unit !== null) {
             try {
                 $model->copyRow($unit);
                 $trueCopy[] = $unitID;
             } catch (RM_Exception $e) {
                 $falseCopy[$unitID] = $e->getMessage();
             }
         }
     }
     if (count($falseCopy) == 0) {
         $success = true;
         $message = $this->_translate->_('Admin.Units.List', 'CopySuccess');
     } else {
         $success = false;
         $message = $this->_translate->_('Admin.Units.List', 'CopyResult');
         if (count($trueCopy) > 0) {
             $message .= " " . $this->_translate->_('Success') . "(ID) : " . implode(', ', $trueCopy) . " .";
         }
         $message .= " " . $this->_translate->_('Failed') . " : ";
         foreach ($falseCopy as $unitID => $errorMessage) {
             $message .= $unitID . "(ID) - " . $errorMessage;
         }
     }
     return array('data' => array('success' => $success, 'message' => $message));
 }