Ejemplo n.º 1
0
 /**
  * @param integer $id
  * @param string $category_id
  * @param string $name
  * @param string $min_value
  * @param string $max_value
  * @param string $min_prefix_exponent
  * @param string $max_prefix_exponent
  * @param string $prefix_calculcation_exponent
  * @param string $calculation
  * @param string $type
  * @return integer
  * @throws BaseUserAccessDeniedException
  */
 public static function set_measuring_unit($id, $category_id, $name, $symbol, $min_value, $max_value, $min_prefix_exponent, $max_prefix_exponent, $prefix_calculation_exponent, $calculation, $type)
 {
     global $user;
     if ($user->is_admin()) {
         if (is_numeric($id) and $name and $symbol) {
             $measuring_unit = new MeasuringUnit($id);
             if ($measuring_unit->set_category_id($category_id) == false) {
                 return "0";
             }
             if ($measuring_unit->set_name($name) == false) {
                 return "0";
             }
             if ($measuring_unit->set_unit_symbol($symbol) == false) {
                 return "0";
             }
             if ($measuring_unit->set_min_value($min_value) == false) {
                 return "0";
             }
             if ($measuring_unit->set_max_value($max_value) == false) {
                 return "0";
             }
             if ($measuring_unit->set_min_prefix_exponent($min_prefix_exponent) == false) {
                 return "0";
             }
             if ($measuring_unit->set_max_prefix_exponent($max_prefix_exponent) == false) {
                 return "0";
             }
             if ($measuring_unit->set_prefix_calculation_exponent($prefix_calculation_exponent) == false) {
                 return "0";
             }
             if ($measuring_unit->set_calculation($calculation) == false) {
                 return "0";
             }
             if ($measuring_unit->set_type($type) == false) {
                 return "0";
             }
             return "1";
         } else {
             return "0";
         }
     } else {
         throw new BaseUserAccessDeniedException();
     }
 }