コード例 #1
0
ファイル: PrevNextCache.php プロジェクト: kidaa30/yes
 /**
  * Returns the list of fields that can be exported
  *
  * @param bool $prefix
  *
  * @return array
  */
 static function &export($prefix = false)
 {
     if (!self::$_export) {
         self::$_export = array();
         $fields = self::fields();
         foreach ($fields as $name => $field) {
             if (CRM_Utils_Array::value('export', $field)) {
                 if ($prefix) {
                     self::$_export['prevnext_cache'] =& $fields[$name];
                 } else {
                     self::$_export[$name] =& $fields[$name];
                 }
             }
         }
     }
     return self::$_export;
 }
コード例 #2
0
 public static function markConflict($id1, $id2, $cacheKey, $conflicts)
 {
     if (empty($cacheKey) || empty($conflicts)) {
         return FALSE;
     }
     $sql = "SELECT pn.*\n      FROM  civicrm_prevnext_cache pn\n      WHERE\n      ((pn.entity_id1 = %1 AND pn.entity_id2 = %2) OR (pn.entity_id1 = %2 AND pn.entity_id2 = %1)) AND\n      (cacheKey = %3 OR cacheKey = %4)";
     $params = array(1 => array($id1, 'Integer'), 2 => array($id2, 'Integer'), 3 => array("{$cacheKey}", 'String'), 4 => array("{$cacheKey}_conflicts", 'String'));
     $pncFind = CRM_Core_DAO::executeQuery($sql, $params);
     while ($pncFind->fetch()) {
         $data = $pncFind->data;
         if (!empty($data)) {
             $data = unserialize($data);
             $data['conflicts'] = implode(",", array_values($conflicts));
             $pncUp = new CRM_Core_DAO_PrevNextCache();
             $pncUp->id = $pncFind->id;
             if ($pncUp->find(TRUE)) {
                 $pncUp->data = serialize($data);
                 $pncUp->cacheKey = "{$cacheKey}_conflicts";
                 $pncUp->save();
             }
         }
     }
     return TRUE;
 }
コード例 #3
0
 /**
  * Flip 2 contacts in the prevNext cache.
  *
  * @param array $prevNextId
  * @param bool $onlySelected
  *   Only flip those which have been marked as selected.
  */
 public static function flipPair(array $prevNextId, $onlySelected)
 {
     $dao = new CRM_Core_DAO_PrevNextCache();
     if ($onlySelected) {
         $dao->is_selected = 1;
     }
     foreach ($prevNextId as $id) {
         $dao->id = $id;
         if ($dao->find(TRUE)) {
             $originalData = unserialize($dao->data);
             $srcFields = array('ID', 'Name');
             $swapFields = array('srcID', 'srcName', 'dstID', 'dstName');
             $data = array_diff_assoc($originalData, array_fill_keys($swapFields, 1));
             foreach ($srcFields as $key) {
                 $data['src' . $key] = $originalData['dst' . $key];
                 $data['dst' . $key] = $originalData['src' . $key];
             }
             $dao->data = serialize($data);
             $dao->entity_id1 = $data['dstID'];
             $dao->entity_id2 = $data['srcID'];
             $dao->save();
         }
     }
 }