/**
  * Also show 'unlocked' authz (for locked sources)
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid   (optional)
  * @param array   $extra (optional)
  * @return array $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     $resp = parent::format($mixed, $method, $uuid, $extra);
     // check for fetch-record
     if ($method == 'fetch' && is_a($mixed, 'Doctrine_Record') && isset($resp['authz'])) {
         $resp['authz']['unlock_write'] = $mixed->user_may_write($this->user, false);
         $resp['authz']['unlock_manage'] = $mixed->user_may_manage($this->user, false);
     }
     return $resp;
 }
 /**
  * Add a title for the CSV file
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid  (optional)
  * @param array   $extra (optional)
  * @return array  $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     $resp = parent::format($mixed, $method, $uuid, $extra);
     $resp['filename'] = 'pinfluence_export.csv';
     return $resp;
 }
 /**
  * Override to include user_may_send authz tests
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid   (optional)
  * @param array   $extra  (optional)
  * @return array $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     $resp = parent::format($mixed, $method, $uuid, $extra);
     if ($method == 'fetch' && is_a($mixed, 'Doctrine_Record')) {
         $resp['authz']['may_send'] = $mixed->user_may_send($this->user);
     }
     return $resp;
 }
 /**
  * Add "Conflict-With" data to fetch
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid   (optional)
  * @param array   $extra  (optional)
  * @return array $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     $data = parent::format($mixed, $method, $uuid, $extra);
     // only add on update/fetch, and only when status = CONFLICT
     if (!$data['success']) {
         return $data;
     }
     if ($method != 'update' && $method != 'fetch') {
         return $data;
     }
     if ($data['radix']['tsrc_status'] != TankSource::$STATUS_CONFLICT) {
         return $data;
     }
     // look for conflicts with something
     $withs = array();
     $cons = json_decode($data['radix']['tsrc_errors'], true);
     if ($cons) {
         if (isset($cons['initial'])) {
             foreach ($cons['initial'] as $key => $confl) {
                 if ($c = $this->_get_with($key, $confl)) {
                     $withs[$key] = $c;
                 }
             }
         }
         // make sure we didn't miss any
         if (isset($cons['last'])) {
             foreach ($cons['initial'] as $key => $confl) {
                 if (!isset($withs[$key]) && ($c = $this->_get_with($key, $confl))) {
                     $withs[$key] = $c;
                 }
             }
         }
     }
     $data['radix']['tsrc_withs'] = $withs;
     // also return the tsrc_id of the next conflict (if any)
     $conn = AIR2_DBManager::get_connection();
     $tid = $this->parent_rec->tank_id;
     $tsid = $data['radix']['tsrc_id'];
     $st = TankSource::$STATUS_CONFLICT;
     $q = "select tsrc_id from tank_source where tsrc_tank_id = ? " . "and tsrc_id != ? and tsrc_status = ? limit 1";
     $next = $conn->fetchOne($q, array($tid, $tsid, $st), 0);
     $data['radix']['next_conflict'] = $next;
     return $data;
 }
 /**
  * Add extra data
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid   (optional)
  * @param array   $extra (optional)
  * @return array $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     $resp = parent::format($mixed, $method, $uuid, $extra);
     $resp['meta'] = array_merge($resp['meta'], $this->preview_extra);
     // include some header-validation data
     if (is_a($mixed, 'CSVImporter')) {
         $hdr_msg = $mixed->validate_headers();
         $hdr_valid = $hdr_msg === true ? true : false;
         if (!$hdr_valid) {
             $resp['message'] = $hdr_msg;
         }
         $this->parent_rec->set_meta_field('valid_header', $hdr_valid);
         $this->parent_rec->save();
     }
     return $resp;
 }
Exemplo n.º 6
0
 /**
  * Add 'bulk' operation data to $extra params
  *
  * @param mixed   $mixed
  * @param string  $method
  * @param string  $uuid  (optional)
  * @param array   $extra (optional)
  * @return array  $response
  */
 protected function format($mixed, $method, $uuid = null, $extra = array())
 {
     if ($method == 'update' && $this->bulk_op) {
         $extra['bulk_op'] = $this->bulk_op;
         $extra['bulk_rs'] = $this->bulk_rs;
     }
     return parent::format($mixed, $method, $uuid, $extra);
 }